From 6bae67261c727ee5030abda0a5996e3f9fa6b6b2 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Sun, 28 Aug 2005 08:00:25 +0000 Subject: [PATCH] Improve sizer support in generic wxNotebook. Fix the widgets sample to take advantage of it. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/notebook.h | 2 ++ samples/widgets/widgets.cpp | 7 ++++++- src/generic/notebook.cpp | 11 +++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/wx/generic/notebook.h b/include/wx/generic/notebook.h index 7ee6f3467f..dae3342fbb 100644 --- a/include/wx/generic/notebook.h +++ b/include/wx/generic/notebook.h @@ -126,6 +126,8 @@ public: virtual void SetConstraintSizes(bool recurse = true); virtual bool DoPhase(int nPhase); + virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const; + // Implementation // wxNotebook on Motif uses a generic wxTabView to implement itself. diff --git a/samples/widgets/widgets.cpp b/samples/widgets/widgets.cpp index c93a10a1d6..d5758b005e 100644 --- a/samples/widgets/widgets.cpp +++ b/samples/widgets/widgets.cpp @@ -327,7 +327,12 @@ WidgetsFrame::WidgetsFrame(const wxString& title) //style |= wxNB_NOPAGETHEME; m_book = new wxBookCtrl(m_panel, wxID_ANY, wxDefaultPosition, - wxDefaultSize, style); +#ifdef __WXMOTIF__ + wxSize(500, -1), // under Motif, height is a function of the width... +#else + wxDefaultSize, +#endif + style); InitBook(); #ifndef __SMARTPHONE__ diff --git a/src/generic/notebook.cpp b/src/generic/notebook.cpp index 11b4abfe09..ec05ba70b4 100644 --- a/src/generic/notebook.cpp +++ b/src/generic/notebook.cpp @@ -622,6 +622,17 @@ void wxNotebook::OnPaint(wxPaintEvent& WXUNUSED(event) ) m_tabView->Draw(dc); } +wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const +{ + // MBN: since the total tab height is really a function of the + // width, this should really call + // GetTotalTabHeightPretendingWidthIs(), but the current + // implementation will suffice, provided the wxNotebook has been + // created with a sensible initial width. + return wxSize( sizePage.x + 12, + sizePage.y + m_tabView->GetTotalTabHeight() + 6 + 4 ); +} + wxRect wxNotebook::GetAvailableClientSize() { int cw, ch; -- 2.45.2