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