Image polygon lines
[GPXSee.git] / src / map / ENC / style.h
blob87337a4380a8151b65601eb3bea0a2c0444f2e81
1 #ifndef ENC_STYLE_H
2 #define ENC_STYLE_H
4 #include <QPen>
5 #include <QBrush>
6 #include <QMap>
7 #include "objects.h"
9 namespace ENC {
11 #define TYPE(t) ((t)<<16)
12 #define SUBTYPE(t, s) (((t)<<16)|(s))
14 class Style
16 public:
17 enum FontSize {
18 None,
19 Small,
20 Normal,
21 Large,
24 class Polygon {
25 public:
26 Polygon() : _brush(Qt::NoBrush), _pen(Qt::NoPen) {}
27 Polygon(const QBrush &brush, const QPen &pen = Qt::NoPen)
28 : _brush(brush)
30 _pen = (pen == Qt::NoPen) ? QPen(_brush, 0) : pen;
32 Polygon(const QImage &img)
33 : _brush(Qt::NoBrush), _pen(Qt::NoPen), _img(img.convertToFormat(
34 QImage::Format_ARGB32_Premultiplied)) {}
36 const QPen &pen() const {return _pen;}
37 const QBrush &brush() const {return _brush;}
38 const QImage &img() const {return _img;}
40 private:
41 QBrush _brush;
42 QPen _pen;
43 QImage _img;
46 class Line {
47 public:
48 Line() : _pen(Qt::NoPen), _textFontSize(None) {}
49 Line(const QPen &pen) : _pen(pen), _textFontSize(None) {}
50 Line(const QImage &img)
51 : _pen(Qt::NoPen), _textFontSize(None), _img(img.convertToFormat(
52 QImage::Format_ARGB32_Premultiplied)) {}
54 void setTextColor(const QColor &color) {_textColor = color;}
55 void setTextFontSize(FontSize size) {_textFontSize = size;}
57 const QPen &pen() const {return _pen;}
58 const QColor &textColor() const {return _textColor;}
59 FontSize textFontSize() const {return _textFontSize;}
60 const QImage &img() const {return _img;}
62 private:
63 QPen _pen;
64 QColor _textColor;
65 FontSize _textFontSize;
66 QImage _img;
69 class Point {
70 public:
71 Point() : _textColor(Qt::black), _textFontSize(Normal) {}
72 Point(const QImage &img, FontSize fontSize = Normal)
73 : _textColor(Qt::black), _textFontSize(fontSize), _img(img) {}
75 void setTextColor(const QColor &color) {_textColor = color;}
76 void setTextFontSize(FontSize size) {_textFontSize = size;}
78 const QColor &textColor() const {return _textColor;}
79 FontSize textFontSize() const {return _textFontSize;}
80 const QImage &img() const {return _img;}
82 private:
83 QColor _textColor;
84 FontSize _textFontSize;
85 QImage _img;
88 Style();
90 const Line &line(uint type) const;
91 const Polygon &polygon(uint type) const;
92 const Point &point(quint32 type) const;
93 const QVector<uint> &drawOrder() const {return _drawOrder;}
95 static bool isSounding(quint32 type)
96 {return type == TYPE(SOUNDG);}
98 private:
99 void defaultPolygonStyle();
100 void defaultLineStyle();
101 void defaultPointStyle();
103 QMap<uint, Line> _lines;
104 QMap<uint, Polygon> _polygons;
105 QMap<uint, Point> _points;
106 QVector<uint> _drawOrder;
111 #endif // ENC_STYLE_H