]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/treebase.cpp
fixed incorrectly inversed test for parent [not] being deleted (patch 1624472)
[wxWidgets.git] / src / common / treebase.cpp
index 4d9c1094e61039d954798d7e18a8cce744940b3e..08220fa5039f081efa02b59d24680e4669a3fb26 100644 (file)
@@ -113,6 +113,12 @@ wxGetBestTreeSize(const wxTreeCtrlBase* treeCtrl, wxTreeItemId id, wxSize& size)
 
     if ( treeCtrl->GetBoundingRect(id, rect, true /* just the item */) )
     {
+        // Translate to logical position so we get the full extent
+#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
+        rect.x += treeCtrl->GetScrollPos(wxHORIZONTAL);
+        rect.y += treeCtrl->GetScrollPos(wxVERTICAL);
+#endif
+
         size.IncTo(wxSize(rect.GetRight(), rect.GetBottom()));
     }
 
@@ -156,14 +162,21 @@ wxSize wxTreeCtrlBase::DoGetBestSize() const
     else // use precise, if potentially slow, size computation method
     {
         // iterate over all items recursively
-        wxGetBestTreeSize(this, GetRootItem(), size);
+        wxTreeItemId idRoot = GetRootItem();
+        if ( idRoot.IsOk() )
+            wxGetBestTreeSize(this, idRoot, size);
     }
 
     // need some minimal size even for empty tree
     if ( !size.x || !size.y )
         size = wxControl::DoGetBestSize();
     else
+    {
+        // Add border size
+        size += GetWindowBorderSize();
+
         CacheBestSize(size);
+    }
 
     return size;
 }