// Created: 11.06.98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows license
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#include <windowsx.h> // for SetWindowFont
-#ifndef __TWIN32__
- #ifdef __GNUWIN32_OLD__
- #include "wx/msw/gnuwin32/extra.h"
- #endif
+#ifdef __GNUWIN32_OLD__
+ #include "wx/msw/gnuwin32/extra.h"
#endif
-#if defined(__WIN95__) && !((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
+#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__))
#include <commctrl.h>
#endif
const wxString& name)
{
// base init
- if ( !CreateControl(parent, id, pos, size, style, wxDefaultValidator, name) )
+ if ( !CreateControl(parent, id, pos, size, style | wxTAB_TRAVERSAL,
+ wxDefaultValidator, name) )
return FALSE;
- // notebook, so explicitly specify 0 as last parameter
- if ( !MSWCreateControl(WC_TABCONTROL, _T(""), pos, size,
- style | wxTAB_TRAVERSAL) )
+ if ( !MSWCreateControl(WC_TABCONTROL, _T(""), pos, size) )
return FALSE;
SetBackgroundColour(wxColour(::GetSysColor(COLOR_BTNFACE)));
::SendMessage(GetHwnd(), TCM_SETITEMSIZE, 0, MAKELPARAM(sz.x, sz.y));
}
+void wxNotebook::AdjustPageSize(wxNotebookPage *page)
+{
+ wxCHECK_RET( page, _T("NULL page in wxNotebook::AdjustPageSize") );
+
+ RECT rc;
+ rc.left =
+ rc.top = 0;
+
+ // get the page size from the notebook size
+ GetSize((int *)&rc.right, (int *)&rc.bottom);
+ TabCtrl_AdjustRect(m_hwnd, FALSE, &rc);
+
+ page->SetSize(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
+}
+
// ----------------------------------------------------------------------------
// wxNotebook operations
// ----------------------------------------------------------------------------
return TRUE;
}
-// add a page to the notebook
-bool wxNotebook::AddPage(wxNotebookPage *pPage,
- const wxString& strText,
- bool bSelect,
- int imageId)
-{
- return InsertPage(GetPageCount(), pPage, strText, bSelect, imageId);
-}
-
// same as AddPage() but does it at given position
bool wxNotebook::InsertPage(int nPage,
wxNotebookPage *pPage,
wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE,
_T("invalid index in wxNotebook::InsertPage") );
+ wxASSERT_MSG( pPage->GetParent() == this,
+ _T("notebook pages must have notebook as parent") );
// add a new tab to the control
// ----------------------------
// fit the notebook page to the tab control's display area: this should be
// done before adding it to the notebook or TabCtrl_InsertItem() will
// change the notebooks size itself!
- 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);
-
+ AdjustPageSize(pPage);
// finally do insert it
- if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 ) {
+ if ( TabCtrl_InsertItem(m_hwnd, nPage, &tcItem) == -1 )
+ {
wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str());
return FALSE;
// succeeded: save the pointer to the page
m_pages.Insert(pPage, nPage);
+ // for the first page (only) we need to adjust the size again because the
+ // notebook size changed: the tabs which hadn't been there before are now
+ // shown
+ if ( m_pages.GetCount() == 1 )
+ {
+ AdjustPageSize(pPage);
+ }
+
// hide the page: unless it is selected, it shouldn't be shown (and if it
// is selected it will be shown later)
HWND hwnd = GetWinHwnd(pPage);
// wxNotebook base class virtuals
// ----------------------------------------------------------------------------
+#if wxUSE_CONSTRAINTS
+
// override these 2 functions to do nothing: everything is done in OnSize
void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
return TRUE;
}
+#endif // wxUSE_CONSTRAINTS
+
// ----------------------------------------------------------------------------
// wxNotebook Windows message handlers
// ----------------------------------------------------------------------------