1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     Property list classes 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // ============================================================================ 
  14 // ============================================================================ 
  16 // ---------------------------------------------------------------------------- 
  18 // ---------------------------------------------------------------------------- 
  21     #pragma implementation "proplist.h" 
  24 // For compilers that support precompilation, includes "wx/wx.h". 
  25 #include "wx/wxprec.h" 
  32     #include "wx/window.h" 
  34     #include "wx/button.h" 
  35     #include "wx/bmpbuttn.h" 
  36     #include "wx/textctrl.h" 
  37     #include "wx/listbox.h" 
  38     #include "wx/settings.h" 
  39     #include "wx/msgdlg.h" 
  40     #include "wx/filedlg.h" 
  44 #include "wx/module.h" 
  47 #include "wx/colordlg.h" 
  48 #include "wx/proplist.h" 
  55 // ---------------------------------------------------------------------------- 
  57 // ---------------------------------------------------------------------------- 
  60     #include "wx/generic/cross.xpm" 
  61     #include "wx/generic/tick.xpm" 
  64 // ---------------------------------------------------------------------------- 
  65 // accessor functions for the bitmaps (may return NULL, check for it!) 
  66 // ---------------------------------------------------------------------------- 
  68 static wxBitmap 
*GetTickBitmap(); 
  69 static wxBitmap 
*GetCrossBitmap(); 
  71 // ---------------------------------------------------------------------------- 
  72 // Property text edit control 
  73 // ---------------------------------------------------------------------------- 
  75 IMPLEMENT_CLASS(wxPropertyTextEdit
, wxTextCtrl
) 
  77 wxPropertyTextEdit::wxPropertyTextEdit(wxPropertyListView 
*v
, wxWindow 
*parent
, 
  78     const wxWindowID id
, const wxString
& value
, 
  79     const wxPoint
& pos
, const wxSize
& size
, 
  80     long style
, const wxString
& name
): 
  81  wxTextCtrl(parent
, id
, value
, pos
, size
, style
, wxDefaultValidator
, name
) 
  86 void wxPropertyTextEdit::OnSetFocus() 
  90 void wxPropertyTextEdit::OnKillFocus() 
  94 // ---------------------------------------------------------------------------- 
  96 // ---------------------------------------------------------------------------- 
  98 bool wxPropertyListView::sm_dialogCancelled 
= FALSE
; 
 100 IMPLEMENT_DYNAMIC_CLASS(wxPropertyListView
, wxPropertyView
) 
 102 BEGIN_EVENT_TABLE(wxPropertyListView
, wxPropertyView
) 
 103     EVT_BUTTON(wxID_OK
,                 wxPropertyListView::OnOk
) 
 104     EVT_BUTTON(wxID_CANCEL
,             wxPropertyListView::OnCancel
) 
 105     EVT_BUTTON(wxID_HELP
,               wxPropertyListView::OnHelp
) 
 106     EVT_BUTTON(wxID_PROP_CROSS
,         wxPropertyListView::OnCross
) 
 107     EVT_BUTTON(wxID_PROP_CHECK
,         wxPropertyListView::OnCheck
) 
 108     EVT_BUTTON(wxID_PROP_EDIT
,          wxPropertyListView::OnEdit
) 
 109     EVT_TEXT_ENTER(wxID_PROP_TEXT
,      wxPropertyListView::OnText
) 
 110     EVT_LISTBOX(wxID_PROP_SELECT
,       wxPropertyListView::OnPropertySelect
) 
 111     EVT_COMMAND(wxID_PROP_SELECT
, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, 
 112                                         wxPropertyListView::OnPropertyDoubleClick
) 
 113     EVT_LISTBOX(wxID_PROP_VALUE_SELECT
, wxPropertyListView::OnValueListSelect
) 
 116 wxPropertyListView::wxPropertyListView(wxPanel 
*propPanel
, long flags
):wxPropertyView(flags
) 
 118   m_propertyScrollingList 
= NULL
; 
 122   m_confirmButton 
= NULL
; 
 123   m_cancelButton 
= NULL
; 
 124   m_propertyWindow 
= propPanel
; 
 125   m_managedWindow 
= NULL
; 
 127   m_windowCloseButton 
= NULL
; 
 128   m_windowCancelButton 
= NULL
; 
 129   m_windowHelpButton 
= NULL
; 
 131   m_detailedEditing 
= FALSE
; 
 134 wxPropertyListView::~wxPropertyListView() 
 138 void wxPropertyListView::ShowView(wxPropertySheet 
*ps
, wxPanel 
*panel
) 
 140   m_propertySheet 
= ps
; 
 142   AssociatePanel(panel
); 
 145   UpdatePropertyList(); 
 149 // Update this view of the viewed object, called e.g. by 
 150 // the object itself. 
 151 bool wxPropertyListView::OnUpdateView() 
 156 bool wxPropertyListView::UpdatePropertyList(bool clearEditArea
) 
 158   if (!m_propertyScrollingList 
|| !m_propertySheet
) 
 161   m_propertyScrollingList
->Clear(); 
 164     m_valueList
->Clear(); 
 165     m_valueText
->SetValue(""); 
 167   wxNode 
*node 
= m_propertySheet
->GetProperties().First(); 
 169   // Should sort them... later... 
 172     wxProperty 
*property 
= (wxProperty 
*)node
->Data(); 
 173     wxString 
stringValueRepr(property
->GetValue().GetStringRepresentation()); 
 174     wxString 
paddedString(MakeNameValueString(property
->GetName(), stringValueRepr
)); 
 175     m_propertyScrollingList
->Append(paddedString
.GetData(), (void *)property
); 
 181 bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty 
*property
) 
 183   if (!m_propertyScrollingList 
|| !m_propertySheet
) 
 187   int currentlySelected 
= m_propertyScrollingList
->GetSelection(); 
 190   wxString 
stringValueRepr(property
->GetValue().GetStringRepresentation()); 
 191   wxString 
paddedString(MakeNameValueString(property
->GetName(), stringValueRepr
)); 
 192   int sel 
= FindListIndexForProperty(property
); 
 196     // Don't update the listbox unnecessarily because it can cause 
 199     if (paddedString 
!= m_propertyScrollingList
->GetString(sel
)) 
 200       m_propertyScrollingList
->SetString(sel
, paddedString
.GetData()); 
 203 //  UpdatePropertyList(FALSE); 
 206   // TODO: why is this necessary? 
 208   if (currentlySelected 
> -1) 
 209     m_propertyScrollingList
->SetSelection(currentlySelected
); 
 215 // Find the wxListBox index corresponding to this property 
 216 int wxPropertyListView::FindListIndexForProperty(wxProperty 
*property
) 
 218   int n 
= m_propertyScrollingList
->Number(); 
 219   for (int i 
= 0; i 
< n
; i
++) 
 221     if (property 
== (wxProperty 
*)m_propertyScrollingList
->wxListBox::GetClientData(i
)) 
 227 wxString 
wxPropertyListView::MakeNameValueString(wxString name
, wxString value
) 
 229   wxString 
theString(name
); 
 232   int padWith 
= nameWidth 
- theString
.Length(); 
 236   if (GetFlags() & wxPROP_SHOWVALUES
) 
 238     // Want to pad with spaces 
 239     theString
.Append(' ', padWith
); 
 246 // Select and show string representation in validator the given 
 247 // property. NULL resets to show no property. 
 248 bool wxPropertyListView::ShowProperty(wxProperty 
*property
, bool select
) 
 250   if (m_currentProperty
) 
 252     EndShowingProperty(m_currentProperty
); 
 253     m_currentProperty 
= NULL
; 
 256   m_valueList
->Clear(); 
 257   m_valueText
->SetValue(""); 
 261     m_currentProperty 
