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

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

Issue 2453683011: Remove FX_BOOL from fpdfsdk. (Closed)
Patch Set: Regenerate patch after rebase. Created 4 years, 1 month 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/pdfwindow/PWL_ScrollBar.h ('k') | fpdfsdk/pdfwindow/PWL_SpecialButton.h » ('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 "fpdfsdk/pdfwindow/PWL_ScrollBar.h" 7 #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h"
8 8
9 #include "core/fxge/cfx_pathdata.h" 9 #include "core/fxge/cfx_pathdata.h"
10 #include "core/fxge/cfx_renderdevice.h" 10 #include "core/fxge/cfx_renderdevice.h"
(...skipping 16 matching lines...) Expand all
27 void PWL_FLOATRANGE::Set(FX_FLOAT min, FX_FLOAT max) { 27 void PWL_FLOATRANGE::Set(FX_FLOAT min, FX_FLOAT max) {
28 if (min > max) { 28 if (min > max) {
29 fMin = max; 29 fMin = max;
30 fMax = min; 30 fMax = min;
31 } else { 31 } else {
32 fMin = min; 32 fMin = min;
33 fMax = max; 33 fMax = max;
34 } 34 }
35 } 35 }
36 36
37 FX_BOOL PWL_FLOATRANGE::In(FX_FLOAT x) const { 37 bool PWL_FLOATRANGE::In(FX_FLOAT x) const {
38 return (IsFloatBigger(x, fMin) || IsFloatEqual(x, fMin)) && 38 return (IsFloatBigger(x, fMin) || IsFloatEqual(x, fMin)) &&
39 (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax)); 39 (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax));
40 } 40 }
41 41
42 FX_FLOAT PWL_FLOATRANGE::GetWidth() const { 42 FX_FLOAT PWL_FLOATRANGE::GetWidth() const {
43 return fMax - fMin; 43 return fMax - fMin;
44 } 44 }
45 45
46 PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() { 46 PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() {
47 Default(); 47 Default();
(...skipping 21 matching lines...) Expand all
69 } 69 }
70 70
71 void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step) { 71 void PWL_SCROLL_PRIVATEDATA::SetSmallStep(FX_FLOAT step) {
72 fSmallStep = step; 72 fSmallStep = step;
73 } 73 }
74 74
75 void PWL_SCROLL_PRIVATEDATA::SetBigStep(FX_FLOAT step) { 75 void PWL_SCROLL_PRIVATEDATA::SetBigStep(FX_FLOAT step) {
76 fBigStep = step; 76 fBigStep = step;
77 } 77 }
78 78
79 FX_BOOL PWL_SCROLL_PRIVATEDATA::SetPos(FX_FLOAT pos) { 79 bool PWL_SCROLL_PRIVATEDATA::SetPos(FX_FLOAT pos) {
80 if (ScrollRange.In(pos)) { 80 if (ScrollRange.In(pos)) {
81 fScrollPos = pos; 81 fScrollPos = pos;
82 return TRUE; 82 return true;
83 } 83 }
84 return FALSE; 84 return false;
85 } 85 }
86 86
87 void PWL_SCROLL_PRIVATEDATA::AddSmall() { 87 void PWL_SCROLL_PRIVATEDATA::AddSmall() {
88 if (!SetPos(fScrollPos + fSmallStep)) 88 if (!SetPos(fScrollPos + fSmallStep))
89 SetPos(ScrollRange.fMax); 89 SetPos(ScrollRange.fMax);
90 } 90 }
91 91
92 void PWL_SCROLL_PRIVATEDATA::SubSmall() { 92 void PWL_SCROLL_PRIVATEDATA::SubSmall() {
93 if (!SetPos(fScrollPos - fSmallStep)) 93 if (!SetPos(fScrollPos - fSmallStep))
94 SetPos(ScrollRange.fMin); 94 SetPos(ScrollRange.fMin);
95 } 95 }
96 96
97 void PWL_SCROLL_PRIVATEDATA::AddBig() { 97 void PWL_SCROLL_PRIVATEDATA::AddBig() {
98 if (!SetPos(fScrollPos + fBigStep)) 98 if (!SetPos(fScrollPos + fBigStep))
99 SetPos(ScrollRange.fMax); 99 SetPos(ScrollRange.fMax);
100 } 100 }
101 101
102 void PWL_SCROLL_PRIVATEDATA::SubBig() { 102 void PWL_SCROLL_PRIVATEDATA::SubBig() {
103 if (!SetPos(fScrollPos - fBigStep)) 103 if (!SetPos(fScrollPos - fBigStep))
104 SetPos(ScrollRange.fMin); 104 SetPos(ScrollRange.fMin);
105 } 105 }
106 106
107 CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, 107 CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType,
108 PWL_SBBUTTON_TYPE eButtonType) { 108 PWL_SBBUTTON_TYPE eButtonType) {
109 m_eScrollBarType = eScrollBarType; 109 m_eScrollBarType = eScrollBarType;
110 m_eSBButtonType = eButtonType; 110 m_eSBButtonType = eButtonType;
111 111
112 m_bMouseDown = FALSE; 112 m_bMouseDown = false;
113 } 113 }
114 114
115 CPWL_SBButton::~CPWL_SBButton() {} 115 CPWL_SBButton::~CPWL_SBButton() {}
116 116
117 CFX_ByteString CPWL_SBButton::GetClassName() const { 117 CFX_ByteString CPWL_SBButton::GetClassName() const {
118 return "CPWL_SBButton"; 118 return "CPWL_SBButton";
119 } 119 }
120 120
121 void CPWL_SBButton::OnCreate(PWL_CREATEPARAM& cp) { 121 void CPWL_SBButton::OnCreate(PWL_CREATEPARAM& cp) {
122 cp.eCursorType = FXCT_ARROW; 122 cp.eCursorType = FXCT_ARROW;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f); 316 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f);
317 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, 317 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
318 ArgbEncode(nTransparancy, 255, 255, 255), 318 ArgbEncode(nTransparancy, 255, 255, 255),
319 1.0f); 319 1.0f);
320 320
321 // draw background 321 // draw background
322 322
323 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f); 323 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f);
324 324
325 if (IsEnabled()) 325 if (IsEnabled())
326 CPWL_Utils::DrawShadow(pDevice, pUser2Device, TRUE, FALSE, rcDraw, 326 CPWL_Utils::DrawShadow(pDevice, pUser2Device, true, false, rcDraw,
327 nTransparancy, 80, 220); 327 nTransparancy, 80, 220);
328 else 328 else
329 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw, 329 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw,
330 ArgbEncode(255, 255, 255, 255)); 330 ArgbEncode(255, 255, 255, 255));
331 331
332 // draw arrow 332 // draw arrow
333 333
334 if (rectWnd.top - rectWnd.bottom > 6.0f) { 334 if (rectWnd.top - rectWnd.bottom > 6.0f) {
335 FX_FLOAT fX = rectWnd.left + 1.5f; 335 FX_FLOAT fX = rectWnd.left + 1.5f;
336 FX_FLOAT fY = rectWnd.bottom; 336 FX_FLOAT fY = rectWnd.bottom;
(...skipping 24 matching lines...) Expand all
361 361
362 // draw inner border 362 // draw inner border
363 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f); 363 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f);
364 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, 364 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw,
365 ArgbEncode(nTransparancy, 255, 255, 255), 365 ArgbEncode(nTransparancy, 255, 255, 255),
366 1.0f); 366 1.0f);
367 367
368 // draw background 368 // draw background
369 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f); 369 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 1.0f);
370 if (IsEnabled()) 370 if (IsEnabled())
371 CPWL_Utils::DrawShadow(pDevice, pUser2Device, TRUE, FALSE, rcDraw, 371 CPWL_Utils::DrawShadow(pDevice, pUser2Device, true, false, rcDraw,
372 nTransparancy, 80, 220); 372 nTransparancy, 80, 220);
373 else 373 else
374 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw, 374 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcDraw,
375 ArgbEncode(255, 255, 255, 255)); 375 ArgbEncode(255, 255, 255, 255));
376 376
377 // draw arrow 377 // draw arrow
378 378
379 if (rectWnd.top - rectWnd.bottom > 6.0f) { 379 if (rectWnd.top - rectWnd.bottom > 6.0f) {
380 FX_FLOAT fX = rectWnd.left + 1.5f; 380 FX_FLOAT fX = rectWnd.left + 1.5f;
381 FX_FLOAT fY = rectWnd.bottom; 381 FX_FLOAT fY = rectWnd.bottom;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } break; 529 } break;
530 default: 530 default:
531 break; 531 break;
532 } 532 }
533 break; 533 break;
534 default: 534 default:
535 break; 535 break;
536 } 536 }
537 } 537 }
538 538
539 FX_BOOL CPWL_SBButton::OnLButtonDown(const CFX_FloatPoint& point, 539 bool CPWL_SBButton::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) {
540 uint32_t nFlag) {
541 CPWL_Wnd::OnLButtonDown(point, nFlag); 540 CPWL_Wnd::OnLButtonDown(point, nFlag);
542 541
543 if (CPWL_Wnd* pParent = GetParentWindow()) 542 if (CPWL_Wnd* pParent = GetParentWindow())
544 pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, (intptr_t)&point); 543 pParent->OnNotify(this, PNM_LBUTTONDOWN, 0, (intptr_t)&point);
545 544
546 m_bMouseDown = TRUE; 545 m_bMouseDown = true;
547 SetCapture(); 546 SetCapture();
548 547
549 return TRUE; 548 return true;
550 } 549 }
551 550
552 FX_BOOL CPWL_SBButton::OnLButtonUp(const CFX_FloatPoint& point, 551 bool CPWL_SBButton::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
553 uint32_t nFlag) {
554 CPWL_Wnd::OnLButtonUp(point, nFlag); 552 CPWL_Wnd::OnLButtonUp(point, nFlag);
555 553
556 if (CPWL_Wnd* pParent = GetParentWindow()) 554 if (CPWL_Wnd* pParent = GetParentWindow())
557 pParent->OnNotify(this, PNM_LBUTTONUP, 0, (intptr_t)&point); 555 pParent->OnNotify(this, PNM_LBUTTONUP, 0, (intptr_t)&point);
558 556
559 m_bMouseDown = FALSE; 557 m_bMouseDown = false;
560 ReleaseCapture(); 558 ReleaseCapture();
561 559
562 return TRUE; 560 return true;
563 } 561 }
564 562
565 FX_BOOL CPWL_SBButton::OnMouseMove(const CFX_FloatPoint& point, 563 bool CPWL_SBButton::OnMouseMove(const CFX_FloatPoint& point, uint32_t nFlag) {
566 uint32_t nFlag) {
567 CPWL_Wnd::OnMouseMove(point, nFlag); 564 CPWL_Wnd::OnMouseMove(point, nFlag);
568 565
569 if (CPWL_Wnd* pParent = GetParentWindow()) { 566 if (CPWL_Wnd* pParent = GetParentWindow()) {
570 pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point); 567 pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point);
571 } 568 }
572 569
573 return TRUE; 570 return true;
574 } 571 }
575 572
576 CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType) 573 CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType)
577 : m_sbType(sbType), 574 : m_sbType(sbType),
578 m_pMinButton(nullptr), 575 m_pMinButton(nullptr),
579 m_pMaxButton(nullptr), 576 m_pMaxButton(nullptr),
580 m_pPosButton(nullptr), 577 m_pPosButton(nullptr),
581 m_bMouseDown(FALSE), 578 m_bMouseDown(false),
582 m_bMinOrMax(FALSE), 579 m_bMinOrMax(false),
583 m_bNotifyForever(TRUE) {} 580 m_bNotifyForever(true) {}
584 581
585 CPWL_ScrollBar::~CPWL_ScrollBar() {} 582 CPWL_ScrollBar::~CPWL_ScrollBar() {}
586 583
587 CFX_ByteString CPWL_ScrollBar::GetClassName() const { 584 CFX_ByteString CPWL_ScrollBar::GetClassName() const {
588 return "CPWL_ScrollBar"; 585 return "CPWL_ScrollBar";
589 } 586 }
590 587
591 void CPWL_ScrollBar::OnCreate(PWL_CREATEPARAM& cp) { 588 void CPWL_ScrollBar::OnCreate(PWL_CREATEPARAM& cp) {
592 cp.eCursorType = FXCT_ARROW; 589 cp.eCursorType = FXCT_ARROW;
593 } 590 }
(...skipping 18 matching lines...) Expand all
612 fBWidth = (rcClient.right - rcClient.left - 609 fBWidth = (rcClient.right - rcClient.left -
613 PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) / 610 PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) /
614 2; 611 2;
615 612
616 if (fBWidth > 0) { 613 if (fBWidth > 0) {
617 rcMinButton = CFX_FloatRect(rcClient.left, rcClient.bottom, 614 rcMinButton = CFX_FloatRect(rcClient.left, rcClient.bottom,
618 rcClient.left + fBWidth, rcClient.top); 615 rcClient.left + fBWidth, rcClient.top);
619 rcMaxButton = CFX_FloatRect(rcClient.right - fBWidth, rcClient.bottom, 616 rcMaxButton = CFX_FloatRect(rcClient.right - fBWidth, rcClient.bottom,
620 rcClient.right, rcClient.top); 617 rcClient.right, rcClient.top);
621 } else { 618 } else {
622 SetVisible(FALSE); 619 SetVisible(false);
623 } 620 }
624 } 621 }
625 break; 622 break;
626 case SBT_VSCROLL: 623 case SBT_VSCROLL:
627 if (IsFloatBigger(rcClient.top - rcClient.bottom, 624 if (IsFloatBigger(rcClient.top - rcClient.bottom,
628 PWL_SCROLLBAR_BUTTON_WIDTH * 2 + 625 PWL_SCROLLBAR_BUTTON_WIDTH * 2 +
629 PWL_SCROLLBAR_POSBUTTON_MINWIDTH + 2)) { 626 PWL_SCROLLBAR_POSBUTTON_MINWIDTH + 2)) {
630 rcMinButton = CFX_FloatRect(rcClient.left, 627 rcMinButton = CFX_FloatRect(rcClient.left,
631 rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH, 628 rcClient.top - PWL_SCROLLBAR_BUTTON_WIDTH,
632 rcClient.right, rcClient.top); 629 rcClient.right, rcClient.top);
633 rcMaxButton = 630 rcMaxButton =
634 CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right, 631 CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right,
635 rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH); 632 rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH);
636 } else { 633 } else {
637 fBWidth = (rcClient.top - rcClient.bottom - 634 fBWidth = (rcClient.top - rcClient.bottom -
638 PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) / 635 PWL_SCROLLBAR_POSBUTTON_MINWIDTH - 2) /
639 2; 636 2;
640 637
641 if (IsFloatBigger(fBWidth, 0)) { 638 if (IsFloatBigger(fBWidth, 0)) {
642 rcMinButton = CFX_FloatRect(rcClient.left, rcClient.top - fBWidth, 639 rcMinButton = CFX_FloatRect(rcClient.left, rcClient.top - fBWidth,
643 rcClient.right, rcClient.top); 640 rcClient.right, rcClient.top);
644 rcMaxButton = 641 rcMaxButton =
645 CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right, 642 CFX_FloatRect(rcClient.left, rcClient.bottom, rcClient.right,
646 rcClient.bottom + fBWidth); 643 rcClient.bottom + fBWidth);
647 } else { 644 } else {
648 SetVisible(FALSE); 645 SetVisible(false);
649 } 646 }
650 } 647 }
651 break; 648 break;
652 } 649 }
653 650
654 if (m_pMinButton) 651 if (m_pMinButton)
655 m_pMinButton->Move(rcMinButton, TRUE, FALSE); 652 m_pMinButton->Move(rcMinButton, true, false);
656 if (m_pMaxButton) 653 if (m_pMaxButton)
657 m_pMaxButton->Move(rcMaxButton, TRUE, FALSE); 654 m_pMaxButton->Move(rcMaxButton, true, false);
658 MovePosButton(FALSE); 655 MovePosButton(false);
659 } 656 }
660 657
661 void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { 658 void CPWL_ScrollBar::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
662 CFX_FloatRect rectWnd = GetWindowRect(); 659 CFX_FloatRect rectWnd = GetWindowRect();
663 660
664 if (IsVisible() && !rectWnd.IsEmpty()) { 661 if (IsVisible() && !rectWnd.IsEmpty()) {
665 CFX_ByteTextBuf sButton; 662 CFX_ByteTextBuf sButton;
666 663
667 sButton << "q\n"; 664 sButton << "q\n";
668 sButton << "0 w\n" 665 sButton << "0 w\n"
669 << CPWL_Utils::GetColorAppStream(GetBackgroundColor(), TRUE) 666 << CPWL_Utils::GetColorAppStream(GetBackgroundColor(), true)
670 .AsStringC(); 667 .AsStringC();
671 sButton << rectWnd.left << " " << rectWnd.bottom << " " 668 sButton << rectWnd.left << " " << rectWnd.bottom << " "
672 << rectWnd.right - rectWnd.left << " " 669 << rectWnd.right - rectWnd.left << " "
673 << rectWnd.top - rectWnd.bottom << " re b Q\n"; 670 << rectWnd.top - rectWnd.bottom << " re b Q\n";
674 671
675 sAppStream << sButton; 672 sAppStream << sButton;
676 } 673 }
677 } 674 }
678 675
679 void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice, 676 void CPWL_ScrollBar::DrawThisAppearance(CFX_RenderDevice* pDevice,
(...skipping 11 matching lines...) Expand all
691 ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f); 688 ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
692 689
693 CPWL_Utils::DrawStrokeLine( 690 CPWL_Utils::DrawStrokeLine(
694 pDevice, pUser2Device, 691 pDevice, pUser2Device,
695 CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.top - 2.0f), 692 CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.top - 2.0f),
696 CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.bottom + 2.0f), 693 CFX_FloatPoint(rectWnd.right - 2.0f, rectWnd.bottom + 2.0f),
697 ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f); 694 ArgbEncode(GetTransparency(), 100, 100, 100), 1.0f);
698 } 695 }
699 } 696 }
700 697
701 FX_BOOL CPWL_ScrollBar::OnLButtonDown(const CFX_FloatPoint& point, 698 bool CPWL_ScrollBar::OnLButtonDown(const CFX_FloatPoint& point,
702 uint32_t nFlag) { 699 uint32_t nFlag) {
703 CPWL_Wnd::OnLButtonDown(point, nFlag); 700 CPWL_Wnd::OnLButtonDown(point, nFlag);
704 701
705 if (HasFlag(PWS_AUTOTRANSPARENT)) { 702 if (HasFlag(PWS_AUTOTRANSPARENT)) {
706 if (GetTransparency() != 255) { 703 if (GetTransparency() != 255) {
707 SetTransparency(255); 704 SetTransparency(255);
708 InvalidateRect(); 705 InvalidateRect();
709 } 706 }
710 } 707 }
711 708
712 CFX_FloatRect rcMinArea, rcMaxArea; 709 CFX_FloatRect rcMinArea, rcMaxArea;
(...skipping 20 matching lines...) Expand all
733 rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH, 730 rcClient.bottom + PWL_SCROLLBAR_BUTTON_WIDTH,
734 rcClient.right, rcPosButton.bottom); 731 rcClient.right, rcPosButton.bottom);
735 break; 732 break;
736 } 733 }
737 734
738 rcMinArea.Normalize(); 735 rcMinArea.Normalize();
739 rcMaxArea.Normalize(); 736 rcMaxArea.Normalize();
740 737
741 if (rcMinArea.Contains(point.x, point.y)) { 738 if (rcMinArea.Contains(point.x, point.y)) {
742 m_sData.SubBig(); 739 m_sData.SubBig();
743 MovePosButton(TRUE); 740 MovePosButton(true);
744 NotifyScrollWindow(); 741 NotifyScrollWindow();
745 } 742 }
746 743
747 if (rcMaxArea.Contains(point.x, point.y)) { 744 if (rcMaxArea.Contains(point.x, point.y)) {
748 m_sData.AddBig(); 745 m_sData.AddBig();
749 MovePosButton(TRUE); 746 MovePosButton(true);
750 NotifyScrollWindow(); 747 NotifyScrollWindow();
751 } 748 }
752 } 749 }
753 750
754 return TRUE; 751 return true;
755 } 752 }
756 753
757 FX_BOOL CPWL_ScrollBar::OnLButtonUp(const CFX_FloatPoint& point, 754 bool CPWL_ScrollBar::OnLButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) {
758 uint32_t nFlag) {
759 CPWL_Wnd::OnLButtonUp(point, nFlag); 755 CPWL_Wnd::OnLButtonUp(point, nFlag);
760 756
761 if (HasFlag(PWS_AUTOTRANSPARENT)) { 757 if (HasFlag(PWS_AUTOTRANSPARENT)) {
762 if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY) { 758 if (GetTransparency() != PWL_SCROLLBAR_TRANSPARANCY) {
763 SetTransparency(PWL_SCROLLBAR_TRANSPARANCY); 759 SetTransparency(PWL_SCROLLBAR_TRANSPARANCY);
764 InvalidateRect(); 760 InvalidateRect();
765 } 761 }
766 } 762 }
767 763
768 EndTimer(); 764 EndTimer();
769 m_bMouseDown = FALSE; 765 m_bMouseDown = false;
770 766
771 return TRUE; 767 return true;
772 } 768 }
773 769
774 void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd, 770 void CPWL_ScrollBar::OnNotify(CPWL_Wnd* pWnd,
775 uint32_t msg, 771 uint32_t msg,
776 intptr_t wParam, 772 intptr_t wParam,
777 intptr_t lParam) { 773 intptr_t lParam) {
778 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam); 774 CPWL_Wnd::OnNotify(pWnd, msg, wParam, lParam);
779 775
780 switch (msg) { 776 switch (msg) {
781 case PNM_LBUTTONDOWN: 777 case PNM_LBUTTONDOWN:
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 m_pMinButton->Create(scp); 853 m_pMinButton->Create(scp);
858 } 854 }
859 855
860 if (!m_pMaxButton) { 856 if (!m_pMaxButton) {
861 m_pMaxButton = new CPWL_SBButton(m_sbType, PSBT_MAX); 857 m_pMaxButton = new CPWL_SBButton(m_sbType, PSBT_MAX);
862 m_pMaxButton->Create(scp); 858 m_pMaxButton->Create(scp);
863 } 859 }
864 860
865 if (!m_pPosButton) { 861 if (!m_pPosButton) {
866 m_pPosButton = new CPWL_SBButton(m_sbType, PSBT_POS); 862 m_pPosButton = new CPWL_SBButton(m_sbType, PSBT_POS);
867 m_pPosButton->SetVisible(FALSE); 863 m_pPosButton->SetVisible(false);
868 m_pPosButton->Create(scp); 864 m_pPosButton->Create(scp);
869 } 865 }
870 } 866 }
871 867
872 FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const { 868 FX_FLOAT CPWL_ScrollBar::GetScrollBarWidth() const {
873 if (!IsVisible()) 869 if (!IsVisible())
874 return 0; 870 return 0;
875 871
876 return PWL_SCROLLBAR_WIDTH; 872 return PWL_SCROLLBAR_WIDTH;
877 } 873 }
878 874
879 void CPWL_ScrollBar::SetScrollRange(FX_FLOAT fMin, 875 void CPWL_ScrollBar::SetScrollRange(FX_FLOAT fMin,
880 FX_FLOAT fMax, 876 FX_FLOAT fMax,
881 FX_FLOAT fClientWidth) { 877 FX_FLOAT fClientWidth) {
882 if (m_pPosButton) { 878 if (m_pPosButton) {
883 m_sData.SetScrollRange(fMin, fMax); 879 m_sData.SetScrollRange(fMin, fMax);
884 m_sData.SetClientWidth(fClientWidth); 880 m_sData.SetClientWidth(fClientWidth);
885 881
886 if (IsFloatSmaller(m_sData.ScrollRange.GetWidth(), 0.0f)) { 882 if (IsFloatSmaller(m_sData.ScrollRange.GetWidth(), 0.0f)) {
887 m_pPosButton->SetVisible(FALSE); 883 m_pPosButton->SetVisible(false);
888 } else { 884 } else {
889 m_pPosButton->SetVisible(TRUE); 885 m_pPosButton->SetVisible(true);
890 MovePosButton(TRUE); 886 MovePosButton(true);
891 } 887 }
892 } 888 }
893 } 889 }
894 890
895 void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos) { 891 void CPWL_ScrollBar::SetScrollPos(FX_FLOAT fPos) {
896 FX_FLOAT fOldPos = m_sData.fScrollPos; 892 FX_FLOAT fOldPos = m_sData.fScrollPos;
897 893
898 m_sData.SetPos(fPos); 894 m_sData.SetPos(fPos);
899 895
900 if (!IsFloatEqual(m_sData.fScrollPos, fOldPos)) 896 if (!IsFloatEqual(m_sData.fScrollPos, fOldPos))
901 MovePosButton(TRUE); 897 MovePosButton(true);
902 } 898 }
903 899
904 void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep) { 900 void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep) {
905 m_sData.SetBigStep(fBigStep); 901 m_sData.SetBigStep(fBigStep);
906 m_sData.SetSmallStep(fSmallStep); 902 m_sData.SetSmallStep(fSmallStep);
907 } 903 }
908 904
909 void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh) { 905 void CPWL_ScrollBar::MovePosButton(bool bRefresh) {
910 ASSERT(m_pMinButton); 906 ASSERT(m_pMinButton);
911 ASSERT(m_pMaxButton); 907 ASSERT(m_pMaxButton);
912 908
913 if (m_pPosButton->IsVisible()) { 909 if (m_pPosButton->IsVisible()) {
914 CFX_FloatRect rcClient; 910 CFX_FloatRect rcClient;
915 CFX_FloatRect rcPosArea, rcPosButton; 911 CFX_FloatRect rcPosArea, rcPosButton;
916 912
917 rcClient = GetClientRect(); 913 rcClient = GetClientRect();
918 rcPosArea = GetScrollArea(); 914 rcPosArea = GetScrollArea();
919 915
(...skipping 27 matching lines...) Expand all
947 fBottom = rcPosArea.bottom; 943 fBottom = rcPosArea.bottom;
948 fTop = fBottom + PWL_SCROLLBAR_POSBUTTON_MINWIDTH; 944 fTop = fBottom + PWL_SCROLLBAR_POSBUTTON_MINWIDTH;
949 } 945 }
950 946
951 rcPosButton = 947 rcPosButton =
952 CFX_FloatRect(rcPosArea.left, fBottom, rcPosArea.right, fTop); 948 CFX_FloatRect(rcPosArea.left, fBottom, rcPosArea.right, fTop);
953 949
954 break; 950 break;
955 } 951 }
956 952
957 m_pPosButton->Move(rcPosButton, TRUE, bRefresh); 953 m_pPosButton->Move(rcPosButton, true, bRefresh);
958 } 954 }
959 } 955 }
960 956
961 void CPWL_ScrollBar::OnMinButtonLBDown(const CFX_FloatPoint& point) { 957 void CPWL_ScrollBar::OnMinButtonLBDown(const CFX_FloatPoint& point) {
962 m_sData.SubSmall(); 958 m_sData.SubSmall();
963 MovePosButton(TRUE); 959 MovePosButton(true);
964 NotifyScrollWindow(); 960 NotifyScrollWindow();
965 961
966 m_bMinOrMax = TRUE; 962 m_bMinOrMax = true;
967 963
968 EndTimer(); 964 EndTimer();
969 BeginTimer(100); 965 BeginTimer(100);
970 } 966 }
971 967
972 void CPWL_ScrollBar::OnMinButtonLBUp(const CFX_FloatPoint& point) {} 968 void CPWL_ScrollBar::OnMinButtonLBUp(const CFX_FloatPoint& point) {}
973 969
974 void CPWL_ScrollBar::OnMinButtonMouseMove(const CFX_FloatPoint& point) {} 970 void CPWL_ScrollBar::OnMinButtonMouseMove(const CFX_FloatPoint& point) {}
975 971
976 void CPWL_ScrollBar::OnMaxButtonLBDown(const CFX_FloatPoint& point) { 972 void CPWL_ScrollBar::OnMaxButtonLBDown(const CFX_FloatPoint& point) {
977 m_sData.AddSmall(); 973 m_sData.AddSmall();
978 MovePosButton(TRUE); 974 MovePosButton(true);
979 NotifyScrollWindow(); 975 NotifyScrollWindow();
980 976
981 m_bMinOrMax = FALSE; 977 m_bMinOrMax = false;
982 978
983 EndTimer(); 979 EndTimer();
984 BeginTimer(100); 980 BeginTimer(100);
985 } 981 }
986 982
987 void CPWL_ScrollBar::OnMaxButtonLBUp(const CFX_FloatPoint& point) {} 983 void CPWL_ScrollBar::OnMaxButtonLBUp(const CFX_FloatPoint& point) {}
988 984
989 void CPWL_ScrollBar::OnMaxButtonMouseMove(const CFX_FloatPoint& point) {} 985 void CPWL_ScrollBar::OnMaxButtonMouseMove(const CFX_FloatPoint& point) {}
990 986
991 void CPWL_ScrollBar::OnPosButtonLBDown(const CFX_FloatPoint& point) { 987 void CPWL_ScrollBar::OnPosButtonLBDown(const CFX_FloatPoint& point) {
992 m_bMouseDown = TRUE; 988 m_bMouseDown = true;
993 989
994 if (m_pPosButton) { 990 if (m_pPosButton) {
995 CFX_FloatRect rcPosButton = m_pPosButton->GetWindowRect(); 991 CFX_FloatRect rcPosButton = m_pPosButton->GetWindowRect();
996 992
997 switch (m_sbType) { 993 switch (m_sbType) {
998 case SBT_HSCROLL: 994 case SBT_HSCROLL:
999 m_nOldPos = point.x; 995 m_nOldPos = point.x;
1000 m_fOldPosButton = rcPosButton.left; 996 m_fOldPosButton = rcPosButton.left;
1001 break; 997 break;
1002 case SBT_VSCROLL: 998 case SBT_VSCROLL:
1003 m_nOldPos = point.y; 999 m_nOldPos = point.y;
1004 m_fOldPosButton = rcPosButton.top; 1000 m_fOldPosButton = rcPosButton.top;
1005 break; 1001 break;
1006 } 1002 }
1007 } 1003 }
1008 } 1004 }
1009 1005
1010 void CPWL_ScrollBar::OnPosButtonLBUp(const CFX_FloatPoint& point) { 1006 void CPWL_ScrollBar::OnPosButtonLBUp(const CFX_FloatPoint& point) {
1011 if (m_bMouseDown) { 1007 if (m_bMouseDown) {
1012 if (!m_bNotifyForever) 1008 if (!m_bNotifyForever)
1013 NotifyScrollWindow(); 1009 NotifyScrollWindow();
1014 } 1010 }
1015 m_bMouseDown = FALSE; 1011 m_bMouseDown = false;
1016 } 1012 }
1017 1013
1018 void CPWL_ScrollBar::OnPosButtonMouseMove(const CFX_FloatPoint& point) { 1014 void CPWL_ScrollBar::OnPosButtonMouseMove(const CFX_FloatPoint& point) {
1019 FX_FLOAT fOldScrollPos = m_sData.fScrollPos; 1015 FX_FLOAT fOldScrollPos = m_sData.fScrollPos;
1020 1016
1021 FX_FLOAT fNewPos = 0; 1017 FX_FLOAT fNewPos = 0;
1022 1018
1023 switch (m_sbType) { 1019 switch (m_sbType) {
1024 case SBT_HSCROLL: 1020 case SBT_HSCROLL:
1025 if (FXSYS_fabs(point.x - m_nOldPos) < 1) 1021 if (FXSYS_fabs(point.x - m_nOldPos) < 1)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 if (IsFloatBigger(fNewPos, m_sData.ScrollRange.fMax)) { 1053 if (IsFloatBigger(fNewPos, m_sData.ScrollRange.fMax)) {
1058 fNewPos = m_sData.ScrollRange.fMax; 1054 fNewPos = m_sData.ScrollRange.fMax;
1059 } 1055 }
1060 1056
1061 m_sData.SetPos(fNewPos); 1057 m_sData.SetPos(fNewPos);
1062 1058
1063 break; 1059 break;
1064 } 1060 }
1065 1061
1066 if (!IsFloatEqual(fOldScrollPos, m_sData.fScrollPos)) { 1062 if (!IsFloatEqual(fOldScrollPos, m_sData.fScrollPos)) {
1067 MovePosButton(TRUE); 1063 MovePosButton(true);
1068 1064
1069 if (m_bNotifyForever) 1065 if (m_bNotifyForever)
1070 NotifyScrollWindow(); 1066 NotifyScrollWindow();
1071 } 1067 }
1072 } 1068 }
1073 } 1069 }
1074 1070
1075 void CPWL_ScrollBar::NotifyScrollWindow() { 1071 void CPWL_ScrollBar::NotifyScrollWindow() {
1076 if (CPWL_Wnd* pParent = GetParentWindow()) { 1072 if (CPWL_Wnd* pParent = GetParentWindow()) {
1077 FX_FLOAT fPos; 1073 FX_FLOAT fPos;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 } 1177 }
1182 1178
1183 void CPWL_ScrollBar::TimerProc() { 1179 void CPWL_ScrollBar::TimerProc() {
1184 PWL_SCROLL_PRIVATEDATA sTemp = m_sData; 1180 PWL_SCROLL_PRIVATEDATA sTemp = m_sData;
1185 if (m_bMinOrMax) 1181 if (m_bMinOrMax)
1186 m_sData.SubSmall(); 1182 m_sData.SubSmall();
1187 else 1183 else
1188 m_sData.AddSmall(); 1184 m_sData.AddSmall();
1189 1185
1190 if (sTemp != m_sData) { 1186 if (sTemp != m_sData) {
1191 MovePosButton(TRUE); 1187 MovePosButton(true);
1192 NotifyScrollWindow(); 1188 NotifyScrollWindow();
1193 } 1189 }
1194 } 1190 }
OLDNEW
« no previous file with comments | « fpdfsdk/pdfwindow/PWL_ScrollBar.h ('k') | fpdfsdk/pdfwindow/PWL_SpecialButton.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698