X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/327972e7b61eed1feb5a306c816541c2e0d2d301..91270d2d17374f24a4de5108ea1a332190b827a6:/include/wx/gdicmn.h diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index e6368d8ff2..624c495072 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -218,6 +218,28 @@ enum wxStockCursor #define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM) #endif // platform +// Macro for creating wxBitmap from in-memory PNG data. +// +// It reads PNG data from name_png static byte arrays that can be created using +// e.g. misc/scripts/png2c.py. +// +// This macro exists mostly as a helper for wxBITMAP_PNG() below but also +// because it's slightly more convenient to use than NewFromPNGData() directly. +#define wxBITMAP_PNG_FROM_DATA(name) \ + wxBitmap::NewFromPNGData(name##_png, WXSIZEOF(name##_png)) + +// Similar to wxBITMAP but used for the bitmaps in PNG format. +// +// Under Windows they should be embedded into the resource file using RT_RCDATA +// resource type and under OS X the PNG file with the specified name must be +// available in the resource subdirectory of the bundle. Elsewhere, this is +// exactly the same thing as wxBITMAP_PNG_FROM_DATA() described above. +#if defined(__WINDOWS__) || defined(__WXOSX__) + #define wxBITMAP_PNG(name) wxBitmap(wxS(#name), wxBITMAP_TYPE_PNG_RESOURCE) +#else + #define wxBITMAP_PNG(name) wxBITMAP_PNG_FROM_DATA(name) +#endif + // =========================================================================== // classes // =========================================================================== @@ -255,6 +277,13 @@ public: { if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; } void DecTo(const wxSize& sz) { if ( sz.x < x ) x = sz.x; if ( sz.y < y ) y = sz.y; } + void DecToIfSpecified(const wxSize& sz) + { + if ( sz.x != wxDefaultCoord && sz.x < x ) + x = sz.x; + if ( sz.y != wxDefaultCoord && sz.y < y ) + y = sz.y; + } void IncBy(int dx, int dy) { x += dx; y += dy; } void IncBy(const wxPoint& pt);