| OLD | NEW |
| 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/include/pdfwindow/PDFWindow.h" | 7 #include "fpdfsdk/include/pdfwindow/PDFWindow.h" |
| 8 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" | 8 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" |
| 9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
| 11 | 11 |
| 12 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) | 12 #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) |
| 13 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) | 13 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
| 14 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) | 14 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
| 15 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) | 15 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
| 16 | 16 |
| 17 /* ------------------------------- PWL_FLOATRANGE | |
| 18 * ------------------------------- */ | |
| 19 | |
| 20 PWL_FLOATRANGE::PWL_FLOATRANGE() { | 17 PWL_FLOATRANGE::PWL_FLOATRANGE() { |
| 21 Default(); | 18 Default(); |
| 22 } | 19 } |
| 23 | 20 |
| 24 PWL_FLOATRANGE::PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max) { | 21 PWL_FLOATRANGE::PWL_FLOATRANGE(FX_FLOAT min, FX_FLOAT max) { |
| 25 Set(min, max); | 22 Set(min, max); |
| 26 } | 23 } |
| 27 | 24 |
| 28 void PWL_FLOATRANGE::Default() { | 25 void PWL_FLOATRANGE::Default() { |
| 29 fMin = 0; | 26 fMin = 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 42 | 39 |
| 43 FX_BOOL PWL_FLOATRANGE::In(FX_FLOAT x) const { | 40 FX_BOOL PWL_FLOATRANGE::In(FX_FLOAT x) const { |
| 44 return (IsFloatBigger(x, fMin) || IsFloatEqual(x, fMin)) && | 41 return (IsFloatBigger(x, fMin) || IsFloatEqual(x, fMin)) && |
| 45 (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax)); | 42 (IsFloatSmaller(x, fMax) || IsFloatEqual(x, fMax)); |
| 46 } | 43 } |
| 47 | 44 |
| 48 FX_FLOAT PWL_FLOATRANGE::GetWidth() const { | 45 FX_FLOAT PWL_FLOATRANGE::GetWidth() const { |
| 49 return fMax - fMin; | 46 return fMax - fMin; |
| 50 } | 47 } |
| 51 | 48 |
| 52 /* ------------------------------- PWL_SCROLL_PRIVATEDATA | |
| 53 * ------------------------------- */ | |
| 54 | |
| 55 PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() { | 49 PWL_SCROLL_PRIVATEDATA::PWL_SCROLL_PRIVATEDATA() { |
| 56 Default(); | 50 Default(); |
| 57 } | 51 } |
| 58 | 52 |
| 59 void PWL_SCROLL_PRIVATEDATA::Default() { | 53 void PWL_SCROLL_PRIVATEDATA::Default() { |
| 60 ScrollRange.Default(); | 54 ScrollRange.Default(); |
| 61 fScrollPos = ScrollRange.fMin; | 55 fScrollPos = ScrollRange.fMin; |
| 62 fClientWidth = 0; | 56 fClientWidth = 0; |
| 63 fBigStep = 10; | 57 fBigStep = 10; |
| 64 fSmallStep = 1; | 58 fSmallStep = 1; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 void PWL_SCROLL_PRIVATEDATA::AddBig() { | 100 void PWL_SCROLL_PRIVATEDATA::AddBig() { |
| 107 if (!SetPos(fScrollPos + fBigStep)) | 101 if (!SetPos(fScrollPos + fBigStep)) |
| 108 SetPos(ScrollRange.fMax); | 102 SetPos(ScrollRange.fMax); |
| 109 } | 103 } |
| 110 | 104 |
| 111 void PWL_SCROLL_PRIVATEDATA::SubBig() { | 105 void PWL_SCROLL_PRIVATEDATA::SubBig() { |
| 112 if (!SetPos(fScrollPos - fBigStep)) | 106 if (!SetPos(fScrollPos - fBigStep)) |
| 113 SetPos(ScrollRange.fMin); | 107 SetPos(ScrollRange.fMin); |
| 114 } | 108 } |
| 115 | 109 |
| 116 /* ------------------------------- CPWL_SBButton ------------------------------- | |
| 117 */ | |
| 118 | |
| 119 CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, | 110 CPWL_SBButton::CPWL_SBButton(PWL_SCROLLBAR_TYPE eScrollBarType, |
| 120 PWL_SBBUTTON_TYPE eButtonType) { | 111 PWL_SBBUTTON_TYPE eButtonType) { |
| 121 m_eScrollBarType = eScrollBarType; | 112 m_eScrollBarType = eScrollBarType; |
| 122 m_eSBButtonType = eButtonType; | 113 m_eSBButtonType = eButtonType; |
| 123 | 114 |
| 124 m_bMouseDown = FALSE; | 115 m_bMouseDown = FALSE; |
| 125 } | 116 } |
| 126 | 117 |
| 127 CPWL_SBButton::~CPWL_SBButton() {} | 118 CPWL_SBButton::~CPWL_SBButton() {} |
| 128 | 119 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 CPWL_Utils::DrawFillArea( | 389 CPWL_Utils::DrawFillArea( |
| 399 pDevice, pUser2Device, pts, 7, | 390 pDevice, pUser2Device, pts, 7, |
| 400 ArgbEncode(nTransparancy, 255, 255, 255)); | 391 ArgbEncode(nTransparancy, 255, 255, 255)); |
| 401 else | 392 else |
| 402 CPWL_Utils::DrawFillArea(pDevice, pUser2Device, pts, 7, | 393 CPWL_Utils::DrawFillArea(pDevice, pUser2Device, pts, 7, |
| 403 CPWL_Utils::PWLColorToFXColor( | 394 CPWL_Utils::PWLColorToFXColor( |
| 404 PWL_DEFAULT_HEAVYGRAYCOLOR, 255)); | 395 PWL_DEFAULT_HEAVYGRAYCOLOR, 255)); |
| 405 } | 396 } |
| 406 } break; | 397 } break; |
| 407 case PSBT_POS: { | 398 case PSBT_POS: { |
| 408 // CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device); | |
| 409 | |
| 410 // draw border | 399 // draw border |
| 411 CPDF_Rect rcDraw = rectWnd; | 400 CPDF_Rect rcDraw = rectWnd; |
| 412 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, | 401 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 413 ArgbEncode(nTransparancy, 100, 100, 100), | 402 ArgbEncode(nTransparancy, 100, 100, 100), |
| 414 0.0f); | 403 0.0f); |
| 415 | 404 |
| 416 // draw inner border | 405 // draw inner border |
| 417 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f); | 406 rcDraw = CPWL_Utils::DeflateRect(rectWnd, 0.5f); |
| 418 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, | 407 CPWL_Utils::DrawStrokeRect(pDevice, pUser2Device, rcDraw, |
| 419 ArgbEncode(nTransparancy, 255, 255, 255), | 408 ArgbEncode(nTransparancy, 255, 255, 255), |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 ptRight.y += 2.0f; | 514 ptRight.y += 2.0f; |
| 526 | 515 |
| 527 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, | 516 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, |
| 528 crStroke, 1.0f); | 517 crStroke, 1.0f); |
| 529 | 518 |
| 530 ptLeft.y += 2.0f; | 519 ptLeft.y += 2.0f; |
| 531 ptRight.y += 2.0f; | 520 ptRight.y += 2.0f; |
| 532 | 521 |
| 533 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, | 522 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, |
| 534 crStroke, 1.0f); | 523 crStroke, 1.0f); |
| 535 | |
| 536 /* | |
| 537 ptLeft.y += 1.5f; | |
| 538 ptRight.y += 1.5f; | |
| 539 | |
| 540 CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, ptLeft, ptRight, | |
| 541 ArgbEncode(nTransparancy,150,150,150),1.0f); | |
| 542 */ | |
| 543 } | 524 } |
| 544 } break; | 525 } break; |
| 545 default: | 526 default: |
| 546 break; | 527 break; |
| 547 } | 528 } |
| 548 break; | 529 break; |
| 549 default: | 530 default: |
| 550 break; | 531 break; |
| 551 } | 532 } |
| 552 } | 533 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 573 ReleaseCapture(); | 554 ReleaseCapture(); |
| 574 | 555 |
| 575 return TRUE; | 556 return TRUE; |
| 576 } | 557 } |
| 577 | 558 |
| 578 FX_BOOL CPWL_SBButton::OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) { | 559 FX_BOOL CPWL_SBButton::OnMouseMove(const CPDF_Point& point, FX_DWORD nFlag) { |
| 579 CPWL_Wnd::OnMouseMove(point, nFlag); | 560 CPWL_Wnd::OnMouseMove(point, nFlag); |
| 580 | 561 |
| 581 if (CPWL_Wnd* pParent = GetParentWindow()) { | 562 if (CPWL_Wnd* pParent = GetParentWindow()) { |
| 582 pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point); | 563 pParent->OnNotify(this, PNM_MOUSEMOVE, 0, (intptr_t)&point); |
| 583 | |
| 584 /* | |
| 585 if (m_bMouseDown && (m_eSBButtonType == PSBT_MIN || m_eSBButtonType == | |
| 586 PSBT_MAX)) | |
| 587 { | |
| 588 if | |
| 589 (!pParent->OnNotify(this,PNM_LBUTTONDOWN,nFlags,(intptr_t)&point)) | |
| 590 return FALSE; | |
| 591 } | |
| 592 */ | |
| 593 } | 564 } |
| 594 | 565 |
| 595 return TRUE; | 566 return TRUE; |
| 596 } | 567 } |
| 597 | 568 |
| 598 /* ------------------------------- CPWL_ScrollBar | |
| 599 * ---------------------------------- */ | |
| 600 | |
| 601 CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType) | 569 CPWL_ScrollBar::CPWL_ScrollBar(PWL_SCROLLBAR_TYPE sbType) |
| 602 : m_sbType(sbType), | 570 : m_sbType(sbType), |
| 603 m_pMinButton(NULL), | 571 m_pMinButton(NULL), |
| 604 m_pMaxButton(NULL), | 572 m_pMaxButton(NULL), |
| 605 m_pPosButton(NULL), | 573 m_pPosButton(NULL), |
| 606 m_bMouseDown(FALSE), | 574 m_bMouseDown(FALSE), |
| 607 m_bMinOrMax(FALSE), | 575 m_bMinOrMax(FALSE), |
| 608 m_bNotifyForever(TRUE) {} | 576 m_bNotifyForever(TRUE) {} |
| 609 | 577 |
| 610 CPWL_ScrollBar::~CPWL_ScrollBar() {} | 578 CPWL_ScrollBar::~CPWL_ScrollBar() {} |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 if (!IsFloatEqual(m_sData.fScrollPos, fOldPos)) | 884 if (!IsFloatEqual(m_sData.fScrollPos, fOldPos)) |
| 917 MovePosButton(TRUE); | 885 MovePosButton(TRUE); |
| 918 } | 886 } |
| 919 | 887 |
| 920 void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep) { | 888 void CPWL_ScrollBar::SetScrollStep(FX_FLOAT fBigStep, FX_FLOAT fSmallStep) { |
| 921 m_sData.SetBigStep(fBigStep); | 889 m_sData.SetBigStep(fBigStep); |
| 922 m_sData.SetSmallStep(fSmallStep); | 890 m_sData.SetSmallStep(fSmallStep); |
| 923 } | 891 } |
| 924 | 892 |
| 925 void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh) { | 893 void CPWL_ScrollBar::MovePosButton(FX_BOOL bRefresh) { |
| 926 ASSERT(m_pPosButton != NULL); | 894 ASSERT(m_pMinButton); |
| 927 ASSERT(m_pMinButton != NULL); | 895 ASSERT(m_pMaxButton); |
| 928 ASSERT(m_pMaxButton != NULL); | |
| 929 | 896 |
| 930 if (m_pPosButton->IsVisible()) { | 897 if (m_pPosButton->IsVisible()) { |
| 931 CPDF_Rect rcClient; | 898 CPDF_Rect rcClient; |
| 932 CPDF_Rect rcPosArea, rcPosButton; | 899 CPDF_Rect rcPosArea, rcPosButton; |
| 933 | 900 |
| 934 rcClient = GetClientRect(); | 901 rcClient = GetClientRect(); |
| 935 rcPosArea = GetScrollArea(); | 902 rcPosArea = GetScrollArea(); |
| 936 | 903 |
| 937 FX_FLOAT fLeft, fRight, fTop, fBottom; | 904 FX_FLOAT fLeft, fRight, fTop, fBottom; |
| 938 | 905 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 if (m_bMinOrMax) | 1167 if (m_bMinOrMax) |
| 1201 m_sData.SubSmall(); | 1168 m_sData.SubSmall(); |
| 1202 else | 1169 else |
| 1203 m_sData.AddSmall(); | 1170 m_sData.AddSmall(); |
| 1204 | 1171 |
| 1205 if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0) { | 1172 if (FXSYS_memcmp(&m_sData, &sTemp, sizeof(PWL_SCROLL_PRIVATEDATA)) != 0) { |
| 1206 MovePosButton(TRUE); | 1173 MovePosButton(TRUE); |
| 1207 NotifyScrollWindow(); | 1174 NotifyScrollWindow(); |
| 1208 } | 1175 } |
| 1209 } | 1176 } |
| OLD | NEW |