1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinCtrlBase class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_SPINCTRL_H_
13 #define _WX_SPINCTRL_H_
19 #include "wx/spinbutt.h" // should make wxSpinEvent visible to the app
21 // ----------------------------------------------------------------------------
22 // A spin ctrl is a text control with a spin button which is usually used to
23 // prompt the user for a numeric input.
24 // There are two kinds for number types T=integer or T=double.
25 // ----------------------------------------------------------------------------
27 class WXDLLEXPORT wxSpinCtrlBase
: public wxControl
32 // accessor functions that derived classes are expected to have
36 // T GetIncrement() const
37 virtual bool GetSnapToTicks() const = 0;
38 // unsigned GetDigits() const - wxSpinCtrlDouble only
40 // operation functions that derived classes are expected to have
41 virtual void SetValue(const wxString
& value
) = 0;
42 // void SetValue(T val)
43 // void SetRange(T minVal, T maxVal)
44 // void SetIncrement(T inc)
45 virtual void SetSnapToTicks(bool snap_to_ticks
) = 0;
46 // void SetDigits(unsigned digits) - wxSpinCtrlDouble only
48 // Select text in the textctrl
49 virtual void SetSelection(long from
, long to
) = 0;
52 DECLARE_NO_COPY_CLASS(wxSpinCtrlBase
)
55 // ----------------------------------------------------------------------------
56 // wxSpinDoubleEvent - a wxSpinEvent for double valued controls
57 // ----------------------------------------------------------------------------
59 class WXDLLEXPORT wxSpinDoubleEvent
: public wxNotifyEvent
62 wxSpinDoubleEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0,
64 : wxNotifyEvent(commandType
, winid
), m_value(value
)
68 wxSpinDoubleEvent(const wxSpinDoubleEvent
& event
)
69 : wxNotifyEvent(event
), m_value(event
.GetValue())
73 double GetValue() const { return m_value
; }
74 void SetValue(double value
) { m_value
= value
; }
76 virtual wxEvent
*Clone() const { return new wxSpinDoubleEvent(*this); }
82 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinDoubleEvent
)
85 // ----------------------------------------------------------------------------
86 // wxSpinDoubleEvent event type, see also wxSpinEvent in wx/spinbutt.h
87 // ----------------------------------------------------------------------------
89 typedef void (wxEvtHandler::*wxSpinDoubleEventFunction
)(wxSpinDoubleEvent
&);
91 #define wxSpinDoubleEventHandler(func) \
92 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSpinDoubleEventFunction, &func)
94 // macros for handling spinctrl events
96 #define EVT_SPINCTRL(id, fn) \
97 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRL_UPDATED, id, wxSpinEventHandler(fn))
99 #define EVT_SPINCTRLDOUBLE(id, fn) \
100 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, id, wxSpinDoubleEventHandler(fn))
102 // ----------------------------------------------------------------------------
103 // include the platform-dependent class implementation
104 // ----------------------------------------------------------------------------
106 // we may have a native wxSpinCtrl implementation, native wxSpinCtrl and
107 // wxSpinCtrlDouble implementations or neither, define the appropriate symbols
108 // and include the generic version if necessary to provide the missing class(es)
110 #if defined(__WXUNIVERSAL__) || \
111 defined(__WXMOTIF__) || \
113 // nothing, use generic controls
114 #elif defined(__WXMSW__)
115 #define wxHAS_NATIVE_SPINCTRL
116 #include "wx/msw/spinctrl.h"
117 #elif defined(__WXPM__)
118 #define wxHAS_NATIVE_SPINCTRL
119 #include "wx/os2/spinctrl.h"
120 #elif defined(__WXGTK20__)
121 #define wxHAS_NATIVE_SPINCTRL
122 #define wxHAS_NATIVE_SPINCTRLDOUBLE
123 #include "wx/gtk/spinctrl.h"
124 #elif defined(__WXGTK__)
125 #define wxHAS_NATIVE_SPINCTRL
126 #include "wx/gtk1/spinctrl.h"
127 #elif defined(__WXMAC__)
128 #define wxHAS_NATIVE_SPINCTRL
129 #include "wx/mac/spinctrl.h"
132 #if !defined(wxHAS_NATIVE_SPINCTRL) || !defined(wxHAS_NATIVE_SPINCTRLDOUBLE)
133 #include "wx/generic/spinctlg.h"
136 #endif // wxUSE_SPINCTRL
138 #endif // _WX_SPINCTRL_H_