Allow constructing wxBitmapBundle from XPM data for compatibility

Add another compatibility implicit constructor to allow the existing
code, directly passing XPM data to various functions that used to take
wxBitmap or wxIcon and now taking wxBitmapBundle, to work.

Closes #22566.
This commit is contained in:
Vadim Zeitlin 2022-06-26 20:51:09 +02:00
parent 8ca3933358
commit f48a13514f
3 changed files with 23 additions and 0 deletions

View file

@ -45,6 +45,12 @@ public:
// wxBitmapBundle.
wxBitmapBundle(const wxImage& image);
// And another one from XPM data, as it's relatively common to pass it to
// various functions that take wxBitmapBundle in the existing code. It is
// not formally deprecated, but should be avoided in any new code and can
// become deprecated in the future.
wxBitmapBundle(const char* const* xpm);
// Default copy ctor and assignment operator and dtor would be ok, but need
// to be defined out of line, where wxBitmapBundleImpl is fully declared.

View file

@ -126,6 +126,18 @@ public:
*/
wxBitmapBundle(const wxImage& image);
/**
Conversion constructor from XPM data.
This constructor overload exists only for compatibility with the
existing code passing XPM data (e.g. @c foo_xpm after including @c
foo.xpm) directly to the functions expecting a bitmap. Don't use it in
the new code, as it is likely to be deprecated in the future.
@since 3.2.0
*/
wxBitmapBundle(const char* const* xpm);
/**
Copy constructor creates a copy of another bundle.
*/

View file

@ -358,6 +358,11 @@ wxBitmapBundle::wxBitmapBundle(const wxImage& image)
{
}
wxBitmapBundle::wxBitmapBundle(const char* const* xpm)
: m_impl(new wxBitmapBundleImplSet(wxBitmap(xpm)))
{
}
wxBitmapBundle::wxBitmapBundle(const wxBitmapBundle& other)
: m_impl(other.m_impl)
{