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_FXFA_CXFA_FFCHECKBUTTON_H_
8 #define XFA_FXFA_CXFA_FFCHECKBUTTON_H_
9 
10 #include "core/fxcrt/unowned_ptr.h"
11 #include "xfa/fxfa/cxfa_fffield.h"
12 #include "xfa/fxfa/cxfa_ffpageview.h"
13 #include "xfa/fxfa/parser/cxfa_node.h"
14 
15 class CXFA_CheckButton;
16 
17 class CXFA_FFCheckButton final : public CXFA_FFField {
18  public:
19   CXFA_FFCheckButton(CXFA_Node* pNode, CXFA_CheckButton* button);
20   ~CXFA_FFCheckButton() override;
21 
22   // CXFA_FFField
23   void RenderWidget(CXFA_Graphics* pGS,
24                     const CFX_Matrix& matrix,
25                     HighlightOption highlight) override;
26 
27   bool LoadWidget() override;
28   bool PerformLayout() override;
29   bool UpdateFWLData() override;
30   void UpdateWidgetProperty() override;
31   bool OnLButtonUp(uint32_t dwFlags, const CFX_PointF& point) override;
32   void OnProcessMessage(CFWL_Message* pMessage) override;
33   void OnProcessEvent(CFWL_Event* pEvent) override;
34   void OnDrawWidget(CXFA_Graphics* pGraphics,
35                     const CFX_Matrix& matrix) override;
36   FormFieldType GetFormFieldType() override;
37 
38   void SetFWLCheckState(XFA_CHECKSTATE eCheckState);
39 
40  private:
41   bool CommitData() override;
42   bool IsDataChanged() override;
43   void CapLeftRightPlacement(const CXFA_Margin* captionMargin);
44   void AddUIMargin(XFA_AttributeValue iCapPlacement);
45   XFA_CHECKSTATE FWLState2XFAState();
46 
47   UnownedPtr<IFWL_WidgetDelegate> m_pOldDelegate;
48   CFX_RectF m_rtCheckBox;
49   UnownedPtr<CXFA_CheckButton> const button_;
50 };
51 
52 #endif  // XFA_FXFA_CXFA_FFCHECKBUTTON_H_
53