+ wxSize sizeTotal = sizePage;
+ sizeTotal.x += 2 * m_macHorizontalBorder + wxMacTabLeftMargin(GetWindowStyle()) +
+ wxMacTabRightMargin(GetWindowStyle()) ;
+ sizeTotal.y += 2 * m_macVerticalBorder + wxMacTabTopMargin(GetWindowStyle()) +
+ wxMacTabBottomMargin(GetWindowStyle()) ;
+
+ return sizeTotal;
+}
+
+wxSize wxNotebook::DoGetBestSize() const
+{
+ // calculate the max page size
+ wxSize size(0, 0);
+
+ size_t count = GetPageCount();
+ if ( count )
+ {
+ for ( size_t n = 0; n < count; n++ )
+ {
+ wxSize sizePage = m_pages[n]->GetSize();
+
+ if ( size.x < sizePage.x )
+ size.x = sizePage.x;
+ if ( size.y < sizePage.y )
+ size.y = sizePage.y;
+ }
+ }
+ else // no pages
+ {
+ // use some arbitrary default size
+ size.x =
+ size.y = 100;
+ }
+
+ return CalcSizeFromPage(size);
+}
+
+int wxNotebook::SetSelection(size_t nPage)
+{
+ wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
+
+ if ( int(nPage) != m_nSelection )
+ {
+ wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
+ event.SetSelection(nPage);
+ event.SetOldSelection(m_nSelection);
+ event.SetEventObject(this);
+ if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
+ {
+ // program allows the page change
+ event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
+ (void)GetEventHandler()->ProcessEvent(event);
+
+ ChangePage(m_nSelection, nPage);
+ }
+ }
+