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_SPINBUTTON_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_SPINBUTTON_H_ |
8 #define XFA_FWL_CORE_IFWL_SPINBUTTON_H_ | 8 #define XFA_FWL_CORE_IFWL_SPINBUTTON_H_ |
9 | 9 |
10 #include "xfa/fwl/core/cfwl_event.h" | 10 #include "xfa/fwl/core/cfwl_event.h" |
11 #include "xfa/fwl/core/ifwl_timer.h" | 11 #include "xfa/fwl/core/ifwl_timer.h" |
12 #include "xfa/fwl/core/ifwl_widget.h" | 12 #include "xfa/fwl/core/ifwl_widget.h" |
13 #include "xfa/fxfa/cxfa_eventparam.h" | 13 #include "xfa/fxfa/cxfa_eventparam.h" |
14 | 14 |
15 #define FWL_STYLEEXE_SPB_Vert (1L << 0) | 15 #define FWL_STYLEEXE_SPB_Vert (1L << 0) |
16 | 16 |
17 class CFWL_MsgMouse; | 17 class CFWL_MsgMouse; |
18 class CFWL_SpinButtonImpDelegate; | 18 class CFWL_SpinButtonImpDelegate; |
19 class CFWL_WidgetImpProperties; | 19 class CFWL_WidgetImpProperties; |
20 | 20 |
21 FWL_EVENT_DEF(CFWL_EvtSpbClick, CFWL_EventType::Click, FX_BOOL m_bUp;) | 21 FWL_EVENT_DEF(CFWL_EvtSpbClick, CFWL_EventType::Click, FX_BOOL m_bUp;) |
22 | 22 |
23 class IFWL_SpinButton : public IFWL_Widget, public IFWL_Timer { | 23 class IFWL_SpinButton : public IFWL_Widget { |
24 public: | 24 public: |
25 explicit IFWL_SpinButton(const CFWL_WidgetImpProperties& properties); | 25 explicit IFWL_SpinButton(const IFWL_App* app, |
| 26 const CFWL_WidgetImpProperties& properties); |
26 ~IFWL_SpinButton() override; | 27 ~IFWL_SpinButton() override; |
27 | 28 |
28 // IFWL_Widget | 29 // IFWL_Widget |
| 30 void Initialize() override; |
| 31 void Finalize() override; |
29 FWL_Type GetClassID() const override; | 32 FWL_Type GetClassID() const override; |
30 FWL_Error Initialize() override; | |
31 void Finalize() override; | |
32 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | 33 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; |
33 FWL_Error Update() override; | 34 FWL_Error Update() override; |
34 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; | 35 FWL_WidgetHit HitTest(FX_FLOAT fx, FX_FLOAT fy) override; |
35 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | 36 FWL_Error DrawWidget(CFX_Graphics* pGraphics, |
36 const CFX_Matrix* pMatrix = nullptr) override; | 37 const CFX_Matrix* pMatrix = nullptr) override; |
37 | 38 |
38 // IFWL_Timer | |
39 void Run(IFWL_TimerInfo* pTimerInfo) override; | |
40 | |
41 FWL_Error EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE); | 39 FWL_Error EnableButton(FX_BOOL bEnable, FX_BOOL bUp = TRUE); |
42 FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE); | 40 FX_BOOL IsButtonEnable(FX_BOOL bUp = TRUE); |
43 | 41 |
44 protected: | 42 protected: |
45 friend class CFWL_SpinButtonImpDelegate; | 43 friend class CFWL_SpinButtonImpDelegate; |
46 | 44 |
| 45 class Timer : public IFWL_Timer { |
| 46 public: |
| 47 explicit Timer(IFWL_SpinButton* pToolTip); |
| 48 ~Timer() override {} |
| 49 |
| 50 void Run(IFWL_TimerInfo* pTimerInfo) override; |
| 51 }; |
| 52 friend class IFWL_SpinButton::Timer; |
| 53 |
47 void DrawUpButton(CFX_Graphics* pGraphics, | 54 void DrawUpButton(CFX_Graphics* pGraphics, |
48 IFWL_ThemeProvider* pTheme, | 55 IFWL_ThemeProvider* pTheme, |
49 const CFX_Matrix* pMatrix); | 56 const CFX_Matrix* pMatrix); |
50 void DrawDownButton(CFX_Graphics* pGraphics, | 57 void DrawDownButton(CFX_Graphics* pGraphics, |
51 IFWL_ThemeProvider* pTheme, | 58 IFWL_ThemeProvider* pTheme, |
52 const CFX_Matrix* pMatrix); | 59 const CFX_Matrix* pMatrix); |
53 | 60 |
54 CFX_RectF m_rtClient; | 61 CFX_RectF m_rtClient; |
55 CFX_RectF m_rtUpButton; | 62 CFX_RectF m_rtUpButton; |
56 CFX_RectF m_rtDnButton; | 63 CFX_RectF m_rtDnButton; |
57 uint32_t m_dwUpState; | 64 uint32_t m_dwUpState; |
58 uint32_t m_dwDnState; | 65 uint32_t m_dwDnState; |
59 int32_t m_iButtonIndex; | 66 int32_t m_iButtonIndex; |
60 FX_BOOL m_bLButtonDwn; | 67 FX_BOOL m_bLButtonDwn; |
61 IFWL_TimerInfo* m_pTimerInfo; | 68 IFWL_TimerInfo* m_pTimerInfo; |
| 69 IFWL_SpinButton::Timer m_Timer; |
62 }; | 70 }; |
63 | 71 |
64 class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate { | 72 class CFWL_SpinButtonImpDelegate : public CFWL_WidgetImpDelegate { |
65 public: | 73 public: |
66 CFWL_SpinButtonImpDelegate(IFWL_SpinButton* pOwner); | 74 CFWL_SpinButtonImpDelegate(IFWL_SpinButton* pOwner); |
67 void OnProcessMessage(CFWL_Message* pMessage) override; | 75 void OnProcessMessage(CFWL_Message* pMessage) override; |
68 void OnProcessEvent(CFWL_Event* pEvent) override; | 76 void OnProcessEvent(CFWL_Event* pEvent) override; |
69 void OnDrawWidget(CFX_Graphics* pGraphics, | 77 void OnDrawWidget(CFX_Graphics* pGraphics, |
70 const CFX_Matrix* pMatrix = nullptr) override; | 78 const CFX_Matrix* pMatrix = nullptr) override; |
71 | 79 |
72 protected: | 80 protected: |
73 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | 81 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); |
74 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 82 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
75 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 83 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
76 void OnMouseMove(CFWL_MsgMouse* pMsg); | 84 void OnMouseMove(CFWL_MsgMouse* pMsg); |
77 void OnMouseLeave(CFWL_MsgMouse* pMsg); | 85 void OnMouseLeave(CFWL_MsgMouse* pMsg); |
78 void OnKeyDown(CFWL_MsgKey* pMsg); | 86 void OnKeyDown(CFWL_MsgKey* pMsg); |
79 IFWL_SpinButton* m_pOwner; | 87 IFWL_SpinButton* m_pOwner; |
80 }; | 88 }; |
81 | 89 |
82 #endif // XFA_FWL_CORE_IFWL_SPINBUTTON_H_ | 90 #endif // XFA_FWL_CORE_IFWL_SPINBUTTON_H_ |
OLD | NEW |