diff --git a/include/wx/ribbon/bar.h b/include/wx/ribbon/bar.h index 72d7b8829b..71bb18be1f 100644 --- a/include/wx/ribbon/bar.h +++ b/include/wx/ribbon/bar.h @@ -125,6 +125,7 @@ public: bool SetActivePage(wxRibbonPage* page); int GetActivePage() const; wxRibbonPage* GetPage(int n); + wxRibbonPage* GetPageById(wxWindowID id); size_t GetPageCount() const; bool DismissExpandedPanel(); int GetPageNumber(wxRibbonPage* page) const; diff --git a/interface/wx/ribbon/bar.h b/interface/wx/ribbon/bar.h index 8c95812405..b328d9168d 100644 --- a/interface/wx/ribbon/bar.h +++ b/interface/wx/ribbon/bar.h @@ -303,6 +303,15 @@ public: */ wxRibbonPage* GetPage(int n); + /** + Get a page by window ID. + + @NULL will be returned if no page with the ID is found. + + @since 3.3.0 + */ + wxRibbonPage* GetPageById(wxWindowID id); + /** Get the number of pages in this bar. diff --git a/src/ribbon/bar.cpp b/src/ribbon/bar.cpp index 99848d202d..45887cfa9d 100644 --- a/src/ribbon/bar.cpp +++ b/src/ribbon/bar.cpp @@ -316,6 +316,16 @@ wxRibbonPage* wxRibbonBar::GetPage(int n) return m_pages.Item(n).page; } +wxRibbonPage* wxRibbonBar::GetPageById(wxWindowID id) +{ + for (const auto& page : m_pages) + { + if (page.page->GetId() == id) + return page.page; + } + return nullptr; +} + size_t wxRibbonBar::GetPageCount() const { return m_pages.GetCount();