1 /////////////////////////////////////////////////////////////////////////////
2 // Name: propeditor.cpp
3 // Purpose: wxWindows Configuration Tool property editor
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
10 /////////////////////////////////////////////////////////////////////////////
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, -1, 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..."), wxDefaultPosition
, wxSize(-1, -1));
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->SetAutoLayout( TRUE
);
103 this->SetSizer( item0
);
106 m_elementTitleTextCtrl
->SetHelpText(_("The title of the property being edited."));
107 FindWindow(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS
)->SetHelpText(_("Click to use an appropriate editor for the selected property (if any)."));
108 FindWindow(ctID_ATTRIBUTE_EDITOR_GRID
)->SetHelpText(_("Shows the properties of the selected item."));
109 FindWindow(ctID_ATTRIBUTE_EDITOR_DESCRIPTION
)->SetHelpText(_("Shows a description of the selected property, or a summary of the whole item."));
111 /// Set up the grid to display properties
112 m_attributeEditorGrid
->RegisterDataType(ctGRID_VALUE_STRING
,
113 new wxGridCellStringRenderer
,
114 new ctGridCellTextEditor
);
116 m_attributeEditorGrid
->CreateGrid( 0, 2, wxGrid::wxGridSelectRows
);
117 m_attributeEditorGrid
->SetRowLabelSize(0);
118 m_attributeEditorGrid
->SetColLabelSize(0 /* 18 */);
120 wxArrayString columns
;
121 columns
.Add(_T("Name"));
122 columns
.Add(_T("Value"));
124 m_attributeEditorGrid
->SetColSize(0, 140);
125 m_attributeEditorGrid
->SetColSize(1, 80);
127 m_attributeEditorGrid
->SetColumnsToDisplay(columns
);
128 m_attributeEditorGrid
->DisplayLabels();
130 m_attributeEditorGrid
->SetStretchableColumn(1);
132 m_attributeEditorGrid
->SetDefaultCellBackgroundColour(ctCELL_BACKGROUND_COLOUR
);
137 /// Show/hide the description control
138 void ctPropertyEditor::ShowDescriptionWindow(bool show
)
142 if (m_splitterWindow
->IsSplit())
143 m_splitterWindow
->Unsplit(m_propertyDescriptionWindow
);
149 m_propertyDescriptionWindow
->Show(TRUE
);
150 if (!m_splitterWindow
->IsSplit())
152 m_splitterWindow
->SplitHorizontally(m_propertyDescriptionWindow
, m_attributeEditorGrid
, pos
);
157 /// Clear grid editor
158 void ctPropertyEditor::ClearEditor()
160 m_attributeEditorGrid
->ClearAttributes();
161 m_propertyDescriptionWindow
->SetPage(WrapDescription(wxEmptyString
));
162 m_elementTitleTextCtrl
->SetValue(_T(""));
165 /// Handles detailed editing event.
166 void ctPropertyEditor::OnEditDetails(wxCommandEvent
& event
)
168 wxWindow
* parentFrame
= this;
169 while (parentFrame
&& !parentFrame
->IsKindOf(CLASSINFO(wxFrame
)))
170 parentFrame
= parentFrame
->GetParent();
172 EditDetails(parentFrame
);
175 /// Handles detailed editing update event.
176 void ctPropertyEditor::OnUpdateEditDetails(wxUpdateUIEvent
& event
)
178 event
.Enable(CanEditDetails());
181 /// Can we edit the details of the selected property?
182 bool ctPropertyEditor::CanEditDetails()
188 ctProperty
* prop
= FindSelectedProperty(row
);
189 if (!prop
|| prop
->GetEditorType().IsEmpty())
195 void ctPropertyEditor::ShowItem(ctConfigItem
* item
)
197 if (m_attributeEditorGrid
->IsCellEditControlEnabled())
198 m_attributeEditorGrid
->SaveEditControlValue();
207 m_attributeEditorGrid
->AppendRows(m_item
->GetProperties().GetCount());
209 wxNode
* node
= m_item
->GetProperties().GetList().GetFirst();
213 ctProperty
* prop
= (ctProperty
*) node
->GetData();
214 DisplayProperty(i
, prop
);
217 node
= node
->GetNext();
219 // Make sure scrollbars are up-to-date, etc.
220 wxSizeEvent
event(m_attributeEditorGrid
->GetSize(), m_attributeEditorGrid
->GetId());
221 m_attributeEditorGrid
->GetEventHandler()->ProcessEvent(event
);
223 DisplayDefaultProperty();
231 /// Determine background colour for this property.
232 void ctPropertyEditor::DeterminePropertyColour(ctProperty
* prop
, wxColour
& colour
)
234 if (prop
->IsCustom())
235 colour
= ctCUSTOM_CELL_BACKGROUND_COLOUR
;
237 colour
= ctCELL_BACKGROUND_COLOUR
;
240 /// Update the title at the top of the property editor
241 void ctPropertyEditor::UpdateTitle()
245 wxString
name(m_item
->GetTitle());
246 m_elementTitleTextCtrl
->SetValue(name
);
250 /// Updates the item display, assuming it was already displayed.
251 void ctPropertyEditor::UpdateItem()
253 if (m_attributeEditorGrid
->IsCellEditControlEnabled())
254 m_attributeEditorGrid
->SaveEditControlValue();
259 wxNode
* node
= m_item
->GetProperties().GetList().GetFirst();
263 ctProperty
* prop
= (ctProperty
*) node
->GetData();
264 DisplayProperty(i
, prop
, TRUE
);
267 node
= node
->GetNext();
269 // Make sure scrollbars are up-to-date, etc.
270 wxSizeEvent
event(m_attributeEditorGrid
->GetSize(), this->GetId());
271 m_attributeEditorGrid
->GetEventHandler()->ProcessEvent(event
);
275 /// Display attribute at given row
276 bool ctPropertyEditor::DisplayProperty(int row
, ctProperty
* prop
, bool valueOnly
)
278 wxColour backgroundColour
;
280 DeterminePropertyColour(prop
, backgroundColour
);
284 m_attributeEditorGrid
->SetCellBackgroundColour(row
, 0, backgroundColour
);
285 m_attributeEditorGrid
->SetCellBackgroundColour(row
, 1, backgroundColour
);
287 m_attributeEditorGrid
->SetCellValue(row
, 0, prop
->GetName());
289 m_attributeEditorGrid
->SetReadOnly(row
, 0);
291 m_attributeEditorGrid
->SetCellAlignment(row
, 1, wxALIGN_LEFT
, wxALIGN_CENTER
);
294 if (!m_item
->CanEditProperty(prop
->GetName()))
296 m_attributeEditorGrid
->SetReadOnly(row
, 1);
298 wxColour
col(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT
));
299 m_attributeEditorGrid
->SetCellTextColour(row
, 1, col
);
303 m_attributeEditorGrid
->SetReadOnly(row
, 1, FALSE
);
304 m_attributeEditorGrid
->SetCellTextColour(row
, 1, * wxBLACK
);
308 m_attributeEditorGrid
->SetCellValue(row
, 1, ctConvertToSingleText(prop
->GetValue()));
313 // Set the value type
314 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 else if (prop
->GetEditorType() == _T("integer") || prop
->GetVariant().GetType() == _T("long"))
325 m_attributeEditorGrid
->SetCellEditor(row
, 1,
326 new wxGridCellNumberEditor
);
328 else if (prop
->GetEditorType() == _T("float") || prop
->GetVariant().GetType() == _T("double"))
330 m_attributeEditorGrid
->SetCellEditor(row
, 1,
331 new wxGridCellFloatEditor
);
333 else if (prop
->GetEditorType() == _T("bool") || prop
->GetVariant().GetType() == _T("bool"))
335 m_attributeEditorGrid
->SetCellValue(row
, 1, prop
->GetVariant().GetBool() ? _T("1") : _T("0"));
336 m_attributeEditorGrid
->SetCellEditor(row
, 1,
337 new wxGridCellBoolEditor
);
338 m_attributeEditorGrid
->SetCellRenderer(row
, 1, new wxGridCellBoolRenderer
);
342 m_attributeEditorGrid
->SetCellEditor(row
, 1,
343 new ctGridCellTextEditor
);
349 /// Display attribute value
350 bool ctPropertyEditor::DisplayProperty(ctProperty
* prop
)
355 int index
= m_item
->GetProperties().GetList().IndexOf(prop
);
356 return DisplayProperty(index
, prop
, TRUE
);
359 /// Display the default property
360 bool ctPropertyEditor::DisplayDefaultProperty()
365 wxString str
= m_item
->GetDefaultProperty();
367 ctProperty
* prop
= m_item
->GetProperties().FindProperty(str
);
370 int index
= m_item
->GetProperties().GetList().IndexOf(prop
);
371 this->m_attributeEditorGrid
->SelectRow(index
);
372 this->m_attributeEditorGrid
->SetGridCursor(index
, 1);
377 /// Edit the default property
378 bool ctPropertyEditor::EditDefaultProperty(ctConfigItem
* item
)
380 wxString defaultPropertyName
= item
->GetDefaultProperty();
381 if (!defaultPropertyName
.IsEmpty())
383 ctProperty
* prop
= item
->GetProperties().FindProperty(defaultPropertyName
);
386 int index
= item
->GetProperties().GetList().IndexOf(prop
);
389 this->m_attributeEditorGrid
->SelectRow(index
);
390 this->m_attributeEditorGrid
->SetGridCursor(index
, 1);
391 EditDetails(wxTheApp
->GetTopWindow());
400 /// Find the selected property
401 ctProperty
* ctPropertyEditor::FindSelectedProperty(int& row
)
406 int selRow
= m_attributeEditorGrid
->GetCursorRow();
411 if (selRow
< (int) m_item
->GetProperties().GetCount())
413 ctProperty
* prop
= m_item
->GetProperties().GetNth(selRow
);
420 /// Find the property
421 ctProperty
* ctPropertyEditor::FindProperty(int row
)
428 if (row
< (int) m_item
->GetProperties().GetCount())
430 ctProperty
* prop
= m_item
->GetProperties().GetNth(row
);
437 /// Edit the details of this cell appropriately.
438 bool ctPropertyEditor::EditDetails(wxWindow
* parent
)
440 if (CanEditDetails())
443 ctProperty
* prop
= FindSelectedProperty(row
);
447 wxString
type(prop
->GetEditorType());
448 wxString value
= m_attributeEditorGrid
->GetCellValue(row
, 1);
450 if (type
== _T("multiline"))
452 value
= ctConvertToMultilineText(value
);
454 msg
.Printf(wxT("Edit %s:"), (const wxChar
*) prop
->GetName());
455 ctMultiLineTextEditor
dialog(wxTheApp
->GetTopWindow(),
456 -1, wxT("Edit Text Property"), msg
, value
);
457 if (dialog
.ShowModal() == wxID_OK
)
459 value
= ctConvertToSingleText(dialog
.GetText());
460 m_attributeEditorGrid
->SetCellValue(row
, 1, value
);
461 ApplyCellValueToProperty(row
, 1);
467 else if (type
== _T("filename"))
469 wxString fullPath
= value
;
470 wxString defaultDir
;
471 wxString defaultFilename
= wxFileNameFromPath(fullPath
);
473 defaultDir
= wxPathOnly(value
);
475 wxString msg
= wxT("Choose a filename");
476 wxFileDialog
dialog(wxTheApp
->GetTopWindow(),
477 msg
, defaultDir
, defaultFilename
, wxT("*.*"));
478 if (dialog
.ShowModal() == wxID_OK
)
480 fullPath
= dialog
.GetPath();
483 m_attributeEditorGrid
->SetCellValue(row
, 1, value
);
484 ApplyCellValueToProperty(row
, 1);
490 else if (type
== _T("configitems"))
493 ctConfigItem::StringToArray(value
, items
);
495 ctConfigItemsSelector
dialog(wxTheApp
->GetTopWindow(),
496 -1, wxT("Select Configuration Items"));
497 dialog
.SetConfigList(items
);
498 if (dialog
.ShowModal() == wxID_OK
)
501 items
= dialog
.GetConfigList();
502 ctConfigItem::ArrayToString(items
, newValue
);
504 m_attributeEditorGrid
->SetCellValue(row
, 1, newValue
);
505 ApplyCellValueToProperty(row
, 1);
516 /// Intercept selection event.
517 void ctPropertyEditor::OnSelectCell(wxGridEvent
& event
)
519 int row
= event
.GetRow();
521 UpdateDescription(row
);
526 /// Update the description
527 void ctPropertyEditor::UpdateDescription(int row
)
531 row
= m_attributeEditorGrid
->GetCursorRow();
535 wxString str
= WrapDescription(wxEmptyString
);
536 m_propertyDescriptionWindow
->SetPage(str
);
540 ctProperty
* prop
= FindProperty(row
);
543 wxString str
= WrapDescription(m_item
->GetDescription(prop
));
544 m_propertyDescriptionWindow
->SetPage(str
);
549 /// Wraps a description string in HTML
550 wxString
ctPropertyEditor::WrapDescription(const wxString
& s
)
552 /// Convert a colour to a 6-digit hex string
553 wxColour col
= ctDESCRIPTION_BACKGROUND_COLOUR
;
554 wxString colStr
= apColourToHexString(col
);
555 colStr
= wxT("#") + colStr
;
558 str
<< _T("<HTML><BODY BGCOLOR=\"") << colStr
<< wxT("\"><FONT SIZE=-1>") ;
560 str
<< _T("</FONT></BODY></HTML>");
565 /// Intercept cell data change event.
566 void ctPropertyEditor::OnChangeCell(wxGridEvent
& event
)
568 int row
= event
.GetRow();
569 int col
= event
.GetCol();
571 ApplyCellValueToProperty(row
, col
);
574 /// Double-click to show specialised editor.
575 void ctPropertyEditor::OnDClickCell(wxGridEvent
& event
)
577 wxWindow
* parentFrame
= this;
578 while (parentFrame
&& !parentFrame
->IsKindOf(CLASSINFO(wxFrame
)))
579 parentFrame
= parentFrame
->GetParent();
581 EditDetails(parentFrame
);
584 /// Apply the cell value to the property, and notify the
586 void ctPropertyEditor::ApplyCellValueToProperty(int row
, int col
)
588 static bool s_Applying
= FALSE
;
594 if (col
== 1 && m_item
)
596 ctProperty
* prop
= m_item
->GetProperties().GetNth(row
);
598 wxString value
= m_attributeEditorGrid
->GetCellValue(row
, col
);
599 if (prop
->GetEditorType() == wxT("multiline"))
600 value
= ctConvertToMultilineText(value
);
602 wxVariant variant
= prop
->GetVariant();
604 if (prop
->GetVariant().GetType() == _T("bool"))
606 if (value
== _T("1"))
607 variant
= (bool) TRUE
;
609 variant
= (bool) FALSE
;
611 else if (prop
->GetVariant().GetType() == _T("long"))
617 else if (prop
->GetVariant().GetType() == _T("double"))
628 ApplyPropertyValue(m_item
, prop
, variant
);
630 if (prop
->GetName() == _T("description"))
631 UpdateDescription(row
);
636 /// Apply the cell value to the property, and notify the
638 void ctPropertyEditor::ApplyPropertyValue(ctConfigItem
* item
, ctProperty
* property
, const wxVariant
& variant
)
640 static bool s_Applying
= FALSE
;
647 // Save the old values
648 ctProperties
* oldProperties
= new ctProperties(item
->GetProperties());
650 wxVariant oldValue
= property
->GetVariant();
652 // Apply the new value
653 property
->GetVariant() = variant
;
654 item
->ApplyProperty(property
, oldValue
);
659 wxString
menuLabel(_T("Change ") + property
->GetName());
661 // This won't do anything first time Do is applied,
662 // since we've already done the action for this property.
663 // But when we Undo or Redo, the changed properties will be applied.
664 item
->GetDocument()->GetCommandProcessor()->Submit(
665 new ctConfigCommand(menuLabel
, ctCMD_APPLY_PROPERTY
,
666 item
, oldProperties
, TRUE
));
672 * Attribute editor grid
675 IMPLEMENT_CLASS(ctPropertyEditorGrid
, wxGrid
)
677 BEGIN_EVENT_TABLE(ctPropertyEditorGrid
, wxGrid
)
678 EVT_SIZE(ctPropertyEditorGrid::OnSize
)
681 ctPropertyEditorGrid::ctPropertyEditorGrid(wxWindow
* parent
, wxWindowID id
,
683 const wxSize
& sz
, long style
):
684 wxGrid(parent
, id
, pos
, sz
, style
)
687 m_stretchableColumn
= -1;
690 void ctPropertyEditorGrid::OnSize(wxSizeEvent
& event
)
692 if (m_stretchableColumn
!= -1)
694 // This window's client size = the internal window's
695 // client size if it has no borders
696 wxSize sz
= GetClientSize();
700 for (i
= 0; i
< GetNumberCols(); i
++)
702 if (i
!= m_stretchableColumn
)
704 totalSize
+= GetColSize(i
);
708 // Allow for grid lines
711 int stretchSize
= wxMax(5, sz
.x
- totalSize
);
712 SetColSize(m_stretchableColumn
, stretchSize
);
718 /// Use m_columnsToDisplay to set the label strings
719 void ctPropertyEditorGrid::DisplayLabels()
722 for (i
= 0; i
< m_columnsToDisplay
.GetCount(); i
++)
724 SetColLabelValue(i
, m_columnsToDisplay
[i
]);
729 bool ctPropertyEditorGrid::ClearAttributes()
731 if (GetNumberRows() > 0)
732 DeleteRows(0, GetNumberRows());
737 * Use a single-line text control.
740 void ctGridCellTextEditor::Create(wxWindow
* parent
, wxWindowID id
,
741 wxEvtHandler
* evtHandler
)
743 m_control
= new wxTextCtrl(parent
, id
, wxEmptyString
,
744 wxDefaultPosition
, wxDefaultSize
747 wxGridCellEditor::Create(parent
, id
, evtHandler
);
751 /// Translate the value to one which can be edited in a single-line
753 wxString
ctConvertToSingleText(const wxString
& value
)
755 wxString
value1(value
);
756 value1
.Replace(wxT("\n"), wxT("\\n"));
757 value1
.Replace(wxT("\t"), wxT("\\t"));
761 /// Translate back to 'real' characters, i.e. newlines are real
763 wxString
ctConvertToMultilineText(const wxString
& value
)
765 wxString
value1(value
);
766 value1
.Replace(wxT("\\n"), wxT("\n"));
767 value1
.Replace(wxT("\\t"), wxT("\t"));
771 //----------------------------------------------------------------------------
772 // ctMultiLineTextEditor
773 //----------------------------------------------------------------------------
775 BEGIN_EVENT_TABLE(ctMultiLineTextEditor
, wxDialog
)
778 ctMultiLineTextEditor::ctMultiLineTextEditor( wxWindow
*parent
, wxWindowID id
, const wxString
&title
,
780 const wxString
& value
,
784 wxDialog(parent
, id
, title
, pos
, size
, style
)
787 AddControls(this, msg
);
791 bool ctMultiLineTextEditor::AddControls(wxWindow
* parent
, const wxString
& msg
)
793 wxBoxSizer
*item0
= new wxBoxSizer( wxVERTICAL
);
795 wxBoxSizer
*item1
= new wxBoxSizer( wxVERTICAL
);
797 wxStaticText
*item2
= new wxStaticText( parent
, wxID_STATIC
, msg
, wxDefaultPosition
, wxDefaultSize
, 0 );
798 item1
->Add( item2
, 0, wxALIGN_CENTER_VERTICAL
|wxTOP
|wxLEFT
|wxRIGHT
, 5 );
800 wxTextCtrl
*item3
= new wxTextCtrl( parent
, -1, wxT(""), wxDefaultPosition
, wxSize(330,180), wxTE_MULTILINE
|wxTE_RICH
);
801 item1
->Add( item3
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
803 wxBoxSizer
*item4
= new wxBoxSizer( wxHORIZONTAL
);
805 item4
->Add( 5, 5, 1, wxALIGN_CENTRE
|wxALL
, 5 );
807 wxButton
*item5
= new wxButton( parent
, wxID_OK
, _("&OK"), wxDefaultPosition
, wxDefaultSize
, 0 );
809 item4
->Add( item5
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
811 wxButton
*item6
= new wxButton( parent
, wxID_CANCEL
, _("&Cancel"), wxDefaultPosition
, wxDefaultSize
, 0 );
812 item4
->Add( item6
, 0, wxALIGN_CENTRE
|wxALL
, 5 );
814 item1
->Add( item4
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
, 5 );
816 item0
->Add( item1
, 1, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
818 item3
->SetValue(m_text
);
819 item3
->SetValidator(wxGenericValidator(& m_text
));
823 ((wxButton
*) FindWindow(wxID_OK
))->SetDefault();
825 parent
->SetAutoLayout( TRUE
);
826 parent
->SetSizer(item0
);
833 * Special-purpose splitter window for changing sash look and
834 * also saving sash width
837 BEGIN_EVENT_TABLE(ctSplitterWindow
, wxSplitterWindow
)
838 EVT_SPLITTER_SASH_POS_CHANGED(-1, ctSplitterWindow::OnChangeSash
)
841 ctSplitterWindow::ctSplitterWindow(wxWindow
* parent
, wxWindowID id
,
842 const wxPoint
& pos
, const wxSize
& size
, long style
):
843 wxSplitterWindow(parent
, id
, pos
, size
, style
)
845 m_updateSettings
= FALSE
;
849 void ctSplitterWindow::OnChangeSash(wxSplitterEvent
& event
)
851 if (!m_updateSettings
)
854 m_position
= event
.GetSashPosition();