diff --git a/include/wx/propgrid/props.h b/include/wx/propgrid/props.h index 5552c263c1..fd1beef5fb 100644 --- a/include/wx/propgrid/props.h +++ b/include/wx/propgrid/props.h @@ -692,7 +692,7 @@ protected: // ----------------------------------------------------------------------- // Property that manages a list of strings. -class WXDLLIMPEXP_PROPGRID wxArrayStringProperty : public wxPGProperty +class WXDLLIMPEXP_PROPGRID wxArrayStringProperty : public wxEditorDialogProperty { WX_PG_DECLARE_PROPERTY_CLASS(wxArrayStringProperty) public: @@ -706,8 +706,6 @@ public: virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const wxOVERRIDE; - virtual bool OnEvent( wxPropertyGrid* propgrid, - wxWindow* primary, wxEvent& event ) wxOVERRIDE; virtual bool DoSetAttribute( const wxString& name, wxVariant& value ) wxOVERRIDE; // Implement in derived class for custom array-to-string conversion. @@ -720,10 +718,13 @@ public: // should be returned if that was the case. virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); +#if WXWIN_COMPATIBILITY_3_0 // Helper. + wxDEPRECATED_MSG("OnButtonClick() function is no longer used") virtual bool OnButtonClick( wxPropertyGrid* propgrid, wxWindow* primary, const wxChar* cbt ); +#endif // WXWIN_COMPATIBILITY_3_0 // Creates wxPGArrayEditorDialog for string editing. Called in OnButtonClick. virtual wxPGArrayEditorDialog* CreateEditorDialog(); @@ -740,6 +741,8 @@ public: wxUniChar delimiter, int flags ); protected: + virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE; + // Previously this was to be implemented in derived class for array-to- // string conversion. Now you should implement ConvertValueToString() // instead. @@ -747,6 +750,7 @@ protected: wxString m_display; // Cache for displayed text. wxUniChar m_delimiter; + wxString m_customBtnText; }; // ----------------------------------------------------------------------- @@ -761,8 +765,6 @@ public: \ const wxString& name = wxPG_LABEL, \ const wxArrayString& value = wxArrayString() ); \ ~PROPNAME(); \ - virtual bool OnEvent( wxPropertyGrid* propgrid, \ - wxWindow* primary, wxEvent& event ) wxOVERRIDE; \ virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ) wxOVERRIDE; \ virtual wxValidator* DoGetValidator() const wxOVERRIDE; \ }; @@ -782,15 +784,9 @@ PROPNAME::PROPNAME( const wxString& label, \ { \ PROPNAME::GenerateValueAsString(); \ m_delimiter = DELIMCHAR; \ + m_customBtnText = CUSTBUTTXT; \ } \ -PROPNAME::~PROPNAME() { } \ -bool PROPNAME::OnEvent( wxPropertyGrid* propgrid, \ - wxWindow* primary, wxEvent& event ) \ -{ \ - if ( event.GetEventType() == wxEVT_BUTTON ) \ - return OnButtonClick(propgrid,primary, CUSTBUTTXT); \ - return false; \ -} +PROPNAME::~PROPNAME() { } #define WX_PG_DECLARE_ARRAYSTRING_PROPERTY(PROPNAME) \ WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR(PROPNAME) diff --git a/interface/wx/propgrid/props.h b/interface/wx/propgrid/props.h index 338ef6d5b8..70fd14a2e5 100644 --- a/interface/wx/propgrid/props.h +++ b/interface/wx/propgrid/props.h @@ -708,7 +708,7 @@ protected: @ingroup classes Property that manages a list of strings. */ -class wxArrayStringProperty : public wxPGProperty +class wxArrayStringProperty : public wxEditorDialogProperty { public: wxArrayStringProperty( const wxString& label = wxPG_LABEL, @@ -721,26 +721,24 @@ public: virtual bool StringToValue( wxVariant& variant, const wxString& text, int argFlags = 0 ) const; - virtual bool OnEvent( wxPropertyGrid* propgrid, - wxWindow* primary, wxEvent& event ); virtual bool DoSetAttribute( const wxString& name, wxVariant& value ); - // Implement in derived class for custom array-to-string conversion. + /** + Implement in derived class for custom array-to-string conversion. + */ virtual void ConvertArrayToString(const wxArrayString& arr, wxString* pString, const wxUniChar& delimiter) const; - // Shows string editor dialog. Value to be edited should be read from - // value, and if dialog is not cancelled, it should be stored back and true - // should be returned if that was the case. + /** + Shows string editor dialog to edit the individual item. Value to be edited + should be read from @a value, and if dialog is not cancelled, it + should be stored back and @true should be returned if that was the case. + */ virtual bool OnCustomStringEdit( wxWindow* parent, wxString& value ); - // Helper. - virtual bool OnButtonClick( wxPropertyGrid* propgrid, - wxWindow* primary, - const wxChar* cbt ); - - // Creates wxPGArrayEditorDialog for string editing. Called in OnButtonClick. + /** Creates wxPGArrayEditorDialog for string editing. + */ virtual wxPGArrayEditorDialog* CreateEditorDialog(); enum ConversionFlags @@ -750,20 +748,25 @@ public: }; /** - Generates contents for string dst based on the contents of - wxArrayString src. + Generates contents for string @a dst based on the contents of + wxArrayString @a src. */ static void ArrayStringToString( wxString& dst, const wxArrayString& src, wxUniChar delimiter, int flags ); protected: - // Previously this was to be implemented in derived class for array-to- - // string conversion. Now you should implement ConvertValueToString() - // instead. + virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value); + + /** + Previously this was to be implemented in derived class for array-to- + string conversion. Now you should implement ConvertValueToString() + instead. + */ virtual void GenerateValueAsString(); wxString m_display; // Cache for displayed text. wxUniChar m_delimiter; + wxString m_customBtnText; }; diff --git a/src/propgrid/props.cpp b/src/propgrid/props.cpp index d92882ef43..e8f5963b37 100644 --- a/src/propgrid/props.cpp +++ b/src/propgrid/props.cpp @@ -2679,16 +2679,15 @@ wxPGArrayStringEditorDialog::OnCustomNewAction(wxString* resString) // wxArrayStringProperty // ----------------------------------------------------------------------- -wxPG_IMPLEMENT_PROPERTY_CLASS(wxArrayStringProperty, // Property name - wxPGProperty, // Property we inherit from - TextCtrlAndButton) // Initial editor +wxPG_IMPLEMENT_PROPERTY_CLASS(wxArrayStringProperty, wxEditorDialogProperty, TextCtrlAndButton) wxArrayStringProperty::wxArrayStringProperty( const wxString& label, const wxString& name, const wxArrayString& array ) - : wxPGProperty(label,name) + : wxEditorDialogProperty(label,name) , m_delimiter(',') { + m_dlgStyle = wxAEDIALOG_STYLE; SetValue( array ); } @@ -2804,19 +2803,24 @@ bool wxArrayStringProperty::OnCustomStringEdit( wxWindow*, wxString& ) return false; } +#if WXWIN_COMPATIBILITY_3_0 +bool wxArrayStringProperty::OnButtonClick(wxPropertyGrid* WXUNUSED(propgrid), + wxWindow* WXUNUSED(primary), + const wxChar* WXUNUSED(cbt)) +{ + return false; +} +#endif // WXWIN_COMPATIBILITY_3_0 + wxPGArrayEditorDialog* wxArrayStringProperty::CreateEditorDialog() { return new wxPGArrayStringEditorDialog(); } -bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid, - wxWindow* WXUNUSED(primaryCtrl), - const wxChar* cbt ) +bool wxArrayStringProperty::DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) { - // Update the value - wxVariant useValue = propGrid->GetUncommittedPropertyValue(); - - if ( !propGrid->EditorValidate() ) + wxASSERT_MSG(value.IsType(wxPG_VARIANT_TYPE_ARRSTRING), "Function called for incompatible property"); + if ( !pg->EditorValidate() ) return false; // Create editor dialog. @@ -2829,14 +2833,15 @@ bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid, wxPGArrayStringEditorDialog* strEdDlg = wxDynamicCast(dlg, wxPGArrayStringEditorDialog); if ( strEdDlg ) - strEdDlg->SetCustomButton(cbt, this); + strEdDlg->SetCustomButton(m_customBtnText, this); - dlg->SetDialogValue( useValue ); - dlg->Create(propGrid, wxEmptyString, m_label); + dlg->SetDialogValue( value ); + dlg->Create(pg->GetPanel(), wxEmptyString, + m_dlgTitle.empty() ? GetLabel() : m_dlgTitle, m_dlgStyle); if ( !wxPropertyGrid::IsSmallScreen() ) { - dlg->Move( propGrid->GetGoodEditorDialogPosition(this,dlg->GetSize()) ); + dlg->Move( pg->GetGoodEditorDialogPosition(this,dlg->GetSize()) ); } bool retVal; @@ -2849,18 +2854,18 @@ bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid, if ( res == wxID_OK && dlg->IsModified() ) { - wxVariant value = dlg->GetDialogValue(); - if ( !value.IsNull() ) + wxVariant curValue = dlg->GetDialogValue(); + if ( !curValue.IsNull() ) { - wxArrayString actualValue = value.GetArrayString(); + wxArrayString actualValue = curValue.GetArrayString(); wxString tempStr; ConvertArrayToString(actualValue, &tempStr, m_delimiter); #if wxUSE_VALIDATORS - if ( dialogValidator.DoValidate(propGrid, validator, + if ( dialogValidator.DoValidate(pg, validator, tempStr) ) #endif { - SetValueInEvent( actualValue ); + value = actualValue; retVal = true; break; } @@ -2877,15 +2882,6 @@ bool wxArrayStringProperty::OnButtonClick( wxPropertyGrid* propGrid, return retVal; } -bool wxArrayStringProperty::OnEvent( wxPropertyGrid* propGrid, - wxWindow* primary, - wxEvent& event ) -{ - if ( propGrid->IsMainButtonEvent(event) ) - return OnButtonClick(propGrid,primary,(const wxChar*) NULL); - return false; -} - bool wxArrayStringProperty::StringToValue( wxVariant& variant, const wxString& text, int ) const { @@ -2925,7 +2921,7 @@ bool wxArrayStringProperty::DoSetAttribute( const wxString& name, wxVariant& val GenerateValueAsString(); return true; } - return wxPGProperty::DoSetAttribute(name, value); + return wxEditorDialogProperty::DoSetAttribute(name, value); } // -----------------------------------------------------------------------