Add wxPreferencesPage::GetIcon() returning wxBitmapBundle

Allow returning a wxBitmapBundle rather than an individual wxBitmap.

Also make GetLargeIcon() non-pure even in wxOSX, as it now doesn't need
to be overridden if GetIcon() is -- but don't make GetIcon() pure
virtual neither to allow the existing code overriding GetLargeIcon() to
keep working.

This incidentally fixes the icons for the standard pages under macOS
broken by 388d322b68 (carry changes to toolbar over to prefs on osx,
2021-09-28), which replaced return statements with assignments,
resulting in the icon being set to the last value assigned to it instead
of the correct one -- this commit restores the previous control flow in
wxStockPreferencesPage::GetLargeIcon() (now called GetIcon()).

Closes #22187.
This commit is contained in:
Vadim Zeitlin
2022-03-10 18:54:58 +00:00
parent e5f195da33
commit 9b2f55833e
4 changed files with 29 additions and 23 deletions

View File

@@ -50,14 +50,15 @@ public:
// Name of the page, used e.g. for tabs
virtual wxString GetName() const = 0;
// Return 32x32 icon used for the page. Currently only used on OS X, where
// Return the icon to use for the page. Currently only used on OS X, where
// implementation is required; unused on other platforms. Because of this,
// the method is only pure virtual on platforms that use it.
#ifdef wxHAS_PREF_EDITOR_ICONS
virtual wxBitmap GetLargeIcon() const = 0;
#else
// these methods are not pure virtual but must be implemented if OS X is
// supported.
//
// New code should override GetIcon(), GetLargeIcon() only exists for
// backwards compatibility.
virtual wxBitmapBundle GetIcon() const { return GetLargeIcon(); }
virtual wxBitmap GetLargeIcon() const { return wxBitmap(); }
#endif
// Create a window (usually a wxPanel) for this page. The caller takes
// ownership of the returned window.
@@ -82,7 +83,7 @@ public:
virtual wxString GetName() const wxOVERRIDE;
#ifdef __WXOSX_COCOA__
virtual wxBitmap GetLargeIcon() const wxOVERRIDE;
virtual wxBitmapBundle GetIcon() const wxOVERRIDE;
#endif
private: