X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6c51ca3750d48a276ae05aaa8b0a62e653dc277d..76015a6bb79156d8af1b5e8b4b8e46b4e192d18f:/src/common/bookctrl.cpp diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index 9f0e284652..8d86c5343e 100644 --- a/src/common/bookctrl.cpp +++ b/src/common/bookctrl.cpp @@ -431,6 +431,18 @@ int wxBookCtrlBase::GetNextPage(bool forward) const return nPage; } +int wxBookCtrlBase::FindPage(const wxWindow* page) const +{ + const size_t nCount = m_pages.size(); + for ( size_t nPage = 0; nPage < nCount; nPage++ ) + { + if ( m_pages[nPage] == page ) + return (int)nPage; + } + + return wxNOT_FOUND; +} + bool wxBookCtrlBase::DoSetSelectionAfterInsertion(size_t n, bool bSelect) { if ( bSelect ) @@ -444,6 +456,26 @@ bool wxBookCtrlBase::DoSetSelectionAfterInsertion(size_t n, bool bSelect) return true; } +void wxBookCtrlBase::DoSetSelectionAfterRemoval(size_t n) +{ + if ( m_selection >= (int)n ) + { + // ensure that the selection is valid + int sel; + if ( GetPageCount() == 0 ) + sel = wxNOT_FOUND; + else + sel = m_selection ? m_selection - 1 : 0; + + // if deleting current page we shouldn't try to hide it + m_selection = m_selection == (int)n ? wxNOT_FOUND + : m_selection - 1; + + if ( sel != wxNOT_FOUND && sel != m_selection ) + SetSelection(sel); + } +} + int wxBookCtrlBase::DoSetSelection(size_t n, int flags) { wxCHECK_MSG( n < GetPageCount(), wxNOT_FOUND,