From b5c3b53817d5b3a63513ae11e34a84d91aeb49f0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 12 Jul 1998 22:59:00 +0000 Subject: [PATCH] constraints handling for notebook pages improved git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@249 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/notebook.cpp | 50 +++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 882cd41f45..6bbc8d4fea 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -369,6 +369,20 @@ void wxNotebook::OnSize(wxSizeEvent& event) m_nSelection = -1; SetSelection(nSel); + // fit the notebook page to the tab control's display area + RECT rc; + rc.left = rc.top = 0; + GetSize((int *)&rc.right, (int *)&rc.bottom); + + TabCtrl_AdjustRect(m_hwnd, FALSE, &rc); + uint nCount = m_aPages.Count(); + for ( uint nPage = 0; nPage < nCount; nPage++ ) { + wxNotebookPage *pPage = m_aPages[nPage]; + pPage->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); + if ( pPage->GetAutoLayout() ) + pPage->Layout(); + } + event.Skip(); } @@ -409,6 +423,20 @@ void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) // ---------------------------------------------------------------------------- // wxNotebook base class virtuals // ---------------------------------------------------------------------------- + +// override these 2 functions to do nothing: everything is done in OnSize + +void wxNotebook::SetConstraintSizes(bool /* recurse */) +{ + // don't set the sizes of the pages - their correct size is not yet known + wxControl::SetConstraintSizes(FALSE); +} + +bool wxNotebook::DoPhase(int /* nPhase */) +{ + return TRUE; +} + void wxNotebook::Command(wxCommandEvent& event) { wxFAIL_MSG("wxNotebook::Command not implemented"); @@ -453,28 +481,8 @@ void wxNotebook::ChangePage(int nOldSel, int nSel) } wxNotebookPage *pPage = m_aPages[nSel]; - FitPage(pPage); pPage->Show(TRUE); - - // set focus to the currently selected page - wxWindow *win = m_aPages[nSel]; - if ( win->IsKindOf(CLASSINFO(wxPanel)) ) { - wxList *children = win->GetChildren(); - if ( children->First() != NULL ); - win = (wxWindow *)children->First()->Data(); - } - win->SetFocus(); + pPage->SetFocus(); m_nSelection = nSel; } - -// fit the notebook page to the tab control's display area -void wxNotebook::FitPage(wxNotebookPage *pPage) -{ - RECT rc; - rc.left = rc.top = 0; - GetSize((int *)&rc.right, (int *)&rc.bottom); - - TabCtrl_AdjustRect(m_hwnd, FALSE, &rc); - pPage->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top); -} \ No newline at end of file