]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/property.cpp
fix memory leak while testing for correct Clone() implementation (closes #10304)
[wxWidgets.git] / src / propgrid / property.cpp
index 3ca05b7db987c2898913df28286ca89a8308ed1a..1897d12761cc5797cf581fc14cf5284a57b0654c 100644 (file)
@@ -149,8 +149,10 @@ int wxPGCellRenderer::PreDrawCell( wxDC& dc, const wxRect& rect, const wxPGCell&
         dc.SetTextForeground(cell.GetFgCol());
     }
 
         dc.SetTextForeground(cell.GetFgCol());
     }
 
-    // Draw Background
-    dc.DrawRectangle(rect);
+    // Draw Background, but only if not rendering in control
+    // (as control already has rendered correct background).
+    if ( !(flags & (Control|ChoicePopup)) )
+        dc.DrawRectangle(rect);
 
     const wxBitmap& bmp = cell.GetBitmap();
     if ( bmp.Ok() &&
 
     const wxBitmap& bmp = cell.GetBitmap();
     if ( bmp.Ok() &&
@@ -227,15 +229,7 @@ void wxPGDefaultRenderer::Render( wxDC& dc, const wxRect& rect,
                 paintdata.m_drawnWidth = imageSize.x;
                 paintdata.m_drawnHeight = imageSize.y;
 
                 paintdata.m_drawnWidth = imageSize.x;
                 paintdata.m_drawnHeight = imageSize.y;
 
-                if ( !isUnspecified )
-                {
-                    property->OnCustomPaint( dc, imageRect, paintdata );
-                }
-                else
-                {
-                    dc.SetBrush(*wxWHITE_BRUSH);
-                    dc.DrawRectangle(imageRect);
-                }
+                property->OnCustomPaint( dc, imageRect, paintdata );
 
                 imageOffset = paintdata.m_drawnWidth;
             }
 
                 imageOffset = paintdata.m_drawnWidth;
             }
@@ -645,10 +639,10 @@ int wxPGProperty::Index( const wxPGProperty* p ) const
     return wxNOT_FOUND;
 }
 
     return wxNOT_FOUND;
 }
 
-void wxPGProperty::UpdateControl( wxWindow* primary )
+void wxPGProperty::UpdateControl( wxWindow* editorWnd )
 {
 {
-    if ( primary )
-        GetEditorClass()->UpdateControl(this, primary);
+    if ( editorWnd )
+        GetEditorClass()->UpdateControl(this, editorWnd);
 }
 
 bool wxPGProperty::ValidateValue( wxVariant& WXUNUSED(value), wxPGValidationInfo& WXUNUSED(validationInfo) ) const
 }
 
 bool wxPGProperty::ValidateValue( wxVariant& WXUNUSED(value), wxPGValidationInfo& WXUNUSED(validationInfo) ) const