= property
; 
 262     BeginShowingProperty(property
); 
 266     int sel 
= FindListIndexForProperty(property
); 
 268       m_propertyScrollingList
->SetSelection(sel
); 
 273 // Find appropriate validator and load property into value controls 
 274 bool wxPropertyListView::BeginShowingProperty(wxProperty 
*property
) 
 276   m_currentValidator 
= FindPropertyValidator(property
); 
 277   if (!m_currentValidator
) 
 280   if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 283   wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 285   listValidator
->OnPrepareControls(property
, this, m_propertyWindow
); 
 286   DisplayProperty(property
); 
 290 // Find appropriate validator and unload property from value controls 
 291 bool wxPropertyListView::EndShowingProperty(wxProperty 
*property
) 
 293   if (!m_currentValidator
) 
 296   RetrieveProperty(property
); 
 298   if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 301   wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 303   listValidator
->OnClearControls(property
, this, m_propertyWindow
); 
 304   if (m_detailedEditing
) 
 306     listValidator
->OnClearDetailControls(property
, this, m_propertyWindow
); 
 307     m_detailedEditing 
= FALSE
; 
 312 void wxPropertyListView::BeginDetailedEditing() 
 314   if (!m_currentValidator
) 
 316   if (!m_currentProperty
) 
 318   if (m_detailedEditing
) 
 320   if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 322   if (!m_currentProperty
->IsEnabled()) 
 325   wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 327   if (listValidator
->OnPrepareDetailControls(m_currentProperty
, this, m_propertyWindow
)) 
 328     m_detailedEditing 
= TRUE
; 
 331 void wxPropertyListView::EndDetailedEditing() 
 333   if (!m_currentValidator
) 
 335   if (!m_currentProperty
) 
 338   RetrieveProperty(m_currentProperty
); 
 340   if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 343   wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 345   if (m_detailedEditing
) 
 347     listValidator
->OnClearDetailControls(m_currentProperty
, this, m_propertyWindow
); 
 348     m_detailedEditing 
