1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/spinbutt.h
3 // Purpose: universal version of wxSpinButton
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_SPINBUTT_H_
13 #define _WX_UNIV_SPINBUTT_H_
15 #include "wx/univ/scrarrow.h"
17 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
21 // actions supported by this control
22 #define wxACTION_SPIN_INC _T("inc")
23 #define wxACTION_SPIN_DEC _T("dec")
25 class WXDLLEXPORT wxSpinButton
: public wxSpinButtonBase
,
26 public wxControlWithArrows
30 wxSpinButton(wxWindow
*parent
,
31 wxWindowID id
= wxID_ANY
,
32 const wxPoint
& pos
= wxDefaultPosition
,
33 const wxSize
& size
= wxDefaultSize
,
34 long style
= wxSP_VERTICAL
| wxSP_ARROW_KEYS
,
35 const wxString
& name
= wxSPIN_BUTTON_NAME
);
37 bool Create(wxWindow
*parent
,
38 wxWindowID id
= wxID_ANY
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
41 long style
= wxSP_VERTICAL
| wxSP_ARROW_KEYS
,
42 const wxString
& name
= wxSPIN_BUTTON_NAME
);
44 // implement wxSpinButtonBase methods
45 virtual int GetValue() const;
46 virtual void SetValue(int val
);
47 virtual void SetRange(int minVal
, int maxVal
);
49 // implement wxControlWithArrows methods
50 virtual wxRenderer
*GetRenderer() const { return m_renderer
; }
51 virtual wxWindow
*GetWindow() { return this; }
52 virtual bool IsVertical() const { return wxSpinButtonBase::IsVertical(); }
53 virtual int GetArrowState(wxScrollArrows::Arrow arrow
) const;
54 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow
, int flag
, bool set
);
55 virtual bool OnArrow(wxScrollArrows::Arrow arrow
);
56 virtual wxScrollArrows::Arrow
HitTest(const wxPoint
& pt
) const;
58 // for wxStdSpinButtonInputHandler
59 const wxScrollArrows
& GetArrows() { return m_arrows
; }
61 virtual bool PerformAction(const wxControlAction
& action
,
63 const wxString
& strArg
= wxEmptyString
);
66 virtual wxSize
DoGetBestClientSize() const;
67 virtual void DoDraw(wxControlRenderer
*renderer
);
68 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
70 // the common part of all ctors
73 // normalize the value to fit into min..max range
74 int NormalizeValue(int value
) const;
76 // change the value by +1/-1 and send the event, return true if value was
78 bool ChangeValue(int inc
);
80 // get the rectangles for our 2 arrows
81 void CalcArrowRects(wxRect
*rect1
, wxRect
*rect2
) const;
83 // the current controls value
87 // the object which manages our arrows
88 wxScrollArrows m_arrows
;
90 // the state (combination of wxCONTROL_XXX flags) of the arrows
91 int m_arrowsState
[wxScrollArrows::Arrow_Max
];
93 DECLARE_DYNAMIC_CLASS(wxSpinButton
)
96 // ----------------------------------------------------------------------------
97 // wxStdSpinButtonInputHandler: manages clicks on them (use arrows like
98 // wxStdScrollBarInputHandler) and processes keyboard events too
99 // ----------------------------------------------------------------------------
101 class WXDLLEXPORT wxStdSpinButtonInputHandler
: public wxStdInputHandler
104 wxStdSpinButtonInputHandler(wxInputHandler
*inphand
);
106 virtual bool HandleKey(wxInputConsumer
*consumer
,
107 const wxKeyEvent
& event
,
109 virtual bool HandleMouse(wxInputConsumer
*consumer
,
110 const wxMouseEvent
& event
);
111 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
112 const wxMouseEvent
& event
);
115 #endif // _WX_UNIV_SPINBUTT_H_