]> git.saurik.com Git - wxWidgets.git/commitdiff
don't update the tree unnecessarily in Expand/CollapseAllChildren() (patch 1809520)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 20 Oct 2007 14:55:50 +0000 (14:55 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 20 Oct 2007 14:55:50 +0000 (14:55 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
src/common/treebase.cpp
src/generic/treectlg.cpp

index 74998a35cab5dec77ad18790430d04ff9d14757d..a5ce3575356cd016ed057da5a65185e71441bac1 100644 (file)
@@ -205,6 +205,7 @@ All (GUI):
   behaviour of GetNextSibling() consistent between wxMSW and generic versions.
 - Merged wxRichTextAttr and wxTextAttrEx into wxTextAttr, and added a font table
   to wxRichTextBuffer to reduce wxFont consumption and increase performance.
+- Optimize wxGenericTreeCtrl::Collapse/ExpandAllChildren() (Szczepan Holyszewski)
 
 wxGTK:
 
index eb37c0dbdb1aef6c7fa7520b31cf62d2f906bbed..4bd01ace539a11f47635039602ed18495b2225c6 100644 (file)
@@ -191,6 +191,7 @@ void wxTreeCtrlBase::ExpandAll()
 
 void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item)
 {
+    Freeze();
     // expand this item first, this might result in its children being added on
     // the fly
     if ( item != GetRootItem() || !HasFlag(wxTR_HIDE_ROOT) )
@@ -205,6 +206,7 @@ void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item)
     {
         ExpandAllChildren(idCurr);
     }
+    Thaw();
 }
 
 void wxTreeCtrlBase::CollapseAll()
@@ -217,6 +219,7 @@ void wxTreeCtrlBase::CollapseAll()
 
 void wxTreeCtrlBase::CollapseAllChildren(const wxTreeItemId& item)
 {
+    Freeze();
     // first (recursively) collapse all the children
     wxTreeItemIdValue cookie;
     for ( wxTreeItemId idCurr = GetFirstChild(item, cookie);
@@ -228,6 +231,7 @@ void wxTreeCtrlBase::CollapseAllChildren(const wxTreeItemId& item)
 
     // then collapse this element too
     Collapse(item);
+    Thaw();
 }
 
 bool wxTreeCtrlBase::IsEmpty() const
index 87a01089a1de020f8d9126115c9c9a5cf7dcdbf8..d30b80d4f0e97e691557f4972a845a67d5cd479f 100644 (file)
@@ -1646,9 +1646,16 @@ void wxGenericTreeCtrl::Expand(const wxTreeItemId& itemId)
     }
 
     item->Expand();
-    CalculatePositions();
+    if ( !m_freezeCount )
+    {
+        CalculatePositions();
 
-    RefreshSubtree(item);
+        RefreshSubtree(item);
+    }
+    else // frozen
+    {
+        m_dirty = true;
+    }
 
     event.SetEventType(wxEVT_COMMAND_TREE_ITEM_EXPANDED);
     GetEventHandler()->ProcessEvent( event );
@@ -3582,7 +3589,10 @@ void wxGenericTreeCtrl::Thaw()
 
     if ( --m_freezeCount == 0 )
     {
-        Refresh();
+        if ( m_dirty )
+            DoDirtyProcessing();
+        else
+            Refresh();
     }
 }