]> git.saurik.com Git - wxWidgets.git/blob - interface/wx/spinctrl.h
move TestTextInputStream() function in CppUnit's TextStreamTestCase class
[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 license
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 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 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
47 @library{wxcore}
48 @category{ctrl}
49 @appearance{spinctrl.png}
50
51 @see wxSpinButton, wxSpinCtrlDouble, wxControl
52 */
53 class wxSpinCtrl : public wxControl
54 {
55 public:
56 /**
57 Default constructor.
58 */
59 wxSpinCtrl();
60
61 /**
62 Constructor, creating and showing a spin control.
63
64 @param parent
65 Parent window. Must not be @NULL.
66 @param value
67 Default value (as text).
68 @param id
69 Window identifier. The value wxID_ANY indicates a default value.
70 @param pos
71 Window position.
72 If ::wxDefaultPosition is specified then a default position is chosen.
73 @param size
74 Window size.
75 If ::wxDefaultSize is specified then a default size is chosen.
76 @param style
77 Window style. See wxSpinButton.
78 @param min
79 Minimal value.
80 @param max
81 Maximal value.
82 @param initial
83 Initial value.
84 @param name
85 Window name.
86
87 @see Create()
88 */
89 wxSpinCtrl(wxWindow* parent, wxWindowID id = wxID_ANY,
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,
95 int initial = 0, const wxString& name = "wxSpinCtrl");
96
97 /**
98 Creation function called by the spin control constructor.
99 See wxSpinCtrl() for details.
100 */
101 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
102 const wxString& value = wxEmptyString,
103 const wxPoint& pos = wxDefaultPosition,
104 const wxSize& size = wxDefaultSize,
105 long style = wxSP_ARROW_KEYS, int min = 0, int max = 100,
106 int initial = 0, const wxString& name = "wxSpinCtrl");
107
108 /**
109 Gets maximal allowable value.
110 */
111 int GetMax() const;
112
113 /**
114 Gets minimal allowable value.
115 */
116 int GetMin() const;
117
118 /**
119 Gets the value of the spin control.
120 */
121 int GetValue() const;
122
123 /**
124 Sets range of allowable values.
125 */
126 void SetRange(int minVal, int maxVal);
127
128 /**
129 Select the text in the text part of the control between positions
130 @a from (inclusive) and @a to (exclusive).
131 This is similar to wxTextCtrl::SetSelection().
132
133 @note this is currently only implemented for Windows and generic versions
134 of the control.
135 */
136 virtual void SetSelection(long from, long to);
137
138 /**
139 Sets the value of the spin control. Use the variant using int instead.
140 */
141 virtual void SetValue(const wxString& text);
142
143 /**
144 Sets the value of the spin control.
145 */
146 void SetValue(int value);
147 };
148
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
162 @library{wxcore}
163 @category{ctrl}
164 @appearance{spinctrldouble.png}
165
166 @see wxSpinButton, wxSpinCtrl, wxControl
167 */
168 class wxSpinCtrlDouble : public wxControl
169 {
170 public:
171 /**
172 Default constructor.
173 */
174 wxSpinCtrlDouble();
175
176 /**
177 Constructor, creating and showing a spin control.
178
179 @param parent
180 Parent window. Must not be @NULL.
181 @param value
182 Default value (as text).
183 @param id
184 Window identifier. The value wxID_ANY indicates a default value.
185 @param pos
186 Window position.
187 If ::wxDefaultPosition is specified then a default position is chosen.
188 @param size
189 Window size.
190 If ::wxDefaultSize is specified then a default size is chosen.
191 @param style
192 Window style. See wxSpinButton.
193 @param min
194 Minimal value.
195 @param max
196 Maximal value.
197 @param initial
198 Initial value.
199 @param inc
200 Increment value.
201 @param name
202 Window name.
203
204 @see Create()
205 */
206 wxSpinCtrlDouble(wxWindow* parent, wxWindowID id = -1,
207 const wxString& value = wxEmptyString,
208 const wxPoint& pos = wxDefaultPosition,
209 const wxSize& size = wxDefaultSize,
210 long style = wxSP_ARROW_KEYS,
211 double min = 0, double max = 100,
212 double initial = 0, double inc = 1,
213 const wxString& name = wxT("wxSpinCtrlDouble"));
214
215 /**
216 Creation function called by the spin control constructor.
217 See wxSpinCtrlDouble() for details.
218 */
219 bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
220 const wxString& value = wxEmptyString,
221 const wxPoint& pos = wxDefaultPosition,
222 const wxSize& size = wxDefaultSize,
223 long style = wxSP_ARROW_KEYS, double min = 0, double max = 100,
224 double initial = 0, double inc = 1,
225 const wxString& name = "wxSpinCtrlDouble");
226
227 /**
228 Gets the number of digits in the display.
229 */
230 unsigned int GetDigits() const;
231
232 /**
233 Gets the increment value.
234 */
235 double GetIncrement() const;
236
237 /**
238 Gets maximal allowable value.
239 */
240 double GetMax() const;
241
242 /**
243 Gets minimal allowable value.
244 */
245 double GetMin() const;
246
247 /**
248 Gets the value of the spin control.
249 */
250 double GetValue() const;
251
252 /**
253 Sets the number of digits in the display.
254 */
255 void SetDigits(unsigned int digits);
256
257 /**
258 Sets the increment value.
259 */
260 void SetIncrement(double inc);
261
262 /**
263 Sets range of allowable values.
264 */
265 void SetRange(double minVal, double maxVal);
266
267 /**
268 Sets the value of the spin control. Use the variant using double instead.
269 */
270 virtual void SetValue(const wxString& text);
271
272 /**
273 Sets the value of the spin control.
274 */
275 void SetValue(double value);
276 };