From fb4e188cea7ef9be6236761cbf603441c499b2e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 5 Oct 2021 16:12:01 +0100 Subject: [PATCH] Add wxHAS_SVG feature test macro This is more clear and future-proof than using wxHAS_RAW_BITMAP for checking for SVG availability. --- docs/doxygen/mainpages/const_cpp.h | 1 + include/wx/bmpbndl.h | 11 +++++++++-- interface/wx/bmpbndl.h | 6 +++--- samples/toolbar/toolbar.cpp | 2 ++ src/generic/bmpsvg.cpp | 7 ++++--- tests/graphics/bmpbundle.cpp | 4 ++-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/docs/doxygen/mainpages/const_cpp.h b/docs/doxygen/mainpages/const_cpp.h index e519d217e5..0c9fdd9b8b 100644 --- a/docs/doxygen/mainpages/const_cpp.h +++ b/docs/doxygen/mainpages/const_cpp.h @@ -209,6 +209,7 @@ Currently the following symbols exist: @itemdef{wxHAS_REGEX_ADVANCED, Defined if advanced syntax is available in wxRegEx. This is always the case in wxWidgets 3.1.6 and later, so this symbol doesn't need to be tested any more.} +@itemdef{wxHAS_SVG, Defined if SVG support (currently only via wxBitmapBundle::FromSVG()) is available.} @itemdef{wxHAS_TASK_BAR_ICON, Defined if wxTaskBarIcon is available on the current platform.} @itemdef{wxHAS_WINDOW_LABEL_IN_STATIC_BOX, Defined if wxStaticBox::Create() overload taking @c wxWindow* instead of the text label is available on the current platform.} diff --git a/include/wx/bmpbndl.h b/include/wx/bmpbndl.h index 21f0da4174..70794bf756 100644 --- a/include/wx/bmpbndl.h +++ b/include/wx/bmpbndl.h @@ -16,6 +16,13 @@ class wxBitmapBundleImpl; +// It should be possible to implement SVG rasterizing without raw bitmap +// support using wxDC::DrawSpline(), but currently we don't do it and so +// FromSVG() is only available in the ports providing raw bitmap access. +#ifdef wxHAS_RAW_BITMAP + #define wxHAS_SVG +#endif + // ---------------------------------------------------------------------------- // wxBitmapBundle provides 1 or more versions of a bitmap, all bundled together // ---------------------------------------------------------------------------- @@ -62,7 +69,7 @@ public: // It should be possible to implement SVG rasterizing without raw bitmap // support using wxDC::DrawSpline(), but currently we don't do it and so // FromSVG() is only available in the ports providing raw bitmap access. -#ifdef wxHAS_RAW_BITMAP +#ifdef wxHAS_SVG // Create from the SVG data (data is supposed to be in UTF-8 encoding). // Notice that the data here is non-const because it can be temporarily // modified while parsing it. @@ -70,7 +77,7 @@ public: // This overload currently makes a copy of the data. static wxBitmapBundle FromSVG(const char* data, const wxSize sizeDef); -#endif // wxHAS_RAW_BITMAP +#endif // wxHAS_SVG // 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. diff --git a/interface/wx/bmpbndl.h b/interface/wx/bmpbndl.h index b7ea18bc1c..9cc2194e1a 100644 --- a/interface/wx/bmpbndl.h +++ b/interface/wx/bmpbndl.h @@ -203,9 +203,9 @@ public: These limitations will be relaxed in the future wxWidgets versions. Please also note that this method is only available in the ports - providing raw bitmap access via wxPixelData and so defining - wxHAS_RAW_BITMAP symbol. Currently SVG images are not supported in the - ports without it, e.g. wxX11. + providing raw bitmap access via wxPixelData. This is the case for all + tier-1 ports, but not all of them, check if @c wxHAS_SVG is defined + before using this method if for maximum portability. @param data This data may, or not, have the XML document preamble, i.e. it can start either with @c "