]> git.saurik.com Git - wxWidgets.git/blob - include/wx/fontmap.h
1. more warnings fixes in gtk/region.cpp and common/tbarsmpl.cpp
[wxWidgets.git] / include / wx / fontmap.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/fontmap.h
3 // Purpose: wxFontMapper class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 04.11.99
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_FONTMAPPER_H_
13 #define _WX_FONTMAPPER_H_
14
15 #ifdef __GNUG__
16 #pragma interface "fontmap.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // headers
21 // ----------------------------------------------------------------------------
22
23 #include "wx/font.h" // for wxFont and wxFontEncoding
24 #include "wx/fontutil.h" // for wxNativeEncodingInfo
25
26 class WXDLLEXPORT wxConfigBase;
27 class WXDLLEXPORT wxWindow;
28
29 // ----------------------------------------------------------------------------
30 // wxFontMapper manages user-definable correspondence between logical font
31 // names and the fonts present on the machine.
32 //
33 // The default implementations of all functions will ask the user if they are
34 // not capable of finding the answer themselves and store the answer in a
35 // config file (configurable via SetConfigXXX functions). This behaviour may
36 // be disabled by giving the value of FALSE to "interactive" parameter.
37 // However, the functions will always consult the config file to allow the
38 // user-defined values override the default logic and there is no way to
39 // disable this - which shouldn't be ever needed because if "interactive" was
40 // never TRUE, the config file is never created anyhow.
41 // ----------------------------------------------------------------------------
42
43 class WXDLLEXPORT wxFontMapper
44 {
45 public:
46 // default ctor
47 wxFontMapper();
48
49 // virtual dtor for a base class
50 virtual ~wxFontMapper();
51
52 // find an alternative for the given encoding (which is supposed to not be
53 // available on this system). If successful, return TRUE and fill info
54 // structure with the parameters required to create the font, otherwise
55 // return FALSE
56 virtual bool GetAltForEncoding(wxFontEncoding encoding,
57 wxNativeEncodingInfo *info,
58 bool interactive = TRUE);
59
60 // returns the encoding for the given charset (in the form of RFC 2046) or
61 // wxFONTENCODING_SYSTEM if couldn't decode it
62 virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
63 bool interactive = TRUE);
64
65 // encoding names
66 // --------------
67
68 // return internal string identifier for the encoding (see also
69 // GetEncodingDescription())
70 static wxString GetEncodingName(wxFontEncoding encoding);
71
72 // return user-readable string describing the given encoding
73 //
74 // NB: hard-coded now, but might change later (read it from config?)
75 static wxString GetEncodingDescription(wxFontEncoding encoding);
76
77 // configure the appearance of the dialogs we may popup
78 // ----------------------------------------------------
79
80 // the parent window for modal dialogs
81 void SetDialogParent(wxWindow *parent) { m_windowParent = parent; }
82
83 // the title for the dialogs (note that default is quite reasonable)
84 void SetDialogTitle(const wxString& title) { m_titleDialog = title; }
85
86 // functions which allow to configure the config object used: by default,
87 // the global one (from wxConfigBase::Get() will be used) and the default
88 // root path for the config settings is the string returned by
89 // GetDefaultConfigPath()
90 // ----------------------------------------------------------------------
91
92 // set the config object to use (may be NULL to use default)
93 void SetConfig(wxConfigBase *config) { m_config = config; }
94
95 // set the root config path to use (should be an absolute path)
96 void SetConfigPath(const wxString& prefix);
97
98 // return default config path
99 static const wxChar *GetDefaultConfigPath();
100
101 protected:
102 // get the config object we're using - if it wasn't set explicitly, this
103 // function will use wxConfig::Get() to get the global one
104 wxConfigBase *GetConfig();
105
106 // gets the root path for our settings - if itwasn't set explicitly, use
107 // GetDefaultConfigPath()
108 const wxString& GetConfigPath();
109
110 // change to the given (relative) path in the config, return TRUE if ok
111 // (then GetConfig() will return something !NULL), FALSE if no config
112 // object
113 //
114 // caller should provide a pointer to the string variable which should be
115 // later passed to RestorePath()
116 bool ChangePath(const wxString& pathNew, wxString *pathOld);
117
118 // restore the config path after use
119 void RestorePath(const wxString& pathOld);
120
121 // GetAltForEncoding() helper: tests for the existence of the given
122 // encoding and saves the result in config if ok - this results in the
123 // following (desired) behaviour: when an unknown/unavailable encoding is
124 // requested for the first time, the user is asked about a replacement,
125 // but if he doesn't choose any and the default logic finds one, it will
126 // be saved in the config so that the user won't be asked about it any
127 // more
128 bool TestAltEncoding(const wxString& configEntry,
129 wxFontEncoding encReplacement,
130 wxNativeEncodingInfo *info);
131
132 // config object and path (in it) to use
133 wxConfigBase *m_config;
134 wxString m_configRootPath;
135
136 // the title for our dialogs
137 wxString m_titleDialog;
138
139 // the parent window for our dialogs
140 wxWindow *m_windowParent;
141
142 friend class wxFontMapperPathChanger;
143 };
144
145 // ----------------------------------------------------------------------------
146 // global variables
147 // ----------------------------------------------------------------------------
148
149 // the default font mapper for wxWindows programs
150 WXDLLEXPORT_DATA(extern wxFontMapper *) wxTheFontMapper;
151
152 #endif // _WX_FONTMAPPER_H_