Fix missing or broken interface items for Phoenix
[wxWidgets.git] / interface / wx / spinctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: spinctrl.h
3 // Purpose: interface of wxSpinCtrl
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxSpinCtrl
11
12 wxSpinCtrl combines wxTextCtrl and wxSpinButton in one control.
13
14 @beginStyleTable
15 @style{wxSP_ARROW_KEYS}
16 The user can use arrow keys to change the value.
17 @style{wxSP_WRAP}
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
23 dialog) under MSW.
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).
31 @endStyleTable
32
33
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.
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
48 @library{wxcore}
49 @category{ctrl}
50 @appearance{spinctrl.png}
51
52 @see wxSpinButton, wxSpinCtrlDouble, wxControl
53 */
54 class wxSpinCtrl : public wxControl
55 {
56 public:
57 /**
58 Default constructor.
59 */
60 wxSpinCtrl();
61
62 /**
63 Constructor, creating and showing a spin control.
64
65 @param parent
66 Parent window. Must not be @NULL.
67 @param value
68 Default value (as text).
69 @param id
70 Window identifier. The value wxID_ANY indicates a default value.
71 @param pos
72 Window position.
73 If ::wxDefaultPosition is specified then a default position is chosen.
74 @param size
75 Window size.
76 If ::wxDefaultSize is specified then a default size is chosen.
77 @param style
78 Window style. See wxSpinButton.
79 @param min
80 Minimal value.
81 @param max
82 Maximal value.
83 @param initial
84 Initial value.
85 @param name
86 Window name.
87
88 @see Create()
89 */
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");
97
98 /**
99 Creation function called by the spin control constructor.
100 See wxSpinCtrl() for details.
101 */
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");
108
109 /**
110 Gets maximal allowable value.
111 */
112 int GetMax() const;
113
114 /**
115 Gets minimal allowable value.
116 */
117 int GetMin() const;
118
119 /**
120 Gets the value of the spin control.
121 */
122 int GetValue() const;
123
124 /**
125 Sets range of allowable values.
126 */
127 void SetRange(int minVal, int maxVal);
128
129 /**
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().
133
134 @note this is currently only implemented for Windows and generic versions
135 of the control.
136 */
137 virtual void SetSelection(long from, long to);
138
139 /**
140 Sets the value of the spin control. Use the variant using int instead.
141 */
142 virtual void SetValue(const wxString& text);
143
144 /**
145 Sets the value of the spin control.
146 */
147 void SetValue(int value);
148 };
149
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
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
171 @library{wxcore}
172 @category{ctrl}
173 @appearance{spinctrldouble.png}
174
175 @see wxSpinButton, wxSpinCtrl, wxControl
176 */
177 class wxSpinCtrlDouble : public wxControl
178 {
179 public:
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 };
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 */
305 class wxSpinDoubleEvent : public wxNotifyEvent
306 {
307 public:
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 };
330
331 wxEventType wxEVT_COMMAND_SPINCTRL_UPDATED;
332 wxEventType wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED;