]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/spinctrl.h
Add wxNavigationEnabled<> helper for implementing TAB navigation.
[wxWidgets.git] / interface / wx / spinctrl.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: spinctrl.h
e54c96f1 3// Purpose: interface of wxSpinCtrl
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxSpinCtrl
7c913512 11
e725ba4f 12 wxSpinCtrl combines wxTextCtrl and wxSpinButton in one control.
7c913512 13
23324ae1 14 @beginStyleTable
8c6791e4 15 @style{wxSP_ARROW_KEYS}
242ec2f7 16 The user can use arrow keys to change the value.
8c6791e4 17 @style{wxSP_WRAP}
242ec2f7
VZ
18 The value wraps at the minimum and maximum.
19 @style{wxTE_PROCESS_ENTER}
3a194bda 20 Indicates that the control should generate @c wxEVT_COMMAND_TEXT_ENTER
242ec2f7
VZ
21 events. Using this style will prevent the user from using the Enter key
22 for dialog navigation (e.g. activating the default button in the
23 dialog) under MSW.
f1ddb476
VZ
24 @style{wxALIGN_LEFT}
25 Same as wxTE_LEFT for wxTextCtrl: the text is left aligned.
26 @style{wxALIGN_CENTRE}
27 Same as wxTE_CENTRE for wxTextCtrl: the text is centered.
28 @style{wxALIGN_RIGHT}
29 Same as wxTE_RIGHT for wxTextCtrl: the text is right aligned (this is
30 the default).
23324ae1 31 @endStyleTable
7c913512 32
e725ba4f 33
3051a44a 34 @beginEventEmissionTable{wxSpinEvent}
e725ba4f 35 @event{EVT_SPINCTRL(id, func)}
5adab482
VZ
36 Process a wxEVT_COMMAND_SPINCTRL_UPDATED event, which is generated
37 whenever the numeric value of the spin control is updated.
e725ba4f
FM
38 @endEventTable
39
40 You may also use the wxSpinButton event macros, however the corresponding events
41 will not be generated under all platforms. Finally, if the user modifies the
42 text in the edit part of the spin control directly, the EVT_TEXT is generated,
43 like for the wxTextCtrl. When the use enters text into the text area, the text
44 is not validated until the control loses focus (e.g. by using the TAB key).
45 The value is then adjusted to the range and a wxSpinEvent sent then if the value
46 is different from the last value sent.
47
23324ae1
FM
48 @library{wxcore}
49 @category{ctrl}
7e59b885 50 @appearance{spinctrl.png}
7c913512 51
42561c3c 52 @see wxSpinButton, wxSpinCtrlDouble, wxControl
23324ae1
FM
53*/
54class wxSpinCtrl : public wxControl
55{
56public:
23324ae1 57 /**
d930d177
RR
58 Default constructor.
59 */
60 wxSpinCtrl();
e725ba4f 61
d930d177 62 /**
23324ae1 63 Constructor, creating and showing a spin control.
3c4f71cc 64
7c913512 65 @param parent
4cc4bfaf 66 Parent window. Must not be @NULL.
7c913512 67 @param value
d930d177 68 Default value (as text).
7c913512 69 @param id
4cc4bfaf 70 Window identifier. The value wxID_ANY indicates a default value.
7c913512 71 @param pos
e725ba4f 72 Window position.
dc1b07fd 73 If ::wxDefaultPosition is specified then a default position is chosen.
7c913512 74 @param size
e725ba4f 75 Window size.
dc1b07fd 76 If ::wxDefaultSize is specified then a default size is chosen.
7c913512 77 @param style
4cc4bfaf 78 Window style. See wxSpinButton.
7c913512 79 @param min
4cc4bfaf 80 Minimal value.
7c913512 81 @param max
4cc4bfaf 82 Maximal value.
7c913512 83 @param initial
4cc4bfaf 84 Initial value.
7c913512 85 @param name
4cc4bfaf 86 Window name.
3c4f71cc 87
4cc4bfaf 88 @see Create()
23324ae1 89 */
11e3af6e 90 wxSpinCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
7c913512
FM
91 const wxString& value = wxEmptyString,
92 const wxPoint& pos = wxDefaultPosition,
93 const wxSize& size = wxDefaultSize,
94 long style = wxSP_ARROW_KEYS,
95 int min = 0, int max = 100,
11e3af6e 96 int initial = 0, const wxString& name = "wxSpinCtrl");
23324ae1
FM
97
98 /**
23324ae1 99 Creation function called by the spin control constructor.
23324ae1
FM
100 See wxSpinCtrl() for details.
101 */
43c48e1e 102 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
23324ae1
FM
103 const wxString& value = wxEmptyString,
104 const wxPoint& pos = wxDefaultPosition,
105 const wxSize& size = wxDefaultSize,
43c48e1e
FM
106 long style = wxSP_ARROW_KEYS, int min = 0, int max = 100,
107 int initial = 0, const wxString& name = "wxSpinCtrl");
23324ae1
FM
108
109 /**
110 Gets maximal allowable value.
111 */
328f5751 112 int GetMax() const;
23324ae1
FM
113
114 /**
115 Gets minimal allowable value.
116 */
328f5751 117 int GetMin() const;
23324ae1
FM
118
119 /**
120 Gets the value of the spin control.
121 */
328f5751 122 int GetValue() const;
23324ae1
FM
123
124 /**
125 Sets range of allowable values.
126 */
127 void SetRange(int minVal, int maxVal);
128
129 /**
7c913512 130 Select the text in the text part of the control between positions
e725ba4f
FM
131 @a from (inclusive) and @a to (exclusive).
132 This is similar to wxTextCtrl::SetSelection().
133
1f1d2182 134 @note this is currently only implemented for Windows and generic versions
e725ba4f 135 of the control.
23324ae1 136 */
0004982c 137 virtual void SetSelection(long from, long to);
23324ae1 138
23324ae1 139 /**
d930d177 140 Sets the value of the spin control. Use the variant using int instead.
23324ae1 141 */
adaaa686 142 virtual void SetValue(const wxString& text);
d930d177
RR
143
144 /**
145 Sets the value of the spin control.
146 */
7c913512 147 void SetValue(int value);
23324ae1 148};
e54c96f1 149
42427d89
VZ
150/**
151 @class wxSpinCtrlDouble
152
153 wxSpinCtrlDouble combines wxTextCtrl and wxSpinButton in one control and
154 displays a real number. (wxSpinCtrl displays an integer.)
155
156 @beginStyleTable
157 @style{wxSP_ARROW_KEYS}
158 The user can use arrow keys to change the value.
159 @style{wxSP_WRAP}
160 The value wraps at the minimum and maximum.
161 @endStyleTable
162
ba81782a
VZ
163 @beginEventEmissionTable{wxSpinDoubleEvent}
164 @event{EVT_SPINCTRLDOUBLE(id, func)}
165 Generated whenever the numeric value of the spin control is changed,
166 that is, when the up/down spin button is clicked, when ENTER is pressed,
167 or the control loses focus and the new value is different from the last.
168 See wxSpinDoubleEvent.
169 @endEventTable
170
42427d89
VZ
171 @library{wxcore}
172 @category{ctrl}
173 @appearance{spinctrldouble.png}
174
175 @see wxSpinButton, wxSpinCtrl, wxControl
176*/
177class wxSpinCtrlDouble : public wxControl
178{
179public:
180 /**
181 Default constructor.
182 */
183 wxSpinCtrlDouble();
184
185 /**
186 Constructor, creating and showing a spin control.
187
188 @param parent
189 Parent window. Must not be @NULL.
190 @param value
191 Default value (as text).
192 @param id
193 Window identifier. The value wxID_ANY indicates a default value.
194 @param pos
195 Window position.
196 If ::wxDefaultPosition is specified then a default position is chosen.
197 @param size
198 Window size.
199 If ::wxDefaultSize is specified then a default size is chosen.
200 @param style
201 Window style. See wxSpinButton.
202 @param min
203 Minimal value.
204 @param max
205 Maximal value.
206 @param initial
207 Initial value.
208 @param inc
209 Increment value.
210 @param name
211 Window name.
212
213 @see Create()
214 */
215 wxSpinCtrlDouble(wxWindow* parent, wxWindowID id = -1,
216 const wxString& value = wxEmptyString,
217 const wxPoint& pos = wxDefaultPosition,
218 const wxSize& size = wxDefaultSize,
219 long style = wxSP_ARROW_KEYS,
220 double min = 0, double max = 100,
221 double initial = 0, double inc = 1,
222 const wxString& name = wxT("wxSpinCtrlDouble"));
223
224 /**
225 Creation function called by the spin control constructor.
226 See wxSpinCtrlDouble() for details.
227 */
228 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
229 const wxString& value = wxEmptyString,
230 const wxPoint& pos = wxDefaultPosition,
231 const wxSize& size = wxDefaultSize,
232 long style = wxSP_ARROW_KEYS, double min = 0, double max = 100,
233 double initial = 0, double inc = 1,
234 const wxString& name = "wxSpinCtrlDouble");
235
236 /**
237 Gets the number of digits in the display.
238 */
239 unsigned int GetDigits() const;
240
241 /**
242 Gets the increment value.
243 */
244 double GetIncrement() const;
245
246 /**
247 Gets maximal allowable value.
248 */
249 double GetMax() const;
250
251 /**
252 Gets minimal allowable value.
253 */
254 double GetMin() const;
255
256 /**
257 Gets the value of the spin control.
258 */
259 double GetValue() const;
260
261 /**
262 Sets the number of digits in the display.
263 */
264 void SetDigits(unsigned int digits);
265
266 /**
267 Sets the increment value.
268 */
269 void SetIncrement(double inc);
270
271 /**
272 Sets range of allowable values.
273 */
274 void SetRange(double minVal, double maxVal);
275
276 /**
277 Sets the value of the spin control. Use the variant using double instead.
278 */
279 virtual void SetValue(const wxString& text);
280
281 /**
282 Sets the value of the spin control.
283 */
284 void SetValue(double value);
285};
ba81782a
VZ
286
287/**
288 @class wxSpinDoubleEvent
289
290 This event class is used for the events generated by wxSpinCtrlDouble.
291
292 @beginEventTable{wxSpinDoubleEvent}
293 @event{EVT_SPINCTRLDOUBLE(id, func)}
294 Generated whenever the numeric value of the spin control is changed,
295 that is, when the up/down spin button is clicked, when ENTER is pressed,
296 or the control loses focus and the new value is different from the last.
297 See wxSpinDoubleEvent.
298 @endEventTable
299
300 @library{wxcore}
301 @category{events}
302
303 @see wxSpinCtrlDouble
304*/
305class wxSpinDoubleEvent : public wxNotifyEvent
306{
307public:
308 /**
309 The constructor. Not normally used by the user code.
310 */
311 wxSpinDoubleEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
312 double value = 0);
313
314 /**
315 The copy constructor.
316 */
317 wxSpinDoubleEvent(const wxSpinDoubleEvent& event);
318
319 /**
320 Returns the value associated with this spin control event.
321 */
322 double GetValue() const;
323
324 /**
325 Set the value associated with the event.
326 (Not normally used by user code.)
327 */
328 void SetValue(double value);
329};