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 #ifndef XFA_FWL_CORE_IFWL_SCROLLBAR_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_SCROLLBAR_H_ |
8 #define XFA_FWL_CORE_IFWL_SCROLLBAR_H_ | 8 #define XFA_FWL_CORE_IFWL_SCROLLBAR_H_ |
9 | 9 |
10 #include "core/fxcrt/fx_system.h" | 10 #include "core/fxcrt/fx_system.h" |
11 #include "xfa/fwl/core/cfwl_widgetproperties.h" | 11 #include "xfa/fwl/core/cfwl_widgetproperties.h" |
12 #include "xfa/fwl/core/fwl_error.h" | |
13 #include "xfa/fwl/core/ifwl_dataprovider.h" | 12 #include "xfa/fwl/core/ifwl_dataprovider.h" |
14 #include "xfa/fwl/core/ifwl_timer.h" | 13 #include "xfa/fwl/core/ifwl_timer.h" |
15 #include "xfa/fwl/core/ifwl_widget.h" | 14 #include "xfa/fwl/core/ifwl_widget.h" |
16 | 15 |
17 class IFWL_Widget; | 16 class IFWL_Widget; |
18 | 17 |
19 #define FWL_STYLEEXT_SCB_Horz (0L << 0) | 18 #define FWL_STYLEEXT_SCB_Horz (0L << 0) |
20 #define FWL_STYLEEXT_SCB_Vert (1L << 0) | 19 #define FWL_STYLEEXT_SCB_Vert (1L << 0) |
21 | 20 |
22 enum FWL_SCBCODE { | 21 enum FWL_SCBCODE { |
(...skipping 21 matching lines...) Expand all Loading... | |
44 // IFWL_Widget | 43 // IFWL_Widget |
45 FWL_Type GetClassID() const override; | 44 FWL_Type GetClassID() const override; |
46 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; | 45 void GetWidgetRect(CFX_RectF& rect, bool bAutoSize = false) override; |
47 void Update() override; | 46 void Update() override; |
48 void DrawWidget(CFX_Graphics* pGraphics, | 47 void DrawWidget(CFX_Graphics* pGraphics, |
49 const CFX_Matrix* pMatrix = nullptr) override; | 48 const CFX_Matrix* pMatrix = nullptr) override; |
50 void OnProcessMessage(CFWL_Message* pMessage) override; | 49 void OnProcessMessage(CFWL_Message* pMessage) override; |
51 void OnDrawWidget(CFX_Graphics* pGraphics, | 50 void OnDrawWidget(CFX_Graphics* pGraphics, |
52 const CFX_Matrix* pMatrix) override; | 51 const CFX_Matrix* pMatrix) override; |
53 | 52 |
54 bool IsVertical(); | 53 void GetRange(FX_FLOAT* fMin, FX_FLOAT* fMax) const { |
dsinclair
2016/11/09 18:25:57
Updated this to *'s as well.
Tom Sepez
2016/11/09 18:46:08
Are these ever nullptrs? can we lose the checks?
dsinclair
2016/11/10 17:56:04
Made them ASSERTs.
| |
55 FWL_Error GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax); | 54 if (fMin) |
56 FWL_Error SetRange(FX_FLOAT fMin, FX_FLOAT fMax); | 55 *fMin = m_fRangeMin; |
57 FX_FLOAT GetPageSize(); | 56 if (fMax) |
58 FWL_Error SetPageSize(FX_FLOAT fPageSize); | 57 *fMax = m_fRangeMax; |
59 FX_FLOAT GetStepSize(); | 58 } |
60 FWL_Error SetStepSize(FX_FLOAT fStepSize); | 59 void SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { |
61 FX_FLOAT GetPos(); | 60 m_fRangeMin = fMin; |
62 FWL_Error SetPos(FX_FLOAT fPos); | 61 m_fRangeMax = fMax; |
63 FX_FLOAT GetTrackPos(); | 62 } |
64 FWL_Error SetTrackPos(FX_FLOAT fTrackPos); | 63 FX_FLOAT GetPageSize() const { return m_fPageSize; } |
65 bool DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f); | 64 void SetPageSize(FX_FLOAT fPageSize) { m_fPageSize = fPageSize; } |
66 FWL_Error SetOuter(IFWL_Widget* pOuter); | 65 FX_FLOAT GetStepSize() const { return m_fStepSize; } |
66 void SetStepSize(FX_FLOAT fStepSize) { m_fStepSize = fStepSize; } | |
67 FX_FLOAT GetPos() const { return m_fPos; } | |
68 void SetPos(FX_FLOAT fPos) { m_fPos = fPos; } | |
69 void SetTrackPos(FX_FLOAT fTrackPos); | |
67 | 70 |
68 protected: | 71 private: |
69 class Timer : public IFWL_Timer { | 72 class Timer : public IFWL_Timer { |
70 public: | 73 public: |
71 explicit Timer(IFWL_ScrollBar* pToolTip); | 74 explicit Timer(IFWL_ScrollBar* pToolTip); |
72 ~Timer() override {} | 75 ~Timer() override {} |
73 | 76 |
74 void Run(IFWL_TimerInfo* pTimerInfo) override; | 77 void Run(IFWL_TimerInfo* pTimerInfo) override; |
75 }; | 78 }; |
76 friend class IFWL_ScrollBar::Timer; | 79 friend class IFWL_ScrollBar::Timer; |
77 | 80 |
78 IFWL_ScrollBar(); | 81 bool IsVertical() const { |
82 return !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert); | |
83 } | |
79 void DrawTrack(CFX_Graphics* pGraphics, | 84 void DrawTrack(CFX_Graphics* pGraphics, |
80 IFWL_ThemeProvider* pTheme, | 85 IFWL_ThemeProvider* pTheme, |
81 bool bLower = true, | 86 bool bLower = true, |
82 const CFX_Matrix* pMatrix = nullptr); | 87 const CFX_Matrix* pMatrix = nullptr); |
83 void DrawArrowBtn(CFX_Graphics* pGraphics, | 88 void DrawArrowBtn(CFX_Graphics* pGraphics, |
84 IFWL_ThemeProvider* pTheme, | 89 IFWL_ThemeProvider* pTheme, |
85 bool bMinBtn = true, | 90 bool bMinBtn = true, |
86 const CFX_Matrix* pMatrix = nullptr); | 91 const CFX_Matrix* pMatrix = nullptr); |
87 void DrawThumb(CFX_Graphics* pGraphics, | 92 void DrawThumb(CFX_Graphics* pGraphics, |
88 IFWL_ThemeProvider* pTheme, | 93 IFWL_ThemeProvider* pTheme, |
89 const CFX_Matrix* pMatrix = nullptr); | 94 const CFX_Matrix* pMatrix = nullptr); |
90 void Layout(); | 95 void Layout(); |
91 void CalcButtonLen(); | 96 void CalcButtonLen(); |
92 void CalcMinButtonRect(CFX_RectF& rect); | 97 void CalcMinButtonRect(CFX_RectF& rect); |
93 void CalcMaxButtonRect(CFX_RectF& rect); | 98 void CalcMaxButtonRect(CFX_RectF& rect); |
94 void CalcThumbButtonRect(CFX_RectF& rect); | 99 void CalcThumbButtonRect(CFX_RectF& rect); |
95 void CalcMinTrackRect(CFX_RectF& rect); | 100 void CalcMinTrackRect(CFX_RectF& rect); |
96 void CalcMaxTrackRect(CFX_RectF& rect); | 101 void CalcMaxTrackRect(CFX_RectF& rect); |
97 FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); | 102 FX_FLOAT GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy); |
98 void GetTrackRect(CFX_RectF& rect, bool bLower = true); | 103 void GetTrackRect(CFX_RectF& rect, bool bLower = true); |
99 bool SendEvent(); | 104 bool SendEvent(); |
100 bool OnScroll(uint32_t dwCode, FX_FLOAT fPos); | 105 bool OnScroll(uint32_t dwCode, FX_FLOAT fPos); |
106 void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
107 void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
108 void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
109 void OnMouseLeave(); | |
110 void OnMouseWheel(FX_FLOAT fx, | |
111 FX_FLOAT fy, | |
112 uint32_t dwFlags, | |
113 FX_FLOAT fDeltaX, | |
114 FX_FLOAT fDeltaY); | |
115 bool DoScroll(uint32_t dwCode, FX_FLOAT fPos = 0.0f); | |
116 void DoMouseDown(int32_t iItem, | |
117 const CFX_RectF& rtItem, | |
118 int32_t& iState, | |
119 FX_FLOAT fx, | |
120 FX_FLOAT fy); | |
121 void DoMouseUp(int32_t iItem, | |
122 const CFX_RectF& rtItem, | |
123 int32_t& iState, | |
124 FX_FLOAT fx, | |
125 FX_FLOAT fy); | |
126 void DoMouseMove(int32_t iItem, | |
127 const CFX_RectF& rtItem, | |
128 int32_t& iState, | |
129 FX_FLOAT fx, | |
130 FX_FLOAT fy); | |
131 void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
132 void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
101 | 133 |
102 IFWL_TimerInfo* m_pTimerInfo; | 134 IFWL_TimerInfo* m_pTimerInfo; |
103 FX_FLOAT m_fRangeMin; | 135 FX_FLOAT m_fRangeMin; |
104 FX_FLOAT m_fRangeMax; | 136 FX_FLOAT m_fRangeMax; |
105 FX_FLOAT m_fPageSize; | 137 FX_FLOAT m_fPageSize; |
106 FX_FLOAT m_fStepSize; | 138 FX_FLOAT m_fStepSize; |
107 FX_FLOAT m_fPos; | 139 FX_FLOAT m_fPos; |
108 FX_FLOAT m_fTrackPos; | 140 FX_FLOAT m_fTrackPos; |
109 int32_t m_iMinButtonState; | 141 int32_t m_iMinButtonState; |
110 int32_t m_iMaxButtonState; | 142 int32_t m_iMaxButtonState; |
111 int32_t m_iThumbButtonState; | 143 int32_t m_iThumbButtonState; |
112 int32_t m_iMinTrackState; | 144 int32_t m_iMinTrackState; |
113 int32_t m_iMaxTrackState; | 145 int32_t m_iMaxTrackState; |
114 FX_FLOAT m_fLastTrackPos; | 146 FX_FLOAT m_fLastTrackPos; |
115 FX_FLOAT m_cpTrackPointX; | 147 FX_FLOAT m_cpTrackPointX; |
116 FX_FLOAT m_cpTrackPointY; | 148 FX_FLOAT m_cpTrackPointY; |
117 int32_t m_iMouseWheel; | 149 int32_t m_iMouseWheel; |
118 bool m_bTrackMouseLeave; | |
119 bool m_bMouseHover; | |
120 bool m_bMouseDown; | 150 bool m_bMouseDown; |
121 bool m_bRepaintThumb; | |
122 FX_FLOAT m_fButtonLen; | 151 FX_FLOAT m_fButtonLen; |
123 bool m_bMinSize; | 152 bool m_bMinSize; |
124 CFX_RectF m_rtClient; | 153 CFX_RectF m_rtClient; |
125 CFX_RectF m_rtThumb; | 154 CFX_RectF m_rtThumb; |
126 CFX_RectF m_rtMinBtn; | 155 CFX_RectF m_rtMinBtn; |
127 CFX_RectF m_rtMaxBtn; | 156 CFX_RectF m_rtMaxBtn; |
128 CFX_RectF m_rtMinTrack; | 157 CFX_RectF m_rtMinTrack; |
129 CFX_RectF m_rtMaxTrack; | 158 CFX_RectF m_rtMaxTrack; |
130 bool m_bCustomLayout; | 159 bool m_bCustomLayout; |
131 FX_FLOAT m_fMinThumb; | 160 FX_FLOAT m_fMinThumb; |
132 IFWL_ScrollBar::Timer m_Timer; | 161 IFWL_ScrollBar::Timer m_Timer; |
133 | |
134 private: | |
135 void OnLButtonDown(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
136 void OnLButtonUp(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
137 void OnMouseMove(uint32_t dwFlags, FX_FLOAT fx, FX_FLOAT fy); | |
138 void OnMouseLeave(); | |
139 void OnMouseWheel(FX_FLOAT fx, | |
140 FX_FLOAT fy, | |
141 uint32_t dwFlags, | |
142 FX_FLOAT fDeltaX, | |
143 FX_FLOAT fDeltaY); | |
144 void DoMouseDown(int32_t iItem, | |
145 const CFX_RectF& rtItem, | |
146 int32_t& iState, | |
147 FX_FLOAT fx, | |
148 FX_FLOAT fy); | |
149 void DoMouseUp(int32_t iItem, | |
150 const CFX_RectF& rtItem, | |
151 int32_t& iState, | |
152 FX_FLOAT fx, | |
153 FX_FLOAT fy); | |
154 void DoMouseMove(int32_t iItem, | |
155 const CFX_RectF& rtItem, | |
156 int32_t& iState, | |
157 FX_FLOAT fx, | |
158 FX_FLOAT fy); | |
159 void DoMouseLeave(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
160 void DoMouseHover(int32_t iItem, const CFX_RectF& rtItem, int32_t& iState); | |
161 }; | 162 }; |
162 | 163 |
163 #endif // XFA_FWL_CORE_IFWL_SCROLLBAR_H_ | 164 #endif // XFA_FWL_CORE_IFWL_SCROLLBAR_H_ |
OLD | NEW |