Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
SVGBox Class Reference

#include <svg-box.h>

Public Member Functions

 SVGBox ()
 An svg box is a type of css/html type which contains up to 4 svg lengths.
 
 SVGBox (Geom::OptRect box)
 
bool read (const std::string &value, const Geom::Scale &doc_scale)
 Read in the value, may be an array of four.
 
void unset ()
 
void readOrUnset (gchar const *str, const Geom::Scale &doc_scale)
 
void update (double em, double ex, double width, double height)
 Update box with em, ex and percentage scaling.
 
 operator bool () const
 
std::string write () const
 Write out the values into a compact form.
 
std::string toString (const std::string &unit, const Geom::Scale &doc_scale, std::optional< unsigned int > precision={}, bool add_unit=true) const
 Write as specific unit for user display.
 
bool fromString (const std::string &value, const std::string &unit, const Geom::Scale &doc_scale)
 Set the svg box from user input, with a default unit.
 
bool fromString (BoxSide side, const std::string &value, const std::string &unit, const Geom::Scale &doc_scale)
 Parse a single side from a string and unit combo (pass through to SVGLength.fromString)
 
bool isZero () const
 Returns true if the box is set, but all values are zero.
 
void set (BoxSide side, double value, bool confine=false)
 Set the value of the side, retaining it's original unit.
 
void set (double top, double right, double bottom, double left)
 Set values into this box model.
 
void set (double top, double horz, double bottom)
 
void set (double vert, double horz)
 
void set (double size)
 
void set (Geom::Rect box)
 
void set (Geom::OptRect box)
 
double get (BoxSide side) const
 
SVGLength top () const
 
SVGLength right () const
 
SVGLength bottom () const
 
SVGLength left () const
 

Static Public Member Functions

static Geom::Dim2 get_scale_axis (BoxSide side)
 

Private Attributes

bool _is_set = false
 
SVGLength _value [4]
 

Detailed Description

Definition at line 26 of file svg-box.h.

Constructor & Destructor Documentation

◆ SVGBox() [1/2]

SVGBox::SVGBox ( )

An svg box is a type of css/html type which contains up to 4 svg lengths.

Usally representing widths, margins, padding of the html box model.

Definition at line 29 of file svg-box.cpp.

◆ SVGBox() [2/2]

SVGBox::SVGBox ( Geom::OptRect  box)
inline

Definition at line 29 of file svg-box.h.

References set.

Member Function Documentation

◆ bottom()

SVGLength SVGBox::bottom ( ) const
inline

Definition at line 61 of file svg-box.h.

References _value, BOX_BOTTOM, and top().

Referenced by SPPage::getBleed(), SPPage::getDocumentMargin(), set(), set(), and SPPage::setDocumentRect().

◆ fromString() [1/2]

bool SVGBox::fromString ( BoxSide  side,
const std::string &  value,
const std::string &  unit,
const Geom::Scale doc_scale 
)

Parse a single side from a string and unit combo (pass through to SVGLength.fromString)

Parameters
side- The side of the box to set
value- The string value entered by the user
unit- The default units the context is using
doc_scale- The document scale factor, for when units are being parsed

Definition at line 116 of file svg-box.cpp.

References _value, SVGLength::fromString(), and get_scale_axis().

◆ fromString() [2/2]

bool SVGBox::fromString ( const std::string &  value,
const std::string &  unit,
const Geom::Scale doc_scale 
)

Set the svg box from user input, with a default unit.

Definition at line 86 of file svg-box.cpp.

References _is_set, _value, BOX_TOP, and fromString().

Referenced by fromString(), read(), SPPage::setBleed(), SPPage::setMargin(), and SPPage::setMarginSide().

◆ get()

double SVGBox::get ( BoxSide  side) const
inline

Definition at line 58 of file svg-box.h.

References _value, and SVGLength::computed.

Referenced by SPPage::getBleedSide(), and SPPage::getMarginSide().

◆ get_scale_axis()

static Geom::Dim2 SVGBox::get_scale_axis ( BoxSide  side)
inlinestatic

Definition at line 64 of file svg-box.h.

References Geom::X, and Geom::Y.

Referenced by fromString(), and toString().

◆ isZero()

bool SVGBox::isZero ( ) const

Returns true if the box is set, but all values are zero.

Definition at line 125 of file svg-box.cpp.

References _value.

Referenced by SPPage::getBleedLabel(), and SPPage::getMarginLabel().

◆ left()

SVGLength SVGBox::left ( ) const
inline

