From 54a4121a62a1a7bc6c003915d247e8362d27750b Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 25 Nov 2006 14:54:22 +0000 Subject: [PATCH] corrected wxTreeCtrl::GetBestSize() for a control with borders git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43640 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 2 ++ include/wx/generic/treectlg.h | 2 ++ src/common/treebase.cpp | 5 +++++ src/generic/treectlg.cpp | 10 ++++++++++ 4 files changed, 19 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 5383882f42..2cb417171d 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -97,6 +97,8 @@ All: - New option wxFS_READ | wxFS_SEEKABLE for wxFileSystem::OpenFile() to return a stream that is seekable. - Fixed bug in wxCalendarCtrl::HitTest() when clicking on month change arrows +- Added wxWindow::GetWindowBorderSize() and corrected wxTreeCtrl::GetBestSize() + for a control with borders (Tim Kosse) wxMSW: diff --git a/include/wx/generic/treectlg.h b/include/wx/generic/treectlg.h index a9a6318ce9..0a1e8fee16 100644 --- a/include/wx/generic/treectlg.h +++ b/include/wx/generic/treectlg.h @@ -345,6 +345,8 @@ protected: void DoDirtyProcessing(); + virtual wxSize DoGetBestSize() const; + private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS(wxGenericTreeCtrl) diff --git a/src/common/treebase.cpp b/src/common/treebase.cpp index 4d9c1094e6..d4244576a7 100644 --- a/src/common/treebase.cpp +++ b/src/common/treebase.cpp @@ -163,7 +163,12 @@ wxSize wxTreeCtrlBase::DoGetBestSize() const if ( !size.x || !size.y ) size = wxControl::DoGetBestSize(); else + { + // Add border size + size += GetWindowBorderSize(); + CacheBestSize(size); + } return size; } diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index a20a4fabe2..c1cd97fdfb 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -3647,4 +3647,14 @@ void wxGenericTreeCtrl::DoDirtyProcessing() AdjustMyScrollbars(); } +wxSize wxGenericTreeCtrl::DoGetBestSize() const +{ + wxSize size = wxTreeCtrlBase::DoGetBestSize(); + + // The generic control seems to have an implicit border + size.IncBy(4, 4); + + return size; +} + #endif // wxUSE_TREECTRL -- 2.45.2