OpenCPN Partial API docs
All Classes Namespaces Functions Variables Pages
FontMgr.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 *
5 ***************************************************************************
6 * Copyright (C) 2013 by David S. Register *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 **************************************************************************/
23
24#ifndef __FONTMGR_H__
25#define __FONTMGR_H__
26
27#include <wx/wxprec.h>
28#ifndef WX_PRECOMP
29#include <wx/wx.h>
30#endif // precompiled headers
31
32#include "FontDesc.h"
33
34class OCPNwxFontList;
35
41class FontMgr {
42public:
43 static FontMgr &Get();
44
45 void SetLocale(wxString &newLocale);
46 wxFont *GetFont(const wxString &TextElement, int default_size = 0);
47 wxColour GetFontColor(const wxString &TextElement) const;
48 wxColour GetDefaultFontColor( const wxString &TextElement );
49 bool SetFontColor(const wxString &TextElement, const wxColour color) const;
50
51 int GetNumFonts(void) const;
52 const wxString &GetConfigString(int i) const;
53 const wxString &GetDialogString(int i) const;
54 const wxString &GetNativeDesc(int i) const;
55 wxString GetFullConfigDesc(int i) const;
56 static wxString GetFontConfigKey(const wxString &description);
57
58 wxArrayString &GetAuxKeyArray() { return m_AuxKeyArray; }
59 bool AddAuxKey(wxString key);
60
61 void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc);
62 bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color);
63 void ScrubList();
64 MyFontDesc *FindFontByConfigString(wxString pConfigString);
65
66 wxFont *FindOrCreateFont(int point_size, wxFontFamily family,
67 wxFontStyle style, wxFontWeight weight,
68 bool underline = false,
69 const wxString &facename = wxEmptyString,
70 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
71 // For wxWidgets 2.8 compatability
72 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
73 bool underline = false,
74 const wxString &face = wxEmptyString,
75 wxFontEncoding encoding = wxFONTENCODING_DEFAULT) {
76 return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style,
77 (wxFontWeight)weight, underline, face, encoding);
78 }
79
80 static void Shutdown();
81
82private: // private for singleton
83 FontMgr();
84 ~FontMgr();
85 FontMgr(const FontMgr &) {}
86 FontMgr &operator=(const FontMgr &) { return *this; }
87
88private:
89 wxString GetSimpleNativeFont(int size, wxString face);
90
91 static FontMgr *instance;
92
93 OCPNwxFontList *m_wxFontCache;
94 FontList *m_fontlist;
95 wxFont *pDefFont;
96 wxArrayString m_AuxKeyArray;
97};
98
99#endif
Manages the font list.
Definition: FontMgr.h:41