X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/43a997b6e2064a189fa73ca1816908fb740ce297..62e819ee45059232300d598d9a85f9ad77a23c45:/src/msw/notebook.cpp?ds=sidebyside diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index d8a82f4809..d492f461cb 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -161,7 +161,7 @@ WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const tabStyle |= WS_TABSTOP | TCS_TABS; - if ( style & wxTC_MULTILINE ) + if ( style & wxNB_MULTILINE ) tabStyle |= TCS_MULTILINE; if ( style & wxNB_FIXEDWIDTH ) tabStyle |= TCS_FIXEDWIDTH; @@ -205,9 +205,23 @@ int wxNotebook::SetSelection(int nPage) { wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") ); - ChangePage(m_nSelection, nPage); + if ( 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); + + TabCtrl_SetCurSel(m_hwnd, nPage); + } + } - return TabCtrl_SetCurSel(m_hwnd, nPage); + return m_nSelection; } bool wxNotebook::SetPageText(int nPage, const wxString& strText) @@ -631,44 +645,4 @@ bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result) return processed; } -// ---------------------------------------------------------------------------- -// wxNotebook helper functions -// ---------------------------------------------------------------------------- - -// generate the page changing and changed events, hide the currently active -// panel and show the new one -void wxNotebook::ChangePage(int nOldSel, int nSel) -{ - // MT-FIXME should use a real semaphore - static bool s_bInsideChangePage = FALSE; - - // when we call ProcessEvent(), our own OnSelChange() is called which calls - // this function - break the infinite loop - if ( s_bInsideChangePage ) - return; - - // it's not an error (the message may be generated by the tab control itself) - // and it may happen - just do nothing - if ( nSel == nOldSel ) - return; - - s_bInsideChangePage = TRUE; - - wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId); - event.SetSelection(nSel); - event.SetOldSelection(nOldSel); - event.SetEventObject(this); - if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() ) - { - // program doesn't allow the page change - s_bInsideChangePage = FALSE; - return; - } - - event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED); - GetEventHandler()->ProcessEvent(event); - - s_bInsideChangePage = FALSE; -} - #endif // wxUSE_NOTEBOOK