SVG for C++
Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Friends | List of all members
SVG::SVG Class Reference

Inherits SVG::Shape.

Classes

class  Style
 

Public Member Functions

 SVG (SVGAttrib _attr={ { "xmlns", "http://www.w3.org/2000/svg" } })
 
 SVG (const SVG &other)
 
 SVG (SVG &&other) noexcept
 
SVGoperator= (SVG &&other) noexcept
 
SVGoperator= (const SVG &other)=delete
 
SVG clone () const
 
AttributeMapstyle (const std::string &key)
 
SVGstyle (const std::string &key, const Attrs &attrs)
 
AttributeMapmedia_style (const std::string &query, const std::string &key)
 
SVGmedia_style (const std::string &query, const std::string &key, const Attrs &attrs)
 
template<typename T >
Variables< T > set_vars (std::initializer_list< VariableSpec< T > > specs)
 
template<typename T >
Variables< T > set_vars (const std::string &selector, std::initializer_list< VariableSpec< T > > specs)
 
template<typename T >
Variables< T > set_vars (const std::string &query, const std::string &selector, std::initializer_list< VariableSpec< T > > specs)
 
std::map< std::string, AttributeMap > & keyframes (const std::string &key)
 
Defsdefs ()
 
template<typename T , typename... Args>
std::enable_if<!std::is_same< T, Defs >::value, T * >::type add_child (Args &&... args)
 
template<typename T , typename... Args>
std::enable_if< std::is_same< T, Defs >::value, T * >::type add_child (Args &&... args)
 
Elementget_element_by_id (const std::string &id)
 
const Elementget_element_by_id (const std::string &id) const
 
template<typename T >
T * get_element_by_id (const std::string &id)
 
template<typename T >
const T * get_element_by_id (const std::string &id) const
 
ElementKind kind () const override
 
BoundingBox get_bbox () const override
 
- Public Member Functions inherited from SVG::Shape
 operator Point () const
 
virtual std::vector< Point > points () const
 
virtual double x () const
 
virtual double y () const
 
virtual double width () const
 
virtual double height () const
 
 Element ()=default
 
 Element (const Element &other)
 
 Element (Element &&other) noexcept
 
 Element (const char *id)
 
- Public Member Functions inherited from SVG::Element
 Element (const Element &other)
 
 Element (Element &&other) noexcept
 
Elementoperator= (const Element &)=delete
 
Elementoperator= (Element &&other) noexcept
 
 Element (const char *id)
 
 operator std::string () const
 
std::unique_ptr< Elementclone_element () const
 
template<typename T , typename... Args>
T * add_child (Args &&... args)
 
template<typename T >
Elementoperator<< (T &&node)
 
template<typename T >
std::vector< T * > get_children ()
 
template<typename T >
std::vector< const T * > get_children () const
 
template<typename T >
std::vector< T * > get_immediate_children ()
 
template<typename T >
std::vector< const T * > get_immediate_children () const
 
Elementget_element_by_id (const std::string &id)
 
const Elementget_element_by_id (const std::string &id) const
 
std::vector< Element * > get_elements_by_class (const std::string &clsname)
 
std::vector< const Element * > get_elements_by_class (const std::string &clsname) const
 
const Elementparent () const
 
Elementid (const std::string &value)
 
std::string id () const
 
void autoscale (const Margins &margins=DEFAULT_MARGINS)
 
void autoscale (const double margin)
 
void autoscale (const AutoscaleOptions &options)
 
void responsive_autoscale (const Margins &margins=DEFAULT_MARGINS)
 
void responsive_autoscale (const double margin)
 
void responsive_autoscale (const AutoscaleOptions &options)
 
Elementlayout_bbox (const BoundingBox &bbox)
 
Elementbbox_padding (const Margins &padding)
 
Elementbbox_padding (double padding)
 
Elementclear_layout_bbox ()
 
bool has_layout_bbox () const
 
BoundingBox layout_bbox () const
 
Elementsnap_to (const Element &target, RelativeAlignment relative, Point offset=Point(0, 0))
 
Elementsnap_to (const Element &target, Alignment alignment, Point offset=Point(0, 0))
 
Elementalign_to (const Element &target, Axis axis, Point offset=Point(0, 0))
 
