xref: /aosp_15_r20/external/pdfium/xfa/fwl/cfwl_pushbutton.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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_PUSHBUTTON_H_
8 #define XFA_FWL_CFWL_PUSHBUTTON_H_
9 
10 #include "xfa/fwl/cfwl_widget.h"
11 
12 #define FWL_STATE_PSB_Hovered (1 << FWL_STATE_WGT_MAX)
13 #define FWL_STATE_PSB_Pressed (1 << (FWL_STATE_WGT_MAX + 1))
14 #define FWL_STATE_PSB_Default (1 << (FWL_STATE_WGT_MAX + 2))
15 
16 class CFWL_MessageKey;
17 class CFWL_MessageMouse;
18 
19 class CFWL_PushButton final : public CFWL_Widget {
20  public:
21   CONSTRUCT_VIA_MAKE_GARBAGE_COLLECTED;
22   ~CFWL_PushButton() override;
23 
24   // CFWL_Widget
25   FWL_Type GetClassID() const override;
26   void SetStates(uint32_t dwStates) override;
27   void Update() override;
28   void DrawWidget(CFGAS_GEGraphics* pGraphics,
29                   const CFX_Matrix& matrix) override;
30   void OnProcessMessage(CFWL_Message* pMessage) override;
31   void OnDrawWidget(CFGAS_GEGraphics* pGraphics,
32                     const CFX_Matrix& matrix) override;
33 
34  private:
35   explicit CFWL_PushButton(CFWL_App* pApp);
36 
37   void DrawBkground(CFGAS_GEGraphics* pGraphics, const CFX_Matrix& mtMatrix);
38   Mask<CFWL_PartState> GetPartStates();
39   void UpdateTextOutStyles();
40   void OnFocusGained();
41   void OnFocusLost();
42   void OnLButtonDown(CFWL_MessageMouse* pMsg);
43   void OnLButtonUp(CFWL_MessageMouse* pMsg);
44   void OnMouseMove(CFWL_MessageMouse* pMsg);
45   void OnMouseLeave(CFWL_MessageMouse* pMsg);
46   void OnKeyDown(CFWL_MessageKey* pMsg);
47 
48   bool m_bBtnDown = false;
49   CFX_RectF m_ClientRect;
50   CFX_RectF m_CaptionRect;
51 };
52 
53 #endif  // XFA_FWL_CFWL_PUSHBUTTON_H_
54