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_BASEWIDGET_FWL_SCROLLBARIMP_H_ | |
8 #define XFA_FWL_BASEWIDGET_FWL_SCROLLBARIMP_H_ | |
9 | |
10 #include "xfa/fwl/core/fwl_widgetimp.h" | |
11 #include "xfa/fwl/core/ifwl_timer.h" | |
12 #include "xfa/fwl/core/ifwl_widget.h" | |
13 | |
14 class CFWL_WidgetImpProperties; | |
15 class IFWL_Widget; | |
16 class CFWL_ScrollBarImpDelegate; | |
17 | |
18 class CFWL_ScrollBarImp : public CFWL_WidgetImp, public IFWL_Timer { | |
19 public: | |
20 CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, | |
21 IFWL_Widget* pOuter); | |
22 ~CFWL_ScrollBarImp() override; | |
23 | |
24 // CFWL_WidgetImp | |
25 FWL_Error GetClassName(CFX_WideString& wsClass) const override; | |
26 FWL_Type GetClassID() const override; | |
27 FWL_Error Initialize() override; | |
28 FWL_Error Finalize() override; | |
29 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | |
30 FWL_Error Update() override; | |
31 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | |
32 const CFX_Matrix* pMatrix = nullptr) override; | |
33 | |
34 // IFWL_Timer | |
35 void Run(IFWL_TimerInfo* pTimerInfo) override; | |
36 | |
37 FX_BOOL IsVertical(); | |
38 FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax); | |
39 FWL_Error SetRange(FX_FLOAT fMin, FX_FLOAT fMax); | |
40 FX_FLOAT GetPageSize(); | |
41 FWL_Error SetPageSize(FX_FLOAT fPageSize); | |
42 FX_FLOAT GetStepSize(); | |
43 FWL_Error SetStepSize(FX_FLOAT fStepSize); | |
44 FX_FLOAT GetPos(); | |
45 FWL_Error SetPos(FX_FLOAT fPos); | |
46 FX_FLOAT GetTrackPos(); | |
47 FWL_Error SetTrackPos(FX_FLOAT fTrackPos); | |
48 FX_BOOL DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f); | |
49 FWL_Error SetOuter(IFWL_Widget* pOuter); | |
50 | |
51 protected: | |
52 friend class CFWL_ScrollBarImpDelegate; | |
53 | |
54 void DrawTrack(CFX_Graphics* pGraphics, | |
55 IFWL_ThemeProvider* pTheme, | |
56 FX_BOOL bLower = TRUE, | |
57 const CFX_Matrix* pMatrix = nullptr); | |
58 void DrawArrowBtn(CFX_Graphics* pGraphics, | |
59 IFWL_ThemeProvider* pTheme, | |
60 FX_BOOL bMinBtn = TRUE, | |
61 const CFX_Matrix* pMatrix = nullptr); | |
62 void DrawThumb(CFX_Graphics* pGraphics, | |
63 IFWL_ThemeProvider* pTheme, | |
64 const CFX_Matrix* pMatrix = nullptr); | |
65 void Layout(); | |
66 void CalcButtonLen(); | |
67 void CalcMinButtonRect(CFX_RectF& rect); | |
68 void CalcMaxButtonRect(CFX_RectF& rect); | |
69 void CalcThumbButtonRect(CFX_RectF& rect); | |
70 void CalcMinTrackRect(CFX_RectF& rect); | |
71 void CalcMaxTrackRect(CFX_RectF& rect); | |
72 FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); | |
73 void GetTrackRect(CFX_RectF& rect, FX_BOOL bLower = TRUE); | |
74 FX_BOOL SendEvent(); | |
75 FX_BOOL OnScroll(uint32_t dwCode, FX_FLOAT fPos); | |
76 | |
77 IFWL_TimerInfo* m_pTimerInfo; | |
78 FX_FLOAT m_fRangeMin; | |
79 FX_FLOAT m_fRangeMax; | |
80 FX_FLOAT m_fPageSize; | |
81 FX_FLOAT m_fStepSize; | |
82 FX_FLOAT m_fPos; | |
83 FX_FLOAT m_fTrackPos; | |
84 int32_t m_iMinButtonState; | |
85 int32_t m_iMaxButtonState; | |
86 int32_t m_iThumbButtonState; | |
87 int32_t m_iMinTrackState; | |
88 int32_t m_iMaxTrackState; | |
89 FX_FLOAT m_fLastTrackPos; | |
90 FX_FLOAT m_cpTrackPointX; | |
91 FX_FLOAT m_cpTrackPointY; | |
92 int32_t m_iMouseWheel; | |
93 FX_BOOL m_bTrackMouseLeave; | |
94 FX_BOOL m_bMouseHover; | |
95 FX_BOOL m_bMouseDown; | |
96 FX_BOOL m_bRepaintThumb; | |
97 FX_FLOAT m_fButtonLen; | |
98 FX_BOOL m_bMinSize; | |
99 CFX_RectF m_rtClient; | |
100 CFX_RectF m_rtThumb; | |
101 CFX_RectF m_rtMinBtn; | |
102 CFX_RectF m_rtMaxBtn; | |
103 CFX_RectF m_rtMinTrack; | |
104 CFX_RectF m_rtMaxTrack; | |
105 FX_BOOL m_bCustomLayout; | |
106 FX_FLOAT m_fMinThumb; | |
107 }; | |
108 | |
109 class CFWL_ScrollBarImpDelegate : public CFWL_WidgetImpDelegate { | |
110 public: | |
111 CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner); | |
112 void OnProcessMessage(CFWL_Message* pMessage) override; | |
113 void OnDrawWidget(CFX_Graphics* pGraphics, | |
114 const CFX_Matrix* pMatrix = nullptr) override; | |
115 | |
116 protected: | |
117 void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
118 void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
119 void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
120 void OnMouseLeave(); | |
121 void OnMouseWheel(FX_FLOAT fx, | |
122 FX_FLOAT fy, | |
123 uint32_t dwFlags, | |
124 FX_FLOAT fDeltaX, | |
125 FX_FLOAT fDeltaY); | |
126 void DoMouseDown(int32_t iItem, | |
127 const CFX_RectF& rtItem, | |
128 int32_t& iState, | |
129 FX_FLOAT fx, | |
130 FX_FLOAT fy); | |
131 void DoMouseUp(int32_t iItem, | |
132 const CFX_RectF& rtItem, | |
133 int32_t& iState, | |
134 FX_FLOAT fx, | |
135 FX_FLOAT fy); | |
136 void DoMouseMove(int32_t iItem, | |
137 const CFX_RectF& rtItem, | |
138 int32_t& iState, | |
139 FX_FLOAT fx, | |
140 FX_FLOAT fy); | |
141 void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
142 void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
143 | |
144 CFWL_ScrollBarImp* m_pOwner; | |
145 }; | |
146 | |
147 #endif // XFA_FWL_BASEWIDGET_FWL_SCROLLBARIMP_H_ | |
OLD | NEW |