Elementalign_to (const Element &target, Axis axis, Anchor anchor, Point offset=Point(0, 0))
 
TransformList transform_list ()
 
TransformList transform_list () const
 
TransformList transform ()
 
TransformList transform () const
 
ChildMap get_children ()
 
ConstChildMap get_children () const
 
DepthFirstIterator begin ()
 
ConstDepthFirstIterator begin () const
 
DepthFirstIterator end ()
 
ConstDepthFirstIterator end () const
 
DepthFirstRange depth_first ()
 
DepthFirstRange depth_first (TraversalOptions options)
 
ConstDepthFirstRange depth_first () const
 
ConstDepthFirstRange depth_first (TraversalOptions options) const
 
DepthFirstRange descendants ()
 
DepthFirstRange descendants (TraversalOptions options)
 
ConstDepthFirstRange descendants () const
 
ConstDepthFirstRange descendants (TraversalOptions options) const
 
template<>
Element::ChildList get_immediate_children ()
 
template<>
Element::ConstChildList get_immediate_children () const
 
 AttributeMap ()=default
 
 AttributeMap (SVGAttrib _attr)
 
- Public Member Functions inherited from SVG::AttributeMap
 AttributeMap (SVGAttrib _attr)
 
const SVGAttrib & attrs () const
 
bool has_attr (const std::string &key) const
 
std::string get_attr (const std::string &key, const std::string &fallback="") const
 
template<typename T >
std::enable_if< detail::is_numeric_attr_type< T >::value, T >::type get_attr (const std::string &key, T fallback) const
 
template<typename T >
AttributeMapset_attr (const std::string key, T value)
 
AttributeMapset_attr (const std::string key, const Color &value)
 
AttributeMapset_attrs (std::initializer_list< std::pair< std::string, std::string > > values)
 
AttributeMapset_attrs (const SVGAttrib &values)
 
AttrSetter set_attr (const std::string key)
 
ClassList class_list ()
 
ClassList class_list () const
 
TransformList transform_list ()
 
TransformList transform_list () const
 
TransformList transform ()
 
TransformList transform () const
 
template<>
AttributeMapset_attr (const std::string key, const double value)
 
template<>
AttributeMapset_attr (const std::string key, const char *value)
 
template<>
AttributeMapset_attr (const std::string key, const std::string value)
 

Public Attributes

Stylecss = this->add_child<Style>()
 

Static Public Attributes

static constexpr ElementKind static_kind = ElementKind::SVG
 

Protected Member Functions

std::unique_ptr< Elementclone_element_impl () const override
 
- Protected Member Functions inherited from SVG::Element
std::vector< Element * > get_children_helper ()
 
std::vector< const Element * > get_children_helper () const
 
BoundingBox get_autoscale_bbox () const
 
BoundingBox measured_layout_bbox () const
 
BoundingBox include_stroke_width (const BoundingBox &bbox) const
 
void autoscale_nested_svgs (const AutoscaleOptions &options, bool responsive)
 
void get_bbox (Element::BoundingBox &, bool visible_only=true) const
 
void set_viewbox_from_bbox (const BoundingBox &bbox, const Margins &margins)
 
virtual std::string svg_to_string (const size_t indent_level) const
 
virtual std::string tag ()
 
virtual std::string tag () const
 
template<typename T >
std::unique_ptr< T > clone_as () const
 
void set_attr_value (const std::string &key, const std::string &value) override
 
AttrSetter make_attr_setter (const std::string &key) override
 
SVGowner_svg ()
 
const SVGowner_svg () const
 
void set_owner_svg (SVG *owner)
 
void register_subtree_ids ()
 
void unregister_subtree_ids ()
 
void register_own_id ()
 
void unregister_own_id ()
 
void clear_children ()
 
Elementinsert_child (std::unique_ptr< Element > child, ChildIterator position)
 
void reparent_children ()
 
double find_numeric (const std::string &key) const
 
- Protected Member Functions inherited from SVG::AttributeMap
SVGAttrib & mutable_attrs ()
 

Friends

class Element
 

Additional Inherited Members

- Public Types inherited from SVG::Element
using ChildList = std::vector< Element * >
 
