X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/681be2ef80274e6c39b243922a594c59e4983dab..c22bbd087aa273141e0e1e3c69e2a42a0e633f75:/src/msw/notebook.cpp diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index f5487c26b9..4b3c6e0aee 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -122,7 +122,6 @@ static bool HasTroubleWithNonTopTabs() WX_DEFINE_LIST( wxNotebookPageInfoList ) BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase) - EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange) EVT_SIZE(wxNotebook::OnSize) EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) @@ -455,9 +454,13 @@ int wxNotebook::SetSelection(size_t nPage) if ( SendPageChangingEvent(nPage) ) { // program allows the page change - SendPageChangedEvent(m_selection, nPage); + const int selectionOld = m_selection; + + UpdateSelection(nPage); TabCtrl_SetCurSel(GetHwnd(), nPage); + + SendPageChangedEvent(selectionOld, nPage); } } @@ -842,16 +845,7 @@ bool wxNotebook::InsertPage(size_t nPage, m_selection++; } - // some page should be selected: either this one or the first one if there - // is still no selection - int selNew = wxNOT_FOUND; - if ( bSelect ) - selNew = nPage; - else if ( m_selection == wxNOT_FOUND ) - selNew = 0; - - if ( selNew != wxNOT_FOUND ) - SetSelection(selNew); + DoSetSelectionAfterInsertion(nPage, bSelect); InvalidateBestSize(); @@ -1091,18 +1085,6 @@ void wxNotebook::OnSize(wxSizeEvent& event) event.Skip(); } -void wxNotebook::OnSelChange(wxBookCtrlEvent& event) -{ - // is it our tab control? - if ( event.GetEventObject() == this ) - { - UpdateSelection(event.GetSelection()); - } - - // we want to give others a chance to process this message as well - event.Skip(); -} - void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) { if ( event.IsWindowChange() ) { @@ -1455,6 +1437,9 @@ bool wxNotebook::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM* result) event.SetInt(idCtrl); bool processed = HandleWindowEvent(event); + if ( hdr->code == TCN_SELCHANGE ) + UpdateSelection(event.GetSelection()); + *result = !event.IsAllowed(); return processed; }