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