1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxSpinCtrl
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
12 wxSpinCtrl combines wxTextCtrl and wxSpinButton in one control.
15 @style{wxSP_ARROW_KEYS}
16 The user can use arrow keys to change the value.
18 The value wraps at the minimum and maximum.
19 @style{wxTE_PROCESS_ENTER}
20 Indicates that the control should generate @c wxEVT_COMMAND_TEXT_ENTER
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
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.
29 Same as wxTE_RIGHT for wxTextCtrl: the text is right aligned (this is
34 @beginEventEmissionTable{wxSpinEvent}
35 @event{EVT_SPINCTRL(id, func)}
36 Process a wxEVT_COMMAND_SPINCTRL_UPDATED event, which is generated
37 whenever the numeric value of the spin control is updated.
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.
50 @appearance{spinctrl.png}
52 @see wxSpinButton, wxSpinCtrlDouble, wxControl
54 class wxSpinCtrl
: public wxControl
63 Constructor, creating and showing a spin control.
66 Parent window. Must not be @NULL.
68 Default value (as text).
70 Window identifier. The value wxID_ANY indicates a default value.
73 If ::wxDefaultPosition is specified then a default position is chosen.
76 If ::wxDefaultSize is specified then a default size is chosen.
78 Window style. See wxSpinButton.
90 wxSpinCtrl(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
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,
96 int initial
= 0, const wxString
& name
= "wxSpinCtrl");
99 Creation function called by the spin control constructor.
100 See wxSpinCtrl() for details.
102 bool Create(wxWindow
* parent
, wxWindowID id
= wxID_ANY
,
103 const wxString
& value
= wxEmptyString
,
104 const wxPoint
& pos
= wxDefaultPosition
,
105 const wxSize
& size
= wxDefaultSize
,
106 long style
= wxSP_ARROW_KEYS
, int min
= 0, int max
= 100,
107 int initial
= 0, const wxString
& name
= "wxSpinCtrl");
110 Gets maximal allowable value.
115 Gets minimal allowable value.
120 Gets the value of the spin control.
122 int GetValue() const;
125 Sets range of allowable values.
127 void SetRange(int minVal
, int maxVal
);
130 Select the text in the text part of the control between positions
131 @a from (inclusive) and @a to (exclusive).
132 This is similar to wxTextCtrl::SetSelection().
134 @note this is currently only implemented for Windows and generic versions
137 virtual void SetSelection(long from
, long to
);
140 Sets the value of the spin control. Use the variant using int instead.
142 virtual void SetValue(const wxString
& text
);
145 Sets the value of the spin control.
147 void SetValue(int value
);
151 @class wxSpinCtrlDouble
153 wxSpinCtrlDouble combines wxTextCtrl and wxSpinButton in one control and
154 displays a real number. (wxSpinCtrl displays an integer.)
157 @style{wxSP_ARROW_KEYS}
158 The user can use arrow keys to change the value.
160 The value wraps at the minimum and maximum.
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.
173 @appearance{spinctrldouble.png}
175 @see wxSpinButton, wxSpinCtrl, wxControl
177 class wxSpinCtrlDouble
: public wxControl
186 Constructor, creating and showing a spin control.
189 Parent window. Must not be @NULL.
191 Default value (as text).
193 Window identifier. The value wxID_ANY indicates a default value.
196 If ::wxDefaultPosition is specified then a default position is chosen.
199 If ::wxDefaultSize is specified then a default size is chosen.
201 Window style. See wxSpinButton.
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"));
225 Creation function called by the spin control constructor.
226 See wxSpinCtrlDouble() for details.
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");
237 Gets the number of digits in the display.
239 unsigned int GetDigits() const;
242 Gets the increment value.
244 double GetIncrement() const;
247 Gets maximal allowable value.
249 double GetMax() const;
252 Gets minimal allowable value.
254 double GetMin() const;
257 Gets the value of the spin control.
259 double GetValue() const;
262 Sets the number of digits in the display.
264 void SetDigits(unsigned int digits
);
267 Sets the increment value.
269 void SetIncrement(double inc
);
272 Sets range of allowable values.
274 void SetRange(double minVal
, double maxVal
);
277 Sets the value of the spin control. Use the variant using double instead.
279 virtual void SetValue(const wxString
& text
);
282 Sets the value of the spin control.
284 void SetValue(double value
);
288 @class wxSpinDoubleEvent
290 This event class is used for the events generated by wxSpinCtrlDouble.
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.
303 @see wxSpinCtrlDouble
305 class wxSpinDoubleEvent
: public wxNotifyEvent
309 The constructor. Not normally used by the user code.
311 wxSpinDoubleEvent(wxEventType commandType
= wxEVT_NULL
, int winid
= 0,
315 The copy constructor.
317 wxSpinDoubleEvent(const wxSpinDoubleEvent
& event
);
320 Returns the value associated with this spin control event.
322 double GetValue() const;
325 Set the value associated with the event.
326 (Not normally used by user code.)
328 void SetValue(double value
);
331 wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED
;
332 wxEventType wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED
;