MythTV master
mythfontproperties.h
Go to the documentation of this file.
1#ifndef MYTHFONTPROPERTIES_H_
2#define MYTHFONTPROPERTIES_H_
3
4#include <QFont>
5#include <QColor>
6#include <QBrush>
7#include <QPoint>
8#include <QMap>
9#include <QMutex>
10
11#include "xmlparsebase.h"
12
14{
15 public:
17
18 QFont* GetFace(void) { return &m_face; }
19
20 void SetFace(const QFont &face);
21 void SetColor(const QColor &color);
22 void SetShadow(bool on, QPoint offset, const QColor &color, int alpha);
23 void SetOutline(bool on, const QColor &color, int size, int alpha);
24
25 QFont face(void) const;
26 QColor color(void) const { return m_brush.color(); }
27 QBrush GetBrush(void) const { return m_brush; }
28
29 bool hasShadow(void) const { return m_hasShadow; }
30 void GetShadow(QPoint &offset, QColor &color, int &alpha) const;
31
32 bool hasOutline(void) const { return m_hasOutline; }
33 void GetOutline(QColor &color, int &size, int &alpha) const;
34
35 QString GetHash(void) const { return m_hash; }
36
37 static MythFontProperties *ParseFromXml(
38 const QString &filename, const QDomElement &element,
39 MythUIType *parent = nullptr, bool addToGlobal = false,
40 bool showWarnings = true);
41
42 void SetRelativeSize(float rSize) { m_relativeSize = rSize; }
43 float GetRelativeSize(void) const { return m_relativeSize; }
44 void SetPixelSize(float size);
45 void SetPointSize(uint points);
46 void Rescale(void);
47 void Rescale(int height);
48 void AdjustStretch(int stretch);
49
50 static void Zoom(void);
51 static void SetZoom(uint zoom_percent);
52
53 private:
54 void Freeze(void); // no hash updates
55 void Unfreeze(void);
56
57 void CalcHash(void);
58
59 QFont m_face;
60 QBrush m_brush {Qt::white};
61
62 bool m_hasShadow {false};
65 int m_shadowAlpha {255};
66
67 bool m_hasOutline {false};
69 int m_outlineSize {0};
70 int m_outlineAlpha {255};
71
72 float m_relativeSize {0.5F};
73
74 QString m_hash;
75
76 bool m_bFreeze {false};
77
78 int m_stretch {100};
79
80 static QMutex s_zoomLock;
82
83 friend class FontMap;
84};
85
87{
88 public:
89 FontMap() = default;
90
91 MythFontProperties *GetFont(const QString &text);
92 bool AddFont(const QString &text, MythFontProperties *fontProp);
93 bool Contains(const QString &text);
94
95 void Clear(void);
96 void Rescale(int height = 0);
97
98 static FontMap *GetGlobalFontMap(void);
99
100 private:
101 QMap<QString, MythFontProperties> m_fontMap;
102};
103
105
106
107// FIXME: remove legacy crap
108struct fontProp {
109 QFont face;
111 QColor color;
112 QColor dropColor;
113};
114extern MUI_PUBLIC QMap<QString, fontProp> globalFontMap;
115
116#endif
#define Clear(a)
QMap< QString, MythFontProperties > m_fontMap
FontMap()=default
QBrush GetBrush(void) const
bool hasOutline(void) const
bool hasShadow(void) const
QColor color(void) const
static QMutex s_zoomLock
void SetRelativeSize(float rSize)
QString GetHash(void) const
float GetRelativeSize(void) const
The base class on which all widgets and screens are based.
Definition: mythuitype.h:86
unsigned int uint
Definition: freesurround.h:24
MUI_PUBLIC FontMap * GetGlobalFontMap(void)
MUI_PUBLIC QMap< QString, fontProp > globalFontMap
#define MUI_PUBLIC
Definition: mythuiexp.h:9
QPoint shadowOffset