diff --git a/include/wx/xrc/xh_bookctrlbase.h b/include/wx/xrc/xh_bookctrlbase.h index f4dc9ae309..8784a80340 100644 --- a/include/wx/xrc/xh_bookctrlbase.h +++ b/include/wx/xrc/xh_bookctrlbase.h @@ -43,7 +43,20 @@ protected: private: // This struct contains the actual page, created by DoCreatePage(), and all // its attributes read from wxXmlNode. - struct PageWithAttrs; + struct PageWithAttrs + { + PageWithAttrs(); + + // Returns bmpId if it's valid or imgId (which can still be invalid) + // otherwise. + int GetImageId() const; + + wxWindow* wnd; + wxString label; + bool selected; + int imgId; // index in the image list + int bmpId; // index in m_bookImages vector + }; // 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 93b08132dc..4782534a4d 100644 --- a/src/xrc/xh_bookctrlbase.cpp +++ b/src/xrc/xh_bookctrlbase.cpp @@ -24,31 +24,23 @@ #include "wx/bookctrl.h" -// ---------------------------------------------------------------------------- -// private types -// ---------------------------------------------------------------------------- - -struct wxBookCtrlXmlHandlerBase::PageWithAttrs -{ - PageWithAttrs() - { - wnd = NULL; - selected = false; - imgId = - bmpId = wxWithImages::NO_IMAGE; - } - - wxWindow* wnd; - wxString label; - bool selected; - int imgId; // index in the image list - int bmpId; // index in m_bookImages vector -}; - // ============================================================================ // wxBookCtrlXmlHandlerBase implementation // ============================================================================ +wxBookCtrlXmlHandlerBase::PageWithAttrs::PageWithAttrs() +{ + wnd = NULL; + selected = false; + imgId = + bmpId = wxWithImages::NO_IMAGE; +} + +int wxBookCtrlXmlHandlerBase::PageWithAttrs::GetImageId() const +{ + return bmpId != wxWithImages::NO_IMAGE ? bmpId : imgId; +} + wxBookCtrlXmlHandlerBase::wxBookCtrlXmlHandlerBase() : m_isInside(false) { @@ -83,16 +75,11 @@ void wxBookCtrlXmlHandlerBase::DoCreatePages(wxBookCtrlBase* book) for ( size_t i = 0; i < m_bookPages.size(); ++i ) { const PageWithAttrs& currentPage = m_bookPages.at(i); - int imgId = currentPage.bmpId; - if ( imgId == -1 ) - { - imgId = currentPage.imgId; - } book->AddPage(currentPage.wnd, currentPage.label, currentPage.selected, - imgId); + currentPage.GetImageId()); } m_bookImages.swap(imagesSave);