• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef XFA_FWL_CFWL_CHECKBOX_H_
8 #define XFA_FWL_CFWL_CHECKBOX_H_
9 
10 #include <memory>
11 
12 #include "xfa/fwl/cfwl_event.h"
13 #include "xfa/fwl/cfwl_widget.h"
14 #include "xfa/fwl/cfwl_widgetproperties.h"
15 
16 #define FWL_STYLEEXT_CKB_3State (1L << 6)
17 #define FWL_STYLEEXT_CKB_RadioButton (1L << 7)
18 #define FWL_STYLEEXT_CKB_SignShapeCheck 0
19 #define FWL_STYLEEXT_CKB_SignShapeCircle (1L << 10)
20 #define FWL_STYLEEXT_CKB_SignShapeCross (2L << 10)
21 #define FWL_STYLEEXT_CKB_SignShapeDiamond (3L << 10)
22 #define FWL_STYLEEXT_CKB_SignShapeSquare (4L << 10)
23 #define FWL_STYLEEXT_CKB_SignShapeStar (5L << 10)
24 #define FWL_STYLEEXT_CKB_SignShapeMask (7L << 10)
25 #define FWL_STATE_CKB_Hovered (1 << FWL_WGTSTATE_MAX)
26 #define FWL_STATE_CKB_Pressed (1 << (FWL_WGTSTATE_MAX + 1))
27 #define FWL_STATE_CKB_Unchecked 0
28 #define FWL_STATE_CKB_Checked (1 << (FWL_WGTSTATE_MAX + 2))
29 #define FWL_STATE_CKB_Neutral (2 << (FWL_WGTSTATE_MAX + 2))
30 #define FWL_STATE_CKB_CheckMask (3L << (FWL_WGTSTATE_MAX + 2))
31 
32 class CFWL_MessageMouse;
33 class CFWL_WidgetProperties;
34 class CFWL_Widget;
35 
36 class CFWL_CheckBox : public CFWL_Widget {
37  public:
38   explicit CFWL_CheckBox(const CFWL_App* pApp);
39   ~CFWL_CheckBox() override;
40 
41   // CFWL_Widget
42   FWL_Type GetClassID() const override;
43   void Update() override;
44   void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
45 
46   void OnProcessMessage(CFWL_Message* pMessage) override;
47   void OnDrawWidget(CXFA_Graphics* pGraphics,
48                     const CFX_Matrix& matrix) override;
49 
50   void SetBoxSize(float fHeight);
51 
52  private:
53   void SetCheckState(int32_t iCheck);
54   void Layout();
55   uint32_t GetPartStates() const;
56   void UpdateTextOutStyles();
57   void NextStates();
58   void OnFocusChanged(bool bSet);
59   void OnLButtonDown();
60   void OnLButtonUp(CFWL_MessageMouse* pMsg);
61   void OnMouseMove(CFWL_MessageMouse* pMsg);
62   void OnMouseLeave();
63   void OnKeyDown(CFWL_MessageKey* pMsg);
64 
65   CFX_RectF m_rtClient;
66   CFX_RectF m_rtBox;
67   CFX_RectF m_rtCaption;
68   CFX_RectF m_rtFocus;
69   FDE_TextStyle m_dwTTOStyles;
70   FDE_TextAlignment m_iTTOAlign;
71   bool m_bBtnDown;
72   float m_fBoxHeight;
73 };
74 
75 #endif  // XFA_FWL_CFWL_CHECKBOX_H_
76