| 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 "xfa/fwl/basewidget/fwl_scrollbarimp.h" | 7 #include "xfa/fwl/basewidget/fwl_scrollbarimp.h" |
| 8 | 8 |
| 9 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" | 9 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" |
| 10 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } | 55 } |
| 56 FWL_ERR IFWL_ScrollBar::SetPos(FX_FLOAT fPos) { | 56 FWL_ERR IFWL_ScrollBar::SetPos(FX_FLOAT fPos) { |
| 57 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetPos(fPos); | 57 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetPos(fPos); |
| 58 } | 58 } |
| 59 FX_FLOAT IFWL_ScrollBar::GetTrackPos() { | 59 FX_FLOAT IFWL_ScrollBar::GetTrackPos() { |
| 60 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetTrackPos(); | 60 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetTrackPos(); |
| 61 } | 61 } |
| 62 FWL_ERR IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { | 62 FWL_ERR IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { |
| 63 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos); | 63 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos); |
| 64 } | 64 } |
| 65 FX_BOOL IFWL_ScrollBar::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) { | 65 FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { |
| 66 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->DoScroll(dwCode, fPos); | 66 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->DoScroll(dwCode, fPos); |
| 67 } | 67 } |
| 68 CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, | 68 CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, |
| 69 IFWL_Widget* pOuter) | 69 IFWL_Widget* pOuter) |
| 70 : CFWL_WidgetImp(properties, pOuter), | 70 : CFWL_WidgetImp(properties, pOuter), |
| 71 m_hTimer(nullptr), | 71 m_hTimer(nullptr), |
| 72 m_fRangeMin(0), | 72 m_fRangeMin(0), |
| 73 m_fRangeMax(-1), | 73 m_fRangeMax(-1), |
| 74 m_fPageSize(0), | 74 m_fPageSize(0), |
| 75 m_fStepSize(0), | 75 m_fStepSize(0), |
| (...skipping 21 matching lines...) Expand all Loading... |
| 97 m_rtMinBtn.Reset(); | 97 m_rtMinBtn.Reset(); |
| 98 m_rtMaxBtn.Reset(); | 98 m_rtMaxBtn.Reset(); |
| 99 m_rtMinTrack.Reset(); | 99 m_rtMinTrack.Reset(); |
| 100 m_rtMaxTrack.Reset(); | 100 m_rtMaxTrack.Reset(); |
| 101 } | 101 } |
| 102 CFWL_ScrollBarImp::~CFWL_ScrollBarImp() {} | 102 CFWL_ScrollBarImp::~CFWL_ScrollBarImp() {} |
| 103 FWL_ERR CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const { | 103 FWL_ERR CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const { |
| 104 wsClass = FWL_CLASS_ScrollBar; | 104 wsClass = FWL_CLASS_ScrollBar; |
| 105 return FWL_ERR_Succeeded; | 105 return FWL_ERR_Succeeded; |
| 106 } | 106 } |
| 107 FX_DWORD CFWL_ScrollBarImp::GetClassID() const { | 107 uint32_t CFWL_ScrollBarImp::GetClassID() const { |
| 108 return FWL_CLASSHASH_ScrollBar; | 108 return FWL_CLASSHASH_ScrollBar; |
| 109 } | 109 } |
| 110 FWL_ERR CFWL_ScrollBarImp::Initialize() { | 110 FWL_ERR CFWL_ScrollBarImp::Initialize() { |
| 111 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) | 111 if (CFWL_WidgetImp::Initialize() != FWL_ERR_Succeeded) |
| 112 return FWL_ERR_Indefinite; | 112 return FWL_ERR_Indefinite; |
| 113 m_pDelegate = new CFWL_ScrollBarImpDelegate(this); | 113 m_pDelegate = new CFWL_ScrollBarImpDelegate(this); |
| 114 return FWL_ERR_Succeeded; | 114 return FWL_ERR_Succeeded; |
| 115 } | 115 } |
| 116 FWL_ERR CFWL_ScrollBarImp::Finalize() { | 116 FWL_ERR CFWL_ScrollBarImp::Finalize() { |
| 117 delete m_pDelegate; | 117 delete m_pDelegate; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 FX_FLOAT CFWL_ScrollBarImp::GetTrackPos() { | 203 FX_FLOAT CFWL_ScrollBarImp::GetTrackPos() { |
| 204 return m_fTrackPos; | 204 return m_fTrackPos; |
| 205 } | 205 } |
| 206 FWL_ERR CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) { | 206 FWL_ERR CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) { |
| 207 m_fTrackPos = fTrackPos; | 207 m_fTrackPos = fTrackPos; |
| 208 CalcThumbButtonRect(m_rtThumb); | 208 CalcThumbButtonRect(m_rtThumb); |
| 209 CalcMinTrackRect(m_rtMinTrack); | 209 CalcMinTrackRect(m_rtMinTrack); |
| 210 CalcMaxTrackRect(m_rtMaxTrack); | 210 CalcMaxTrackRect(m_rtMaxTrack); |
| 211 return FWL_ERR_Succeeded; | 211 return FWL_ERR_Succeeded; |
| 212 } | 212 } |
| 213 FX_BOOL CFWL_ScrollBarImp::DoScroll(FX_DWORD dwCode, FX_FLOAT fPos) { | 213 FX_BOOL CFWL_ScrollBarImp::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { |
| 214 switch (dwCode) { | 214 switch (dwCode) { |
| 215 case FWL_SCBCODE_Min: | 215 case FWL_SCBCODE_Min: |
| 216 case FWL_SCBCODE_Max: | 216 case FWL_SCBCODE_Max: |
| 217 case FWL_SCBCODE_PageBackward: | 217 case FWL_SCBCODE_PageBackward: |
| 218 case FWL_SCBCODE_PageForward: | 218 case FWL_SCBCODE_PageForward: |
| 219 case FWL_SCBCODE_StepBackward: | 219 case FWL_SCBCODE_StepBackward: |
| 220 break; | 220 break; |
| 221 case FWL_SCBCODE_StepForward: | 221 case FWL_SCBCODE_StepForward: |
| 222 break; | 222 break; |
| 223 case FWL_SCBCODE_Pos: | 223 case FWL_SCBCODE_Pos: |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos); | 608 DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos); |
| 609 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); | 609 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); |
| 610 } | 610 } |
| 611 if (m_iMouseWheel) { | 611 if (m_iMouseWheel) { |
| 612 uint16_t dwCode = | 612 uint16_t dwCode = |
| 613 m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward; | 613 m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward; |
| 614 DoScroll(dwCode, m_fTrackPos); | 614 DoScroll(dwCode, m_fTrackPos); |
| 615 } | 615 } |
| 616 return TRUE; | 616 return TRUE; |
| 617 } | 617 } |
| 618 FX_BOOL CFWL_ScrollBarImp::OnScroll(FX_DWORD dwCode, FX_FLOAT fPos) { | 618 FX_BOOL CFWL_ScrollBarImp::OnScroll(uint32_t dwCode, FX_FLOAT fPos) { |
| 619 FX_BOOL bRet = TRUE; | 619 FX_BOOL bRet = TRUE; |
| 620 CFWL_EvtScroll ev; | 620 CFWL_EvtScroll ev; |
| 621 ev.m_iScrollCode = dwCode; | 621 ev.m_iScrollCode = dwCode; |
| 622 ev.m_pSrcTarget = m_pInterface; | 622 ev.m_pSrcTarget = m_pInterface; |
| 623 ev.m_fPos = fPos; | 623 ev.m_fPos = fPos; |
| 624 ev.m_pRet = &bRet; | 624 ev.m_pRet = &bRet; |
| 625 DispatchEvent(&ev); | 625 DispatchEvent(&ev); |
| 626 return bRet; | 626 return bRet; |
| 627 } | 627 } |
| 628 CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner) | 628 CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner) |
| 629 : m_pOwner(pOwner) {} | 629 : m_pOwner(pOwner) {} |
| 630 int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 630 int32_t CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 631 if (!pMessage) | 631 if (!pMessage) |
| 632 return 0; | 632 return 0; |
| 633 int32_t iRet = 1; | 633 int32_t iRet = 1; |
| 634 FX_DWORD dwMsgCode = pMessage->GetClassID(); | 634 uint32_t dwMsgCode = pMessage->GetClassID(); |
| 635 if (dwMsgCode == FWL_MSGHASH_Mouse) { | 635 if (dwMsgCode == FWL_MSGHASH_Mouse) { |
| 636 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 636 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 637 FX_DWORD dwCmd = pMsg->m_dwCmd; | 637 uint32_t dwCmd = pMsg->m_dwCmd; |
| 638 switch (dwCmd) { | 638 switch (dwCmd) { |
| 639 case FWL_MSGMOUSECMD_LButtonDown: { | 639 case FWL_MSGMOUSECMD_LButtonDown: { |
| 640 OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); | 640 OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); |
| 641 break; | 641 break; |
| 642 } | 642 } |
| 643 case FWL_MSGMOUSECMD_LButtonUp: { | 643 case FWL_MSGMOUSECMD_LButtonUp: { |
| 644 OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); | 644 OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); |
| 645 break; | 645 break; |
| 646 } | 646 } |
| 647 case FWL_MSGMOUSECMD_MouseMove: { | 647 case FWL_MSGMOUSECMD_MouseMove: { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 660 pMsg->m_fDeltaY); | 660 pMsg->m_fDeltaY); |
| 661 } else { | 661 } else { |
| 662 iRet = 0; | 662 iRet = 0; |
| 663 } | 663 } |
| 664 return iRet; | 664 return iRet; |
| 665 } | 665 } |
| 666 FWL_ERR CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 666 FWL_ERR CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 667 const CFX_Matrix* pMatrix) { | 667 const CFX_Matrix* pMatrix) { |
| 668 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 668 return m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 669 } | 669 } |
| 670 void CFWL_ScrollBarImpDelegate::OnLButtonDown(FX_DWORD dwFlags, | 670 void CFWL_ScrollBarImpDelegate::OnLButtonDown(uint32_t dwFlags, |
| 671 FX_FLOAT fx, | 671 FX_FLOAT fx, |
| 672 FX_FLOAT fy) { | 672 FX_FLOAT fy) { |
| 673 if (!m_pOwner->IsEnabled()) { | 673 if (!m_pOwner->IsEnabled()) { |
| 674 return; | 674 return; |
| 675 } | 675 } |
| 676 m_pOwner->m_bMouseDown = TRUE; | 676 m_pOwner->m_bMouseDown = TRUE; |
| 677 m_pOwner->SetGrab(TRUE); | 677 m_pOwner->SetGrab(TRUE); |
| 678 m_pOwner->m_cpTrackPointX = fx; | 678 m_pOwner->m_cpTrackPointX = fx; |
| 679 m_pOwner->m_cpTrackPointY = fy; | 679 m_pOwner->m_cpTrackPointY = fy; |
| 680 m_pOwner->m_fLastTrackPos = m_pOwner->m_fTrackPos; | 680 m_pOwner->m_fLastTrackPos = m_pOwner->m_fTrackPos; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 696 DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, | 696 DoMouseDown(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, |
| 697 fy); | 697 fy); |
| 698 } | 698 } |
| 699 } | 699 } |
| 700 } | 700 } |
| 701 } | 701 } |
| 702 if (!m_pOwner->SendEvent()) { | 702 if (!m_pOwner->SendEvent()) { |
| 703 m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse); | 703 m_pOwner->m_hTimer = FWL_StartTimer(m_pOwner, FWL_SCROLLBAR_Elapse); |
| 704 } | 704 } |
| 705 } | 705 } |
| 706 void CFWL_ScrollBarImpDelegate::OnLButtonUp(FX_DWORD dwFlags, | 706 void CFWL_ScrollBarImpDelegate::OnLButtonUp(uint32_t dwFlags, |
| 707 FX_FLOAT fx, | 707 FX_FLOAT fx, |
| 708 FX_FLOAT fy) { | 708 FX_FLOAT fy) { |
| 709 FWL_StopTimer(m_pOwner->m_hTimer); | 709 FWL_StopTimer(m_pOwner->m_hTimer); |
| 710 m_pOwner->m_bMouseDown = FALSE; | 710 m_pOwner->m_bMouseDown = FALSE; |
| 711 DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); | 711 DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); |
| 712 DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); | 712 DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); |
| 713 DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); | 713 DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); |
| 714 DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); | 714 DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); |
| 715 DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); | 715 DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); |
| 716 m_pOwner->SetGrab(FALSE); | 716 m_pOwner->SetGrab(FALSE); |
| 717 } | 717 } |
| 718 void CFWL_ScrollBarImpDelegate::OnMouseMove(FX_DWORD dwFlags, | 718 void CFWL_ScrollBarImpDelegate::OnMouseMove(uint32_t dwFlags, |
| 719 FX_FLOAT fx, | 719 FX_FLOAT fx, |
| 720 FX_FLOAT fy) { | 720 FX_FLOAT fy) { |
| 721 DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); | 721 DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); |
| 722 DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); | 722 DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); |
| 723 DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); | 723 DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); |
| 724 DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); | 724 DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); |
| 725 DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); | 725 DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); |
| 726 } | 726 } |
| 727 void CFWL_ScrollBarImpDelegate::OnMouseLeave() { | 727 void CFWL_ScrollBarImpDelegate::OnMouseLeave() { |
| 728 DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState); | 728 DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState); |
| 729 DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState); | 729 DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState); |
| 730 DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState); | 730 DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState); |
| 731 DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState); | 731 DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState); |
| 732 DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState); | 732 DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState); |
| 733 } | 733 } |
| 734 void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx, | 734 void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx, |
| 735 FX_FLOAT fy, | 735 FX_FLOAT fy, |
| 736 FX_DWORD dwFlags, | 736 uint32_t dwFlags, |
| 737 FX_FLOAT fDeltaX, | 737 FX_FLOAT fDeltaX, |
| 738 FX_FLOAT fDeltaY) { | 738 FX_FLOAT fDeltaY) { |
| 739 m_pOwner->m_iMouseWheel = (int32_t)fDeltaX; | 739 m_pOwner->m_iMouseWheel = (int32_t)fDeltaX; |
| 740 m_pOwner->SendEvent(); | 740 m_pOwner->SendEvent(); |
| 741 m_pOwner->m_iMouseWheel = 0; | 741 m_pOwner->m_iMouseWheel = 0; |
| 742 } | 742 } |
| 743 void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem, | 743 void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem, |
| 744 const CFX_RectF& rtItem, | 744 const CFX_RectF& rtItem, |
| 745 int32_t& iState, | 745 int32_t& iState, |
| 746 FX_FLOAT fx, | 746 FX_FLOAT fx, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 } | 799 } |
| 800 void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem, | 800 void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem, |
| 801 const CFX_RectF& rtItem, | 801 const CFX_RectF& rtItem, |
| 802 int32_t& iState) { | 802 int32_t& iState) { |
| 803 if (iState == FWL_PARTSTATE_SCB_Hovered) { | 803 if (iState == FWL_PARTSTATE_SCB_Hovered) { |
| 804 return; | 804 return; |
| 805 } | 805 } |
| 806 iState = FWL_PARTSTATE_SCB_Hovered; | 806 iState = FWL_PARTSTATE_SCB_Hovered; |
| 807 m_pOwner->Repaint(&rtItem); | 807 m_pOwner->Repaint(&rtItem); |
| 808 } | 808 } |
| OLD | NEW |