00001 #ifndef MYTHFONTPROPERTIES_H_
00002 #define MYTHFONTPROPERTIES_H_
00003
00004 #include <qfont.h>
00005 #include <qcolor.h>
00006 #include <qpoint.h>
00007 #include <qmap.h>
00008
00009 #include "xmlparsebase.h"
00010
00011 class MythFontProperties: public XMLParseBase
00012 {
00013 public:
00014 MythFontProperties();
00015
00016 void SetFace(const QFont &face);
00017 void SetColor(const QColor &color);
00018 void SetShadow(bool on, const QPoint &offset, const QColor &color, int alpha);
00019 void SetOutline(bool on, const QColor &color, int size, int alpha);
00020
00021 QFont face(void) const { return m_face; }
00022 QColor color(void) const { return m_color; }
00023
00024 bool hasShadow(void) const { return m_hasShadow; }
00025 void GetShadow(QPoint &offset, QColor &color, int &alpha) const;
00026
00027 bool hasOutline(void) const { return m_hasOutline; }
00028 void GetOutline(QColor &color, int &size, int &alpha) const;
00029
00030 QString GetHash(void) const { return m_hash; }
00031
00032 static MythFontProperties *ParseFromXml(QDomElement &element,
00033 bool addToGlobal = false);
00034
00035 private:
00036 void Freeze(void);
00037 void Unfreeze(void);
00038
00039 void CalcHash(void);
00040
00041 QFont m_face;
00042 QColor m_color;
00043
00044 bool m_hasShadow;
00045 QPoint m_shadowOffset;
00046 QColor m_shadowColor;
00047 int m_shadowAlpha;
00048
00049 bool m_hasOutline;
00050 QColor m_outlineColor;
00051 int m_outlineSize;
00052 int m_outlineAlpha;
00053
00054 QString m_hash;
00055
00056 bool m_bFreeze;
00057
00058 friend class FontMap;
00059 };
00060
00061 class FontMap
00062 {
00063 public:
00064 FontMap() {}
00065
00066 MythFontProperties *GetFont(const QString &text);
00067 bool AddFont(const QString &text, MythFontProperties *fontProp);
00068 bool Contains(const QString &text);
00069
00070 void Clear(void);
00071
00072 static FontMap *GetGlobalFontMap(void);
00073
00074 private:
00075 QMap<QString, MythFontProperties> m_FontMap;
00076 };
00077
00078 FontMap *GetGlobalFontMap(void);
00079
00080 #endif