corrected GetBestSize() implementation: take all items, not just the currently visible ones
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35860 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2140,12 +2140,20 @@ bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item,
|
|||||||
wxSize wxTreeCtrl::DoGetBestSize() const
|
wxSize wxTreeCtrl::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
wxSize size;
|
wxSize size;
|
||||||
wxRect rect;
|
|
||||||
for ( wxTreeItemId node = GetFirstVisibleItem();
|
// this doesn't really compute the total bounding rectangle of all items
|
||||||
node.IsOk();
|
// but a not too bad guess of it which has the advantage of not having to
|
||||||
node = GetNextVisible(node) )
|
// examine all (potentially hundreds or thousands) items in the control
|
||||||
|
for ( wxTreeItemId item = GetRootItem();
|
||||||
|
item.IsOk();
|
||||||
|
item = GetLastChild(item) )
|
||||||
{
|
{
|
||||||
if ( GetBoundingRect(node, rect) )
|
wxRect rect;
|
||||||
|
|
||||||
|
// last parameter is "true" to get only the dimensions of the text
|
||||||
|
// label, we don't want to get the entire item width as it's determined
|
||||||
|
// by the current size
|
||||||
|
if ( GetBoundingRect(item, rect, true) )
|
||||||
{
|
{
|
||||||
if ( size.x < rect.x + rect.width )
|
if ( size.x < rect.x + rect.width )
|
||||||
size.x = rect.x + rect.width;
|
size.x = rect.x + rect.width;
|
||||||
@@ -2154,6 +2162,10 @@ wxSize wxTreeCtrl::DoGetBestSize() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// need some minimal size even for empty tree
|
||||||
|
if ( !size.x || !size.y )
|
||||||
|
size = wxControl::DoGetBestSize();
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user