From ce4ae5639b5c1cd9aa45ed766d0f5abae029ca2f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 29 Mar 2013 19:53:13 +0000 Subject: [PATCH] Added wxBookCtrlBase::FindPage(). Add helper function to find the index of the given page. Closes #15125. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73734 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/bookctrl.h | 3 +++ interface/wx/bookctrl.h | 11 +++++++++++ src/common/bookctrl.cpp | 12 ++++++++++++ 4 files changed, 27 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 2711785..23b2862 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -624,6 +624,7 @@ All (GUI): - Add wxAUI_TB_PLAIN_BACKGROUND wxAuiToolBar style (Allann Jones). - Make wxGenericDataViewCtrl::SetFont() really work (Laurent Poujoulat). - Remove wxLogWindow::OnFrameCreate(), it was never called anyhow. +- Added wxBookCtrlBase::FindPage() (troelsk). - Added wxDocument::Activate() (troelsk). - Added wxDocManager::FindDocumentByPath() (troelsk). diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h index 018d120..cd2929e 100644 --- a/include/wx/bookctrl.h +++ b/include/wx/bookctrl.h @@ -215,6 +215,9 @@ public: } } + // return the index of the given page or wxNOT_FOUND + int FindPage(const wxWindow* page) const; + // hit test: returns which page is hit and, optionally, where (icon, label) virtual int HitTest(const wxPoint& WXUNUSED(pt), long * WXUNUSED(flags) = NULL) const diff --git a/interface/wx/bookctrl.h b/interface/wx/bookctrl.h index bbffcc2..17b6920 100644 --- a/interface/wx/bookctrl.h +++ b/interface/wx/bookctrl.h @@ -193,6 +193,17 @@ public: */ virtual int ChangeSelection(size_t page) = 0; + /** + Returns the index of the specified tab window or @c wxNOT_FOUND + if not found. + + @param page One of the control pages. + @return The zero-based tab index or @c wxNOT_FOUND if not found. + + @since 2.9.5 + */ + int FindPage(const wxWindow* page) const; + //@} diff --git a/src/common/bookctrl.cpp b/src/common/bookctrl.cpp index 9f0e284..9ec08ba 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 ) -- 2.7.4