53 lines
No EOL
1.1 KiB
C++
53 lines
No EOL
1.1 KiB
C++
#include "SvgTextElement.h"
|
|
|
|
#include "XmlAttribute.h"
|
|
|
|
#include <sstream>
|
|
|
|
SvgTextElement::SvgTextElement()
|
|
:SvgElement("text")
|
|
{
|
|
|
|
}
|
|
|
|
void SvgTextElement::setLocation(const Point& loc)
|
|
{
|
|
auto x = std::make_unique<XmlAttribute>("x");
|
|
auto y = std::make_unique<XmlAttribute>("y");
|
|
|
|
x->setValue(std::to_string(loc.getX()));
|
|
y->setValue(std::to_string(loc.getY()));
|
|
|
|
addAttribute(std::move(x));
|
|
addAttribute(std::move(y));
|
|
}
|
|
|
|
void SvgTextElement::setContent(const std::string& content)
|
|
{
|
|
setText(content);
|
|
}
|
|
|
|
void SvgTextElement::setFill(const Color& fill)
|
|
{
|
|
auto attr = std::make_unique<XmlAttribute>("fill");
|
|
|
|
std::stringstream sstr;
|
|
sstr << "rgb(" << fill.toString() << ")";
|
|
attr->setValue(sstr.str());
|
|
|
|
addAttribute(std::move(attr));
|
|
}
|
|
|
|
void SvgTextElement::setFontFamily(const std::string& family)
|
|
{
|
|
auto attr = std::make_unique<XmlAttribute>("font-family");
|
|
attr->setValue(family);
|
|
addAttribute(std::move(attr));
|
|
}
|
|
|
|
void SvgTextElement::setFontSize(float size)
|
|
{
|
|
auto attr = std::make_unique<XmlAttribute>("font-size");
|
|
attr->setValue(std::to_string(size));
|
|
addAttribute(std::move(attr));
|
|
} |