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