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_IFWL_SCROLLBAR_H_ | |
8 #define XFA_FWL_CORE_IFWL_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_widgetproperties.h" | |
16 #include "xfa/fwl/core/ifwl_widget.h" | |
17 | |
18 class IFWL_Widget; | |
19 | |
20 #define FWL_STYLEEXT_SCB_Horz (0L << 0) | |
21 #define FWL_STYLEEXT_SCB_Vert (1L << 0) | |
22 | |
23 class IFWL_ScrollBar : public IFWL_Widget { | |
24 public: | |
25 IFWL_ScrollBar(const CFWL_App* app, | |
26 std::unique_ptr<CFWL_WidgetProperties> properties, | |
27 IFWL_Widget* pOuter); | |
28 ~IFWL_ScrollBar() override; | |
29 | |
30 // IFWL_Widget | |
31 FWL_Type GetClassID() const override; | |
32 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; | |
33 void Update() override; | |
34 void DrawWidget(CFX_Graphics* pGraphics, | |
35 const CFX_Matrix* pMatrix = nullptr) override; | |
36 void OnProcessMessage(CFWL_Message* pMessage) override; | |
37 void OnDrawWidget(CFX_Graphics* pGraphics, | |
38 const CFX_Matrix* pMatrix) override; | |
39 | |
40 void GetRange(FX_FLOAT* fMin, FX_FLOAT* fMax) const { | |
41 ASSERT(fMin); | |
42 ASSERT(fMax); | |
43 *fMin = m_fRangeMin; | |
44 *fMax = m_fRangeMax; | |
45 } | |
46 void SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { | |
47 m_fRangeMin = fMin; | |
48 m_fRangeMax = fMax; | |
49 } | |
50 FX_FLOAT GetPageSize() const { return m_fPageSize; } | |
51 void SetPageSize(FX_FLOAT fPageSize) { m_fPageSize = fPageSize; } | |
52 FX_FLOAT GetStepSize() const { return m_fStepSize; } | |
53 void SetStepSize(FX_FLOAT fStepSize) { m_fStepSize = fStepSize; } | |
54 FX_FLOAT GetPos() const { return m_fPos; } | |
55 void SetPos(FX_FLOAT fPos) { m_fPos = fPos; } | |
56 void SetTrackPos(FX_FLOAT fTrackPos); | |
57 | |
58 private: | |
59 class Timer : public CFWL_Timer { | |
60 public: | |
61 explicit Timer(IFWL_ScrollBar* pToolTip); | |
62 ~Timer() override {} | |
63 | |
64 void Run(CFWL_TimerInfo* pTimerInfo) override; | |
65 }; | |
66 friend class IFWL_ScrollBar::Timer; | |
67 | |
68 bool IsVertical() const { | |
69 return !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert); | |
70 } | |
71 void DrawTrack(CFX_Graphics* pGraphics, | |
72 IFWL_ThemeProvider* pTheme, | |
73 bool bLower = true, | |
74 const CFX_Matrix* pMatrix = nullptr); | |
75 void DrawArrowBtn(CFX_Graphics* pGraphics, | |
76 IFWL_ThemeProvider* pTheme, | |
77 bool bMinBtn = true, | |
78 const CFX_Matrix* pMatrix = nullptr); | |
79 void DrawThumb(CFX_Graphics* pGraphics, | |
80 IFWL_ThemeProvider* pTheme, | |
81 const CFX_Matrix* pMatrix = nullptr); | |
82 void Layout(); | |
83 void CalcButtonLen(); | |
84 void CalcMinButtonRect(CFX_RectF& rect); | |
85 void CalcMaxButtonRect(CFX_RectF& rect); | |
86 void CalcThumbButtonRect(CFX_RectF& rect); | |
87 void CalcMinTrackRect(CFX_RectF& rect); | |
88 void CalcMaxTrackRect(CFX_RectF& rect); | |
89 FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); | |
90 void GetTrackRect(CFX_RectF& rect, bool bLower = true); | |
91 bool SendEvent(); | |
92 bool OnScroll(FWL_SCBCODE dwCode, FX_FLOAT fPos); | |
93 void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
94 void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
95 void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
96 void OnMouseLeave(); | |
97 void OnMouseWheel(FX_FLOAT fx, | |
98 FX_FLOAT fy, | |
99 uint32_t dwFlags, | |
100 FX_FLOAT fDeltaX, | |
101 FX_FLOAT fDeltaY); | |
102 bool DoScroll(FWL_SCBCODE dwCode, FX_FLOAT fPos = 0.0f); | |
103 void DoMouseDown(int32_t iItem, | |
104 const CFX_RectF& rtItem, | |
105 int32_t& iState, | |
106 FX_FLOAT fx, | |
107 FX_FLOAT fy); | |
108 void DoMouseUp(int32_t iItem, | |
109 const CFX_RectF& rtItem, | |
110 int32_t& iState, | |
111 FX_FLOAT fx, | |
112 FX_FLOAT fy); | |
113 void DoMouseMove(int32_t iItem, | |
114 const CFX_RectF& rtItem, | |
115 int32_t& iState, | |
116 FX_FLOAT fx, | |
117 FX_FLOAT fy); | |
118 void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
119 void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
120 | |
121 CFWL_TimerInfo* m_pTimerInfo; | |
122 FX_FLOAT m_fRangeMin; | |
123 FX_FLOAT m_fRangeMax; | |
124 FX_FLOAT m_fPageSize; | |
125 FX_FLOAT m_fStepSize; | |
126 FX_FLOAT m_fPos; | |
127 FX_FLOAT m_fTrackPos; | |
128 int32_t m_iMinButtonState; | |
129 int32_t m_iMaxButtonState; | |
130 int32_t m_iThumbButtonState; | |
131 int32_t m_iMinTrackState; | |
132 int32_t m_iMaxTrackState; | |
133 FX_FLOAT m_fLastTrackPos; | |
134 FX_FLOAT m_cpTrackPointX; | |
135 FX_FLOAT m_cpTrackPointY; | |
136 int32_t m_iMouseWheel; | |
137 bool m_bMouseDown; | |
138 FX_FLOAT m_fButtonLen; | |
139 bool m_bMinSize; | |
140 CFX_RectF m_rtClient; | |
141 CFX_RectF m_rtThumb; | |
142 CFX_RectF m_rtMinBtn; | |
143 CFX_RectF m_rtMaxBtn; | |
144 CFX_RectF m_rtMinTrack; | |
145 CFX_RectF m_rtMaxTrack; | |
146 FX_FLOAT m_fMinThumb; | |
147 IFWL_ScrollBar::Timer m_Timer; | |
148 }; | |
149 | |
150 #endif // XFA_FWL_CORE_IFWL_SCROLLBAR_H_ | |
OLD | NEW |