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