summaryrefslogtreecommitdiff
path: root/src/data/style.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/style.cpp')
-rw-r--r--src/data/style.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/data/style.cpp b/src/data/style.cpp
new file mode 100644
index 0000000..927271c
--- /dev/null
+++ b/src/data/style.cpp
@@ -0,0 +1,60 @@
+#include "style.h"
+
+Style::Style() : _name("none"), _data(0)
+{
+}
+
+Style::Style(QString name, GraphElementData *data) : _name(name), _data(data)
+{
+}
+
+bool Style::isNone()
+{
+ return _data == 0;
+}
+
+GraphElementData *Style::data() const
+{
+ return _data;
+}
+
+QString Style::name() const
+{
+ return _name;
+}
+
+QColor Style::strokeColor() const
+{
+ if (_data == 0) return Qt::black;
+
+ QString col = propertyWithDefault("draw", "black");
+
+ QColor namedColor(col);
+ if (namedColor.isValid()) {
+ return namedColor;
+ } else {
+ // TODO: read RGB colors
+ return QColor(Qt::black);
+ }
+}
+
+// TODO
+int Style::strokeThickness() const
+{
+ return 1;
+}
+
+QPen Style::pen() const
+{
+ QPen p(strokeColor());
+ p.setWidthF((float)strokeThickness() * 3.0f);
+ return p;
+}
+
+QString Style::propertyWithDefault(QString prop, QString def) const
+{
+ QString val = _data->property("tikzit " + prop);
+ if (val.isNull()) val = _data->property(prop);
+ if (val.isNull()) val = def;
+ return val;
+}