Definition at line 62 of file svg-box.h.

References _value, BOX_LEFT, and right().

Referenced by SPPage::getBleed(), SPPage::getDocumentMargin(), set(), and SPPage::setDocumentRect().

◆ operator bool()

SVGBox::operator bool ( ) const
inline

Definition at line 36 of file svg-box.h.

References _is_set.

◆ read()

bool SVGBox::read ( const std::string &  value,
const Geom::Scale doc_scale 
)

Read in the value, may be an array of four.

Definition at line 35 of file svg-box.cpp.

References fromString().

Referenced by SPPage::copyFrom(), and readOrUnset().

◆ readOrUnset()

void SVGBox::readOrUnset ( gchar const *  str,
const Geom::Scale doc_scale 
)

Definition at line 163 of file svg-box.cpp.

References read(), and unset().

Referenced by SPPage::set().

◆ right()

SVGLength SVGBox::right ( ) const
inline

Definition at line 60 of file svg-box.h.

References _value, BOX_RIGHT, and top().

Referenced by SPPage::getBleed(), SPPage::getDocumentMargin(), left(), set(), and SPPage::setDocumentRect().

◆ set() [1/7]

void SVGBox::set ( BoxSide  side,
double  px,
bool  confine = false 
)

Set the value of the side, retaining it's original unit.

confine - If true, will set any OTHER sides which are the same.

Definition at line 148 of file svg-box.cpp.

References _is_set, _value, original, SVGLength::PX, and SVGLength::set().

Referenced by SPPage::setBleedSide(), and SPPage::setMarginSide().

◆ set() [2/7]

void SVGBox::set ( double  size)
inline

Definition at line 48 of file svg-box.h.

References set(), and size.

Referenced by set().

◆ set() [3/7]

void SVGBox::set ( double  top,
double  horz,
double  bottom 
)
inline

Definition at line 46 of file svg-box.h.

References bottom(), set(), and top().

Referenced by set().

◆ set() [4/7]

void SVGBox::set ( double  top,
double  right,
double  bottom,
double  left 
)

Set values into this box model.

Definition at line 136 of file svg-box.cpp.

References bottom(), BOX_BOTTOM, BOX_LEFT, BOX_RIGHT, BOX_TOP, left(), right(), set, and top().

◆ set() [5/7]

void SVGBox::set ( double  vert,
double  horz 
)
inline

Definition at line 47 of file svg-box.h.

References set().

Referenced by set().

◆ set() [6/7]

void SVGBox::set ( Geom::OptRect  box)
inline

Definition at line 51 of file svg-box.h.

References set, and unset().

◆ set() [7/7]

void SVGBox::set ( Geom::Rect  box)
inline

◆ top()

SVGLength SVGBox::top ( ) const
inline

Definition at line 59 of file svg-box.h.

References _value, and BOX_TOP.

Referenced by bottom(), SPPage::getBleed(), SPPage::getDocumentMargin(), right(), set(), set(), and SPPage::setDocumentRect().

◆ toString()

std::string SVGBox::toString ( const std::string &  unit,
const Geom::Scale doc_scale,
std::optional< unsigned int >  precision = {},
bool  add_unit = true 
) const

Write as specific unit for user display.

Definition at line 62 of file svg-box.cpp.

References _value, BOX_TOP, get_scale_axis(), SVGLength::toString(), write(), and SVGLength::write().

Referenced by SPPage::getBleedLabel(), SPPage::getMarginLabel(), and write().

◆ unset()

void SVGBox::unset ( )

Definition at line 159 of file svg-box.cpp.

References _is_set.

Referenced by readOrUnset(), and set().

◆ update()

void SVGBox::update ( double  em,
double  ex,
double  width,
double  height 
)

Update box with em, ex and percentage scaling.

Definition at line 43 of file svg-box.cpp.

References _value, height, SVGLength::update(), and width.

Referenced by SPPage::update_relatives().

◆ write()

std::string SVGBox::write ( ) const

Write out the values into a compact form.

Definition at line 54 of file svg-box.cpp.

References toString().

Referenced by toString(), and SPPage::write().

Member Data Documentation

◆ _is_set

bool SVGBox::_is_set = false
private

Definition at line 66 of file svg-box.h.

Referenced by fromString(), operator bool(), set(), and unset().

◆ _value

SVGLength SVGBox::_value[4]
private

Definition at line 68 of file svg-box.h.

Referenced by bottom(), fromString(), fromString(), get(), isZero(), left(), right(), set(), top(), toString(), and update().


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