X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/71ada1a5fbecf774be6cb7ab7421a8f784d6c84c..08b97268061292f7c3794dae243a6490b23a42f1:/utils/configtool/src/propeditor.cpp diff --git a/utils/configtool/src/propeditor.cpp b/utils/configtool/src/propeditor.cpp index d45415fe2f..286f9d438e 100644 --- a/utils/configtool/src/propeditor.cpp +++ b/utils/configtool/src/propeditor.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: propeditor.cpp -// Purpose: wxWindows Configuration Tool property editor +// Purpose: wxWidgets Configuration Tool property editor // Author: Julian Smart // Modified by: // Created: 2003-06-03 @@ -9,27 +9,29 @@ // Licence: ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "propeditor.h" -#endif - -#include +// For compilers that support precompilation, includes "wx/wx.h". +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif -#include "wx/html/htmlwin.h" +#ifndef WX_PRECOMP + #include "wx/grid.h" #include "wx/filedlg.h" + +#endif + +#include "wx/html/htmlwin.h" #include "wx/tokenzr.h" #include "wx/valgen.h" - #include "propeditor.h" #include "symbols.h" #include "utils.h" #include "configtooldoc.h" #include "configitemselector.h" + #include "bitmaps/ellipsis.xpm" @@ -59,13 +61,9 @@ ctPropertyEditor::ctPropertyEditor(wxWindow *parent, wxWindowID id, const wxPoin CreateControls(this); } -ctPropertyEditor::~ctPropertyEditor() -{ -} - void ctPropertyEditor::CreateControls(wxWindow* parent) { - m_elementTitleTextCtrl = new wxTextCtrl(this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); + m_elementTitleTextCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY); wxBitmap detailsIcon(ellipsis_xpm); wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); @@ -75,8 +73,8 @@ void ctPropertyEditor::CreateControls(wxWindow* parent) wxTextCtrl *item2 = m_elementTitleTextCtrl; item1->Add( item2, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - wxButton *item3a = new wxButton( parent, ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS, wxT("Edit..."), wxDefaultPosition, wxSize(-1, -1)); - item1->Add( item3a, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); + m_attributeEditorEditDetails = new wxButton( parent, ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS, wxT("Edit...")); + item1->Add( m_attributeEditorEditDetails, 0, wxALIGN_CENTRE|wxRIGHT|wxTOP|wxBOTTOM, 5 ); item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 ); @@ -95,18 +93,17 @@ void ctPropertyEditor::CreateControls(wxWindow* parent) // TODO: show or hide description window // if (some-setting) -// ShowDescriptionWindow(FALSE); +// ShowDescriptionWindow(false); item0->Add( m_splitterWindow, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT|wxBOTTOM, 5 ); - this->SetAutoLayout( TRUE ); this->SetSizer( item0 ); /// Add help text m_elementTitleTextCtrl->SetHelpText(_("The title of the property being edited.")); - FindWindow(ctID_ATTRIBUTE_EDITOR_EDIT_DETAILS)->SetHelpText(_("Click to use an appropriate editor for the selected property (if any).")); - FindWindow(ctID_ATTRIBUTE_EDITOR_GRID)->SetHelpText(_("Shows the properties of the selected item.")); - FindWindow(ctID_ATTRIBUTE_EDITOR_DESCRIPTION)->SetHelpText(_("Shows a description of the selected property, or a summary of the whole item.")); + m_attributeEditorEditDetails->SetHelpText(_("Click to use an appropriate editor for the selected property (if any).")); + m_attributeEditorGrid->SetHelpText(_("Shows the properties of the selected item.")); + m_propertyDescriptionWindow->SetHelpText(_("Shows a description of the selected property, or a summary of the whole item.")); /// Set up the grid to display properties m_attributeEditorGrid->RegisterDataType(ctGRID_VALUE_STRING, @@ -146,7 +143,7 @@ void ctPropertyEditor::ShowDescriptionWindow(bool show) { // TODO int pos = 100; - m_propertyDescriptionWindow->Show(TRUE); + m_propertyDescriptionWindow->Show(true); if (!m_splitterWindow->IsSplit()) { m_splitterWindow->SplitHorizontally(m_propertyDescriptionWindow, m_attributeEditorGrid, pos); @@ -159,7 +156,7 @@ void ctPropertyEditor::ClearEditor() { m_attributeEditorGrid->ClearAttributes(); m_propertyDescriptionWindow->SetPage(WrapDescription(wxEmptyString)); - m_elementTitleTextCtrl->SetValue(_T("")); + m_elementTitleTextCtrl->SetValue(wxEmptyString); } /// Handles detailed editing event. @@ -182,13 +179,13 @@ void ctPropertyEditor::OnUpdateEditDetails(wxUpdateUIEvent& event) bool ctPropertyEditor::CanEditDetails() { if (!m_item) - return FALSE; + return false; int row; ctProperty* prop = FindSelectedProperty(row); - if (!prop || prop->GetEditorType().IsEmpty()) - return FALSE; - return TRUE; + if (!prop || prop->GetEditorType().empty()) + return false; + return true; } /// Shows the item @@ -206,7 +203,7 @@ void ctPropertyEditor::ShowItem(ctConfigItem* item) m_attributeEditorGrid->AppendRows(m_item->GetProperties().GetCount()); - wxNode* node = m_item->GetProperties().GetList().GetFirst(); + wxObjectList::compatibility_iterator node = m_item->GetProperties().GetList().GetFirst(); int i = 0; while (node) { @@ -256,12 +253,12 @@ void ctPropertyEditor::UpdateItem() { UpdateTitle(); - wxNode* node = m_item->GetProperties().GetList().GetFirst(); + wxObjectList::compatibility_iterator node = m_item->GetProperties().GetList().GetFirst(); int i = 0; while (node) { ctProperty* prop = (ctProperty*) node->GetData(); - DisplayProperty(i, prop, TRUE); + DisplayProperty(i, prop, true); i ++; node = node->GetNext(); @@ -294,13 +291,13 @@ bool ctPropertyEditor::DisplayProperty(int row, ctProperty* prop, bool valueOnly if (!m_item->CanEditProperty(prop->GetName())) { m_attributeEditorGrid->SetReadOnly(row, 1); - + wxColour col(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT)); m_attributeEditorGrid->SetCellTextColour(row, 1, col); } else { - m_attributeEditorGrid->SetReadOnly(row, 1, FALSE); + m_attributeEditorGrid->SetReadOnly(row, 1, false); m_attributeEditorGrid->SetCellTextColour(row, 1, * wxBLACK); } @@ -308,7 +305,7 @@ bool ctPropertyEditor::DisplayProperty(int row, ctProperty* prop, bool valueOnly m_attributeEditorGrid->SetCellValue(row, 1, ctConvertToSingleText(prop->GetValue())); if (valueOnly) - return TRUE; + return true; // Set the value type if (prop->GetEditorType() == _T("choice")) @@ -346,25 +343,25 @@ bool ctPropertyEditor::DisplayProperty(int row, ctProperty* prop, bool valueOnly m_attributeEditorGrid->SetCellEditor(row, 1, new ctGridCellTextEditor); } - - return TRUE; + + return true; } /// Display attribute value bool ctPropertyEditor::DisplayProperty(ctProperty* prop) { if (!m_item) - return FALSE; + return false; int index = m_item->GetProperties().GetList().IndexOf(prop); - return DisplayProperty(index, prop, TRUE); + return DisplayProperty(index, prop, true); } /// Display the default property bool ctPropertyEditor::DisplayDefaultProperty() { if (!m_item) - return FALSE; + return false; wxString str = m_item->GetDefaultProperty(); @@ -375,14 +372,14 @@ bool ctPropertyEditor::DisplayDefaultProperty() this->m_attributeEditorGrid->SelectRow(index); this->m_attributeEditorGrid->SetGridCursor(index, 1); } - return TRUE; + return true; } /// Edit the default property bool ctPropertyEditor::EditDefaultProperty(ctConfigItem* item) { wxString defaultPropertyName = item->GetDefaultProperty(); - if (!defaultPropertyName.IsEmpty()) + if (!defaultPropertyName.empty()) { ctProperty* prop = item->GetProperties().FindProperty(defaultPropertyName); if (prop) @@ -393,12 +390,12 @@ bool ctPropertyEditor::EditDefaultProperty(ctConfigItem* item) this->m_attributeEditorGrid->SelectRow(index); this->m_attributeEditorGrid->SetGridCursor(index, 1); EditDetails(wxTheApp->GetTopWindow()); - return TRUE; + return true; } } } - return FALSE; + return false; } /// Find the selected property @@ -411,7 +408,7 @@ ctProperty* ctPropertyEditor::FindSelectedProperty(int& row) if (selRow > -1) { row = selRow; - + if (selRow < (int) m_item->GetProperties().GetCount()) { ctProperty* prop = m_item->GetProperties().GetNth(selRow); @@ -446,7 +443,7 @@ bool ctPropertyEditor::EditDetails(wxWindow* WXUNUSED(parent)) int row; ctProperty* prop = FindSelectedProperty(row); if (!prop) - return FALSE; + return false; wxString type(prop->GetEditorType()); wxString value = m_attributeEditorGrid->GetCellValue(row, 1); @@ -457,16 +454,16 @@ bool ctPropertyEditor::EditDetails(wxWindow* WXUNUSED(parent)) wxString msg; msg.Printf(wxT("Edit %s:"), (const wxChar*) prop->GetName()); ctMultiLineTextEditor dialog(wxTheApp->GetTopWindow(), - -1, wxT("Edit Text Property"), msg, value); + wxID_ANY, wxT("Edit Text Property"), msg, value); if (dialog.ShowModal() == wxID_OK) { value = ctConvertToSingleText(dialog.GetText()); m_attributeEditorGrid->SetCellValue(row, 1, value); ApplyCellValueToProperty(row, 1); - return TRUE; + return true; } else - return FALSE; + return false; } else if (type == _T("filename")) { @@ -486,10 +483,10 @@ bool ctPropertyEditor::EditDetails(wxWindow* WXUNUSED(parent)) m_attributeEditorGrid->SetCellValue(row, 1, value); ApplyCellValueToProperty(row, 1); - return TRUE; + return true; } else - return FALSE; + return false; } else if (type == _T("configitems")) { @@ -497,7 +494,7 @@ bool ctPropertyEditor::EditDetails(wxWindow* WXUNUSED(parent)) ctConfigItem::StringToArray(value, items); ctConfigItemsSelector dialog(wxTheApp->GetTopWindow(), - -1, wxT("Select Configuration Items")); + wxID_ANY, wxT("Select Configuration Items")); dialog.SetConfigList(items); if (dialog.ShowModal() == wxID_OK) { @@ -507,14 +504,14 @@ bool ctPropertyEditor::EditDetails(wxWindow* WXUNUSED(parent)) m_attributeEditorGrid->SetCellValue(row, 1, newValue); ApplyCellValueToProperty(row, 1); - return TRUE; + return true; } else - return FALSE; + return false; } } - return FALSE; + return false; } /// Intercept selection event. @@ -536,7 +533,7 @@ void ctPropertyEditor::UpdateDescription(int row) } if (row == -1) { - wxString str = WrapDescription(wxEmptyString); + wxString str = WrapDescription(wxEmptyString); m_propertyDescriptionWindow->SetPage(str); } else @@ -544,7 +541,7 @@ void ctPropertyEditor::UpdateDescription(int row) ctProperty* prop = FindProperty(row); if (prop) { - wxString str = WrapDescription(m_item->GetDescription(prop)); + wxString str = WrapDescription(m_item->GetDescription(prop)); m_propertyDescriptionWindow->SetPage(str); } } @@ -557,13 +554,13 @@ wxString ctPropertyEditor::WrapDescription(const wxString& s) wxColour col = ctDESCRIPTION_BACKGROUND_COLOUR; wxString colStr = apColourToHexString(col); colStr = wxT("#") + colStr; - + wxString str; str << _T("") ; str << s; str << _T(""); - - return str; + + return str; } /// Intercept cell data change event. @@ -589,12 +586,12 @@ void ctPropertyEditor::OnDClickCell(wxGridEvent& WXUNUSED(event)) /// item object. void ctPropertyEditor::ApplyCellValueToProperty(int row, int col) { - static bool s_Applying = FALSE; + static bool s_Applying = false; if (s_Applying) return; - s_Applying = TRUE; + s_Applying = true; if (col == 1 && m_item) { ctProperty* prop = m_item->GetProperties().GetNth(row); @@ -608,9 +605,9 @@ void ctPropertyEditor::ApplyCellValueToProperty(int row, int col) if (prop->GetVariant().GetType() == _T("bool")) { if (value == _T("1")) - variant = (bool) TRUE; + variant = true; else - variant = (bool) FALSE; + variant = false; } else if (prop->GetVariant().GetType() == _T("long")) { @@ -634,19 +631,19 @@ void ctPropertyEditor::ApplyCellValueToProperty(int row, int col) if (prop->GetName() == _T("description")) UpdateDescription(row); } - s_Applying = FALSE; + s_Applying = false; } /// Apply the cell value to the property, and notify the /// item object. void ctPropertyEditor::ApplyPropertyValue(ctConfigItem* item, ctProperty* property, const wxVariant& variant) { - static bool s_Applying = FALSE; + static bool s_Applying = false; if (s_Applying) return; - s_Applying = TRUE; + s_Applying = true; // Save the old values ctProperties* oldProperties = new ctProperties(item->GetProperties()); @@ -655,21 +652,21 @@ void ctPropertyEditor::ApplyPropertyValue(ctConfigItem* item, ctProperty* proper // Apply the new value property->GetVariant() = variant; - item->ApplyProperty(property, oldValue); + item->ApplyProperty(property, oldValue); item->Modify(); - + UpdateItem(); wxString menuLabel(_T("Change ") + property->GetName()); - + // This won't do anything first time Do is applied, // since we've already done the action for this property. // But when we Undo or Redo, the changed properties will be applied. item->GetDocument()->GetCommandProcessor()->Submit( new ctConfigCommand(menuLabel, ctCMD_APPLY_PROPERTY, - item, oldProperties, TRUE)); + item, oldProperties, true)); - s_Applying = FALSE; + s_Applying = false; } /*! @@ -734,7 +731,7 @@ bool ctPropertyEditorGrid::ClearAttributes() { if (GetNumberRows() > 0) DeleteRows(0, GetNumberRows()); - return TRUE; + return true; } /*! @@ -791,7 +788,7 @@ ctMultiLineTextEditor::ctMultiLineTextEditor( wxWindow *parent, wxWindowID id, c AddControls(this, msg); Centre(); } - + bool ctMultiLineTextEditor::AddControls(wxWindow* parent, const wxString& msg) { wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL ); @@ -801,18 +798,17 @@ bool ctMultiLineTextEditor::AddControls(wxWindow* parent, const wxString& msg) wxStaticText *item2 = new wxStaticText( parent, wxID_STATIC, msg, wxDefaultPosition, wxDefaultSize, 0 ); item1->Add( item2, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxLEFT|wxRIGHT, 5 ); - wxTextCtrl *item3 = new wxTextCtrl( parent, -1, wxT(""), wxDefaultPosition, wxSize(330,180), wxTE_MULTILINE|wxTE_RICH ); + wxTextCtrl *item3 = new wxTextCtrl( parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize(330,180), wxTE_MULTILINE|wxTE_RICH ); item1->Add( item3, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 ); wxBoxSizer *item4 = new wxBoxSizer( wxHORIZONTAL ); item4->Add( 5, 5, 1, wxALIGN_CENTRE|wxALL, 5 ); - wxButton *item5 = new wxButton( parent, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); - item5->SetDefault(); + wxButton *item5 = new wxButton( parent, wxID_OK); item4->Add( item5, 0, wxALIGN_CENTRE|wxALL, 5 ); - wxButton *item6 = new wxButton( parent, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); + wxButton *item6 = new wxButton( parent, wxID_CANCEL); item4->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 ); item1->Add( item4, 0, wxGROW|wxALIGN_CENTER_VERTICAL, 5 ); @@ -824,13 +820,12 @@ bool ctMultiLineTextEditor::AddControls(wxWindow* parent, const wxString& msg) item3->SetFocus(); - ((wxButton*) FindWindow(wxID_OK))->SetDefault(); + item5->SetDefault(); - parent->SetAutoLayout( TRUE ); parent->SetSizer(item0); item0->Fit(parent); - return TRUE; + return true; } /* @@ -839,14 +834,14 @@ bool ctMultiLineTextEditor::AddControls(wxWindow* parent, const wxString& msg) */ BEGIN_EVENT_TABLE(ctSplitterWindow, wxSplitterWindow) - EVT_SPLITTER_SASH_POS_CHANGED(-1, ctSplitterWindow::OnChangeSash) + EVT_SPLITTER_SASH_POS_CHANGED(wxID_ANY, ctSplitterWindow::OnChangeSash) END_EVENT_TABLE() ctSplitterWindow::ctSplitterWindow(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style): wxSplitterWindow(parent, id, pos, size, style) { - m_updateSettings = FALSE; + m_updateSettings = false; m_position = 0; }