From 630e6b898fa4d3a20ea424aef33b31757e41dc23 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 5 Oct 2021 22:42:16 +0100 Subject: [PATCH] Add conversion ctor from wxIcon to wxBitmapBundle too Existing code may call functions taking wxBitmap with wxIcon, due to an existing conversion from wxIcon to wxBitmap, so we need to provide a similar conversion to wxBitmapBundle for compatibility. --- include/wx/bmpbndl.h | 3 +++ interface/wx/bmpbndl.h | 8 ++++++++ src/common/bmpbndl.cpp | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/include/wx/bmpbndl.h b/include/wx/bmpbndl.h index 8e4d9f68ab..f5db5ab140 100644 --- a/include/wx/bmpbndl.h +++ b/include/wx/bmpbndl.h @@ -41,6 +41,9 @@ public: // using wxBitmap. wxBitmapBundle(const wxBitmap& bitmap); + // This is similar to above and also exists only for compatibility. + wxBitmapBundle(const wxIcon& icon); + // Another conversion ctor from a single image: this one is needed to allow // passing wxImage to the functions that used to take wxBitmap but now take // wxBitmapBundle. diff --git a/interface/wx/bmpbndl.h b/interface/wx/bmpbndl.h index bd9d4cb5e3..c17273ef04 100644 --- a/interface/wx/bmpbndl.h +++ b/interface/wx/bmpbndl.h @@ -108,6 +108,14 @@ public: */ wxBitmapBundle(const wxBitmap& bitmap); + /** + Conversion constructor from a single icon. + + This constructor does the same thing as FromBitmap() and only exists + for interoperability with the existing code using wxIcon. + */ + wxBitmapBundle(const wxIcon& icon); + /** Conversion constructor from a single image. diff --git a/src/common/bmpbndl.cpp b/src/common/bmpbndl.cpp index 61ed5f731e..0628b5ecd0 100644 --- a/src/common/bmpbndl.cpp +++ b/src/common/bmpbndl.cpp @@ -22,6 +22,7 @@ #endif // WX_PRECOMP #include "wx/bmpbndl.h" +#include "wx/icon.h" #include "wx/private/bmpbndl.h" @@ -257,6 +258,11 @@ wxBitmapBundle::wxBitmapBundle(const wxBitmap& bitmap) { } +wxBitmapBundle::wxBitmapBundle(const wxIcon& icon) + : m_impl(icon.IsOk() ? new wxBitmapBundleImplSet(wxBitmap(icon)) : NULL) +{ +} + wxBitmapBundle::wxBitmapBundle(const wxImage& image) : m_impl(image.IsOk() ? new wxBitmapBundleImplSet(wxBitmap(image)) : NULL) {