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