1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinButtonBase class
4 // Author: Julian Smart, Vadim Zeitlin
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_SPINBUTT_H_BASE_
12 #define _WX_SPINBUTT_H_BASE_
14 // ----------------------------------------------------------------------------
16 // ----------------------------------------------------------------------------
22 #include "wx/control.h"
26 #define wxSPIN_BUTTON_NAME wxT("wxSpinButton")
28 // ----------------------------------------------------------------------------
29 // The wxSpinButton is like a small scrollbar than is often placed next
33 // wxSP_HORIZONTAL: horizontal spin button
34 // wxSP_VERTICAL: vertical spin button (the default)
35 // wxSP_ARROW_KEYS: arrow keys increment/decrement value
36 // wxSP_WRAP: value wraps at either end
37 // ----------------------------------------------------------------------------
39 class WXDLLIMPEXP_CORE wxSpinButtonBase
: public wxControl
42 // ctor initializes the range with the default (0..100) values
43 wxSpinButtonBase() { m_min
= 0; m_max
= 100; }
46 virtual int GetValue() const = 0;
47 virtual int GetMin() const { return m_min
; }
48 virtual int GetMax() const { return m_max
; }
49 wxRange
GetRange() const { return wxRange( GetMin(), GetMax() );}
52 virtual void SetValue(int val
) = 0;
53 virtual void SetMin(int minVal
) { SetRange ( minVal
, m_max
) ; }
54 virtual void SetMax(int maxVal
) { SetRange ( m_min
, maxVal
) ; }
55 virtual void SetRange(int minVal
, int maxVal
)
60 void SetRange( const wxRange
& range
) { SetRange( range
.GetMin(), range
.GetMax()); }
62 // is this spin button vertically oriented?
63 bool IsVertical() const { return (m_windowStyle
& wxSP_VERTICAL
) != 0; }
70 wxDECLARE_NO_COPY_CLASS(wxSpinButtonBase
);
73 // ----------------------------------------------------------------------------
74 // include the declaration of the real class
75 // ----------------------------------------------------------------------------
77 #if defined(__WXUNIVERSAL__)
78 #include "wx/univ/spinbutt.h"
79 #elif defined(__WXMSW__)
80 #include "wx/msw/spinbutt.h"
81 #elif defined(__WXMOTIF__)
82 #include "wx/motif/spinbutt.h"
83 #elif defined(__WXGTK20__)
84 #include "wx/gtk/spinbutt.h"
85 #elif defined(__WXGTK__)
86 #include "wx/gtk1/spinbutt.h"
87 #elif defined(__WXMAC__)
88 #include "wx/osx/spinbutt.h"
89 #elif defined(__WXCOCOA__)
90 #include "wx/cocoa/spinbutt.h"
91 #elif defined(__WXPM__)
92 #include "wx/os2/spinbutt.h"
95 // ----------------------------------------------------------------------------
96 // the wxSpinButton event
97 // ----------------------------------------------------------------------------
99 class WXDLLIMPEXP_CORE wxSpinEvent
: public wxNotifyEvent
102 wxSpinEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0)
103 : wxNotifyEvent(commandType
, winid
)
107 wxSpinEvent(const wxSpinEvent
& event
) : wxNotifyEvent(event
) {}
109 // get the current value of the control
110 int GetValue() const { return m_commandInt
; }
111 void SetValue(int value
) { m_commandInt
= value
; }
113 int GetPosition() const { return m_commandInt
; }
114 void SetPosition(int pos
) { m_commandInt
= pos
; }
116 virtual wxEvent
*Clone() const { return new wxSpinEvent(*this); }
119 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinEvent
)
122 typedef void (wxEvtHandler::*wxSpinEventFunction
)(wxSpinEvent
&);
124 #define wxSpinEventHandler(func) \
125 wxEVENT_HANDLER_CAST(wxSpinEventFunction, func)
127 // macros for handling spin events: notice that we must use the real values of
128 // the event type constants and not their references (wxEVT_SPIN[_UP/DOWN])
129 // here as otherwise the event tables could end up with non-initialized
130 // (because of undefined initialization order of the globals defined in
131 // different translation units) references in them
132 #define EVT_SPIN_UP(winid, func) \
133 wx__DECLARE_EVT1(wxEVT_SPIN_UP, winid, wxSpinEventHandler(func))
134 #define EVT_SPIN_DOWN(winid, func) \
135 wx__DECLARE_EVT1(wxEVT_SPIN_DOWN, winid, wxSpinEventHandler(func))
136 #define EVT_SPIN(winid, func) \
137 wx__DECLARE_EVT1(wxEVT_SPIN, winid, wxSpinEventHandler(func))
139 #endif // wxUSE_SPINBTN
142 // _WX_SPINBUTT_H_BASE_