Fix keymap.
[vuplus_xbmc] / xbmc / guilib / GUIFontManager.h
1 /*!
2 \file GUIFontManager.h
3 \brief
4 */
5
6 #ifndef GUILIB_FONTMANAGER_H
7 #define GUILIB_FONTMANAGER_H
8
9 #pragma once
10
11 /*
12  *      Copyright (C) 2005-2013 Team XBMC
13  *      http://xbmc.org
14  *
15  *  This Program is free software; you can redistribute it and/or modify
16  *  it under the terms of the GNU General Public License as published by
17  *  the Free Software Foundation; either version 2, or (at your option)
18  *  any later version.
19  *
20  *  This Program is distributed in the hope that it will be useful,
21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  *  GNU General Public License for more details.
24  *
25  *  You should have received a copy of the GNU General Public License
26  *  along with XBMC; see the file COPYING.  If not, see
27  *  <http://www.gnu.org/licenses/>.
28  *
29  */
30
31 #include "GraphicContext.h"
32 #include "IMsgTargetCallback.h"
33 #include "utils/GlobalsHandling.h"
34
35 // Forward
36 class CGUIFont;
37 class CGUIFontTTFBase;
38 class CXBMCTinyXML;
39 class TiXmlNode;
40 class CSetting;
41
42 struct OrigFontInfo
43 {
44    int size;
45    float aspect;
46    CStdString fontFilePath;
47    CStdString fileName;
48    RESOLUTION_INFO sourceRes;
49    bool preserveAspect;
50    bool border;
51 };
52
53 /*!
54  \ingroup textures
55  \brief
56  */
57 class GUIFontManager : public IMsgTargetCallback
58 {
59 public:
60   GUIFontManager(void);
61   virtual ~GUIFontManager(void);
62
63   virtual bool OnMessage(CGUIMessage &message);
64
65   void Unload(const CStdString& strFontName);
66   void LoadFonts(const CStdString& strFontSet);
67   CGUIFont* LoadTTF(const CStdString& strFontName, const CStdString& strFilename, color_t textColor, color_t shadowColor, const int iSize, const int iStyle, bool border = false, float lineSpacing = 1.0f, float aspect = 1.0f, const RESOLUTION_INFO *res = NULL, bool preserveAspect = false);
68   CGUIFont* GetFont(const CStdString& strFontName, bool fallback = true);
69
70   /*! \brief return a default font
71    \param border whether the font should be a font with an outline
72    \return the font.  NULL if no default font can be found.
73    */
74   CGUIFont* GetDefaultFont(bool border = false);
75
76   void Clear();
77   void FreeFontFile(CGUIFontTTFBase *pFont);
78
79   bool IsFontSetUnicode() const { return m_fontsetUnicode; }
80   bool IsFontSetUnicode(const CStdString& strFontSet);
81   bool GetFirstFontSetUnicode(CStdString& strFontSet);
82
83   static void SettingOptionsFontsFiller(const CSetting *setting, std::vector< std::pair<std::string, std::string> > &list, std::string &current);
84
85 protected:
86   void ReloadTTFFonts();
87   static void RescaleFontSizeAndAspect(float *size, float *aspect, const RESOLUTION_INFO &sourceRes, bool preserveAspect);
88   void LoadFonts(const TiXmlNode* fontNode);
89   CGUIFontTTFBase* GetFontFile(const CStdString& strFontFile);
90   bool OpenFontFile(CXBMCTinyXML& xmlDoc);
91
92   std::vector<CGUIFont*> m_vecFonts;
93   std::vector<CGUIFontTTFBase*> m_vecFontFiles;
94   std::vector<OrigFontInfo> m_vecFontInfo;
95   bool m_fontsetUnicode;
96   RESOLUTION_INFO m_skinResolution;
97   bool m_canReload;
98 };
99
100 /*!
101  \ingroup textures
102  \brief
103  */
104 XBMC_GLOBAL_REF(GUIFontManager, g_fontManager);
105 #define g_fontManager XBMC_GLOBAL_USE(GUIFontManager)
106 #endif