OpenCPN Partial API docs
Loading...
Searching...
No Matches
FontMgr.h
1/***************************************************************************
2 * Copyright (C) 2013 by David S. Register *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 **************************************************************************/
19
20#ifndef __FONTMGR_H__
21#define __FONTMGR_H__
22
23#include <wx/wxprec.h>
24#ifndef WX_PRECOMP
25#include <wx/wx.h>
26#endif // precompiled headers
27
28#include "FontDesc.h"
29
30class OCPNwxFontList;
31
37class FontMgr {
38public:
39 static FontMgr &Get();
40
41 void SetLocale(wxString &newLocale);
61 wxFont *GetFont(const wxString &TextElement, int requested_font_size = 0);
71 wxColour GetFontColor(const wxString &TextElement) const;
83 wxColour GetDefaultFontColor(const wxString &TextElement);
94 bool SetFontColor(const wxString &TextElement, const wxColour color) const;
95
103 int GetNumFonts(void) const;
120 const wxString &GetConfigString(int i) const;
130 const wxString &GetDialogString(int i) const;
131
138 wxArrayString GetDialogStrings(const wxString &locale = wxEmptyString) const;
139
150 const wxString &GetNativeDesc(int i) const;
156 wxString GetFullConfigDesc(int i) const;
164 static wxString GetFontConfigKey(const wxString &description);
165
177 wxArrayString &GetAuxKeyArray() { return m_AuxKeyArray; }
187 bool AddAuxKey(wxString key);
188
205 void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc);
220 bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color);
227 void ScrubList();
234 MyFontDesc *FindFontByConfigString(wxString pConfigString);
235
252 wxFont *FindOrCreateFont(int point_size, wxFontFamily family,
253 wxFontStyle style, wxFontWeight weight,
254 bool underline = false,
255 const wxString &facename = wxEmptyString,
256 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
257 // For wxWidgets 2.8 compatability
258 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
259 bool underline = false,
260 const wxString &face = wxEmptyString,
261 wxFontEncoding encoding = wxFONTENCODING_DEFAULT) {
262 return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style,
263 (wxFontWeight)weight, underline, face, encoding);
264 }
265
278 bool ResetFontToDefault(const wxString &TextElement);
279
280 static void Shutdown();
281
282private: // private for singleton
283 FontMgr();
284 ~FontMgr();
285 FontMgr(const FontMgr &) {}
286 FontMgr &operator=(const FontMgr &) { return *this; }
287
306 wxString GetSimpleNativeFont(int size, wxString face);
307
321 bool IsDefaultFontEntry(const MyFontDesc *font_desc) const;
331 static int GetSystemFontSize();
341 static wxString GetSystemFontFaceName();
342
353 MyFontDesc *GetFontDesc(const wxString &TextElement) const;
354
355 static FontMgr *instance;
356
365 OCPNwxFontList *m_wxFontCache;
375 FontList *m_fontlist;
378 wxFont *pDefFont;
381 wxArrayString m_AuxKeyArray;
382};
383
384#endif
Manages the font list.
Definition FontMgr.h:37
wxFont * FindOrCreateFont(int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline=false, const wxString &facename=wxEmptyString, wxFontEncoding encoding=wxFONTENCODING_DEFAULT)
Creates or finds a matching font in the font cache.
Definition FontMgr.cpp:450
wxString GetFullConfigDesc(int i) const
Gets description of font at index i.
Definition FontMgr.cpp:362
wxColour GetFontColor(const wxString &TextElement) const
Gets the text color for a UI element.
Definition FontMgr.cpp:117
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
Definition FontMgr.cpp:668
bool ResetFontToDefault(const wxString &TextElement)
Resets the font configuration for a UI element back to system defaults.
Definition FontMgr.cpp:676
void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc)
Loads font settings from a string descriptor.
Definition FontMgr.cpp:392
bool SetFontColor(const wxString &TextElement, const wxColour color) const
Sets the text color for a UI element.
Definition FontMgr.cpp:122
static wxString GetFontConfigKey(const wxString &description)
Creates configuration key from UI element name by combining locale with hash.
Definition FontMgr.cpp:132
bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color)
Sets the default font properties for a UI element.
Definition FontMgr.cpp:305
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
Definition FontMgr.cpp:325
wxColour GetDefaultFontColor(const wxString &TextElement)
Gets the default text color for a UI element.
Definition FontMgr.cpp:265
void ScrubList()
Cleans up stale font entries after a locale change.
Definition FontMgr.cpp:565
wxArrayString GetDialogStrings(const wxString &locale=wxEmptyString) const
Gets the list of unique dialog strings.
Definition FontMgr.cpp:337
MyFontDesc * FindFontByConfigString(wxString pConfigString)
Finds font descriptor by its configuration key.
Definition FontMgr.cpp:376
const wxString & GetNativeDesc(int i) const
Gets the native font descriptor string for the font at index i.
Definition FontMgr.cpp:357
const wxString & GetConfigString(int i) const
Gets the locale-specific configuration key for a font at index i.
Definition FontMgr.cpp:327
wxArrayString & GetAuxKeyArray()
Gets array of plugin-defined font configuration keys.
Definition FontMgr.h:177
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Definition FontMgr.cpp:186
const wxString & GetDialogString(int i) const
Gets the UI element identifier string for the font at index i.
Definition FontMgr.cpp:332