• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
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 "xfa/fwl/cfwl_event.h"
11 #include "xfa/fwl/cfwl_widget.h"
12 
13 #define FWL_STYLEEXT_CKB_3State (1L << 6)
14 #define FWL_STYLEEXT_CKB_RadioButton (1L << 7)
15 #define FWL_STYLEEXT_CKB_SignShapeCheck 0
16 #define FWL_STYLEEXT_CKB_SignShapeCircle (1L << 10)
17 #define FWL_STYLEEXT_CKB_SignShapeCross (2L << 10)
18 #define FWL_STYLEEXT_CKB_SignShapeDiamond (3L << 10)
19 #define FWL_STYLEEXT_CKB_SignShapeSquare (4L << 10)
20 #define FWL_STYLEEXT_CKB_SignShapeStar (5L << 10)
21 #define FWL_STYLEEXT_CKB_SignShapeMask (7L << 10)
22 #define FWL_STATE_CKB_Hovered (1 << FWL_STATE_WGT_MAX)
23 #define FWL_STATE_CKB_Pressed (1 << (FWL_STATE_WGT_MAX + 1))
24 #define FWL_STATE_CKB_Unchecked 0
25 #define FWL_STATE_CKB_Checked (1 << (FWL_STATE_WGT_MAX + 2))
26 #define FWL_STATE_CKB_Neutral (2 << (FWL_STATE_WGT_MAX + 2))
27 #define FWL_STATE_CKB_CheckMask (3L << (FWL_STATE_WGT_MAX + 2))
28 
29 class CFWL_MessageKey;
30 class CFWL_MessageMouse;
31 
32 class CFWL_CheckBox final : public CFWL_Widget {
33  public:
34   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
35   ~CFWL_CheckBox() override;
36 
37   // CFWL_Widget
38   FWL_Type GetClassID() const override;
39   void Update() override;
40   void DrawWidget(CFGAS_GEGraphics* pGraphics,
41                   const CFX_Matrix& matrix) override;
42 
43   void OnProcessMessage(CFWL_Message* pMessage) override;
44   void OnDrawWidget(CFGAS_GEGraphics* pGraphics,
45                     const CFX_Matrix& matrix) override;
46 
47   void SetBoxSize(float fHeight);
48 
49  private:
50   explicit CFWL_CheckBox(CFWL_App* pApp);
51 
52   void SetCheckState(int32_t iCheck);
53   void Layout();
54   Mask<CFWL_PartState> GetPartStates() const;
55   void UpdateTextOutStyles();
56   void NextStates();
57   void OnFocusGained();
58   void OnFocusLost();
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_ClientRect;
66   CFX_RectF m_BoxRect;
67   CFX_RectF m_CaptionRect;
68   CFX_RectF m_FocusRect;
69   FDE_TextStyle m_TTOStyles;
70   FDE_TextAlignment m_iTTOAlign = FDE_TextAlignment::kCenter;
71   bool m_bBtnDown = false;
72   float m_fBoxHeight = 16.0f;
73 };
74 
75 #endif  // XFA_FWL_CFWL_CHECKBOX_H_
76