= FALSE
; 
 352 bool wxPropertyListView::DisplayProperty(wxProperty 
*property
) 
 354   if (!m_currentValidator
) 
 357   if (((m_currentValidator
->GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == 0) || !property
->IsEnabled()) 
 358     m_valueText
->SetEditable(FALSE
); 
 360     m_valueText
->SetEditable(TRUE
); 
 362   if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 365   wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 367   listValidator
->OnDisplayValue(property
, this, m_propertyWindow
); 
 371 bool wxPropertyListView::RetrieveProperty(wxProperty 
*property
) 
 373   if (!m_currentValidator
) 
 375   if (!property
->IsEnabled()) 
 378   if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 381   wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 383   if (listValidator
->OnCheckValue(property
, this, m_propertyWindow
)) 
 385     if (listValidator
->OnRetrieveValue(property
, this, m_propertyWindow
)) 
 387       UpdatePropertyDisplayInList(property
); 
 388       OnPropertyChanged(property
); 
 393     // Revert to old value 
 394     listValidator
->OnDisplayValue(property
, this, m_propertyWindow
); 
 400 bool wxPropertyListView::EditProperty(wxProperty 
*WXUNUSED(property
)) 
 405 // Called by the listbox callback 
 406 void wxPropertyListView::OnPropertySelect(wxCommandEvent
& WXUNUSED(event
)) 
 408   int sel 
= m_propertyScrollingList
->GetSelection(); 
 411     wxProperty 
*newSel 
= (wxProperty 
*)m_propertyScrollingList
->wxListBox::GetClientData(sel
); 
 412     if (newSel 
&& newSel 
!= m_currentProperty
) 
 414       ShowProperty(newSel
, FALSE
); 
 419 bool wxPropertyListView::CreateControls() 
 421     wxPanel 
*panel 
= (wxPanel 
*)m_propertyWindow
; 
 423     wxSize 
largeButtonSize( 70, 25 ); 
 424     wxSize 
smallButtonSize( 23, 23 ); 
 432     wxSystemSettings settings
; 
 433     wxFont guiFont 
= settings
.GetSystemFont(wxSYS_DEFAULT_GUI_FONT
); 
 436     wxFont 
*boringFont 
= wxTheFontList
->FindOrCreateFont(guiFont
.GetPointSize(), wxMODERN
, wxNORMAL
, wxNORMAL
, FALSE
, "Courier New"); 
 438     wxFont 
*boringFont 
= wxTheFontList
->FindOrCreateFont(guiFont
.GetPointSize(), wxTELETYPE
, wxNORMAL
, wxNORMAL
); 
 441     // May need to be changed in future to eliminate clashes with app. 
 442     // WHAT WAS THIS FOR? 
 443 //  panel->SetClientData((char *)this); 
 445     wxBoxSizer 
*mainsizer 
= new wxBoxSizer( wxVERTICAL 
); 
 447     // top row with optional buttons and input line 
 449     wxBoxSizer 
*topsizer 
= new wxBoxSizer( wxHORIZONTAL 
); 
 450     int buttonborder 
= 3; 
 452     if (m_buttonFlags 
& wxPROP_BUTTON_CHECK_CROSS
) 
 454         wxBitmap 
*tickBitmap 
= GetTickBitmap(); 
 455         wxBitmap 
*crossBitmap 
= GetCrossBitmap(); 
 457         if ( tickBitmap 
&& crossBitmap 
) 
 459             m_confirmButton 
= new wxBitmapButton(panel
, wxID_PROP_CHECK
, *tickBitmap
, wxPoint(-1, -1), smallButtonSize 
); 
 460             m_cancelButton 
= new wxBitmapButton(panel
, wxID_PROP_CROSS
, *crossBitmap
, wxPoint(-1, -1), smallButtonSize 
); 
 464             m_confirmButton 
= new wxButton(panel
, wxID_PROP_CHECK
, ":-)", wxPoint(-1, -1), smallButtonSize 
); 
 465             m_cancelButton 
= new wxButton(panel
, wxID_PROP_CROSS
, "X", wxPoint(-1, -1), smallButtonSize 
); 
 468         topsizer
->Add( m_confirmButton
, 0, wxLEFT
|wxTOP
|wxBOTTOM 
| wxEXPAND
, buttonborder 
); 
 469         topsizer
->Add( m_cancelButton
, 0, wxLEFT
|wxTOP
|wxBOTTOM 
| wxEXPAND
, buttonborder 
); 
 472     m_valueText 
= new wxPropertyTextEdit(this, panel
, wxID_PROP_TEXT
, "", 
 473        wxPoint(-1, -1), wxSize(-1, smallButtonSize
.y
), wxPROCESS_ENTER
); 
 474     m_valueText
->Enable(FALSE
); 
 475     topsizer
->Add( m_valueText
, 1, wxALL 
| wxEXPAND
, buttonborder 
); 
 477     if (m_buttonFlags 
& wxPROP_PULLDOWN
) 
 479         m_editButton 
= new wxButton(panel
, wxID_PROP_EDIT
, "...",  wxPoint(-1, -1), smallButtonSize
); 
 480         m_editButton
->Enable(FALSE
); 
 481         topsizer
->Add( m_editButton
, 0, wxRIGHT
|wxTOP
|wxBOTTOM 
| wxEXPAND
, buttonborder 
); 
 484     mainsizer
->Add( topsizer
, 0, wxEXPAND 
); 
 486     // middle section with two list boxes 
 488     m_middleSizer 
= new wxBoxSizer( wxVERTICAL 
); 
 490     m_valueList 
= new wxListBox(panel
, wxID_PROP_VALUE_SELECT
, wxPoint(-1, -1), wxSize(-1, 60)); 
 491     m_valueList
->Show(FALSE
); 
 493     m_propertyScrollingList 
= new wxListBox(panel
, wxID_PROP_SELECT
, wxPoint(-1, -1), wxSize(100, 100)); 
 494     m_propertyScrollingList
->SetFont(* boringFont
); 
 495     m_middleSizer
->Add( m_propertyScrollingList
, 1, wxALL
|wxEXPAND
, buttonborder 
); 
 497     mainsizer
->Add( m_middleSizer
, 1, wxEXPAND 
); 
 499     // bottom row with buttons 
 501     if ((m_buttonFlags 
& wxPROP_BUTTON_OK
) || 
 502         (m_buttonFlags 
& wxPROP_BUTTON_CLOSE
) || 
 503         (m_buttonFlags 
& wxPROP_BUTTON_CANCEL
) || 
 504         (m_buttonFlags 
& wxPROP_BUTTON_HELP
)) 
 506         wxBoxSizer 
*bottomsizer 
= new wxBoxSizer( wxHORIZONTAL 
); 
 509         if (m_buttonFlags 
& wxPROP_BUTTON_OK
) 
 511             m_windowCloseButton 
= new wxButton(panel
, wxID_OK
, _("OK"), wxPoint(-1, -1), largeButtonSize 
); 
 512             m_windowCloseButton
->SetDefault(); 
 513             m_windowCloseButton
->SetFocus(); 
 514             bottomsizer
->Add( m_windowCloseButton
, 0, wxALL
, buttonborder 
); 
 516         else if (m_buttonFlags 
& wxPROP_BUTTON_CLOSE
) 
 518             m_windowCloseButton 
= new wxButton(panel
, wxID_OK
, _("Close"), wxPoint(-1, -1), largeButtonSize 
); 
 519             bottomsizer
->Add( m_windowCloseButton
, 0, wxALL
, buttonborder 
); 
 521         if (m_buttonFlags 
& wxPROP_BUTTON_CANCEL
) 
 523             m_windowCancelButton 
= new wxButton(panel
, wxID_CANCEL
, _("Cancel"), wxPoint(-1, -1), largeButtonSize 
); 
 524             bottomsizer
->Add( m_windowCancelButton
, 0, wxALL
, buttonborder 
); 
 526         if (m_buttonFlags 
& wxPROP_BUTTON_HELP
) 
 528             m_windowHelpButton 
= new wxButton(panel
, wxID_HELP
, _("Help"), wxPoint(-1, -1), largeButtonSize 
); 
 529             bottomsizer
->Add( m_windowHelpButton
, 0, wxALL
, buttonborder 
); 
 532         mainsizer
->Add( bottomsizer
, 0, wxALIGN_RIGHT 
| wxEXPAND 
); 
 535     panel
->SetSizer( mainsizer 
); 
 540 void wxPropertyListView::ShowTextControl(bool show
) 
 543     m_valueText
->Show(show
); 
 546 void wxPropertyListView::ShowListBoxControl(bool show
) 
 548     if (!m_valueList
) return; 
 550     m_valueList
->Show(show
); 
 552     if (m_buttonFlags 
& wxPROP_DYNAMIC_VALUE_FIELD
) 
 555             m_middleSizer
->Prepend( m_valueList
, 0, wxTOP
|wxLEFT
|wxRIGHT 
| wxEXPAND
, 3 ); 
 557             m_middleSizer
->Remove( 0 ); 
 559         m_propertyWindow
->Layout(); 
 563 void wxPropertyListView::EnableCheck(bool show
) 
 566     m_confirmButton
->Enable(show
); 
 569 void wxPropertyListView::EnableCross(bool show
) 
 572     m_cancelButton
->Enable(show
); 
 575 bool wxPropertyListView::OnClose() 
 577   // Retrieve the value if any 
 578   wxCommandEvent event
; 
 585 void wxPropertyListView::OnValueListSelect(wxCommandEvent
& WXUNUSED(event
)) 
 587   if (m_currentProperty 
&& m_currentValidator
) 
 589     if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 592     wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 594     listValidator
->OnValueListSelect(m_currentProperty
, this, m_propertyWindow
); 
 598 void wxPropertyListView::OnOk(wxCommandEvent
& event
) 
 600   // Retrieve the value if any 
 603   m_managedWindow
->Close(TRUE
); 
 606 void wxPropertyListView::OnCancel(wxCommandEvent
& WXUNUSED(event
)) 
 608 //  SetReturnCode(wxID_CANCEL); 
 609   m_managedWindow
->Close(TRUE
); 
 610   sm_dialogCancelled 
= TRUE
; 
 613 void wxPropertyListView::OnHelp(wxCommandEvent
& WXUNUSED(event
)) 
 617 void wxPropertyListView::OnCheck(wxCommandEvent
& WXUNUSED(event
)) 
 619   if (m_currentProperty
) 
 621     RetrieveProperty(m_currentProperty
); 
 625 void wxPropertyListView::OnCross(wxCommandEvent
& WXUNUSED(event
)) 
 627   if (m_currentProperty 
&& m_currentValidator
) 
 629     if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 632     wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 634     // Revert to old value 
 635     listValidator
->OnDisplayValue(m_currentProperty
, this, m_propertyWindow
); 
 639 void wxPropertyListView::OnPropertyDoubleClick(wxCommandEvent
& WXUNUSED(event
)) 
 641   if (m_currentProperty 
&& m_currentValidator
) 
 643     if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 646     wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 648     // Revert to old value 
 649     listValidator
->OnDoubleClick(m_currentProperty
, this, m_propertyWindow
); 
 653 void wxPropertyListView::OnEdit(wxCommandEvent
& WXUNUSED(event
)) 
 655   if (m_currentProperty 
&& m_currentValidator
) 
 657     if (!m_currentValidator
->IsKindOf(CLASSINFO(wxPropertyListValidator
))) 
 660     wxPropertyListValidator 
*listValidator 
= (wxPropertyListValidator 
*)m_currentValidator
; 
 662     listValidator
->OnEdit(m_currentProperty
, this, m_propertyWindow
); 
 666 void wxPropertyListView::OnText(wxCommandEvent
& event
) 
 668   if (event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
) 
 674 // ---------------------------------------------------------------------------- 
 675 // Property dialog box 
 676 // ---------------------------------------------------------------------------- 
 678 IMPLEMENT_CLASS(wxPropertyListDialog
, wxDialog
) 
 680 BEGIN_EVENT_TABLE(wxPropertyListDialog
, wxDialog
) 
 681     EVT_BUTTON(wxID_CANCEL
,                wxPropertyListDialog::OnCancel
) 
 682     EVT_CLOSE(wxPropertyListDialog::OnCloseWindow
) 
 685 wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView 
*v
, wxWindow 
*parent
, 
 686     const wxString
& title
, const wxPoint
& pos
, 
 687     const wxSize
& size
, long style
, const wxString
& name
): 
 688      wxDialog(parent
, -1, title
, pos
, size
, style
, name
) 
 691   m_view
->AssociatePanel( ((wxPanel
*)this) ); 
 692   m_view
