]> git.saurik.com Git - wxWidgets.git/blob - include/wx/spinctrl.h
add an assert indicating that old code overriding OnExecute() must be updated with 2.9
[wxWidgets.git] / include / wx / spinctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: spinctrl.h
3 // Purpose: wxSpinCtrlBase class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 22.07.99
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_SPINCTRL_H_
13 #define _WX_SPINCTRL_H_
14
15 #include "wx/defs.h"
16
17 #if wxUSE_SPINCTRL
18
19 #include "wx/spinbutt.h" // should make wxSpinEvent visible to the app
20
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 // ----------------------------------------------------------------------------
26
27 class WXDLLIMPEXP_CORE wxSpinCtrlBase : public wxControl
28 {
29 public:
30 wxSpinCtrlBase() {}
31
32 // accessor functions that derived classes are expected to have
33 // T GetValue() const
34 // T GetMin() const
35 // T GetMax() const
36 // T GetIncrement() const
37 virtual bool GetSnapToTicks() const = 0;
38 // unsigned GetDigits() const - wxSpinCtrlDouble only
39
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
47
48 // Select text in the textctrl
49 virtual void SetSelection(long from, long to) = 0;
50
51 private:
52 DECLARE_NO_COPY_CLASS(wxSpinCtrlBase)
53 };
54
55 // ----------------------------------------------------------------------------
56 // wxSpinDoubleEvent - a wxSpinEvent for double valued controls
57 // ----------------------------------------------------------------------------
58
59 class WXDLLIMPEXP_CORE wxSpinDoubleEvent : public wxNotifyEvent
60 {
61 public:
62 wxSpinDoubleEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
63 double value = 0)
64 : wxNotifyEvent(commandType, winid), m_value(value)
65 {
66 }
67
68 wxSpinDoubleEvent(const wxSpinDoubleEvent& event)
69 : wxNotifyEvent(event), m_value(event.GetValue())
70 {
71 }
72
73 double GetValue() const { return m_value; }
74 void SetValue(double value) { m_value = value; }
75
76 virtual wxEvent *Clone() const { return new wxSpinDoubleEvent(*this); }
77
78 protected:
79 double m_value;
80
81 private:
82 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinDoubleEvent)
83 };
84
85 // ----------------------------------------------------------------------------
86 // wxSpinDoubleEvent event type, see also wxSpinEvent in wx/spinbutt.h
87 // ----------------------------------------------------------------------------
88
89 typedef void (wxEvtHandler::*wxSpinDoubleEventFunction)(wxSpinDoubleEvent&);
90
91 #define wxSpinDoubleEventHandler(func) \
92 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSpinDoubleEventFunction, &func)
93
94 // macros for handling spinctrl events
95
96 #define EVT_SPINCTRL(id, fn) \
97 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRL_UPDATED, id, wxSpinEventHandler(fn))
98
99 #define EVT_SPINCTRLDOUBLE(id, fn) \
100 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, id, wxSpinDoubleEventHandler(fn))
101
102 // ----------------------------------------------------------------------------
103 // include the platform-dependent class implementation
104 // ----------------------------------------------------------------------------
105
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)
109
110 #if defined(__WXUNIVERSAL__) || \
111 defined(__WXMOTIF__) || \
112 defined(__WXCOCOA__)
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"
130 #endif // platform
131
132 #if !defined(wxHAS_NATIVE_SPINCTRL) || !defined(wxHAS_NATIVE_SPINCTRLDOUBLE)
133 #include "wx/generic/spinctlg.h"
134 #endif
135
136 #endif // wxUSE_SPINCTRL
137
138 #endif // _WX_SPINCTRL_H_