X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b5982058625b149a820cc53a2e8098026e9d3ce4..8e13c1ec4e6e8d2c5852df39c6be5db4fd279227:/contrib/src/deprecated/proplist.cpp?ds=sidebyside diff --git a/contrib/src/deprecated/proplist.cpp b/contrib/src/deprecated/proplist.cpp index 5e366c05ef..29c17d30f2 100644 --- a/contrib/src/deprecated/proplist.cpp +++ b/contrib/src/deprecated/proplist.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: proplist.cpp +// Name: contrib/src/deprecated/proplist.cpp // Purpose: Property list classes // Author: Julian Smart // Modified by: @@ -17,10 +17,6 @@ // headers // ---------------------------------------------------------------------------- -#ifdef __GNUG__ - #pragma implementation "proplist.h" -#endif - // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" @@ -156,7 +152,7 @@ bool wxPropertyListView::UpdatePropertyList(bool clearEditArea) if (clearEditArea) { m_valueList->Clear(); - m_valueText->SetValue( wxT("") ); + m_valueText->SetValue(wxEmptyString); } wxNode *node = m_propertySheet->GetProperties().GetFirst(); @@ -215,7 +211,7 @@ int wxPropertyListView::FindListIndexForProperty(wxProperty *property) if (property == (wxProperty *)m_propertyScrollingList->wxListBox::GetClientData(i)) return i; } - return -1; + return wxNOT_FOUND; } wxString wxPropertyListView::MakeNameValueString(wxString name, wxString value) @@ -223,7 +219,7 @@ wxString wxPropertyListView::MakeNameValueString(wxString name, wxString value) wxString theString(name); int nameWidth = 25; - int padWith = nameWidth - theString.Length(); + int padWith = nameWidth - theString.length(); if (padWith < 0) padWith = 0; @@ -248,7 +244,7 @@ bool wxPropertyListView::ShowProperty(wxProperty *property, bool select) } m_valueList->Clear(); - m_valueText->SetValue( wxT("") ); + m_valueText->SetValue(wxEmptyString); if (property) { @@ -258,7 +254,7 @@ bool wxPropertyListView::ShowProperty(wxProperty *property, bool select) if (select) { int sel = FindListIndexForProperty(property); - if (sel > -1) + if (sel != wxNOT_FOUND) m_propertyScrollingList->SetSelection(sel); } return true; @@ -400,7 +396,7 @@ bool wxPropertyListView::EditProperty(wxProperty *WXUNUSED(property)) void wxPropertyListView::OnPropertySelect(wxCommandEvent& WXUNUSED(event)) { int sel = m_propertyScrollingList->GetSelection(); - if (sel > -1) + if (sel != wxNOT_FOUND) { wxProperty *newSel = (wxProperty *)m_propertyScrollingList->wxListBox::GetClientData(sel); if (newSel && newSel != m_currentProperty) @@ -423,7 +419,7 @@ bool wxPropertyListView::CreateControls() if (!panel) return false; - wxFont guiFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + wxFont guiFont = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); #ifdef __WXMSW__ wxFont *boringFont = @@ -464,15 +460,15 @@ bool wxPropertyListView::CreateControls() topsizer->Add( m_cancelButton, 0, wxLEFT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); } - m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, _T(""), - wxDefaultPosition, wxSize(wxDefaultSize.x, smallButtonSize.y), wxPROCESS_ENTER); - m_valueText->Enable(false); + m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, wxEmptyString, + wxDefaultPosition, wxSize(wxDefaultCoord, smallButtonSize.y), wxTE_PROCESS_ENTER); + m_valueText->Disable(); topsizer->Add( m_valueText, 1, wxALL | wxEXPAND, buttonborder ); if (m_buttonFlags & wxPROP_PULLDOWN) { m_editButton = new wxButton(panel, wxID_PROP_EDIT, _T("..."), wxDefaultPosition, smallButtonSize); - m_editButton->Enable(false); + m_editButton->Disable(); topsizer->Add( m_editButton, 0, wxRIGHT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); } @@ -482,7 +478,7 @@ bool wxPropertyListView::CreateControls() m_middleSizer = new wxBoxSizer( wxVERTICAL ); - m_valueList = new wxListBox(panel, wxID_PROP_VALUE_SELECT, wxDefaultPosition, wxSize(wxDefaultSize.x, 60)); + m_valueList = new wxListBox(panel, wxID_PROP_VALUE_SELECT, wxDefaultPosition, wxSize(wxDefaultCoord, 60)); m_valueList->Show(false); m_propertyScrollingList = new wxListBox(panel, wxID_PROP_SELECT, wxDefaultPosition, wxSize(100, 100)); @@ -826,7 +822,7 @@ bool wxPropertyListValidator::OnSelect(bool select, wxProperty *property, wxProp bool wxPropertyListValidator::OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { wxString s(view->GetValueList()->GetStringSelection()); - if (s != wxT("")) + if ( !s.empty() ) { view->GetValueText()->SetValue(s); view->RetrieveProperty(property); @@ -864,11 +860,11 @@ void wxPropertyListValidator::OnEdit(wxProperty *WXUNUSED(property), wxPropertyL bool wxPropertyListValidator::OnClearControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(false); + view->GetConfirmButton()->Disable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(false); + view->GetCancelButton()->Disable(); if (view->GetEditButton()) - view->GetEditButton()->Enable(false); + view->GetEditButton()->Disable(); return true; } @@ -929,13 +925,13 @@ bool wxRealListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListVi bool wxRealListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(true); + view->GetConfirmButton()->Enable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(true); + view->GetCancelButton()->Enable(); if (view->GetEditButton()) - view->GetEditButton()->Enable(false); + view->GetEditButton()->Disable(); if (view->GetValueText()) - view->GetValueText()->Enable(true); + view->GetValueText()->Enable(); return true; } @@ -991,13 +987,13 @@ bool wxIntegerListValidator::OnRetrieveValue(wxProperty *property, wxPropertyLis bool wxIntegerListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(true); + view->GetConfirmButton()->Enable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(true); + view->GetCancelButton()->Enable(); if (view->GetEditButton()) - view->GetEditButton()->Enable(false); + view->GetEditButton()->Disable(); if (view->GetValueText()) - view->GetValueText()->Enable(true); + view->GetValueText()->Enable(); return true; } @@ -1054,13 +1050,13 @@ bool wxBoolListValidator::OnDisplayValue(wxProperty *property, wxPropertyListVie bool wxBoolListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(false); + view->GetConfirmButton()->Disable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(false); + view->GetCancelButton()->Disable(); if (view->GetEditButton()) - view->GetEditButton()->Enable(true); + view->GetEditButton()->Enable(); if (view->GetValueText()) - view->GetValueText()->Enable(false); + view->GetValueText()->Disable(); return true; } @@ -1069,7 +1065,7 @@ bool wxBoolListValidator::OnPrepareDetailControls(wxProperty *WXUNUSED(property) if (view->GetValueList()) { view->ShowListBoxControl(true); - view->GetValueList()->Enable(true); + view->GetValueList()->Enable(); view->GetValueList()->Append(wxT("True")); view->GetValueList()->Append(wxT("False")); @@ -1086,7 +1082,7 @@ bool wxBoolListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property), { view->GetValueList()->Clear(); view->ShowListBoxControl(false); - view->GetValueList()->Enable(false); + view->GetValueList()->Disable(); } return true; } @@ -1175,27 +1171,27 @@ bool wxStringListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wx if (!m_strings) { if (view->GetEditButton()) - view->GetEditButton()->Enable(false); + view->GetEditButton()->Disable(); if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(true); + view->GetConfirmButton()->Enable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(true); + view->GetCancelButton()->Enable(); if (view->GetValueText()) - view->GetValueText()->Enable(true); + view->GetValueText()->Enable(); return true; } // Constrained if (view->GetValueText()) - view->GetValueText()->Enable(false); + view->GetValueText()->Disable(); if (view->GetEditButton()) - view->GetEditButton()->Enable(true); + view->GetEditButton()->Enable(); if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(false); + view->GetConfirmButton()->Disable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(false); + view->GetCancelButton()->Disable(); return true; } @@ -1206,7 +1202,7 @@ bool wxStringListValidator::OnPrepareDetailControls( wxProperty *property, if (view->GetValueList()) { view->ShowListBoxControl(true); - view->GetValueList()->Enable(true); + view->GetValueList()->Enable(); wxStringList::Node *node = m_strings->GetFirst(); while (node) { @@ -1231,7 +1227,7 @@ bool wxStringListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property) { view->GetValueList()->Clear(); view->ShowListBoxControl(false); - view->GetValueList()->Enable(false); + view->GetValueList()->Disable(); } return true; } @@ -1326,11 +1322,11 @@ bool wxFilenameListValidator::OnDoubleClick(wxProperty *property, wxPropertyList bool wxFilenameListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(true); + view->GetConfirmButton()->Enable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(true); + view->GetCancelButton()->Enable(); if (view->GetEditButton()) - view->GetEditButton()->Enable(true); + view->GetEditButton()->Enable(); if (view->GetValueText()) view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING); return true; @@ -1341,21 +1337,27 @@ void wxFilenameListValidator::OnEdit(wxProperty *property, wxPropertyListView *v if (!view->GetValueText()) return; - wxString s = wxFileSelector( - m_filenameMessage.GetData(), - wxPathOnly(property->GetValue().StringValue()), - wxFileNameFromPath(property->GetValue().StringValue()), - NULL, - m_filenameWildCard.GetData(), - 0, - parentWindow); - if (s != wxT("")) - { - property->GetValue() = s; - view->DisplayProperty(property); - view->UpdatePropertyDisplayInList(property); - view->OnPropertyChanged(property); - } +#if wxUSE_FILEDLG + wxString s = wxFileSelector( + m_filenameMessage.GetData(), + wxPathOnly(property->GetValue().StringValue()), + wxFileNameFromPath(property->GetValue().StringValue()), + NULL, + m_filenameWildCard.GetData(), + 0, + parentWindow); + if ( !s.empty() ) + { + property->GetValue() = s; + view->DisplayProperty(property); + view->UpdatePropertyDisplayInList(property); + view->OnPropertyChanged(property); + } +#else + wxUnusedVar(property); + wxUnusedVar(view); + wxUnusedVar(parentWindow); +#endif } /// @@ -1414,15 +1416,19 @@ bool wxColourListValidator::OnDoubleClick(wxProperty *property, wxPropertyListVi bool wxColourListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { - if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(true); - if (view->GetCancelButton()) - view->GetCancelButton()->Enable(true); - if (view->GetEditButton()) - view->GetEditButton()->Enable(true); - if (view->GetValueText()) - view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING); - return true; + if (view->GetConfirmButton()) + view->GetConfirmButton()->Enable(); + + if (view->GetCancelButton()) + view->GetCancelButton()->Enable(); + + if (view->GetEditButton()) + view->GetEditButton()->Enable(); + + if (view->GetValueText()) + view->GetValueText()->Enable((GetFlags() & wxPROP_ALLOW_TEXT_EDITING) == wxPROP_ALLOW_TEXT_EDITING); + + return true; } void wxColourListValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) @@ -1431,14 +1437,14 @@ void wxColourListValidator::OnEdit(wxProperty *property, wxPropertyListView *vie return; wxChar *s = property->GetValue().StringValue(); - int r = 0; - int g = 0; - int b = 0; + unsigned char r = 0; + unsigned char g = 0; + unsigned char b = 0; if (s) { - r = wxHexToDec(s); - g = wxHexToDec(s+2); - b = wxHexToDec(s+4); + r = (unsigned char)wxHexToDec(s); + g = (unsigned char)wxHexToDec(s+2); + b = (unsigned char)wxHexToDec(s+4); } wxColour col(r,g,b); @@ -1449,7 +1455,9 @@ void wxColourListValidator::OnEdit(wxProperty *property, wxPropertyListView *vie for (int i = 0; i < 16; i++) { - wxColour colour(i*16, i*16, i*16); + wxColour colour((unsigned char)(i*16), + (unsigned char)(i*16), + (unsigned char)(i*16)); data.SetCustomColour(i, colour); } @@ -1509,14 +1517,14 @@ bool wxListOfStringsListValidator::OnDisplayValue(wxProperty *property, wxProper bool wxListOfStringsListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetEditButton()) - view->GetEditButton()->Enable(true); + view->GetEditButton()->Enable(); if (view->GetValueText()) - view->GetValueText()->Enable(false); + view->GetValueText()->Disable(); if (view->GetConfirmButton()) - view->GetConfirmButton()->Enable(false); + view->GetConfirmButton()->Disable(); if (view->GetCancelButton()) - view->GetCancelButton()->Enable(false); + view->GetCancelButton()->Disable(); return true; } @@ -1569,17 +1577,17 @@ void wxListOfStringsListValidator::OnEdit( wxProperty *property, class wxPropertyStringListEditorDialog: public wxDialog { - public: +public: wxPropertyStringListEditorDialog(wxWindow *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxT("stringEditorDialogBox")): wxDialog(parent, wxID_ANY, title, pos, size, windowStyle, name) { - m_stringList = NULL; - m_stringText = NULL; - m_listBox = NULL; - sm_dialogCancelled = false; - m_currentSelection = -1; + m_stringList = NULL; + m_stringText = NULL; + m_listBox = NULL; + sm_dialogCancelled = false; + m_currentSelection = -1; } ~wxPropertyStringListEditorDialog(void) {} void OnCloseWindow(wxCloseEvent& event); @@ -1643,7 +1651,7 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList wxBeginBusyCursor(); wxPropertyStringListEditorDialog *dialog = new wxPropertyStringListEditorDialog(parent, - title, wxPoint(10, 10), wxSize(400, 400), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); + title, wxPoint(10, 10), wxSize(400, 400)); dialog->m_stringList = stringList; @@ -1651,9 +1659,9 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE); dialog->m_stringText = new wxPropertyStringListEditorText(dialog, - wxID_PROP_SL_TEXT, wxT(""), wxPoint(5, 240), - wxSize(300, wxDefaultSize.y), wxPROCESS_ENTER); - dialog->m_stringText->Enable(false); + wxID_PROP_SL_TEXT, wxEmptyString, wxPoint(5, 240), + wxSize(300, wxDefaultCoord), wxTE_PROCESS_ENTER); + dialog->m_stringText->Disable(); wxButton *addButton = new wxButton(dialog, wxID_PROP_SL_ADD, wxT("Add"), wxDefaultPosition, wxSize(largeButtonWidth, largeButtonHeight)); wxButton *deleteButton = new wxButton(dialog, wxID_PROP_SL_DELETE, wxT("Delete"), wxDefaultPosition, wxSize(largeButtonWidth, largeButtonHeight)); @@ -1665,15 +1673,15 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList #endif wxBoxSizer *m_bottom_sizer = new wxBoxSizer( wxHORIZONTAL ); - m_bottom_sizer->Add(addButton, 0, wxALL | wxALIGN_LEFT, 2 ); - m_bottom_sizer->Add(deleteButton, 0, wxALL | wxALIGN_LEFT, 2 ); + m_bottom_sizer->Add(addButton, 0, wxALL | wxALIGN_LEFT, 2 ); + m_bottom_sizer->Add(deleteButton, 0, wxALL | wxALIGN_LEFT, 2 ); m_bottom_sizer->Add(1, 1, 1, wxEXPAND | wxALL); - m_bottom_sizer->Add(cancelButton, 0, wxALL | wxALIGN_RIGHT, 2 ); - m_bottom_sizer->Add(okButton, 0, wxALL | wxALIGN_RIGHT, 2 ); + m_bottom_sizer->Add(cancelButton, 0, wxALL | wxALIGN_RIGHT, 2 ); + m_bottom_sizer->Add(okButton, 0, wxALL | wxALIGN_RIGHT, 2 ); wxBoxSizer *m_sizer = new wxBoxSizer( wxVERTICAL ); - m_sizer->Add(dialog->m_listBox, 1, wxEXPAND | wxALL, 2 ); - m_sizer->Add(dialog->m_stringText, 0, wxEXPAND | wxALL, 2 ); + m_sizer->Add(dialog->m_listBox, 1, wxEXPAND | wxALL, 2 ); + m_sizer->Add(dialog->m_stringText, 0, wxEXPAND | wxALL, 2 ); m_sizer->Add(m_bottom_sizer, 0, wxEXPAND | wxALL , 0 ); dialog->SetSizer( m_sizer ); @@ -1706,30 +1714,30 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList void wxPropertyStringListEditorDialog::OnStrings(wxCommandEvent& WXUNUSED(event)) { - int sel = m_listBox->GetSelection(); - if (sel > -1) - { - m_currentSelection = sel; + int sel = m_listBox->GetSelection(); + if (sel != wxNOT_FOUND) + { + m_currentSelection = sel; - ShowCurrentSelection(); - } + ShowCurrentSelection(); + } } void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& WXUNUSED(event)) { - int sel = m_listBox->GetSelection(); - if (sel == -1) - return; + int sel = m_listBox->GetSelection(); + if (sel == wxNOT_FOUND) + return; - wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(sel); - if (!node) - return; + wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(sel); + if (!node) + return; - m_listBox->Delete(sel); - delete[] (wxChar *)node->GetData(); - delete node; - m_currentSelection = -1; - m_stringText->SetValue(_T("")); + m_listBox->Delete(sel); + delete[] (wxChar *)node->GetData(); + delete node; + m_currentSelection = -1; + m_stringText->SetValue(wxEmptyString); } void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event)) @@ -1747,34 +1755,34 @@ void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event)) void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { - SaveCurrentSelection(); - EndModal(wxID_OK); - // Close(true); - this->Destroy(); + SaveCurrentSelection(); + EndModal(wxID_OK); +// Close(true); + this->Destroy(); } void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { - sm_dialogCancelled = true; - EndModal(wxID_CANCEL); + sm_dialogCancelled = true; + EndModal(wxID_CANCEL); // Close(true); - this->Destroy(); + this->Destroy(); } void wxPropertyStringListEditorDialog::OnText(wxCommandEvent& event) { - if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER) - { - SaveCurrentSelection(); - } + if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER) + { + SaveCurrentSelection(); + } } void wxPropertyStringListEditorDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { - SaveCurrentSelection(); + SaveCurrentSelection(); - Destroy(); + Destroy(); } void wxPropertyStringListEditorDialog::SaveCurrentSelection() @@ -1798,13 +1806,13 @@ void wxPropertyStringListEditorDialog::ShowCurrentSelection() { if (m_currentSelection == -1) { - m_stringText->SetValue(wxT("")); + m_stringText->SetValue(wxEmptyString); return; } wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection); wxChar *txt = (wxChar *)node->GetData(); m_stringText->SetValue(txt); - m_stringText->Enable(true); + m_stringText->Enable(); }