]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/propgrid/sampleprops.cpp
Use wxCONTROL_SPECIAL to denote first header button
[wxWidgets.git] / samples / propgrid / sampleprops.cpp
index d61c8677caad9680384b3986a417bc24de4c0875..5791ebae837293d458478d38d7bec75872f66dbe 100644 (file)
@@ -4,7 +4,7 @@
 // Author:      Jaakko Salli
 // Modified by:
 // Created:     2006-03-05
-// RCS-ID:      $Id:
+// RCS-ID:      $Id$
 // Copyright:   (c) Jaakko Salli
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
@@ -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,11 +133,10 @@ bool wxFontDataProperty::OnEvent( wxPropertyGrid* propgrid,
 {
     if ( propgrid->IsMainButtonEvent(event) )
     {
-        // Update value from last minute changes
-        PrepareValueForDialogEditing(propgrid);
+        wxVariant useValue = propgrid->GetUncommittedPropertyValue();
 
         wxFontData fontData;
-        fontData << m_value_wxFontData;
+        fontData << useValue;
 
         fontData.SetInitialFont(fontData.GetChosenFont());
 
@@ -198,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) );
 }
@@ -234,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) );
 }
@@ -510,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,10 +570,10 @@ bool wxArrayDoubleProperty::OnEvent( wxPropertyGrid* propgrid,
 {
     if ( propgrid->IsMainButtonEvent(event) )
     {
-        wxArrayDouble& value = wxArrayDoubleRefFromVariant(m_value);
-
         // Update the value in case of last minute changes
-        PrepareValueForDialogEditing(propgrid);
+        wxVariant useValue = propgrid->GetUncommittedPropertyValue();
+
+        wxArrayDouble& value = wxArrayDoubleRefFromVariant(useValue);
 
         // Create editor dialog.
         wxArrayDoubleEditorDialog dlg;