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:
@@ -213,7 +213,7 @@ public:
|
||||
}
|
||||
|
||||
// return the index of the given page or wxNOT_FOUND
|
||||
int FindPage(const wxWindow* page) const;
|
||||
virtual int FindPage(const wxWindow* page) const;
|
||||
|
||||
// hit test: returns which page is hit and, optionally, where (icon, label)
|
||||
virtual int HitTest(const wxPoint& WXUNUSED(pt),
|
||||
@@ -304,7 +304,7 @@ protected:
|
||||
// leaf item in wxTreebook tree and this method must be overridden to
|
||||
// return it if AllowNullPage() is overridden. Note that it can still
|
||||
// return null if there are no valid pages after this one.
|
||||
virtual wxWindow *TryGetNonNullPage(size_t page) { return m_pages[page]; }
|
||||
virtual wxWindow *TryGetNonNullPage(size_t page) { return GetPage(page); }
|
||||
|
||||
// Remove the page and return a pointer to it.
|
||||
//
|
||||
@@ -338,7 +338,9 @@ protected:
|
||||
#endif // wxUSE_HELP
|
||||
|
||||
|
||||
// the array of all pages of this control
|
||||
// the array of all pages of this control: this is used in most, but not
|
||||
// all derived classes, notable wxAuiNotebook doesn't store its page here
|
||||
// and so must override all virtual methods of this class using m_pages
|
||||
wxVector<wxWindow*> m_pages;
|
||||
|
||||
// get the page area
|
||||
|
||||
Reference in New Issue
Block a user