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"
22 #include "wx/html/htmlwin.h"
24 #include "wx/filedlg.h"
25 #include "wx/tokenzr.h"
26 #include "wx/valgen.h"
28 #include "propeditor.h"
31 #include "configtooldoc.h"
32 #include "configitemselector.h"
33 #include "bitmaps/ellipsis.xpm"
37 * A container window for the property editor.
38 * and attribute editor.
41 IMPLEMENT_CLASS(ctPropertyEditor
, wxPanel
)
43 BEGIN_EVENT_TABLE(ctPropertyEditor
, wxPanel
)
44 EVT_BUTTON(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
, ctPropertyEditor::OnEditDetails
)
45 EVT_GRID_SELECT_CELL(ctPropertyEditor::OnSelectCell
)
46 EVT_GRID_CELL_CHANGE(ctPropertyEditor::OnChangeCell
)
47 EVT_GRID_CELL_LEFT_DCLICK(ctPropertyEditor::OnDClickCell
)
48 EVT_UPDATE_UI(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
, ctPropertyEditor::OnUpdateEditDetails
)
51 ctPropertyEditor::ctPropertyEditor(wxWindow
*parent
, wxWindowID id
, const wxPoint
& pos
, const wxSize
& size
, long style
):
52 wxPanel(parent
, id
, pos
, size
, style
)
54 m_splitterWindow
= NULL
;
55 m_attributeEditorGrid
= NULL
;
56 m_propertyDescriptionWindow
= NULL
;
57 m_elementTitleTextCtrl
= NULL
;
62 ctPropertyEditor::~ctPropertyEditor()
66 void ctPropertyEditor::CreateControls(wxWindow
* parent
)
68 m_elementTitleTextCtrl
= new wxTextCtrl(this, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, wxTE_READONLY
);
69 wxBitmap
detailsIcon(ellipsis_xpm
);
71 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
73 wxBoxSizer
*item1
= new wxBoxSizer( wxHORIZONTAL
);
75 wxTextCtrl
*item2
= m_elementTitleTextCtrl
;
76 item1
->Add( item2
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
78 wxButton
*item3a
= new wxButton( parent
, ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
, wxT("Edit..."));
79 item1
->Add( item3a
, 0, wxALIGN_CENTRE
|wxRIGHT
|wxTOP
|wxBOTTOM
, 5 );
81 item0
->Add( item1
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
83 // TODO: find sash pos from last time
86 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
);
87 m_splitterWindow
->SetMinimumPaneSize(10);
89 m_propertyDescriptionWindow
= new wxHtmlWindow(m_splitterWindow
, ctID_ATTRIBUTE_EDITOR_DESCRIPTION
, wxDefaultPosition
, wxSize(200, 60), wxSUNKEN_BORDER
);
90 m_propertyDescriptionWindow
->SetBackgroundColour(ctDESCRIPTION_BACKGROUND_COLOUR
);
91 m_propertyDescriptionWindow
->SetBorders(4);
92 m_attributeEditorGrid
= new ctPropertyEditorGrid(m_splitterWindow
, ctID_ATTRIBUTE_EDITOR_GRID
, wxPoint(0, 0), wxSize(200, 100), wxBORDER_SUNKEN
| wxWANTS_CHARS
);
94 m_splitterWindow
->SplitHorizontally(m_propertyDescriptionWindow
, m_attributeEditorGrid
, sashPos
);
96 // TODO: show or hide description window
98 // ShowDescriptionWindow(false);
100 item0
->Add( m_splitterWindow
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
|wxBOTTOM
, 5 );
102 this->SetSizer( item0
);
105 m_elementTitleTextCtrl
->SetHelpText(_("The title of the property being edited."));
106 FindWindow(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
)->SetHelpText(_("Click to use an appropriate editor for the selected property (if any)."));
107 FindWindow(ctID_ATTRIBUTE_EDITOR_GRID
)->SetHelpText(_("Shows the properties of the selected item."));
108 FindWindow(ctID_ATTRIBUTE_EDITOR_DESCRIPTION
)->SetHelpText(_("Shows a description of the selected property, or a summary of the whole item."));
110 /// Set up the grid to display properties
111 m_attributeEditorGrid
->RegisterDataType(ctGRID_VALUE_STRING
,
112 new wxGridCellStringRenderer
,
113 new ctGridCellTextEditor
);
115 m_attributeEditorGrid
->CreateGrid( 0, 2, wxGrid::wxGridSelectRows
);
116 m_attributeEditorGrid
->SetRowLabelSize(0);
117 m_attributeEditorGrid
->SetColLabelSize(0 /* 18 */);
119 wxArrayString columns
;
120 columns
.Add(_T("Name"));
121 columns
.Add(_T("Value"));
123 m_attributeEditorGrid
->SetColSize(0, 140);
124 m_attributeEditorGrid
->SetColSize(1, 80);
126 m_attributeEditorGrid
->SetColumnsToDisplay(columns
);
127 m_attributeEditorGrid
->DisplayLabels();
129 m_attributeEditorGrid
->SetStretchableColumn(1);
131 m_attributeEditorGrid
->SetDefaultCellBackgroundColour(ctCELL_BACKGROUND_COLOUR
);
136 /// Show/hide the description control
137 void ctPropertyEditor::ShowDescriptionWindow(bool show
)
141 if (m_splitterWindow
->IsSplit())
142 m_splitterWindow
->Unsplit(m_propertyDescriptionWindow
);
148 m_propertyDescriptionWindow
->Show(true);
149 if (!m_splitterWindow
->IsSplit())
151 m_splitterWindow
->SplitHorizontally(m_propertyDescriptionWindow
, m_attributeEditorGrid
, pos
);
156 /// Clear grid editor
157 void ctPropertyEditor::ClearEditor()
159 m_attributeEditorGrid
->ClearAttributes();
160 m_propertyDescriptionWindow
->SetPage(WrapDescription(wxEmptyString
));
161 m_elementTitleTextCtrl
->SetValue(wxEmptyString
);
164 /// Handles detailed editing event.
165 void ctPropertyEditor::OnEditDetails(wxCommandEvent
& WXUNUSED(event
))
167 wxWindow
* parentFrame
= this;
168 while (parentFrame
&& !parentFrame
->IsKindOf(CLASSINFO(wxFrame
)))
169 parentFrame
= parentFrame
->GetParent();
171 EditDetails(parentFrame
);
174 /// Handles detailed editing update event.
175 void ctPropertyEditor::OnUpdateEditDetails(wxUpdateUIEvent
& event
)
177 event
.Enable(CanEditDetails());
180 /// Can we edit the details of the selected property?
181 bool ctPropertyEditor::CanEditDetails()
187 ctProperty
* prop
= FindSelectedProperty(row
);
188 if (!prop
|| prop
->GetEditorType().IsEmpty())
194 void ctPropertyEditor::ShowItem(ctConfigItem
* item
)
196 if (m_attributeEditorGrid
->IsCellEditControlEnabled())
197 m_attributeEditorGrid
->SaveEditControlValue();
206 m_attributeEditorGrid
->AppendRows(m_item
->GetProperties().GetCount());
208 wxNode
* node
= m_item
->GetProperties().GetList().GetFirst();
212 ctProperty
* prop
= (ctProperty
*) node
->GetData();
213 DisplayProperty(i
, prop
);
216 node
= node
->GetNext();
218 // Make sure scrollbars are up-to-date, etc.
219 wxSizeEvent
event(m_attributeEditorGrid
->GetSize(), m_attributeEditorGrid
->GetId());
220 m_attributeEditorGrid
->GetEventHandler()->ProcessEvent(event
);
222 DisplayDefaultProperty();
230 /// Determine background colour for this property.
231 void ctPropertyEditor::DeterminePropertyColour(ctProperty
* prop
, wxColour
& colour
)
233 if (prop
->IsCustom())
234 colour
= ctCUSTOM_CELL_BACKGROUND_COLOUR
;
236 colour
= ctCELL_BACKGROUND_COLOUR
;
239 /// Update the title at the top of the property editor
240 void ctPropertyEditor::UpdateTitle()
244 wxString
name(m_item
->GetTitle());
245 m_elementTitleTextCtrl
->SetValue(name
);
249 /// Updates the item display, assuming it was already displayed.
250 void ctPropertyEditor::UpdateItem()
252 if (m_attributeEditorGrid
->IsCellEditControlEnabled())
253 m_attributeEditorGrid
->SaveEditControlValue();
258 wxNode
* node
= m_item
->GetProperties().GetList().GetFirst();
262 ctProperty
* prop
= (ctProperty
*) node
->GetData();
263 DisplayProperty(i
, prop
, true);
266 node
= node
->GetNext();
268 // Make sure scrollbars are up-to-date, etc.
269 wxSizeEvent
event(m_attributeEditorGrid
->GetSize(), this->GetId());
270 m_attributeEditorGrid
->GetEventHandler()->ProcessEvent(event
);
274 /// Display attribute at given row
275 bool ctPropertyEditor::DisplayProperty(int row
, ctProperty
* prop
, bool valueOnly
)
277 wxColour backgroundColour
;
279 DeterminePropertyColour(prop
, backgroundColour
);
283 m_attributeEditorGrid
->SetCellBackgroundColour(row
, 0, backgroundColour
);
284 m_attributeEditorGrid
->SetCellBackgroundColour(row
, 1, backgroundColour
);
286 m_attributeEditorGrid
->SetCellValue(row
, 0, prop
->GetName());
288 m_attributeEditorGrid
->SetReadOnly(row
, 0);
290 m_attributeEditorGrid
->SetCellAlignment(row
, 1, wxALIGN_LEFT
, wxALIGN_CENTER
);
293 if (!m_item
->CanEditProperty(prop
->GetName()))
295 m_attributeEditorGrid
->SetReadOnly(row
, 1);
297 wxColour
col(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
));
298 m_attributeEditorGrid
->SetCellTextColour(row
, 1, col
);
302 m_attributeEditorGrid
->SetReadOnly(row
, 1, false);
303 m_attributeEditorGrid
->SetCellTextColour(row
, 1, * wxBLACK
);
307 m_attributeEditorGrid
->SetCellValue(row
, 1, ctConvertToSingleText(prop
->GetValue()));
312 // Set the value type
313 if (prop
->GetEditorType() == _T("choice"))
316 wxString
* strArr
= prop
->GetChoices().GetStringArray();
318 m_attributeEditorGrid
->SetCellEditor(row
, 1,
319 new wxGridCellChoiceEditor(prop
->GetChoices().GetCount(), strArr
));
323 m_attributeEditorGrid
->SetCellEditor(row
, 1,
324 new wxGridCellChoiceEditor(prop
->GetChoices()));
326 else if (prop
->GetEditorType() == _T("integer") || prop
->GetVariant().GetType() == _T("long"))
328 m_attributeEditorGrid
->SetCellEditor(row
, 1,
329 new wxGridCellNumberEditor
);
331 else if (prop
->GetEditorType() == _T("float") || prop
->GetVariant().GetType() == _T("double"))
333 m_attributeEditorGrid
->SetCellEditor(row
, 1,
334 new wxGridCellFloatEditor
);
336 else if (prop
->GetEditorType() == _T("bool") || prop
->GetVariant().GetType() == _T("bool"))
338 m_attributeEditorGrid
->SetCellValue(row
, 1, prop
->GetVariant().GetBool() ? _T("1") : _T("0"));
339 m_attributeEditorGrid
->SetCellEditor(row
, 1,
340 new wxGridCellBoolEditor
);
341 m_attributeEditorGrid
->SetCellRenderer(row
, 1, new wxGridCellBoolRenderer
);
345 m_attributeEditorGrid
->SetCellEditor(row
, 1,
346 new ctGridCellTextEditor
);
352 /// Display attribute value
353 bool ctPropertyEditor::DisplayProperty(ctProperty
* prop
)
358 int index
= m_item
->GetProperties().GetList().IndexOf(prop
);
359 return DisplayProperty(index
, prop
, true);
362 /// Display the default property
363 bool ctPropertyEditor::DisplayDefaultProperty()
368 wxString str
= m_item
->GetDefaultProperty();
370 ctProperty
* prop
= m_item
->GetProperties().FindProperty(str
);
373 int index
= m_item
->GetProperties().GetList().IndexOf(prop
);
374 this->m_attributeEditorGrid
->SelectRow(index
);
375 this->m_attributeEditorGrid
->SetGridCursor(index
, 1);
380 /// Edit the default property
381 bool ctPropertyEditor::EditDefaultProperty(ctConfigItem
* item
)
383 wxString defaultPropertyName
= item
->GetDefaultProperty();
384 if (!defaultPropertyName
.IsEmpty())
386 ctProperty
* prop
= item
->GetProperties().FindProperty(defaultPropertyName
);
389 int index
= item
->GetProperties().GetList().IndexOf(prop
);
392 this->m_attributeEditorGrid
->SelectRow(index
);
393 this->m_attributeEditorGrid
->SetGridCursor(index
, 1);
394 EditDetails(wxTheApp
->GetTopWindow());
403 /// Find the selected property
404 ctProperty
* ctPropertyEditor::FindSelectedProperty(int& row
)
409 int selRow
= m_attributeEditorGrid
->GetCursorRow();
414 if (selRow
< (int) m_item
->GetProperties().GetCount())
416 ctProperty
* prop
= m_item
->GetProperties().GetNth(selRow
);
423 /// Find the property
424 ctProperty
* ctPropertyEditor::FindProperty(int row
)
431 if (row
< (int) m_item
->GetProperties().GetCount())
433 ctProperty
* prop
= m_item
->GetProperties().GetNth(row
);
440 /// Edit the details of this cell appropriately.
441 bool ctPropertyEditor::EditDetails(wxWindow
* WXUNUSED(parent
))
443 if (CanEditDetails())
446 ctProperty
* prop
= FindSelectedProperty(row
);
450 wxString
type(prop
->GetEditorType());
451 wxString value
= m_attributeEditorGrid
->GetCellValue(row
, 1);
453 if (type
== _T("multiline"))
455 value
= ctConvertToMultilineText(value
);
457 msg
.Printf(wxT("Edit %s:"), (const wxChar
*) prop
->GetName());
458 ctMultiLineTextEditor
dialog(wxTheApp
->GetTopWindow(),
459 wxID_ANY
, wxT("Edit Text Property"), msg
, value
);
460 if (dialog
.ShowModal() == wxID_OK
)
462 value
= ctConvertToSingleText(dialog
.GetText());
463 m_attributeEditorGrid
->SetCellValue(row
, 1, value
);
464 ApplyCellValueToProperty(row
, 1);
470 else if (type
== _T("filename"))
472 wxString fullPath
= value
;
473 wxString defaultDir
;
474 wxString defaultFilename
= wxFileNameFromPath(fullPath
);
476 defaultDir
= wxPathOnly(value
);
478 wxString msg
= wxT("Choose a filename");
479 wxFileDialog
dialog(wxTheApp
->GetTopWindow(),
480 msg
, defaultDir
, defaultFilename
, wxT("*.*"));
481 if (dialog
.ShowModal() == wxID_OK
)
483 fullPath
= dialog
.GetPath();
486 m_attributeEditorGrid
->SetCellValue(row
, 1, value
);
487 ApplyCellValueToProperty(row
, 1);
493 else if (type
== _T("configitems"))
496 ctConfigItem::StringToArray(value
, items
);
498 ctConfigItemsSelector
dialog(wxTheApp
->GetTopWindow(),
499 wxID_ANY
, wxT("Select Configuration Items"));
500 dialog
.SetConfigList(items
);
501 if (dialog
.ShowModal() == wxID_OK
)
504 items
= dialog
.GetConfigList();
505 ctConfigItem::ArrayToString(items
, newValue
);
507 m_attributeEditorGrid
->SetCellValue(row
, 1, newValue
);
508 ApplyCellValueToProperty(row
, 1);
519 /// Intercept selection event.
520 void ctPropertyEditor::OnSelectCell(wxGridEvent
& event
)
522 int row
= event
.GetRow();
524 UpdateDescription(row
);
529 /// Update the description
530 void ctPropertyEditor::UpdateDescription(int row
)
534 row
= m_attributeEditorGrid
->GetCursorRow();
538 wxString str
= WrapDescription(wxEmptyString
);
539 m_propertyDescriptionWindow
->SetPage(str
);
543 ctProperty
* prop
= FindProperty(row
);
546 wxString str
= WrapDescription(m_item
->GetDescription(prop
));
547 m_propertyDescriptionWindow
->SetPage(str
);
552 /// Wraps a description string in HTML
553 wxString
ctPropertyEditor::WrapDescription(const wxString
& s
)
555 /// Convert a colour to a 6-digit hex string
556 wxColour col
= ctDESCRIPTION_BACKGROUND_COLOUR
;
557 wxString colStr
= apColourToHexString(col
);
558 colStr
= wxT("#") + colStr
;
561 str
<< _T("<HTML><BODY BGCOLOR=\"") << colStr
<< wxT("\"><FONT SIZE=-1>") ;
563 str
<< _T("</FONT></BODY></HTML>");
568 /// Intercept cell data change event.
569 void ctPropertyEditor::OnChangeCell(wxGridEvent
& event
)
571 int row
= event
.GetRow();
572 int col
= event
.GetCol();
574 ApplyCellValueToProperty(row
, col
);
577 /// Double-click to show specialised editor.
578 void ctPropertyEditor::OnDClickCell(wxGridEvent
& WXUNUSED(event
))
580 wxWindow
* parentFrame
= this;
581 while (parentFrame
&& !parentFrame
->IsKindOf(CLASSINFO(wxFrame
)))
582 parentFrame
= parentFrame
->GetParent();
584 EditDetails(parentFrame
);
587 /// Apply the cell value to the property, and notify the
589 void ctPropertyEditor::ApplyCellValueToProperty(int row
, int col
)
591 static bool s_Applying
= false;
597 if (col
== 1 && m_item
)
599 ctProperty
* prop
= m_item
->GetProperties().GetNth(row
);
601 wxString value
= m_attributeEditorGrid
->GetCellValue(row
, col
);
602 if (prop
->GetEditorType() == wxT("multiline"))
603 value
= ctConvertToMultilineText(value
);
605 wxVariant variant
= prop
->GetVariant();
607 if (prop
->GetVariant().GetType() == _T("bool"))
609 if (value
== _T("1"))
614 else if (prop
->GetVariant().GetType() == _T("long"))
620 else if (prop
->GetVariant().GetType() == _T("double"))
631 ApplyPropertyValue(m_item
, prop
, variant
);
633 if (prop
->GetName() == _T("description"))
634 UpdateDescription(row
);
639 /// Apply the cell value to the property, and notify the
641 void ctPropertyEditor::ApplyPropertyValue(ctConfigItem
* item
, ctProperty
* property
, const wxVariant
& variant
)
643 static bool s_Applying
= false;
650 // Save the old values
651 ctProperties
* oldProperties
= new ctProperties(item
->GetProperties());
653 wxVariant oldValue
= property
->GetVariant();
655 // Apply the new value
656 property
->GetVariant() = variant
;
657 item
->ApplyProperty(property
, oldValue
);
662 wxString
menuLabel(_T("Change ") + property
->GetName());
664 // This won't do anything first time Do is applied,
665 // since we've already done the action for this property.
666 // But when we Undo or Redo, the changed properties will be applied.
667 item
->GetDocument()->GetCommandProcessor()->Submit(
668 new ctConfigCommand(menuLabel
, ctCMD_APPLY_PROPERTY
,
669 item
, oldProperties
, true));
675 * Attribute editor grid
678 IMPLEMENT_CLASS(ctPropertyEditorGrid
, wxGrid
)
680 BEGIN_EVENT_TABLE(ctPropertyEditorGrid
, wxGrid
)
681 EVT_SIZE(ctPropertyEditorGrid::OnSize
)
684 ctPropertyEditorGrid::ctPropertyEditorGrid(wxWindow
* parent
, wxWindowID id
,
686 const wxSize
& sz
, long style
):
687 wxGrid(parent
, id
, pos
, sz
, style
)
690 m_stretchableColumn
= -1;
693 void ctPropertyEditorGrid::OnSize(wxSizeEvent
& event
)
695 if (m_stretchableColumn
!= -1)
697 // This window's client size = the internal window's
698 // client size if it has no borders
699 wxSize sz
= GetClientSize();
703 for (i
= 0; i
< GetNumberCols(); i
++)
705 if (i
!= m_stretchableColumn
)
707 totalSize
+= GetColSize(i
);
711 // Allow for grid lines
714 int stretchSize
= wxMax(5, sz
.x
- totalSize
);
715 SetColSize(m_stretchableColumn
, stretchSize
);
721 /// Use m_columnsToDisplay to set the label strings
722 void ctPropertyEditorGrid::DisplayLabels()
725 for (i
= 0; i
< m_columnsToDisplay
.GetCount(); i
++)
727 SetColLabelValue(i
, m_columnsToDisplay
[i
]);
732 bool ctPropertyEditorGrid::ClearAttributes()
734 if (GetNumberRows() > 0)
735 DeleteRows(0, GetNumberRows());
740 * Use a single-line text control.
743 void ctGridCellTextEditor::Create(wxWindow
* parent
, wxWindowID id
,
744 wxEvtHandler
* evtHandler
)
746 m_control
= new wxTextCtrl(parent
, id
, wxEmptyString
,
747 wxDefaultPosition
, wxDefaultSize
750 wxGridCellEditor::Create(parent
, id
, evtHandler
);
754 /// Translate the value to one which can be edited in a single-line
756 wxString
ctConvertToSingleText(const wxString
& value
)
758 wxString
value1(value
);
759 value1
.Replace(wxT("\n"), wxT("\\n"));
760 value1
.Replace(wxT("\t"), wxT("\\t"));
764 /// Translate back to 'real' characters, i.e. newlines are real
766 wxString
ctConvertToMultilineText(const wxString
& value
)
768 wxString
value1(value
);
769 value1
.Replace(wxT("\\n"), wxT("\n"));
770 value1
.Replace(wxT("\\t"), wxT("\t"));
774 //----------------------------------------------------------------------------
775 // ctMultiLineTextEditor
776 //----------------------------------------------------------------------------
778 BEGIN_EVENT_TABLE(ctMultiLineTextEditor
, wxDialog
)
781 ctMultiLineTextEditor::ctMultiLineTextEditor( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
783 const wxString
& value
,
787 wxDialog(parent
, id
, title
, pos
, size
, style
)
790 AddControls(this, msg
);
794 bool ctMultiLineTextEditor::AddControls(wxWindow
* parent
, const wxString
& msg
)
796 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
798 wxBoxSizer
*item1
= new wxBoxSizer( wxVERTICAL
);
800 wxStaticText
*item2
= new wxStaticText( parent
, wxID_STATIC
, msg
, wxDefaultPosition
, wxDefaultSize
, 0 );
801 item1
->Add( item2
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxLEFT
|wxRIGHT
, 5 );
803 wxTextCtrl
*item3
= new wxTextCtrl( parent
, wxID_ANY
, wxEmptyString
, wxDefaultPosition
, wxSize(330,180), wxTE_MULTILINE
|wxTE_RICH
);
804 item1
->Add( item3
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
806 wxBoxSizer
*item4
= new wxBoxSizer( wxHORIZONTAL
);
808 item4
->Add( 5, 5, 1, wxALIGN_CENTRE
|wxALL
, 5 );
810 wxButton
*item5
= new wxButton( parent
, wxID_OK
, _("&OK"), wxDefaultPosition
, wxDefaultSize
, 0 );
812 item4
->Add( item5
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
814 wxButton
*item6
= new wxButton( parent
, wxID_CANCEL
, _("&Cancel"), wxDefaultPosition
, wxDefaultSize
, 0 );
815 item4
->Add( item6
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
817 item1
->Add( item4
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
819 item0
->Add( item1
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
821 item3
->SetValue(m_text
);
822 item3
->SetValidator(wxGenericValidator(& m_text
));
826 ((wxButton
*) FindWindow(wxID_OK
))->SetDefault();
828 parent
->SetSizer(item0
);
835 * Special-purpose splitter window for changing sash look and
836 * also saving sash width
839 BEGIN_EVENT_TABLE(ctSplitterWindow
, wxSplitterWindow
)
840 EVT_SPLITTER_SASH_POS_CHANGED(wxID_ANY
, ctSplitterWindow::OnChangeSash
)
843 ctSplitterWindow::ctSplitterWindow(wxWindow
* parent
, wxWindowID id
,
844 const wxPoint
& pos
, const wxSize
& size
, long style
):
845 wxSplitterWindow(parent
, id
, pos
, size
, style
)
847 m_updateSettings
= false;
851 void ctSplitterWindow::OnChangeSash(wxSplitterEvent
& event
)
853 if (!m_updateSettings
)
856 m_position
= event
.GetSashPosition();