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_CHECKBOX_H_ | 7 #ifndef XFA_FWL_CORE_IFWL_CHECKBOX_H_ |
8 #define XFA_FWL_CORE_IFWL_CHECKBOX_H_ | 8 #define XFA_FWL_CORE_IFWL_CHECKBOX_H_ |
9 | 9 |
10 #include "xfa/fwl/core/cfwl_event.h" | 10 #include "xfa/fwl/core/cfwl_event.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #define FWL_STYLEEXT_CKB_VLayoutMask (3L << 2) | 36 #define FWL_STYLEEXT_CKB_VLayoutMask (3L << 2) |
37 #define FWL_STYLEEXT_CKB_ShapeMask (3L << 8) | 37 #define FWL_STYLEEXT_CKB_ShapeMask (3L << 8) |
38 #define FWL_STYLEEXT_CKB_SignShapeMask (7L << 10) | 38 #define FWL_STYLEEXT_CKB_SignShapeMask (7L << 10) |
39 #define FWL_STATE_CKB_Hovered (1 << FWL_WGTSTATE_MAX) | 39 #define FWL_STATE_CKB_Hovered (1 << FWL_WGTSTATE_MAX) |
40 #define FWL_STATE_CKB_Pressed (1 << (FWL_WGTSTATE_MAX + 1)) | 40 #define FWL_STATE_CKB_Pressed (1 << (FWL_WGTSTATE_MAX + 1)) |
41 #define FWL_STATE_CKB_Unchecked (0 << (FWL_WGTSTATE_MAX + 2)) | 41 #define FWL_STATE_CKB_Unchecked (0 << (FWL_WGTSTATE_MAX + 2)) |
42 #define FWL_STATE_CKB_Checked (1 << (FWL_WGTSTATE_MAX + 2)) | 42 #define FWL_STATE_CKB_Checked (1 << (FWL_WGTSTATE_MAX + 2)) |
43 #define FWL_STATE_CKB_Neutral (2 << (FWL_WGTSTATE_MAX + 2)) | 43 #define FWL_STATE_CKB_Neutral (2 << (FWL_WGTSTATE_MAX + 2)) |
44 #define FWL_STATE_CKB_CheckMask (3L << (FWL_WGTSTATE_MAX + 2)) | 44 #define FWL_STATE_CKB_CheckMask (3L << (FWL_WGTSTATE_MAX + 2)) |
45 | 45 |
46 class CFWL_CheckBoxImpDelegate; | |
47 class CFWL_MsgMouse; | 46 class CFWL_MsgMouse; |
48 class CFWL_WidgetImpProperties; | 47 class CFWL_WidgetImpProperties; |
49 class IFWL_Widget; | 48 class IFWL_Widget; |
50 | 49 |
51 FWL_EVENT_DEF(CFWL_EvtCkbCheckStateChanged, CFWL_EventType::CheckStateChanged) | 50 FWL_EVENT_DEF(CFWL_EvtCkbCheckStateChanged, CFWL_EventType::CheckStateChanged) |
52 | 51 |
53 class IFWL_CheckBoxDP : public IFWL_DataProvider { | 52 class IFWL_CheckBoxDP : public IFWL_DataProvider { |
54 public: | 53 public: |
55 virtual FX_FLOAT GetBoxSize(IFWL_Widget* pWidget) = 0; | 54 virtual FX_FLOAT GetBoxSize(IFWL_Widget* pWidget) = 0; |
56 }; | 55 }; |
57 | 56 |
58 class IFWL_CheckBox : public IFWL_Widget { | 57 class IFWL_CheckBox : public IFWL_Widget { |
59 public: | 58 public: |
60 explicit IFWL_CheckBox(const IFWL_App* app, | 59 explicit IFWL_CheckBox(const IFWL_App* app, |
61 const CFWL_WidgetImpProperties& properties); | 60 const CFWL_WidgetImpProperties& properties); |
62 ~IFWL_CheckBox() override; | 61 ~IFWL_CheckBox() override; |
63 | 62 |
64 // IFWL_Widget | 63 // IFWL_Widget |
65 FWL_Type GetClassID() const override; | 64 FWL_Type GetClassID() const override; |
66 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; | 65 FWL_Error GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize = FALSE) override; |
67 FWL_Error Update() override; | 66 FWL_Error Update() override; |
68 FWL_Error DrawWidget(CFX_Graphics* pGraphics, | 67 FWL_Error DrawWidget(CFX_Graphics* pGraphics, |
69 const CFX_Matrix* pMatrix = nullptr) override; | 68 const CFX_Matrix* pMatrix = nullptr) override; |
| 69 |
| 70 void OnProcessMessage(CFWL_Message* pMessage) override; |
| 71 void OnDrawWidget(CFX_Graphics* pGraphics, |
| 72 const CFX_Matrix* pMatrix) override; |
| 73 |
70 int32_t GetCheckState(); | 74 int32_t GetCheckState(); |
71 FWL_Error SetCheckState(int32_t iCheck); | 75 FWL_Error SetCheckState(int32_t iCheck); |
72 | 76 |
73 protected: | 77 protected: |
74 friend class CFWL_CheckBoxImpDelegate; | |
75 | |
76 void Layout(); | 78 void Layout(); |
77 uint32_t GetPartStates(); | 79 uint32_t GetPartStates(); |
78 void UpdateTextOutStyles(); | 80 void UpdateTextOutStyles(); |
79 void NextStates(); | 81 void NextStates(); |
80 | 82 |
81 CFX_RectF m_rtClient; | 83 CFX_RectF m_rtClient; |
82 CFX_RectF m_rtBox; | 84 CFX_RectF m_rtBox; |
83 CFX_RectF m_rtCaption; | 85 CFX_RectF m_rtCaption; |
84 CFX_RectF m_rtFocus; | 86 CFX_RectF m_rtFocus; |
85 uint32_t m_dwTTOStyles; | 87 uint32_t m_dwTTOStyles; |
86 int32_t m_iTTOAlign; | 88 int32_t m_iTTOAlign; |
87 FX_BOOL m_bBtnDown; | 89 FX_BOOL m_bBtnDown; |
88 }; | |
89 | 90 |
90 class CFWL_CheckBoxImpDelegate : public CFWL_WidgetImpDelegate { | 91 private: |
91 public: | |
92 CFWL_CheckBoxImpDelegate(IFWL_CheckBox* pOwner); | |
93 | |
94 void OnProcessMessage(CFWL_Message* pMessage) override; | |
95 void OnDrawWidget(CFX_Graphics* pGraphics, | |
96 const CFX_Matrix* pMatrix = nullptr) override; | |
97 | |
98 protected: | |
99 void OnActivate(CFWL_Message* pMsg); | 92 void OnActivate(CFWL_Message* pMsg); |
100 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet = TRUE); | 93 void OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet); |
101 void OnLButtonDown(CFWL_MsgMouse* pMsg); | 94 void OnLButtonDown(CFWL_MsgMouse* pMsg); |
102 void OnLButtonUp(CFWL_MsgMouse* pMsg); | 95 void OnLButtonUp(CFWL_MsgMouse* pMsg); |
103 void OnMouseMove(CFWL_MsgMouse* pMsg); | 96 void OnMouseMove(CFWL_MsgMouse* pMsg); |
104 void OnMouseLeave(CFWL_MsgMouse* pMsg); | 97 void OnMouseLeave(CFWL_MsgMouse* pMsg); |
105 void OnKeyDown(CFWL_MsgKey* pMsg); | 98 void OnKeyDown(CFWL_MsgKey* pMsg); |
106 | |
107 IFWL_CheckBox* m_pOwner; | |
108 }; | 99 }; |
109 | 100 |
110 #endif // XFA_FWL_CORE_IFWL_CHECKBOX_H_ | 101 #endif // XFA_FWL_CORE_IFWL_CHECKBOX_H_ |
OLD | NEW |