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