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/core/ifwl_spinbutton.h" | 7 #include "xfa/fwl/core/ifwl_spinbutton.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 else | 214 else |
215 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); | 215 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); |
216 | 216 |
217 Repaint(&m_rtClient); | 217 Repaint(&m_rtClient); |
218 } | 218 } |
219 | 219 |
220 void IFWL_SpinButton::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 220 void IFWL_SpinButton::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
221 m_bLButtonDwn = true; | 221 m_bLButtonDwn = true; |
222 SetGrab(true); | 222 SetGrab(true); |
223 SetFocus(true); | 223 SetFocus(true); |
224 if (!m_pProperties->m_pDataProvider) | |
225 return; | |
226 | 224 |
227 bool bUpPress = | 225 bool bUpPress = |
228 (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(true)); | 226 (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(true)); |
229 bool bDnPress = | 227 bool bDnPress = |
230 (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(false)); | 228 (m_rtDnButton.Contains(pMsg->m_fx, pMsg->m_fy) && IsButtonEnabled(false)); |
231 if (!bUpPress && !bDnPress) | 229 if (!bUpPress && !bDnPress) |
232 return; | 230 return; |
233 if (bUpPress) { | 231 if (bUpPress) { |
234 m_iButtonIndex = 0; | 232 m_iButtonIndex = 0; |
235 m_dwUpState = CFWL_PartState_Pressed; | 233 m_dwUpState = CFWL_PartState_Pressed; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 } else if (m_dwDnState == CFWL_PartState_Pressed && IsButtonEnabled(false)) { | 265 } else if (m_dwDnState == CFWL_PartState_Pressed && IsButtonEnabled(false)) { |
268 m_dwDnState = CFWL_PartState_Normal; | 266 m_dwDnState = CFWL_PartState_Normal; |
269 bRepaint = true; | 267 bRepaint = true; |
270 rtInvalidate = m_rtDnButton; | 268 rtInvalidate = m_rtDnButton; |
271 } | 269 } |
272 if (bRepaint) | 270 if (bRepaint) |
273 Repaint(&rtInvalidate); | 271 Repaint(&rtInvalidate); |
274 } | 272 } |
275 | 273 |
276 void IFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { | 274 void IFWL_SpinButton::OnMouseMove(CFWL_MsgMouse* pMsg) { |
277 if (!m_pProperties->m_pDataProvider) | |
278 return; | |
279 if (m_bLButtonDwn) | 275 if (m_bLButtonDwn) |
280 return; | 276 return; |
281 | 277 |
282 bool bRepaint = false; | 278 bool bRepaint = false; |
283 CFX_RectF rtInvlidate; | 279 CFX_RectF rtInvlidate; |
284 rtInvlidate.Reset(); | 280 rtInvlidate.Reset(); |
285 if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { | 281 if (m_rtUpButton.Contains(pMsg->m_fx, pMsg->m_fy)) { |
286 if (IsButtonEnabled(true)) { | 282 if (IsButtonEnabled(true)) { |
287 if (m_dwUpState == CFWL_PartState_Hovered) { | 283 if (m_dwUpState == CFWL_PartState_Hovered) { |
288 m_dwUpState = CFWL_PartState_Hovered; | 284 m_dwUpState = CFWL_PartState_Hovered; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 return; | 340 return; |
345 if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnabled(true)) | 341 if (m_dwUpState != CFWL_PartState_Normal && IsButtonEnabled(true)) |
346 m_dwUpState = CFWL_PartState_Normal; | 342 m_dwUpState = CFWL_PartState_Normal; |
347 if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnabled(false)) | 343 if (m_dwDnState != CFWL_PartState_Normal && IsButtonEnabled(false)) |
348 m_dwDnState = CFWL_PartState_Normal; | 344 m_dwDnState = CFWL_PartState_Normal; |
349 | 345 |
350 Repaint(&m_rtClient); | 346 Repaint(&m_rtClient); |
351 } | 347 } |
352 | 348 |
353 void IFWL_SpinButton::OnKeyDown(CFWL_MsgKey* pMsg) { | 349 void IFWL_SpinButton::OnKeyDown(CFWL_MsgKey* pMsg) { |
354 if (!m_pProperties->m_pDataProvider) | |
355 return; | |
356 | |
357 bool bUp = | 350 bool bUp = |
358 pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; | 351 pMsg->m_dwKeyCode == FWL_VKEY_Up || pMsg->m_dwKeyCode == FWL_VKEY_Left; |
359 bool bDown = | 352 bool bDown = |
360 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; | 353 pMsg->m_dwKeyCode == FWL_VKEY_Down || pMsg->m_dwKeyCode == FWL_VKEY_Right; |
361 if (!bUp && !bDown) | 354 if (!bUp && !bDown) |
362 return; | 355 return; |
363 | 356 |
364 bool bUpEnable = IsButtonEnabled(true); | 357 bool bUpEnable = IsButtonEnabled(true); |
365 bool bDownEnable = IsButtonEnabled(false); | 358 bool bDownEnable = IsButtonEnabled(false); |
366 if (!bUpEnable && !bDownEnable) | 359 if (!bUpEnable && !bDownEnable) |
(...skipping 12 matching lines...) Expand all Loading... |
379 void IFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { | 372 void IFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { |
380 IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget); | 373 IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget); |
381 | 374 |
382 if (!pButton->m_pTimerInfo) | 375 if (!pButton->m_pTimerInfo) |
383 return; | 376 return; |
384 | 377 |
385 CFWL_EvtClick wmPosChanged; | 378 CFWL_EvtClick wmPosChanged; |
386 wmPosChanged.m_pSrcTarget = pButton; | 379 wmPosChanged.m_pSrcTarget = pButton; |
387 pButton->DispatchEvent(&wmPosChanged); | 380 pButton->DispatchEvent(&wmPosChanged); |
388 } | 381 } |
OLD | NEW |