]> git.saurik.com Git - wxWidgets.git/blob - utils/dialoged/src/propform.cpp
correct a bug in the MSW code using wxMask
[wxWidgets.git] / utils / dialoged / src / propform.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: propform.cpp
3 // Purpose: Property form classes
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 04/01/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "propform.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/wx.h"
25 #endif
26
27 #include <ctype.h>
28 #include <stdlib.h>
29 #include <math.h>
30 #include <string.h>
31
32 #if wxUSE_IOSTREAMH
33 #if defined(__WXMSW__) && !defined(__GNUWIN32__)
34 #include <strstrea.h>
35 #else
36 #include <strstream.h>
37 #endif
38 #else
39 #include <strstream>
40 #endif
41
42 #include "wx/window.h"
43 #include "wx/utils.h"
44 #include "wx/list.h"
45 #include "propform.h"
46
47 /*
48 * Property view
49 */
50
51 IMPLEMENT_DYNAMIC_CLASS(wxPropertyFormView, wxPropertyView)
52
53 BEGIN_EVENT_TABLE(wxPropertyFormView, wxPropertyView)
54 EVT_BUTTON(wxID_OK, wxPropertyFormView::OnOk)
55 EVT_BUTTON(wxID_CANCEL, wxPropertyFormView::OnCancel)
56 EVT_BUTTON(wxID_HELP, wxPropertyFormView::OnHelp)
57 EVT_BUTTON(wxID_PROP_REVERT, wxPropertyFormView::OnRevert)
58 EVT_BUTTON(wxID_PROP_UPDATE, wxPropertyFormView::OnUpdate)
59 END_EVENT_TABLE()
60
61 bool wxPropertyFormView::sm_dialogCancelled = FALSE;
62
63 wxPropertyFormView::wxPropertyFormView(wxWindow *propPanel, long flags):wxPropertyView(flags)
64 {
65 m_propertyWindow = propPanel;
66 m_managedWindow = NULL;
67
68 m_windowCloseButton = NULL;
69 m_windowCancelButton = NULL;
70 m_windowHelpButton = NULL;
71
72 m_detailedEditing = FALSE;
73 }
74
75 wxPropertyFormView::~wxPropertyFormView(void)
76 {
77 }
78
79 void wxPropertyFormView::ShowView(wxPropertySheet *ps, wxWindow *panel)
80 {
81 m_propertySheet = ps;
82
83 AssociatePanel(panel);
84 // CreateControls();
85 // UpdatePropertyList();
86 }
87
88 // Update this view of the viewed object, called e.g. by
89 // the object itself.
90 bool wxPropertyFormView::OnUpdateView(void)
91 {
92 return TRUE;
93 }
94
95 bool wxPropertyFormView::Check(void)
96 {
97 if (!m_propertySheet)
98 return FALSE;
99
100 wxNode *node = m_propertySheet->GetProperties().First();
101 while (node)
102 {
103 wxProperty *prop = (wxProperty *)node->Data();
104 wxPropertyValidator *validator = FindPropertyValidator(prop);
105 if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
106 {
107 wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
108 if (!formValidator->OnCheckValue(prop, this, m_propertyWindow))
109 return FALSE;
110 }
111 node = node->Next();
112 }
113 return TRUE;
114 }
115
116 bool wxPropertyFormView::TransferToPropertySheet(void)
117 {
118 if (!m_propertySheet)
119 return FALSE;
120
121 wxNode *node = m_propertySheet->GetProperties().First();
122 while (node)
123 {
124 wxProperty *prop = (wxProperty *)node->Data();
125 wxPropertyValidator *validator = FindPropertyValidator(prop);
126 if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
127 {
128 wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
129 formValidator->OnRetrieveValue(prop, this, m_propertyWindow);
130 }
131 node = node->Next();
132 }
133 return TRUE;
134 }
135
136 bool wxPropertyFormView::TransferToDialog(void)
137 {
138 if (!m_propertySheet)
139 return FALSE;
140
141 wxNode *node = m_propertySheet->GetProperties().First();
142 while (node)
143 {
144 wxProperty *prop = (wxProperty *)node->Data();
145 wxPropertyValidator *validator = FindPropertyValidator(prop);
146 if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
147 {
148 wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
149 formValidator->OnDisplayValue(prop, this, m_propertyWindow);
150 }
151 node = node->Next();
152 }
153 return TRUE;
154 }
155
156 bool wxPropertyFormView::AssociateNames(void)
157 {
158 if (!m_propertySheet || !m_propertyWindow)
159 return FALSE;
160
161 wxNode *node = m_propertyWindow->GetChildren()->First();
162 while (node)
163 {
164 wxWindow *win = (wxWindow *)node->Data();
165 if (win->GetName() != "")
166 {
167 wxProperty *prop = m_propertySheet->GetProperty(win->GetName());
168 if (prop)
169 prop->SetWindow(win);
170 }
171 node = node->Next();
172 }
173 return TRUE;
174 }
175
176
177 bool wxPropertyFormView::OnClose(void)
178 {
179 delete this;
180 return TRUE;
181 }
182
183 void wxPropertyFormView::OnOk(wxCommandEvent& WXUNUSED(event))
184 {
185 // Retrieve the value if any
186 if (!Check())
187 return;
188
189 sm_dialogCancelled = FALSE;
190
191 m_managedWindow->Close(TRUE);
192 }
193
194 void wxPropertyFormView::OnCancel(wxCommandEvent& WXUNUSED(event))
195 {
196 sm_dialogCancelled = TRUE;
197
198 m_managedWindow->Close(TRUE);
199 }
200
201 void wxPropertyFormView::OnHelp(wxCommandEvent& WXUNUSED(event))
202 {
203 }
204
205 void wxPropertyFormView::OnUpdate(wxCommandEvent& WXUNUSED(event))
206 {
207 TransferToPropertySheet();
208 }
209
210 void wxPropertyFormView::OnRevert(wxCommandEvent& WXUNUSED(event))
211 {
212 TransferToDialog();
213 }
214
215 void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event)
216 {
217 if (!m_propertySheet)
218 return;
219
220 if (win.GetName() == "")
221 return;
222
223 if (strcmp(win.GetName(), "ok") == 0)
224 OnOk(event);
225 else if (strcmp(win.GetName(), "cancel") == 0)
226 OnCancel(event);
227 else if (strcmp(win.GetName(), "help") == 0)
228 OnHelp(event);
229 else if (strcmp(win.GetName(), "update") == 0)
230 OnUpdate(event);
231 else if (strcmp(win.GetName(), "revert") == 0)
232 OnRevert(event);
233 else
234 {
235 // Find a validator to route the command to.
236 wxNode *node = m_propertySheet->GetProperties().First();
237 while (node)
238 {
239 wxProperty *prop = (wxProperty *)node->Data();
240 if (prop->GetWindow() && (prop->GetWindow() == &win))
241 {
242 wxPropertyValidator *validator = FindPropertyValidator(prop);
243 if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
244 {
245 wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
246 formValidator->OnCommand(prop, this, m_propertyWindow, event);
247 return;
248 }
249 }
250 node = node->Next();
251 }
252 }
253 }
254
255 void wxPropertyFormView::OnDoubleClick(wxControl *item)
256 {
257 if (!m_propertySheet)
258 return;
259
260 // Find a validator to route the command to.
261 wxNode *node = m_propertySheet->GetProperties().First();
262 while (node)
263 {
264 wxProperty *prop = (wxProperty *)node->Data();
265 if (prop->GetWindow() && ((wxControl *)prop->GetWindow() == item))
266 {
267 wxPropertyValidator *validator = FindPropertyValidator(prop);
268 if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
269 {
270 wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
271 formValidator->OnDoubleClick(prop, this, m_propertyWindow);
272 return;
273 }
274 }
275 node = node->Next();
276 }
277 }
278
279 /*
280 * Property form dialog box
281 */
282
283 IMPLEMENT_CLASS(wxPropertyFormDialog, wxDialog)
284
285 wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title,
286 const wxPoint& pos, const wxSize& size, long style, const wxString& name):
287 wxDialog(parent, -1, title, pos, size, style, name)
288 {
289 m_view = v;
290 m_view->AssociatePanel(this);
291 m_view->SetManagedWindow(this);
292 // SetAutoLayout(TRUE);
293 }
294
295 bool wxPropertyFormDialog::OnClose(void)
296 {
297 if (m_view)
298 {
299 m_view->OnClose();
300 m_view = NULL;
301 return TRUE;
302 }
303 else
304 return FALSE;
305 }
306
307 void wxPropertyFormDialog::OnDefaultAction(wxControl *item)
308 {
309 m_view->OnDoubleClick(item);
310 }
311
312 void wxPropertyFormDialog::OnCommand(wxWindow& win, wxCommandEvent& event)
313 {
314 if ( m_view )
315 m_view->OnCommand(win, event);
316 }
317
318 // Extend event processing to search the view's event table
319 bool wxPropertyFormDialog::ProcessEvent(wxEvent& event)
320 {
321 if ( !m_view || ! m_view->ProcessEvent(event) )
322 return wxEvtHandler::ProcessEvent(event);
323 else
324 return TRUE;
325 }
326
327
328 /*
329 * Property form panel
330 */
331
332 IMPLEMENT_CLASS(wxPropertyFormPanel, wxPanel)
333
334 void wxPropertyFormPanel::OnDefaultAction(wxControl *item)
335 {
336 m_view->OnDoubleClick(item);
337 }
338
339 void wxPropertyFormPanel::OnCommand(wxWindow& win, wxCommandEvent& event)
340 {
341 m_view->OnCommand(win, event);
342 }
343
344 // Extend event processing to search the view's event table
345 bool wxPropertyFormPanel::ProcessEvent(wxEvent& event)
346 {
347 if ( !m_view || ! m_view->ProcessEvent(event) )
348 return wxEvtHandler::ProcessEvent(event);
349 else
350 return TRUE;
351 }
352
353 /*
354 * Property frame
355 */
356
357 IMPLEMENT_CLASS(wxPropertyFormFrame, wxFrame)
358
359 bool wxPropertyFormFrame::OnClose(void)
360 {
361 if (m_view)
362 return m_view->OnClose();
363 else
364 return FALSE;
365 }
366
367 wxPanel *wxPropertyFormFrame::OnCreatePanel(wxFrame *parent, wxPropertyFormView *v)
368 {
369 return new wxPropertyFormPanel(v, parent);
370 }
371
372 bool wxPropertyFormFrame::Initialize(void)
373 {
374 m_propertyPanel = OnCreatePanel(this, m_view);
375 if (m_propertyPanel)
376 {
377 m_view->AssociatePanel(m_propertyPanel);
378 m_view->SetManagedWindow(this);
379 return TRUE;
380 }
381 else
382 return FALSE;
383 }
384
385 /*
386 * Property form specific validator
387 */
388
389 IMPLEMENT_ABSTRACT_CLASS(wxPropertyFormValidator, wxPropertyValidator)
390
391
392 /*
393 * Default validators
394 */
395
396 IMPLEMENT_DYNAMIC_CLASS(wxRealFormValidator, wxPropertyFormValidator)
397
398 ///
399 /// Real number form validator
400 ///
401 bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
402 wxWindow *parentWindow)
403 {
404 if (m_realMin == 0.0 && m_realMax == 0.0)
405 return TRUE;
406
407 // The item used for viewing the real number: should be a text item.
408 wxWindow *m_propertyWindow = property->GetWindow();
409 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
410 return FALSE;
411
412 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
413
414 float val = 0.0;
415 if (!StringToFloat(WXSTRINGCAST value, &val))
416 {
417 char buf[200];
418 sprintf(buf, "Value %s is not a valid real number!", (const char *)value);
419 wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
420 return FALSE;
421 }
422
423 if (val < m_realMin || val > m_realMax)
424 {
425 char buf[200];
426 sprintf(buf, "Value must be a real number between %.2f and %.2f!", m_realMin, m_realMax);
427 wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
428 return FALSE;
429 }
430 return TRUE;
431 }
432
433 bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
434 wxWindow *WXUNUSED(parentWindow) )
435 {
436 // The item used for viewing the real number: should be a text item.
437 wxWindow *m_propertyWindow = property->GetWindow();
438 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
439 return FALSE;
440
441 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
442
443 if (value.Length() == 0)
444 return FALSE;
445
446 float f = (float)atof((const char *)value);
447 property->GetValue() = f;
448 return TRUE;
449 }
450
451 bool wxRealFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
452 wxWindow *WXUNUSED(parentWindow) )
453 {
454 // The item used for viewing the real number: should be a text item.
455 wxWindow *m_propertyWindow = property->GetWindow();
456 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
457 return FALSE;
458
459 wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow;
460 textItem->SetValue(FloatToString(property->GetValue().RealValue()));
461 return TRUE;
462 }
463
464 ///
465 /// Integer validator
466 ///
467 IMPLEMENT_DYNAMIC_CLASS(wxIntegerFormValidator, wxPropertyFormValidator)
468
469 bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
470 wxWindow *parentWindow)
471 {
472 if (m_integerMin == 0.0 && m_integerMax == 0.0)
473 return TRUE;
474
475 // The item used for viewing the real number: should be a text item or a slider
476 wxWindow *m_propertyWindow = property->GetWindow();
477 if (!m_propertyWindow)
478 return FALSE;
479
480 long val = 0;
481
482 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
483 {
484 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
485
486 if (!StringToLong(WXSTRINGCAST value, &val))
487 {
488 char buf[200];
489 sprintf(buf, "Value %s is not a valid integer!", (const char *)value);
490 wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
491 return FALSE;
492 }
493 }
494 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))
495 {
496 val = (long)((wxSlider *)m_propertyWindow)->GetValue();
497 }
498 else
499 return FALSE;
500
501 if (val < m_integerMin || val > m_integerMax)
502 {
503 char buf[200];
504 sprintf(buf, "Value must be an integer between %ld and %ld!", m_integerMin, m_integerMax);
505 wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
506 return FALSE;
507 }
508 return TRUE;
509 }
510
511 bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
512 wxWindow *WXUNUSED(parentWindow))
513 {
514 // The item used for viewing the real number: should be a text item or a slider
515 wxWindow *m_propertyWindow = property->GetWindow();
516 if (!m_propertyWindow)
517 return FALSE;
518
519 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
520 {
521 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
522
523 if (value.Length() == 0)
524 return FALSE;
525
526 long i = atol((const char *)value);
527 property->GetValue() = i;
528 }
529 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))
530 {
531 property->GetValue() = (long)((wxSlider *)m_propertyWindow)->GetValue();
532 }
533 else
534 return FALSE;
535
536 return TRUE;
537 }
538
539 bool wxIntegerFormValidator::OnDisplayValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
540 wxWindow *WXUNUSED(parentWindow))
541 {
542 // The item used for viewing the real number: should be a text item or a slider
543 wxWindow *m_propertyWindow = property->GetWindow();
544 if (!m_propertyWindow)
545 return FALSE;
546
547 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
548 {
549 wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow;
550 textItem->SetValue(LongToString(property->GetValue().IntegerValue()));
551 }
552 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))
553 {
554 ((wxSlider *)m_propertyWindow)->SetValue((int)property->GetValue().IntegerValue());
555 }
556 else
557 return FALSE;
558 return TRUE;
559 }
560
561 ///
562 /// Boolean validator
563 ///
564 IMPLEMENT_DYNAMIC_CLASS(wxBoolFormValidator, wxPropertyFormValidator)
565
566 bool wxBoolFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
567 wxWindow *WXUNUSED(parentWindow))
568 {
569 // The item used for viewing the boolean: should be a checkbox
570 wxWindow *m_propertyWindow = property->GetWindow();
571 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
572 return FALSE;
573
574 return TRUE;
575 }
576
577 bool wxBoolFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
578 wxWindow *WXUNUSED(parentWindow) )
579 {
580 // The item used for viewing the boolean: should be a checkbox.
581 wxWindow *m_propertyWindow = property->GetWindow();
582 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
583 return FALSE;
584
585 wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow;
586
587 property->GetValue() = (bool)checkBox->GetValue();
588 return TRUE;
589 }
590
591 bool wxBoolFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
592 wxWindow *WXUNUSED(parentWindow))
593 {
594 // The item used for viewing the boolean: should be a checkbox.
595 wxWindow *m_propertyWindow = property->GetWindow();
596 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
597 return FALSE;
598
599 wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow;
600 checkBox->SetValue((bool)property->GetValue().BoolValue());
601 return TRUE;
602 }
603
604 ///
605 /// String validator
606 ///
607 IMPLEMENT_DYNAMIC_CLASS(wxStringFormValidator, wxPropertyFormValidator)
608
609 wxStringFormValidator::wxStringFormValidator(wxStringList *list, long flags):
610 wxPropertyFormValidator(flags)
611 {
612 m_strings = list;
613 }
614
615 bool wxStringFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
616 wxWindow *parentWindow )
617 {
618 if (!m_strings)
619 return TRUE;
620
621 // The item used for viewing the string: should be a text item, choice item or listbox.
622 wxWindow *m_propertyWindow = property->GetWindow();
623 if (!m_propertyWindow)
624 return FALSE;
625 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
626 {
627 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
628 if (!m_strings->Member(text->GetValue()))
629 {
630 wxString s("Value ");
631 s += text->GetValue();
632 s += " is not valid.";
633 wxMessageBox(s, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
634 return FALSE;
635 }
636 }
637 else
638 {
639 // Any other item constrains the string value,
640 // so we don't have to check it.
641 }
642 return TRUE;
643 }
644
645 bool wxStringFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
646 wxWindow *WXUNUSED(parentWindow) )
647 {
648 // The item used for viewing the string: should be a text item, choice item or listbox.
649 wxWindow *m_propertyWindow = property->GetWindow();
650 if (!m_propertyWindow)
651 return FALSE;
652 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
653 {
654 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
655 property->GetValue() = text->GetValue();
656 }
657 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox)))
658 {
659 wxListBox *lbox = (wxListBox *)m_propertyWindow;
660 if (lbox->GetSelection() > -1)
661 property->GetValue() = lbox->GetStringSelection();
662 }
663 /*
664 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox)))
665 {
666 wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow;
667 int n = 0;
668 if ((n = rbox->GetSelection()) > -1)
669 property->GetValue() = rbox->GetString(n);
670 }
671 */
672 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice)))
673 {
674 wxChoice *choice = (wxChoice *)m_propertyWindow;
675 if (choice->GetSelection() > -1)
676 property->GetValue() = choice->GetStringSelection();
677 }
678 else
679 return FALSE;
680 return TRUE;
681 }
682
683 bool wxStringFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
684 wxWindow *WXUNUSED(parentWindow) )
685 {
686 // The item used for viewing the string: should be a text item, choice item or listbox.
687 wxWindow *m_propertyWindow = property->GetWindow();
688 if (!m_propertyWindow)
689 return FALSE;
690 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
691 {
692 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
693 text->SetValue(property->GetValue().StringValue());
694 }
695 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox)))
696 {
697 wxListBox *lbox = (wxListBox *)m_propertyWindow;
698 if (lbox->Number() == 0 && m_strings)
699 {
700 // Try to initialize the listbox from 'strings'
701 wxNode *node = m_strings->First();
702 while (node)
703 {
704 char *s = (char *)node->Data();
705 lbox->Append(s);
706 node = node->Next();
707 }
708 }
709 lbox->SetStringSelection(property->GetValue().StringValue());
710 }
711 /*
712 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox)))
713 {
714 wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow;
715 rbox->SetStringSelection(property->GetValue().StringValue());
716 }
717 */
718 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice)))
719 {
720 wxChoice *choice = (wxChoice *)m_propertyWindow;
721 #ifndef __XVIEW__
722 if (choice->Number() == 0 && m_strings)
723 {
724 // Try to initialize the choice item from 'strings'
725 // XView doesn't allow this kind of thing.
726 wxNode *node = m_strings->First();
727 while (node)
728 {
729 char *s = (char *)node->Data();
730 choice->Append(s);
731 node = node->Next();
732 }
733 }
734 #endif
735 choice->SetStringSelection(property->GetValue().StringValue());
736 }
737 else
738 return FALSE;
739 return TRUE;
740 }
741