From fc2b7e5266d10687215ad3582c5cbb5f92b3539e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Jan 2022 18:27:36 +0000 Subject: [PATCH] Add wxBitmapBundle::GetIconFor() This is to GetBitmapFor() as GetIcon() is to GetBitmap(). --- include/wx/bmpbndl.h | 7 ++++--- interface/wx/bmpbndl.h | 11 +++++++++++ src/common/bmpbndl.cpp | 5 +++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/wx/bmpbndl.h b/include/wx/bmpbndl.h index bc511fd847..c0eabee387 100644 --- a/include/wx/bmpbndl.h +++ b/include/wx/bmpbndl.h @@ -115,10 +115,11 @@ public: // GetBitmap() converting the returned bitmap to the icon. wxIcon GetIcon(const wxSize& size) const; - // Helper combining GetBitmap() and GetPreferredSizeFor(): returns the - // bitmap of the size appropriate for the current DPI scaling of the given - // window. + // Helpers combining GetBitmap() or GetIcon() and GetPreferredSizeFor(): + // return the bitmap or icon of the size appropriate for the current DPI + // scaling of the given window. wxBitmap GetBitmapFor(const wxWindow* window) const; + wxIcon GetIconFor(const wxWindow* window) const; // Access implementation wxBitmapBundleImpl* GetImpl() const { return m_impl.get(); } diff --git a/interface/wx/bmpbndl.h b/interface/wx/bmpbndl.h index 733ac23d3a..afc3cda298 100644 --- a/interface/wx/bmpbndl.h +++ b/interface/wx/bmpbndl.h @@ -342,6 +342,17 @@ public: */ wxIcon GetIcon(const wxSize& size) const; + /** + Get icon of the size appropriate for the DPI scaling used by the + given window. + + This is similar to GetBitmapFor(), but returns a wxIcon, as GetIcon() + does. + + @param window Non-null and fully created window. + */ + wxIcon GetIconFor(const wxWindow* window) const; + /** Check if the two bundles refer to the same object. diff --git a/src/common/bmpbndl.cpp b/src/common/bmpbndl.cpp index fa73b9c178..61a9978563 100644 --- a/src/common/bmpbndl.cpp +++ b/src/common/bmpbndl.cpp @@ -477,6 +477,11 @@ wxBitmap wxBitmapBundle::GetBitmapFor(const wxWindow* window) const return GetBitmap(GetPreferredSizeFor(window)); } +wxIcon wxBitmapBundle::GetIconFor(const wxWindow* window) const +{ + return GetIcon(GetPreferredSizeFor(window)); +} + namespace {