1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinButtonBase class
4 // Author: Julian Smart, Vadim Zeitlin
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_SPINBUTT_H_BASE_
13 #define _WX_SPINBUTT_H_BASE_
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
23 #include "wx/control.h"
26 #define wxSPIN_BUTTON_NAME _T("wxSpinButton")
28 class WXDLLIMPEXP_FWD_CORE wxSpinEvent
;
29 wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE
, wxEVT_SPIN_UP
, wxSpinEvent
)
30 wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE
, wxEVT_SPIN_DOWN
, wxSpinEvent
)
31 wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE
, wxEVT_SPIN
, wxSpinEvent
)
33 // ----------------------------------------------------------------------------
34 // The wxSpinButton is like a small scrollbar than is often placed next
38 // wxSP_HORIZONTAL: horizontal spin button
39 // wxSP_VERTICAL: vertical spin button (the default)
40 // wxSP_ARROW_KEYS: arrow keys increment/decrement value
41 // wxSP_WRAP: value wraps at either end
42 // ----------------------------------------------------------------------------
44 class WXDLLIMPEXP_CORE wxSpinButtonBase
: public wxControl
47 // ctor initializes the range with the default (0..100) values
48 wxSpinButtonBase() { m_min
= 0; m_max
= 100; }
51 virtual int GetValue() const = 0;
52 virtual int GetMin() const { return m_min
; }
53 virtual int GetMax() const { return m_max
; }
56 virtual void SetValue(int val
) = 0;
57 virtual void SetMin(int minVal
) { SetRange ( minVal
, m_max
) ; }
58 virtual void SetMax(int maxVal
) { SetRange ( m_min
, maxVal
) ; }
59 virtual void SetRange(int minVal
, int maxVal
)
65 // is this spin button vertically oriented?
66 bool IsVertical() const { return (m_windowStyle
& wxSP_VERTICAL
) != 0; }
73 DECLARE_NO_COPY_CLASS(wxSpinButtonBase
)
76 // ----------------------------------------------------------------------------
77 // include the declaration of the real class
78 // ----------------------------------------------------------------------------
80 #if defined(__WXUNIVERSAL__)
81 #include "wx/univ/spinbutt.h"
82 #elif defined(__WXMSW__)
83 #include "wx/msw/spinbutt.h"
84 #elif defined(__WXMOTIF__)
85 #include "wx/motif/spinbutt.h"
86 #elif defined(__WXGTK20__)
87 #include "wx/gtk/spinbutt.h"
88 #elif defined(__WXGTK__)
89 #include "wx/gtk1/spinbutt.h"
90 #elif defined(__WXMAC__)
91 #include "wx/osx/spinbutt.h"
92 #elif defined(__WXCOCOA__)
93 #include "wx/cocoa/spinbutt.h"
94 #elif defined(__WXPM__)
95 #include "wx/os2/spinbutt.h"
98 // ----------------------------------------------------------------------------
99 // the wxSpinButton event
100 // ----------------------------------------------------------------------------
102 class WXDLLIMPEXP_CORE wxSpinEvent
: public wxNotifyEvent
105 wxSpinEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
106 : wxNotifyEvent(commandType
, winid
)
110 wxSpinEvent(const wxSpinEvent
& event
) : wxNotifyEvent(event
) {}
112 // get the current value of the control
113 int GetValue() const { return m_commandInt
; }
114 void SetValue(int value
) { m_commandInt
= value
; }
116 int GetPosition() const { return m_commandInt
; }
117 void SetPosition(int pos
) { m_commandInt
= pos
; }
119 virtual wxEvent
*Clone() const { return new wxSpinEvent(*this); }
122 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinEvent
)
125 typedef void (wxEvtHandler::*wxSpinEventFunction
)(wxSpinEvent
&);
127 #define wxSpinEventHandler(func) \
128 wxEVENT_HANDLER_CAST(wxSpinEventFunction, func)
130 // macros for handling spin events
131 #define EVT_SPIN_UP(winid, func) \
132 wx__DECLARE_EVT1(wxEVT_SPIN_UP, winid, wxSpinEventHandler(func))
133 #define EVT_SPIN_DOWN(winid, func) \
134 wx__DECLARE_EVT1(wxEVT_SPIN_DOWN, winid, wxSpinEventHandler(func))
135 #define EVT_SPIN(winid, func) \
136 wx__DECLARE_EVT1(wxEVT_SPIN, winid, wxSpinEventHandler(func))
138 #endif // wxUSE_SPINBTN
141 // _WX_SPINBUTT_H_BASE_