using ConstChildList = std::vector< const Element * >
 
using ChildMap = std::map< std::string, ChildList >
 
using ConstChildMap = std::map< std::string, ConstChildList >
 
- Protected Types inherited from SVG::Element
using ChildIterator = std::vector< std::unique_ptr< Element > >::iterator
 
- Static Protected Member Functions inherited from SVG::Element
static detail::AffineTransform transform_for (const Element *element, const detail::AffineTransform &parent_transform)
 
- Protected Attributes inherited from SVG::Element
std::vector< std::unique_ptr< Element > > children
 

Constructor & Destructor Documentation

◆ SVG() [1/2]

SVG::SVG::SVG ( SVGAttrib  _attr = { { "xmlns", "http://www.w3.org/2000/svg" } })
inline

Create an SVG root element with the default namespace unless attributes override it.

◆ SVG() [2/2]

SVG::SVG::SVG ( const SVG other)
inline

Deep-copy a document and rebuild internal element indexes for the copied tree.

Member Function Documentation

◆ clone()

SVG SVG::SVG::clone ( ) const
inline

Return a deep copy of the SVG document with independent elements and rebuilt indexes.

◆ clone_element_impl()

std::unique_ptr< Element > SVG::SVG::clone_element_impl ( ) const
inlineoverrideprotectedvirtual

Reimplemented from SVG::Element.

◆ defs()

Defs * SVG::SVG::defs ( )
inline

Return the document's singleton defs element, creating it after styles when needed.

◆ get_bbox()

Element::BoundingBox SVG::SVG::get_bbox ( ) const
inlineoverridevirtual

Return the viewport bounds for nested SVGs, or content bounds when no size is set.

Reimplemented from SVG::Element.

◆ get_element_by_id() [1/2]

template<typename T >
T * SVG::SVG::get_element_by_id ( const std::string &  id)
inline

Return an element by id only when its built-in kind matches T::static_kind.

◆ get_element_by_id() [2/2]

template<typename T >
const T * SVG::SVG::get_element_by_id ( const std::string &  id) const
inline

Return an element by id only when its built-in kind matches T::static_kind.

◆ keyframes()

std::map< std::string, AttributeMap > & SVG::SVG::keyframes ( const std::string &  key)
inline

Add or modify an animation keyframe

Parameters
[in]keyThe name of the animation

◆ kind()

ElementKind SVG::SVG::kind ( ) const
inlineoverridevirtual

Return the element category used by typed traversal; custom subclasses default to Custom.

Reimplemented from SVG::Element.

◆ media_style() [1/2]

AttributeMap & SVG::SVG::media_style ( const std::string &  query,
const std::string &  key 
)
inline

Retrieve a handle corresponding to a selector within a CSS media query

◆ media_style() [2/2]

SVG & SVG::SVG::media_style ( const std::string &  query,
const std::string &  key,
const Attrs attrs 
)
inline

Set media-query selector styles from Attrs and return the SVG for chaining.

◆ set_vars() [1/3]

template<typename T >
Variables< T > SVG::SVG::set_vars ( const std::string &  query,
const std::string &  selector,
std::initializer_list< VariableSpec< T > >  specs 
)
inline

Define typed CSS custom properties in a selector inside a media query.

◆ set_vars() [2/3]

template<typename T >
Variables< T > SVG::SVG::set_vars ( const std::string &  selector,
std::initializer_list< VariableSpec< T > >  specs 
)
inline

Define typed CSS custom properties in a selector style block.

◆ set_vars() [3/3]

template<typename T >
Variables< T > SVG::SVG::set_vars ( std::initializer_list< VariableSpec< T > >  specs)
inline

Define typed CSS custom properties in the :root style block.

◆ style() [1/2]

AttributeMap & SVG::SVG::style ( const std::string &  key)
inline

Retrieve a handle corresponding to the given CSS selector

◆ style() [2/2]

SVG & SVG::SVG::style ( const std::string &  key,
const Attrs attrs 
)
inline

Set selector styles from Attrs and return the SVG for chaining.

Member Data Documentation

◆ css

Style* SVG::SVG::css = this->add_child<Style>()

This item's associated CSS stylesheet


The documentation for this class was generated from the following file: