00001 #ifndef MYTHFONTPROPERTIES_H_
00002 #define MYTHFONTPROPERTIES_H_
00003
00004 #include <QFont>
00005 #include <QColor>
00006 #include <QBrush>
00007 #include <QPoint>
00008 #include <QMap>
00009
00010 #include "xmlparsebase.h"
00011 #include "mythmainwindow.h"
00012
00013 class MUI_PUBLIC MythFontProperties: public XMLParseBase
00014 {
00015 public:
00016 MythFontProperties();
00017
00018 QFont* GetFace(void) { return &m_face; }
00019
00020 void SetFace(const QFont &face);
00021 void SetColor(const QColor &color);
00022 void SetShadow(bool on, const QPoint &offset, const QColor &color, int alpha);
00023 void SetOutline(bool on, const QColor &color, int size, int alpha);
00024
00025 QFont face(void) const { return m_face; }
00026 QColor color(void) const { return m_brush.color(); }
00027 QBrush GetBrush(void) const { return m_brush; }
00028
00029 bool hasShadow(void) const { return m_hasShadow; }
00030 void GetShadow(QPoint &offset, QColor &color, int &alpha) const;
00031
00032 bool hasOutline(void) const { return m_hasOutline; }
00033 void GetOutline(QColor &color, int &size, int &alpha) const;
00034
00035 QString GetHash(void) const { return m_hash; }
00036
00037 static MythFontProperties *ParseFromXml(
00038 const QString &filename, const QDomElement &element,
00039 MythUIType *parent = NULL, bool addToGlobal = false,
00040 bool showWarnings = true);
00041
00042 void GetOffset(QPoint &offset) const;
00043
00044 void SetRelativeSize(float rSize) { m_relativeSize = rSize; }
00045 float GetRelativeSize(void) const { return m_relativeSize; }
00046 void SetPixelSize(float size);
00047 void SetPointSize(uint size);
00048 void Rescale(void);
00049 void Rescale(int height);
00050 void AdjustStretch(int stretch);
00051
00052 private:
00053 void Freeze(void);
00054 void Unfreeze(void);
00055
00056 void CalcHash(void);
00057
00058 QFont m_face;
00059 QBrush m_brush;
00060
00061 bool m_hasShadow;
00062 QPoint m_shadowOffset;
00063 QColor m_shadowColor;
00064 int m_shadowAlpha;
00065
00066 bool m_hasOutline;
00067 QColor m_outlineColor;
00068 int m_outlineSize;
00069 int m_outlineAlpha;
00070
00071 QPoint m_drawingOffset;
00072
00073 float m_relativeSize;
00074
00075 QString m_hash;
00076
00077 bool m_bFreeze;
00078
00079 int m_stretch;
00080
00081 friend class FontMap;
00082 };
00083
00084 class MUI_PUBLIC FontMap
00085 {
00086 public:
00087 FontMap() {}
00088
00089 MythFontProperties *GetFont(const QString &text);
00090 bool AddFont(const QString &text, MythFontProperties *fontProp);
00091 bool Contains(const QString &text);
00092
00093 void Clear(void);
00094 void Rescale(int height = 0);
00095
00096 static FontMap *GetGlobalFontMap(void);
00097
00098 private:
00099 QMap<QString, MythFontProperties> m_FontMap;
00100 };
00101
00102 MUI_PUBLIC FontMap *GetGlobalFontMap(void);
00103
00104
00105
00106 struct fontProp {
00107 QFont face;
00108 QPoint shadowOffset;
00109 QColor color;
00110 QColor dropColor;
00111 };
00112 extern MUI_PUBLIC QMap<QString, fontProp> globalFontMap;
00113
00114 #endif