X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e3a43801df2f05c057892481df9d3cfe30fd8800..e63fdcd600e2eb717a19f9fa2895e9256e83c890:/src/generic/proplist.cpp diff --git a/src/generic/proplist.cpp b/src/generic/proplist.cpp index 52b80b5c21..d5f5dcd9c4 100644 --- a/src/generic/proplist.cpp +++ b/src/generic/proplist.cpp @@ -6,91 +6,113 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + #ifdef __GNUG__ -#pragma implementation "proplist.h" + #pragma implementation "proplist.h" #endif // For compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #ifndef WX_PRECOMP -#include "wx/wx.h" + #include "wx/window.h" + #include "wx/font.h" + #include "wx/button.h" + #include "wx/bmpbuttn.h" + #include "wx/textctrl.h" + #include "wx/listbox.h" + #include "wx/settings.h" + #include "wx/msgdlg.h" + #include "wx/filedlg.h" #endif +#include "wx/sizer.h" +#include "wx/module.h" +#include "wx/intl.h" + +#include "wx/colordlg.h" +#include "wx/proplist.h" + #include #include #include #include -#if wxUSE_IOSTREAMH -#if defined(__WXMSW__) && !defined(__GNUWIN32__) -#include -#else -#include -#endif -#else -#include +// ---------------------------------------------------------------------------- +// XPMs +// ---------------------------------------------------------------------------- + +#ifndef __WXMSW__ + #include "wx/generic/cross.xpm" + #include "wx/generic/tick.xpm" #endif -#include "wx/window.h" -#include "wx/utils.h" -#include "wx/list.h" -#include "wx/colordlg.h" -#include "wx/proplist.h" +// ---------------------------------------------------------------------------- +// accessor functions for the bitmaps (may return NULL, check for it!) +// ---------------------------------------------------------------------------- -/* - * Property text edit control - */ - -IMPLEMENT_CLASS(wxPropertyTextEdit, wxTextCtrl) +static wxBitmap *GetTickBitmap(); +static wxBitmap *GetCrossBitmap(); + +// ---------------------------------------------------------------------------- +// Property text edit control +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxPropertyTextEdit, wxTextCtrl) wxPropertyTextEdit::wxPropertyTextEdit(wxPropertyListView *v, wxWindow *parent, const wxWindowID id, const wxString& value, - const wxPoint& pos, const wxSize& size, + const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxTextCtrl(parent, id, value, pos, size, style, wxDefaultValidator, name) { m_view = v; } -void wxPropertyTextEdit::OnSetFocus(void) +void wxPropertyTextEdit::OnSetFocus() { } -void wxPropertyTextEdit::OnKillFocus(void) +void wxPropertyTextEdit::OnKillFocus() { } -/* - * Property list view - */ +// ---------------------------------------------------------------------------- +// Property list view +// ---------------------------------------------------------------------------- + +bool wxPropertyListView::sm_dialogCancelled = FALSE; IMPLEMENT_DYNAMIC_CLASS(wxPropertyListView, wxPropertyView) BEGIN_EVENT_TABLE(wxPropertyListView, wxPropertyView) - EVT_BUTTON(wxID_OK, wxPropertyListView::OnOk) - EVT_BUTTON(wxID_CANCEL, wxPropertyListView::OnCancel) - EVT_BUTTON(wxID_HELP, wxPropertyListView::OnHelp) - EVT_BUTTON(wxID_PROP_CROSS, wxPropertyListView::OnCross) - EVT_BUTTON(wxID_PROP_CHECK, wxPropertyListView::OnCheck) - EVT_BUTTON(wxID_PROP_EDIT, wxPropertyListView::OnEdit) - EVT_TEXT_ENTER(wxID_PROP_TEXT, wxPropertyListView::OnText) - EVT_LISTBOX(wxID_PROP_SELECT, wxPropertyListView::OnPropertySelect) - EVT_COMMAND(wxID_PROP_SELECT, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxPropertyListView::OnPropertyDoubleClick) - EVT_LISTBOX(wxID_PROP_VALUE_SELECT, wxPropertyListView::OnValueListSelect) + EVT_BUTTON(wxID_OK, wxPropertyListView::OnOk) + EVT_BUTTON(wxID_CANCEL, wxPropertyListView::OnCancel) + EVT_BUTTON(wxID_HELP, wxPropertyListView::OnHelp) + EVT_BUTTON(wxID_PROP_CROSS, wxPropertyListView::OnCross) + EVT_BUTTON(wxID_PROP_CHECK, wxPropertyListView::OnCheck) + EVT_BUTTON(wxID_PROP_EDIT, wxPropertyListView::OnEdit) + EVT_TEXT_ENTER(wxID_PROP_TEXT, wxPropertyListView::OnText) + EVT_LISTBOX(wxID_PROP_SELECT, wxPropertyListView::OnPropertySelect) + EVT_COMMAND(wxID_PROP_SELECT, wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, + wxPropertyListView::OnPropertyDoubleClick) + EVT_LISTBOX(wxID_PROP_VALUE_SELECT, wxPropertyListView::OnValueListSelect) END_EVENT_TABLE() -bool wxPropertyListView::sm_dialogCancelled = FALSE; -wxBitmap *wxPropertyListView::sm_tickBitmap = NULL; -wxBitmap *wxPropertyListView::sm_crossBitmap = NULL; - wxPropertyListView::wxPropertyListView(wxPanel *propPanel, long flags):wxPropertyView(flags) { m_propertyScrollingList = NULL; @@ -109,14 +131,8 @@ wxPropertyListView::wxPropertyListView(wxPanel *propPanel, long flags):wxPropert m_detailedEditing = FALSE; } -wxPropertyListView::~wxPropertyListView(void) +wxPropertyListView::~wxPropertyListView() { -/* - if (m_tickBitmap) - delete m_tickBitmap; - if (m_crossBitmap) - delete m_crossBitmap; -*/ } void wxPropertyListView::ShowView(wxPropertySheet *ps, wxPanel *panel) @@ -132,7 +148,7 @@ void wxPropertyListView::ShowView(wxPropertySheet *ps, wxPanel *panel) // Update this view of the viewed object, called e.g. by // the object itself. -bool wxPropertyListView::OnUpdateView(void) +bool wxPropertyListView::OnUpdateView() { return TRUE; } @@ -156,8 +172,7 @@ bool wxPropertyListView::UpdatePropertyList(bool clearEditArea) wxProperty *property = (wxProperty *)node->Data(); wxString stringValueRepr(property->GetValue().GetStringRepresentation()); wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr)); - - m_propertyScrollingList->Append(paddedString.GetData(), (char *)property); + m_propertyScrollingList->Append(paddedString.GetData(), (void *)property); node = node->Next(); } return TRUE; @@ -168,7 +183,9 @@ bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) if (!m_propertyScrollingList || !m_propertySheet) return FALSE; +#ifdef __WXMSW__ int currentlySelected = m_propertyScrollingList->GetSelection(); +#endif // #ifdef __WXMSW__ wxString stringValueRepr(property->GetValue().GetStringRepresentation()); wxString paddedString(MakeNameValueString(property->GetName(), stringValueRepr)); @@ -178,7 +195,7 @@ bool wxPropertyListView::UpdatePropertyDisplayInList(wxProperty *property) { // Don't update the listbox unnecessarily because it can cause // ugly flashing. - + if (paddedString != m_propertyScrollingList->GetString(sel)) m_propertyScrollingList->SetString(sel, paddedString.GetData()); } @@ -292,7 +309,7 @@ bool wxPropertyListView::EndShowingProperty(wxProperty *property) return TRUE; } -void wxPropertyListView::BeginDetailedEditing(void) +void wxPropertyListView::BeginDetailedEditing() { if (!m_currentValidator) return; @@ -311,7 +328,7 @@ void wxPropertyListView::BeginDetailedEditing(void) m_detailedEditing = TRUE; } -void wxPropertyListView::EndDetailedEditing(void) +void wxPropertyListView::EndDetailedEditing() { if (!m_currentValidator) return; @@ -399,256 +416,125 @@ void wxPropertyListView::OnPropertySelect(wxCommandEvent& WXUNUSED(event)) } } -bool wxPropertyListView::CreateControls(void) +bool wxPropertyListView::CreateControls() { - wxPanel *panel = (wxPanel *)m_propertyWindow; - - int largeButtonWidth = 60; - int largeButtonHeight = 25; + wxPanel *panel = (wxPanel *)m_propertyWindow; - int smallButtonWidth = 25; - int smallButtonHeight = 20; + wxSize largeButtonSize( 70, 25 ); + wxSize smallButtonSize( 23, 23 ); - // XView must be allowed to choose its own sized buttons -#ifdef __XVIEW__ - largeButtonWidth = -1; - largeButtonHeight = -1; - - smallButtonWidth = -1; - smallButtonHeight = -1; -#endif - - if (m_valueText) - return TRUE; - - if (!panel) - return FALSE; + if (m_valueText) + return TRUE; - wxWindow *leftMostWindow = panel; - wxWindow *topMostWindow = panel; - wxWindow *rightMostWindow = panel; + if (!panel) + return FALSE; - wxSystemSettings settings; - wxFont guiFont = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + wxSystemSettings settings; + wxFont guiFont = settings.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, "Courier New"); #else - wxFont *boringFont = wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxTELETYPE, wxNORMAL, wxNORMAL); + wxFont *boringFont = wxTheFontList->FindOrCreateFont(guiFont.GetPointSize(), wxTELETYPE, wxNORMAL, wxNORMAL); #endif - // May need to be changed in future to eliminate clashes with app. - // WHAT WAS THIS FOR? + // May need to be changed in future to eliminate clashes with app. + // WHAT WAS THIS FOR? // panel->SetClientData((char *)this); - // These buttons are at the bottom of the window, but create them now - // so the constraints are evaluated in the correct order - if (m_buttonFlags & wxPROP_BUTTON_OK) - { - m_windowCloseButton = new wxButton(panel, wxID_OK, "OK", - wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - m_windowCloseButton->SetDefault(); - m_windowCloseButton->SetFocus(); - } - else if (m_buttonFlags & wxPROP_BUTTON_CLOSE) - { - m_windowCloseButton = new wxButton(panel, wxID_OK, "Close", - wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - } - if (m_buttonFlags & wxPROP_BUTTON_CANCEL) - { - m_windowCancelButton = new wxButton(panel, wxID_CANCEL, "Cancel", - wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - } - if (m_buttonFlags & wxPROP_BUTTON_HELP) - { - m_windowHelpButton = new wxButton(panel, wxID_HELP, "Help", - wxPoint(-1, -1), wxSize(largeButtonWidth, largeButtonHeight)); - } + wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL ); - if (m_windowCloseButton) - { - wxLayoutConstraints *c1 = new wxLayoutConstraints; - - c1->left.SameAs (panel, wxLeft, 2); - c1->bottom.SameAs (panel, wxBottom, 2); - c1->width.AsIs(); - c1->height.AsIs(); - m_windowCloseButton->SetConstraints(c1); - leftMostWindow = m_windowCloseButton; - } - if (m_windowCancelButton) - { - wxLayoutConstraints *c2 = new wxLayoutConstraints; - - c2->right.SameAs (panel, wxRight, 2); - c2->bottom.SameAs (panel, wxBottom, 2); - c2->width.AsIs(); - c2->height.AsIs(); - m_windowCancelButton->SetConstraints(c2); - leftMostWindow = m_windowCancelButton; - } - if (m_windowHelpButton) - { - wxLayoutConstraints *c2 = new wxLayoutConstraints; - if (leftMostWindow == panel) - c2->left.SameAs (panel, wxLeft, 2); - else - c2->left.RightOf (leftMostWindow, 2); - - c2->bottom.SameAs (panel, wxBottom, 2); - c2->width.AsIs(); - c2->height.AsIs(); - m_windowHelpButton->SetConstraints(c2); - leftMostWindow = m_windowHelpButton; - } + // top row with optional buttons and input line - if (m_buttonFlags & wxPROP_BUTTON_CHECK_CROSS) - { -/* - if (!tickBitmap) - { -#ifdef __WXMSW__ - tickBitmap = new wxBitmap("tick_bmp", wxBITMAP_TYPE_RESOURCE); - crossBitmap = new wxBitmap("cross_bmp", wxBITMAP_TYPE_RESOURCE); - if (!tickBitmap || !crossBitmap || !tickBitmap->Ok() || !crossBitmap->Ok()) - { - if (tickBitmap) - delete tickBitmap; - if (crossBitmap) - delete crossBitmap; - tickBitmap = NULL; - crossBitmap = NULL; - } -#endif - } -*/ -/* - if (tickBitmap && crossBitmap) - { - m_confirmButton = new wxBitmapButton(panel, wxID_PROP_CHECK, tickBitmap, - wxPoint(-1, -1), wxSize(smallButtonWidth-5, smallButtonHeight-5)); - m_cancelButton = new wxBitmapButton(panel, wxID_PROP_CROSS, crossBitmap, - wxPoint(-1, -1), wxSize(smallButtonWidth-5, smallButtonHeight-5)); - } - else -*/ - { - m_confirmButton = new wxButton(panel, wxID_PROP_CHECK, ":-)", - wxPoint(-1, -1), wxSize(smallButtonWidth, smallButtonHeight)); - m_cancelButton = new wxButton(panel, wxID_PROP_CROSS, "X", - wxPoint(-1, -1), wxSize(smallButtonWidth, smallButtonHeight)); - } - - wxLayoutConstraints *c = new wxLayoutConstraints; - c->left.SameAs (panel, wxLeft, 2); -/* - if (windowCloseButton) - c->top.Below (m_windowCloseButton, 2); - else -*/ - c->top.SameAs (panel, wxTop, 2); - - c->width.AsIs(); - c->height.AsIs(); - - m_cancelButton->SetConstraints(c); - - c = new wxLayoutConstraints; - c->left.RightOf (m_cancelButton, 2); - c->top.SameAs (m_cancelButton, wxTop, 0); - c->width.AsIs(); - c->height.AsIs(); - - m_confirmButton->SetConstraints(c); - - m_cancelButton->Enable(FALSE); - m_confirmButton->Enable(FALSE); - } - - if (m_buttonFlags & wxPROP_PULLDOWN) - { - m_editButton = new wxButton(panel, wxID_PROP_EDIT, "...", - wxPoint(-1, -1), wxSize(smallButtonWidth, smallButtonHeight)); - m_editButton->Enable(FALSE); - wxLayoutConstraints *c = new wxLayoutConstraints; - -/* - if (m_windowCloseButton) - c->top.Below (m_windowCloseButton, 2); - else -*/ - c->top.SameAs (panel, wxTop, 2); + wxBoxSizer *topsizer = new wxBoxSizer( wxHORIZONTAL ); + int buttonborder = 3; - c->right.SameAs (panel, wxRight, 2); - c->width.AsIs(); - c->height.AsIs(); - m_editButton->SetConstraints(c); - } - - m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, "", wxPoint(-1, -1), wxSize(-1, -1), wxPROCESS_ENTER); - m_valueText->Enable(FALSE); - - wxLayoutConstraints *c = new wxLayoutConstraints; + if (m_buttonFlags & wxPROP_BUTTON_CHECK_CROSS) + { + wxBitmap *tickBitmap = GetTickBitmap(); + wxBitmap *crossBitmap = GetCrossBitmap(); - if (m_cancelButton) - c->left.RightOf (m_confirmButton, 2); - else - c->left.SameAs (panel, wxLeft, 2); -/* - if (m_windowCloseButton) - c->top.Below (m_windowCloseButton, 2); - else -*/ - c->top.SameAs (panel, wxTop, 2); + if ( tickBitmap && crossBitmap ) + { + 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 ); + } - if (m_editButton) - c->right.LeftOf (m_editButton, 2); - else - c->right.SameAs (panel, wxRight, 2); - c->height.AsIs(); + topsizer->Add( m_confirmButton, 0, wxLEFT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); + topsizer->Add( m_cancelButton, 0, wxLEFT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); + } - m_valueText->SetConstraints(c); + m_valueText = new wxPropertyTextEdit(this, panel, wxID_PROP_TEXT, "", + wxPoint(-1, -1), wxSize(-1, smallButtonSize.y), wxPROCESS_ENTER); + m_valueText->Enable(FALSE); + topsizer->Add( m_valueText, 1, wxALL | wxEXPAND, buttonborder ); - m_valueList = new wxListBox(panel, wxID_PROP_VALUE_SELECT, wxPoint(-1, -1), wxSize(-1, 60)); - m_valueList->Show(FALSE); + if (m_buttonFlags & wxPROP_PULLDOWN) + { + m_editButton = new wxButton(panel, wxID_PROP_EDIT, "...", wxPoint(-1, -1), smallButtonSize); + m_editButton->Enable(FALSE); + topsizer->Add( m_editButton, 0, wxRIGHT|wxTOP|wxBOTTOM | wxEXPAND, buttonborder ); + } - c = new wxLayoutConstraints; + mainsizer->Add( topsizer, 0, wxEXPAND ); - c->left.SameAs (panel, wxLeft, 2); - c->top.Below (m_valueText, 2); - c->right.SameAs (panel, wxRight, 2); - c->height.Absolute(60); + // middle section with two list boxes - m_valueList->SetConstraints(c); + m_middleSizer = new wxBoxSizer( wxVERTICAL ); - m_propertyScrollingList = new wxListBox(panel, wxID_PROP_SELECT, - wxPoint(-1, -1), wxSize(300, 300)); - m_propertyScrollingList->SetFont(* boringFont); + m_valueList = new wxListBox(panel, wxID_PROP_VALUE_SELECT, wxPoint(-1, -1), wxSize(-1, 60)); + m_valueList->Show(FALSE); - c = new wxLayoutConstraints; + m_propertyScrollingList = new wxListBox(panel, wxID_PROP_SELECT, wxPoint(-1, -1), wxSize(100, 100)); + m_propertyScrollingList->SetFont(* boringFont); + m_middleSizer->Add( m_propertyScrollingList, 1, wxALL|wxEXPAND, buttonborder ); - c->left.SameAs (panel, wxLeft, 2); + mainsizer->Add( m_middleSizer, 1, wxEXPAND ); - if (m_buttonFlags & wxPROP_DYNAMIC_VALUE_FIELD) - c->top.Below (m_valueText, 2); - else - c->top.Below (m_valueList, 2); + // bottom row with buttons - c->right.SameAs (panel, wxRight, 2); + if ((m_buttonFlags & wxPROP_BUTTON_OK) || + (m_buttonFlags & wxPROP_BUTTON_CLOSE) || + (m_buttonFlags & wxPROP_BUTTON_CANCEL) || + (m_buttonFlags & wxPROP_BUTTON_HELP)) + { + wxBoxSizer *bottomsizer = new wxBoxSizer( wxHORIZONTAL ); + buttonborder = 5; - if (m_windowCloseButton) - c->bottom.Above (m_windowCloseButton, -2); - else - c->bottom.SameAs (panel, wxBottom, 2); + if (m_buttonFlags & wxPROP_BUTTON_OK) + { + m_windowCloseButton = new wxButton(panel, wxID_OK, _("OK"), wxPoint(-1, -1), largeButtonSize ); + m_windowCloseButton->SetDefault(); + m_windowCloseButton->SetFocus(); + bottomsizer->Add( m_windowCloseButton, 0, wxALL, buttonborder ); + } + else if (m_buttonFlags & wxPROP_BUTTON_CLOSE) + { + m_windowCloseButton = new wxButton(panel, wxID_OK, _("Close"), wxPoint(-1, -1), largeButtonSize ); + bottomsizer->Add( m_windowCloseButton, 0, wxALL, buttonborder ); + } + if (m_buttonFlags & wxPROP_BUTTON_CANCEL) + { + m_windowCancelButton = new wxButton(panel, wxID_CANCEL, _("Cancel"), wxPoint(-1, -1), largeButtonSize ); + bottomsizer->Add( m_windowCancelButton, 0, wxALL, buttonborder ); + } + if (m_buttonFlags & wxPROP_BUTTON_HELP) + { + m_windowHelpButton = new wxButton(panel, wxID_HELP, _("Help"), wxPoint(-1, -1), largeButtonSize ); + bottomsizer->Add( m_windowHelpButton, 0, wxALL, buttonborder ); + } - m_propertyScrollingList->SetConstraints(c); + mainsizer->Add( bottomsizer, 0, wxALIGN_RIGHT | wxEXPAND ); + } - // Note: if this is called now, it causes a GPF. - // Why? -// panel->Layout(); + panel->SetSizer( mainsizer ); - return TRUE; + return TRUE; } void wxPropertyListView::ShowTextControl(bool show) @@ -659,30 +545,19 @@ void wxPropertyListView::ShowTextControl(bool show) void wxPropertyListView::ShowListBoxControl(bool show) { - if (m_valueList) - { + if (!m_valueList) return; + m_valueList->Show(show); + if (m_buttonFlags & wxPROP_DYNAMIC_VALUE_FIELD) { - wxLayoutConstraints *constraints = m_propertyScrollingList->GetConstraints(); - if (constraints) - { if (show) - { - constraints->top.Below(m_valueList, 2); - // Maintain back-pointer so when valueList is deleted, - // any reference to it from this window is removed. - m_valueList->AddConstraintReference(m_propertyScrollingList); - } + m_middleSizer->Prepend( m_valueList, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 3 ); else - { - constraints->top.Below(m_valueText, 2); - m_valueText->AddConstraintReference(m_propertyScrollingList); - } + m_middleSizer->Remove( 0 ); + m_propertyWindow->Layout(); - } } - } } void wxPropertyListView::EnableCheck(bool show) @@ -697,12 +572,12 @@ void wxPropertyListView::EnableCross(bool show) m_cancelButton->Enable(show); } -bool wxPropertyListView::OnClose(void) +bool wxPropertyListView::OnClose() { // Retrieve the value if any wxCommandEvent event; OnCheck(event); - + delete this; return TRUE; } @@ -724,7 +599,7 @@ void wxPropertyListView::OnOk(wxCommandEvent& event) { // Retrieve the value if any OnCheck(event); - + m_managedWindow->Close(TRUE); } @@ -796,18 +671,19 @@ void wxPropertyListView::OnText(wxCommandEvent& event) } } -/* - * Property dialog box - */ - -IMPLEMENT_CLASS(wxPropertyListDialog, wxDialog) +// ---------------------------------------------------------------------------- +// Property dialog box +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxPropertyListDialog, wxDialog) BEGIN_EVENT_TABLE(wxPropertyListDialog, wxDialog) - EVT_BUTTON(wxID_CANCEL, wxPropertyListDialog::OnCancel) + EVT_BUTTON(wxID_CANCEL, wxPropertyListDialog::OnCancel) + EVT_CLOSE(wxPropertyListDialog::OnCloseWindow) END_EVENT_TABLE() wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *parent, - const wxString& title, const wxPoint& pos, + const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxDialog(parent, -1, title, pos, size, style, name) { @@ -817,26 +693,28 @@ wxPropertyListDialog::wxPropertyListDialog(wxPropertyListView *v, wxWindow *pare SetAutoLayout(TRUE); } -bool wxPropertyListDialog::OnClose(void) +void wxPropertyListDialog::OnCloseWindow(wxCloseEvent& event) { if (m_view) { - SetReturnCode(wxID_CANCEL); + SetReturnCode(wxID_CANCEL); m_view->OnClose(); - m_view = NULL; - return TRUE; + m_view = NULL; + this->Destroy(); } else - return FALSE; + { + event.Veto(); + } } void wxPropertyListDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { - SetReturnCode(wxID_CANCEL); + SetReturnCode(wxID_CANCEL); this->Close(); } -void wxPropertyListDialog::OnDefaultAction(wxControl *item) +void wxPropertyListDialog::OnDefaultAction(wxControl *WXUNUSED(item)) { /* if (item == m_view->GetPropertyScrollingList()) @@ -847,17 +725,17 @@ void wxPropertyListDialog::OnDefaultAction(wxControl *item) // Extend event processing to search the view's event table bool wxPropertyListDialog::ProcessEvent(wxEvent& event) { - if ( !m_view || ! m_view->ProcessEvent(event) ) - return wxEvtHandler::ProcessEvent(event); - else - return TRUE; + if ( !m_view || ! m_view->ProcessEvent(event) ) + return wxEvtHandler::ProcessEvent(event); + else + return TRUE; } -/* - * Property panel - */ - -IMPLEMENT_CLASS(wxPropertyListPanel, wxPanel) +// ---------------------------------------------------------------------------- +// Property panel +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxPropertyListPanel, wxPanel) BEGIN_EVENT_TABLE(wxPropertyListPanel, wxPanel) EVT_SIZE(wxPropertyListPanel::OnSize) @@ -867,7 +745,7 @@ wxPropertyListPanel::~wxPropertyListPanel() { } -void wxPropertyListPanel::OnDefaultAction(wxControl *item) +void wxPropertyListPanel::OnDefaultAction(wxControl *WXUNUSED(item)) { /* if (item == view->GetPropertyScrollingList()) @@ -878,10 +756,10 @@ void wxPropertyListPanel::OnDefaultAction(wxControl *item) // Extend event processing to search the view's event table bool wxPropertyListPanel::ProcessEvent(wxEvent& event) { - if ( !m_view || ! m_view->ProcessEvent(event) ) - return wxEvtHandler::ProcessEvent(event); - else - return TRUE; + if ( !m_view || ! m_view->ProcessEvent(event) ) + return wxEvtHandler::ProcessEvent(event); + else + return TRUE; } void wxPropertyListPanel::OnSize(wxSizeEvent& WXUNUSED(event)) @@ -889,13 +767,17 @@ void wxPropertyListPanel::OnSize(wxSizeEvent& WXUNUSED(event)) Layout(); } -/* - * Property frame - */ - -IMPLEMENT_CLASS(wxPropertyListFrame, wxFrame) +// ---------------------------------------------------------------------------- +// Property frame +// ---------------------------------------------------------------------------- -bool wxPropertyListFrame::OnClose(void) +IMPLEMENT_DYNAMIC_CLASS(wxPropertyListFrame, wxFrame) + +BEGIN_EVENT_TABLE(wxPropertyListFrame, wxFrame) + EVT_CLOSE(wxPropertyListFrame::OnCloseWindow) +END_EVENT_TABLE() + +void wxPropertyListFrame::OnCloseWindow(wxCloseEvent& event) { if (m_view) { @@ -903,10 +785,12 @@ bool wxPropertyListFrame::OnClose(void) m_propertyPanel->SetView(NULL); m_view->OnClose(); m_view = NULL; - return TRUE; + this->Destroy(); } else - return FALSE; + { + event.Veto(); + } } wxPropertyListPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPropertyListView *v) @@ -914,7 +798,7 @@ wxPropertyListPanel *wxPropertyListFrame::OnCreatePanel(wxFrame *parent, wxPrope return new wxPropertyListPanel(v, parent); } -bool wxPropertyListFrame::Initialize(void) +bool wxPropertyListFrame::Initialize() { m_propertyPanel = OnCreatePanel(this, m_view); if (m_propertyPanel) @@ -928,10 +812,10 @@ bool wxPropertyListFrame::Initialize(void) return FALSE; } - /* - * Property list specific validator - */ - +// ---------------------------------------------------------------------------- +// Property list specific validator +// ---------------------------------------------------------------------------- + IMPLEMENT_ABSTRACT_CLASS(wxPropertyListValidator, wxPropertyValidator) bool wxPropertyListValidator::OnSelect(bool select, wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) @@ -943,10 +827,10 @@ bool wxPropertyListValidator::OnSelect(bool select, wxProperty *property, wxProp return TRUE; } -bool wxPropertyListValidator::OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxPropertyListValidator::OnValueListSelect(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { wxString s(view->GetValueList()->GetStringSelection()); - if (s != "") + if (s != wxT("")) { view->GetValueText()->SetValue(s); view->RetrieveProperty(property); @@ -954,7 +838,7 @@ bool wxPropertyListValidator::OnValueListSelect(wxProperty *property, wxProperty return TRUE; } -bool wxPropertyListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxPropertyListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { // view->GetValueText()->Show(TRUE); wxString str(property->GetValue().GetStringRepresentation()); @@ -966,14 +850,14 @@ bool wxPropertyListValidator::OnDisplayValue(wxProperty *property, wxPropertyLis // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxPropertyListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxPropertyListValidator::OnRetrieveValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; return FALSE; } -void wxPropertyListValidator::OnEdit(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +void wxPropertyListValidator::OnEdit(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetDetailedEditing()) view->EndDetailedEditing(); @@ -981,7 +865,7 @@ void wxPropertyListValidator::OnEdit(wxProperty *property, wxPropertyListView *v view->BeginDetailedEditing(); } -bool wxPropertyListValidator::OnClearControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxPropertyListValidator::OnClearControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) view->GetConfirmButton()->Enable(FALSE); @@ -992,20 +876,20 @@ bool wxPropertyListValidator::OnClearControls(wxProperty *property, wxPropertyLi return TRUE; } -/* - * Default validators - */ +// ---------------------------------------------------------------------------- +// Default validators +// ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxRealListValidator, wxPropertyListValidator) /// /// Real number validator -/// -bool wxRealListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +/// +bool wxRealListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow) { if (m_realMin == 0.0 && m_realMax == 0.0) return TRUE; - + if (!view->GetValueText()) return FALSE; wxString value(view->GetValueText()->GetValue()); @@ -1013,12 +897,12 @@ bool wxRealListValidator::OnCheckValue(wxProperty *property, wxPropertyListView float val = 0.0; if (!StringToFloat(WXSTRINGCAST value, &val)) { - char buf[200]; - sprintf(buf, "Value %s is not a valid real number!", value.GetData()); - wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxChar buf[200]; + wxSprintf(buf, wxT("Value %s is not a valid real number!"), value.GetData()); + wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } - + if (val < m_realMin || val > m_realMax) { char buf[200]; @@ -1032,21 +916,21 @@ bool wxRealListValidator::OnCheckValue(wxProperty *property, wxPropertyListView // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxRealListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxRealListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; - if (strlen(view->GetValueText()->GetValue()) == 0) + if (wxStrlen(view->GetValueText()->GetValue()) == 0) return FALSE; - + wxString value(view->GetValueText()->GetValue()); - float f = (float)atof(value.GetData()); + float f = (float)wxAtof(value.GetData()); property->GetValue() = f; return TRUE; } -bool wxRealListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxRealListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) view->GetConfirmButton()->Enable(TRUE); @@ -1061,14 +945,14 @@ bool wxRealListValidator::OnPrepareControls(wxProperty *property, wxPropertyList /// /// Integer validator -/// +/// IMPLEMENT_DYNAMIC_CLASS(wxIntegerListValidator, wxPropertyListValidator) -bool wxIntegerListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxIntegerListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow) { if (m_integerMin == 0 && m_integerMax == 0) return TRUE; - + if (!view->GetValueText()) return FALSE; wxString value(view->GetValueText()->GetValue()); @@ -1076,16 +960,16 @@ bool wxIntegerListValidator::OnCheckValue(wxProperty *property, wxPropertyListVi long val = 0; if (!StringToLong(WXSTRINGCAST value, &val)) { - char buf[200]; - sprintf(buf, "Value %s is not a valid integer!", value.GetData()); - wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxChar buf[200]; + wxSprintf(buf, wxT("Value %s is not a valid integer!"), value.GetData()); + wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } if (val < m_integerMin || val > m_integerMax) { - char buf[200]; - sprintf(buf, "Value must be an integer between %ld and %ld!", m_integerMin, m_integerMax); - wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxChar buf[200]; + wxSprintf(buf, wxT("Value must be an integer between %ld and %ld!"), m_integerMin, m_integerMax); + wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } return TRUE; @@ -1094,21 +978,21 @@ bool wxIntegerListValidator::OnCheckValue(wxProperty *property, wxPropertyListVi // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxIntegerListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxIntegerListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; - if (strlen(view->GetValueText()->GetValue()) == 0) + if (wxStrlen(view->GetValueText()->GetValue()) == 0) return FALSE; - + wxString value(view->GetValueText()->GetValue()); - long val = (long)atoi(value.GetData()); + long val = (long)wxAtoi(value.GetData()); property->GetValue() = (long)val; return TRUE; } -bool wxIntegerListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxIntegerListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) view->GetConfirmButton()->Enable(TRUE); @@ -1126,14 +1010,14 @@ bool wxIntegerListValidator::OnPrepareControls(wxProperty *property, wxPropertyL /// IMPLEMENT_DYNAMIC_CLASS(wxBoolListValidator, wxPropertyListValidator) -bool wxBoolListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxBoolListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow) { if (!view->GetValueText()) return FALSE; wxString value(view->GetValueText()->GetValue()); - if (value != "True" && value != "False") + if (value != wxT("True") && value != wxT("False")) { - wxMessageBox("Value must be True or False!", "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxMessageBox(wxT("Value must be True or False!"), wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } return TRUE; @@ -1142,17 +1026,17 @@ bool wxBoolListValidator::OnCheckValue(wxProperty *property, wxPropertyListView // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxBoolListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxBoolListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; - if (strlen(view->GetValueText()->GetValue()) == 0) + if (wxStrlen(view->GetValueText()->GetValue()) == 0) return FALSE; - + wxString value(view->GetValueText()->GetValue()); bool boolValue = FALSE; - if (value == "True") + if (value == wxT("True")) boolValue = TRUE; else boolValue = FALSE; @@ -1160,7 +1044,7 @@ bool wxBoolListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListVi return TRUE; } -bool wxBoolListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxBoolListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1175,7 +1059,7 @@ bool wxBoolListValidator::OnDisplayValue(wxProperty *property, wxPropertyListVie return TRUE; } -bool wxBoolListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxBoolListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) view->GetConfirmButton()->Enable(FALSE); @@ -1188,23 +1072,23 @@ bool wxBoolListValidator::OnPrepareControls(wxProperty *property, wxPropertyList return TRUE; } -bool wxBoolListValidator::OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxBoolListValidator::OnPrepareDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetValueList()) { view->ShowListBoxControl(TRUE); view->GetValueList()->Enable(TRUE); - - view->GetValueList()->Append("True"); - view->GetValueList()->Append("False"); - char *currentString = copystring(view->GetValueText()->GetValue()); + + view->GetValueList()->Append(wxT("True")); + view->GetValueList()->Append(wxT("False")); + wxChar *currentString = copystring(view->GetValueText()->GetValue()); view->GetValueList()->SetStringSelection(currentString); delete[] currentString; } return TRUE; } -bool wxBoolListValidator::OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxBoolListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetValueList()) { @@ -1217,7 +1101,7 @@ bool wxBoolListValidator::OnClearDetailControls(wxProperty *property, wxProperty // Called when the property is double clicked. Extra functionality can be provided, // cycling through possible values. -bool wxBoolListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxBoolListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1233,7 +1117,7 @@ bool wxBoolListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView /// /// String validator -/// +/// IMPLEMENT_DYNAMIC_CLASS(wxStringListValidator, wxPropertyListValidator) wxStringListValidator::wxStringListValidator(wxStringList *list, long flags): @@ -1245,7 +1129,7 @@ wxStringListValidator::wxStringListValidator(wxStringList *list, long flags): m_validatorFlags |= wxPROP_ALLOW_TEXT_EDITING; } -bool wxStringListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxStringListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *parentWindow) { if (!m_strings) return TRUE; @@ -1268,7 +1152,7 @@ bool wxStringListValidator::OnCheckValue(wxProperty *property, wxPropertyListVie // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxStringListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxStringListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1280,7 +1164,7 @@ bool wxStringListValidator::OnRetrieveValue(wxProperty *property, wxPropertyList // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1293,7 +1177,7 @@ bool wxStringListValidator::OnDisplayValue(wxProperty *property, wxPropertyListV return TRUE; } -bool wxStringListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxStringListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { // Unconstrained if (!m_strings) @@ -1308,7 +1192,7 @@ bool wxStringListValidator::OnPrepareControls(wxProperty *property, wxPropertyLi view->GetValueText()->Enable(TRUE); return TRUE; } - + // Constrained if (view->GetValueText()) view->GetValueText()->Enable(FALSE); @@ -1323,7 +1207,7 @@ bool wxStringListValidator::OnPrepareControls(wxProperty *property, wxPropertyLi return TRUE; } -bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetValueList()) { @@ -1332,17 +1216,17 @@ bool wxStringListValidator::OnPrepareDetailControls(wxProperty *property, wxProp wxNode *node = m_strings->First(); while (node) { - char *s = (char *)node->Data(); + wxChar *s = (wxChar *)node->Data(); view->GetValueList()->Append(s); node = node->Next(); } - char *currentString = property->GetValue().StringValue(); + wxChar *currentString = property->GetValue().StringValue(); view->GetValueList()->SetStringSelection(currentString); } return TRUE; } -bool wxStringListValidator::OnClearDetailControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxStringListValidator::OnClearDetailControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!m_strings) { @@ -1360,7 +1244,7 @@ bool wxStringListValidator::OnClearDetailControls(wxProperty *property, wxProper // Called when the property is double clicked. Extra functionality can be provided, // cycling through possible values. -bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1368,17 +1252,17 @@ bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListVi return FALSE; wxNode *node = m_strings->First(); - char *currentString = property->GetValue().StringValue(); + wxChar *currentString = property->GetValue().StringValue(); while (node) { - char *s = (char *)node->Data(); - if (strcmp(s, currentString) == 0) + wxChar *s = (wxChar *)node->Data(); + if (wxStrcmp(s, currentString) == 0) { - char *nextString = NULL; + wxChar *nextString = NULL; if (node->Next()) - nextString = (char *)node->Next()->Data(); + nextString = (wxChar *)node->Next()->Data(); else - nextString = (char *)m_strings->First()->Data(); + nextString = (wxChar *)m_strings->First()->Data(); property->GetValue() = wxString(nextString); view->DisplayProperty(property); view->UpdatePropertyDisplayInList(property); @@ -1392,7 +1276,7 @@ bool wxStringListValidator::OnDoubleClick(wxProperty *property, wxPropertyListVi /// /// Filename validator -/// +/// IMPLEMENT_DYNAMIC_CLASS(wxFilenameListValidator, wxPropertyListValidator) wxFilenameListValidator::wxFilenameListValidator(wxString message , wxString wildcard, long flags): @@ -1400,11 +1284,11 @@ wxFilenameListValidator::wxFilenameListValidator(wxString message , wxString wil { } -wxFilenameListValidator::~wxFilenameListValidator(void) +wxFilenameListValidator::~wxFilenameListValidator() { } -bool wxFilenameListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxFilenameListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) { return TRUE; } @@ -1412,7 +1296,7 @@ bool wxFilenameListValidator::OnCheckValue(wxProperty *property, wxPropertyListV // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxFilenameListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxFilenameListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1424,7 +1308,7 @@ bool wxFilenameListValidator::OnRetrieveValue(wxProperty *property, wxPropertyLi // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxFilenameListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxFilenameListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1443,7 +1327,7 @@ bool wxFilenameListValidator::OnDoubleClick(wxProperty *property, wxPropertyList return TRUE; } -bool wxFilenameListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxFilenameListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) view->GetConfirmButton()->Enable(TRUE); @@ -1461,7 +1345,7 @@ void wxFilenameListValidator::OnEdit(wxProperty *property, wxPropertyListView *v if (!view->GetValueText()) return; - char *s = wxFileSelector( + wxString s = wxFileSelector( m_filenameMessage.GetData(), wxPathOnly(property->GetValue().StringValue()), wxFileNameFromPath(property->GetValue().StringValue()), @@ -1469,9 +1353,9 @@ void wxFilenameListValidator::OnEdit(wxProperty *property, wxPropertyListView *v m_filenameWildCard.GetData(), 0, parentWindow); - if (s) + if (s != wxT("")) { - property->GetValue() = wxString(s); + property->GetValue() = s; view->DisplayProperty(property); view->UpdatePropertyDisplayInList(property); view->OnPropertyChanged(property); @@ -1480,7 +1364,7 @@ void wxFilenameListValidator::OnEdit(wxProperty *property, wxPropertyListView *v /// /// Colour validator -/// +/// IMPLEMENT_DYNAMIC_CLASS(wxColourListValidator, wxPropertyListValidator) wxColourListValidator::wxColourListValidator(long flags): @@ -1488,11 +1372,11 @@ wxColourListValidator::wxColourListValidator(long flags): { } -wxColourListValidator::~wxColourListValidator(void) +wxColourListValidator::~wxColourListValidator() { } -bool wxColourListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxColourListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) { return TRUE; } @@ -1500,12 +1384,12 @@ bool wxColourListValidator::OnCheckValue(wxProperty *property, wxPropertyListVie // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxColourListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxColourListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; wxString value(view->GetValueText()->GetValue()); - + property->GetValue() = value ; return TRUE; } @@ -1513,7 +1397,7 @@ bool wxColourListValidator::OnRetrieveValue(wxProperty *property, wxPropertyList // Called when TICK is pressed or focus is lost or view wants to update // the property list. // Does the transferance from the property editing area to the property itself -bool wxColourListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxColourListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1532,7 +1416,7 @@ bool wxColourListValidator::OnDoubleClick(wxProperty *property, wxPropertyListVi return TRUE; } -bool wxColourListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxColourListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetConfirmButton()) view->GetConfirmButton()->Enable(TRUE); @@ -1549,8 +1433,8 @@ void wxColourListValidator::OnEdit(wxProperty *property, wxPropertyListView *vie { if (!view->GetValueText()) return; - - char *s = property->GetValue().StringValue(); + + wxChar *s = property->GetValue().StringValue(); int r = 0; int g = 0; int b = 0; @@ -1560,26 +1444,26 @@ void wxColourListValidator::OnEdit(wxProperty *property, wxPropertyListView *vie g = wxHexToDec(s+2); b = wxHexToDec(s+4); } - + wxColour col(r,g,b); - + wxColourData data; data.SetChooseFull(TRUE); data.SetColour(col); - + for (int i = 0; i < 16; i++) { wxColour colour(i*16, i*16, i*16); data.SetCustomColour(i, colour); } - + wxColourDialog dialog(parentWindow, &data); if (dialog.ShowModal() != wxID_CANCEL) { wxColourData retData = dialog.GetColourData(); col = retData.GetColour(); - - char buf[7]; + + wxChar buf[7]; wxDecToHex(col.Red(), buf); wxDecToHex(col.Green(), buf+2); wxDecToHex(col.Blue(), buf+4); @@ -1602,7 +1486,7 @@ wxListOfStringsListValidator::wxListOfStringsListValidator(long flags): { } -bool wxListOfStringsListValidator::OnCheckValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxListOfStringsListValidator::OnCheckValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) { // No constraints for an arbitrary, user-editable list of strings. return TRUE; @@ -1612,12 +1496,12 @@ bool wxListOfStringsListValidator::OnCheckValue(wxProperty *property, wxProperty // the property list. // Does the transferance from the property editing area to the property itself. // In this case, the user cannot directly edit the string list. -bool wxListOfStringsListValidator::OnRetrieveValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxListOfStringsListValidator::OnRetrieveValue(wxProperty *WXUNUSED(property), wxPropertyListView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow)) { return TRUE; } -bool wxListOfStringsListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxListOfStringsListValidator::OnDisplayValue(wxProperty *property, wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (!view->GetValueText()) return FALSE; @@ -1626,7 +1510,7 @@ bool wxListOfStringsListValidator::OnDisplayValue(wxProperty *property, wxProper return TRUE; } -bool wxListOfStringsListValidator::OnPrepareControls(wxProperty *property, wxPropertyListView *view, wxWindow *parentWindow) +bool wxListOfStringsListValidator::OnPrepareControls(wxProperty *WXUNUSED(property), wxPropertyListView *view, wxWindow *WXUNUSED(parentWindow)) { if (view->GetEditButton()) view->GetEditButton()->Enable(TRUE); @@ -1652,19 +1536,19 @@ void wxListOfStringsListValidator::OnEdit(wxProperty *property, wxPropertyListVi { // Convert property value to a list of strings for editing wxStringList *stringList = new wxStringList; - + wxPropertyValue *expr = property->GetValue().GetFirst(); while (expr) { - char *s = expr->StringValue(); + wxChar *s = expr->StringValue(); if (s) stringList->Add(s); expr = expr->GetNext(); } - - wxString title("Editing "); + + wxString title(wxT("Editing ")); title += property->GetName(); - + if (EditStringList(parentWindow, stringList, title.GetData())) { wxPropertyValue& oldValue = property->GetValue(); @@ -1672,12 +1556,12 @@ void wxListOfStringsListValidator::OnEdit(wxProperty *property, wxPropertyListVi wxNode *node = stringList->First(); while (node) { - char *s = (char *)node->Data(); + wxChar *s = (wxChar *)node->Data(); oldValue.Append(new wxPropertyValue(s)); - + node = node->Next(); } - + view->DisplayProperty(property); view->UpdatePropertyDisplayInList(property); view->OnPropertyChanged(property); @@ -1689,9 +1573,9 @@ 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"): - wxDialog(parent, -1, title, pos, size, windowStyle, name) + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + long windowStyle = wxDEFAULT_DIALOG_STYLE, const wxString& name = "stringEditorDialogBox"): + wxDialog(parent, -1, title, pos, size, windowStyle, name) { m_stringList = NULL; m_stringText = NULL; @@ -1700,16 +1584,16 @@ class wxPropertyStringListEditorDialog: public wxDialog m_currentSelection = -1; } ~wxPropertyStringListEditorDialog(void) {} - bool OnClose(void); + void OnCloseWindow(wxCloseEvent& event); void SaveCurrentSelection(void); void ShowCurrentSelection(void); - void OnOK(wxCommandEvent& event); - void OnCancel(wxCommandEvent& event); - void OnAdd(wxCommandEvent& event); - void OnDelete(wxCommandEvent& event); - void OnStrings(wxCommandEvent& event); - void OnText(wxCommandEvent& event); + void OnOK(wxCommandEvent& event); + void OnCancel(wxCommandEvent& event); + void OnAdd(wxCommandEvent& event); + void OnDelete(wxCommandEvent& event); + void OnStrings(wxCommandEvent& event); + void OnText(wxCommandEvent& event); public: wxStringList* m_stringList; @@ -1720,30 +1604,31 @@ public: DECLARE_EVENT_TABLE() }; -#define wxID_PROP_SL_ADD 3000 -#define wxID_PROP_SL_DELETE 3001 -#define wxID_PROP_SL_STRINGS 3002 -#define wxID_PROP_SL_TEXT 3003 +#define wxID_PROP_SL_ADD 3000 +#define wxID_PROP_SL_DELETE 3001 +#define wxID_PROP_SL_STRINGS 3002 +#define wxID_PROP_SL_TEXT 3003 BEGIN_EVENT_TABLE(wxPropertyStringListEditorDialog, wxDialog) - EVT_BUTTON(wxID_OK, wxPropertyStringListEditorDialog::OnOK) - EVT_BUTTON(wxID_CANCEL, wxPropertyStringListEditorDialog::OnCancel) - EVT_BUTTON(wxID_PROP_SL_ADD, wxPropertyStringListEditorDialog::OnAdd) - EVT_BUTTON(wxID_PROP_SL_DELETE, wxPropertyStringListEditorDialog::OnDelete) - EVT_LISTBOX(wxID_PROP_SL_STRINGS, wxPropertyStringListEditorDialog::OnStrings) - EVT_TEXT_ENTER(wxID_PROP_SL_TEXT, wxPropertyStringListEditorDialog::OnText) + EVT_BUTTON(wxID_OK, wxPropertyStringListEditorDialog::OnOK) + EVT_BUTTON(wxID_CANCEL, wxPropertyStringListEditorDialog::OnCancel) + EVT_BUTTON(wxID_PROP_SL_ADD, wxPropertyStringListEditorDialog::OnAdd) + EVT_BUTTON(wxID_PROP_SL_DELETE, wxPropertyStringListEditorDialog::OnDelete) + EVT_LISTBOX(wxID_PROP_SL_STRINGS, wxPropertyStringListEditorDialog::OnStrings) + EVT_TEXT_ENTER(wxID_PROP_SL_TEXT, wxPropertyStringListEditorDialog::OnText) + EVT_CLOSE(wxPropertyStringListEditorDialog::OnCloseWindow) END_EVENT_TABLE() class wxPropertyStringListEditorText: public wxTextCtrl { public: wxPropertyStringListEditorText(wxWindow *parent, wxWindowID id, const wxString& val, - const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, + const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long windowStyle = 0, const wxString& name = "text"): wxTextCtrl(parent, id, val, pos, size, windowStyle, wxDefaultValidator, name) { } - void OnKillFocus(void) + void OnKillFocus() { wxPropertyStringListEditorDialog *dialog = (wxPropertyStringListEditorDialog *)GetParent(); dialog->SaveCurrentSelection(); @@ -1753,17 +1638,17 @@ class wxPropertyStringListEditorText: public wxTextCtrl bool wxPropertyStringListEditorDialog::sm_dialogCancelled = FALSE; // Edit the string list. -bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList *stringList, const char *title) +bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList *stringList, const wxChar *title) { int largeButtonWidth = 60; int largeButtonHeight = 25; 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), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL); + dialog->m_stringList = stringList; - + dialog->m_listBox = new wxListBox(dialog, wxID_PROP_SL_STRINGS, wxPoint(-1, -1), wxSize(-1, -1), 0, NULL, wxLB_SINGLE); @@ -1777,7 +1662,9 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList 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)); +#ifndef __WXGTK__ okButton->SetDefault(); +#endif wxLayoutConstraints *c = new wxLayoutConstraints; @@ -1837,9 +1724,9 @@ bool wxListOfStringsListValidator::EditStringList(wxWindow *parent, wxStringList dialog->Centre(wxBOTH); wxEndBusyCursor(); if (dialog->ShowModal() == wxID_CANCEL) - return FALSE; + return FALSE; else - return TRUE; + return TRUE; } /* @@ -1863,13 +1750,13 @@ void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& WXUNUSED(event)) int sel = m_listBox->GetSelection(); if (sel == -1) return; - + wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(sel); if (!node) return; - + m_listBox->Delete(sel); - delete[] (char *)node->Data(); + delete[] (wxChar *)node->Data(); delete node; m_currentSelection = -1; m_stringText->SetValue(""); @@ -1878,10 +1765,10 @@ void wxPropertyStringListEditorDialog::OnDelete(wxCommandEvent& WXUNUSED(event)) void wxPropertyStringListEditorDialog::OnAdd(wxCommandEvent& WXUNUSED(event)) { SaveCurrentSelection(); - - char *initialText = ""; + + wxChar *initialText = wxT(""); wxNode *node = m_stringList->Add(initialText); - m_listBox->Append(initialText, (char *)node); + m_listBox->Append(initialText, (void *)node); m_currentSelection = m_stringList->Number() - 1; m_listBox->SetSelection(m_currentSelection); ShowCurrentSelection(); @@ -1892,48 +1779,52 @@ void wxPropertyStringListEditorDialog::OnOK(wxCommandEvent& WXUNUSED(event)) { SaveCurrentSelection(); EndModal(wxID_OK); - Close(TRUE); + // Close(TRUE); + this->Destroy(); } void wxPropertyStringListEditorDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) { sm_dialogCancelled = TRUE; EndModal(wxID_CANCEL); - Close(TRUE); +// Close(TRUE); + this->Destroy(); } void wxPropertyStringListEditorDialog::OnText(wxCommandEvent& event) { - if (event.GetEventType() == wxEVENT_TYPE_TEXT_ENTER_COMMAND) + if (event.GetEventType() == wxEVT_COMMAND_TEXT_ENTER) { SaveCurrentSelection(); } } -bool wxPropertyStringListEditorDialog::OnClose(void) +void +wxPropertyStringListEditorDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) { SaveCurrentSelection(); - return TRUE; + + Destroy(); } -void wxPropertyStringListEditorDialog::SaveCurrentSelection(void) +void wxPropertyStringListEditorDialog::SaveCurrentSelection() { if (m_currentSelection == -1) return; - + wxNode *node = (wxNode *)m_listBox->wxListBox::GetClientData(m_currentSelection); if (!node) return; - + wxString txt(m_stringText->GetValue()); if (node->Data()) delete[] (char *)node->Data(); node->SetData((wxObject *)copystring(txt)); - + m_listBox->SetString(m_currentSelection, (char *)node->Data()); } -void wxPropertyStringListEditorDialog::ShowCurrentSelection(void) +void wxPropertyStringListEditorDialog::ShowCurrentSelection() { if (m_currentSelection == -1) { @@ -1946,3 +1837,46 @@ void wxPropertyStringListEditorDialog::ShowCurrentSelection(void) 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; +} +