X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9b5bafcf38a1c6b1ad9f8974e4745c73a559a26e..58bd3862b82749175bd04809607d82f1b22f0300:/samples/propgrid/sampleprops.cpp?ds=sidebyside diff --git a/samples/propgrid/sampleprops.cpp b/samples/propgrid/sampleprops.cpp index 21303e7af4..5791ebae83 100644 --- a/samples/propgrid/sampleprops.cpp +++ b/samples/propgrid/sampleprops.cpp @@ -67,6 +67,8 @@ wxFontDataProperty::wxFontDataProperty( const wxString& label, const wxString& n // (instead of calling SetValue) in derived (wxObject) properties. m_value_wxFontData << value; + SetParentalType(wxPG_PROP_AGGREGATE); + // Add extra children. AddChild( new wxColourProperty(_("Colour"), wxPG_LABEL, fontData.GetColour() ) ); @@ -131,7 +133,7 @@ bool wxFontDataProperty::OnEvent( wxPropertyGrid* propgrid, { if ( propgrid->IsMainButtonEvent(event) ) { - wxVariant useValue = propgrid->GetPendingEditedValue(); + wxVariant useValue = propgrid->GetUncommittedPropertyValue(); wxFontData fontData; fontData << useValue; @@ -197,6 +199,7 @@ wxSizeProperty::wxSizeProperty( const wxString& label, const wxString& name, const wxSize& value) : wxPGProperty(label,name) { SetValueI(value); + SetParentalType(wxPG_PROP_AGGREGATE); AddChild( new wxIntProperty(wxT("Width"),wxPG_LABEL,value.x) ); AddChild( new wxIntProperty(wxT("Height"),wxPG_LABEL,value.y) ); } @@ -233,6 +236,7 @@ wxPointProperty::wxPointProperty( const wxString& label, const wxString& name, const wxPoint& value) : wxPGProperty(label,name) { SetValueI(value); + SetParentalType(wxPG_PROP_AGGREGATE); AddChild( new wxIntProperty(wxT("X"),wxPG_LABEL,value.x) ); AddChild( new wxIntProperty(wxT("Y"),wxPG_LABEL,value.y) ); } @@ -509,16 +513,29 @@ wxArrayDoubleProperty::~wxArrayDoubleProperty () { } void wxArrayDoubleProperty::OnSetValue() { + // Generate cached display string, to optimize grid drawing GenerateValueAsString( m_display, m_precision, true ); } -wxString wxArrayDoubleProperty::GetValueAsString( int arg_flags ) const +wxString wxArrayDoubleProperty::ValueToString( wxVariant& value, + int argFlags ) const { - if ( !(arg_flags & wxPG_FULL_VALUE )) - return m_display; - wxString s; - GenerateValueAsString(s,-1,false); + + if ( argFlags & wxPG_FULL_VALUE ) + { + GenerateValueAsString(s,-1,false); + } + else + { + // + // Display cached string only if value truly matches m_value + if ( value.GetData() == m_value.GetData() ) + return m_display; + else + GenerateValueAsString( s, m_precision, true ); + } + return s; } @@ -554,7 +571,7 @@ bool wxArrayDoubleProperty::OnEvent( wxPropertyGrid* propgrid, if ( propgrid->IsMainButtonEvent(event) ) { // Update the value in case of last minute changes - wxVariant useValue = propgrid->GetPendingEditedValue(); + wxVariant useValue = propgrid->GetUncommittedPropertyValue(); wxArrayDouble& value = wxArrayDoubleRefFromVariant(useValue);