]>
Commit | Line | Data |
---|---|---|
89c684ef JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: valgen.cpp | |
3 | // Purpose: wxGenericValidator class | |
4 | // Author: Kevin Smith | |
5 | // Modified by: | |
6 | // Created: Jan 22 1999 | |
7448de8d | 7 | // RCS-ID: $Id$ |
89c684ef | 8 | // Copyright: (c) 1999 Kevin Smith |
7448de8d | 9 | // Licence: wxWindows licence |
89c684ef JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
14f355c2 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
89c684ef JS |
13 | #pragma implementation "valgen.h" |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
ce4169a4 | 20 | #pragma hdrstop |
89c684ef JS |
21 | #endif |
22 | ||
23 | #ifndef WX_PRECOMP | |
ce4169a4 RR |
24 | #include "wx/defs.h" |
25 | #endif | |
26 | ||
27 | #if wxUSE_VALIDATORS | |
28 | ||
29 | #ifndef WX_PRECOMP | |
30 | #include "wx/utils.h" | |
31 | #include "wx/intl.h" | |
32 | #include "wx/dynarray.h" | |
33 | #include "wx/choice.h" | |
34 | #include "wx/combobox.h" | |
35 | #include "wx/radiobox.h" | |
36 | #include "wx/radiobut.h" | |
37 | #include "wx/checkbox.h" | |
38 | #include "wx/scrolbar.h" | |
39 | #include "wx/gauge.h" | |
40 | #include "wx/stattext.h" | |
41 | #include "wx/textctrl.h" | |
42 | #include "wx/button.h" | |
43 | #include "wx/listbox.h" | |
e90196a5 | 44 | #include "wx/slider.h" |
89c684ef JS |
45 | #endif |
46 | ||
cab1a605 | 47 | |
a55e0ebc | 48 | #include "wx/spinctrl.h" |
4ded51f2 | 49 | |
cab1a605 | 50 | #if wxUSE_SPINBTN |
ce4169a4 | 51 | #include "wx/spinbutt.h" |
750b78ba | 52 | #endif |
cab1a605 | 53 | #if wxUSE_CHECKLISTBOX |
a55e0ebc | 54 | #include "wx/checklst.h" |
f6bcfd97 | 55 | #endif |
89c684ef JS |
56 | |
57 | #include "wx/valgen.h" | |
58 | ||
5cf69f76 JS |
59 | IMPLEMENT_CLASS(wxGenericValidator, wxValidator) |
60 | ||
89c684ef JS |
61 | wxGenericValidator::wxGenericValidator(bool *val) |
62 | { | |
ce4169a4 RR |
63 | Initialize(); |
64 | m_pBool = val; | |
89c684ef JS |
65 | } |
66 | ||
67 | wxGenericValidator::wxGenericValidator(int *val) | |
68 | { | |
ce4169a4 RR |
69 | Initialize(); |
70 | m_pInt = val; | |
89c684ef JS |
71 | } |
72 | ||
73 | wxGenericValidator::wxGenericValidator(wxString *val) | |
74 | { | |
ce4169a4 RR |
75 | Initialize(); |
76 | m_pString = val; | |
89c684ef JS |
77 | } |
78 | ||
79 | wxGenericValidator::wxGenericValidator(wxArrayInt *val) | |
80 | { | |
ce4169a4 RR |
81 | Initialize(); |
82 | m_pArrayInt = val; | |
89c684ef JS |
83 | } |
84 | ||
85 | wxGenericValidator::wxGenericValidator(const wxGenericValidator& val) | |
d84afea9 | 86 | : wxValidator() |
89c684ef | 87 | { |
ce4169a4 | 88 | Copy(val); |
89c684ef JS |
89 | } |
90 | ||
91 | bool wxGenericValidator::Copy(const wxGenericValidator& val) | |
92 | { | |
e90196a5 | 93 | wxValidator::Copy(val); |
89c684ef | 94 | |
e90196a5 RR |
95 | m_pBool = val.m_pBool; |
96 | m_pInt = val.m_pInt; | |
97 | m_pString = val.m_pString; | |
98 | m_pArrayInt = val.m_pArrayInt; | |
89c684ef | 99 | |
cab1a605 | 100 | return true; |
89c684ef JS |
101 | } |
102 | ||
89c684ef JS |
103 | // Called to transfer data to the window |
104 | bool wxGenericValidator::TransferToWindow(void) | |
105 | { | |
e90196a5 | 106 | if ( !m_validatorWindow ) |
cab1a605 | 107 | return false; |
89c684ef | 108 | |
e90196a5 | 109 | // bool controls |
dcf924a3 | 110 | #if wxUSE_CHECKBOX |
e90196a5 | 111 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) ) |
89c684ef | 112 | { |
e90196a5 RR |
113 | wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow; |
114 | if (m_pBool) | |
3ca6a5f0 BP |
115 | { |
116 | pControl->SetValue(*m_pBool); | |
cab1a605 | 117 | return true; |
3ca6a5f0 | 118 | } |
e90196a5 | 119 | } else |
dcf924a3 RR |
120 | #endif |
121 | #if wxUSE_RADIOBTN | |
e90196a5 | 122 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) ) |
89c684ef | 123 | { |
e90196a5 | 124 | wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow; |
3ca6a5f0 BP |
125 | if (m_pBool) |
126 | { | |
127 | pControl->SetValue(*m_pBool) ; | |
cab1a605 | 128 | return true; |
3ca6a5f0 | 129 | } |
e90196a5 | 130 | } else |
dcf924a3 | 131 | #endif |
e90196a5 RR |
132 | |
133 | // int controls | |
dcf924a3 | 134 | #if wxUSE_GAUGE |
e90196a5 | 135 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) ) |
89c684ef | 136 | { |
e90196a5 | 137 | wxGauge* pControl = (wxGauge*) m_validatorWindow; |
3ca6a5f0 BP |
138 | if (m_pInt) |
139 | { | |
140 | pControl->SetValue(*m_pInt); | |
cab1a605 | 141 | return true; |
3ca6a5f0 | 142 | } |
e90196a5 | 143 | } else |
dcf924a3 RR |
144 | #endif |
145 | #if wxUSE_RADIOBOX | |
e90196a5 | 146 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) ) |
89c684ef | 147 | { |
e90196a5 | 148 | wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow; |
3ca6a5f0 BP |
149 | if (m_pInt) |
150 | { | |
151 | pControl->SetSelection(*m_pInt) ; | |
cab1a605 | 152 | return true; |
3ca6a5f0 | 153 | } |
e90196a5 | 154 | } else |
dcf924a3 RR |
155 | #endif |
156 | #if wxUSE_SCROLLBAR | |
e90196a5 | 157 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) ) |
89c684ef | 158 | { |
e90196a5 | 159 | wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow; |
3ca6a5f0 BP |
160 | if (m_pInt) |
161 | { | |
162 | pControl->SetThumbPosition(*m_pInt) ; | |
cab1a605 | 163 | return true; |
3ca6a5f0 | 164 | } |
e90196a5 | 165 | } else |
dcf924a3 | 166 | #endif |
3a5bcc4d | 167 | #if wxUSE_SPINCTRL && !defined(__WXMOTIF__) |
a55e0ebc JS |
168 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) ) |
169 | { | |
170 | wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow; | |
171 | if (m_pInt) | |
172 | { | |
173 | pControl->SetValue(*m_pInt); | |
cab1a605 | 174 | return true; |
a55e0ebc JS |
175 | } |
176 | } else | |
177 | #endif | |
3a5bcc4d | 178 | #if wxUSE_SPINBTN |
e90196a5 | 179 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) ) |
89c684ef | 180 | { |
e90196a5 | 181 | wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow; |
3ca6a5f0 BP |
182 | if (m_pInt) |
183 | { | |
184 | pControl->SetValue(*m_pInt) ; | |
cab1a605 | 185 | return true; |
3ca6a5f0 | 186 | } |
e90196a5 | 187 | } else |
dcf924a3 | 188 | #endif |
e90196a5 RR |
189 | #if wxUSE_SLIDER |
190 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) ) | |
191 | { | |
192 | wxSlider* pControl = (wxSlider*) m_validatorWindow; | |
193 | if (m_pInt) | |
194 | { | |
3ca6a5f0 | 195 | pControl->SetValue(*m_pInt) ; |
cab1a605 | 196 | return true; |
3ca6a5f0 | 197 | } |
e90196a5 RR |
198 | } else |
199 | #endif | |
200 | ||
3ca6a5f0 | 201 | // string controls |
d7260478 | 202 | #if wxUSE_BUTTON |
e90196a5 | 203 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) ) |
89c684ef | 204 | { |
e90196a5 | 205 | wxButton* pControl = (wxButton*) m_validatorWindow; |
3ca6a5f0 BP |
206 | if (m_pString) |
207 | { | |
208 | pControl->SetLabel(*m_pString) ; | |
cab1a605 | 209 | return true; |
3ca6a5f0 | 210 | } |
e90196a5 | 211 | } else |
d7260478 | 212 | #endif |
e90196a5 RR |
213 | #if wxUSE_COMBOBOX |
214 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) ) | |
89c684ef | 215 | { |
e90196a5 | 216 | wxComboBox* pControl = (wxComboBox*) m_validatorWindow; |
f6bcfd97 BP |
217 | if (m_pInt) |
218 | { | |
219 | pControl->SetSelection(*m_pInt) ; | |
cab1a605 | 220 | return true; |
f6bcfd97 BP |
221 | } |
222 | else if (m_pString) | |
223 | { | |
cab1a605 | 224 | if (pControl->FindString(* m_pString) != wxNOT_FOUND) |
f6bcfd97 BP |
225 | { |
226 | pControl->SetStringSelection(* m_pString); | |
227 | } | |
780fb83c | 228 | if ((m_validatorWindow->GetWindowStyle() & wxCB_READONLY) == 0) |
7cc3cec9 JS |
229 | { |
230 | pControl->SetValue(* m_pString); | |
231 | } | |
cab1a605 | 232 | return true; |
f6bcfd97 | 233 | } |
e90196a5 | 234 | } else |
ce4169a4 | 235 | #endif |
a55e0ebc JS |
236 | #if wxUSE_CHOICE |
237 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) ) | |
f6bcfd97 | 238 | { |
a55e0ebc | 239 | wxChoice* pControl = (wxChoice*) m_validatorWindow; |
f6bcfd97 BP |
240 | if (m_pInt) |
241 | { | |
242 | pControl->SetSelection(*m_pInt) ; | |
cab1a605 | 243 | return true; |
f6bcfd97 BP |
244 | } |
245 | else if (m_pString) | |
246 | { | |
cab1a605 | 247 | if (pControl->FindString(* m_pString) != wxNOT_FOUND) |
f6bcfd97 BP |
248 | { |
249 | pControl->SetStringSelection(* m_pString); | |
250 | } | |
cab1a605 | 251 | return true; |
f6bcfd97 BP |
252 | } |
253 | } else | |
a55e0ebc | 254 | #endif |
001e76a9 | 255 | #if wxUSE_STATTEXT |
e90196a5 | 256 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) |
89c684ef | 257 | { |
e90196a5 | 258 | wxStaticText* pControl = (wxStaticText*) m_validatorWindow; |
f6bcfd97 BP |
259 | if (m_pString) |
260 | { | |
261 | pControl->SetLabel(*m_pString) ; | |
cab1a605 | 262 | return true; |
f6bcfd97 | 263 | } |
3ca6a5f0 | 264 | } else |
001e76a9 | 265 | #endif |
d7260478 | 266 | #if wxUSE_TEXTCTRL |
e90196a5 | 267 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) ) |
89c684ef | 268 | { |
e90196a5 | 269 | wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow; |
f6bcfd97 BP |
270 | if (m_pString) |
271 | { | |
272 | pControl->SetValue(*m_pString) ; | |
cab1a605 | 273 | return true; |
f6bcfd97 BP |
274 | } |
275 | else if (m_pInt) | |
276 | { | |
277 | wxString str; | |
66b3ec7f | 278 | str.Printf(wxT("%d"), *m_pInt); |
f6bcfd97 | 279 | pControl->SetValue(str); |
cab1a605 | 280 | return true; |
f6bcfd97 | 281 | } |
e90196a5 | 282 | } else |
d7260478 | 283 | #endif |
1e6feb95 | 284 | // array controls |
3a5bcc4d | 285 | #if wxUSE_CHECKLISTBOX |
1e6feb95 VZ |
286 | // NOTE: wxCheckListBox is a wxListBox, so wxCheckListBox MUST come first: |
287 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) ) | |
89c684ef | 288 | { |
1e6feb95 VZ |
289 | wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow; |
290 | if (m_pArrayInt) | |
291 | { | |
292 | // clear all selections | |
293 | size_t i, | |
294 | count = pControl->GetCount(); | |
295 | for ( i = 0 ; i < count; i++ ) | |
cab1a605 | 296 | pControl->Check(i, false); |
1e6feb95 VZ |
297 | |
298 | // select each item in our array | |
299 | count = m_pArrayInt->GetCount(); | |
300 | for ( i = 0 ; i < count; i++ ) | |
301 | pControl->Check(m_pArrayInt->Item(i)); | |
302 | ||
cab1a605 | 303 | return true; |
1e6feb95 | 304 | } |
3ca6a5f0 | 305 | else |
cab1a605 | 306 | return false; |
1e6feb95 | 307 | } else |
750b78ba | 308 | #endif |
dcf924a3 | 309 | #if wxUSE_LISTBOX |
e90196a5 | 310 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) ) |
89c684ef | 311 | { |
e90196a5 | 312 | wxListBox* pControl = (wxListBox*) m_validatorWindow; |
3ca6a5f0 BP |
313 | if (m_pArrayInt) |
314 | { | |
315 | // clear all selections | |
1e6feb95 VZ |
316 | size_t i, |
317 | count = pControl->GetCount(); | |
318 | for ( i = 0 ; i < count; i++ ) | |
3ca6a5f0 | 319 | pControl->Deselect(i); |
1e6feb95 | 320 | |
3ca6a5f0 | 321 | // select each item in our array |
1e6feb95 VZ |
322 | count = m_pArrayInt->GetCount(); |
323 | for ( i = 0 ; i < count; i++ ) | |
324 | pControl->SetSelection(m_pArrayInt->Item(i)); | |
325 | ||
cab1a605 | 326 | return true; |
3ca6a5f0 | 327 | } |
e90196a5 | 328 | } else |
dcf924a3 | 329 | #endif |
3ca6a5f0 | 330 | ; // to match the last 'else' above |
89c684ef JS |
331 | |
332 | // unrecognized control, or bad pointer | |
cab1a605 | 333 | return false; |
89c684ef JS |
334 | } |
335 | ||
e90196a5 | 336 | // Called to transfer data from the window |
89c684ef JS |
337 | bool wxGenericValidator::TransferFromWindow(void) |
338 | { | |
7448de8d WS |
339 | if ( !m_validatorWindow ) |
340 | return false; | |
89c684ef | 341 | |
7448de8d | 342 | // BOOL CONTROLS ************************************** |
dcf924a3 | 343 | #if wxUSE_CHECKBOX |
7448de8d | 344 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckBox)) ) |
89c684ef | 345 | { |
7448de8d WS |
346 | wxCheckBox* pControl = (wxCheckBox*) m_validatorWindow; |
347 | if (m_pBool) | |
348 | { | |
349 | *m_pBool = pControl->GetValue() ; | |
350 | return true; | |
351 | } | |
352 | } else | |
dcf924a3 RR |
353 | #endif |
354 | #if wxUSE_RADIOBTN | |
7448de8d | 355 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioButton)) ) |
89c684ef | 356 | { |
7448de8d WS |
357 | wxRadioButton* pControl = (wxRadioButton*) m_validatorWindow; |
358 | if (m_pBool) | |
359 | { | |
360 | *m_pBool = pControl->GetValue() ; | |
361 | return true; | |
362 | } | |
363 | } else | |
dcf924a3 | 364 | #endif |
7448de8d WS |
365 | |
366 | // INT CONTROLS *************************************** | |
dcf924a3 | 367 | #if wxUSE_GAUGE |
7448de8d | 368 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxGauge)) ) |
89c684ef | 369 | { |
7448de8d WS |
370 | wxGauge* pControl = (wxGauge*) m_validatorWindow; |
371 | if (m_pInt) | |
372 | { | |
373 | *m_pInt = pControl->GetValue() ; | |
374 | return true; | |
375 | } | |
376 | } else | |
dcf924a3 RR |
377 | #endif |
378 | #if wxUSE_RADIOBOX | |
7448de8d | 379 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxRadioBox)) ) |
89c684ef | 380 | { |
7448de8d WS |
381 | wxRadioBox* pControl = (wxRadioBox*) m_validatorWindow; |
382 | if (m_pInt) | |
383 | { | |
384 | *m_pInt = pControl->GetSelection() ; | |
385 | return true; | |
386 | } | |
387 | } else | |
dcf924a3 RR |
388 | #endif |
389 | #if wxUSE_SCROLLBAR | |
7448de8d | 390 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxScrollBar)) ) |
89c684ef | 391 | { |
7448de8d WS |
392 | wxScrollBar* pControl = (wxScrollBar*) m_validatorWindow; |
393 | if (m_pInt) | |
394 | { | |
395 | *m_pInt = pControl->GetThumbPosition() ; | |
396 | return true; | |
397 | } | |
398 | } else | |
dcf924a3 | 399 | #endif |
3a5bcc4d | 400 | #if wxUSE_SPINCTRL && !defined(__WXMOTIF__) |
a55e0ebc JS |
401 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinCtrl)) ) |
402 | { | |
403 | wxSpinCtrl* pControl = (wxSpinCtrl*) m_validatorWindow; | |
404 | if (m_pInt) | |
405 | { | |
406 | *m_pInt=pControl->GetValue(); | |
cab1a605 | 407 | return true; |
a55e0ebc JS |
408 | } |
409 | } else | |
410 | #endif | |
3a5bcc4d | 411 | #if wxUSE_SPINBTN |
7448de8d | 412 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxSpinButton)) ) |
89c684ef | 413 | { |
7448de8d WS |
414 | wxSpinButton* pControl = (wxSpinButton*) m_validatorWindow; |
415 | if (m_pInt) | |
416 | { | |
417 | *m_pInt = pControl->GetValue() ; | |
418 | return true; | |
419 | } | |
420 | } else | |
dcf924a3 | 421 | #endif |
e90196a5 | 422 | #if wxUSE_SLIDER |
7448de8d | 423 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxSlider)) ) |
e90196a5 | 424 | { |
7448de8d WS |
425 | wxSlider* pControl = (wxSlider*) m_validatorWindow; |
426 | if (m_pInt) | |
427 | { | |
428 | *m_pInt = pControl->GetValue() ; | |
429 | return true; | |
430 | } | |
431 | } else | |
750b78ba | 432 | #endif |
7448de8d WS |
433 | |
434 | // STRING CONTROLS ************************************ | |
d7260478 | 435 | #if wxUSE_BUTTON |
7448de8d | 436 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxButton)) ) |
89c684ef | 437 | { |
7448de8d WS |
438 | wxButton* pControl = (wxButton*) m_validatorWindow; |
439 | if (m_pString) | |
440 | { | |
441 | *m_pString = pControl->GetLabel() ; | |
442 | return true; | |
443 | } | |
444 | } else | |
d7260478 | 445 | #endif |
dcf924a3 | 446 | #if wxUSE_COMBOBOX |
7448de8d | 447 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxComboBox)) ) |
f6bcfd97 | 448 | { |
7448de8d WS |
449 | wxComboBox* pControl = (wxComboBox*) m_validatorWindow; |
450 | if (m_pInt) | |
451 | { | |
452 | *m_pInt = pControl->GetSelection() ; | |
453 | return true; | |
454 | } | |
455 | else if (m_pString) | |
456 | { | |
457 | if (m_validatorWindow->GetWindowStyle() & wxCB_READONLY) | |
458 | *m_pString = pControl->GetStringSelection(); | |
459 | else | |
460 | *m_pString = pControl->GetValue(); | |
461 | return true; | |
462 | } | |
463 | } else | |
dcf924a3 | 464 | #endif |
ce4169a4 | 465 | #if wxUSE_CHOICE |
7448de8d | 466 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxChoice)) ) |
f6bcfd97 | 467 | { |
7448de8d WS |
468 | wxChoice* pControl = (wxChoice*) m_validatorWindow; |
469 | if (m_pInt) | |
470 | { | |
471 | *m_pInt = pControl->GetSelection() ; | |
472 | return true; | |
473 | } | |
474 | else if (m_pString) | |
475 | { | |
476 | *m_pString = pControl->GetStringSelection(); | |
477 | return true; | |
478 | } | |
479 | } else | |
ce4169a4 | 480 | #endif |
001e76a9 | 481 | #if wxUSE_STATTEXT |
7448de8d | 482 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxStaticText)) ) |
89c684ef | 483 | { |
7448de8d WS |
484 | wxStaticText* pControl = (wxStaticText*) m_validatorWindow; |
485 | if (m_pString) | |
486 | { | |
487 | *m_pString = pControl->GetLabel() ; | |
488 | return true; | |
489 | } | |
490 | } else | |
001e76a9 | 491 | #endif |
d7260478 | 492 | #if wxUSE_TEXTCTRL |
7448de8d | 493 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)) ) |
f6bcfd97 | 494 | { |
7448de8d WS |
495 | wxTextCtrl* pControl = (wxTextCtrl*) m_validatorWindow; |
496 | if (m_pString) | |
497 | { | |
498 | *m_pString = pControl->GetValue() ; | |
499 | return true; | |
500 | } | |
501 | else if (m_pInt) | |
502 | { | |
503 | *m_pInt = wxAtoi(pControl->GetValue()); | |
504 | return true; | |
505 | } | |
506 | } else | |
d7260478 | 507 | #endif |
7448de8d WS |
508 | |
509 | // ARRAY CONTROLS ************************************* | |
e90196a5 | 510 | #if wxUSE_CHECKLISTBOX |
7448de8d WS |
511 | // NOTE: wxCheckListBox isa wxListBox, so wxCheckListBox MUST come first: |
512 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxCheckListBox)) ) | |
89c684ef | 513 | { |
7448de8d WS |
514 | wxCheckListBox* pControl = (wxCheckListBox*) m_validatorWindow; |
515 | if (m_pArrayInt) | |
516 | { | |
517 | // clear our array | |
518 | m_pArrayInt->Clear(); | |
519 | ||
520 | // add each selected item to our array | |
521 | size_t i, | |
522 | count = pControl->GetCount(); | |
523 | for ( i = 0; i < count; i++ ) | |
524 | { | |
525 | if (pControl->IsChecked(i)) | |
526 | m_pArrayInt->Add(i); | |
527 | } | |
528 | ||
529 | return true; | |
530 | } | |
531 | else | |
532 | return false; | |
533 | } else | |
dcf924a3 | 534 | #endif |
dcf924a3 | 535 | #if wxUSE_LISTBOX |
7448de8d | 536 | if (m_validatorWindow->IsKindOf(CLASSINFO(wxListBox)) ) |
89c684ef | 537 | { |
7448de8d WS |
538 | wxListBox* pControl = (wxListBox*) m_validatorWindow; |
539 | if (m_pArrayInt) | |
540 | { | |
541 | // clear our array | |
542 | m_pArrayInt->Clear(); | |
1e6feb95 | 543 | |
7448de8d WS |
544 | // add each selected item to our array |
545 | size_t i, | |
546 | count = pControl->GetCount(); | |
547 | for ( i = 0; i < count; i++ ) | |
548 | { | |
549 | if (pControl->Selected(i)) | |
550 | m_pArrayInt->Add(i); | |
551 | } | |
1e6feb95 | 552 | |
7448de8d WS |
553 | return true; |
554 | } | |
555 | } else | |
dcf924a3 | 556 | #endif |
89c684ef | 557 | |
7448de8d WS |
558 | // unrecognized control, or bad pointer |
559 | return false; | |
560 | ||
cab1a605 | 561 | return false; |
89c684ef JS |
562 | } |
563 | ||
564 | /* | |
565 | Called by constructors to initialize ALL data members | |
566 | */ | |
567 | void wxGenericValidator::Initialize() | |
568 | { | |
ce4169a4 RR |
569 | m_pBool = 0; |
570 | m_pInt = 0; | |
571 | m_pString = 0; | |
572 | m_pArrayInt = 0; | |
89c684ef JS |
573 | } |
574 | ||
ce4169a4 RR |
575 | #endif |
576 | // wxUSE_VALIDATORS | |
913df6f2 | 577 |