don't update the tree unnecessarily in Expand/CollapseAllChildren() (patch 1809520)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@49262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-10-20 14:55:50 +00:00
parent c4b64a941e
commit 624f89c2d7
3 changed files with 18 additions and 3 deletions

View 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:

View 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

View 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();
}
}