diff --git a/include/wx/xrc/xh_bookctrlbase.h b/include/wx/xrc/xh_bookctrlbase.h index 8784a80340..8db4d72bdd 100644 --- a/include/wx/xrc/xh_bookctrlbase.h +++ b/include/wx/xrc/xh_bookctrlbase.h @@ -40,7 +40,6 @@ protected: // Return true if we're parsing the book control node itself. bool IsInside() const { return m_isInside; } -private: // This struct contains the actual page, created by DoCreatePage(), and all // its attributes read from wxXmlNode. struct PageWithAttrs @@ -58,6 +57,14 @@ private: int bmpId; // index in m_bookImages vector }; +private: + // This function is implemented by just calling AddPage() in the base + // class, but can be overridden if something else is needed, as is e.g. the + // case for wxTreebookXmlHandler. + virtual void + DoAddPage(wxBookCtrlBase* book, size_t n, const PageWithAttrs& page); + + // And this vector contains all the pages created so far. wxVector m_bookPages; diff --git a/src/xrc/xh_bookctrlbase.cpp b/src/xrc/xh_bookctrlbase.cpp index 4782534a4d..aff51084b7 100644 --- a/src/xrc/xh_bookctrlbase.cpp +++ b/src/xrc/xh_bookctrlbase.cpp @@ -52,6 +52,14 @@ wxBookCtrlXmlHandlerBase::~wxBookCtrlXmlHandlerBase() // PageWithAttrs which is not fully declared in the header. } +void +wxBookCtrlXmlHandlerBase::DoAddPage(wxBookCtrlBase* book, + size_t WXUNUSED(n), + const PageWithAttrs& page) +{ + book->AddPage(page.wnd, page.label, page.selected, page.GetImageId()); +} + void wxBookCtrlXmlHandlerBase::DoCreatePages(wxBookCtrlBase* book) { bool old_ins = m_isInside; @@ -74,12 +82,7 @@ void wxBookCtrlXmlHandlerBase::DoCreatePages(wxBookCtrlBase* book) for ( size_t i = 0; i < m_bookPages.size(); ++i ) { - const PageWithAttrs& currentPage = m_bookPages.at(i); - - book->AddPage(currentPage.wnd, - currentPage.label, - currentPage.selected, - currentPage.GetImageId()); + DoAddPage(book, i, m_bookPages[i]); } m_bookImages.swap(imagesSave);