Inkscape
Vector Graphics Editor
|
#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] |
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.
|
inline |
|
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().
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)
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().
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().
|
inline |
Definition at line 58 of file svg-box.h.
References _value, and SVGLength::computed.
Referenced by SPPage::getBleedSide(), and SPPage::getMarginSide().
|
inlinestatic |
Definition at line 64 of file svg-box.h.
References Geom::X, and Geom::Y.
Referenced by fromString(), and toString().
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().
|
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().
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().
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().
|
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().
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().
|
inline |
|
inline |
void SVGBox::set | ( | double | top, |
double | right, | ||
double | bottom, | ||
double | left | ||
) |
|
inline |
|
inline |
|
inline |
Definition at line 50 of file svg-box.h.
References Geom::GenericRect< C >::bottom(), Geom::GenericRect< C >::left(), Geom::GenericRect< C >::right(), set(), and Geom::GenericRect< C >::top().
Referenced by set().
|
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().
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().
void SVGBox::unset | ( | ) |
Definition at line 159 of file svg-box.cpp.
References _is_set.
Referenced by readOrUnset(), and set().
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().
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().
|
private |
Definition at line 66 of file svg-box.h.
Referenced by fromString(), operator bool(), set(), and unset().
|
private |
Definition at line 68 of file svg-box.h.
Referenced by bottom(), fromString(), fromString(), get(), isZero(), left(), right(), set(), top(), toString(), and update().