->SetManagedWindow(this); 
 696 void wxPropertyListDialog::OnCloseWindow(wxCloseEvent
& event
) 
 700     SetReturnCode(wxID_CANCEL
); 
 711 void wxPropertyListDialog::OnCancel(wxCommandEvent
& WXUNUSED(event
)) 
 713     SetReturnCode(wxID_CANCEL
); 
 717 void wxPropertyListDialog::OnDefaultAction(wxControl 
*WXUNUSED(item
)) 
 720   if (item == m_view->GetPropertyScrollingList()) 
 721     view->OnDoubleClick(); 
 725 // Extend event processing to search the view's event table 
 726 bool wxPropertyListDialog::ProcessEvent(wxEvent
& event
) 
 728     if ( !m_view 
|| ! m_view
->ProcessEvent(event
) ) 
 729         return wxEvtHandler::ProcessEvent(event
); 
 734 // ---------------------------------------------------------------------------- 
 736 // ---------------------------------------------------------------------------- 
 738 IMPLEMENT_CLASS(wxPropertyListPanel
, wxPanel
) 
 740 BEGIN_EVENT_TABLE(wxPropertyListPanel
, wxPanel
) 
 741     EVT_SIZE(wxPropertyListPanel::OnSize
) 
 744 wxPropertyListPanel::~wxPropertyListPanel() 
 748 void wxPropertyListPanel::OnDefaultAction(wxControl 
*WXUNUSED(item
)) 
 751   if (item == view->GetPropertyScrollingList()) 
 752     view->OnDoubleClick(); 
 756 // Extend event processing to search the view's event table 
 757 bool wxPropertyListPanel::ProcessEvent(wxEvent
& event
) 
 759     if ( !m_view 
|| ! m_view
->ProcessEvent(event
) ) 
 760         return wxEvtHandler::ProcessEvent(event
); 
 765 void wxPropertyListPanel::OnSize(wxSizeEvent
& WXUNUSED(event
)) 
 770 // ---------------------------------------------------------------------------- 
 772 // ---------------------------------------------------------------------------- 
 774 IMPLEMENT_CLASS(wxPropertyListFrame
, wxFrame
) 
 776 BEGIN_EVENT_TABLE(wxPropertyListFrame
, wxFrame
) 
 777     EVT_CLOSE(wxPropertyListFrame::OnCloseWindow
) 
 780 void wxPropertyListFrame::OnCloseWindow(wxCloseEvent
& event
) 
 785         m_propertyPanel
->SetView(NULL
); 
 796 wxPropertyListPanel 
*wxPropertyListFrame::OnCreatePanel(wxFrame 
*parent
, wxPropertyListView 
*v
) 
 798   return new wxPropertyListPanel(v
, parent
); 
 801 bool wxPropertyListFrame::Initialize() 
 803   m_propertyPanel 
= OnCreatePanel(this, m_view
); 
 806     m_view
->AssociatePanel(m_propertyPanel
); 
 807     m_view
->SetManagedWindow(this); 
 808     m_propertyPanel
