X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/837e57436a89516a5fa9f478f401e06bd872c17c..2356708db31b737c6eae53c2316b642aa5a2e68d:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index d6c5fc5234..2961439e4b 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -42,11 +42,13 @@ #ifndef __TWIN32__ #ifdef __GNUWIN32__ +#ifndef wxUSE_NORLANDER_HEADERS #include "wx/msw/gnuwin32/extra.h" #endif #endif +#endif -#if !defined(__GNUWIN32__) || defined(__TWIN32__) +#if !defined(__GNUWIN32__) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS) #include #endif @@ -122,7 +124,8 @@ bool wxNotebook::Create(wxWindow *parent, const wxString& name) { // base init - CreateBase(parent, id, pos, size, style, name); + if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) ) + return FALSE; // colors and font m_backgroundColour = wxColour(GetSysColor(COLOR_BTNFACE)); @@ -274,11 +277,22 @@ bool wxNotebook::DeletePage(int nPage) { wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("notebook page out of range") ); + if ( m_nSelection == nPage ) { + // advance selection backwards - the page being deleted shouldn't be left + // selected + AdvanceSelection(FALSE); + } + TabCtrl_DeleteItem(m_hwnd, nPage); delete m_aPages[nPage]; m_aPages.Remove(nPage); + if ( m_aPages.IsEmpty() ) { + // no selection if the notebook became empty + m_nSelection = -1; + } + return TRUE; } @@ -370,6 +384,11 @@ bool wxNotebook::InsertPage(int nPage, // this updates internal flag too - otherwise it will get out of sync pPage->Show(FALSE); + // FIXME this is ugly, I'm breaking my own rules... but needed to get display + // right (why?) + wxSizeEvent event; + OnSize(event); + return TRUE; } @@ -408,7 +427,23 @@ void wxNotebook::OnSelChange(wxNotebookEvent& event) { // is it our tab control? if ( event.GetEventObject() == this ) - ChangePage(event.GetOldSelection(), event.GetSelection()); + { + // don't call ChangePage() here because it will generate redundant + // notification events + int sel = event.GetOldSelection(); + if ( sel != -1 ) + m_aPages[sel]->Show(FALSE); + + sel = event.GetSelection(); + if ( sel != -1 ) + { + wxNotebookPage *pPage = m_aPages[sel]; + pPage->Show(TRUE); + pPage->SetFocus(); + } + + m_nSelection = sel; + } // we want to give others a chance to process this message as well event.Skip();