Reuse wxBookCtrlBase::DoSetSelection() in wxTreebook too

Avoid duplicating base class DoSetSelection() implementation in
wxTreebook, just extend it slightly by using DoGetNonNullPage() to allow
using a (sub-)page if the page associated to the selected item is null
and reuse it.

Also get rid of wxTreebook::m_actualSelection, it seems completely
unnecessary to bother keeping and updating it when we can just find it
whenever we need (which actually seems to only have been the case in the
now removed DoSetSelection() implementation anyhow).

As a side effect of this, wxTreebook pages should now be sizer correctly
when switching to them as DoSetSelection() in the base class does call
SetSize() on the page before showing it, unlike the previously used
version in wxTreebook, which omitted this call for some reason.

There should be no other user-visible changes.

Closes #4379.
This commit is contained in:
Vadim Zeitlin
2018-03-25 00:13:15 +01:00
parent af6a61e3a0
commit 02a92e23f3
4 changed files with 53 additions and 129 deletions

View File

@@ -292,6 +292,12 @@ protected:
// having nodes without any associated page)
virtual bool AllowNullPage() const { return false; }
// For classes that allow null pages, we also need a way to find the
// closest non-NULL page corresponding to the given index, e.g. the first
// leaf item in wxTreebook tree and this method must be overridden to
// return it if AllowNullPage() is overridden.
virtual wxWindow *DoGetNonNullPage(size_t page) { return m_pages[page]; }
// Remove the page and return a pointer to it.
//
// It also needs to update the current selection if necessary, i.e. if the