1 /////////////////////////////////////////////////////////////////////////////
2 // Name: propeditor.cpp
3 // Purpose: wxWidgets Configuration Tool property editor
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "propeditor.h"
16 // For compilers that support precompilation, includes "wx/wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/filedlg.h"
30 #include "wx/html/htmlwin.h"
31 #include "wx/tokenzr.h"
32 #include "wx/valgen.h"
33 #include "propeditor.h"
36 #include "configtooldoc.h"
37 #include "configitemselector.h"
39 #include "bitmaps/ellipsis.xpm"
43 * A container window for the property editor.
44 * and attribute editor.
47 IMPLEMENT_CLASS(ctPropertyEditor
, wxPanel
)
49 BEGIN_EVENT_TABLE(ctPropertyEditor
, wxPanel
)
50 EVT_BUTTON(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
, ctPropertyEditor::OnEditDetails
)
51 EVT_GRID_SELECT_CELL(ctPropertyEditor::OnSelectCell
)
52 EVT_GRID_CELL_CHANGE(ctPropertyEditor::OnChangeCell
)
53 EVT_GRID_CELL_LEFT_DCLICK(ctPropertyEditor::OnDClickCell
)
54 EVT_UPDATE_UI(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
, ctPropertyEditor::OnUpdateEditDetails
)
57 ctPropertyEditor::ctPropertyEditor(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
):
58 wxPanel(parent
, id
, pos
, size
, style
)
60 m_splitterWindow
= NULL
;
61 m_attributeEditorGrid
= NULL
;
62 m_propertyDescriptionWindow
= NULL
;
63 m_elementTitleTextCtrl
= NULL
;
68 ctPropertyEditor::~ctPropertyEditor()
72 void ctPropertyEditor::CreateControls(wxWindow
* parent
)
74 m_elementTitleTextCtrl
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_READONLY
);
75 wxBitmap
detailsIcon(ellipsis_xpm
);
77 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
79 wxBoxSizer
*item1
= new wxBoxSizer( wxHORIZONTAL
);
81 wxTextCtrl
*item2
= m_elementTitleTextCtrl
;
82 item1
->Add( item2
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
84 m_attributeEditorEditDetails
= new wxButton( parent
, ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
, wxT("Edit..."));
85 item1
->Add( m_attributeEditorEditDetails
, 0, wxALIGN_CENTRE
|wxRIGHT
|wxTOP
|wxBOTTOM
, 5 );
87 item0
->Add( item1
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
89 // TODO: find sash pos from last time
92 m_splitterWindow
= new wxSplitterWindow(parent
, ctID_PROPERTY_EDITOR_SPLITTER
, wxDefaultPosition
, wxSize(500, 400), wxSP_3DSASH
|wxSP_FULLSASH
/*|wxCLIP_CHILDREN*/ |wxBORDER_NONE
|wxNO_FULL_REPAINT_ON_RESIZE
);
93 m_splitterWindow
->SetMinimumPaneSize(10);
95 m_propertyDescriptionWindow
= new wxHtmlWindow(m_splitterWindow
, ctID_ATTRIBUTE_EDITOR_DESCRIPTION
, wxDefaultPosition
, wxSize(200, 60), wxSUNKEN_BORDER
);
96 m_propertyDescriptionWindow
->SetBackgroundColour(ctDESCRIPTION_BACKGROUND_COLOUR
);
97 m_propertyDescriptionWindow
->SetBorders(4);
98 m_attributeEditorGrid
= new ctPropertyEditorGrid(m_splitterWindow
, ctID_ATTRIBUTE_EDITOR_GRID
, wxPoint(0, 0), wxSize(200, 100), wxBORDER_SUNKEN
| wxWANTS_CHARS
);
100 m_splitterWindow
->SplitHorizontally(m_propertyDescriptionWindow
, m_attributeEditorGrid
, sashPos
);
102 // TODO: show or hide description window
104 // ShowDescriptionWindow(false);
106 item0
->Add( m_splitterWindow
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
|wxBOTTOM
, 5 );
108 this->SetSizer( item0
);
111 m_elementTitleTextCtrl
->SetHelpText(_("The title of the property being edited."));
112 m_attributeEditorEditDetails
->SetHelpText(_("Click to use an appropriate editor for the selected property (if any)."));
113 m_attributeEditorGrid
->SetHelpText(_("Shows the properties of the selected item."));
114 m_propertyDescriptionWindow
->SetHelpText(_("Shows a description of the selected property, or a summary of the whole item."));
116 /// Set up the grid to display properties
117 m_attributeEditorGrid
->RegisterDataType(ctGRID_VALUE_STRING
,
118 new wxGridCellStringRenderer
,
119 new ctGridCellTextEditor
);
121 m_attributeEditorGrid
->CreateGrid( 0, 2, wxGrid::wxGridSelectRows
);
122 m_attributeEditorGrid
->SetRowLabelSize(0);
123 m_attributeEditorGrid
->SetColLabelSize(0 /* 18 */);
125 wxArrayString columns
;
126 columns
.Add(_T("Name"));
127 columns
.Add(_T("Value"));
129 m_attributeEditorGrid
->SetColSize(0, 140);
130 m_attributeEditorGrid
->SetColSize(1, 80);
132 m_attributeEditorGrid
->SetColumnsToDisplay(columns
);
133 m_attributeEditorGrid
->DisplayLabels();
135 m_attributeEditorGrid
->SetStretchableColumn(1);
137 m_attributeEditorGrid
->SetDefaultCellBackgroundColour(ctCELL_BACKGROUND_COLOUR
);
142 /// Show/hide the description control
143 void ctPropertyEditor::ShowDescriptionWindow(bool show
)
147 if (m_splitterWindow
->IsSplit())
148 m_splitterWindow
->Unsplit(m_propertyDescriptionWindow
);
154 m_propertyDescriptionWindow
->Show(true);
155 if (!m_splitterWindow
->IsSplit())
157 m_splitterWindow
->SplitHorizontally(m_propertyDescriptionWindow
, m_attributeEditorGrid
, pos
);
162 /// Clear grid editor
163 void ctPropertyEditor::ClearEditor()
165 m_attributeEditorGrid
->ClearAttributes();
166 m_propertyDescriptionWindow
->SetPage(WrapDescription(wxEmptyString
));
167 m_elementTitleTextCtrl
->SetValue(wxEmptyString
);
170 /// Handles detailed editing event.
171 void ctPropertyEditor::OnEditDetails(wxCommandEvent
& WXUNUSED(event
))
173 wxWindow
* parentFrame
= this;
174 while (parentFrame
&& !parentFrame
->IsKindOf(CLASSINFO(wxFrame
)))
175 parentFrame
= parentFrame
->GetParent();
177 EditDetails(parentFrame
);
180 /// Handles detailed editing update event.
181 void ctPropertyEditor::OnUpdateEditDetails(wxUpdateUIEvent
& event
)
183 event
.Enable(CanEditDetails());
186 /// Can we edit the details of the selected property?
187 bool ctPropertyEditor::CanEditDetails()
193 ctProperty
* prop
= FindSelectedProperty(row
);
194 if (!prop
|| prop
->GetEditorType().IsEmpty())
200 void ctPropertyEditor::ShowItem(ctConfigItem
* item
)
202 if (m_attributeEditorGrid
->IsCellEditControlEnabled())
203 m_attributeEditorGrid
->SaveEditControlValue();
212 m_attributeEditorGrid
->AppendRows(m_item
->GetProperties().GetCount());
214 wxObjectList::compatibility_iterator node
= m_item
->GetProperties().GetList().GetFirst();
218 ctProperty
* prop
= (ctProperty
*) node
->GetData();
219 DisplayProperty(i
, prop
);
222 node
= node
->GetNext();
224 // Make sure scrollbars are up-to-date, etc.
225 wxSizeEvent
event(m_attributeEditorGrid
->GetSize(), m_attributeEditorGrid
->GetId());
226 m_attributeEditorGrid
->GetEventHandler()->ProcessEvent(event
);
228 DisplayDefaultProperty();
236 /// Determine background colour for this property.
237 void ctPropertyEditor::DeterminePropertyColour(ctProperty
* prop
, wxColour
& colour
)
239 if (prop
->IsCustom())
240 colour
= ctCUSTOM_CELL_BACKGROUND_COLOUR
;
242 colour
= ctCELL_BACKGROUND_COLOUR
;
245 /// Update the title at the top of the property editor
246 void ctPropertyEditor::UpdateTitle()
250 wxString
name(m_item
->GetTitle());
251 m_elementTitleTextCtrl
->SetValue(name
);
255 /// Updates the item display, assuming it was already displayed.
256 void ctPropertyEditor::UpdateItem()
258 if (m_attributeEditorGrid
->IsCellEditControlEnabled())
259 m_attributeEditorGrid
->SaveEditControlValue();
264 wxObjectList::compatibility_iterator node
= m_item
->GetProperties().GetList().GetFirst();
268 ctProperty
* prop
= (ctProperty
*) node
->GetData();
269 DisplayProperty(i
, prop
, true);
272 node
= node
->GetNext();
274 // Make sure scrollbars are up-to-date, etc.
275 wxSizeEvent
event(m_attributeEditorGrid
->GetSize(), this->GetId());
276 m_attributeEditorGrid
->GetEventHandler()->ProcessEvent(event
);
280 /// Display attribute at given row
281 bool ctPropertyEditor::DisplayProperty(int row
, ctProperty
* prop
, bool valueOnly
)
283 wxColour backgroundColour
;
285 DeterminePropertyColour(prop
, backgroundColour
);
289 m_attributeEditorGrid
->SetCellBackgroundColour(row
, 0, backgroundColour
);
290 m_attributeEditorGrid
->SetCellBackgroundColour(row
, 1, backgroundColour
);
292 m_attributeEditorGrid
->SetCellValue(row
, 0, prop
->GetName());
294 m_attributeEditorGrid
->SetReadOnly(row
, 0);
296 m_attributeEditorGrid
->SetCellAlignment(row
, 1, wxALIGN_LEFT
, wxALIGN_CENTER
);
299 if (!m_item
->CanEditProperty(prop
->GetName()))
301 m_attributeEditorGrid
->SetReadOnly(row
, 1);
303 wxColour
col(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
));
304 m_attributeEditorGrid
->SetCellTextColour(row
, 1, col
);
308 m_attributeEditorGrid
->SetReadOnly(row
, 1, false);
309 m_attributeEditorGrid
->SetCellTextColour(row
, 1, * wxBLACK
);
313 m_attributeEditorGrid
->SetCellValue(row
, 1, ctConvertToSingleText(prop
->GetValue()));
318 // Set the value type
319 if (prop
->GetEditorType() == _T("choice"))
322 wxString
* strArr
= prop
->GetChoices().GetStringArray();
324 m_attributeEditorGrid
->SetCellEditor(row
, 1,
325 new wxGridCellChoiceEditor(prop
->GetChoices().GetCount(), strArr
));
329 m_attributeEditorGrid
->SetCellEditor(row
, 1,
330 new wxGridCellChoiceEditor(prop
->GetChoices()));
332 else if (prop
->GetEditorType() == _T("integer") || prop
->GetVariant().GetType() == _T("long"))
334 m_attributeEditorGrid
->SetCellEditor(row
, 1,
335 new wxGridCellNumberEditor
);
337 else if (prop
->GetEditorType() == _T("float") || prop
->GetVariant().GetType() == _T("double"))
339 m_attributeEditorGrid
->SetCellEditor(row
, 1,
340 new wxGridCellFloatEditor
);
342 else if (prop
->GetEditorType() == _T("bool") || prop
->GetVariant().GetType() == _T("bool"))
344 m_attributeEditorGrid
->SetCellValue(row
, 1, prop
->GetVariant().GetBool() ? _T("1") : _T("0"));
345 m_attributeEditorGrid
->SetCellEditor(row
, 1,
346 new wxGridCellBoolEditor
);
347 m_attributeEditorGrid
->SetCellRenderer(row
, 1, new wxGridCellBoolRenderer
);
351 m_attributeEditorGrid
->SetCellEditor(row
, 1,
352 new ctGridCellTextEditor
);
358 /// Display attribute value
359 bool ctPropertyEditor::DisplayProperty(ctProperty
* prop
)
364 int index
= m_item
->GetProperties().GetList().IndexOf(prop
);
365 return DisplayProperty(index
, prop
, true);
368 /// Display the default property
369 bool ctPropertyEditor::DisplayDefaultProperty()
374 wxString str
= m_item
->GetDefaultProperty();
376 ctProperty
* prop
= m_item
->GetProperties().FindProperty(str
);
379 int index
= m_item
->GetProperties().GetList().IndexOf(prop
);
380 this->m_attributeEditorGrid
->SelectRow(index
);
381 this->m_attributeEditorGrid
->SetGridCursor(index
, 1);
386 /// Edit the default property
387 bool ctPropertyEditor::EditDefaultProperty(ctConfigItem
* item
)
389 wxString defaultPropertyName
= item
->GetDefaultProperty();
390 if (!defaultPropertyName
.IsEmpty())
392 ctProperty
* prop
= item
->GetProperties().FindProperty(defaultPropertyName
);
395 int index
= item
->GetProperties().GetList().IndexOf(prop
);
398 this->m_attributeEditorGrid
->SelectRow(index
);
399 this->m_attributeEditorGrid
->SetGridCursor(index
, 1);
400 EditDetails(wxTheApp
->GetTopWindow());
409 /// Find the selected property
410 ctProperty
* ctPropertyEditor::FindSelectedProperty(int& row
)
415 int selRow
= m_attributeEditorGrid
->GetCursorRow();
420 if (selRow
< (int) m_item
->GetProperties().GetCount())
422 ctProperty
* prop
= m_item
->GetProperties().GetNth(selRow
);
429 /// Find the property
430 ctProperty
* ctPropertyEditor::FindProperty(int row
)
437 if (row
< (int) m_item
->GetProperties().GetCount())
439 ctProperty
* prop
= m_item
->GetProperties().GetNth(row
);
446 /// Edit the details of this cell appropriately.
447 bool ctPropertyEditor::EditDetails(wxWindow
* WXUNUSED(parent
))
449 if (CanEditDetails())
452 ctProperty
* prop
= FindSelectedProperty(row
);
456 wxString
type(prop
->GetEditorType());
457 wxString value
= m_attributeEditorGrid
->GetCellValue(row
, 1);
459 if (type
== _T("multiline"))
461 value
= ctConvertToMultilineText(value
);
463 msg
.Printf(wxT("Edit %s:"), (const wxChar
*) prop
->GetName());
464 ctMultiLineTextEditor
dialog(wxTheApp
->GetTopWindow(),
465 wxID_ANY
, wxT("Edit Text Property"), msg
, value
);
466 if (dialog
.ShowModal() == wxID_OK
)
468 value
= ctConvertToSingleText(dialog
.GetText());
469 m_attributeEditorGrid
->SetCellValue(row
, 1, value
);
470 ApplyCellValueToProperty(row
, 1);
476 else if (type
== _T("filename"))
478 wxString fullPath
= value
;
479 wxString defaultDir
;
480 wxString defaultFilename
= wxFileNameFromPath(fullPath
);
482 defaultDir
= wxPathOnly(value
);
484 wxString msg
= wxT("Choose a filename");
485 wxFileDialog
dialog(wxTheApp
->GetTopWindow(),
486 msg
, defaultDir
, defaultFilename
, wxT("*.*"));
487 if (dialog
.ShowModal() == wxID_OK
)
489 fullPath
= dialog
.GetPath();
492 m_attributeEditorGrid
->SetCellValue(row
, 1, value
);
493 ApplyCellValueToProperty(row
, 1);
499 else if (type
== _T("configitems"))
502 ctConfigItem::StringToArray(value
, items
);
504 ctConfigItemsSelector
dialog(wxTheApp
->GetTopWindow(),
505 wxID_ANY
, wxT("Select Configuration Items"));
506 dialog
.SetConfigList(items
);
507 if (dialog
.ShowModal() == wxID_OK
)
510 items
= dialog
.GetConfigList();
511 ctConfigItem::ArrayToString(items
, newValue
);
513 m_attributeEditorGrid
->SetCellValue(row
, 1, newValue
);
514 ApplyCellValueToProperty(row
, 1);
525 /// Intercept selection event.
526 void ctPropertyEditor::OnSelectCell(wxGridEvent
& event
)
528 int row
= event
.GetRow();
530 UpdateDescription(row
);
535 /// Update the description
536 void ctPropertyEditor::UpdateDescription(int row
)
540 row
= m_attributeEditorGrid
->GetCursorRow();
544 wxString str
= WrapDescription(wxEmptyString
);
545 m_propertyDescriptionWindow
->SetPage(str
);
549 ctProperty
* prop
= FindProperty(row
);
552 wxString str
= WrapDescription(m_item
->GetDescription(prop
));
553 m_propertyDescriptionWindow
->SetPage(str
);
558 /// Wraps a description string in HTML
559 wxString
ctPropertyEditor::WrapDescription(const wxString
& s
)
561 /// Convert a colour to a 6-digit hex string
562 wxColour col
= ctDESCRIPTION_BACKGROUND_COLOUR
;
563 wxString colStr
= apColourToHexString(col
);
564 colStr
= wxT("#") + colStr
;
567 str
<< _T("<HTML><BODY BGCOLOR=\"") << colStr
<< wxT("\"><FONT SIZE=-1>") ;
569 str
<< _T("</FONT></BODY></HTML>");
574 /// Intercept cell data change event.
575 void ctPropertyEditor::OnChangeCell(wxGridEvent
& event
)
577 int row
= event
.GetRow();
578 int col
= event
.GetCol();
580 ApplyCellValueToProperty(row
, col
);
583 /// Double-click to show specialised editor.
584 void ctPropertyEditor::OnDClickCell(wxGridEvent
& WXUNUSED(event
))
586 wxWindow
* parentFrame
= this;
587 while (parentFrame
&& !parentFrame
->IsKindOf(CLASSINFO(wxFrame
)))
588 parentFrame
= parentFrame
->GetParent();
590 EditDetails(parentFrame
);
593 /// Apply the cell value to the property, and notify the
595 void ctPropertyEditor::ApplyCellValueToProperty(int row
, int col
)
597 static bool s_Applying
= false;
603 if (col
== 1 && m_item
)
605 ctProperty
* prop
= m_item
->GetProperties().GetNth(row
);
607 wxString value
= m_attributeEditorGrid
->GetCellValue(row
, col
);
608 if (prop
->GetEditorType() == wxT("multiline"))
609 value
= ctConvertToMultilineText(value
);
611 wxVariant variant
= prop
->GetVariant();
613 if (prop
->GetVariant().GetType() == _T("bool"))
615 if (value
== _T("1"))
620 else if (prop
->GetVariant().GetType() == _T("long"))
626 else if (prop
->GetVariant().GetType() == _T("double"))
637 ApplyPropertyValue(m_item
, prop
, variant
);
639 if (prop
->GetName() == _T("description"))
640 UpdateDescription(row
);
645 /// Apply the cell value to the property, and notify the
647 void ctPropertyEditor::ApplyPropertyValue(ctConfigItem
* item
, ctProperty
* property
, const wxVariant
& variant
)
649 static bool s_Applying
= false;
656 // Save the old values
657 ctProperties
* oldProperties
= new ctProperties(item
->GetProperties());
659 wxVariant oldValue
= property
->GetVariant();
661 // Apply the new value
662 property
->GetVariant() = variant
;
663 item
->ApplyProperty(property
, oldValue
);
668 wxString
menuLabel(_T("Change ") + property
->GetName());
670 // This won't do anything first time Do is applied,
671 // since we've already done the action for this property.
672 // But when we Undo or Redo, the changed properties will be applied.
673 item
->GetDocument()->GetCommandProcessor()->Submit(
674 new ctConfigCommand(menuLabel
, ctCMD_APPLY_PROPERTY
,
675 item
, oldProperties
, true));
681 * Attribute editor grid
684 IMPLEMENT_CLASS(ctPropertyEditorGrid
, wxGrid
)
686 BEGIN_EVENT_TABLE(ctPropertyEditorGrid
, wxGrid
)
687 EVT_SIZE(ctPropertyEditorGrid::OnSize
)
690 ctPropertyEditorGrid::ctPropertyEditorGrid(wxWindow
* parent
, wxWindowID id
,
692 const wxSize
& sz
, long style
):
693 wxGrid(parent
, id
, pos
, sz
, style
)
696 m_stretchableColumn
= -1;
699 void ctPropertyEditorGrid::OnSize(wxSizeEvent
& event
)
701 if (m_stretchableColumn
!= -1)
703 // This window's client size = the internal window's
704 // client size if it has no borders
705 wxSize sz
= GetClientSize();
709 for (i
= 0; i
< GetNumberCols(); i
++)
711 if (i
!= m_stretchableColumn
)
713 totalSize
+= GetColSize(i
);
717 // Allow for grid lines
720 int stretchSize
= wxMax(5, sz
.x
- totalSize
);
721 SetColSize(m_stretchableColumn
, stretchSize
);
727 /// Use m_columnsToDisplay to set the label strings
728 void ctPropertyEditorGrid::DisplayLabels()
731 for (i
= 0; i
< m_columnsToDisplay
.GetCount(); i
++)
733 SetColLabelValue(i
, m_columnsToDisplay
[i
]);
738 bool ctPropertyEditorGrid::ClearAttributes()
740 if (GetNumberRows() > 0)
741 DeleteRows(0, GetNumberRows());
746 * Use a single-line text control.
749 void ctGridCellTextEditor::Create(wxWindow
* parent
, wxWindowID id
,
750 wxEvtHandler
* evtHandler
)
752 m_control
= new wxTextCtrl(parent
, id
, wxEmptyString
,
753 wxDefaultPosition
, wxDefaultSize
756 wxGridCellEditor::Create(parent
, id
, evtHandler
);
760 /// Translate the value to one which can be edited in a single-line
762 wxString
ctConvertToSingleText(const wxString
& value
)
764 wxString
value1(value
);
765 value1
.Replace(wxT("\n"), wxT("\\n"));
766 value1
.Replace(wxT("\t"), wxT("\\t"));
770 /// Translate back to 'real' characters, i.e. newlines are real
772 wxString
ctConvertToMultilineText(const wxString
& value
)
774 wxString
value1(value
);
775 value1
.Replace(wxT("\\n"), wxT("\n"));
776 value1
.Replace(wxT("\\t"), wxT("\t"));
780 //----------------------------------------------------------------------------
781 // ctMultiLineTextEditor
782 //----------------------------------------------------------------------------
784 BEGIN_EVENT_TABLE(ctMultiLineTextEditor
, wxDialog
)
787 ctMultiLineTextEditor::ctMultiLineTextEditor( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
789 const wxString
& value
,
793 wxDialog(parent
, id
, title
, pos
, size
, style
)
796 AddControls(this, msg
);
800 bool ctMultiLineTextEditor::AddControls(wxWindow
* parent
, const wxString
& msg
)
802 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
804 wxBoxSizer
*item1
= new wxBoxSizer( wxVERTICAL
);
806 wxStaticText
*item2
= new wxStaticText( parent
, wxID_STATIC
, msg
, wxDefaultPosition
, wxDefaultSize
, 0 );
807 item1
->Add( item2
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxLEFT
|wxRIGHT
, 5 );
809 wxTextCtrl
*item3
= new wxTextCtrl( parent
, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxSize(330,180), wxTE_MULTILINE
|wxTE_RICH
);
810 item1
->Add( item3
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
812 wxBoxSizer
*item4
= new wxBoxSizer( wxHORIZONTAL
);
814 item4
->Add( 5, 5, 1, wxALIGN_CENTRE
|wxALL
, 5 );
816 wxButton
*item5
= new wxButton( parent
, wxID_OK
, _("&OK"), wxDefaultPosition
, wxDefaultSize
, 0 );
817 item4
->Add( item5
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
819 wxButton
*item6
= new wxButton( parent
, wxID_CANCEL
, _("&Cancel"), wxDefaultPosition
, wxDefaultSize
, 0 );
820 item4
->Add( item6
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
822 item1
->Add( item4
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
824 item0
->Add( item1
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
826 item3
->SetValue(m_text
);
827 item3
->SetValidator(wxGenericValidator(& m_text
));
833 parent
->SetSizer(item0
);
840 * Special-purpose splitter window for changing sash look and
841 * also saving sash width
844 BEGIN_EVENT_TABLE(ctSplitterWindow
, wxSplitterWindow
)
845 EVT_SPLITTER_SASH_POS_CHANGED(wxID_ANY
, ctSplitterWindow::OnChangeSash
)
848 ctSplitterWindow::ctSplitterWindow(wxWindow
* parent
, wxWindowID id
,
849 const wxPoint
& pos
, const wxSize
& size
, long style
):
850 wxSplitterWindow(parent
, id
, pos
, size
, style
)
852 m_updateSettings
= false;
856 void ctSplitterWindow::OnChangeSash(wxSplitterEvent
& event
)
858 if (!m_updateSettings
)
861 m_position
= event
.GetSashPosition();