diff --git a/samples/propgrid/sampleprops.cpp b/samples/propgrid/sampleprops.cpp index 591552248c..1d69f4dfb2 100644 --- a/samples/propgrid/sampleprops.cpp +++ b/samples/propgrid/sampleprops.cpp @@ -481,18 +481,18 @@ bool operator == (const wxArrayDouble& a, const wxArrayDouble& b) WX_PG_IMPLEMENT_VARIANT_DATA_DUMMY_EQ(wxArrayDouble) wxPG_IMPLEMENT_PROPERTY_CLASS(wxArrayDoubleProperty, - wxPGProperty, + wxEditorDialogProperty, TextCtrlAndButton) wxArrayDoubleProperty::wxArrayDoubleProperty (const wxString& label, const wxString& name, const wxArrayDouble& array ) - : wxPGProperty(label,name) + : wxEditorDialogProperty(label,name) + , m_precision(-1) { - m_precision = -1; + m_dlgStyle = wxAEDIALOG_STYLE; - // // Need to figure out delimiter needed for this locale // (i.e. can't use comma when comma acts as decimal point in float). wxChar use_delimiter = ','; @@ -538,7 +538,6 @@ wxString wxArrayDoubleProperty::ValueToString( wxVariant& value, void wxArrayDoubleProperty::GenerateValueAsString( wxString& target, int prec, bool removeZeroes ) const { wxString between = ", "; - size_t i; between[0] = m_delimiter; @@ -549,7 +548,7 @@ void wxArrayDoubleProperty::GenerateValueAsString( wxString& target, int prec, b if (removeZeroes) style = wxNumberFormatter::Style_NoTrailingZeroes; - for ( i=0; iIsMainButtonEvent(event) ) + wxASSERT_MSG(value.IsType("wxArrayDouble"), "Function called for incompatible property"); + + wxArrayDouble& curValue = wxArrayDoubleRefFromVariant(value); + + // Create editor dialog. + wxArrayDoubleEditorDialog dlg; + dlg.SetPrecision(m_precision); + dlg.Create(pg->GetPanel(), wxEmptyString, + m_dlgTitle.empty() ? GetLabel() : m_dlgTitle, curValue, m_dlgStyle); + dlg.Move( pg->GetGoodEditorDialogPosition(this,dlg.GetSize()) ); + + // Execute editor dialog + int res = dlg.ShowModal(); + if ( res == wxID_OK && dlg.IsModified() ) { - // Update the value in case of last minute changes - wxVariant useValue = propgrid->GetUncommittedPropertyValue(); - - wxArrayDouble& value = wxArrayDoubleRefFromVariant(useValue); - - // Create editor dialog. - wxArrayDoubleEditorDialog dlg; - dlg.SetPrecision(m_precision); - dlg.Create( propgrid, wxEmptyString, m_label, value ); - dlg.Move( propgrid->GetGoodEditorDialogPosition(this,dlg.GetSize()) ); - - // Execute editor dialog - int res = dlg.ShowModal(); - if ( res == wxID_OK && dlg.IsModified() ) - { - SetValueInEvent( WXVARIANT(dlg.GetArray()) ); - return true; - } - return false; + value = WXVARIANT(dlg.GetArray()); + return true; } return false; } @@ -639,7 +632,7 @@ bool wxArrayDoubleProperty::DoSetAttribute( const wxString& name, wxVariant& val GenerateValueAsString( m_display, m_precision, true ); return true; } - return wxPGProperty::DoSetAttribute(name, value); + return wxEditorDialogProperty::DoSetAttribute(name, value); } wxValidator* wxArrayDoubleProperty::DoGetValidator() const diff --git a/samples/propgrid/sampleprops.h b/samples/propgrid/sampleprops.h index b80bbf3089..c73e4ccf04 100644 --- a/samples/propgrid/sampleprops.h +++ b/samples/propgrid/sampleprops.h @@ -105,7 +105,7 @@ WX_PG_DECLARE_ARRAYSTRING_PROPERTY_WITH_VALIDATOR_WITH_DECL(wxDirsProperty, clas WX_PG_DECLARE_VARIANT_DATA(wxArrayDouble) -class wxArrayDoubleProperty : public wxPGProperty +class wxArrayDoubleProperty : public wxEditorDialogProperty { WX_PG_DECLARE_PROPERTY_CLASS(wxArrayDoubleProperty) public: @@ -121,7 +121,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; // Generates cache for displayed text @@ -132,6 +131,8 @@ public: wxPGValidationInfo& validationInfo) const wxOVERRIDE; protected: + virtual bool DisplayEditorDialog(wxPropertyGrid* pg, wxVariant& value) wxOVERRIDE; + wxString m_display; // Stores cache for displayed text int m_precision; // Used when formatting displayed string. wxChar m_delimiter; // Delimiter between array entries.