Make wxAuiNotebook::FindPage() work correctly

Make this function virtual in the base class so that it could be
overridden to do the right thing in wxAuiNotebook, instead of just
always returning NULL as before and add a unit test checking that it
works.

Explain that wxBookCtrlBase::m_pages may not be used in the derived
classes, but that in this case they must override all the methods using
it.

Finally, "soft-deprecate" wxAuiNotebook::GetPageIndex(), which is
identical to FindPage() now.

This fixes infinite recursion when handling wxEVT_HELP in wxAuiNotebook
in wxUniv too, see #22309.

Closes #15932.
This commit is contained in:
Vadim Zeitlin 2022-04-16 23:01:57 +01:00
parent 8afbf79d02
commit fac4822ab3
5 changed files with 29 additions and 9 deletions

View file

@ -292,7 +292,11 @@ public:
virtual size_t GetPageCount() const wxOVERRIDE;
virtual wxWindow* GetPage(size_t pageIdx) const wxOVERRIDE;
int GetPageIndex(wxWindow* pageWnd) const;
virtual int FindPage(const wxWindow* page) const wxOVERRIDE;
// This is wxAUI-specific equivalent of FindPage(), prefer to use the other
// function.
int GetPageIndex(wxWindow* pageWnd) const { return FindPage(pageWnd); }
bool SetPageText(size_t page, const wxString& text) wxOVERRIDE;
wxString GetPageText(size_t pageIdx) const wxOVERRIDE;