X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e3a43801df2f05c057892481df9d3cfe30fd8800..77611ad4da9df336a0805508276a81b8f4437107:/src/generic/propform.cpp diff --git a/src/generic/propform.cpp b/src/generic/propform.cpp index 2a94303a4e..e8f651083c 100644 --- a/src/generic/propform.cpp +++ b/src/generic/propform.cpp @@ -24,25 +24,13 @@ #include "wx/wx.h" #endif +#include "wx/propform.h" + #include #include #include #include -#if wxUSE_IOSTREAMH -#if defined(__WXMSW__) && !defined(__GNUWIN32__) -#include -#else -#include -#endif -#else -#include -#endif - -#include "wx/window.h" -#include "wx/utils.h" -#include "wx/list.h" -#include "wx/propform.h" /* * Property view @@ -162,7 +150,7 @@ bool wxPropertyFormView::AssociateNames(void) while (node) { wxWindow *win = (wxWindow *)node->Data(); - if (win->GetName() != "") + if (win->GetName() != wxT("")) { wxProperty *prop = m_propertySheet->GetProperty(win->GetName()); if (prop) @@ -219,18 +207,18 @@ void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event) if (!m_propertySheet) return; - if (win.GetName() == "") + if (win.GetName() == wxT("")) return; - if (strcmp(win.GetName(), "ok") == 0) + if (wxStrcmp(win.GetName(), wxT("ok")) == 0) OnOk(event); - else if (strcmp(win.GetName(), "cancel") == 0) + else if (wxStrcmp(win.GetName(), wxT("cancel")) == 0) OnCancel(event); - else if (strcmp(win.GetName(), "help") == 0) + else if (wxStrcmp(win.GetName(), wxT("help")) == 0) OnHelp(event); - else if (strcmp(win.GetName(), "update") == 0) + else if (wxStrcmp(win.GetName(), wxT("update")) == 0) OnUpdate(event); - else if (strcmp(win.GetName(), "revert") == 0) + else if (wxStrcmp(win.GetName(), wxT("revert")) == 0) OnRevert(event); else { @@ -254,6 +242,20 @@ void wxPropertyFormView::OnCommand(wxWindow& win, wxCommandEvent& event) } } +// Extend event processing to call OnCommand +bool wxPropertyFormView::ProcessEvent(wxEvent& event) +{ + if (wxEvtHandler::ProcessEvent(event)) + return TRUE; + else if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxUpdateUIEvent)) && event.GetEventObject()) + { + OnCommand(* ((wxWindow*) event.GetEventObject()), (wxCommandEvent&) event); + return TRUE; + } + else + return FALSE; +} + void wxPropertyFormView::OnDoubleClick(wxControl *item) { if (!m_propertySheet) @@ -284,6 +286,10 @@ void wxPropertyFormView::OnDoubleClick(wxControl *item) IMPLEMENT_CLASS(wxPropertyFormDialog, wxDialog) +BEGIN_EVENT_TABLE(wxPropertyFormDialog, wxDialog) + EVT_CLOSE(wxPropertyFormDialog::OnCloseWindow) +END_EVENT_TABLE() + wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *parent, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name): wxDialog(parent, -1, title, pos, size, style, name) @@ -294,16 +300,16 @@ wxPropertyFormDialog::wxPropertyFormDialog(wxPropertyFormView *v, wxWindow *pare // SetAutoLayout(TRUE); } -bool wxPropertyFormDialog::OnClose(void) +void wxPropertyFormDialog::OnCloseWindow(wxCloseEvent& event) { if (m_view) { m_view->OnClose(); m_view = NULL; - return TRUE; + this->Destroy(); } else - return FALSE; + event.Veto(); } void wxPropertyFormDialog::OnDefaultAction(wxControl *item) @@ -358,12 +364,16 @@ bool wxPropertyFormPanel::ProcessEvent(wxEvent& event) IMPLEMENT_CLASS(wxPropertyFormFrame, wxFrame) -bool wxPropertyFormFrame::OnClose(void) +BEGIN_EVENT_TABLE(wxPropertyFormFrame, wxFrame) + EVT_CLOSE(wxPropertyFormFrame::OnCloseWindow) +END_EVENT_TABLE() + +void wxPropertyFormFrame::OnCloseWindow(wxCloseEvent& event) { - if (m_view) - return m_view->OnClose(); + if (m_view && m_view->OnClose()) + this->Destroy(); else - return FALSE; + event.Veto(); } wxPanel *wxPropertyFormFrame::OnCreatePanel(wxFrame *parent, wxPropertyFormView *v) @@ -416,17 +426,17 @@ bool wxRealFormValidator::OnCheckValue( wxProperty *property, wxPropertyFormView float val = 0.0; if (!StringToFloat(WXSTRINGCAST value, &val)) { - char buf[200]; - sprintf(buf, "Value %s is not a valid real number!", (const char *)value); - wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxChar buf[200]; + wxSprintf(buf, wxT("Value %s is not a valid real number!"), (const wxChar *)value); + wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } 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; @@ -445,7 +455,7 @@ bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormVi if (value.Length() == 0) return FALSE; - float f = (float)atof((const char *)value); + float f = (float)wxAtof((const wxChar *)value); property->GetValue() = f; return TRUE; } @@ -487,9 +497,9 @@ bool wxIntegerFormValidator::OnCheckValue(wxProperty *property, wxPropertyFormVi if (!StringToLong(WXSTRINGCAST value, &val)) { - char buf[200]; - sprintf(buf, "Value %s is not a valid integer!", (const char *)value); - wxMessageBox(buf, "Property value error", wxOK | wxICON_EXCLAMATION, parentWindow); + wxChar buf[200]; + wxSprintf(buf, wxT("Value %s is not a valid integer!"), (const wxChar *)value); + wxMessageBox(buf, wxT("Property value error"), wxOK | wxICON_EXCLAMATION, parentWindow); return FALSE; } } @@ -525,7 +535,7 @@ bool wxIntegerFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFor if (value.Length() == 0) return FALSE; - long i = atol((const char *)value); + long i = wxAtol((const wxChar *)value); property->GetValue() = i; } else if (m_propertyWindow->IsKindOf(CLASSINFO(wxSlider)))