]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/treebase.cpp
include wx/utils.h in PCH-less build to ensure that we get the correct (DLL-exported...
[wxWidgets.git] / src / common / treebase.cpp
index 08220fa5039f081efa02b59d24680e4669a3fb26..f10e2af927b24c6b40ecdf0924b6bead4fb33566 100644 (file)
@@ -183,6 +183,9 @@ wxSize wxTreeCtrlBase::DoGetBestSize() const
 
 void wxTreeCtrlBase::ExpandAll()
 {
+    if ( IsEmpty() )
+        return;
+
     ExpandAllChildren(GetRootItem());
 }
 
@@ -202,5 +205,33 @@ void wxTreeCtrlBase::ExpandAllChildren(const wxTreeItemId& item)
     }
 }
 
+void wxTreeCtrlBase::CollapseAll()
+{
+    if ( IsEmpty() )
+        return;
+
+    CollapseAllChildren(GetRootItem());
+}
+
+void wxTreeCtrlBase::CollapseAllChildren(const wxTreeItemId& item)
+{
+    // first (recursively) collapse all the children
+    wxTreeItemIdValue cookie;
+    for ( wxTreeItemId idCurr = GetFirstChild(item, cookie);
+          idCurr.IsOk();
+          idCurr = GetNextChild(item, cookie) )
+    {
+        CollapseAllChildren(idCurr);
+    }
+
+    // then collapse this element too
+    Collapse(item);
+}
+
+bool wxTreeCtrlBase::IsEmpty() const
+{
+    return !GetRootItem().IsOk();
+}
+
 #endif // wxUSE_TREECTRL