1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/spinbutt.h
3 // Purpose: universal version of wxSpinButton
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIV_SPINBUTT_H_
12 #define _WX_UNIV_SPINBUTT_H_
14 #include "wx/univ/scrarrow.h"
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // actions supported by this control
21 #define wxACTION_SPIN_INC wxT("inc")
22 #define wxACTION_SPIN_DEC wxT("dec")
24 class WXDLLIMPEXP_CORE wxSpinButton
: public wxSpinButtonBase
,
25 public wxControlWithArrows
29 wxSpinButton(wxWindow
*parent
,
30 wxWindowID id
= wxID_ANY
,
31 const wxPoint
& pos
= wxDefaultPosition
,
32 const wxSize
& size
= wxDefaultSize
,
33 long style
= wxSP_VERTICAL
| wxSP_ARROW_KEYS
,
34 const wxString
& name
= wxSPIN_BUTTON_NAME
);
36 bool Create(wxWindow
*parent
,
37 wxWindowID id
= wxID_ANY
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
40 long style
= wxSP_VERTICAL
| wxSP_ARROW_KEYS
,
41 const wxString
& name
= wxSPIN_BUTTON_NAME
);
43 // implement wxSpinButtonBase methods
44 virtual int GetValue() const;
45 virtual void SetValue(int val
);
46 virtual void SetRange(int minVal
, int maxVal
);
48 // implement wxControlWithArrows methods
49 virtual wxRenderer
*GetRenderer() const { return m_renderer
; }
50 virtual wxWindow
*GetWindow() { return this; }
51 virtual bool IsVertical() const { return wxSpinButtonBase::IsVertical(); }
52 virtual int GetArrowState(wxScrollArrows::Arrow arrow
) const;
53 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow
, int flag
, bool set
);
54 virtual bool OnArrow(wxScrollArrows::Arrow arrow
);
55 virtual wxScrollArrows::Arrow
HitTestArrow(const wxPoint
& pt
) const;
57 // for wxStdSpinButtonInputHandler
58 const wxScrollArrows
& GetArrows() { return m_arrows
; }
60 virtual bool PerformAction(const wxControlAction
& action
,
62 const wxString
& strArg
= wxEmptyString
);
64 static wxInputHandler
*GetStdInputHandler(wxInputHandler
*handlerDef
);
65 virtual wxInputHandler
*DoGetStdInputHandler(wxInputHandler
*handlerDef
)
67 return GetStdInputHandler(handlerDef
);
71 virtual wxSize
DoGetBestClientSize() const;
72 virtual void DoDraw(wxControlRenderer
*renderer
);
73 virtual wxBorder
GetDefaultBorder() const { return wxBORDER_NONE
; }
75 // the common part of all ctors
78 // normalize the value to fit into min..max range
79 int NormalizeValue(int value
) const;
81 // change the value by +1/-1 and send the event, return true if value was
83 bool ChangeValue(int inc
);
85 // get the rectangles for our 2 arrows
86 void CalcArrowRects(wxRect
*rect1
, wxRect
*rect2
) const;
88 // the current controls value
92 // the object which manages our arrows
93 wxScrollArrows m_arrows
;
95 // the state (combination of wxCONTROL_XXX flags) of the arrows
96 int m_arrowsState
[wxScrollArrows::Arrow_Max
];
98 DECLARE_DYNAMIC_CLASS(wxSpinButton
)
101 // ----------------------------------------------------------------------------
102 // wxStdSpinButtonInputHandler: manages clicks on them (use arrows like
103 // wxStdScrollBarInputHandler) and processes keyboard events too
104 // ----------------------------------------------------------------------------
106 class WXDLLIMPEXP_CORE wxStdSpinButtonInputHandler
: public wxStdInputHandler
109 wxStdSpinButtonInputHandler(wxInputHandler
*inphand
);
111 virtual bool HandleKey(wxInputConsumer
*consumer
,
112 const wxKeyEvent
& event
,
114 virtual bool HandleMouse(wxInputConsumer
*consumer
,
115 const wxMouseEvent
& event
);
116 virtual bool HandleMouseMove(wxInputConsumer
*consumer
,
117 const wxMouseEvent
& event
);
120 #endif // _WX_UNIV_SPINBUTT_H_