Add wxHAS_SVG feature test macro
This is more clear and future-proof than using wxHAS_RAW_BITMAP for checking for SVG availability.
This commit is contained in:
@@ -209,6 +209,7 @@ Currently the following symbols exist:
|
|||||||
@itemdef{wxHAS_REGEX_ADVANCED, Defined if advanced syntax is available in
|
@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
|
wxRegEx. This is always the case in wxWidgets 3.1.6 and later, so this
|
||||||
symbol doesn't need to be tested any more.}
|
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_TASK_BAR_ICON, Defined if wxTaskBarIcon is available on the current platform.}
|
||||||
@itemdef{wxHAS_WINDOW_LABEL_IN_STATIC_BOX, Defined if wxStaticBox::Create()
|
@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.}
|
overload taking @c wxWindow* instead of the text label is available on the current platform.}
|
||||||
|
@@ -16,6 +16,13 @@
|
|||||||
|
|
||||||
class wxBitmapBundleImpl;
|
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
|
// 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
|
// It should be possible to implement SVG rasterizing without raw bitmap
|
||||||
// support using wxDC::DrawSpline(), but currently we don't do it and so
|
// support using wxDC::DrawSpline(), but currently we don't do it and so
|
||||||
// FromSVG() is only available in the ports providing raw bitmap access.
|
// 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).
|
// 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
|
// Notice that the data here is non-const because it can be temporarily
|
||||||
// modified while parsing it.
|
// modified while parsing it.
|
||||||
@@ -70,7 +77,7 @@ public:
|
|||||||
|
|
||||||
// This overload currently makes a copy of the data.
|
// This overload currently makes a copy of the data.
|
||||||
static wxBitmapBundle FromSVG(const char* data, const wxSize sizeDef);
|
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
|
// 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.
|
// form name_2x or name@2x (and also using other factors) will be used.
|
||||||
|
@@ -203,9 +203,9 @@ public:
|
|||||||
These limitations will be relaxed in the future wxWidgets versions.
|
These limitations will be relaxed in the future wxWidgets versions.
|
||||||
|
|
||||||
Please also note that this method is only available in the ports
|
Please also note that this method is only available in the ports
|
||||||
providing raw bitmap access via wxPixelData and so defining
|
providing raw bitmap access via wxPixelData. This is the case for all
|
||||||
wxHAS_RAW_BITMAP symbol. Currently SVG images are not supported in the
|
tier-1 ports, but not all of them, check if @c wxHAS_SVG is defined
|
||||||
ports without it, e.g. wxX11.
|
before using this method if for maximum portability.
|
||||||
|
|
||||||
@param data This data may, or not, have the XML document preamble, i.e.
|
@param data This data may, or not, have the XML document preamble, i.e.
|
||||||
it can start either with @c "<?xml" processing instruction or
|
it can start either with @c "<?xml" processing instruction or
|
||||||
|
@@ -421,8 +421,10 @@ void MyFrame::PopulateToolbar(wxToolBarBase* toolBar)
|
|||||||
const wxSize sizeBitmap = toolBarBitmaps[Tool_new].GetDefaultSize() *
|
const wxSize sizeBitmap = toolBarBitmaps[Tool_new].GetDefaultSize() *
|
||||||
(m_smallToolbar ? 1 : 2);
|
(m_smallToolbar ? 1 : 2);
|
||||||
|
|
||||||
|
#ifdef wxHAS_SVG
|
||||||
// Use vector SVG image for this button for demonstration purposes.
|
// Use vector SVG image for this button for demonstration purposes.
|
||||||
toolBarBitmaps[Tool_about] = wxBitmapBundle::FromSVG(svg_data, sizeBitmap);
|
toolBarBitmaps[Tool_about] = wxBitmapBundle::FromSVG(svg_data, sizeBitmap);
|
||||||
|
#endif // wxHAS_SVG
|
||||||
|
|
||||||
// Note that there is no need for FromDIP() here, wxMSW will adjust the
|
// Note that there is no need for FromDIP() here, wxMSW will adjust the
|
||||||
// size on its own and under the other platforms there is no need for
|
// size on its own and under the other platforms there is no need for
|
||||||
|
@@ -19,13 +19,14 @@
|
|||||||
// for compilers that support precompilation, includes "wx.h".
|
// for compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef wxHAS_RAW_BITMAP
|
#include "wx/bmpbndl.h"
|
||||||
|
|
||||||
|
#ifdef wxHAS_SVG
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/utils.h" // Only for wxMin()
|
#include "wx/utils.h" // Only for wxMin()
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/bmpbndl.h"
|
|
||||||
#include "wx/rawbmp.h"
|
#include "wx/rawbmp.h"
|
||||||
|
|
||||||
#include "wx/private/bmpbndl.h"
|
#include "wx/private/bmpbndl.h"
|
||||||
@@ -180,4 +181,4 @@ wxBitmapBundle wxBitmapBundle::FromSVG(const char* data, const wxSize sizeDef)
|
|||||||
return FromSVG(copy.data(), sizeDef);
|
return FromSVG(copy.data(), sizeDef);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxHAS_RAW_BITMAP
|
#endif // wxHAS_SVG
|
||||||
|
@@ -47,7 +47,7 @@ TEST_CASE("BitmapBundle::FromBitmaps", "[bmpbundle]")
|
|||||||
CHECK( b.GetBitmap(wxSize(24, 24)).GetSize() == wxSize(24, 24) );
|
CHECK( b.GetBitmap(wxSize(24, 24)).GetSize() == wxSize(24, 24) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef wxHAS_RAW_BITMAP
|
#ifdef wxHAS_SVG
|
||||||
|
|
||||||
TEST_CASE("BitmapBundle::FromSVG", "[bmpbundle][svg]")
|
TEST_CASE("BitmapBundle::FromSVG", "[bmpbundle][svg]")
|
||||||
{
|
{
|
||||||
@@ -76,4 +76,4 @@ TEST_CASE("BitmapBundle::FromSVG", "[bmpbundle][svg]")
|
|||||||
CHECK( b.GetBitmap(wxSize(16, 16)).GetSize() == wxSize(16, 16) );
|
CHECK( b.GetBitmap(wxSize(16, 16)).GetSize() == wxSize(16, 16) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxHAS_RAW_BITMAP
|
#endif // wxHAS_SVG
|
||||||
|
Reference in New Issue
Block a user