OpenCPN Partial API docs
Loading...
Searching...
No Matches
font_mgr.h
Go to the documentation of this file.
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, see <https://www.gnu.org/licenses/>. *
16 **************************************************************************/
17
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
31
32#include <wx/colour.h>
33#include <wx/font.h>
34#include <wx/string.h>
35
36#include "font_desc.h"
37#include "font_mgr.h"
38
39class OCPNwxFontList; // forward, in font_mgr.cpp
40
46class FontMgr {
47public:
48 static FontMgr &Get();
49
50 wxFont *GetFontLegacy(const wxString &TextElement, int user_default_size);
51
52 void SetLocale(wxString &newLocale);
53
77 wxFont *GetFont(const wxString &TextElement, int requested_font_size = 0);
78
88 wxColour GetFontColor(const wxString &TextElement) const;
89
101 wxColour GetDefaultFontColor(const wxString &TextElement);
102
113 bool SetFontColor(const wxString &TextElement, const wxColour color) const;
114
122 int GetNumFonts(void) const;
123
140 const wxString &GetConfigString(int i) const;
141
151 const wxString &GetDialogString(int i) const;
152
159 wxArrayString GetDialogStrings(const wxString &locale = wxEmptyString) const;
160
171 const wxString &GetNativeDesc(int i) const;
172
178 wxString GetFullConfigDesc(int i) const;
179
187 static wxString GetFontConfigKey(const wxString &description);
188
200 wxArrayString &GetAuxKeyArray() { return m_AuxKeyArray; }
201
211 bool AddAuxKey(wxString key);
212
229 void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc);
230
245 bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color);
246
253 void ScrubList();
254
261 MyFontDesc *FindFontByConfigString(wxString pConfigString);
262
279 wxFont *FindOrCreateFont(int point_size, wxFontFamily family,
280 wxFontStyle style, wxFontWeight weight,
281 bool underline = false,
282 const wxString &facename = wxEmptyString,
283 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
284 // For wxWidgets 2.8 compatability
285 wxFont *FindOrCreateFont(int pointSize, int family, int style, int weight,
286 bool underline = false,
287 const wxString &face = wxEmptyString,
288 wxFontEncoding encoding = wxFONTENCODING_DEFAULT) {
289 return FindOrCreateFont(pointSize, (wxFontFamily)family, (wxFontStyle)style,
290 (wxFontWeight)weight, underline, face, encoding);
291 }
292
305 bool ResetFontToDefault(const wxString &TextElement);
306
307 static void Shutdown();
308
309private: // private for singleton
310 FontMgr();
311 ~FontMgr();
312 FontMgr(const FontMgr &) {}
313 FontMgr &operator=(const FontMgr &) { return *this; }
314
333 wxString GetSimpleNativeFont(int size, wxString face);
334
348 bool IsDefaultFontEntry(const MyFontDesc *font_desc) const;
349
359 static int GetSystemFontSize();
369 static wxString GetSystemFontFaceName();
370
381 MyFontDesc *GetFontDesc(const wxString &TextElement) const;
382
383 static FontMgr *instance;
384
393 OCPNwxFontList *m_wxFontCache;
394
404 FontList *m_fontlist;
405
408 wxFont *pDefFont;
409
412 wxArrayString m_AuxKeyArray;
413};
414
415#endif
Manage the font list.
Definition font_mgr.h:46
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 font_mgr.cpp:449
wxString GetFullConfigDesc(int i) const
Gets description of font at index i.
Definition font_mgr.cpp:367
wxColour GetFontColor(const wxString &TextElement) const
Gets the text color for a UI element.
Definition font_mgr.cpp:117
bool AddAuxKey(wxString key)
Adds new plugin-defined font configuration key.
Definition font_mgr.cpp:660
bool ResetFontToDefault(const wxString &TextElement)
Resets the font configuration for a UI element back to system defaults.
Definition font_mgr.cpp:668
void LoadFontNative(wxString *pConfigString, wxString *pNativeDesc)
Loads font settings from a string descriptor.
Definition font_mgr.cpp:394
bool SetFontColor(const wxString &TextElement, const wxColour color) const
Sets the text color for a UI element.
Definition font_mgr.cpp:122
static wxString GetFontConfigKey(const wxString &description)
Creates configuration key from UI element name by combining locale with hash.
Definition font_mgr.cpp:132
bool SetFont(const wxString &TextElement, wxFont *pFont, wxColour color)
Sets the default font properties for a UI element.
Definition font_mgr.cpp:309
int GetNumFonts(void) const
Gets the total number of font configurations currently loaded.
Definition font_mgr.cpp:329
wxColour GetDefaultFontColor(const wxString &TextElement)
Gets the default text color for a UI element.
Definition font_mgr.cpp:269
void ScrubList()
Cleans up stale font entries after a locale change.
Definition font_mgr.cpp:564
wxArrayString GetDialogStrings(const wxString &locale=wxEmptyString) const
Gets the list of unique dialog strings.
Definition font_mgr.cpp:343
MyFontDesc * FindFontByConfigString(wxString pConfigString)
Finds font descriptor by its configuration key.
Definition font_mgr.cpp:383
const wxString & GetNativeDesc(int i) const
Gets the native font descriptor string for the font at index i.
Definition font_mgr.cpp:361
const wxString & GetConfigString(int i) const
Gets the locale-specific configuration key for a font at index i.
Definition font_mgr.cpp:331
wxArrayString & GetAuxKeyArray()
Gets array of plugin-defined font configuration keys.
Definition font_mgr.h:200
wxFont * GetFont(const wxString &TextElement, int requested_font_size=0)
Get a font object for a UI element.
Definition font_mgr.cpp:200
const wxString & GetDialogString(int i) const
Gets the UI element identifier string for the font at index i.
Definition font_mgr.cpp:337
Font description container.
Font list manager.