]> git.saurik.com Git - wxWidgets.git/commitdiff
count the root item in wxTreeCtrl::GetCount()
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Jun 2004 12:06:10 +0000 (12:06 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Jun 2004 12:06:10 +0000 (12:06 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27726 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/treectlg.cpp

index 4a83697fd7da58f52c6dad9df7816bd3b0a53f31..39d30b76147bfd97e8435b32026edacf82f8e2da 100644 (file)
@@ -825,7 +825,20 @@ wxGenericTreeCtrl::~wxGenericTreeCtrl()
 
 size_t wxGenericTreeCtrl::GetCount() const
 {
-    return m_anchor == NULL ? 0u : m_anchor->GetChildrenCount();
+    if ( !m_anchor )
+    {
+        // the tree is empty
+        return 0;
+    }
+
+    size_t count = m_anchor->GetChildrenCount();
+    if ( !HasFlag(wxTR_HIDE_ROOT) )
+    {
+        // take the root itself into account
+        count++;
+    }
+
+    return count;
 }
 
 void wxGenericTreeCtrl::SetIndent(unsigned int indent)