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.
This commit is contained in:
Vadim Zeitlin
2021-10-05 22:42:16 +01:00
parent d4bc1daf19
commit 630e6b898f
3 changed files with 17 additions and 0 deletions

View File

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

View File

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

View File

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