Implement loading resource bundle from Windows resources

This allows to use resources defined in the .rc files under MSW instead
of embedding them in the program text as arrays.
This commit is contained in:
Vadim Zeitlin
2021-09-25 00:49:15 +01:00
parent 97f6c85d9b
commit b33df7360a
15 changed files with 815 additions and 62 deletions

View File

@@ -59,6 +59,10 @@ public:
static wxBitmapBundle FromBitmap(const wxBitmap& bitmap);
static wxBitmapBundle FromImage(const wxImage& image);
// Create from the resources: all existing versions of the bitmap of the
// form name_2x or name@2x (and also using other factors) will be used.
static wxBitmapBundle FromResources(const wxString& name);
// Check if bitmap bundle is non-empty.
bool IsOk() const { return m_impl; }
@@ -83,6 +87,16 @@ private:
wxBitmapBundleImplPtr m_impl;
};
// This macro can be used to create a bundle from resources on the platforms
// that support it and from name_png and name_2x_png on the other ones.
#ifdef wxHAS_IMAGE_RESOURCES
#define wxBITMAP_BUNDLE_2(name) wxBitmapBundle::FromResources(#name)
#else
#define wxBITMAP_BUNDLE_2(name) \
wxBitmapBundle::FromBitmaps(wxBITMAP_PNG_FROM_DATA(name), \
wxBITMAP_PNG_FROM_DATA(name##_2x))
#endif
// Inline functions implementation.
/* static */ inline