@@ -796,7 +790,7 @@ void wxPGProperty::DoGenerateComposedValue( wxString& text,
                 childValue = overrideValue;
             else
                 childValue = curChild->GetValue();
                 childValue = overrideValue;
             else
                 childValue = curChild->GetValue();
-            node++;
+            ++node;
             if ( node != valueOverrides->end() )
                 overrideValue = *node;
             else
             if ( node != valueOverrides->end() )
                 overrideValue = *node;
             else
@@ -1047,7 +1041,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
                 {
                     int depth = 1;
 
                 {
                     int depth = 1;
 
-                    if ( it != text.end() ) it++;
+                    if ( it != text.end() ) ++it;
                     pos++;
                     size_t startPos = pos;
 
                     pos++;
                     size_t startPos = pos;
 
@@ -1055,7 +1049,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
                     while ( it != text.end() && depth > 0 )
                     {
                         a = *it;
                     while ( it != text.end() && depth > 0 )
                     {
                         a = *it;
-                        it++;
+                        ++it;
                         pos++;
 
                         if ( a == wxS(']') )
                         pos++;
 
                         if ( a == wxS(']') )
@@ -1109,7 +1103,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
                     if ( a == delimeter )
                     {
                         pos--;
                     if ( a == delimeter )
                     {
                         pos--;
-                        it--;
+                        --it;
                     }
                 }
             }
                     }
                 }
             }
@@ -1118,7 +1112,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
         if ( a == 0 )
             break;
 
         if ( a == 0 )
             break;
 
-        it++;
+        ++it;
         if ( it != text.end() )
         {
             a = *it;
         if ( it != text.end() )
         {
             a = *it;
@@ -1243,7 +1237,7 @@ void wxPGProperty::SetValue( wxVariant value, wxVariant* pList, int flags )
 
             // Children in list can be in any order, but we will give hint to
             // GetPropertyByNameWH(). This optimizes for full list parsing.
 
             // Children in list can be in any order, but we will give hint to
             // GetPropertyByNameWH(). This optimizes for full list parsing.
-            for ( node = list.begin(); node != list.end(); node++ )
+            for ( node = list.begin(); node != list.end(); ++node )
             {
                 wxVariant& childValue = *((wxVariant*)*node);
                 wxPGProperty* child = GetPropertyByNameWH(childValue.GetName(), i);
             {
                 wxVariant& childValue = *((wxVariant*)*node);
                 wxPGProperty* child = GetPropertyByNameWH(childValue.GetName(), i);
@@ -1342,18 +1336,13 @@ void wxPGProperty::SetFlagRecursively( FlagType flag, bool set )
 
 void wxPGProperty::RefreshEditor()
 {
 
 void wxPGProperty::RefreshEditor()
 {
-    if ( m_parent && GetParentState() )
-    {
-        wxPropertyGrid* pg = GetParentState()->GetGrid();
-        if ( pg->GetSelectedProperty() == this )
-        {
-            wxWindow* editor = pg->GetEditorControl();
-            if ( editor )
-                GetEditorClass()->UpdateControl( this, editor );
-        }
-    }
-}
+    if ( !m_parent )
+        return;
 
 
+    wxPropertyGrid* pg = GetGrid();
+    if ( pg && pg->GetSelectedProperty() == this )
+        UpdateControl(pg->GetEditorControl());
+}
 
 wxVariant wxPGProperty::GetDefaultValue() const
 {
 
 wxVariant wxPGProperty::GetDefaultValue() const
 {
@@ -2282,6 +2271,17 @@ void wxPGProperty::Empty()
     m_children.clear();
 }
 
     m_children.clear();
 }
 
+void wxPGProperty::DeleteChildren()
+{
+    wxPropertyGridPageState* state = m_parentState;
+
+    while ( GetChildCount() )
+    {
+        wxPGProperty* child = Item(GetChildCount()-1);
+        state->DoDelete(child, true);
+    }
+}
+
 void wxPGProperty::ChildChanged( wxVariant& WXUNUSED(thisValue),
                                  int WXUNUSED(childIndex),
                                  wxVariant& WXUNUSED(childValue) ) const
 void wxPGProperty::ChildChanged( wxVariant& WXUNUSED(thisValue),
                                  int WXUNUSED(childIndex),
                                  wxVariant& WXUNUSED(childValue) ) const
@@ -2311,7 +2311,7 @@ bool wxPGProperty::AreAllChildrenSpecified( wxVariant* pendingList ) const
         {
             const wxString& childName = child->GetBaseName();
 
         {
             const wxString& childName = child->GetBaseName();
 
-            for ( ; node != pList->end(); node++ )
+            for ( ; node != pList->end(); ++node )
             {
                 const wxVariant& item = *((const wxVariant*)*node);
                 if ( item.GetName() == childName )
             {
                 const wxVariant& item = *((const wxVariant*)*node);
                 if ( item.GetName() == childName )
@@ -2500,7 +2500,7 @@ wxPGAttributeStorage::~wxPGAttributeStorage()
 {
     wxPGHashMapS2P::iterator it;
 
 {
     wxPGHashMapS2P::iterator it;
 
-    for ( it = m_map.begin(); it != m_map.end(); it++ )
+    for ( it = m_map.begin(); it != m_map.end(); ++it )
     {
         wxVariantData* data = (wxVariantData*) it->second;
         data->DecRef();
     {
         wxVariantData* data = (wxVariantData*) it->second;
         data->DecRef();