From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Sun, 9 Oct 2005 13:38:15 +0000 (+0000)
Subject: implemented GetBestSize() (TODO: make this available in generic version as well)
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/96d8f9207f20a286140aed1a6385a8e1ff6fdba7

implemented GetBestSize() (TODO: make this available in generic version as well)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35856 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/include/wx/msw/treectrl.h b/include/wx/msw/treectrl.h
index b4c5c75616..310d4cb34d 100644
--- a/include/wx/msw/treectrl.h
+++ b/include/wx/msw/treectrl.h
@@ -429,6 +429,9 @@ public:
     int GetState(const wxTreeItemId& node);
 
 protected:
+    virtual wxSize DoGetBestSize() const;
+
+    
     // SetImageList helper
     void SetAnyImageList(wxImageList *imageList, int which);
 
diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp
index 13edcec7c3..7f17ef8bbb 100644
--- a/src/msw/treectrl.cpp
+++ b/src/msw/treectrl.cpp
@@ -2137,6 +2137,26 @@ bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item,
     }
 }
 
+wxSize wxTreeCtrl::DoGetBestSize() const
+{
+    wxSize size;
+    wxRect rect;
+    for ( wxTreeItemId node = GetFirstVisibleItem();
+          node.IsOk();
+          node = GetNextVisible(node) )
+    {
+        if ( GetBoundingRect(node, rect) )
+        {
+            if ( size.x < rect.x + rect.width )
+                size.x = rect.x + rect.width;
+            if ( size.y < rect.y + rect.height )
+                size.y = rect.y + rect.height;
+        }
+    }
+
+    return size;
+}
+
 // ----------------------------------------------------------------------------
 // sorting stuff
 // ----------------------------------------------------------------------------