1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 21:51:17 +01:00
GPXSee/src/map/ENC/style.h

113 lines
2.6 KiB
C
Raw Normal View History

2022-11-04 09:03:36 +01:00
#ifndef ENC_STYLE_H
#define ENC_STYLE_H
#include <QPen>
#include <QBrush>
#include <QMap>
2022-11-05 17:43:32 +01:00
#include "objects.h"
2022-11-04 09:03:36 +01:00
namespace ENC {
2022-11-05 17:43:32 +01:00
#define TYPE(t) ((t)<<16)
#define SUBTYPE(t, s) (((t)<<16)|(s))
2022-11-04 09:03:36 +01:00
class Style
{
public:
enum FontSize {
None,
Small,
Normal,
Large,
};
class Polygon {
public:
Polygon() : _brush(Qt::NoBrush), _pen(Qt::NoPen) {}
Polygon(const QBrush &brush, const QPen &pen = Qt::NoPen)
: _brush(brush)
{
_pen = (pen == Qt::NoPen) ? QPen(_brush, 0) : pen;
}
2022-11-08 00:38:45 +01:00
Polygon(const QImage &img)
: _brush(Qt::NoBrush), _pen(Qt::NoPen), _img(img.convertToFormat(
QImage::Format_ARGB32_Premultiplied)) {}
2022-11-04 09:03:36 +01:00
const QPen &pen() const {return _pen;}
const QBrush &brush() const {return _brush;}
2022-11-08 00:38:45 +01:00
const QImage &img() const {return _img;}
2022-11-04 09:03:36 +01:00
private:
QBrush _brush;
QPen _pen;
2022-11-08 00:38:45 +01:00
QImage _img;
2022-11-04 09:03:36 +01:00
};
class Line {
public:
Line() : _pen(Qt::NoPen), _textFontSize(None) {}
Line(const QPen &pen) : _pen(pen), _textFontSize(None) {}
2022-11-04 09:03:36 +01:00
Line(const QImage &img)
: _pen(Qt::NoPen), _textFontSize(None), _img(img.convertToFormat(
2022-11-04 09:03:36 +01:00
QImage::Format_ARGB32_Premultiplied)) {}
void setTextColor(const QColor &color) {_textColor = color;}
void setTextFontSize(FontSize size) {_textFontSize = size;}
const QPen &pen() const {return _pen;}
2022-11-04 09:03:36 +01:00
const QColor &textColor() const {return _textColor;}
FontSize textFontSize() const {return _textFontSize;}
const QImage &img() const {return _img;}
private:
QPen _pen;
2022-11-04 09:03:36 +01:00
QColor _textColor;
FontSize _textFontSize;
QImage _img;
};
class Point {
public:
2022-12-08 00:29:39 +01:00
Point() : _textColor(Qt::black), _haloColor(Qt::white),
_textFontSize(Normal) {}
2022-11-04 09:03:36 +01:00
Point(const QImage &img, FontSize fontSize = Normal)
2022-12-08 00:29:39 +01:00
: _textColor(Qt::black), _haloColor(Qt::white),
_textFontSize(fontSize), _img(img) {}
2022-11-04 09:03:36 +01:00
void setTextColor(const QColor &color) {_textColor = color;}
2022-12-08 00:29:39 +01:00
void setHaloColor(const QColor &color) {_haloColor = color;}
2022-11-04 09:03:36 +01:00
void setTextFontSize(FontSize size) {_textFontSize = size;}
const QColor &textColor() const {return _textColor;}
2022-12-08 00:29:39 +01:00
const QColor &haloColor() const {return _haloColor;}
2022-11-04 09:03:36 +01:00
FontSize textFontSize() const {return _textFontSize;}
const QImage &img() const {return _img;}
private:
2022-12-08 00:29:39 +01:00
QColor _textColor, _haloColor;
2022-11-04 09:03:36 +01:00
FontSize _textFontSize;
QImage _img;
};
Style();
const Line &line(uint type) const;
const Polygon &polygon(uint type) const;
const Point &point(uint type) const;
2022-11-04 09:03:36 +01:00
const QVector<uint> &drawOrder() const {return _drawOrder;}
private:
2022-12-05 08:52:27 +01:00
void polygonStyle();
void lineStyle();
void pointStyle();
2022-11-04 09:03:36 +01:00
QMap<uint, Line> _lines;
QMap<uint, Polygon> _polygons;
QMap<uint, Point> _points;
QVector<uint> _drawOrder;
};
}
#endif // ENC_STYLE_H