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:
16  MythFontProperties(void);
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};
64  QColor m_shadowColor;
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
108 struct fontProp {
109  QFont face;
110  QPoint shadowOffset;
111  QColor color;
112  QColor dropColor;
113 };
114 extern MUI_PUBLIC QMap<QString, fontProp> globalFontMap;
115 
116 #endif
MythFontProperties::m_shadowColor
QColor m_shadowColor
Definition: mythfontproperties.h:64
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
globalFontMap
MUI_PUBLIC QMap< QString, fontProp > globalFontMap
Definition: mythfontproperties.cpp:522
MythFontProperties::s_zoomPercent
static uint s_zoomPercent
Definition: mythfontproperties.h:81
XMLParseBase
Definition: xmlparsebase.h:23
MythFontProperties::GetFace
QFont * GetFace(void)
Definition: mythfontproperties.h:18
MythFontProperties::GetHash
QString GetHash(void) const
Definition: mythfontproperties.h:35
MythFontProperties::hasShadow
bool hasShadow(void) const
Definition: mythfontproperties.h:29
MythFontProperties::hasOutline
bool hasOutline(void) const
Definition: mythfontproperties.h:32
FontMap
Definition: mythfontproperties.h:86
MythFontProperties::m_face
QFont m_face
Definition: mythfontproperties.h:59
fontProp::face
QFont face
Definition: mythfontproperties.h:109
MythFontProperties
Definition: mythfontproperties.h:13
MythFontProperties::GetBrush
QBrush GetBrush(void) const
Definition: mythfontproperties.h:27
fontProp
Definition: mythfontproperties.h:108
MythFontProperties::GetRelativeSize
float GetRelativeSize(void) const
Definition: mythfontproperties.h:43
MythFontProperties::color
QColor color(void) const
Definition: mythfontproperties.h:26
xmlparsebase.h
GetGlobalFontMap
MUI_PUBLIC FontMap * GetGlobalFontMap(void)
Definition: mythfontproperties.cpp:601
MythFontProperties::m_hash
QString m_hash
Definition: mythfontproperties.h:74
MythFontProperties::SetRelativeSize
void SetRelativeSize(float rSize)
Definition: mythfontproperties.h:42
MythUIType
The base class on which all widgets and screens are based.
Definition: mythuitype.h:85
fontProp::color
QColor color
Definition: mythfontproperties.h:111
fontProp::dropColor
QColor dropColor
Definition: mythfontproperties.h:112
Clear
#define Clear(a)
Definition: audiooutputopensles.cpp:54
fontProp::shadowOffset
QPoint shadowOffset
Definition: mythfontproperties.h:110
FontMap::m_fontMap
QMap< QString, MythFontProperties > m_fontMap
Definition: mythfontproperties.h:101
build_compdb.filename
filename
Definition: build_compdb.py:21
MythFontProperties::m_shadowOffset
QPoint m_shadowOffset
Definition: mythfontproperties.h:63
MythFontProperties::s_zoomLock
static QMutex s_zoomLock
Definition: mythfontproperties.h:80
uint
unsigned int uint
Definition: freesurround.h:24
MythFontProperties::m_outlineColor
QColor m_outlineColor
Definition: mythfontproperties.h:68