]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: fontmap.h | |
e54c96f1 | 3 | // Purpose: interface of wxFontMapper |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxFontMapper | |
7c913512 | 11 | |
23324ae1 FM |
12 | wxFontMapper manages user-definable correspondence between logical font |
13 | names and the fonts present on the machine. | |
7c913512 | 14 | |
23324ae1 FM |
15 | The default implementations of all functions will ask the user if they are |
16 | not capable of finding the answer themselves and store the answer in a | |
17 | config file (configurable via SetConfigXXX functions). This behaviour may | |
18 | be disabled by giving the value of @false to "interactive" parameter. | |
7c913512 | 19 | |
23324ae1 FM |
20 | However, the functions will always consult the config file to allow the |
21 | user-defined values override the default logic and there is no way to | |
22 | disable this - which shouldn't be ever needed because if "interactive" was | |
23 | never @true, the config file is never created anyhow. | |
7c913512 | 24 | |
23324ae1 | 25 | In case everything else fails (i.e. there is no record in config file |
7c913512 FM |
26 | and "interactive" is @false or user denied to choose any replacement), |
27 | the class queries wxEncodingConverter | |
23324ae1 | 28 | for "equivalent" encodings (e.g. iso8859-2 and cp1250) and tries them. |
7c913512 | 29 | |
23324ae1 FM |
30 | @library{wxcore} |
31 | @category{misc} | |
7c913512 | 32 | |
e54c96f1 | 33 | @see wxEncodingConverter, @ref overview_nonenglishoverview "Writing non-English |
23324ae1 FM |
34 | applications" |
35 | */ | |
7c913512 | 36 | class wxFontMapper |
23324ae1 FM |
37 | { |
38 | public: | |
39 | /** | |
40 | Default ctor. | |
41 | */ | |
42 | wxFontMapper(); | |
43 | ||
44 | /** | |
45 | Virtual dtor for a base class. | |
46 | */ | |
47 | ~wxFontMapper(); | |
48 | ||
49 | /** | |
50 | Returns the encoding for the given charset (in the form of RFC 2046) or | |
51 | @c wxFONTENCODING_SYSTEM if couldn't decode it. | |
4cc4bfaf | 52 | Be careful when using this function with @a interactive set to @true |
23324ae1 FM |
53 | (default value) as the function then may show a dialog box to the user which |
54 | may lead to unexpected reentrancies and may also take a significantly longer | |
55 | time than a simple function call. For these reasons, it is almost always a bad | |
56 | idea to call this function from the event handlers for repeatedly generated | |
57 | events such as @c EVT_PAINT. | |
58 | */ | |
59 | wxFontEncoding CharsetToEncoding(const wxString& charset, | |
4cc4bfaf | 60 | bool interactive = true); |
23324ae1 FM |
61 | |
62 | /** | |
63 | Get the current font mapper object. If there is no current object, creates | |
64 | one. | |
3c4f71cc | 65 | |
4cc4bfaf | 66 | @see Set() |
23324ae1 | 67 | */ |
4cc4bfaf | 68 | static wxFontMapper* Get(); |
23324ae1 FM |
69 | |
70 | /** | |
71 | Returns the array of all possible names for the given encoding. The array is | |
72 | @NULL-terminated. IF it isn't empty, the first name in it is the canonical | |
7c913512 | 73 | encoding name, i.e. the same string as returned by |
23324ae1 FM |
74 | GetEncodingName(). |
75 | */ | |
76 | static const wxChar** GetAllEncodingNames(wxFontEncoding encoding); | |
77 | ||
78 | //@{ | |
79 | /** | |
80 | Find an alternative for the given encoding (which is supposed to not be | |
81 | available on this system). If successful, return @true and fill info | |
82 | structure with the parameters required to create the font, otherwise | |
83 | return @false. | |
23324ae1 FM |
84 | The first form is for wxWidgets' internal use while the second one |
85 | is better suitable for general use -- it returns wxFontEncoding which | |
86 | can consequently be passed to wxFont constructor. | |
87 | */ | |
88 | bool GetAltForEncoding(wxFontEncoding encoding, | |
89 | wxNativeEncodingInfo* info, | |
90 | const wxString& facename = wxEmptyString, | |
4cc4bfaf | 91 | bool interactive = true); |
7c913512 FM |
92 | bool GetAltForEncoding(wxFontEncoding encoding, |
93 | wxFontEncoding* alt_encoding, | |
94 | const wxString& facename = wxEmptyString, | |
4cc4bfaf | 95 | bool interactive = true); |
23324ae1 FM |
96 | //@} |
97 | ||
98 | /** | |
7c913512 FM |
99 | Returns the @e n-th supported encoding. Together with |
100 | GetSupportedEncodingsCount() | |
23324ae1 FM |
101 | this method may be used to get all supported encodings. |
102 | */ | |
103 | static wxFontEncoding GetEncoding(size_t n); | |
104 | ||
105 | /** | |
106 | Return user-readable string describing the given encoding. | |
107 | */ | |
108 | static wxString GetEncodingDescription(wxFontEncoding encoding); | |
109 | ||
110 | /** | |
111 | Return the encoding corresponding to the given internal name. This function is | |
112 | the inverse of GetEncodingName() and is | |
7c913512 | 113 | intentionally less general than |
23324ae1 FM |
114 | CharsetToEncoding(), i.e. it doesn't |
115 | try to make any guesses nor ever asks the user. It is meant just as a way of | |
7c913512 | 116 | restoring objects previously serialized using |
23324ae1 FM |
117 | GetEncodingName(). |
118 | */ | |
119 | static wxFontEncoding GetEncodingFromName(const wxString& encoding); | |
120 | ||
121 | /** | |
7c913512 | 122 | Return internal string identifier for the encoding (see also |
23324ae1 | 123 | wxFontMapper::GetEncodingDescription) |
3c4f71cc | 124 | |
4cc4bfaf | 125 | @see GetEncodingFromName() |
23324ae1 FM |
126 | */ |
127 | static wxString GetEncodingName(wxFontEncoding encoding); | |
128 | ||
129 | /** | |
7c913512 | 130 | Returns the number of the font encodings supported by this class. Together with |
23324ae1 FM |
131 | GetEncoding() this method may be used to get |
132 | all supported encodings. | |
133 | */ | |
134 | static size_t GetSupportedEncodingsCount(); | |
135 | ||
136 | /** | |
137 | Check whether given encoding is available in given face or not. | |
138 | If no facename is given, find @e any font in this encoding. | |
139 | */ | |
140 | bool IsEncodingAvailable(wxFontEncoding encoding, | |
141 | const wxString& facename = wxEmptyString); | |
142 | ||
143 | /** | |
144 | Set the current font mapper object and return previous one (may be @NULL). | |
145 | This method is only useful if you want to plug-in an alternative font mapper | |
146 | into wxWidgets. | |
3c4f71cc | 147 | |
4cc4bfaf | 148 | @see Get() |
23324ae1 | 149 | */ |
4cc4bfaf | 150 | static wxFontMapper* Set(wxFontMapper* mapper); |
23324ae1 FM |
151 | |
152 | /** | |
153 | Set the config object to use (may be @NULL to use default). | |
7c913512 | 154 | By default, the global one (from wxConfigBase::Get() will be used) |
23324ae1 FM |
155 | and the default root path for the config settings is the string returned by |
156 | GetDefaultConfigPath(). | |
157 | */ | |
158 | void SetConfig(wxConfigBase* config); | |
159 | ||
160 | /** | |
161 | Set the root config path to use (should be an absolute path). | |
162 | */ | |
163 | void SetConfigPath(const wxString& prefix); | |
164 | ||
165 | /** | |
166 | The parent window for modal dialogs. | |
167 | */ | |
168 | void SetDialogParent(wxWindow* parent); | |
169 | ||
170 | /** | |
171 | The title for the dialogs (note that default is quite reasonable). | |
172 | */ | |
173 | void SetDialogTitle(const wxString& title); | |
174 | }; | |
e54c96f1 | 175 |