Add wxBitmapBundle::GetIconFor()

This is to GetBitmapFor() as GetIcon() is to GetBitmap().
This commit is contained in:
Vadim Zeitlin 2022-01-22 18:27:36 +00:00
parent 84b5e4639e
commit fc2b7e5266
3 changed files with 20 additions and 3 deletions

View File

@ -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(); }

View File

@ -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.

View File

@ -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
{