Add FromSVG() overload taking const data
Passing non-const data is inconvenient and error-prone, as data can't be used again after it was modified by Nano SVG, which resulted in the button using SVG bitmap not working any longer in the toolbar sample after recreating the toolbar. So make it easier to do the right thing, while still keeping the overload taking non-const data for the situations when avoiding an extra copy is worth it.
This commit is contained in:
@@ -195,16 +195,21 @@ public:
|
||||
|
||||
@param data This data may, or not, have the XML document preamble, i.e.
|
||||
it can start either with @c "<?xml" processing instruction or
|
||||
directly with @c svg tag. Notice that the pointer is non-const as
|
||||
the current implementation modifies it while parsing, i.e. do @a
|
||||
not use @c const_cast to pass data that is actually const to this
|
||||
function.
|
||||
directly with @c svg tag. Notice that two overloads of this
|
||||
function, taking const and non-const data, are provided: as the
|
||||
current implementation modifies the data while parsing, using the
|
||||
non-const variant is more efficient, as it avoids making copy of
|
||||
the data, but the data is consumed by it and can't be reused any
|
||||
more.
|
||||
@param sizeDef The default size to return from GetDefaultSize() for
|
||||
this bundle. As SVG images usually don't have any natural
|
||||
default size, it should be provided when creating the bundle.
|
||||
*/
|
||||
static wxBitmapBundle FromSVG(char* data, const wxSize sizeDef);
|
||||
|
||||
/// @overload
|
||||
static wxBitmapBundle FromSVG(const char* data, const wxSize sizeDef);
|
||||
|
||||
/**
|
||||
Check if bitmap bundle is non-empty.
|
||||
|
||||
|
Reference in New Issue
Block a user