| OLD | NEW |
| (Empty) |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | |
| 6 | |
| 7 #ifndef XFA_FWL_CORE_CFWL_SCROLLBAR_H_ | |
| 8 #define XFA_FWL_CORE_CFWL_SCROLLBAR_H_ | |
| 9 | |
| 10 #include <memory> | |
| 11 | |
| 12 #include "core/fxcrt/fx_system.h" | |
| 13 #include "xfa/fwl/core/cfwl_evtscroll.h" | |
| 14 #include "xfa/fwl/core/cfwl_timer.h" | |
| 15 #include "xfa/fwl/core/cfwl_widget.h" | |
| 16 #include "xfa/fwl/core/cfwl_widgetproperties.h" | |
| 17 | |
| 18 class CFWL_Widget; | |
| 19 | |
| 20 #define FWL_STYLEEXT_SCB_Horz (0L << 0) | |
| 21 #define FWL_STYLEEXT_SCB_Vert (1L << 0) | |
| 22 | |
| 23 class CFWL_ScrollBar : public CFWL_Widget { | |
| 24 public: | |
| 25 CFWL_ScrollBar(const CFWL_App* app, | |
| 26 std::unique_ptr<CFWL_WidgetProperties> properties, | |
| 27 CFWL_Widget* pOuter); | |
| 28 ~CFWL_ScrollBar() override; | |
| 29 | |
| 30 // CFWL_Widget | |
| 31 FWL_Type GetClassID() const override; | |
| 32 void Update() override; | |
| 33 void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override; | |
| 34 void OnProcessMessage(CFWL_Message* pMessage) override; | |
| 35 void OnDrawWidget(CFX_Graphics* pGraphics, | |
| 36 const CFX_Matrix* pMatrix) override; | |
| 37 | |
| 38 void GetRange(FX_FLOAT* fMin, FX_FLOAT* fMax) const { | |
| 39 ASSERT(fMin); | |
| 40 ASSERT(fMax); | |
| 41 *fMin = m_fRangeMin; | |
| 42 *fMax = m_fRangeMax; | |
| 43 } | |
| 44 void SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { | |
| 45 m_fRangeMin = fMin; | |
| 46 m_fRangeMax = fMax; | |
| 47 } | |
| 48 FX_FLOAT GetPageSize() const { return m_fPageSize; } | |
| 49 void SetPageSize(FX_FLOAT fPageSize) { m_fPageSize = fPageSize; } | |
| 50 FX_FLOAT GetStepSize() const { return m_fStepSize; } | |
| 51 void SetStepSize(FX_FLOAT fStepSize) { m_fStepSize = fStepSize; } | |
| 52 FX_FLOAT GetPos() const { return m_fPos; } | |
| 53 void SetPos(FX_FLOAT fPos) { m_fPos = fPos; } | |
| 54 void SetTrackPos(FX_FLOAT fTrackPos); | |
| 55 | |
| 56 private: | |
| 57 class Timer : public CFWL_Timer { | |
| 58 public: | |
| 59 explicit Timer(CFWL_ScrollBar* pToolTip); | |
| 60 ~Timer() override {} | |
| 61 | |
| 62 void Run(CFWL_TimerInfo* pTimerInfo) override; | |
| 63 }; | |
| 64 friend class CFWL_ScrollBar::Timer; | |
| 65 | |
| 66 bool IsVertical() const { | |
| 67 return !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert); | |
| 68 } | |
| 69 void DrawTrack(CFX_Graphics* pGraphics, | |
| 70 IFWL_ThemeProvider* pTheme, | |
| 71 bool bLower, | |
| 72 const CFX_Matrix* pMatrix); | |
| 73 void DrawArrowBtn(CFX_Graphics* pGraphics, | |
| 74 IFWL_ThemeProvider* pTheme, | |
| 75 bool bMinBtn, | |
| 76 const CFX_Matrix* pMatrix); | |
| 77 void DrawThumb(CFX_Graphics* pGraphics, | |
| 78 IFWL_ThemeProvider* pTheme, | |
| 79 const CFX_Matrix* pMatrix); | |
| 80 void Layout(); | |
| 81 void CalcButtonLen(); | |
| 82 void CalcMinButtonRect(CFX_RectF& rect); | |
| 83 void CalcMaxButtonRect(CFX_RectF& rect); | |
| 84 void CalcThumbButtonRect(CFX_RectF& rect); | |
| 85 void CalcMinTrackRect(CFX_RectF& rect); | |
| 86 void CalcMaxTrackRect(CFX_RectF& rect); | |
| 87 FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); | |
| 88 | |
| 89 bool SendEvent(); | |
| 90 bool OnScroll(CFWL_EvtScroll::Code dwCode, FX_FLOAT fPos); | |
| 91 void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
| 92 void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
| 93 void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
| 94 void OnMouseLeave(); | |
| 95 void OnMouseWheel(FX_FLOAT fx, | |
| 96 FX_FLOAT fy, | |
| 97 uint32_t dwFlags, | |
| 98 FX_FLOAT fDeltaX, | |
| 99 FX_FLOAT fDeltaY); | |
| 100 bool DoScroll(CFWL_EvtScroll::Code dwCode, FX_FLOAT fPos); | |
| 101 void DoMouseDown(int32_t iItem, | |
| 102 const CFX_RectF& rtItem, | |
| 103 int32_t& iState, | |
| 104 FX_FLOAT fx, | |
| 105 FX_FLOAT fy); | |
| 106 void DoMouseUp(int32_t iItem, | |
| 107 const CFX_RectF& rtItem, | |
| 108 int32_t& iState, | |
| 109 FX_FLOAT fx, | |
| 110 FX_FLOAT fy); | |
| 111 void DoMouseMove(int32_t iItem, | |
| 112 const CFX_RectF& rtItem, | |
| 113 int32_t& iState, | |
| 114 FX_FLOAT fx, | |
| 115 FX_FLOAT fy); | |
| 116 void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
| 117 void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
| 118 | |
| 119 CFWL_TimerInfo* m_pTimerInfo; | |
| 120 FX_FLOAT m_fRangeMin; | |
| 121 FX_FLOAT m_fRangeMax; | |
| 122 FX_FLOAT m_fPageSize; | |
| 123 FX_FLOAT m_fStepSize; | |
| 124 FX_FLOAT m_fPos; | |
| 125 FX_FLOAT m_fTrackPos; | |
| 126 int32_t m_iMinButtonState; | |
| 127 int32_t m_iMaxButtonState; | |
| 128 int32_t m_iThumbButtonState; | |
| 129 int32_t m_iMinTrackState; | |
| 130 int32_t m_iMaxTrackState; | |
| 131 FX_FLOAT m_fLastTrackPos; | |
| 132 FX_FLOAT m_cpTrackPointX; | |
| 133 FX_FLOAT m_cpTrackPointY; | |
| 134 int32_t m_iMouseWheel; | |
| 135 bool m_bMouseDown; | |
| 136 FX_FLOAT m_fButtonLen; | |
| 137 bool m_bMinSize; | |
| 138 CFX_RectF m_rtClient; | |
| 139 CFX_RectF m_rtThumb; | |
| 140 CFX_RectF m_rtMinBtn; | |
| 141 CFX_RectF m_rtMaxBtn; | |
| 142 CFX_RectF m_rtMinTrack; | |
| 143 CFX_RectF m_rtMaxTrack; | |
| 144 FX_FLOAT m_fMinThumb; | |
| 145 CFWL_ScrollBar::Timer m_Timer; | |
| 146 }; | |
| 147 | |
| 148 #endif // XFA_FWL_CORE_CFWL_SCROLLBAR_H_ | |
| OLD | NEW |