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_FFPUSHBUTTON_H_
8 #define XFA_FXFA_CXFA_FFPUSHBUTTON_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/unowned_ptr.h"
13 #include "xfa/fxfa/cxfa_fffield.h"
14 
15 #define XFA_FWL_PSBSTYLEEXT_HiliteInverted (1L << 0)
16 #define XFA_FWL_PSBSTYLEEXT_HilitePush (1L << 1)
17 #define XFA_FWL_PSBSTYLEEXT_HiliteOutLine (1L << 2)
18 
19 class CXFA_Button;
20 class CXFA_TextLayout;
21 class CXFA_TextProvider;
22 
23 class CXFA_FFPushButton final : public CXFA_FFField {
24  public:
25   CXFA_FFPushButton(CXFA_Node* pNode, CXFA_Button* button);
26   ~CXFA_FFPushButton() override;
27 
28   // CXFA_FFField
29   void RenderWidget(CXFA_Graphics* pGS,
30                     const CFX_Matrix& matrix,
31                     HighlightOption highlight) override;
32   bool LoadWidget() override;
33   bool PerformLayout() override;
34   void UpdateWidgetProperty() override;
35   void OnProcessMessage(CFWL_Message* pMessage) override;
36   void OnProcessEvent(CFWL_Event* pEvent) override;
37   void OnDrawWidget(CXFA_Graphics* pGraphics,
38                     const CFX_Matrix& matrix) override;
39   FormFieldType GetFormFieldType() override;
40 
41  private:
42   void LoadHighlightCaption();
43   void LayoutHighlightCaption();
44   void RenderHighlightCaption(CXFA_Graphics* pGS, CFX_Matrix* pMatrix);
45   float GetLineWidth();
46   FX_ARGB GetLineColor();
47   FX_ARGB GetFillColor();
48 
49   std::unique_ptr<CXFA_TextLayout> m_pRolloverTextLayout;
50   std::unique_ptr<CXFA_TextLayout> m_pDownTextLayout;
51   std::unique_ptr<CXFA_TextProvider> m_pRollProvider;
52   std::unique_ptr<CXFA_TextProvider> m_pDownProvider;
53   UnownedPtr<IFWL_WidgetDelegate> m_pOldDelegate;
54   UnownedPtr<CXFA_Button> const button_;
55 };
56 
57 #endif  // XFA_FXFA_CXFA_FFPUSHBUTTON_H_
58