Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_ScrollBar.cpp

Issue 1258093002: FX Bool considered harmful, part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_Note.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Signature.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../include/pdfwindow/PDFWindow.h" 7 #include "../../include/pdfwindow/PDFWindow.h"
8 #include "../../include/pdfwindow/PWL_Wnd.h" 8 #include "../../include/pdfwindow/PWL_Wnd.h"
9 #include "../../include/pdfwindow/PWL_ScrollBar.h" 9 #include "../../include/pdfwindow/PWL_ScrollBar.h"
10 #include "../../include/pdfwindow/PWL_Utils.h" 10 #include "../../include/pdfwindow/PWL_Utils.h"
(...skipping 29 matching lines...) Expand all
40 fMin = max; 40 fMin = max;
41 fMax = min; 41 fMax = min;
42 } 42 }
43 else 43 else
44 { 44 {
45 fMin = min; 45 fMin = min;
46 fMax = max; 46 fMax = max;
47 } 47 }
48 } 48 }
49 49
50 FX_BOOL»PWL_FLOATRANGE::In(FX_FLOAT x) const 50 bool» PWL_FLOATRANGE::In(FX_FLOAT x) const
51 { 51 {
52 return (IsFloatBigger(x,fMin) || IsFloatEqual(x, fMin)) && 52 return (IsFloatBigger(x,fMin) || IsFloatEqual(x, fMin)) &&
53 (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax)); 53 (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax));
54 } 54 }
55 55
56 FX_FLOAT PWL_FLOATRANGE::GetWidth() const 56 FX_FLOAT PWL_FLOATRANGE::GetWidth() const
57 { 57 {
58 return fMax - fMin; 58 return fMax - fMin;
59 } 59 }
60 60
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step) 92 void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step)
93 { 93 {
94 fSmallStep = step; 94 fSmallStep = step;
95 } 95 }
96 96
97 void PWL_SCROLL_PRIVATEDATA::SetBigStep(FX_FLOAT step) 97 void PWL_SCROLL_PRIVATEDATA::SetBigStep(FX_FLOAT step)
98 { 98 {
99 fBigStep = step; 99 fBigStep = step;
100 } 100 }
101 101
102 FX_BOOL PWL_SCROLL_PRIVATEDATA::SetPos(FX_FLOAT pos) 102 bool PWL_SCROLL_PRIVATEDATA::SetPos(FX_FLOAT pos)
103 { 103 {
104 if (ScrollRange.In(pos)) 104 if (ScrollRange.In(pos))
105 { 105 {
106 fScrollPos = pos; 106 fScrollPos = pos;
107 » » return TRUE; 107 » » return true;
108 } 108 }
109 » return FALSE; 109 » return false;
110 } 110 }
111 111
112 void PWL_SCROLL_PRIVATEDATA::AddSmall() 112 void PWL_SCROLL_PRIVATEDATA::AddSmall()
113 { 113 {
114 if (!SetPos(fScrollPos + fSmallStep)) 114 if (!SetPos(fScrollPos + fSmallStep))
115 SetPos(ScrollRange.fMax); 115 SetPos(ScrollRange.fMax);
116 } 116 }
117 117
118 void PWL_SCROLL_PRIVATEDATA::SubSmall() 118 void PWL_SCROLL_PRIVATEDATA::SubSmall()
119 { 119 {
(...skipping 13 matching lines...) Expand all
133 SetPos(ScrollRange.fMin); 133 SetPos(ScrollRange.fMin);
134 } 134 }
135 135
136 /* ------------------------------- CPWL_SBButton ------------------------------- */ 136 /* ------------------------------- CPWL_SBButton ------------------------------- */
137 137
138 CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,PWL_SBBUTTON_TYPE eButtonType) 138 CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,PWL_SBBUTTON_TYPE eButtonType)
139 { 139 {
140 m_eScrollBarType = eScrollBarType; 140 m_eScrollBarType = eScrollBarType;
141 m_eSBButtonType = eButtonType; 141 m_eSBButtonType = eButtonType;
142 142
143 » m_bMouseDown = FALSE; 143 » m_bMouseDown = false;
144 } 144 }
145 145
146 CPWL_SBButton::~CPWL_SBButton() 146 CPWL_SBButton::~CPWL_SBButton()
147 { 147 {
148 148
149 } 149 }
150 150
151 CFX_ByteString CPWL_SBButton::GetClassName() const 151 CFX_ByteString CPWL_SBButton::GetClassName() const
152 { 152 {
153 return "CPWL_SBButton"; 153 return "CPWL_SBButton";
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 //draw inner border 352 //draw inner border
353 rcDraw = CPWL_Utils::DeflateRect(rectWnd,0.5f); 353 rcDraw = CPWL_Utils::DeflateRect(rectWnd,0.5f);
354 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device , rcDraw, 354 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device , rcDraw,
355 ArgbEncode(nTransparancy,255,255,255),1. 0f); 355 ArgbEncode(nTransparancy,255,255,255),1. 0f);
356 356
357 //draw background 357 //draw background
358 358
359 rcDraw = CPWL_Utils::DeflateRect(rectWnd,1.0f); 359 rcDraw = CPWL_Utils::DeflateRect(rectWnd,1.0f);
360 360
361 if (IsEnabled()) 361 if (IsEnabled())
362 » » » » » CPWL_Utils::DrawShadow(pDevice, pUser2De vice, TRUE, FALSE, rcDraw, nTransparancy, 80, 220); 362 » » » » » CPWL_Utils::DrawShadow(pDevice, pUser2De vice, true, false, rcDraw, nTransparancy, 80, 220);
363 else 363 else
364 CPWL_Utils::DrawFillRect(pDevice, pUser2 Device, rcDraw, ArgbEncode(255,255,255,255)); 364 CPWL_Utils::DrawFillRect(pDevice, pUser2 Device, rcDraw, ArgbEncode(255,255,255,255));
365 365
366 //draw arrow 366 //draw arrow
367 367
368 if (rectWnd.top - rectWnd.bottom > 6.0f ) 368 if (rectWnd.top - rectWnd.bottom > 6.0f )
369 { 369 {
370 FX_FLOAT fX = rectWnd.left + 1.5f; 370 FX_FLOAT fX = rectWnd.left + 1.5f;
371 FX_FLOAT fY = rectWnd.bottom; 371 FX_FLOAT fY = rectWnd.bottom;
372 CPDF_Point pts[7] = { 372 CPDF_Point pts[7] = {
(...skipping 22 matching lines...) Expand all
395 ArgbEncode(nTransparancy,100,100,100),0. 0f); 395 ArgbEncode(nTransparancy,100,100,100),0. 0f);
396 396
397 //draw inner border 397 //draw inner border
398 rcDraw = CPWL_Utils::DeflateRect(rectWnd,0.5f); 398 rcDraw = CPWL_Utils::DeflateRect(rectWnd,0.5f);
399 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device , rcDraw, 399 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device , rcDraw,
400 ArgbEncode(nTransparancy,255,255,255),1. 0f); 400 ArgbEncode(nTransparancy,255,255,255),1. 0f);
401 401
402 //draw background 402 //draw background
403 rcDraw = CPWL_Utils::DeflateRect(rectWnd,1.0f); 403 rcDraw = CPWL_Utils::DeflateRect(rectWnd,1.0f);
404 if (IsEnabled()) 404 if (IsEnabled())
405 » » » » » CPWL_Utils::DrawShadow(pDevice, pUser2De vice, TRUE, FALSE, rcDraw, nTransparancy, 80, 220); 405 » » » » » CPWL_Utils::DrawShadow(pDevice, pUser2De vice, true, false, rcDraw, nTransparancy, 80, 220);
406 else 406 else
407 CPWL_Utils::DrawFillRect(pDevice, pUser2 Device, rcDraw, ArgbEncode(255,255,255,255)); 407 CPWL_Utils::DrawFillRect(pDevice, pUser2 Device, rcDraw, ArgbEncode(255,255,255,255));
408 408
409 //draw arrow 409 //draw arrow
410 410
411 if (rectWnd.top - rectWnd.bottom > 6.0f ) 411 if (rectWnd.top - rectWnd.bottom > 6.0f )
412 { 412 {
413 FX_FLOAT fX = rectWnd.left + 1.5f; 413 FX_FLOAT fX = rectWnd.left + 1.5f;
414 FX_FLOAT fY = rectWnd.bottom; 414 FX_FLOAT fY = rectWnd.bottom;
415 415
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 break; 558 break;
559 default: 559 default:
560 break; 560 break;
561 } 561 }
562 break; 562 break;
563 default: 563 default:
564 break; 564 break;
565 } 565 }
566 } 566 }
567 567
568 FX_BOOL CPWL_SBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) 568 bool CPWL_SBButton::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
569 { 569 {
570 CPWL_Wnd::OnLButtonDown(point,nFlag); 570 CPWL_Wnd::OnLButtonDown(point,nFlag);
571 571
572 if (CPWL_Wnd * pParent = GetParentWindow()) 572 if (CPWL_Wnd * pParent = GetParentWindow())
573 pParent->OnNotify(this,PNM_LBUTTONDOWN,0,(intptr_t)&point); 573 pParent->OnNotify(this,PNM_LBUTTONDOWN,0,(intptr_t)&point);
574 574
575 » m_bMouseDown = TRUE; 575 » m_bMouseDown = true;
576 SetCapture(); 576 SetCapture();
577 577
578 » return TRUE; 578 » return true;
579 } 579 }
580 580
581 FX_BOOL CPWL_SBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) 581 bool CPWL_SBButton::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
582 { 582 {
583 CPWL_Wnd::OnLButtonUp(point,nFlag); 583 CPWL_Wnd::OnLButtonUp(point,nFlag);
584 584
585 if (CPWL_Wnd * pParent = GetParentWindow()) 585 if (CPWL_Wnd * pParent = GetParentWindow())
586 pParent->OnNotify(this,PNM_LBUTTONUP,0,(intptr_t)&point); 586 pParent->OnNotify(this,PNM_LBUTTONUP,0,(intptr_t)&point);
587 587
588 » m_bMouseDown = FALSE; 588 » m_bMouseDown = false;
589 ReleaseCapture(); 589 ReleaseCapture();
590 590
591 » return TRUE; 591 » return true;
592 } 592 }
593 593
594 FX_BOOL CPWL_SBButton::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag) 594 bool CPWL_SBButton::OnMouseMove(const CPDF_Point & point, FX_DWORD nFlag)
595 { 595 {
596 CPWL_Wnd::OnMouseMove(point,nFlag); 596 CPWL_Wnd::OnMouseMove(point,nFlag);
597 597
598 if (CPWL_Wnd * pParent = GetParentWindow()) 598 if (CPWL_Wnd * pParent = GetParentWindow())
599 { 599 {
600 pParent->OnNotify(this,PNM_MOUSEMOVE,0,(intptr_t)&point); 600 pParent->OnNotify(this,PNM_MOUSEMOVE,0,(intptr_t)&point);
601 601
602 /* 602 /*
603 if (m_bMouseDown && (m_eSBButtonType == PSBT_MIN || m_eSBButtonT ype == PSBT_MAX)) 603 if (m_bMouseDown && (m_eSBButtonType == PSBT_MIN || m_eSBButtonT ype == PSBT_MAX))
604 { 604 {
605 if (!pParent->OnNotify(this,PNM_LBUTTONDOWN,nFlags,(intp tr_t)&point)) 605 if (!pParent->OnNotify(this,PNM_LBUTTONDOWN,nFlags,(intp tr_t)&point))
606 » » » » return FALSE; 606 » » » » return false;
607 } 607 }
608 */ 608 */
609 } 609 }
610 610
611 » return TRUE; 611 » return true;
612 } 612 }
613 613
614 /* ------------------------------- CPWL_ScrollBar ------------------------------ ---- */ 614 /* ------------------------------- CPWL_ScrollBar ------------------------------ ---- */
615 615
616 CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType): 616 CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType):
617 m_sbType(sbType), 617 m_sbType(sbType),
618 m_pMinButton(NULL), 618 m_pMinButton(NULL),
619 m_pMaxButton(NULL), 619 m_pMaxButton(NULL),
620 m_pPosButton(NULL), 620 m_pPosButton(NULL),
621 » m_bMouseDown(FALSE), 621 » m_bMouseDown(false),
622 » m_bMinOrMax(FALSE), 622 » m_bMinOrMax(false),
623 » m_bNotifyForever(TRUE) 623 » m_bNotifyForever(true)
624 { 624 {
625 } 625 }
626 626
627 CPWL_ScrollBar::~CPWL_ScrollBar() 627 CPWL_ScrollBar::~CPWL_ScrollBar()
628 { 628 {
629 } 629 }
630 630
631 CFX_ByteString CPWL_ScrollBar::GetClassName() const 631 CFX_ByteString CPWL_ScrollBar::GetClassName() const
632 { 632 {
633 return "CPWL_ScrollBar"; 633 return "CPWL_ScrollBar";
(...skipping 24 matching lines...) Expand all
658 { 658 {
659 fBWidth = (rcClient.right - rcClient.left - PWL_SCROLLBA R_POSBUTTON_MINWIDTH - 2) / 2; 659 fBWidth = (rcClient.right - rcClient.left - PWL_SCROLLBA R_POSBUTTON_MINWIDTH - 2) / 2;
660 660
661 if (fBWidth > 0) 661 if (fBWidth > 0)
662 { 662 {
663 rcMinButton = CPDF_Rect(rcClient.left,rcClient.b ottom, 663 rcMinButton = CPDF_Rect(rcClient.left,rcClient.b ottom,
664 rcClient.left + fBWidth,rcClient.top); 664 rcClient.left + fBWidth,rcClient.top);
665 rcMaxButton = CPDF_Rect(rcClient.right - fBWidth ,rcClient.bottom, 665 rcMaxButton = CPDF_Rect(rcClient.right - fBWidth ,rcClient.bottom,
666 rcClient.right,rcClient.top); 666 rcClient.right,rcClient.top);
667 } 667 }
668 » » » else SetVisible(FALSE); 668 » » » else SetVisible(false);
669 } 669 }
670 break; 670 break;
671 case SBT_VSCROLL: 671 case SBT_VSCROLL:
672 if (IsFloatBigger(rcClient.top - rcClient.bottom, PWL_SCROLLBAR_ BUTTON_WIDTH * 2 + PWL_SCROLLBAR_POSBUTTON_MINWIDTH + 2)) 672 if (IsFloatBigger(rcClient.top - rcClient.bottom, PWL_SCROLLBAR_ BUTTON_WIDTH * 2 + PWL_SCROLLBAR_POSBUTTON_MINWIDTH + 2))
673 { 673 {
674 rcMinButton = CPDF_Rect(rcClient.left,rcClient.top - PWL _SCROLLBAR_BUTTON_WIDTH, 674 rcMinButton = CPDF_Rect(rcClient.left,rcClient.top - PWL _SCROLLBAR_BUTTON_WIDTH,
675 rcClient.right,rcClient.top); 675 rcClient.right,rcClient.top);
676 rcMaxButton = CPDF_Rect(rcClient.left,rcClient.bottom, 676 rcMaxButton = CPDF_Rect(rcClient.left,rcClient.bottom,
677 rcClient.right,rcClient.bottom + PWL_SCROLLBAR_B UTTON_WIDTH); 677 rcClient.right,rcClient.bottom + PWL_SCROLLBAR_B UTTON_WIDTH);
678 } 678 }
679 else 679 else
680 { 680 {
681 fBWidth = (rcClient.top - rcClient.bottom - PWL_SCROLLBA R_POSBUTTON_MINWIDTH - 2) / 2; 681 fBWidth = (rcClient.top - rcClient.bottom - PWL_SCROLLBA R_POSBUTTON_MINWIDTH - 2) / 2;
682 682
683 if (IsFloatBigger(fBWidth, 0)) 683 if (IsFloatBigger(fBWidth, 0))
684 { 684 {
685 rcMinButton = CPDF_Rect(rcClient.left,rcClient.t op - fBWidth, 685 rcMinButton = CPDF_Rect(rcClient.left,rcClient.t op - fBWidth,
686 rcClient.right,rcClient.top); 686 rcClient.right,rcClient.top);
687 rcMaxButton = CPDF_Rect(rcClient.left,rcClient.b ottom, 687 rcMaxButton = CPDF_Rect(rcClient.left,rcClient.b ottom,
688 rcClient.right,rcClient.bottom + fBWidth ); 688 rcClient.right,rcClient.bottom + fBWidth );
689 } 689 }
690 » » » else SetVisible(FALSE); 690 » » » else SetVisible(false);
691 } 691 }
692 break; 692 break;
693 } 693 }
694 694
695 if (m_pMinButton) 695 if (m_pMinButton)
696 m_pMinButton->Move(rcMinButton, TRUE, FALSE); 696 m_pMinButton->Move(rcMinButton, true, false);
697 if (m_pMaxButton) 697 if (m_pMaxButton)
698 m_pMaxButton->Move(rcMaxButton, TRUE, FALSE); 698 m_pMaxButton->Move(rcMaxButton, true, false);
699 MovePosButton(FALSE); 699 MovePosButton(false);
700 } 700 }
701 701
702 void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) 702 void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
703 { 703 {
704 CPDF_Rect rectWnd = GetWindowRect(); 704 CPDF_Rect rectWnd = GetWindowRect();
705 705
706 if (IsVisible() && !rectWnd.IsEmpty()) 706 if (IsVisible() && !rectWnd.IsEmpty())
707 { 707 {
708 CFX_ByteTextBuf sButton; 708 CFX_ByteTextBuf sButton;
709 709
710 sButton << "q\n"; 710 sButton << "q\n";
711 » » sButton << "0 w\n" << CPWL_Utils::GetColorAppStream(GetBackgroun dColor(),TRUE); 711 » » sButton << "0 w\n" << CPWL_Utils::GetColorAppStream(GetBackgroun dColor(),true);
712 sButton << rectWnd.left << " " << rectWnd.bottom << " " 712 sButton << rectWnd.left << " " << rectWnd.bottom << " "
713 << rectWnd.right - rectWnd.left << " " << rectWn d.top - rectWnd.bottom << " re b Q\n"; 713 << rectWnd.right - rectWnd.left << " " << rectWn d.top - rectWnd.bottom << " re b Q\n";
714 714
715 sAppStream << sButton; 715 sAppStream << sButton;
716 } 716 }
717 } 717 }
718 718
719 void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device) 719 void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
720 { 720 {
721 CPDF_Rect rectWnd = GetWindowRect(); 721 CPDF_Rect rectWnd = GetWindowRect();
722 722
723 if (IsVisible() && !rectWnd.IsEmpty()) 723 if (IsVisible() && !rectWnd.IsEmpty())
724 { 724 {
725 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd, GetBack groundColor(), GetTransparency()); 725 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rectWnd, GetBack groundColor(), GetTransparency());
726 726
727 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, 727 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device,
728 CPDF_Point(rectWnd.left+2.0f,rectWnd.top-2.0f), CPDF_Poi nt(rectWnd.left+2.0f,rectWnd.bottom+2.0f), 728 CPDF_Point(rectWnd.left+2.0f,rectWnd.top-2.0f), CPDF_Poi nt(rectWnd.left+2.0f,rectWnd.bottom+2.0f),
729 ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f); 729 ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
730 730
731 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, 731 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device,
732 CPDF_Point(rectWnd.right-2.0f,rectWnd.top-2.0f), CPDF_Po int(rectWnd.right-2.0f,rectWnd.bottom+2.0f), 732 CPDF_Point(rectWnd.right-2.0f,rectWnd.top-2.0f), CPDF_Po int(rectWnd.right-2.0f,rectWnd.bottom+2.0f),
733 ArgbEncode(GetTransparency(), 100, 100, 100),1.0f); 733 ArgbEncode(GetTransparency(), 100, 100, 100),1.0f);
734 } 734 }
735 } 735 }
736 736
737 FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag) 737 bool CPWL_ScrollBar::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
738 { 738 {
739 CPWL_Wnd::OnLButtonDown(point,nFlag); 739 CPWL_Wnd::OnLButtonDown(point,nFlag);
740 740
741 if (HasFlag(PWS_AUTOTRANSPARENT)) 741 if (HasFlag(PWS_AUTOTRANSPARENT))
742 { 742 {
743 if (GetTransparency() != 255) 743 if (GetTransparency() != 255)
744 { 744 {
745 SetTransparency(255); 745 SetTransparency(255);
746 InvalidateRect(); 746 InvalidateRect();
747 } 747 }
(...skipping 22 matching lines...) Expand all
770 rcClient.right,rcPosButt on.bottom); 770 rcClient.right,rcPosButt on.bottom);
771 break; 771 break;
772 } 772 }
773 773
774 rcMinArea.Normalize(); 774 rcMinArea.Normalize();
775 rcMaxArea.Normalize(); 775 rcMaxArea.Normalize();
776 776
777 if (rcMinArea.Contains(point.x,point.y)) 777 if (rcMinArea.Contains(point.x,point.y))
778 { 778 {
779 m_sData.SubBig(); 779 m_sData.SubBig();
780 » » » MovePosButton(TRUE); 780 » » » MovePosButton(true);
781 NotifyScrollWindow(); 781 NotifyScrollWindow();
782 } 782 }
783 783
784 if (rcMaxArea.Contains(point.x,point.y)) 784 if (rcMaxArea.Contains(point.x,point.y))
785 { 785 {
786 m_sData.AddBig(); 786 m_sData.AddBig();
787 » » » MovePosButton(TRUE); 787 » » » MovePosButton(true);
788 NotifyScrollWindow(); 788 NotifyScrollWindow();
789 } 789 }
790 } 790 }
791 791
792 » return TRUE; 792 » return true;
793 } 793 }
794 794
795 FX_BOOL CPWL_ScrollBar::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag) 795 bool CPWL_ScrollBar::OnLButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
796 { 796 {
797 CPWL_Wnd::OnLButtonUp(point,nFlag); 797 CPWL_Wnd::OnLButtonUp(point,nFlag);
798 798
799 if (HasFlag(PWS_AUTOTRANSPARENT)) 799 if (HasFlag(PWS_AUTOTRANSPARENT))
800 { 800 {
801 if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY) 801 if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY)
802 { 802 {
803 SetTransparency(PWL_SCROLLBAR_TRANSPARANCY); 803 SetTransparency(PWL_SCROLLBAR_TRANSPARANCY);
804 InvalidateRect(); 804 InvalidateRect();
805 } 805 }
806 } 806 }
807 807
808 EndTimer(); 808 EndTimer();
809 » m_bMouseDown = FALSE; 809 » m_bMouseDown = false;
810 810
811 » return TRUE; 811 » return true;
812 } 812 }
813 813
814 void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, int ptr_t lParam) 814 void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, int ptr_t lParam)
815 { 815 {
816 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam); 816 CPWL_Wnd::OnNotify(pWnd,msg,wParam,lParam);
817 817
818 switch (msg) 818 switch (msg)
819 { 819 {
820 case PNM_LBUTTONDOWN: 820 case PNM_LBUTTONDOWN:
821 if (pWnd == m_pMinButton) 821 if (pWnd == m_pMinButton)
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 915
916 if (!m_pMaxButton) 916 if (!m_pMaxButton)
917 { 917 {
918 m_pMaxButton = new CPWL_SBButton(m_sbType,PSBT_MAX); 918 m_pMaxButton = new CPWL_SBButton(m_sbType,PSBT_MAX);
919 m_pMaxButton->Create(scp); 919 m_pMaxButton->Create(scp);
920 } 920 }
921 921
922 if (!m_pPosButton) 922 if (!m_pPosButton)
923 { 923 {
924 m_pPosButton = new CPWL_SBButton(m_sbType,PSBT_POS); 924 m_pPosButton = new CPWL_SBButton(m_sbType,PSBT_POS);
925 » » m_pPosButton->SetVisible(FALSE); 925 » » m_pPosButton->SetVisible(false);
926 m_pPosButton->Create(scp); 926 m_pPosButton->Create(scp);
927 } 927 }
928 } 928 }
929 929
930 FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const 930 FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const
931 { 931 {
932 if (!IsVisible()) return 0; 932 if (!IsVisible()) return 0;
933 933
934 return PWL_SCROLLBAR_WIDTH; 934 return PWL_SCROLLBAR_WIDTH;
935 } 935 }
936 936
937 void CPWL_ScrollBar::SetScrollRange(FX_FLOAT fMin,FX_FLOAT fMax,FX_FLOAT fClient Width) 937 void CPWL_ScrollBar::SetScrollRange(FX_FLOAT fMin,FX_FLOAT fMax,FX_FLOAT fClient Width)
938 { 938 {
939 if (m_pPosButton) 939 if (m_pPosButton)
940 { 940 {
941 m_sData.SetScrollRange(fMin,fMax); 941 m_sData.SetScrollRange(fMin,fMax);
942 m_sData.SetClientWidth(fClientWidth); 942 m_sData.SetClientWidth(fClientWidth);
943 943
944 if (IsFloatSmaller(m_sData.ScrollRange.GetWidth(), 0.0f)) 944 if (IsFloatSmaller(m_sData.ScrollRange.GetWidth(), 0.0f))
945 { 945 {
946 » » » m_pPosButton->SetVisible(FALSE); 946 » » » m_pPosButton->SetVisible(false);
947 } 947 }
948 else 948 else
949 { 949 {
950 » » » m_pPosButton->SetVisible(TRUE); 950 » » » m_pPosButton->SetVisible(true);
951 » » » MovePosButton(TRUE); 951 » » » MovePosButton(true);
952 } 952 }
953 } 953 }
954 } 954 }
955 955
956 void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos) 956 void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos)
957 { 957 {
958 FX_FLOAT fOldPos = m_sData.fScrollPos; 958 FX_FLOAT fOldPos = m_sData.fScrollPos;
959 959
960 m_sData.SetPos(fPos); 960 m_sData.SetPos(fPos);
961 961
962 if (!IsFloatEqual(m_sData.fScrollPos, fOldPos)) 962 if (!IsFloatEqual(m_sData.fScrollPos, fOldPos))
963 » » MovePosButton(TRUE); 963 » » MovePosButton(true);
964 } 964 }
965 965
966 void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep,FX_FLOAT fSmallStep) 966 void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep,FX_FLOAT fSmallStep)
967 { 967 {
968 m_sData.SetBigStep(fBigStep); 968 m_sData.SetBigStep(fBigStep);
969 m_sData.SetSmallStep(fSmallStep); 969 m_sData.SetSmallStep(fSmallStep);
970 } 970 }
971 971
972 void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh) 972 void CPWL_ScrollBar::MovePosButton(bool bRefresh)
973 { 973 {
974 ASSERT (m_pPosButton != NULL); 974 ASSERT (m_pPosButton != NULL);
975 ASSERT (m_pMinButton != NULL); 975 ASSERT (m_pMinButton != NULL);
976 ASSERT (m_pMaxButton != NULL); 976 ASSERT (m_pMaxButton != NULL);
977 977
978 if (m_pPosButton->IsVisible()) 978 if (m_pPosButton->IsVisible())
979 { 979 {
980 980
981 981
982 982
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 } 1024 }
1025 1025
1026 rcPosButton = CPDF_Rect(rcPosArea.left, 1026 rcPosButton = CPDF_Rect(rcPosArea.left,
1027 fBottom, 1027 fBottom,
1028 rcPosArea.right, 1028 rcPosArea.right,
1029 fTop); 1029 fTop);
1030 1030
1031 break; 1031 break;
1032 } 1032 }
1033 1033
1034 » » m_pPosButton->Move(rcPosButton,TRUE,bRefresh); 1034 » » m_pPosButton->Move(rcPosButton,true,bRefresh);
1035 } 1035 }
1036 } 1036 }
1037 1037
1038 void CPWL_ScrollBar::OnMinButtonLBDown(const CPDF_Point & point) 1038 void CPWL_ScrollBar::OnMinButtonLBDown(const CPDF_Point & point)
1039 { 1039 {
1040 m_sData.SubSmall(); 1040 m_sData.SubSmall();
1041 » MovePosButton(TRUE); 1041 » MovePosButton(true);
1042 NotifyScrollWindow(); 1042 NotifyScrollWindow();
1043 1043
1044 » m_bMinOrMax = TRUE; 1044 » m_bMinOrMax = true;
1045 1045
1046 EndTimer(); 1046 EndTimer();
1047 BeginTimer(100); 1047 BeginTimer(100);
1048 } 1048 }
1049 1049
1050 void CPWL_ScrollBar::OnMinButtonLBUp(const CPDF_Point & point) 1050 void CPWL_ScrollBar::OnMinButtonLBUp(const CPDF_Point & point)
1051 { 1051 {
1052 } 1052 }
1053 1053
1054 void CPWL_ScrollBar::OnMinButtonMouseMove(const CPDF_Point & point) 1054 void CPWL_ScrollBar::OnMinButtonMouseMove(const CPDF_Point & point)
1055 { 1055 {
1056 } 1056 }
1057 1057
1058 void CPWL_ScrollBar::OnMaxButtonLBDown(const CPDF_Point & point) 1058 void CPWL_ScrollBar::OnMaxButtonLBDown(const CPDF_Point & point)
1059 { 1059 {
1060 m_sData.AddSmall(); 1060 m_sData.AddSmall();
1061 » MovePosButton(TRUE); 1061 » MovePosButton(true);
1062 NotifyScrollWindow(); 1062 NotifyScrollWindow();
1063 1063
1064 » m_bMinOrMax = FALSE; 1064 » m_bMinOrMax = false;
1065 1065
1066 EndTimer(); 1066 EndTimer();
1067 BeginTimer(100); 1067 BeginTimer(100);
1068 } 1068 }
1069 1069
1070 void CPWL_ScrollBar::OnMaxButtonLBUp(const CPDF_Point & point) 1070 void CPWL_ScrollBar::OnMaxButtonLBUp(const CPDF_Point & point)
1071 { 1071 {
1072 } 1072 }
1073 1073
1074 void CPWL_ScrollBar::OnMaxButtonMouseMove(const CPDF_Point & point) 1074 void CPWL_ScrollBar::OnMaxButtonMouseMove(const CPDF_Point & point)
1075 { 1075 {
1076 } 1076 }
1077 1077
1078 void CPWL_ScrollBar::OnPosButtonLBDown(const CPDF_Point & point) 1078 void CPWL_ScrollBar::OnPosButtonLBDown(const CPDF_Point & point)
1079 { 1079 {
1080 » m_bMouseDown = TRUE; 1080 » m_bMouseDown = true;
1081 1081
1082 if (m_pPosButton) 1082 if (m_pPosButton)
1083 { 1083 {
1084 CPDF_Rect rcPosButton = m_pPosButton->GetWindowRect(); 1084 CPDF_Rect rcPosButton = m_pPosButton->GetWindowRect();
1085 1085
1086 switch(m_sbType) 1086 switch(m_sbType)
1087 { 1087 {
1088 case SBT_HSCROLL: 1088 case SBT_HSCROLL:
1089 m_nOldPos = point.x; 1089 m_nOldPos = point.x;
1090 m_fOldPosButton = rcPosButton.left; 1090 m_fOldPosButton = rcPosButton.left;
1091 break; 1091 break;
1092 case SBT_VSCROLL: 1092 case SBT_VSCROLL:
1093 m_nOldPos = point.y; 1093 m_nOldPos = point.y;
1094 m_fOldPosButton = rcPosButton.top; 1094 m_fOldPosButton = rcPosButton.top;
1095 break; 1095 break;
1096 } 1096 }
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 void CPWL_ScrollBar::OnPosButtonLBUp(const CPDF_Point & point) 1100 void CPWL_ScrollBar::OnPosButtonLBUp(const CPDF_Point & point)
1101 { 1101 {
1102 if (m_bMouseDown) 1102 if (m_bMouseDown)
1103 { 1103 {
1104 if (!m_bNotifyForever) 1104 if (!m_bNotifyForever)
1105 NotifyScrollWindow(); 1105 NotifyScrollWindow();
1106 } 1106 }
1107 » m_bMouseDown = FALSE; 1107 » m_bMouseDown = false;
1108 } 1108 }
1109 1109
1110 void CPWL_ScrollBar::OnPosButtonMouseMove(const CPDF_Point & point) 1110 void CPWL_ScrollBar::OnPosButtonMouseMove(const CPDF_Point & point)
1111 { 1111 {
1112 FX_FLOAT fOldScrollPos = m_sData.fScrollPos; 1112 FX_FLOAT fOldScrollPos = m_sData.fScrollPos;
1113 1113
1114 FX_FLOAT fNewPos = 0; 1114 FX_FLOAT fNewPos = 0;
1115 1115
1116 switch (m_sbType) 1116 switch (m_sbType)
1117 { 1117 {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1156 fNewPos = m_sData.ScrollRange.fMax; 1156 fNewPos = m_sData.ScrollRange.fMax;
1157 } 1157 }
1158 1158
1159 m_sData.SetPos(fNewPos); 1159 m_sData.SetPos(fNewPos);
1160 1160
1161 break; 1161 break;
1162 } 1162 }
1163 1163
1164 if (!IsFloatEqual(fOldScrollPos, m_sData.fScrollPos)) 1164 if (!IsFloatEqual(fOldScrollPos, m_sData.fScrollPos))
1165 { 1165 {
1166 » » » MovePosButton(TRUE); 1166 » » » MovePosButton(true);
1167 1167
1168 if (m_bNotifyForever) 1168 if (m_bNotifyForever)
1169 NotifyScrollWindow(); 1169 NotifyScrollWindow();
1170 } 1170 }
1171 } 1171 }
1172 } 1172 }
1173 1173
1174 void CPWL_ScrollBar::NotifyScrollWindow() 1174 void CPWL_ScrollBar::NotifyScrollWindow()
1175 { 1175 {
1176 if (CPWL_Wnd * pParent = GetParentWindow()) 1176 if (CPWL_Wnd * pParent = GetParentWindow())
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 1290
1291 void CPWL_ScrollBar::TimerProc() 1291 void CPWL_ScrollBar::TimerProc()
1292 { 1292 {
1293 PWL_SCROLL_PRIVATEDATA sTemp = m_sData; 1293 PWL_SCROLL_PRIVATEDATA sTemp = m_sData;
1294 1294
1295 if (m_bMinOrMax)m_sData.SubSmall(); 1295 if (m_bMinOrMax)m_sData.SubSmall();
1296 else m_sData.AddSmall(); 1296 else m_sData.AddSmall();
1297 1297
1298 if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0) 1298 if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0)
1299 { 1299 {
1300 » » MovePosButton(TRUE); 1300 » » MovePosButton(true);
1301 NotifyScrollWindow(); 1301 NotifyScrollWindow();
1302 } 1302 }
1303 } 1303 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_Note.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Signature.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698