Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: xfa/fwl/core/ifwl_spinbutton.cpp

Issue 2467993003: Merge delegates into IFWL_* classes. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/core/ifwl_spinbutton.h" 7 #include "xfa/fwl/core/ifwl_spinbutton.h"
8 8
9 #include "third_party/base/ptr_util.h" 9 #include "third_party/base/ptr_util.h"
10 #include "xfa/fwl/core/cfwl_message.h" 10 #include "xfa/fwl/core/cfwl_message.h"
(...skipping 19 matching lines...) Expand all
30 m_dwUpState(CFWL_PartState_Normal), 30 m_dwUpState(CFWL_PartState_Normal),
31 m_dwDnState(CFWL_PartState_Normal), 31 m_dwDnState(CFWL_PartState_Normal),
32 m_iButtonIndex(0), 32 m_iButtonIndex(0),
33 m_bLButtonDwn(FALSE), 33 m_bLButtonDwn(FALSE),
34 m_pTimerInfo(nullptr), 34 m_pTimerInfo(nullptr),
35 m_Timer(this) { 35 m_Timer(this) {
36 m_rtClient.Reset(); 36 m_rtClient.Reset();
37 m_rtUpButton.Reset(); 37 m_rtUpButton.Reset();
38 m_rtDnButton.Reset(); 38 m_rtDnButton.Reset();
39 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; 39 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert;
40
41 SetDelegate(pdfium::MakeUnique<CFWL_SpinButtonImpDelegate>(this));
42 } 40 }
43 41
44 IFWL_SpinButton::~IFWL_SpinButton() {} 42 IFWL_SpinButton::~IFWL_SpinButton() {}
45 43
46 FWL_Type IFWL_SpinButton::GetClassID() const { 44 FWL_Type IFWL_SpinButton::GetClassID() const {
47 return FWL_Type::SpinButton; 45 return FWL_Type::SpinButton;
48 } 46 }
49 47
50 FWL_Error IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { 48 FWL_Error IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) {
51 if (bAutoSize) { 49 if (bAutoSize) {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 return FWL_WidgetHit::UpButton; 89 return FWL_WidgetHit::UpButton;
92 if (m_rtDnButton.Contains(fx, fy)) 90 if (m_rtDnButton.Contains(fx, fy))
93 return FWL_WidgetHit::DownButton; 91 return FWL_WidgetHit::DownButton;
94 return FWL_WidgetHit::Unknown; 92 return FWL_WidgetHit::Unknown;
95 } 93 }
96 94
97 FWL_Error IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics, 95 FWL_Error IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics,
98 const CFX_Matrix* pMatrix) { 96 const CFX_Matrix* pMatrix) {
99 if (!pGraphics) 97 if (!pGraphics)
100 return FWL_Error::Indefinite; 98 return FWL_Error::Indefinite;
99
101 CFX_RectF rtClip(m_rtClient); 100 CFX_RectF rtClip(m_rtClient);
102 if (pMatrix) { 101 if (pMatrix)
103 pMatrix->TransformRect(rtClip); 102 pMatrix->TransformRect(rtClip);
104 } 103
105 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); 104 IFWL_ThemeProvider* pTheme = GetAvailableTheme();
106 if (HasBorder()) { 105 if (HasBorder())
107 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 106 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
108 } 107 if (HasEdge())
109 if (HasEdge()) {
110 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 108 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
111 } 109
112 DrawUpButton(pGraphics, pTheme, pMatrix); 110 DrawUpButton(pGraphics, pTheme, pMatrix);
113 DrawDownButton(pGraphics, pTheme, pMatrix); 111 DrawDownButton(pGraphics, pTheme, pMatrix);
114 return FWL_Error::Succeeded; 112 return FWL_Error::Succeeded;
115 } 113 }
116 114
117 FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) { 115 FWL_Error IFWL_SpinButton::EnableButton(FX_BOOL bEnable, FX_BOOL bUp) {
118 if (bUp) { 116 if (bUp)
119 if (bEnable) { 117 m_dwUpState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled;
120 m_dwUpState = CFWL_PartState_Normal; 118 else
121 } else { 119 m_dwDnState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled;
122 m_dwUpState = CFWL_PartState_Disabled; 120
123 }
124 } else {
125 if (bEnable) {
126 m_dwDnState = CFWL_PartState_Normal;
127 } else {
128 m_dwDnState = CFWL_PartState_Disabled;
129 }
130 }
131 return FWL_Error::Succeeded; 121 return FWL_Error::Succeeded;
132 } 122 }
133 123
134 FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) { 124 FX_BOOL IFWL_SpinButton::IsButtonEnable(FX_BOOL bUp) {
135 if (bUp) { 125 if (bUp)
136 return (m_dwUpState != CFWL_PartState_Disabled); 126 return (m_dwUpState != CFWL_PartState_Disabled);
137 }
138 return (m_dwDnState != CFWL_PartState_Disabled); 127 return (m_dwDnState != CFWL_PartState_Disabled);
139 } 128 }
140 129
141 void IFWL_SpinButton::DrawUpButton(CFX_Graphics* pGraphics, 130 void IFWL_SpinButton::DrawUpButton(CFX_Graphics* pGraphics,
142 IFWL_ThemeProvider* pTheme, 131 IFWL_ThemeProvider* pTheme,
143 const CFX_Matrix* pMatrix) { 132 const CFX_Matrix* pMatrix) {
144 CFWL_ThemeBackground params; 133 CFWL_ThemeBackground params;
145 params.m_pWidget = this; 134 params.m_pWidget = this;
146 params.m_iPart = CFWL_Part::UpButton; 135 params.m_iPart = CFWL_Part::UpButton;
147 params.m_pGraphics = pGraphics; 136 params.m_pGraphics = pGraphics;
148 params.m_dwStates = m_dwUpState + 1; 137 params.m_dwStates = m_dwUpState + 1;
149 if (pMatrix) { 138 if (pMatrix)
150 params.m_matrix.Concat(*pMatrix); 139 params.m_matrix.Concat(*pMatrix);
151 } 140
152 params.m_rtPart = m_rtUpButton; 141 params.m_rtPart = m_rtUpButton;
153 pTheme->DrawBackground(&params); 142 pTheme->DrawBackground(&params);
154 } 143 }
155 144
156 void IFWL_SpinButton::DrawDownButton(CFX_Graphics* pGraphics, 145 void IFWL_SpinButton::DrawDownButton(CFX_Graphics* pGraphics,
157 IFWL_ThemeProvider* pTheme, 146 IFWL_ThemeProvider* pTheme,
158 const CFX_Matrix* pMatrix) { 147 const CFX_Matrix* pMatrix) {
159 CFWL_ThemeBackground params; 148 CFWL_ThemeBackground params;
160 params.m_pWidget = this; 149 params.m_pWidget = this;
161 params.m_iPart = CFWL_Part::DownButton; 150 params.m_iPart = CFWL_Part::DownButton;
162 params.m_pGraphics = pGraphics; 151 params.m_pGraphics = pGraphics;
163 params.m_dwStates = m_dwDnState + 1; 152 params.m_dwStates = m_dwDnState + 1;
164 if (pMatrix) { 153 if (pMatrix)
165 params.m_matrix.Concat(*pMatrix); 154 params.m_matrix.Concat(*pMatrix);
166 } 155
167 params.m_rtPart = m_rtDnButton; 156 params.m_rtPart = m_rtDnButton;
168 pTheme->DrawBackground(&params); 157 pTheme->DrawBackground(&params);
169 } 158 }
170 159
171 CFWL_SpinButtonImpDelegate::CFWL_SpinButtonImpDelegate(IFWL_SpinButton* pOwner) 160 void IFWL_SpinButton::OnProcessMessage(CFWL_Message* pMessage) {
172 : m_pOwner(pOwner) {}
173
174 void CFWL_SpinButtonImpDelegate::OnProcessMessage(CFWL_Message* pMessage) {
175 if (!pMessage) 161 if (!pMessage)
176 return; 162 return;
177 163
178 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); 164 CFWL_MessageType dwMsgCode = pMessage->GetClassID();
179 switch (dwMsgCode) { 165 switch (dwMsgCode) {
180 case CFWL_MessageType::SetFocus: { 166 case CFWL_MessageType::SetFocus: {
181 OnFocusChanged(pMessage, TRUE); 167 OnFocusChanged(pMessage, TRUE);
182 break; 168 break;
183 } 169 }
184 case CFWL_MessageType::KillFocus: { 170 case CFWL_MessageType::KillFocus: {
185 OnFocusChanged(pMessage, FALSE); 171 OnFocusChanged(pMessage, FALSE);
186 break; 172 break;
187 } 173 }
188 case CFWL_MessageType::Mouse: { 174 case CFWL_MessageType::Mouse: {
189 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); 175 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage);
190 switch (pMsg->m_dwCmd) { 176 switch (pMsg->m_dwCmd) {
191 case FWL_MouseCommand::LeftButtonDown: { 177 case FWL_MouseCommand::LeftButtonDown:
192 OnLButtonDown(pMsg); 178 OnLButtonDown(pMsg);
193 break; 179 break;
194 } 180 case FWL_MouseCommand::LeftButtonUp:
195 case FWL_MouseCommand::LeftButtonUp: {
196 OnLButtonUp(pMsg); 181 OnLButtonUp(pMsg);
197 break; 182 break;
198 } 183 case FWL_MouseCommand::Move:
199 case FWL_MouseCommand::Move: {
200 OnMouseMove(pMsg); 184 OnMouseMove(pMsg);
201 break; 185 break;
202 } 186 case FWL_MouseCommand::Leave:
203 case FWL_MouseCommand::Leave: {
204 OnMouseLeave(pMsg); 187 OnMouseLeave(pMsg);
205 break; 188 break;
206 }
207 default: 189 default:
208 break; 190 break;
209 } 191 }
210 break; 192 break;
211 } 193 }
212 case CFWL_MessageType::Key: { 194 case CFWL_MessageType::Key: {
213 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage); 195 CFWL_MsgKey* pKey = static_cast<CFWL_MsgKey*>(pMessage);
214 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown) 196 if (pKey->m_dwCmd == FWL_KeyCommand::KeyDown)
215 OnKeyDown(pKey); 197 OnKeyDown(pKey);
216 break; 198 break;
217 } 199 }
218 default: { break; } 200 default:
201 break;
219 } 202 }
220 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); 203 IFWL_Widget::OnProcessMessage(pMessage);
221 } 204 }
222 205
223 void CFWL_SpinButtonImpDelegate::OnProcessEvent(CFWL_Event* pEvent) {} 206 void IFWL_SpinButton::OnDrawWidget(CFX_Graphics* pGraphics,
224 207 const CFX_Matrix* pMatrix) {
225 void CFWL_SpinButtonImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, 208 DrawWidget(pGraphics, pMatrix);
226 const CFX_Matrix* pMatrix) {
227 m_pOwner->DrawWidget(pGraphics, pMatrix);
228 } 209 }
229 210
230 void CFWL_SpinButtonImpDelegate::OnFocusChanged(CFWL_Message* pMsg, 211 void IFWL_SpinButton::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) {
231 FX_BOOL bSet) { 212 if (bSet)
232 if (bSet) { 213 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
233 m_pOwner->m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); 214 else
234 } else { 215 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
235 m_pOwner->m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); 216
236 } 217 Repaint(&m_rtClient);
237 m_pOwner->Repaint(&m_pOwner->m_rtClient);
238 } 218 }
239 219
240 void CFWL_SpinButtonImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { 220 void IFWL_SpinButton::OnLButtonDown(CFWL_MsgMouse* pMsg) {
241 m_pOwner->m_bLButtonDwn = TRUE; 221 m_bLButtonDwn = TRUE;
242 m_pOwner->SetGrab(TRUE); 222 SetGrab(TRUE);
243 m_pOwner->SetFocus(TRUE); 223 SetFocus(TRUE);
244 if (!m_pOwner->m_pProperties->m_pDataProvider) 224 if (!m_pProperties->m_pDataProvider)
245 return; 225 return;
246 FX_BOOL bUpPress = (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && 226
247 m_pOwner->IsButtonEnable(TRUE)); 227 FX_BOOL bUpPress =
248 FX_BOOL bDnPress = (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && 228 (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnable(TRUE));
249 m_pOwner->IsButtonEnable(FALSE)); 229 FX_BOOL bDnPress =
250 if (!bUpPress && !bDnPress) { 230 (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnable(FALSE));
231 if (!bUpPress && !bDnPress)
251 return; 232 return;
252 }
253 if (bUpPress) { 233 if (bUpPress) {
254 m_pOwner->m_iButtonIndex = 0; 234 m_iButtonIndex = 0;
255 m_pOwner->m_dwUpState = CFWL_PartState_Pressed; 235 m_dwUpState = CFWL_PartState_Pressed;
256 } 236 }
257 if (bDnPress) { 237 if (bDnPress) {
258 m_pOwner->m_iButtonIndex = 1; 238 m_iButtonIndex = 1;
259 m_pOwner->m_dwDnState = CFWL_PartState_Pressed; 239 m_dwDnState = CFWL_PartState_Pressed;
260 } 240 }
261 CFWL_EvtSpbClick wmPosChanged; 241 CFWL_EvtSpbClick wmPosChanged;
262 wmPosChanged.m_pSrcTarget = m_pOwner; 242 wmPosChanged.m_pSrcTarget = this;
263 wmPosChanged.m_bUp = bUpPress; 243 wmPosChanged.m_bUp = bUpPress;
264 m_pOwner->DispatchEvent(&wmPosChanged); 244 DispatchEvent(&wmPosChanged);
265 m_pOwner->Repaint(bUpPress ? &m_pOwner->m_rtUpButton 245 Repaint(bUpPress ? &m_rtUpButton : &m_rtDnButton);
266 : &m_pOwner->m_rtDnButton); 246 m_pTimerInfo = m_Timer.StartTimer(kElapseTime, true);
267 m_pOwner->m_pTimerInfo = m_pOwner->m_Timer.StartTimer(kElapseTime, true);
268 } 247 }
269 248
270 void CFWL_SpinButtonImpDelegate::OnLButtonUp(CFWL_MsgMouse* pMsg) { 249 void IFWL_SpinButton::OnLButtonUp(CFWL_MsgMouse* pMsg) {
271 if (m_pOwner->m_pProperties->m_dwStates & CFWL_PartState_Disabled) { 250 if (m_pProperties->m_dwStates & CFWL_PartState_Disabled)
272 return; 251 return;
273 } 252
274 m_pOwner->m_bLButtonDwn = FALSE; 253 m_bLButtonDwn = FALSE;
275 m_pOwner->SetGrab(FALSE); 254 SetGrab(FALSE);
276 m_pOwner->SetFocus(FALSE); 255 SetFocus(FALSE);
277 if (m_pOwner->m_pTimerInfo) { 256 if (m_pTimerInfo) {
278 m_pOwner->m_pTimerInfo->StopTimer(); 257 m_pTimerInfo->StopTimer();
279 m_pOwner->m_pTimerInfo = nullptr; 258 m_pTimerInfo = nullptr;
280 } 259 }
281 FX_BOOL bRepaint = FALSE; 260 FX_BOOL bRepaint = FALSE;
282 CFX_RectF rtInvalidate; 261 CFX_RectF rtInvalidate;
283 if (m_pOwner->m_dwUpState == CFWL_PartState_Pressed && 262 if (m_dwUpState == CFWL_PartState_Pressed && IsButtonEnable(TRUE)) {
284 m_pOwner->IsButtonEnable(TRUE)) { 263 m_dwUpState = CFWL_PartState_Normal;
285 m_pOwner->m_dwUpState = CFWL_PartState_Normal;
286 bRepaint = TRUE; 264 bRepaint = TRUE;
287 rtInvalidate = m_pOwner->m_rtUpButton; 265 rtInvalidate = m_rtUpButton;
288 } else if (m_pOwner->m_dwDnState == CFWL_PartState_Pressed && 266 } else if (m_dwDnState == CFWL_PartState_Pressed && IsButtonEnable(FALSE)) {
289 m_pOwner->IsButtonEnable(FALSE)) { 267 m_dwDnState = CFWL_PartState_Normal;
290 m_pOwner->m_dwDnState = CFWL_PartState_Normal;
291 bRepaint = TRUE; 268 bRepaint = TRUE;
292 rtInvalidate = m_pOwner->m_rtDnButton; 269 rtInvalidate = m_rtDnButton;
293 } 270 }
294 if (bRepaint) { 271 if (bRepaint)
295 m_pOwner->Repaint(&rtInvalidate); 272 Repaint(&rtInvalidate);
296 }
297 } 273 }
298 274
299 void CFWL_SpinButtonImpDelegate::OnMouseMove(CFWL_MsgMouse* pMsg) { 275 void IFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) {
300 if (!m_pOwner->m_pProperties->m_pDataProvider) 276 if (!m_pProperties->m_pDataProvider)
301 return; 277 return;
302 if (m_pOwner->m_bLButtonDwn) { 278 if (m_bLButtonDwn)
303 return; 279 return;
304 } 280
305 FX_BOOL bRepaint = FALSE; 281 FX_BOOL bRepaint = FALSE;
306 CFX_RectF rtInvlidate; 282 CFX_RectF rtInvlidate;
307 rtInvlidate.Reset(); 283 rtInvlidate.Reset();
308 if (m_pOwner->m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { 284 if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
309 if (m_pOwner->IsButtonEnable(TRUE)) { 285 if (IsButtonEnable(TRUE)) {
310 if (m_pOwner->m_dwUpState == CFWL_PartState_Hovered) { 286 if (m_dwUpState == CFWL_PartState_Hovered) {
311 m_pOwner->m_dwUpState = CFWL_PartState_Hovered; 287 m_dwUpState = CFWL_PartState_Hovered;
312 bRepaint = TRUE; 288 bRepaint = TRUE;
313 rtInvlidate = m_pOwner->m_rtUpButton; 289 rtInvlidate = m_rtUpButton;
314 } 290 }
315 if (m_pOwner->m_dwDnState != CFWL_PartState_Normal && 291 if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnable(FALSE)) {
316 m_pOwner->IsButtonEnable(FALSE)) { 292 m_dwDnState = CFWL_PartState_Normal;
317 m_pOwner->m_dwDnState = CFWL_PartState_Normal; 293 if (bRepaint)
318 if (bRepaint) { 294 rtInvlidate.Union(m_rtDnButton);
319 rtInvlidate.Union(m_pOwner->m_rtDnButton); 295 else
320 } else { 296 rtInvlidate = m_rtDnButton;
321 rtInvlidate = m_pOwner->m_rtDnButton; 297
322 }
323 bRepaint = TRUE; 298 bRepaint = TRUE;
324 } 299 }
325 } 300 }
326 if (!m_pOwner->IsButtonEnable(FALSE)) { 301 if (!IsButtonEnable(FALSE))
327 m_pOwner->EnableButton(FALSE, FALSE); 302 EnableButton(FALSE, FALSE);
328 } 303
329 } else if (m_pOwner->m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) { 304 } else if (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy)) {
330 if (m_pOwner->IsButtonEnable(FALSE)) { 305 if (IsButtonEnable(FALSE)) {
331 if (m_pOwner->m_dwDnState != CFWL_PartState_Hovered) { 306 if (m_dwDnState != CFWL_PartState_Hovered) {
332 m_pOwner->m_dwDnState = CFWL_PartState_Hovered; 307 m_dwDnState = CFWL_PartState_Hovered;
333 bRepaint = TRUE; 308 bRepaint = TRUE;
334 rtInvlidate = m_pOwner->m_rtDnButton; 309 rtInvlidate = m_rtDnButton;
335 } 310 }
336 if (m_pOwner->m_dwUpState != CFWL_PartState_Normal && 311 if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnable(TRUE)) {
337 m_pOwner->IsButtonEnable(TRUE)) { 312 m_dwUpState = CFWL_PartState_Normal;
338 m_pOwner->m_dwUpState = CFWL_PartState_Normal; 313 if (bRepaint)
339 if (bRepaint) { 314 rtInvlidate.Union(m_rtUpButton);
340 rtInvlidate.Union(m_pOwner->m_rtUpButton); 315 else
341 } else { 316 rtInvlidate = m_rtUpButton;
342 rtInvlidate = m_pOwner->m_rtUpButton;
343 }
344 bRepaint = TRUE; 317 bRepaint = TRUE;
345 } 318 }
346 } 319 }
347 } else if (m_pOwner->m_dwUpState != CFWL_PartState_Normal || 320 } else if (m_dwUpState != CFWL_PartState_Normal ||
348 m_pOwner->m_dwDnState != CFWL_PartState_Normal) { 321 m_dwDnState != CFWL_PartState_Normal) {
349 if (m_pOwner->m_dwUpState != CFWL_PartState_Normal) { 322 if (m_dwUpState != CFWL_PartState_Normal) {
350 m_pOwner->m_dwUpState = CFWL_PartState_Normal; 323 m_dwUpState = CFWL_PartState_Normal;
351 bRepaint = TRUE; 324 bRepaint = TRUE;
352 rtInvlidate = m_pOwner->m_rtUpButton; 325 rtInvlidate = m_rtUpButton;
353 } 326 }
354 if (m_pOwner->m_dwDnState != CFWL_PartState_Normal) { 327 if (m_dwDnState != CFWL_PartState_Normal) {
355 m_pOwner->m_dwDnState = CFWL_PartState_Normal; 328 m_dwDnState = CFWL_PartState_Normal;
356 if (bRepaint) { 329 if (bRepaint)
357 rtInvlidate.Union(m_pOwner->m_rtDnButton); 330 rtInvlidate.Union(m_rtDnButton);
358 } else { 331 else
359 rtInvlidate = m_pOwner->m_rtDnButton; 332 rtInvlidate = m_rtDnButton;
360 } 333
361 bRepaint = TRUE; 334 bRepaint = TRUE;
362 } 335 }
363 } 336 }
364 if (bRepaint) { 337 if (bRepaint)
365 m_pOwner->Repaint(&rtInvlidate); 338 Repaint(&rtInvlidate);
366 }
367 } 339 }
368 340
369 void CFWL_SpinButtonImpDelegate::OnMouseLeave(CFWL_MsgMouse* pMsg) { 341 void IFWL_SpinButton::OnMouseLeave(CFWL_MsgMouse* pMsg) {
370 if (!pMsg) 342 if (!pMsg)
371 return; 343 return;
372 if (m_pOwner->m_dwUpState != CFWL_PartState_Normal && 344 if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnable(TRUE))
373 m_pOwner->IsButtonEnable(TRUE)) { 345 m_dwUpState = CFWL_PartState_Normal;
374 m_pOwner->m_dwUpState = CFWL_PartState_Normal; 346 if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnable(FALSE))
375 } 347 m_dwDnState = CFWL_PartState_Normal;
376 if (m_pOwner->m_dwDnState != CFWL_PartState_Normal && 348
377 m_pOwner->IsButtonEnable(FALSE)) { 349 Repaint(&m_rtClient);
378 m_pOwner->m_dwDnState = CFWL_PartState_Normal;
379 }
380 m_pOwner->Repaint(&m_pOwner->m_rtClient);
381 } 350 }
382 351
383 void CFWL_SpinButtonImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { 352 void IFWL_SpinButton::OnKeyDown(CFWL_MsgKey* pMsg) {
384 if (!m_pOwner->m_pProperties->m_pDataProvider) 353 if (!m_pProperties->m_pDataProvider)
385 return; 354 return;
355
386 FX_BOOL bUp = 356 FX_BOOL bUp =
387 pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; 357 pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left;
388 FX_BOOL bDown = 358 FX_BOOL bDown =
389 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; 359 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right;
390 if (!bUp && !bDown) { 360 if (!bUp && !bDown)
391 return; 361 return;
392 } 362
393 FX_BOOL bUpEnable = m_pOwner->IsButtonEnable(TRUE); 363 FX_BOOL bUpEnable = IsButtonEnable(TRUE);
394 FX_BOOL bDownEnable = m_pOwner->IsButtonEnable(FALSE); 364 FX_BOOL bDownEnable = IsButtonEnable(FALSE);
395 if (!bUpEnable && !bDownEnable) { 365 if (!bUpEnable && !bDownEnable)
396 return; 366 return;
397 } 367
398 CFWL_EvtSpbClick wmPosChanged; 368 CFWL_EvtSpbClick wmPosChanged;
399 wmPosChanged.m_pSrcTarget = m_pOwner; 369 wmPosChanged.m_pSrcTarget = this;
400 wmPosChanged.m_bUp = bUpEnable; 370 wmPosChanged.m_bUp = bUpEnable;
401 m_pOwner->DispatchEvent(&wmPosChanged); 371 DispatchEvent(&wmPosChanged);
402 m_pOwner->Repaint(bUpEnable ? &m_pOwner->m_rtUpButton 372 Repaint(bUpEnable ? &m_rtUpButton : &m_rtDnButton);
403 : &m_pOwner->m_rtDnButton);
404 } 373 }
405 374
406 IFWL_SpinButton::Timer::Timer(IFWL_SpinButton* pToolTip) 375 IFWL_SpinButton::Timer::Timer(IFWL_SpinButton* pToolTip)
407 : IFWL_Timer(pToolTip) {} 376 : IFWL_Timer(pToolTip) {}
408 377
409 void IFWL_SpinButton::Timer::Run(IFWL_TimerInfo* pTimerInfo) { 378 void IFWL_SpinButton::Timer::Run(IFWL_TimerInfo* pTimerInfo) {
410 IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget); 379 IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget);
411 380
412 if (!pButton->m_pTimerInfo) 381 if (!pButton->m_pTimerInfo)
413 return; 382 return;
414 383
415 CFWL_EvtSpbClick wmPosChanged; 384 CFWL_EvtSpbClick wmPosChanged;
416 wmPosChanged.m_pSrcTarget = pButton; 385 wmPosChanged.m_pSrcTarget = pButton;
417 wmPosChanged.m_bUp = pButton->m_iButtonIndex == 0; 386 wmPosChanged.m_bUp = pButton->m_iButtonIndex == 0;
418 pButton->DispatchEvent(&wmPosChanged); 387 pButton->DispatchEvent(&wmPosChanged);
419 } 388 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698