• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SPINBUTTON_H_
8 #define XFA_FWL_CFWL_SPINBUTTON_H_
9 
10 #include <memory>
11 
12 #include "xfa/fwl/cfwl_timer.h"
13 #include "xfa/fwl/cfwl_widget.h"
14 #include "xfa/fxfa/cxfa_eventparam.h"
15 
16 #define FWL_STYLEEXE_SPB_Vert (1L << 0)
17 
18 class CFWL_MessageMouse;
19 class CFWL_WidgetProperties;
20 
21 class CFWL_SpinButton : public CFWL_Widget {
22  public:
23   CFWL_SpinButton(const CFWL_App* app,
24                   std::unique_ptr<CFWL_WidgetProperties> properties);
25   ~CFWL_SpinButton() override;
26 
27   // CFWL_Widget
28   FWL_Type GetClassID() const override;
29   void Update() override;
30   FWL_WidgetHit HitTest(const CFX_PointF& point) override;
31   void DrawWidget(CFX_Graphics* pGraphics, const CFX_Matrix* pMatrix) override;
32   void OnProcessMessage(CFWL_Message* pMessage) override;
33   void OnDrawWidget(CFX_Graphics* pGraphics,
34                     const CFX_Matrix* pMatrix) override;
35 
36  private:
37   class Timer : public CFWL_Timer {
38    public:
39     explicit Timer(CFWL_SpinButton* pToolTip);
~Timer()40     ~Timer() override {}
41 
42     void Run(CFWL_TimerInfo* pTimerInfo) override;
43   };
44   friend class CFWL_SpinButton::Timer;
45 
46   void DisableButton();
47   bool IsUpButtonEnabled();
48   bool IsDownButtonEnabled();
49   void DrawUpButton(CFX_Graphics* pGraphics,
50                     IFWL_ThemeProvider* pTheme,
51                     const CFX_Matrix* pMatrix);
52   void DrawDownButton(CFX_Graphics* pGraphics,
53                       IFWL_ThemeProvider* pTheme,
54                       const CFX_Matrix* pMatrix);
55   void OnFocusChanged(CFWL_Message* pMsg, bool bSet);
56   void OnLButtonDown(CFWL_MessageMouse* pMsg);
57   void OnLButtonUp(CFWL_MessageMouse* pMsg);
58   void OnMouseMove(CFWL_MessageMouse* pMsg);
59   void OnMouseLeave(CFWL_MessageMouse* pMsg);
60   void OnKeyDown(CFWL_MessageKey* pMsg);
61 
62   CFX_RectF m_rtClient;
63   CFX_RectF m_rtUpButton;
64   CFX_RectF m_rtDnButton;
65   uint32_t m_dwUpState;
66   uint32_t m_dwDnState;
67   int32_t m_iButtonIndex;
68   bool m_bLButtonDwn;
69   CFWL_TimerInfo* m_pTimerInfo;
70   CFWL_SpinButton::Timer m_Timer;
71 };
72 
73 #endif  // XFA_FWL_CFWL_SPINBUTTON_H_
74