->SetAutoLayout(TRUE
); 
 815 // ---------------------------------------------------------------------------- 
 816 // Property list specific validator 
 817 // ---------------------------------------------------------------------------- 
 819 IMPLEMENT_ABSTRACT_CLASS(wxPropertyListValidator
, wxPropertyValidator
) 
 821 bool wxPropertyListValidator::OnSelect(bool select
, wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
 823 //  view->GetValueText()->Show(TRUE); 
 825     OnDisplayValue(property
, view
, parentWindow
); 
 830 bool wxPropertyListValidator::OnValueListSelect(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 832   wxString 
s(view
->GetValueList()->GetStringSelection()); 
 835     view
->GetValueText()->SetValue(s
); 
 836     view
->RetrieveProperty(property
); 
 841 bool wxPropertyListValidator::OnDisplayValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 843 //  view->GetValueText()->Show(TRUE); 
 844   wxString 
str(property
->GetValue().GetStringRepresentation()); 
 846   view
->GetValueText()->SetValue(str
); 
 850 // Called when TICK is pressed or focus is lost or view wants to update 
 851 // the property list. 
 852 // Does the transferance from the property editing area to the property itself 
 853 bool wxPropertyListValidator::OnRetrieveValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 855   if (!view
->GetValueText()) 
 860 void wxPropertyListValidator::OnEdit(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 862   if (view
->GetDetailedEditing()) 
 863     view
->EndDetailedEditing(); 
 865     view
->BeginDetailedEditing(); 
 868 bool wxPropertyListValidator::OnClearControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 870   if (view
->GetConfirmButton()) 
 871     view
->GetConfirmButton()->Enable(FALSE
); 
 872   if (view
->GetCancelButton()) 
 873     view
->GetCancelButton()->Enable(FALSE
); 
 874   if (view
->GetEditButton()) 
 875     view
->GetEditButton()->Enable(FALSE
); 
 879 // ---------------------------------------------------------------------------- 
 880 // Default validators 
 881 // ---------------------------------------------------------------------------- 
 883 IMPLEMENT_DYNAMIC_CLASS(wxRealListValidator
, wxPropertyListValidator
) 
 886 /// Real number validator 
 888 bool wxRealListValidator::OnCheckValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
 890   if (m_realMin 
== 0.0 && m_realMax 
== 0.0) 
 893   if (!view
->GetValueText()) 
 895   wxString 
value(view
->GetValueText()->GetValue()); 
 898   if (!StringToFloat(WXSTRINGCAST value
, &val
)) 
 901     wxSprintf(buf
, wxT("Value %s is not a valid real number!"), value
.GetData()); 
 902     wxMessageBox(buf
, wxT("Property value error"), wxOK 
| wxICON_EXCLAMATION
, parentWindow
); 
 906   if (val 
< m_realMin 
|| val 
> m_realMax
) 
 909     sprintf(buf
, "Value must be a real number between %.2f and %.2f!", m_realMin
, m_realMax
); 
 910     wxMessageBox(buf
, "Property value error", wxOK 
| wxICON_EXCLAMATION
, parentWindow
); 
 916 // Called when TICK is pressed or focus is lost or view wants to update 
 917 // the property list. 
 918 // Does the transferance from the property editing area to the property itself 
 919 bool wxRealListValidator::OnRetrieveValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 921   if (!view
->GetValueText()) 
 924   if (wxStrlen(view
->GetValueText()->GetValue()) == 0) 
 927   wxString 
value(view
->GetValueText()->GetValue()); 
 928   float f 
= (float)wxAtof(value
.GetData()); 
 929   property
->GetValue() = f
; 
 933 bool wxRealListValidator::OnPrepareControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 935   if (view
->GetConfirmButton()) 
 936     view
->GetConfirmButton()->Enable(TRUE
); 
 937   if (view
->GetCancelButton()) 
 938     view
->GetCancelButton()->Enable(TRUE
); 
 939   if (view
->GetEditButton()) 
 940     view
->GetEditButton()->Enable(FALSE
); 
 941   if (view
->GetValueText()) 
 942     view
->GetValueText()->Enable(TRUE
); 
 947 /// Integer validator 
 949 IMPLEMENT_DYNAMIC_CLASS(wxIntegerListValidator
, wxPropertyListValidator
) 
 951 bool wxIntegerListValidator::OnCheckValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
 953   if (m_integerMin 
== 0 && m_integerMax 
== 0) 
 956   if (!view
->GetValueText()) 
 958   wxString 
value(view
->GetValueText()->GetValue()); 
 961   if (!StringToLong(WXSTRINGCAST value
, &val
)) 
 964     wxSprintf(buf
, wxT("Value %s is not a valid integer!"), value
.GetData()); 
 965     wxMessageBox(buf
, wxT("Property value error"), wxOK 
| wxICON_EXCLAMATION
, parentWindow
); 
 968   if (val 
< m_integerMin 
|| val 
> m_integerMax
) 
 971     wxSprintf(buf
, wxT("Value must be an integer between %ld and %ld!"), m_integerMin
, m_integerMax
); 
 972     wxMessageBox(buf
, wxT("Property value error"), wxOK 
| wxICON_EXCLAMATION
, parentWindow
); 
 978 // Called when TICK is pressed or focus is lost or view wants to update 
 979 // the property list. 
 980 // Does the transferance from the property editing area to the property itself 
 981 bool wxIntegerListValidator::OnRetrieveValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 983   if (!view
->GetValueText()) 
 986   if (wxStrlen(view
->GetValueText()->GetValue()) == 0) 
 989   wxString 
value(view
->GetValueText()->GetValue()); 
 990   long val 
= (long)wxAtoi(value
.GetData()); 
 991   property
->GetValue() = (long)val
; 
 995 bool wxIntegerListValidator::OnPrepareControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
 997   if (view
->GetConfirmButton()) 
 998     view
->GetConfirmButton()->Enable(TRUE
); 
 999   if (view
->GetCancelButton()) 
1000     view
->GetCancelButton()->Enable(TRUE
); 
1001   if (view
->GetEditButton()) 
1002     view
->GetEditButton()->Enable(FALSE
); 
1003   if (view
->GetValueText()) 
1004     view
->GetValueText()->Enable(TRUE
); 
1009 /// boolean validator 
1011 IMPLEMENT_DYNAMIC_CLASS(wxBoolListValidator
, wxPropertyListValidator
) 
1013 bool wxBoolListValidator::OnCheckValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1015   if (!view
->GetValueText()) 
1017   wxString 
value(view
->GetValueText()->GetValue()); 
1018   if (value 
!= wxT("True") && value 
!= wxT("False")) 
1020     wxMessageBox(wxT("Value must be True or False!"), wxT("Property value error"), wxOK 
| wxICON_EXCLAMATION
, parentWindow
); 
1026 // Called when TICK is pressed or focus is lost or view wants to update 
1027 // the property list. 
1028 // Does the transferance from the property editing area to the property itself 
1029 bool wxBoolListValidator::OnRetrieveValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1031   if (!view
->GetValueText()) 
1034   if (wxStrlen(view
->GetValueText()->GetValue()) == 0) 
1037   wxString 
value(view
->GetValueText()->GetValue()); 
1038   bool boolValue 
= FALSE
; 
1039   if (value 
== wxT("True")) 
1043   property
->GetValue() = (bool)boolValue
; 
1047 bool wxBoolListValidator::OnDisplayValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1049   if (!view
->GetValueText()) 
1051   wxString 
str(property
->GetValue().GetStringRepresentation()); 
1053   view
->GetValueText()->SetValue(str
); 
1055   if (view
->GetValueList()->IsShown()) 
1057     view
->GetValueList()->SetStringSelection(str
); 
1062 bool wxBoolListValidator::OnPrepareControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1064   if (view
->GetConfirmButton()) 
1065     view
->GetConfirmButton()->Enable(FALSE
); 
1066   if (view
->GetCancelButton()) 
1067     view
->GetCancelButton()->Enable(FALSE
); 
1068   if (view
->GetEditButton()) 
1069     view
->GetEditButton()->Enable(TRUE
); 
1070   if (view
->GetValueText()) 
1071     view
->GetValueText()->Enable(FALSE
); 
1075 bool wxBoolListValidator::OnPrepareDetailControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1077   if (view
->GetValueList()) 
1079     view
->ShowListBoxControl(TRUE
); 
1080     view
->GetValueList()->Enable(TRUE
); 
1082     view
->GetValueList()->Append(wxT("True")); 
1083     view
->GetValueList()->Append(wxT("False")); 
1084     wxChar 
*currentString 
= copystring(view
->GetValueText()->GetValue()); 
1085     view
->GetValueList()->SetStringSelection(currentString
); 
1086     delete[] currentString
; 
1091 bool wxBoolListValidator::OnClearDetailControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1093   if (view
->GetValueList()) 
1095     view
->GetValueList()->Clear(); 
1096     view
->ShowListBoxControl(FALSE
); 
1097     view
->GetValueList()->Enable(FALSE
); 
1102 // Called when the property is double clicked. Extra functionality can be provided, 
1103 // cycling through possible values. 
1104 bool wxBoolListValidator::OnDoubleClick(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1106   if (!view
->GetValueText()) 
1108   if (property
->GetValue().BoolValue()) 
1109     property
->GetValue() = (bool)FALSE
; 
1111     property
->GetValue() = (bool)TRUE
; 
1112   view
->DisplayProperty(property
); 
1113   view
->UpdatePropertyDisplayInList(property
); 
1114   view
->OnPropertyChanged(property
); 
1119 /// String validator 
1121 IMPLEMENT_DYNAMIC_CLASS(wxStringListValidator
, wxPropertyListValidator
) 
1123 wxStringListValidator::wxStringListValidator(wxStringList 
*list
, long flags
): 
1124   wxPropertyListValidator(flags
) 
1127   // If no constraint, we just allow the string to be edited. 
1128   if (!m_strings 
&& ((m_validatorFlags 
& wxPROP_ALLOW_TEXT_EDITING
) == 0)) 
1129     m_validatorFlags 
|= wxPROP_ALLOW_TEXT_EDITING
; 
1132 bool wxStringListValidator::OnCheckValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1137   if (!view
->GetValueText()) 
1139   wxString 
value(view
->GetValueText()->GetValue()); 
1141   if (!m_strings
->Member(value
.GetData())) 
1143     wxString 
s("Value "); 
1144     s 
+= value
.GetData(); 
1145     s 
+= " is not valid."; 
1146     wxMessageBox(s
.GetData(), "Property value error", wxOK 
| wxICON_EXCLAMATION
, parentWindow
); 
1152 // Called when TICK is pressed or focus is lost or view wants to update 
1153 // the property list. 
1154 // Does the transferance from the property editing area to the property itself 
1155 bool wxStringListValidator::OnRetrieveValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1157   if (!view
->GetValueText()) 
1159   wxString 
value(view
->GetValueText()->GetValue()); 
1160   property
->GetValue() = value 
; 
1164 // Called when TICK is pressed or focus is lost or view wants to update 
1165 // the property list. 
1166 // Does the transferance from the property editing area to the property itself 
1167 bool wxStringListValidator::OnDisplayValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1169   if (!view
->GetValueText()) 
1171   wxString 
str(property
->GetValue().GetStringRepresentation()); 
1172   view
->GetValueText()->SetValue(str
); 
1173   if (m_strings 
&& view
->GetValueList() && view
->GetValueList()->IsShown() && view
->GetValueList()->Number() > 0) 
1175     view
->GetValueList()->SetStringSelection(str
); 
1180 bool wxStringListValidator::OnPrepareControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1185     if (view
->GetEditButton()) 
1186       view
->GetEditButton()->Enable(FALSE
); 
1187     if (view
->GetConfirmButton()) 
1188       view
->GetConfirmButton()->Enable(TRUE
); 
1189     if (view
->GetCancelButton()) 
1190       view
->GetCancelButton()->Enable(TRUE
); 
1191     if (view
->GetValueText()) 
1192       view
->GetValueText()->Enable(TRUE
); 
1197   if (view
->GetValueText()) 
1198     view
->GetValueText()->Enable(FALSE
); 
1200   if (view
->GetEditButton()) 
1201     view
->GetEditButton()->Enable(TRUE
); 
1203   if (view
->GetConfirmButton()) 
1204     view
->GetConfirmButton()->Enable(FALSE
); 
1205   if (view
->GetCancelButton()) 
1206     view
->GetCancelButton()->Enable(FALSE
); 
1210 bool wxStringListValidator::OnPrepareDetailControls(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1212   if (view
->GetValueList()) 
1214     view
->ShowListBoxControl(TRUE
); 
1215     view
->GetValueList()->Enable(TRUE
); 
1216     wxNode 
*node 
= m_strings
->First(); 
1219       wxChar 
*s 
= (wxChar 
*)node
->Data(); 
1220       view
->GetValueList()->Append(s
); 
1221       node 
= node
->Next(); 
1223     wxChar 
*currentString 
= property
->GetValue().StringValue(); 
1224     view
->GetValueList()->SetStringSelection(currentString
); 
1229 bool wxStringListValidator::OnClearDetailControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1236   if (view
->GetValueList()) 
1238     view
->GetValueList()->Clear(); 
1239     view
->ShowListBoxControl(FALSE
); 
1240     view
->GetValueList()->Enable(FALSE
); 
1245 // Called when the property is double clicked. Extra functionality can be provided, 
1246 // cycling through possible values. 
1247 bool wxStringListValidator::OnDoubleClick(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1249   if (!view
->GetValueText()) 
1254   wxNode 
*node 
= m_strings
->First(); 
1255   wxChar 
*currentString 
= property
->GetValue().StringValue(); 
1258     wxChar 
*s 
= (wxChar 
*)node
->Data(); 
1259     if (wxStrcmp(s
, currentString
) == 0) 
1261       wxChar 
*nextString 
= NULL
; 
1263         nextString 
= (wxChar 
*)node
->Next()->Data(); 
1265         nextString 
= (wxChar 
*)m_strings
->First()->Data(); 
1266       property
->GetValue() = wxString(nextString
); 
1267       view
->DisplayProperty(property
); 
1268       view
->UpdatePropertyDisplayInList(property
); 
1269       view
->OnPropertyChanged(property
); 
1272     else node 
= node
->Next(); 
1278 /// Filename validator 
1280 IMPLEMENT_DYNAMIC_CLASS(wxFilenameListValidator
, wxPropertyListValidator
) 
1282 wxFilenameListValidator::wxFilenameListValidator(wxString message 
, wxString wildcard
, long flags
): 
1283   wxPropertyListValidator(flags
), m_filenameWildCard(wildcard
), m_filenameMessage(message
) 
1287 wxFilenameListValidator::~wxFilenameListValidator() 
1291 bool wxFilenameListValidator::OnCheckValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*WXUNUSED(view
), wxWindow 
*WXUNUSED(parentWindow
)) 
1296 // Called when TICK is pressed or focus is lost or view wants to update 
1297 // the property list. 
1298 // Does the transferance from the property editing area to the property itself 
1299 bool wxFilenameListValidator::OnRetrieveValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1301   if (!view
->GetValueText()) 
1303   wxString 
value(view
->GetValueText()->GetValue()); 
1304   property
->GetValue() = value 
; 
1308 // Called when TICK is pressed or focus is lost or view wants to update 
1309 // the property list. 
1310 // Does the transferance from the property editing area to the property itself 
1311 bool wxFilenameListValidator::OnDisplayValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1313   if (!view
->GetValueText()) 
1315   wxString 
str(property
->GetValue().GetStringRepresentation()); 
1316   view
->GetValueText()->SetValue(str
); 
1320 // Called when the property is double clicked. Extra functionality can be provided, 
1321 // cycling through possible values. 
1322 bool wxFilenameListValidator::OnDoubleClick(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1324   if (!view
->GetValueText()) 
1326   OnEdit(property
, view
, parentWindow
); 
1330 bool wxFilenameListValidator::OnPrepareControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1332   if (view
->GetConfirmButton()) 
1333     view
->GetConfirmButton()->Enable(TRUE
); 
1334   if (view
->GetCancelButton()) 
1335     view
->GetCancelButton()->Enable(TRUE
); 
1336   if (view
->GetEditButton()) 
1337     view
->GetEditButton()->Enable(TRUE
); 
1338   if (view
->GetValueText()) 
1339     view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
); 
1343 void wxFilenameListValidator::OnEdit(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1345   if (!view
->GetValueText()) 
1348   wxString s 
= wxFileSelector( 
1349      m_filenameMessage
.GetData(), 
1350      wxPathOnly(property
->GetValue().StringValue()), 
1351      wxFileNameFromPath(property
->GetValue().StringValue()), 
1353      m_filenameWildCard
.GetData(), 
1358     property
->GetValue() = s
; 
1359     view
->DisplayProperty(property
); 
1360     view
->UpdatePropertyDisplayInList(property
); 
1361     view
->OnPropertyChanged(property
); 
1366 /// Colour validator 
1368 IMPLEMENT_DYNAMIC_CLASS(wxColourListValidator
, wxPropertyListValidator
) 
1370 wxColourListValidator::wxColourListValidator(long flags
): 
1371   wxPropertyListValidator(flags
) 
1375 wxColourListValidator::~wxColourListValidator() 
1379 bool wxColourListValidator::OnCheckValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*WXUNUSED(view
), wxWindow 
*WXUNUSED(parentWindow
)) 
1384 // Called when TICK is pressed or focus is lost or view wants to update 
1385 // the property list. 
1386 // Does the transferance from the property editing area to the property itself 
1387 bool wxColourListValidator::OnRetrieveValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1389   if (!view
->GetValueText()) 
1391   wxString 
value(view
->GetValueText()->GetValue()); 
1393   property
->GetValue() = value 
; 
1397 // Called when TICK is pressed or focus is lost or view wants to update 
1398 // the property list. 
1399 // Does the transferance from the property editing area to the property itself 
1400 bool wxColourListValidator::OnDisplayValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1402   if (!view
->GetValueText()) 
1404   wxString 
str(property
->GetValue().GetStringRepresentation()); 
1405   view
->GetValueText()->SetValue(str
); 
1409 // Called when the property is double clicked. Extra functionality can be provided, 
1410 // cycling through possible values. 
1411 bool wxColourListValidator::OnDoubleClick(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1413   if (!view
->GetValueText()) 
1415   OnEdit(property
, view
, parentWindow
); 
1419 bool wxColourListValidator::OnPrepareControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1421   if (view
->GetConfirmButton()) 
1422     view
->GetConfirmButton()->Enable(TRUE
); 
1423   if (view
->GetCancelButton()) 
1424     view
->GetCancelButton()->Enable(TRUE
); 
1425   if (view
->GetEditButton()) 
1426     view
->GetEditButton()->Enable(TRUE
); 
1427   if (view
->GetValueText()) 
1428     view
->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING
) == wxPROP_ALLOW_TEXT_EDITING
); 
1432 void wxColourListValidator::OnEdit(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1434   if (!view
->GetValueText()) 
1437   wxChar 
*s 
= property
->GetValue().StringValue(); 
1444     g 
= wxHexToDec(s
+2); 
1445     b 
= wxHexToDec(s
+4); 
1448   wxColour 
col(r
,g
,b
); 
1451   data
.SetChooseFull(TRUE
); 
1452   data
.SetColour(col
); 
1454   for (int i 
= 0; i 
< 16; i
++) 
1456     wxColour 
colour(i
*16, i
*16, i
*16); 
1457     data
.SetCustomColour(i
, colour
); 
1460   wxColourDialog 
dialog(parentWindow
, &data
); 
1461   if (dialog
.ShowModal() != wxID_CANCEL
) 
1463     wxColourData retData 
= dialog
.GetColourData(); 
1464     col 
= retData
.GetColour(); 
1467     wxDecToHex(col
.Red(), buf
); 
1468     wxDecToHex(col
.Green(), buf
+2); 
1469     wxDecToHex(col
.Blue(), buf
+4); 
1471     property
->GetValue() = wxString(buf
); 
1472     view
->DisplayProperty(property
); 
1473     view
->UpdatePropertyDisplayInList(property
); 
1474     view
->OnPropertyChanged(property
); 
1479 /// List of strings validator. For this we need more user interface than 
1480 /// we get with a property list; so create a new dialog for editing the list. 
1482 IMPLEMENT_DYNAMIC_CLASS(wxListOfStringsListValidator
, wxPropertyListValidator
) 
1484 wxListOfStringsListValidator::wxListOfStringsListValidator(long flags
): 
1485   wxPropertyListValidator(flags
) 
1489 bool wxListOfStringsListValidator::OnCheckValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*WXUNUSED(view
), wxWindow 
*WXUNUSED(parentWindow
)) 
1491   // No constraints for an arbitrary, user-editable list of strings. 
1495 // Called when TICK is pressed or focus is lost or view wants to update 
1496 // the property list. 
1497 // Does the transferance from the property editing area to the property itself. 
1498 // In this case, the user cannot directly edit the string list. 
1499 bool wxListOfStringsListValidator::OnRetrieveValue(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*WXUNUSED(view
), wxWindow 
*WXUNUSED(parentWindow
)) 
1504 bool wxListOfStringsListValidator::OnDisplayValue(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1506   if (!view
->GetValueText()) 
1508   wxString 
str(property
->GetValue().GetStringRepresentation()); 
1509   view
->GetValueText()->SetValue(str
); 
1513 bool wxListOfStringsListValidator::OnPrepareControls(wxProperty 
*WXUNUSED(property
), wxPropertyListView 
*view
, wxWindow 
*WXUNUSED(parentWindow
)) 
1515   if (view
->GetEditButton()) 
1516     view
->GetEditButton()->Enable(TRUE
); 
1517   if (view
->GetValueText()) 
1518     view
->GetValueText()->Enable(FALSE
); 
1520   if (view
->GetConfirmButton()) 
1521     view
->GetConfirmButton()->Enable(FALSE
); 
1522   if (view
->GetCancelButton()) 
1523     view
->GetCancelButton()->Enable(FALSE
); 
1527 // Called when the property is double clicked. Extra functionality can be provided, 
1528 // cycling through possible values. 
1529 bool wxListOfStringsListValidator::OnDoubleClick(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1531   OnEdit(property
, view
, parentWindow
); 
1535 void wxListOfStringsListValidator::OnEdit(wxProperty 
*property
, wxPropertyListView 
*view
, wxWindow 
*parentWindow
) 
1537   // Convert property value to a list of strings for editing 
1538   wxStringList 
*stringList 
= new wxStringList
; 
1540   wxPropertyValue 
*expr 
= property
->GetValue().GetFirst(); 
1543     wxChar 
*s 
= expr
->StringValue(); 
1546     expr 
= expr
->GetNext(); 
1549   wxString 
title(wxT("Editing ")); 
1550   title 
+= property
->GetName(); 
1552   if (EditStringList(parentWindow
, stringList
, title
.GetData())) 
1554     wxPropertyValue
& oldValue 
= property
->GetValue(); 
1555     oldValue
.ClearList(); 
1556     wxNode 
*node 
= stringList
->First(); 
1559       wxChar 
*s 
= (wxChar 
*)node
->Data(); 
1560       oldValue
.Append(new wxPropertyValue(s
)); 
1562       node 
= node
->Next(); 
1565     view
->DisplayProperty(property
); 
1566     view
->UpdatePropertyDisplayInList(property
); 
1567     view
->OnPropertyChanged(property
); 
1572 class wxPropertyStringListEditorDialog
: public wxDialog
 
1575     wxPropertyStringListEditorDialog(wxWindow 
*parent
, const wxString
& title
, 
1576         const wxPoint
& pos 
= wxDefaultPosition
, const wxSize
& size 
= wxDefaultSize
, 
1577           long windowStyle 
= wxDEFAULT_DIALOG_STYLE
, const wxString
& name 
= "stringEditorDialogBox"): 
1578                wxDialog(parent
, -1, title
, pos
, size
, windowStyle
, name
) 
1580       m_stringList 
= NULL
; 
1581       m_stringText 
= NULL
; 
1583       sm_dialogCancelled 
= FALSE
; 
1584       m_currentSelection 
= -1; 
1586     ~wxPropertyStringListEditorDialog(void) {} 
1587     void OnCloseWindow(wxCloseEvent
& event
); 
1588     void SaveCurrentSelection(void); 
1589     void ShowCurrentSelection(void); 
1591     void OnOK(wxCommandEvent
& event
); 
1592     void OnCancel(wxCommandEvent
& event
); 
1593     void OnAdd(wxCommandEvent
& event
); 
1594     void OnDelete(wxCommandEvent
& event
); 
1595     void OnStrings(wxCommandEvent
& event
); 
1596     void OnText(wxCommandEvent
& event
); 
1599     wxStringList
*       m_stringList
; 
1600     wxListBox
*          m_listBox
; 
1601     wxTextCtrl
*         m_stringText
; 
1602     static bool         sm_dialogCancelled
; 
1603     int                 m_currentSelection
; 
1604 DECLARE_EVENT_TABLE() 
1607 #define    wxID_PROP_SL_ADD            3000 
1608 #define    wxID_PROP_SL_DELETE            3001 
1609 #define    wxID_PROP_SL_STRINGS        3002 
1610 #define    wxID_PROP_SL_TEXT            3003 
1612 BEGIN_EVENT_TABLE(wxPropertyStringListEditorDialog
, wxDialog
) 
1613     EVT_BUTTON(wxID_OK
,                 wxPropertyStringListEditorDialog::OnOK
) 
1614     EVT_BUTTON(wxID_CANCEL
,                wxPropertyStringListEditorDialog::OnCancel
) 
1615     EVT_BUTTON(wxID_PROP_SL_ADD
,        wxPropertyStringListEditorDialog::OnAdd
) 
1616     EVT_BUTTON(wxID_PROP_SL_DELETE
,        wxPropertyStringListEditorDialog::OnDelete
) 
1617     EVT_LISTBOX(wxID_PROP_SL_STRINGS
,    wxPropertyStringListEditorDialog::OnStrings
) 
1618     EVT_TEXT_ENTER(wxID_PROP_SL_TEXT
,            wxPropertyStringListEditorDialog::OnText
) 
1619     EVT_CLOSE(wxPropertyStringListEditorDialog::OnCloseWindow
) 
1622 class wxPropertyStringListEditorText
: public wxTextCtrl
 
1625   wxPropertyStringListEditorText(wxWindow 
*parent
, wxWindowID id
, const wxString
& val
, 
1626       const wxPoint
& pos 
= wxDefaultPosition
, const wxSize
& size 
= wxDefaultSize
, 
1627     long windowStyle 
= 0, const wxString
& name 
= "text"): 
1628      wxTextCtrl(parent
, id
, val
, pos
, size
, windowStyle
, wxDefaultValidator
, name
) 
1633     wxPropertyStringListEditorDialog 
*dialog 
= (wxPropertyStringListEditorDialog 
*)GetParent(); 
1634     dialog
->SaveCurrentSelection(); 
1638 bool wxPropertyStringListEditorDialog::sm_dialogCancelled 
= FALSE
; 
1640 // Edit the string list. 
1641 bool wxListOfStringsListValidator::EditStringList(wxWindow 
*parent
, wxStringList 
*stringList
, const wxChar 
*title
) 
1643   int largeButtonWidth 
= 60; 
1644   int largeButtonHeight 
= 25; 
1646   wxBeginBusyCursor(); 
1647   wxPropertyStringListEditorDialog 
*dialog 
= new wxPropertyStringListEditorDialog(parent
, 
1648       title
, wxPoint(10, 10), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE
|wxDIALOG_MODAL
); 
1650   dialog
->m_stringList 
= stringList
; 
1652   dialog
->m_listBox 
= new wxListBox(dialog
, wxID_PROP_SL_STRINGS
, 
1653     wxPoint(-1, -1), wxSize(-1, -1), 0, NULL
, wxLB_SINGLE
); 
1655   dialog
->m_stringText 
= new wxPropertyStringListEditorText(dialog
, 
1656   wxID_PROP_SL_TEXT
, "", wxPoint(5, 240), 
1657        wxSize(300, -1), wxPROCESS_ENTER
); 
1658   dialog
->m_stringText
->Enable(FALSE
); 
1660   wxButton 
*addButton 
= new wxButton(dialog
, wxID_PROP_SL_ADD
, "Add", wxPoint(-1, -1), wxSize(largeButtonWidth
, largeButtonHeight
)); 
1661   wxButton 
*deleteButton 
= new wxButton(dialog
, wxID_PROP_SL_DELETE
, "Delete", wxPoint(-1, -1), wxSize(largeButtonWidth
, largeButtonHeight
)); 
1662   wxButton 
*cancelButton 
= new wxButton(dialog
, wxID_CANCEL
, "Cancel", wxPoint(-1, -1), wxSize(largeButtonWidth
, largeButtonHeight
)); 
1663   wxButton 
*okButton 
= new wxButton(dialog
, wxID_OK
, "OK", wxPoint(-1, -1), wxSize(largeButtonWidth
, largeButtonHeight
)); 
1666   okButton
->SetDefault(); 
1669   wxLayoutConstraints 
*c 
= new wxLayoutConstraints
; 
1671   c
->top
.SameAs     (dialog
, wxTop
, 2); 
1672   c
->left
.SameAs    (dialog
, wxLeft
, 2); 
1673   c
->right
.SameAs   (dialog
, wxRight
, 2); 
1674   c
->bottom
.SameAs  (dialog
->m_stringText
, wxTop
, 2); 
1675   dialog
->m_listBox
->SetConstraints(c
); 
1677   c 
= new wxLayoutConstraints
; 
1678   c
->left
.SameAs    (dialog
, wxLeft
, 2); 
1679   c
->right
.SameAs   (dialog
, wxRight
, 2); 
1680   c
->bottom
.SameAs  (addButton
, wxTop
, 2); 
1682   dialog
->m_stringText
->SetConstraints(c
); 
1684   c 
= new wxLayoutConstraints
; 
1685   c
->bottom
.SameAs  (dialog
, wxBottom
, 2); 
1686   c
->left
.SameAs    (dialog
, wxLeft
, 2); 
1689   addButton
->SetConstraints(c
); 
1691   c 
= new wxLayoutConstraints
; 
1692   c
->bottom
.SameAs  (dialog
, wxBottom
, 2); 
1693   c
->left
.SameAs    (addButton
, wxRight
, 2); 
1696   deleteButton
->SetConstraints(c
); 
1698   c 
= new wxLayoutConstraints
; 
1699   c
->bottom
.SameAs  (dialog
, wxBottom
, 2); 
1700   c
->right
.SameAs   (dialog
, wxRight
, 2); 
1703   cancelButton
->SetConstraints(c
); 
1705   c 
= new wxLayoutConstraints
; 
1706   c
->bottom
.SameAs  (dialog
, wxBottom
, 2); 
1707   c
->right
.SameAs   (cancelButton
, wxLeft
, 2); 
1710   okButton
->SetConstraints(c
); 
1712   wxNode 
*node 
= stringList
->First(); 
1715     char *str 
= (char *)node
->Data(); 
1716     // Save node as client data for each listbox item 
1717     dialog
->m_listBox
->Append(str
, (char *)node
); 
1718     node 
= node
->Next(); 
1721   dialog
->SetClientSize(310, 305); 
1724   dialog
->Centre(wxBOTH
); 
1726   if (dialog
->ShowModal() == wxID_CANCEL
) 
1733  * String list editor callbacks 
1737 void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent
& WXUNUSED(event
)) 
1739   int sel 
= m_listBox
->GetSelection(); 
1742     m_currentSelection 
= sel
; 
1744     ShowCurrentSelection(); 
1748 void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent
& WXUNUSED(event
)) 
1750   int sel 
= m_listBox
->GetSelection(); 
1754   wxNode 
*node 
= (wxNode 
*)m_listBox
->wxListBox::GetClientData(sel
); 
1758   m_listBox
->Delete(sel
); 
1759   delete[] (wxChar 
*)node
->Data(); 
1761   m_currentSelection 
= -1; 
1762   m_stringText
->SetValue(""); 
1765 void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent
& WXUNUSED(event
)) 
1767   SaveCurrentSelection(); 
1769   wxChar 
*initialText 
= wxT(""); 
1770   wxNode 
*node 
= m_stringList
->Add(initialText
); 
1771   m_listBox
->Append(initialText
, (void *)node
); 
1772   m_currentSelection 
= m_stringList
->Number() - 1; 
1773   m_listBox
->SetSelection(m_currentSelection
); 
1774   ShowCurrentSelection(); 
1775   m_stringText
->SetFocus(); 
1778 void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent
& WXUNUSED(event
)) 
1780   SaveCurrentSelection(); 
1786 void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent
& WXUNUSED(event
)) 
1788   sm_dialogCancelled 
= TRUE
; 
1789   EndModal(wxID_CANCEL
); 
1794 void wxPropertyStringListEditorDialog::OnText(wxCommandEvent
& event
) 
1796   if (event
.GetEventType() == wxEVT_COMMAND_TEXT_ENTER
) 
1798     SaveCurrentSelection(); 
1803 wxPropertyStringListEditorDialog::OnCloseWindow(wxCloseEvent
& WXUNUSED(event
)) 
1805   SaveCurrentSelection(); 
1810 void wxPropertyStringListEditorDialog::SaveCurrentSelection() 
1812   if (m_currentSelection 
== -1) 
1815   wxNode 
*node 
= (wxNode 
*)m_listBox
->wxListBox::GetClientData(m_currentSelection
); 
1819   wxString 
txt(m_stringText
->GetValue()); 
1821     delete[] (char *)node
->Data(); 
1822   node
->SetData((wxObject 
*)copystring(txt
)); 
1824   m_listBox
->SetString(m_currentSelection
, (char *)node
->Data()); 
1827 void wxPropertyStringListEditorDialog::ShowCurrentSelection() 
1829   if (m_currentSelection 
== -1) 
1831     m_stringText
->SetValue(""); 
1834   wxNode 
*node 
= (wxNode 
*)m_listBox
->wxListBox::GetClientData(m_currentSelection
); 
1835   char *txt 
= (char *)node
->Data(); 
1836   m_stringText
->SetValue(txt
); 
1837   m_stringText
->Enable(TRUE
); 
1840 // ---------------------------------------------------------------------------- 
1842 // ---------------------------------------------------------------------------- 
1845 static wxBitmap 
*GetTickBitmap() 
1847     static wxBitmap
* s_tickBitmap 
= (wxBitmap 
*) NULL
; 
1848     static bool s_loaded 
= FALSE
; 
1852         s_loaded 
= TRUE
; // set it to TRUE anyhow, we won't try again 
1854         #if defined(__WXMSW__) || defined(__WXOS2__) 
1855             s_tickBitmap 
= new wxBitmap("tick_bmp", wxBITMAP_TYPE_RESOURCE
); 
1857             s_tickBitmap 
= new wxBitmap( tick_xpm 
); 
1861     return s_tickBitmap
; 
1864 static wxBitmap 
*GetCrossBitmap() 
1866     static wxBitmap
* s_crossBitmap 
= (wxBitmap 
*) NULL
; 
1867     static bool s_loaded 
= FALSE
; 
1871         s_loaded 
= TRUE
; // set it to TRUE anyhow, we won't try again 
1873         #if defined(__WXMSW__) || defined(__WXOS2__) 
1874             s_crossBitmap 
=  new wxBitmap("cross_bmp", wxBITMAP_TYPE_RESOURCE
); 
1876             s_crossBitmap 
=  new wxBitmap( cross_xpm 
); 
1880     return s_crossBitmap
;