]> git.saurik.com Git - wxWidgets.git/blob - src/generic/propform.cpp
Changed a few true -> TRUE
[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 <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__) && !defined(__WXWINE__)
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 "wx/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() != _T(""))
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 TransferToPropertySheet();
191
192 m_managedWindow->Close(TRUE);
193 }
194
195 void wxPropertyFormView::OnCancel(wxCommandEvent& WXUNUSED(event))
196 {
197 sm_dialogCancelled = TRUE;
198
199 m_managedWindow->Close(TRUE);
200 }
201
202 void wxPropertyFormView::OnHelp(wxCommandEvent& WXUNUSED(event))
203 {
204 }
205
206 void wxPropertyFormView::OnUpdate(wxCommandEvent& WXUNUSED(event))
207 {
208 if (Check())
209 TransferToPropertySheet();
210 }
211
212 void wxPropertyFormView::OnRevert(wxCommandEvent& WXUNUSED(event))
213 {
214 TransferToDialog();
215 }
216
217 void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event)
218 {
219 if (!m_propertySheet)
220 return;
221
222 if (win.GetName() == _T(""))
223 return;
224
225 if (wxStrcmp(win.GetName(), _T("ok")) == 0)
226 OnOk(event);
227 else if (wxStrcmp(win.GetName(), _T("cancel")) == 0)
228 OnCancel(event);
229 else if (wxStrcmp(win.GetName(), _T("help")) == 0)
230 OnHelp(event);
231 else if (wxStrcmp(win.GetName(), _T("update")) == 0)
232 OnUpdate(event);
233 else if (wxStrcmp(win.GetName(), _T("revert")) == 0)
234 OnRevert(event);
235 else
236 {
237 // Find a validator to route the command to.
238 wxNode *node = m_propertySheet->GetProperties().First();
239 while (node)
240 {
241 wxProperty *prop = (wxProperty *)node->Data();
242 if (prop->GetWindow() && (prop->GetWindow() == &win))
243 {
244 wxPropertyValidator *validator = FindPropertyValidator(prop);
245 if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
246 {
247 wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
248 formValidator->OnCommand(prop, this, m_propertyWindow, event);
249 return;
250 }
251 }
252 node = node->Next();
253 }
254 }
255 }
256
257 void wxPropertyFormView::OnDoubleClick(wxControl *item)
258 {
259 if (!m_propertySheet)
260 return;
261
262 // Find a validator to route the command to.
263 wxNode *node = m_propertySheet->GetProperties().First();
264 while (node)
265 {
266 wxProperty *prop = (wxProperty *)node->Data();
267 if (prop->GetWindow() && ((wxControl *)prop->GetWindow() == item))
268 {
269 wxPropertyValidator *validator = FindPropertyValidator(prop);
270 if (validator && validator->IsKindOf(CLASSINFO(wxPropertyFormValidator)))
271 {
272 wxPropertyFormValidator *formValidator = (wxPropertyFormValidator *)validator;
273 formValidator->OnDoubleClick(prop, this, m_propertyWindow);
274 return;
275 }
276 }
277 node = node->Next();
278 }
279 }
280
281 /*
282 * Property form dialog box
283 */
284
285 IMPLEMENT_CLASS(wxPropertyFormDialog, wxDialog)
286
287 BEGIN_EVENT_TABLE(wxPropertyFormDialog, wxDialog)
288 EVT_CLOSE(wxPropertyFormDialog::OnCloseWindow)
289 END_EVENT_TABLE()
290
291 wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title,
292 const wxPoint& pos, const wxSize& size, long style, const wxString& name):
293 wxDialog(parent, -1, title, pos, size, style, name)
294 {
295 m_view = v;
296 m_view->AssociatePanel(this);
297 m_view->SetManagedWindow(this);
298 // SetAutoLayout(TRUE);
299 }
300
301 void wxPropertyFormDialog::OnCloseWindow(wxCloseEvent& event)
302 {
303 if (m_view)
304 {
305 m_view->OnClose();
306 m_view = NULL;
307 this->Destroy();
308 }
309 else
310 event.Veto();
311 }
312
313 void wxPropertyFormDialog::OnDefaultAction(wxControl *item)
314 {
315 m_view->OnDoubleClick(item);
316 }
317
318 void wxPropertyFormDialog::OnCommand(wxWindow& win, wxCommandEvent& event)
319 {
320 if ( m_view )
321 m_view->OnCommand(win, event);
322 }
323
324 // Extend event processing to search the view's event table
325 bool wxPropertyFormDialog::ProcessEvent(wxEvent& event)
326 {
327 if ( !m_view || ! m_view->ProcessEvent(event) )
328 return wxEvtHandler::ProcessEvent(event);
329 else
330 return TRUE;
331 }
332
333
334 /*
335 * Property form panel
336 */
337
338 IMPLEMENT_CLASS(wxPropertyFormPanel, wxPanel)
339
340 void wxPropertyFormPanel::OnDefaultAction(wxControl *item)
341 {
342 m_view->OnDoubleClick(item);
343 }
344
345 void wxPropertyFormPanel::OnCommand(wxWindow& win, wxCommandEvent& event)
346 {
347 m_view->OnCommand(win, event);
348 }
349
350 // Extend event processing to search the view's event table
351 bool wxPropertyFormPanel::ProcessEvent(wxEvent& event)
352 {
353 if ( !m_view || ! m_view->ProcessEvent(event) )
354 return wxEvtHandler::ProcessEvent(event);
355 else
356 return TRUE;
357 }
358
359 /*
360 * Property frame
361 */
362
363 IMPLEMENT_CLASS(wxPropertyFormFrame, wxFrame)
364
365 BEGIN_EVENT_TABLE(wxPropertyFormFrame, wxFrame)
366 EVT_CLOSE(wxPropertyFormFrame::OnCloseWindow)
367 END_EVENT_TABLE()
368
369 void wxPropertyFormFrame::OnCloseWindow(wxCloseEvent& event)
370 {
371 if (m_view && m_view->OnClose())
372 this->Destroy();
373 else
374 event.Veto();
375 }
376
377 wxPanel *wxPropertyFormFrame::OnCreatePanel(wxFrame *parent, wxPropertyFormView *v)
378 {
379 return new wxPropertyFormPanel(v, parent);
380 }
381
382 bool wxPropertyFormFrame::Initialize(void)
383 {
384 m_propertyPanel = OnCreatePanel(this, m_view);
385 if (m_propertyPanel)
386 {
387 m_view->AssociatePanel(m_propertyPanel);
388 m_view->SetManagedWindow(this);
389 return TRUE;
390 }
391 else
392 return FALSE;
393 }
394
395 /*
396 * Property form specific validator
397 */
398
399 IMPLEMENT_ABSTRACT_CLASS(wxPropertyFormValidator, wxPropertyValidator)
400
401
402 /*
403 * Default validators
404 */
405
406 IMPLEMENT_DYNAMIC_CLASS(wxRealFormValidator, wxPropertyFormValidator)
407
408 ///
409 /// Real number form validator
410 ///
411 bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
412 wxWindow *parentWindow)
413 {
414 if (m_realMin == 0.0 && m_realMax == 0.0)
415 return TRUE;
416
417 // The item used for viewing the real number: should be a text item.
418 wxWindow *m_propertyWindow = property->GetWindow();
419 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
420 return FALSE;
421
422 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
423
424 float val = 0.0;
425 if (!StringToFloat(WXSTRINGCAST value, &val))
426 {
427 wxChar buf[200];
428 wxSprintf(buf, _T("Value %s is not a valid real number!"), (const wxChar *)value);
429 wxMessageBox(buf, _T("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
430 return FALSE;
431 }
432
433 if (val < m_realMin || val > m_realMax)
434 {
435 wxChar buf[200];
436 wxSprintf(buf, _T("Value must be a real number between %.2f and %.2f!"), m_realMin, m_realMax);
437 wxMessageBox(buf, _T("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
438 return FALSE;
439 }
440 return TRUE;
441 }
442
443 bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
444 wxWindow *WXUNUSED(parentWindow) )
445 {
446 // The item used for viewing the real number: should be a text item.
447 wxWindow *m_propertyWindow = property->GetWindow();
448 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
449 return FALSE;
450
451 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
452
453 if (value.Length() == 0)
454 return FALSE;
455
456 float f = (float)wxAtof((const wxChar *)value);
457 property->GetValue() = f;
458 return TRUE;
459 }
460
461 bool wxRealFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
462 wxWindow *WXUNUSED(parentWindow) )
463 {
464 // The item used for viewing the real number: should be a text item.
465 wxWindow *m_propertyWindow = property->GetWindow();
466 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
467 return FALSE;
468
469 wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow;
470 textItem->SetValue(FloatToString(property->GetValue().RealValue()));
471 return TRUE;
472 }
473
474 ///
475 /// Integer validator
476 ///
477 IMPLEMENT_DYNAMIC_CLASS(wxIntegerFormValidator, wxPropertyFormValidator)
478
479 bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
480 wxWindow *parentWindow)
481 {
482 if (m_integerMin == 0.0 && m_integerMax == 0.0)
483 return TRUE;
484
485 // The item used for viewing the real number: should be a text item or a slider
486 wxWindow *m_propertyWindow = property->GetWindow();
487 if (!m_propertyWindow)
488 return FALSE;
489
490 long val = 0;
491
492 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
493 {
494 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
495
496 if (!StringToLong(WXSTRINGCAST value, &val))
497 {
498 wxChar buf[200];
499 wxSprintf(buf, _T("Value %s is not a valid integer!"), (const wxChar *)value);
500 wxMessageBox(buf, _T("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow);
501 return FALSE;
502 }
503 }
504 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))
505 {
506 val = (long)((wxSlider *)m_propertyWindow)->GetValue();
507 }
508 else
509 return FALSE;
510
511 if (val < m_integerMin || val > m_integerMax)
512 {
513 char buf[200];
514 sprintf(buf, "Value must be an integer between %ld and %ld!", m_integerMin, m_integerMax);
515 wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
516 return FALSE;
517 }
518 return TRUE;
519 }
520
521 bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
522 wxWindow *WXUNUSED(parentWindow))
523 {
524 // The item used for viewing the real number: should be a text item or a slider
525 wxWindow *m_propertyWindow = property->GetWindow();
526 if (!m_propertyWindow)
527 return FALSE;
528
529 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
530 {
531 wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue());
532
533 if (value.Length() == 0)
534 return FALSE;
535
536 long i = wxAtol((const wxChar *)value);
537 property->GetValue() = i;
538 }
539 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))
540 {
541 property->GetValue() = (long)((wxSlider *)m_propertyWindow)->GetValue();
542 }
543 else
544 return FALSE;
545
546 return TRUE;
547 }
548
549 bool wxIntegerFormValidator::OnDisplayValue( wxProperty *property, wxPropertyFormView *WXUNUSED(view),
550 wxWindow *WXUNUSED(parentWindow))
551 {
552 // The item used for viewing the real number: should be a text item or a slider
553 wxWindow *m_propertyWindow = property->GetWindow();
554 if (!m_propertyWindow)
555 return FALSE;
556
557 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
558 {
559 wxTextCtrl *textItem = (wxTextCtrl *)m_propertyWindow;
560 textItem->SetValue(LongToString(property->GetValue().IntegerValue()));
561 }
562 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))
563 {
564 ((wxSlider *)m_propertyWindow)->SetValue((int)property->GetValue().IntegerValue());
565 }
566 else
567 return FALSE;
568 return TRUE;
569 }
570
571 ///
572 /// Boolean validator
573 ///
574 IMPLEMENT_DYNAMIC_CLASS(wxBoolFormValidator, wxPropertyFormValidator)
575
576 bool wxBoolFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
577 wxWindow *WXUNUSED(parentWindow))
578 {
579 // The item used for viewing the boolean: should be a checkbox
580 wxWindow *m_propertyWindow = property->GetWindow();
581 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
582 return FALSE;
583
584 return TRUE;
585 }
586
587 bool wxBoolFormValidator::OnRetrieveValue(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
597 property->GetValue() = (bool)checkBox->GetValue();
598 return TRUE;
599 }
600
601 bool wxBoolFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
602 wxWindow *WXUNUSED(parentWindow))
603 {
604 // The item used for viewing the boolean: should be a checkbox.
605 wxWindow *m_propertyWindow = property->GetWindow();
606 if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxCheckBox)))
607 return FALSE;
608
609 wxCheckBox *checkBox = (wxCheckBox *)m_propertyWindow;
610 checkBox->SetValue((bool)property->GetValue().BoolValue());
611 return TRUE;
612 }
613
614 ///
615 /// String validator
616 ///
617 IMPLEMENT_DYNAMIC_CLASS(wxStringFormValidator, wxPropertyFormValidator)
618
619 wxStringFormValidator::wxStringFormValidator(wxStringList *list, long flags):
620 wxPropertyFormValidator(flags)
621 {
622 m_strings = list;
623 }
624
625 bool wxStringFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
626 wxWindow *parentWindow )
627 {
628 if (!m_strings)
629 return TRUE;
630
631 // The item used for viewing the string: should be a text item, choice item or listbox.
632 wxWindow *m_propertyWindow = property->GetWindow();
633 if (!m_propertyWindow)
634 return FALSE;
635 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
636 {
637 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
638 if (!m_strings->Member(text->GetValue()))
639 {
640 wxString s("Value ");
641 s += text->GetValue();
642 s += " is not valid.";
643 wxMessageBox(s, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow);
644 return FALSE;
645 }
646 }
647 else
648 {
649 // Any other item constrains the string value,
650 // so we don't have to check it.
651 }
652 return TRUE;
653 }
654
655 bool wxStringFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
656 wxWindow *WXUNUSED(parentWindow) )
657 {
658 // The item used for viewing the string: should be a text item, choice item or listbox.
659 wxWindow *m_propertyWindow = property->GetWindow();
660 if (!m_propertyWindow)
661 return FALSE;
662 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
663 {
664 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
665 property->GetValue() = text->GetValue();
666 }
667 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox)))
668 {
669 wxListBox *lbox = (wxListBox *)m_propertyWindow;
670 if (lbox->GetSelection() > -1)
671 property->GetValue() = lbox->GetStringSelection();
672 }
673 /*
674 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox)))
675 {
676 wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow;
677 int n = 0;
678 if ((n = rbox->GetSelection()) > -1)
679 property->GetValue() = rbox->GetString(n);
680 }
681 */
682 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice)))
683 {
684 wxChoice *choice = (wxChoice *)m_propertyWindow;
685 if (choice->GetSelection() > -1)
686 property->GetValue() = choice->GetStringSelection();
687 }
688 else
689 return FALSE;
690 return TRUE;
691 }
692
693 bool wxStringFormValidator::OnDisplayValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view),
694 wxWindow *WXUNUSED(parentWindow) )
695 {
696 // The item used for viewing the string: should be a text item, choice item or listbox.
697 wxWindow *m_propertyWindow = property->GetWindow();
698 if (!m_propertyWindow)
699 return FALSE;
700 if (m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl)))
701 {
702 wxTextCtrl *text = (wxTextCtrl *)m_propertyWindow;
703 text->SetValue(property->GetValue().StringValue());
704 }
705 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxListBox)))
706 {
707 wxListBox *lbox = (wxListBox *)m_propertyWindow;
708 if (lbox->Number() == 0 && m_strings)
709 {
710 // Try to initialize the listbox from 'strings'
711 wxNode *node = m_strings->First();
712 while (node)
713 {
714 char *s = (char *)node->Data();
715 lbox->Append(s);
716 node = node->Next();
717 }
718 }
719 lbox->SetStringSelection(property->GetValue().StringValue());
720 }
721 /*
722 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxRadioBox)))
723 {
724 wxRadioBox *rbox = (wxRadioBox *)m_propertyWindow;
725 rbox->SetStringSelection(property->GetValue().StringValue());
726 }
727 */
728 else if (m_propertyWindow->IsKindOf(CLASSINFO(wxChoice)))
729 {
730 wxChoice *choice = (wxChoice *)m_propertyWindow;
731 #ifndef __XVIEW__
732 if (choice->Number() == 0 && m_strings)
733 {
734 // Try to initialize the choice item from 'strings'
735 // XView doesn't allow this kind of thing.
736 wxNode *node = m_strings->First();
737 while (node)
738 {
739 char *s = (char *)node->Data();
740 choice->Append(s);
741 node = node->Next();
742 }
743 }
744 #endif
745 choice->SetStringSelection(property->GetValue().StringValue());
746 }
747 else
748 return FALSE;
749 return TRUE;
750 }
751