Move wxBookCtrlXmlHandlerBase::PageWithAttrs into the header

This struct is finally going to have to be declared in the header as it
will be needed by wxTreebookXmlHandler when it's modified to derive from
wxBookCtrlXmlHandlerBase too.

Also add GetImageId() function to the struct while moving it.
This commit is contained in:
Vadim Zeitlin
2022-02-25 03:59:56 +00:00
parent 1549aafdc9
commit d3c0d0c064
2 changed files with 28 additions and 28 deletions

View File

@@ -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<PageWithAttrs> m_bookPages;

View File

@@ -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);