X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5c3beb8ee5dca82b1a20e45d694df9a01a1be96a..d477aa2bb3ec93c915542185bd2fb9ef74642356:/src/generic/proplist.cpp diff --git a/src/generic/proplist.cpp b/src/generic/proplist.cpp index 60e51cadd6..f6aa8cf737 100644 --- a/src/generic/proplist.cpp +++ b/src/generic/proplist.cpp @@ -28,6 +28,8 @@ #pragma hdrstop #endif +#if wxUSE_PROPSHEET + #ifndef WX_PRECOMP #include "wx/window.h" #include "wx/font.h" @@ -43,6 +45,7 @@ #include "wx/sizer.h" #include "wx/module.h" #include "wx/intl.h" +#include "wx/artprov.h" #include "wx/colordlg.h" #include "wx/proplist.h" @@ -52,27 +55,11 @@ #include #include -// ---------------------------------------------------------------------------- -// XPMs -// ---------------------------------------------------------------------------- - -#ifndef __WXMSW__ - #include "wx/generic/cross.xpm" - #include "wx/generic/tick.xpm" -#endif - -// ---------------------------------------------------------------------------- -// accessor functions for the bitmaps (may return NULL, check for it!) -// ---------------------------------------------------------------------------- - -static wxBitmap *GetTickBitmap(); -static wxBitmap *GetCrossBitmap(); - // ---------------------------------------------------------------------------- // Property text edit control // ---------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxPropertyTextEdit, wxTextCtrl) +IMPLEMENT_DYNAMIC_CLASS(wxPropertyTextEdit, wxTextCtrl) wxPropertyTextEdit::wxPropertyTextEdit(wxPropertyListView *v, wxWindow *parent, const wxWindowID id, const wxString& value, @@ -162,18 +149,18 @@ bool wxPropertyListView::UpdatePropertyList(bool clearEditArea) if (clearEditArea) { m_valueList->Clear(); - m_valueText->SetValue(""); + m_valueText->SetValue( wxT("") ); } - wxNode *node = m_propertySheet->GetProperties().First(); + wxNode *node = m_propertySheet->GetProperties().GetFirst(); // Should sort them... later... while (node) { - wxProperty *property = (wxProperty *)node->Data(); + wxProperty *property = (wxProperty *)node->GetData(); wxString stringValueRepr(property->GetValue().GetStringRepresentation()); wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr)); m_propertyScrollingList->Append(paddedString.GetData(), (void *)property); - node = node->Next(); + node = node->GetNext(); } return TRUE; } @@ -215,7 +202,7 @@ bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) // Find the wxListBox index corresponding to this property int wxPropertyListView::FindListIndexForProperty(wxProperty *property) { - int n = m_propertyScrollingList->Number(); + int n = m_propertyScrollingList->GetCount(); for (int i = 0; i < n; i++) { if (property == (wxProperty *)m_propertyScrollingList->wxListBox::GetClientData(i)) @@ -236,7 +223,7 @@ wxString wxPropertyListView::MakeNameValueString(wxString name, wxString value) if (GetFlags() & wxPROP_SHOWVALUES) { // Want to pad with spaces - theString.Append(' ', padWith); + theString.Append( wxT(' '), padWith); theString += value; } @@ -254,7 +241,7 @@ bool wxPropertyListView::ShowProperty(wxProperty *property, bool select) } m_valueList->Clear(); - m_valueText->SetValue(""); + m_valueText->SetValue( wxT("") ); if (property) { @@ -429,11 +416,12 @@ bool wxPropertyListView::CreateControls() if (!panel) return FALSE; - wxSystemSettings settings; - wxFont guiFont = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + wxFont guiFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); #ifdef __WXMSW__ - wxFont *boringFont = wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL, FALSE, "Courier New"); + wxFont *boringFont = + wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxMODERN, + wxNORMAL, wxNORMAL, FALSE, _T("Courier New")); #else wxFont *boringFont = wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxTELETYPE, wxNORMAL, wxNORMAL); #endif @@ -451,32 +439,32 @@ bool wxPropertyListView::CreateControls() if (m_buttonFlags & wxPROP_BUTTON_CHECK_CROSS) { - wxBitmap *tickBitmap = GetTickBitmap(); - wxBitmap *crossBitmap = GetCrossBitmap(); + wxBitmap tickBitmap = wxArtProvider::GetBitmap(wxART_TICK_MARK); + wxBitmap crossBitmap = wxArtProvider::GetBitmap(wxART_CROSS_MARK); - if ( tickBitmap && crossBitmap ) + if ( tickBitmap.Ok() && crossBitmap.Ok() ) { - m_confirmButton = new wxBitmapButton(panel, wxID_PROP_CHECK, *tickBitmap, wxPoint(-1, -1), smallButtonSize ); - m_cancelButton = new wxBitmapButton(panel, wxID_PROP_CROSS, *crossBitmap, wxPoint(-1, -1), smallButtonSize ); + m_confirmButton = new wxBitmapButton(panel, wxID_PROP_CHECK, tickBitmap, wxPoint(-1, -1), smallButtonSize ); + m_cancelButton = new wxBitmapButton(panel, wxID_PROP_CROSS, crossBitmap, wxPoint(-1, -1), smallButtonSize ); } else { - m_confirmButton = new wxButton(panel, wxID_PROP_CHECK, ":-)", wxPoint(-1, -1), smallButtonSize ); - m_cancelButton = new wxButton(panel, wxID_PROP_CROSS, "X", wxPoint(-1, -1), smallButtonSize ); + m_confirmButton = new wxButton(panel, wxID_PROP_CHECK, _T(":-)"), wxPoint(-1, -1), smallButtonSize ); + m_cancelButton = new wxButton(panel, wxID_PROP_CROSS, _T("X"), wxPoint(-1, -1), smallButtonSize ); } topsizer->Add( m_confirmButton, 0, wxLEFT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); topsizer->Add( m_cancelButton, 0, wxLEFT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); } - m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, "", + m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, _T(""), wxPoint(-1, -1), wxSize(-1, smallButtonSize.y), wxPROCESS_ENTER); m_valueText->Enable(FALSE); topsizer->Add( m_valueText, 1, wxALL | wxEXPAND, buttonborder ); if (m_buttonFlags & wxPROP_PULLDOWN) { - m_editButton = new wxButton(panel, wxID_PROP_EDIT, "...", wxPoint(-1, -1), smallButtonSize); + m_editButton = new wxButton(panel, wxID_PROP_EDIT, _T("..."), wxPoint(-1, -1), smallButtonSize); m_editButton->Enable(FALSE); topsizer->Add( m_editButton, 0, wxRIGHT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); } @@ -601,6 +589,7 @@ void wxPropertyListView::OnOk(wxCommandEvent& event) OnCheck(event); m_managedWindow->Close(TRUE); + sm_dialogCancelled = FALSE; } void wxPropertyListView::OnCancel(wxCommandEvent& WXUNUSED(event)) @@ -675,7 +664,7 @@ void wxPropertyListView::OnText(wxCommandEvent& event) // Property dialog box // ---------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxPropertyListDialog, wxDialog) +IMPLEMENT_DYNAMIC_CLASS(wxPropertyListDialog, wxDialog) BEGIN_EVENT_TABLE(wxPropertyListDialog, wxDialog) EVT_BUTTON(wxID_CANCEL, wxPropertyListDialog::OnCancel) @@ -735,7 +724,7 @@ bool wxPropertyListDialog::ProcessEvent(wxEvent& event) // Property panel // ---------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxPropertyListPanel, wxPanel) +IMPLEMENT_DYNAMIC_CLASS(wxPropertyListPanel, wxPanel) BEGIN_EVENT_TABLE(wxPropertyListPanel, wxPanel) EVT_SIZE(wxPropertyListPanel::OnSize) @@ -771,7 +760,7 @@ void wxPropertyListPanel::OnSize(wxSizeEvent& WXUNUSED(event)) // Property frame // ---------------------------------------------------------------------------- -IMPLEMENT_CLASS(wxPropertyListFrame, wxFrame) +IMPLEMENT_DYNAMIC_CLASS(wxPropertyListFrame, wxFrame) BEGIN_EVENT_TABLE(wxPropertyListFrame, wxFrame) EVT_CLOSE(wxPropertyListFrame::OnCloseWindow) @@ -905,9 +894,9 @@ bool wxRealListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropert if (val < m_realMin || val > m_realMax) { - char buf[200]; - sprintf(buf, "Value must be a real number between %.2f and %.2f!", m_realMin, m_realMax); - wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxChar buf[200]; + wxSprintf(buf, wxT("Value must be a real number between %.2f and %.2f!"), m_realMin, m_realMax); + wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } return TRUE; @@ -1140,10 +1129,10 @@ bool wxStringListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPrope if (!m_strings->Member(value.GetData())) { - wxString s("Value "); - s += value.GetData(); - s += " is not valid."; - wxMessageBox(s.GetData(), "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxString str( wxT("Value ") ); + str += value.GetData(); + str += wxT(" is not valid."); + wxMessageBox( str.GetData(), wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } return TRUE; @@ -1170,7 +1159,7 @@ bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListV return FALSE; wxString str(property->GetValue().GetStringRepresentation()); view->GetValueText()->SetValue(str); - if (m_strings && view->GetValueList() && view->GetValueList()->IsShown() && view->GetValueList()->Number() > 0) + if (m_strings && view->GetValueList() && view->GetValueList()->IsShown() && view->GetValueList()->GetCount() > 0) { view->GetValueList()->SetStringSelection(str); } @@ -1207,18 +1196,20 @@ bool wxStringListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wx return TRUE; } -bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) +bool wxStringListValidator::OnPrepareDetailControls( wxProperty *property, + wxPropertyListView *view, + wxWindow *WXUNUSED(parentWindow) ) { if (view->GetValueList()) { view->ShowListBoxControl(TRUE); view->GetValueList()->Enable(TRUE); - wxNode *node = m_strings->First(); + wxStringList::Node *node = m_strings->GetFirst(); while (node) { - wxChar *s = (wxChar *)node->Data(); + wxChar *s = node->GetData(); view->GetValueList()->Append(s); - node = node->Next(); + node = node->GetNext(); } wxChar *currentString = property->GetValue().StringValue(); view->GetValueList()->SetStringSelection(currentString); @@ -1244,32 +1235,34 @@ bool wxStringListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property) // Called when the property is double clicked. Extra functionality can be provided, // cycling through possible values. -bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) +bool wxStringListValidator::OnDoubleClick( wxProperty *property, + wxPropertyListView *view, + wxWindow *WXUNUSED(parentWindow) ) { if (!view->GetValueText()) return FALSE; if (!m_strings) return FALSE; - wxNode *node = m_strings->First(); - wxChar *currentString = property->GetValue().StringValue(); + wxStringList::Node *node = m_strings->GetFirst(); + wxChar *currentString = property->GetValue().StringValue(); while (node) { - wxChar *s = (wxChar *)node->Data(); + wxChar *s = node->GetData(); if (wxStrcmp(s, currentString) == 0) { wxChar *nextString = NULL; - if (node->Next()) - nextString = (wxChar *)node->Next()->Data(); + if (node->GetNext()) + nextString = node->GetNext()->GetData(); else - nextString = (wxChar *)m_strings->First()->Data(); + nextString = m_strings->GetFirst()->GetData(); property->GetValue() = wxString(nextString); view->DisplayProperty(property); view->UpdatePropertyDisplayInList(property); view->OnPropertyChanged(property); return TRUE; } - else node = node->Next(); + else node = node->GetNext(); } return TRUE; } @@ -1532,7 +1525,9 @@ bool wxListOfStringsListValidator::OnDoubleClick(wxProperty *property, wxPropert return TRUE; } -void wxListOfStringsListValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +void wxListOfStringsListValidator::OnEdit( wxProperty *property, + wxPropertyListView *view, + wxWindow *parentWindow ) { // Convert property value to a list of strings for editing wxStringList *stringList = new wxStringList; @@ -1553,13 +1548,13 @@ void wxListOfStringsListValidator::OnEdit(wxProperty *property, wxPropertyListVi { wxPropertyValue& oldValue = property->GetValue(); oldValue.ClearList(); - wxNode *node = stringList->First(); + wxStringList::Node *node = stringList->GetFirst(); while (node) { - wxChar *s = (wxChar *)node->Data(); + wxChar *s = node->GetData(); oldValue.Append(new wxPropertyValue(s)); - node = node->Next(); + node = node->GetNext(); } view->DisplayProperty(property); @@ -1574,7 +1569,7 @@ class wxPropertyStringListEditorDialog: public wxDialog public: wxPropertyStringListEditorDialog(wxWindow *parent, const wxString& title, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = "stringEditorDialogBox"): + long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxT("stringEditorDialogBox")): wxDialog(parent, -1, title, pos, size, windowStyle, name) { m_stringList = NULL; @@ -1624,7 +1619,7 @@ class wxPropertyStringListEditorText: public wxTextCtrl public: wxPropertyStringListEditorText(wxWindow *parent, wxWindowID id, const wxString& val, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, - long windowStyle = 0, const wxString& name = "text"): + long windowStyle = 0, const wxString& name = wxT("text")): wxTextCtrl(parent, id, val, pos, size, windowStyle, wxDefaultValidator, name) { } @@ -1653,14 +1648,14 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList wxPoint(-1, -1), wxSize(-1, -1), 0, NULL, wxLB_SINGLE); dialog->m_stringText = new wxPropertyStringListEditorText(dialog, - wxID_PROP_SL_TEXT, "", wxPoint(5, 240), + wxID_PROP_SL_TEXT, wxT(""), wxPoint(5, 240), wxSize(300, -1), wxPROCESS_ENTER); dialog->m_stringText->Enable(FALSE); - wxButton *addButton = new wxButton(dialog, wxID_PROP_SL_ADD, "Add", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - wxButton *deleteButton = new wxButton(dialog, wxID_PROP_SL_DELETE, "Delete", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - wxButton *cancelButton = new wxButton(dialog, wxID_CANCEL, "Cancel", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - wxButton *okButton = new wxButton(dialog, wxID_OK, "OK", wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); + wxButton *addButton = new wxButton(dialog, wxID_PROP_SL_ADD, wxT("Add"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); + wxButton *deleteButton = new wxButton(dialog, wxID_PROP_SL_DELETE, wxT("Delete"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); + wxButton *cancelButton = new wxButton(dialog, wxID_CANCEL, wxT("Cancel"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); + wxButton *okButton = new wxButton(dialog, wxID_OK, wxT("OK"), wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); #ifndef __WXGTK__ okButton->SetDefault(); @@ -1709,13 +1704,13 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList c->height.AsIs(); okButton->SetConstraints(c); - wxNode *node = stringList->First(); + wxStringList::Node *node = stringList->GetFirst(); while (node) { - char *str = (char *)node->Data(); + wxChar *str = node->GetData(); // Save node as client data for each listbox item - dialog->m_listBox->Append(str, (char *)node); - node = node->Next(); + dialog->m_listBox->Append(str, (wxChar *)node); + node = node->GetNext(); } dialog->SetClientSize(310, 305); @@ -1756,20 +1751,20 @@ void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& WXUNUSED(event)) return; m_listBox->Delete(sel); - delete[] (wxChar *)node->Data(); + delete[] (wxChar *)node->GetData(); delete node; m_currentSelection = -1; - m_stringText->SetValue(""); + m_stringText->SetValue(_T("")); } void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event)) { SaveCurrentSelection(); - wxChar *initialText = wxT(""); + wxString initialText; wxNode *node = m_stringList->Add(initialText); m_listBox->Append(initialText, (void *)node); - m_currentSelection = m_stringList->Number() - 1; + m_currentSelection = m_stringList->GetCount() - 1; m_listBox->SetSelection(m_currentSelection); ShowCurrentSelection(); m_stringText->SetFocus(); @@ -1817,66 +1812,25 @@ void wxPropertyStringListEditorDialog::SaveCurrentSelection() return; wxString txt(m_stringText->GetValue()); - if (node->Data()) - delete[] (char *)node->Data(); - node->SetData((wxObject *)copystring(txt)); + if (node->GetData()) + delete[] (wxChar *)node->GetData(); + node->SetData((wxObject *)wxStrdup(txt)); - m_listBox->SetString(m_currentSelection, (char *)node->Data()); + m_listBox->SetString(m_currentSelection, (wxChar *)node->GetData()); } void wxPropertyStringListEditorDialog::ShowCurrentSelection() { if (m_currentSelection == -1) { - m_stringText->SetValue(""); + m_stringText->SetValue(wxT("")); return; } wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection); - char *txt = (char *)node->Data(); + wxChar *txt = (wxChar *)node->GetData(); m_stringText->SetValue(txt); m_stringText->Enable(TRUE); } -// ---------------------------------------------------------------------------- -// global functions -// ---------------------------------------------------------------------------- - -// FIXME MT-UNSAFE -static wxBitmap *GetTickBitmap() -{ - static wxBitmap* s_tickBitmap = (wxBitmap *) NULL; - static bool s_loaded = FALSE; - - if ( !s_loaded ) - { - s_loaded = TRUE; // set it to TRUE anyhow, we won't try again - - #if defined(__WXMSW__) || defined(__WXPM__) - s_tickBitmap = new wxBitmap("tick_bmp", wxBITMAP_TYPE_RESOURCE); - #else - s_tickBitmap = new wxBitmap( tick_xpm ); - #endif - } - - return s_tickBitmap; -} - -static wxBitmap *GetCrossBitmap() -{ - static wxBitmap* s_crossBitmap = (wxBitmap *) NULL; - static bool s_loaded = FALSE; - - if ( !s_loaded ) - { - s_loaded = TRUE; // set it to TRUE anyhow, we won't try again - - #if defined(__WXMSW__) || defined(__WXPM__) - s_crossBitmap = new wxBitmap("cross_bmp", wxBITMAP_TYPE_RESOURCE); - #else // XPMs - s_crossBitmap = new wxBitmap( cross_xpm ); - #endif // BMPs/XPMs - } - - return s_crossBitmap; -} +#endif // wxUSE_PROPSHEET