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/core/ifwl_scrollbar.h" |
8 | 8 |
9 #include "xfa/fwl/basewidget/ifwl_scrollbar.h" | |
10 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
11 #include "xfa/fwl/core/cfwl_themebackground.h" | 10 #include "xfa/fwl/core/cfwl_themebackground.h" |
12 #include "xfa/fwl/core/cfwl_themepart.h" | 11 #include "xfa/fwl/core/cfwl_themepart.h" |
13 #include "xfa/fwl/core/fwl_noteimp.h" | 12 #include "xfa/fwl/core/fwl_noteimp.h" |
14 #include "xfa/fwl/core/fwl_widgetimp.h" | 13 #include "xfa/fwl/core/ifwl_scrollbar.h" |
15 #include "xfa/fwl/core/ifwl_themeprovider.h" | 14 #include "xfa/fwl/core/ifwl_themeprovider.h" |
16 | 15 |
17 #define FWL_SCROLLBAR_Elapse 500 | 16 #define FWL_SCROLLBAR_Elapse 500 |
18 #define FWL_SCROLLBAR_MinThumb 5 | 17 #define FWL_SCROLLBAR_MinThumb 5 |
19 | 18 |
20 // static | 19 // static |
21 IFWL_ScrollBar* IFWL_ScrollBar::Create( | 20 IFWL_ScrollBar* IFWL_ScrollBar::Create( |
22 const CFWL_WidgetImpProperties& properties, | 21 const CFWL_WidgetImpProperties& properties, |
23 IFWL_Widget* pOuter) { | 22 IFWL_Widget* pOuter) { |
24 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar; | 23 return new IFWL_ScrollBar(properties, pOuter); |
25 CFWL_ScrollBarImp* pScrollBarImpl = new CFWL_ScrollBarImp(properties, pOuter); | |
26 pScrollBar->SetImpl(pScrollBarImpl); | |
27 pScrollBarImpl->SetInterface(pScrollBar); | |
28 return pScrollBar; | |
29 } | 24 } |
30 IFWL_ScrollBar::IFWL_ScrollBar() {} | 25 |
31 FX_BOOL IFWL_ScrollBar::IsVertical() { | 26 IFWL_ScrollBar::IFWL_ScrollBar(const CFWL_WidgetImpProperties& properties, |
32 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->IsVertical(); | 27 IFWL_Widget* pOuter) |
33 } | 28 : IFWL_Widget(properties, pOuter), |
34 FWL_Error IFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { | |
35 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetRange(fMin, fMax); | |
36 } | |
37 FWL_Error IFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { | |
38 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetRange(fMin, fMax); | |
39 } | |
40 FX_FLOAT IFWL_ScrollBar::GetPageSize() { | |
41 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetPageSize(); | |
42 } | |
43 FWL_Error IFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) { | |
44 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetPageSize(fPageSize); | |
45 } | |
46 FX_FLOAT IFWL_ScrollBar::GetStepSize() { | |
47 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetStepSize(); | |
48 } | |
49 FWL_Error IFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) { | |
50 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetStepSize(fStepSize); | |
51 } | |
52 FX_FLOAT IFWL_ScrollBar::GetPos() { | |
53 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetPos(); | |
54 } | |
55 FWL_Error IFWL_ScrollBar::SetPos(FX_FLOAT fPos) { | |
56 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetPos(fPos); | |
57 } | |
58 FX_FLOAT IFWL_ScrollBar::GetTrackPos() { | |
59 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->GetTrackPos(); | |
60 } | |
61 FWL_Error IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { | |
62 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->SetTrackPos(fTrackPos); | |
63 } | |
64 FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { | |
65 return static_cast<CFWL_ScrollBarImp*>(GetImpl())->DoScroll(dwCode, fPos); | |
66 } | |
67 CFWL_ScrollBarImp::CFWL_ScrollBarImp(const CFWL_WidgetImpProperties& properties, | |
68 IFWL_Widget* pOuter) | |
69 : CFWL_WidgetImp(properties, pOuter), | |
70 m_pTimerInfo(nullptr), | 29 m_pTimerInfo(nullptr), |
71 m_fRangeMin(0), | 30 m_fRangeMin(0), |
72 m_fRangeMax(-1), | 31 m_fRangeMax(-1), |
73 m_fPageSize(0), | 32 m_fPageSize(0), |
74 m_fStepSize(0), | 33 m_fStepSize(0), |
75 m_fPos(0), | 34 m_fPos(0), |
76 m_fTrackPos(0), | 35 m_fTrackPos(0), |
77 m_iMinButtonState(CFWL_PartState_Normal), | 36 m_iMinButtonState(CFWL_PartState_Normal), |
78 m_iMaxButtonState(CFWL_PartState_Normal), | 37 m_iMaxButtonState(CFWL_PartState_Normal), |
79 m_iThumbButtonState(CFWL_PartState_Normal), | 38 m_iThumbButtonState(CFWL_PartState_Normal), |
(...skipping 12 matching lines...) Expand all Loading... |
92 m_bCustomLayout(FALSE), | 51 m_bCustomLayout(FALSE), |
93 m_fMinThumb(FWL_SCROLLBAR_MinThumb) { | 52 m_fMinThumb(FWL_SCROLLBAR_MinThumb) { |
94 m_rtClient.Reset(); | 53 m_rtClient.Reset(); |
95 m_rtThumb.Reset(); | 54 m_rtThumb.Reset(); |
96 m_rtMinBtn.Reset(); | 55 m_rtMinBtn.Reset(); |
97 m_rtMaxBtn.Reset(); | 56 m_rtMaxBtn.Reset(); |
98 m_rtMinTrack.Reset(); | 57 m_rtMinTrack.Reset(); |
99 m_rtMaxTrack.Reset(); | 58 m_rtMaxTrack.Reset(); |
100 } | 59 } |
101 | 60 |
102 CFWL_ScrollBarImp::~CFWL_ScrollBarImp() {} | 61 IFWL_ScrollBar::~IFWL_ScrollBar() {} |
103 | 62 |
104 FWL_Error CFWL_ScrollBarImp::GetClassName(CFX_WideString& wsClass) const { | 63 FWL_Error IFWL_ScrollBar::GetClassName(CFX_WideString& wsClass) const { |
105 wsClass = FWL_CLASS_ScrollBar; | 64 wsClass = FWL_CLASS_ScrollBar; |
106 return FWL_Error::Succeeded; | 65 return FWL_Error::Succeeded; |
107 } | 66 } |
108 | 67 |
109 FWL_Type CFWL_ScrollBarImp::GetClassID() const { | 68 FWL_Type IFWL_ScrollBar::GetClassID() const { |
110 return FWL_Type::ScrollBar; | 69 return FWL_Type::ScrollBar; |
111 } | 70 } |
112 | 71 |
113 FWL_Error CFWL_ScrollBarImp::Initialize() { | 72 FWL_Error IFWL_ScrollBar::Initialize() { |
114 if (CFWL_WidgetImp::Initialize() != FWL_Error::Succeeded) | 73 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) |
115 return FWL_Error::Indefinite; | 74 return FWL_Error::Indefinite; |
116 | 75 |
117 m_pDelegate = new CFWL_ScrollBarImpDelegate(this); | 76 m_pDelegate = new CFWL_ScrollBarImpDelegate(this); |
118 return FWL_Error::Succeeded; | 77 return FWL_Error::Succeeded; |
119 } | 78 } |
120 | 79 |
121 FWL_Error CFWL_ScrollBarImp::Finalize() { | 80 FWL_Error IFWL_ScrollBar::Finalize() { |
122 delete m_pDelegate; | 81 delete m_pDelegate; |
123 m_pDelegate = nullptr; | 82 m_pDelegate = nullptr; |
124 return CFWL_WidgetImp::Finalize(); | 83 return IFWL_Widget::Finalize(); |
125 } | 84 } |
126 FWL_Error CFWL_ScrollBarImp::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 85 |
| 86 FWL_Error IFWL_ScrollBar::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
127 if (bAutoSize) { | 87 if (bAutoSize) { |
128 rect.Set(0, 0, 0, 0); | 88 rect.Set(0, 0, 0, 0); |
129 FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>( | 89 FX_FLOAT* pfMinWidth = static_cast<FX_FLOAT*>( |
130 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); | 90 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); |
131 if (!pfMinWidth) | 91 if (!pfMinWidth) |
132 return FWL_Error::Indefinite; | 92 return FWL_Error::Indefinite; |
133 if (IsVertical()) { | 93 if (IsVertical()) { |
134 rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3); | 94 rect.Set(0, 0, (*pfMinWidth), (*pfMinWidth) * 3); |
135 } else { | 95 } else { |
136 rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth)); | 96 rect.Set(0, 0, (*pfMinWidth) * 3, (*pfMinWidth)); |
137 } | 97 } |
138 CFWL_WidgetImp::GetWidgetRect(rect, TRUE); | 98 IFWL_Widget::GetWidgetRect(rect, TRUE); |
139 } else { | 99 } else { |
140 rect = m_pProperties->m_rtWidget; | 100 rect = m_pProperties->m_rtWidget; |
141 } | 101 } |
142 return FWL_Error::Succeeded; | 102 return FWL_Error::Succeeded; |
143 } | 103 } |
144 FWL_Error CFWL_ScrollBarImp::Update() { | 104 |
| 105 FWL_Error IFWL_ScrollBar::Update() { |
145 if (IsLocked()) { | 106 if (IsLocked()) { |
146 return FWL_Error::Indefinite; | 107 return FWL_Error::Indefinite; |
147 } | 108 } |
148 if (!m_pProperties->m_pThemeProvider) { | 109 if (!m_pProperties->m_pThemeProvider) { |
149 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 110 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
150 } | 111 } |
151 Layout(); | 112 Layout(); |
152 return FWL_Error::Succeeded; | 113 return FWL_Error::Succeeded; |
153 } | 114 } |
154 FWL_Error CFWL_ScrollBarImp::DrawWidget(CFX_Graphics* pGraphics, | 115 |
155 const CFX_Matrix* pMatrix) { | 116 FWL_Error IFWL_ScrollBar::DrawWidget(CFX_Graphics* pGraphics, |
| 117 const CFX_Matrix* pMatrix) { |
156 if (!pGraphics) | 118 if (!pGraphics) |
157 return FWL_Error::Indefinite; | 119 return FWL_Error::Indefinite; |
158 if (!m_pProperties->m_pThemeProvider) | 120 if (!m_pProperties->m_pThemeProvider) |
159 return FWL_Error::Indefinite; | 121 return FWL_Error::Indefinite; |
160 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 122 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
161 if (HasBorder()) { | 123 if (HasBorder()) { |
162 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 124 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
163 } | 125 } |
164 if (HasEdge()) { | 126 if (HasEdge()) { |
165 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 127 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
166 } | 128 } |
167 DrawTrack(pGraphics, pTheme, TRUE, pMatrix); | 129 DrawTrack(pGraphics, pTheme, TRUE, pMatrix); |
168 DrawTrack(pGraphics, pTheme, FALSE, pMatrix); | 130 DrawTrack(pGraphics, pTheme, FALSE, pMatrix); |
169 DrawArrowBtn(pGraphics, pTheme, TRUE, pMatrix); | 131 DrawArrowBtn(pGraphics, pTheme, TRUE, pMatrix); |
170 DrawArrowBtn(pGraphics, pTheme, FALSE, pMatrix); | 132 DrawArrowBtn(pGraphics, pTheme, FALSE, pMatrix); |
171 DrawThumb(pGraphics, pTheme, pMatrix); | 133 DrawThumb(pGraphics, pTheme, pMatrix); |
172 return FWL_Error::Succeeded; | 134 return FWL_Error::Succeeded; |
173 } | 135 } |
174 inline FX_BOOL CFWL_ScrollBarImp::IsVertical() { | 136 |
| 137 inline FX_BOOL IFWL_ScrollBar::IsVertical() { |
175 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert; | 138 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert; |
176 } | 139 } |
177 FWL_Error CFWL_ScrollBarImp::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { | 140 |
| 141 FWL_Error IFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { |
178 fMin = m_fRangeMin; | 142 fMin = m_fRangeMin; |
179 fMax = m_fRangeMax; | 143 fMax = m_fRangeMax; |
180 return FWL_Error::Succeeded; | 144 return FWL_Error::Succeeded; |
181 } | 145 } |
182 FWL_Error CFWL_ScrollBarImp::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { | 146 |
| 147 FWL_Error IFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { |
183 m_fRangeMin = fMin; | 148 m_fRangeMin = fMin; |
184 m_fRangeMax = fMax; | 149 m_fRangeMax = fMax; |
185 return FWL_Error::Succeeded; | 150 return FWL_Error::Succeeded; |
186 } | 151 } |
187 FX_FLOAT CFWL_ScrollBarImp::GetPageSize() { | 152 |
| 153 FX_FLOAT IFWL_ScrollBar::GetPageSize() { |
188 return m_fPageSize; | 154 return m_fPageSize; |
189 } | 155 } |
190 FWL_Error CFWL_ScrollBarImp::SetPageSize(FX_FLOAT fPageSize) { | 156 |
| 157 FWL_Error IFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) { |
191 m_fPageSize = fPageSize; | 158 m_fPageSize = fPageSize; |
192 return FWL_Error::Succeeded; | 159 return FWL_Error::Succeeded; |
193 } | 160 } |
194 FX_FLOAT CFWL_ScrollBarImp::GetStepSize() { | 161 |
| 162 FX_FLOAT IFWL_ScrollBar::GetStepSize() { |
195 return m_fStepSize; | 163 return m_fStepSize; |
196 } | 164 } |
197 FWL_Error CFWL_ScrollBarImp::SetStepSize(FX_FLOAT fStepSize) { | 165 |
| 166 FWL_Error IFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) { |
198 m_fStepSize = fStepSize; | 167 m_fStepSize = fStepSize; |
199 return FWL_Error::Succeeded; | 168 return FWL_Error::Succeeded; |
200 } | 169 } |
201 FX_FLOAT CFWL_ScrollBarImp::GetPos() { | 170 |
| 171 FX_FLOAT IFWL_ScrollBar::GetPos() { |
202 return m_fPos; | 172 return m_fPos; |
203 } | 173 } |
204 FWL_Error CFWL_ScrollBarImp::SetPos(FX_FLOAT fPos) { | 174 |
| 175 FWL_Error IFWL_ScrollBar::SetPos(FX_FLOAT fPos) { |
205 m_fPos = fPos; | 176 m_fPos = fPos; |
206 return FWL_Error::Succeeded; | 177 return FWL_Error::Succeeded; |
207 } | 178 } |
208 FX_FLOAT CFWL_ScrollBarImp::GetTrackPos() { | 179 |
| 180 FX_FLOAT IFWL_ScrollBar::GetTrackPos() { |
209 return m_fTrackPos; | 181 return m_fTrackPos; |
210 } | 182 } |
211 FWL_Error CFWL_ScrollBarImp::SetTrackPos(FX_FLOAT fTrackPos) { | 183 |
| 184 FWL_Error IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { |
212 m_fTrackPos = fTrackPos; | 185 m_fTrackPos = fTrackPos; |
213 CalcThumbButtonRect(m_rtThumb); | 186 CalcThumbButtonRect(m_rtThumb); |
214 CalcMinTrackRect(m_rtMinTrack); | 187 CalcMinTrackRect(m_rtMinTrack); |
215 CalcMaxTrackRect(m_rtMaxTrack); | 188 CalcMaxTrackRect(m_rtMaxTrack); |
216 return FWL_Error::Succeeded; | 189 return FWL_Error::Succeeded; |
217 } | 190 } |
218 FX_BOOL CFWL_ScrollBarImp::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { | 191 |
| 192 FX_BOOL IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { |
219 switch (dwCode) { | 193 switch (dwCode) { |
220 case FWL_SCBCODE_Min: | 194 case FWL_SCBCODE_Min: |
221 case FWL_SCBCODE_Max: | 195 case FWL_SCBCODE_Max: |
222 case FWL_SCBCODE_PageBackward: | 196 case FWL_SCBCODE_PageBackward: |
223 case FWL_SCBCODE_PageForward: | 197 case FWL_SCBCODE_PageForward: |
224 case FWL_SCBCODE_StepBackward: | 198 case FWL_SCBCODE_StepBackward: |
225 break; | 199 break; |
226 case FWL_SCBCODE_StepForward: | 200 case FWL_SCBCODE_StepForward: |
227 break; | 201 break; |
228 case FWL_SCBCODE_Pos: | 202 case FWL_SCBCODE_Pos: |
229 case FWL_SCBCODE_TrackPos: | 203 case FWL_SCBCODE_TrackPos: |
230 case FWL_SCBCODE_EndScroll: | 204 case FWL_SCBCODE_EndScroll: |
231 break; | 205 break; |
232 default: { return FALSE; } | 206 default: { return FALSE; } |
233 } | 207 } |
234 return OnScroll(dwCode, fPos); | 208 return OnScroll(dwCode, fPos); |
235 } | 209 } |
236 | 210 |
237 void CFWL_ScrollBarImp::Run(IFWL_TimerInfo* pTimerInfo) { | 211 void IFWL_ScrollBar::Run(IFWL_TimerInfo* pTimerInfo) { |
238 if (m_pTimerInfo) | 212 if (m_pTimerInfo) |
239 m_pTimerInfo->StopTimer(); | 213 m_pTimerInfo->StopTimer(); |
240 | 214 |
241 if (!SendEvent()) | 215 if (!SendEvent()) |
242 m_pTimerInfo = StartTimer(0, true); | 216 m_pTimerInfo = StartTimer(0, true); |
243 } | 217 } |
244 | 218 |
245 FWL_Error CFWL_ScrollBarImp::SetOuter(IFWL_Widget* pOuter) { | 219 FWL_Error IFWL_ScrollBar::SetOuter(IFWL_Widget* pOuter) { |
246 m_pOuter = pOuter; | 220 m_pOuter = pOuter; |
247 return FWL_Error::Succeeded; | 221 return FWL_Error::Succeeded; |
248 } | 222 } |
249 void CFWL_ScrollBarImp::DrawTrack(CFX_Graphics* pGraphics, | 223 |
250 IFWL_ThemeProvider* pTheme, | 224 void IFWL_ScrollBar::DrawTrack(CFX_Graphics* pGraphics, |
251 FX_BOOL bLower, | 225 IFWL_ThemeProvider* pTheme, |
252 const CFX_Matrix* pMatrix) { | 226 FX_BOOL bLower, |
| 227 const CFX_Matrix* pMatrix) { |
253 CFWL_ThemeBackground param; | 228 CFWL_ThemeBackground param; |
254 param.m_pWidget = m_pInterface; | 229 param.m_pWidget = this; |
255 param.m_iPart = bLower ? CFWL_Part::LowerTrack : CFWL_Part::UpperTrack; | 230 param.m_iPart = bLower ? CFWL_Part::LowerTrack : CFWL_Part::UpperTrack; |
256 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 231 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
257 ? CFWL_PartState_Disabled | 232 ? CFWL_PartState_Disabled |
258 : (bLower ? m_iMinTrackState : m_iMaxTrackState); | 233 : (bLower ? m_iMinTrackState : m_iMaxTrackState); |
259 param.m_pGraphics = pGraphics; | 234 param.m_pGraphics = pGraphics; |
260 param.m_matrix.Concat(*pMatrix); | 235 param.m_matrix.Concat(*pMatrix); |
261 param.m_rtPart = bLower ? m_rtMinTrack : m_rtMaxTrack; | 236 param.m_rtPart = bLower ? m_rtMinTrack : m_rtMaxTrack; |
262 pTheme->DrawBackground(¶m); | 237 pTheme->DrawBackground(¶m); |
263 } | 238 } |
264 void CFWL_ScrollBarImp::DrawArrowBtn(CFX_Graphics* pGraphics, | 239 |
265 IFWL_ThemeProvider* pTheme, | 240 void IFWL_ScrollBar::DrawArrowBtn(CFX_Graphics* pGraphics, |
266 FX_BOOL bMinBtn, | 241 IFWL_ThemeProvider* pTheme, |
267 const CFX_Matrix* pMatrix) { | 242 FX_BOOL bMinBtn, |
| 243 const CFX_Matrix* pMatrix) { |
268 CFWL_ThemeBackground param; | 244 CFWL_ThemeBackground param; |
269 param.m_pWidget = m_pInterface; | 245 param.m_pWidget = this; |
270 param.m_iPart = bMinBtn ? CFWL_Part::ForeArrow : CFWL_Part::BackArrow; | 246 param.m_iPart = bMinBtn ? CFWL_Part::ForeArrow : CFWL_Part::BackArrow; |
271 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 247 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
272 ? CFWL_PartState_Disabled | 248 ? CFWL_PartState_Disabled |
273 : (bMinBtn ? m_iMinButtonState : m_iMaxButtonState); | 249 : (bMinBtn ? m_iMinButtonState : m_iMaxButtonState); |
274 param.m_pGraphics = pGraphics; | 250 param.m_pGraphics = pGraphics; |
275 param.m_matrix.Concat(*pMatrix); | 251 param.m_matrix.Concat(*pMatrix); |
276 param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn; | 252 param.m_rtPart = bMinBtn ? m_rtMinBtn : m_rtMaxBtn; |
277 if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) { | 253 if (param.m_rtPart.height > 0 && param.m_rtPart.width > 0) { |
278 pTheme->DrawBackground(¶m); | 254 pTheme->DrawBackground(¶m); |
279 } | 255 } |
280 } | 256 } |
281 void CFWL_ScrollBarImp::DrawThumb(CFX_Graphics* pGraphics, | 257 |
282 IFWL_ThemeProvider* pTheme, | 258 void IFWL_ScrollBar::DrawThumb(CFX_Graphics* pGraphics, |
283 const CFX_Matrix* pMatrix) { | 259 IFWL_ThemeProvider* pTheme, |
| 260 const CFX_Matrix* pMatrix) { |
284 CFWL_ThemeBackground param; | 261 CFWL_ThemeBackground param; |
285 param.m_pWidget = m_pInterface; | 262 param.m_pWidget = this; |
286 param.m_iPart = CFWL_Part::Thumb; | 263 param.m_iPart = CFWL_Part::Thumb; |
287 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 264 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
288 ? CFWL_PartState_Disabled | 265 ? CFWL_PartState_Disabled |
289 : m_iThumbButtonState; | 266 : m_iThumbButtonState; |
290 param.m_pGraphics = pGraphics; | 267 param.m_pGraphics = pGraphics; |
291 param.m_matrix.Concat(*pMatrix); | 268 param.m_matrix.Concat(*pMatrix); |
292 param.m_rtPart = m_rtThumb; | 269 param.m_rtPart = m_rtThumb; |
293 pTheme->DrawBackground(¶m); | 270 pTheme->DrawBackground(¶m); |
294 } | 271 } |
295 void CFWL_ScrollBarImp::Layout() { | 272 |
| 273 void IFWL_ScrollBar::Layout() { |
296 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; | 274 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; |
297 CFWL_ThemePart part; | 275 CFWL_ThemePart part; |
298 part.m_pWidget = m_pInterface; | 276 part.m_pWidget = this; |
299 m_fMinThumb = *static_cast<FX_FLOAT*>( | 277 m_fMinThumb = *static_cast<FX_FLOAT*>( |
300 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Size)); | 278 pTheme->GetCapacity(&part, CFWL_WidgetCapacity::Size)); |
301 m_bCustomLayout = pTheme->IsCustomizedLayout(m_pInterface); | 279 m_bCustomLayout = pTheme->IsCustomizedLayout(this); |
302 GetClientRect(m_rtClient); | 280 GetClientRect(m_rtClient); |
303 CalcButtonLen(); | 281 CalcButtonLen(); |
304 CalcMinButtonRect(m_rtMinBtn); | 282 CalcMinButtonRect(m_rtMinBtn); |
305 CalcMaxButtonRect(m_rtMaxBtn); | 283 CalcMaxButtonRect(m_rtMaxBtn); |
306 CalcThumbButtonRect(m_rtThumb); | 284 CalcThumbButtonRect(m_rtThumb); |
307 CalcMinTrackRect(m_rtMinTrack); | 285 CalcMinTrackRect(m_rtMinTrack); |
308 CalcMaxTrackRect(m_rtMaxTrack); | 286 CalcMaxTrackRect(m_rtMaxTrack); |
309 } | 287 } |
310 void CFWL_ScrollBarImp::CalcButtonLen() { | 288 |
| 289 void IFWL_ScrollBar::CalcButtonLen() { |
311 m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height; | 290 m_fButtonLen = IsVertical() ? m_rtClient.width : m_rtClient.height; |
312 FX_FLOAT fLength = IsVertical() ? m_rtClient.height : m_rtClient.width; | 291 FX_FLOAT fLength = IsVertical() ? m_rtClient.height : m_rtClient.width; |
313 if (fLength < m_fButtonLen * 2) { | 292 if (fLength < m_fButtonLen * 2) { |
314 m_fButtonLen = fLength / 2; | 293 m_fButtonLen = fLength / 2; |
315 m_bMinSize = TRUE; | 294 m_bMinSize = TRUE; |
316 } else { | 295 } else { |
317 m_bMinSize = FALSE; | 296 m_bMinSize = FALSE; |
318 } | 297 } |
319 } | 298 } |
320 void CFWL_ScrollBarImp::CalcMinButtonRect(CFX_RectF& rect) { | 299 |
| 300 void IFWL_ScrollBar::CalcMinButtonRect(CFX_RectF& rect) { |
321 if (m_bCustomLayout) | 301 if (m_bCustomLayout) |
322 return; | 302 return; |
323 | 303 |
324 rect.left = m_rtClient.left; | 304 rect.left = m_rtClient.left; |
325 rect.top = m_rtClient.top; | 305 rect.top = m_rtClient.top; |
326 rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; | 306 rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; |
327 rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; | 307 rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; |
328 } | 308 } |
329 | 309 |
330 void CFWL_ScrollBarImp::CalcMaxButtonRect(CFX_RectF& rect) { | 310 void IFWL_ScrollBar::CalcMaxButtonRect(CFX_RectF& rect) { |
331 if (m_bCustomLayout) | 311 if (m_bCustomLayout) |
332 return; | 312 return; |
333 | 313 |
334 rect.left = | 314 rect.left = |
335 IsVertical() ? m_rtClient.left : m_rtClient.right() - m_fButtonLen; | 315 IsVertical() ? m_rtClient.left : m_rtClient.right() - m_fButtonLen; |
336 rect.top = IsVertical() ? m_rtClient.bottom() - m_fButtonLen : m_rtClient.top; | 316 rect.top = IsVertical() ? m_rtClient.bottom() - m_fButtonLen : m_rtClient.top; |
337 rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; | 317 rect.width = IsVertical() ? m_rtClient.width : m_fButtonLen; |
338 rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; | 318 rect.height = IsVertical() ? m_fButtonLen : m_rtClient.height; |
339 } | 319 } |
340 | 320 |
341 void CFWL_ScrollBarImp::CalcThumbButtonRect(CFX_RectF& rect) { | 321 void IFWL_ScrollBar::CalcThumbButtonRect(CFX_RectF& rect) { |
342 if (!IsEnabled()) { | 322 if (!IsEnabled()) { |
343 m_rtThumb.Reset(); | 323 m_rtThumb.Reset(); |
344 return; | 324 return; |
345 } | 325 } |
346 if (m_bMinSize) { | 326 if (m_bMinSize) { |
347 m_rtThumb.Empty(); | 327 m_rtThumb.Empty(); |
348 return; | 328 return; |
349 } | 329 } |
350 FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; | 330 FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; |
351 memset(&rect, 0, sizeof(CFX_Rect)); | 331 memset(&rect, 0, sizeof(CFX_Rect)); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 rect.left += iPos; | 406 rect.left += iPos; |
427 } | 407 } |
428 rect.top = rtClient.top; | 408 rect.top = rtClient.top; |
429 if (IsVertical()) { | 409 if (IsVertical()) { |
430 rect.top += iPos; | 410 rect.top += iPos; |
431 } | 411 } |
432 rect.width = IsVertical() ? rtClient.width : fThumbSize; | 412 rect.width = IsVertical() ? rtClient.width : fThumbSize; |
433 rect.height = IsVertical() ? fThumbSize : rtClient.height; | 413 rect.height = IsVertical() ? fThumbSize : rtClient.height; |
434 } | 414 } |
435 } | 415 } |
436 void CFWL_ScrollBarImp::CalcMinTrackRect(CFX_RectF& rect) { | 416 |
| 417 void IFWL_ScrollBar::CalcMinTrackRect(CFX_RectF& rect) { |
437 if (m_bMinSize) { | 418 if (m_bMinSize) { |
438 rect.Empty(); | 419 rect.Empty(); |
439 return; | 420 return; |
440 } | 421 } |
441 FX_FLOAT fBottom = m_rtThumb.bottom(); | 422 FX_FLOAT fBottom = m_rtThumb.bottom(); |
442 FX_FLOAT fRight = m_rtThumb.right(); | 423 FX_FLOAT fRight = m_rtThumb.right(); |
443 FX_FLOAT ix = (m_rtThumb.left + fRight) / 2; | 424 FX_FLOAT ix = (m_rtThumb.left + fRight) / 2; |
444 FX_FLOAT iy = (m_rtThumb.top + fBottom) / 2; | 425 FX_FLOAT iy = (m_rtThumb.top + fBottom) / 2; |
445 rect.left = m_rtClient.left; | 426 rect.left = m_rtClient.left; |
446 rect.top = m_rtClient.top; | 427 rect.top = m_rtClient.top; |
(...skipping 11 matching lines...) Expand all Loading... |
458 } else { | 439 } else { |
459 if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { | 440 if (0 == m_rtMinBtn.width && 0 == m_rtMaxBtn.width) { |
460 rect.left = m_rtClient.left; | 441 rect.left = m_rtClient.left; |
461 } else if (m_rtMinBtn.left < m_rtThumb.left) { | 442 } else if (m_rtMinBtn.left < m_rtThumb.left) { |
462 rect.left = m_rtMinBtn.right(); | 443 rect.left = m_rtMinBtn.right(); |
463 rect.width -= (m_rtMinBtn.right() - m_rtClient.left); | 444 rect.width -= (m_rtMinBtn.right() - m_rtClient.left); |
464 } | 445 } |
465 } | 446 } |
466 } | 447 } |
467 } | 448 } |
468 void CFWL_ScrollBarImp::CalcMaxTrackRect(CFX_RectF& rect) { | 449 |
| 450 void IFWL_ScrollBar::CalcMaxTrackRect(CFX_RectF& rect) { |
469 if (m_bMinSize) { | 451 if (m_bMinSize) { |
470 rect.Empty(); | 452 rect.Empty(); |
471 return; | 453 return; |
472 } | 454 } |
473 FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2; | 455 FX_FLOAT ix = (m_rtThumb.left + m_rtThumb.right()) / 2; |
474 FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2; | 456 FX_FLOAT iy = (m_rtThumb.top + m_rtThumb.bottom()) / 2; |
475 FX_BOOL bVertical = IsVertical(); | 457 FX_BOOL bVertical = IsVertical(); |
476 rect.left = bVertical ? m_rtClient.left : ix; | 458 rect.left = bVertical ? m_rtClient.left : ix; |
477 rect.top = bVertical ? iy : m_rtClient.top; | 459 rect.top = bVertical ? iy : m_rtClient.top; |
478 rect.width = bVertical ? m_rtClient.width : m_rtClient.right() - ix; | 460 rect.width = bVertical ? m_rtClient.width : m_rtClient.right() - ix; |
479 rect.height = bVertical ? m_rtClient.bottom() - iy : m_rtClient.height; | 461 rect.height = bVertical ? m_rtClient.bottom() - iy : m_rtClient.height; |
480 if (m_bCustomLayout) { | 462 if (m_bCustomLayout) { |
481 if (bVertical) { | 463 if (bVertical) { |
482 if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 && | 464 if (m_rtMinBtn.top > m_rtThumb.top && m_rtMinBtn.height > 0 && |
483 m_rtMaxBtn.height > 0) { | 465 m_rtMaxBtn.height > 0) { |
484 rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top); | 466 rect.height -= (m_rtClient.bottom() - m_rtMinBtn.top); |
485 } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) { | 467 } else if (m_rtMinBtn.height > 0 && m_rtMaxBtn.height > 0) { |
486 rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top); | 468 rect.height -= (m_rtClient.bottom() - m_rtMaxBtn.top); |
487 } | 469 } |
488 } else { | 470 } else { |
489 if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 && | 471 if (m_rtMinBtn.left > m_rtThumb.left && m_rtMinBtn.width > 0 && |
490 m_rtMaxBtn.width > 0) { | 472 m_rtMaxBtn.width > 0) { |
491 rect.width -= (m_rtClient.right() - m_rtMinBtn.left); | 473 rect.width -= (m_rtClient.right() - m_rtMinBtn.left); |
492 } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) { | 474 } else if (m_rtMinBtn.width > 0 && m_rtMaxBtn.width > 0) { |
493 rect.width -= (m_rtClient.right() - m_rtMaxBtn.left); | 475 rect.width -= (m_rtClient.right() - m_rtMaxBtn.left); |
494 } | 476 } |
495 } | 477 } |
496 } | 478 } |
497 } | 479 } |
498 FX_FLOAT CFWL_ScrollBarImp::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { | 480 |
| 481 FX_FLOAT IFWL_ScrollBar::GetTrackPointPos(FX_FLOAT fx, FX_FLOAT fy) { |
499 FX_FLOAT fDiffX = fx - m_cpTrackPointX; | 482 FX_FLOAT fDiffX = fx - m_cpTrackPointX; |
500 FX_FLOAT fDiffY = fy - m_cpTrackPointY; | 483 FX_FLOAT fDiffY = fy - m_cpTrackPointY; |
501 FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; | 484 FX_FLOAT fRange = m_fRangeMax - m_fRangeMin; |
502 FX_FLOAT fPos; | 485 FX_FLOAT fPos; |
503 if (m_bCustomLayout) { | 486 if (m_bCustomLayout) { |
504 if (IsVertical()) { | 487 if (IsVertical()) { |
505 if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { | 488 if (0 == m_rtMinBtn.height && 0 == m_rtMaxBtn.height) { |
506 fPos = fRange * fDiffY / (m_rtClient.height - m_rtThumb.height); | 489 fPos = fRange * fDiffY / (m_rtClient.height - m_rtThumb.height); |
507 } else if (m_rtMinBtn.bottom() == m_rtMaxBtn.top) { | 490 } else if (m_rtMinBtn.bottom() == m_rtMaxBtn.top) { |
508 fPos = fRange * fDiffY / | 491 fPos = fRange * fDiffY / |
(...skipping 24 matching lines...) Expand all Loading... |
533 } | 516 } |
534 fPos += m_fLastTrackPos; | 517 fPos += m_fLastTrackPos; |
535 if (fPos < m_fRangeMin) { | 518 if (fPos < m_fRangeMin) { |
536 fPos = m_fRangeMin; | 519 fPos = m_fRangeMin; |
537 } | 520 } |
538 if (fPos > m_fRangeMax) { | 521 if (fPos > m_fRangeMax) { |
539 fPos = m_fRangeMax; | 522 fPos = m_fRangeMax; |
540 } | 523 } |
541 return fPos; | 524 return fPos; |
542 } | 525 } |
543 void CFWL_ScrollBarImp::GetTrackRect(CFX_RectF& rect, FX_BOOL bLower) { | 526 |
| 527 void IFWL_ScrollBar::GetTrackRect(CFX_RectF& rect, FX_BOOL bLower) { |
544 FX_BOOL bDisabled = m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled; | 528 FX_BOOL bDisabled = m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled; |
545 if (bDisabled || m_bCustomLayout) { | 529 if (bDisabled || m_bCustomLayout) { |
546 rect = bLower ? m_rtMinTrack : m_rtMaxTrack; | 530 rect = bLower ? m_rtMinTrack : m_rtMaxTrack; |
547 } else { | 531 } else { |
548 FX_FLOAT fW = m_rtThumb.width / 2; | 532 FX_FLOAT fW = m_rtThumb.width / 2; |
549 FX_FLOAT fH = m_rtThumb.height / 2; | 533 FX_FLOAT fH = m_rtThumb.height / 2; |
550 FX_BOOL bVert = IsVertical(); | 534 FX_BOOL bVert = IsVertical(); |
551 if (bLower) { | 535 if (bLower) { |
552 if (bVert) { | 536 if (bVert) { |
553 FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height; | 537 FX_FLOAT fMinTrackHeight = m_rtMinTrack.height - fH - m_rtMinBtn.height; |
(...skipping 16 matching lines...) Expand all Loading... |
570 } else { | 554 } else { |
571 FX_FLOAT fMaxTrackWidth = | 555 FX_FLOAT fMaxTrackWidth = |
572 m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2; | 556 m_rtMaxTrack.width - fW - m_rtMaxBtn.width + 2; |
573 fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f; | 557 fMaxTrackWidth = (fMaxTrackWidth >= 0.0f) ? fMaxTrackWidth : 0.0f; |
574 rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth, | 558 rect.Set(m_rtMaxTrack.left + fW, m_rtMaxTrack.top, fMaxTrackWidth, |
575 m_rtMaxTrack.height); | 559 m_rtMaxTrack.height); |
576 } | 560 } |
577 } | 561 } |
578 } | 562 } |
579 } | 563 } |
580 FX_BOOL CFWL_ScrollBarImp::SendEvent() { | 564 |
| 565 FX_BOOL IFWL_ScrollBar::SendEvent() { |
581 if (m_iMinButtonState == CFWL_PartState_Pressed) { | 566 if (m_iMinButtonState == CFWL_PartState_Pressed) { |
582 DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos); | 567 DoScroll(FWL_SCBCODE_StepBackward, m_fTrackPos); |
583 return FALSE; | 568 return FALSE; |
584 } | 569 } |
585 if (m_iMaxButtonState == CFWL_PartState_Pressed) { | 570 if (m_iMaxButtonState == CFWL_PartState_Pressed) { |
586 DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos); | 571 DoScroll(FWL_SCBCODE_StepForward, m_fTrackPos); |
587 return FALSE; | 572 return FALSE; |
588 } | 573 } |
589 if (m_iMinTrackState == CFWL_PartState_Pressed) { | 574 if (m_iMinTrackState == CFWL_PartState_Pressed) { |
590 DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos); | 575 DoScroll(FWL_SCBCODE_PageBackward, m_fTrackPos); |
591 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); | 576 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); |
592 } | 577 } |
593 if (m_iMaxTrackState == CFWL_PartState_Pressed) { | 578 if (m_iMaxTrackState == CFWL_PartState_Pressed) { |
594 DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos); | 579 DoScroll(FWL_SCBCODE_PageForward, m_fTrackPos); |
595 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); | 580 return m_rtThumb.Contains(m_cpTrackPointX, m_cpTrackPointY); |
596 } | 581 } |
597 if (m_iMouseWheel) { | 582 if (m_iMouseWheel) { |
598 uint16_t dwCode = | 583 uint16_t dwCode = |
599 m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward; | 584 m_iMouseWheel < 0 ? FWL_SCBCODE_StepForward : FWL_SCBCODE_StepBackward; |
600 DoScroll(dwCode, m_fTrackPos); | 585 DoScroll(dwCode, m_fTrackPos); |
601 } | 586 } |
602 return TRUE; | 587 return TRUE; |
603 } | 588 } |
604 FX_BOOL CFWL_ScrollBarImp::OnScroll(uint32_t dwCode, FX_FLOAT fPos) { | 589 |
| 590 FX_BOOL IFWL_ScrollBar::OnScroll(uint32_t dwCode, FX_FLOAT fPos) { |
605 FX_BOOL bRet = TRUE; | 591 FX_BOOL bRet = TRUE; |
606 CFWL_EvtScroll ev; | 592 CFWL_EvtScroll ev; |
607 ev.m_iScrollCode = dwCode; | 593 ev.m_iScrollCode = dwCode; |
608 ev.m_pSrcTarget = m_pInterface; | 594 ev.m_pSrcTarget = this; |
609 ev.m_fPos = fPos; | 595 ev.m_fPos = fPos; |
610 ev.m_pRet = &bRet; | 596 ev.m_pRet = &bRet; |
611 DispatchEvent(&ev); | 597 DispatchEvent(&ev); |
612 return bRet; | 598 return bRet; |
613 } | 599 } |
614 | 600 |
615 CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(CFWL_ScrollBarImp* pOwner) | 601 CFWL_ScrollBarImpDelegate::CFWL_ScrollBarImpDelegate(IFWL_ScrollBar* pOwner) |
616 : m_pOwner(pOwner) {} | 602 : m_pOwner(pOwner) {} |
617 | 603 |
618 void CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 604 void CFWL_ScrollBarImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
619 if (!pMessage) | 605 if (!pMessage) |
620 return; | 606 return; |
621 | 607 |
622 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 608 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
623 if (dwMsgCode == CFWL_MessageType::Mouse) { | 609 if (dwMsgCode == CFWL_MessageType::Mouse) { |
624 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 610 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
625 switch (pMsg->m_dwCmd) { | 611 switch (pMsg->m_dwCmd) { |
626 case FWL_MouseCommand::LeftButtonDown: { | 612 case FWL_MouseCommand::LeftButtonDown: { |
627 OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); | 613 OnLButtonDown(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); |
628 break; | 614 break; |
629 } | 615 } |
630 case FWL_MouseCommand::LeftButtonUp: { | 616 case FWL_MouseCommand::LeftButtonUp: { |
631 OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); | 617 OnLButtonUp(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); |
632 break; | 618 break; |
633 } | 619 } |
634 case FWL_MouseCommand::Move: { | 620 case FWL_MouseCommand::Move: { |
635 OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); | 621 OnMouseMove(pMsg->m_dwFlags, pMsg->m_fx, pMsg->m_fy); |
636 break; | 622 break; |
637 } | 623 } |
638 case FWL_MouseCommand::Leave: { | 624 case FWL_MouseCommand::Leave: { |
639 OnMouseLeave(); | 625 OnMouseLeave(); |
640 break; | 626 break; |
641 } | 627 } |
642 default: { | 628 default: { break; } |
643 break; | |
644 } | |
645 } | 629 } |
646 } else if (dwMsgCode == CFWL_MessageType::MouseWheel) { | 630 } else if (dwMsgCode == CFWL_MessageType::MouseWheel) { |
647 CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage); | 631 CFWL_MsgMouseWheel* pMsg = static_cast<CFWL_MsgMouseWheel*>(pMessage); |
648 OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX, | 632 OnMouseWheel(pMsg->m_fx, pMsg->m_fy, pMsg->m_dwFlags, pMsg->m_fDeltaX, |
649 pMsg->m_fDeltaY); | 633 pMsg->m_fDeltaY); |
650 } | 634 } |
651 } | 635 } |
652 | 636 |
653 void CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 637 void CFWL_ScrollBarImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
654 const CFX_Matrix* pMatrix) { | 638 const CFX_Matrix* pMatrix) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 FX_FLOAT fy) { | 680 FX_FLOAT fy) { |
697 m_pOwner->m_pTimerInfo->StopTimer(); | 681 m_pOwner->m_pTimerInfo->StopTimer(); |
698 m_pOwner->m_bMouseDown = FALSE; | 682 m_pOwner->m_bMouseDown = FALSE; |
699 DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); | 683 DoMouseUp(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); |
700 DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); | 684 DoMouseUp(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); |
701 DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); | 685 DoMouseUp(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); |
702 DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); | 686 DoMouseUp(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); |
703 DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); | 687 DoMouseUp(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); |
704 m_pOwner->SetGrab(FALSE); | 688 m_pOwner->SetGrab(FALSE); |
705 } | 689 } |
| 690 |
706 void CFWL_ScrollBarImpDelegate::OnMouseMove(uint32_t dwFlags, | 691 void CFWL_ScrollBarImpDelegate::OnMouseMove(uint32_t dwFlags, |
707 FX_FLOAT fx, | 692 FX_FLOAT fx, |
708 FX_FLOAT fy) { | 693 FX_FLOAT fy) { |
709 DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); | 694 DoMouseMove(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState, fx, fy); |
710 DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); | 695 DoMouseMove(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState, fx, fy); |
711 DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); | 696 DoMouseMove(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState, fx, fy); |
712 DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); | 697 DoMouseMove(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState, fx, fy); |
713 DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); | 698 DoMouseMove(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState, fx, fy); |
714 } | 699 } |
| 700 |
715 void CFWL_ScrollBarImpDelegate::OnMouseLeave() { | 701 void CFWL_ScrollBarImpDelegate::OnMouseLeave() { |
716 DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState); | 702 DoMouseLeave(0, m_pOwner->m_rtMinBtn, m_pOwner->m_iMinButtonState); |
717 DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState); | 703 DoMouseLeave(1, m_pOwner->m_rtThumb, m_pOwner->m_iThumbButtonState); |
718 DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState); | 704 DoMouseLeave(2, m_pOwner->m_rtMaxBtn, m_pOwner->m_iMaxButtonState); |
719 DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState); | 705 DoMouseLeave(3, m_pOwner->m_rtMinTrack, m_pOwner->m_iMinTrackState); |
720 DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState); | 706 DoMouseLeave(4, m_pOwner->m_rtMaxTrack, m_pOwner->m_iMaxTrackState); |
721 } | 707 } |
| 708 |
722 void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx, | 709 void CFWL_ScrollBarImpDelegate::OnMouseWheel(FX_FLOAT fx, |
723 FX_FLOAT fy, | 710 FX_FLOAT fy, |
724 uint32_t dwFlags, | 711 uint32_t dwFlags, |
725 FX_FLOAT fDeltaX, | 712 FX_FLOAT fDeltaX, |
726 FX_FLOAT fDeltaY) { | 713 FX_FLOAT fDeltaY) { |
727 m_pOwner->m_iMouseWheel = (int32_t)fDeltaX; | 714 m_pOwner->m_iMouseWheel = (int32_t)fDeltaX; |
728 m_pOwner->SendEvent(); | 715 m_pOwner->SendEvent(); |
729 m_pOwner->m_iMouseWheel = 0; | 716 m_pOwner->m_iMouseWheel = 0; |
730 } | 717 } |
| 718 |
731 void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem, | 719 void CFWL_ScrollBarImpDelegate::DoMouseDown(int32_t iItem, |
732 const CFX_RectF& rtItem, | 720 const CFX_RectF& rtItem, |
733 int32_t& iState, | 721 int32_t& iState, |
734 FX_FLOAT fx, | 722 FX_FLOAT fx, |
735 FX_FLOAT fy) { | 723 FX_FLOAT fy) { |
736 if (!rtItem.Contains(fx, fy)) { | 724 if (!rtItem.Contains(fx, fy)) { |
737 return; | 725 return; |
738 } | 726 } |
739 if (iState == CFWL_PartState_Pressed) { | 727 if (iState == CFWL_PartState_Pressed) { |
740 return; | 728 return; |
741 } | 729 } |
742 iState = CFWL_PartState_Pressed; | 730 iState = CFWL_PartState_Pressed; |
743 m_pOwner->Repaint(&rtItem); | 731 m_pOwner->Repaint(&rtItem); |
744 } | 732 } |
| 733 |
745 void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem, | 734 void CFWL_ScrollBarImpDelegate::DoMouseUp(int32_t iItem, |
746 const CFX_RectF& rtItem, | 735 const CFX_RectF& rtItem, |
747 int32_t& iState, | 736 int32_t& iState, |
748 FX_FLOAT fx, | 737 FX_FLOAT fx, |
749 FX_FLOAT fy) { | 738 FX_FLOAT fy) { |
750 int32_t iNewState = | 739 int32_t iNewState = |
751 rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal; | 740 rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered : CFWL_PartState_Normal; |
752 if (iState == iNewState) { | 741 if (iState == iNewState) { |
753 return; | 742 return; |
754 } | 743 } |
755 iState = iNewState; | 744 iState = iNewState; |
756 m_pOwner->Repaint(&rtItem); | 745 m_pOwner->Repaint(&rtItem); |
757 m_pOwner->OnScroll(FWL_SCBCODE_EndScroll, m_pOwner->m_fTrackPos); | 746 m_pOwner->OnScroll(FWL_SCBCODE_EndScroll, m_pOwner->m_fTrackPos); |
758 } | 747 } |
| 748 |
759 void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem, | 749 void CFWL_ScrollBarImpDelegate::DoMouseMove(int32_t iItem, |
760 const CFX_RectF& rtItem, | 750 const CFX_RectF& rtItem, |
761 int32_t& iState, | 751 int32_t& iState, |
762 FX_FLOAT fx, | 752 FX_FLOAT fx, |
763 FX_FLOAT fy) { | 753 FX_FLOAT fy) { |
764 if (!m_pOwner->m_bMouseDown) { | 754 if (!m_pOwner->m_bMouseDown) { |
765 int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered | 755 int32_t iNewState = rtItem.Contains(fx, fy) ? CFWL_PartState_Hovered |
766 : CFWL_PartState_Normal; | 756 : CFWL_PartState_Normal; |
767 if (iState == iNewState) { | 757 if (iState == iNewState) { |
768 return; | 758 return; |
769 } | 759 } |
770 iState = iNewState; | 760 iState = iNewState; |
771 m_pOwner->Repaint(&rtItem); | 761 m_pOwner->Repaint(&rtItem); |
772 } else if ((2 == iItem) && | 762 } else if ((2 == iItem) && |
773 (m_pOwner->m_iThumbButtonState == CFWL_PartState_Pressed)) { | 763 (m_pOwner->m_iThumbButtonState == CFWL_PartState_Pressed)) { |
774 FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy); | 764 FX_FLOAT fPos = m_pOwner->GetTrackPointPos(fx, fy); |
775 m_pOwner->m_fTrackPos = fPos; | 765 m_pOwner->m_fTrackPos = fPos; |
776 m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos); | 766 m_pOwner->OnScroll(FWL_SCBCODE_TrackPos, fPos); |
777 } | 767 } |
778 } | 768 } |
| 769 |
779 void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem, | 770 void CFWL_ScrollBarImpDelegate::DoMouseLeave(int32_t iItem, |
780 const CFX_RectF& rtItem, | 771 const CFX_RectF& rtItem, |
781 int32_t& iState) { | 772 int32_t& iState) { |
782 if (iState == CFWL_PartState_Normal) { | 773 if (iState == CFWL_PartState_Normal) { |
783 return; | 774 return; |
784 } | 775 } |
785 iState = CFWL_PartState_Normal; | 776 iState = CFWL_PartState_Normal; |
786 m_pOwner->Repaint(&rtItem); | 777 m_pOwner->Repaint(&rtItem); |
787 } | 778 } |
| 779 |
788 void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem, | 780 void CFWL_ScrollBarImpDelegate::DoMouseHover(int32_t iItem, |
789 const CFX_RectF& rtItem, | 781 const CFX_RectF& rtItem, |
790 int32_t& iState) { | 782 int32_t& iState) { |
791 if (iState == CFWL_PartState_Hovered) { | 783 if (iState == CFWL_PartState_Hovered) { |
792 return; | 784 return; |
793 } | 785 } |
794 iState = CFWL_PartState_Hovered; | 786 iState = CFWL_PartState_Hovered; |
795 m_pOwner->Repaint(&rtItem); | 787 m_pOwner->Repaint(&rtItem); |
796 } | 788 } |
OLD | NEW |