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_PUSHBUTTON_H_
8 #define XFA_FWL_CFWL_PUSHBUTTON_H_
9 
10 #include "xfa/fwl/cfwl_widget.h"
11 #include "xfa/fwl/cfwl_widgetproperties.h"
12 
13 #define FWL_STATE_PSB_Hovered (1 << FWL_WGTSTATE_MAX)
14 #define FWL_STATE_PSB_Pressed (1 << (FWL_WGTSTATE_MAX + 1))
15 
16 class CFWL_MessageMouse;
17 class CFX_DIBitmap;
18 class CFWL_Widget;
19 
20 class CFWL_PushButton final : public CFWL_Widget {
21  public:
22   explicit CFWL_PushButton(const CFWL_App*);
23   ~CFWL_PushButton() override;
24 
25   // CFWL_Widget
26   FWL_Type GetClassID() const override;
27   void SetStates(uint32_t dwStates) override;
28   void Update() override;
29   void DrawWidget(CXFA_Graphics* pGraphics, const CFX_Matrix& matrix) override;
30   void OnProcessMessage(CFWL_Message* pMessage) override;
31   void OnDrawWidget(CXFA_Graphics* pGraphics,
32                     const CFX_Matrix& matrix) override;
33 
34  private:
35   void DrawBkground(CXFA_Graphics* pGraphics,
36                     IFWL_ThemeProvider* pTheme,
37                     const CFX_Matrix* pMatrix);
38   uint32_t GetPartStates();
39   void UpdateTextOutStyles();
40   void OnFocusChanged(CFWL_Message* pMsg, bool bSet);
41   void OnLButtonDown(CFWL_MessageMouse* pMsg);
42   void OnLButtonUp(CFWL_MessageMouse* pMsg);
43   void OnMouseMove(CFWL_MessageMouse* pMsg);
44   void OnMouseLeave(CFWL_MessageMouse* pMsg);
45   void OnKeyDown(CFWL_MessageKey* pMsg);
46 
47   bool m_bBtnDown = false;
48   CFX_RectF m_rtClient;
49   CFX_RectF m_rtCaption;
50 };
51 
52 #endif  // XFA_FWL_CFWL_PUSHBUTTON_H_
53