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