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 wxFont *GetFontLegacy(const wxString &TextElement, int user_default_size);
42
43 void SetLocale(wxString &newLocale);
67 wxFont *GetFont(const wxString &TextElement, int requested_font_size = 0);
77 wxColour GetFontColor(const wxString &TextElement) const;
89 wxColour GetDefaultFontColor(const wxString &TextElement);
100 bool SetFontColor(const wxString &TextElement, const wxColour color) const;
101
109 int GetNumFonts(void) const;
126 const wxString &GetConfigString(int i) const;
136 const wxString &GetDialogString(int i) const;
137
144 wxArrayString GetDialogStrings(const wxString &locale = wxEmptyString) const;
145
156 const wxString &GetNativeDesc(int i) const;
162 wxString GetFullConfigDesc(int i) const;
170 static wxString GetFontConfigKey(const wxString &description);
171
183 wxArrayString &GetAuxKeyArray() { return m_AuxKeyArray; }
193 bool AddAuxKey(wxString key);
194
211 void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc);
226 bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color);
233 void ScrubList();
240 MyFontDesc *FindFontByConfigString(wxString pConfigString);
241
258 wxFont *FindOrCreateFont(int point_size, wxFontFamily family,
259 wxFontStyle style, wxFontWeight weight,
260 bool underline = false,
261 const wxString &facename = wxEmptyString,
262 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
263 // For wxWidgets 2.8 compatability
264 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
265 bool underline = false,
266 const wxString &face = wxEmptyString,
267 wxFontEncoding encoding = wxFONTENCODING_DEFAULT) {
268 return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style,
269 (wxFontWeight)weight, underline, face, encoding);
270 }
271
284 bool ResetFontToDefault(const wxString &TextElement);
285
286 static void Shutdown();
287
288private: // private for singleton
289 FontMgr();
290 ~FontMgr();
291 FontMgr(const FontMgr &) {}
292 FontMgr &operator=(const FontMgr &) { return *this; }
293
312 wxString GetSimpleNativeFont(int size, wxString face);
313
327 bool IsDefaultFontEntry(const MyFontDesc *font_desc) const;
337 static int GetSystemFontSize();
347 static wxString GetSystemFontFaceName();
348
359 MyFontDesc *GetFontDesc(const wxString &TextElement) const;
360
361 static FontMgr *instance;
362
371 OCPNwxFontList *m_wxFontCache;
381 FontList *m_fontlist;
384 wxFont *pDefFont;
387 wxArrayString m_AuxKeyArray;
388};
389
390#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:467
wxString GetFullConfigDesc(int i) const
Gets description of font at index i.
Definition FontMgr.cpp:379
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:684
bool ResetFontToDefault(const wxString &TextElement)
Resets the font configuration for a UI element back to system defaults.
Definition FontMgr.cpp:692
void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc)
Loads font settings from a string descriptor.
Definition FontMgr.cpp:409
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:322
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
Definition FontMgr.cpp:342
wxColour GetDefaultFontColor(const wxString &TextElement)
Gets the default text color for a UI element.
Definition FontMgr.cpp:282
void ScrubList()
Cleans up stale font entries after a locale change.
Definition FontMgr.cpp:582
wxArrayString GetDialogStrings(const wxString &locale=wxEmptyString) const
Gets the list of unique dialog strings.
Definition FontMgr.cpp:354
MyFontDesc * FindFontByConfigString(wxString pConfigString)
Finds font descriptor by its configuration key.
Definition FontMgr.cpp:393
const wxString & GetNativeDesc(int i) const
Gets the native font descriptor string for the font at index i.
Definition FontMgr.cpp:374
const wxString & GetConfigString(int i) const
Gets the locale-specific configuration key for a font at index i.
Definition FontMgr.cpp:344
wxArrayString & GetAuxKeyArray()
Gets array of plugin-defined font configuration keys.
Definition FontMgr.h:183
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Gets a font object for a UI element.
Definition FontMgr.cpp:203
const wxString & GetDialogString(int i) const
Gets the UI element identifier string for the font at index i.
Definition FontMgr.cpp:349