From 6ddb01662f9bd96a092501fdc7c895c9c3a90ec6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Nov 2008 22:39:47 +0000 Subject: [PATCH] fix best size caluclation for the notebooks with multiple rows (#2335) [backport of r57024 from trunk] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@57033 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/notebook.cpp | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index de3c7ca0e8..53ab012362 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -129,6 +129,7 @@ wxMSW: - Fixed toolbar buttons so that they don't disappear temporarily when clicked if the event handler causes window update. - Fix display enumeration under WinCE (Vince Harron). +- Fix best size calculation for wxNotebook with multiple rows (Alex McCarthy). wxGTK: diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index d5e6e021a0..ff7022558c 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -656,16 +656,18 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const tabSize.y = rect.bottom - rect.top; } + const int rows = GetRowCount(); + // add an extra margin in both directions const int MARGIN = 8; if ( IsVertical() ) { sizeTotal.x += MARGIN; - sizeTotal.y += tabSize.y + MARGIN; + sizeTotal.y += tabSize.y * rows + MARGIN; } else // horizontal layout { - sizeTotal.x += tabSize.x + MARGIN; + sizeTotal.x += tabSize.x * rows + MARGIN; sizeTotal.y += MARGIN; } @@ -1027,6 +1029,10 @@ void wxNotebook::OnSize(wxSizeEvent& event) MAKELPARAM(rc.right, rc.bottom)); s_isInOnSize = false; } + + // The best size depends on the number of rows of tabs, which can + // change when the notepad is resized. + InvalidateBestSize(); } #if wxUSE_UXTHEME