]>
Commit | Line | Data |
---|---|---|
04a4a2af VS |
1 | % |
2 | % automatically generated by HelpGen from | |
3 | % fontmap.h at 10/Mar/00 23:54:16 | |
4 | % | |
775a998e VZ |
5 | |
6 | \section{\class{wxFontMapper}}\label{wxfontmapper} | |
7 | ||
04a4a2af VS |
8 | wxFontMapper manages user-definable correspondence between logical font |
9 | names and the fonts present on the machine. | |
10 | ||
11 | The default implementations of all functions will ask the user if they are | |
12 | not capable of finding the answer themselves and store the answer in a | |
13 | config file (configurable via SetConfigXXX functions). This behaviour may | |
cc81d32f | 14 | be disabled by giving the value of false to "interactive" parameter. |
04a4a2af VS |
15 | |
16 | However, the functions will always consult the config file to allow the | |
17 | user-defined values override the default logic and there is no way to | |
18 | disable this - which shouldn't be ever needed because if "interactive" was | |
cc81d32f | 19 | never true, the config file is never created anyhow. |
04a4a2af VS |
20 | |
21 | In case everything else fails (i.e. there is no record in config file | |
cc81d32f | 22 | and "interactive" is false or user denied to choose any replacement), |
fa482912 | 23 | the class queries \helpref{wxEncodingConverter}{wxencodingconverter} |
04a4a2af VS |
24 | for "equivalent" encodings (e.g. iso8859-2 and cp1250) and tries them. |
25 | ||
a663cce7 | 26 | \wxheading{Using wxFontMapper in conjunction with wxMBConv classes} |
04a4a2af VS |
27 | |
28 | If you need to display text in encoding which is not available at | |
29 | host system (see \helpref{IsEncodingAvailable}{wxfontmapperisencodingavailable}), | |
dccce9ea | 30 | you may use these two classes to find font in some similar encoding |
04a4a2af | 31 | (see \helpref{GetAltForEncoding}{wxfontmappergetaltforencoding}) |
dccce9ea | 32 | and convert the text to this encoding |
a663cce7 | 33 | (\helpref{wxMBConv classes}{mbconvclasses}). |
04a4a2af VS |
34 | |
35 | Following code snippet demonstrates it: | |
36 | ||
37 | \begin{verbatim} | |
142b3bc2 | 38 | if (!wxFontMapper::Get()->IsEncodingAvailable(enc, facename)) |
04a4a2af VS |
39 | { |
40 | wxFontEncoding alternative; | |
142b3bc2 | 41 | if (wxFontMapper::Get()->GetAltForEncoding(enc, &alternative, |
cc81d32f | 42 | facename, false)) |
04a4a2af | 43 | { |
a663cce7 VS |
44 | wxCSConv convFrom(wxFontMapper::Get()->GetEncodingName(enc)); |
45 | wxCSConv convTo(wxFontMapper::Get()->GetEncodingName(alternative)); | |
46 | text = wxString(text.mb_str(convFrom), convTo); | |
04a4a2af VS |
47 | } |
48 | else | |
49 | ...failure (or we may try iso8859-1/7bit ASCII)... | |
50 | } | |
51 | ...display text... | |
52 | \end{verbatim} | |
53 | ||
54 | ||
55 | \wxheading{Derived from} | |
56 | ||
57 | No base class | |
58 | ||
59 | \wxheading{Include files} | |
60 | ||
61 | <wx/fontmap.h> | |
62 | ||
a7af285d VZ |
63 | \wxheading{Library} |
64 | ||
65 | \helpref{wxCore}{librarieslist} | |
66 | ||
04a4a2af VS |
67 | \wxheading{See also} |
68 | ||
69 | \helpref{wxEncodingConverter}{wxencodingconverter}, | |
70 | \helpref{Writing non-English applications}{nonenglishoverview} | |
71 | ||
04a4a2af VS |
72 | \latexignore{\rtfignore{\wxheading{Members}}} |
73 | ||
910b9fc5 | 74 | |
04a4a2af VS |
75 | \membersection{wxFontMapper::wxFontMapper}\label{wxfontmapperwxfontmapper} |
76 | ||
77 | \func{}{wxFontMapper}{\void} | |
78 | ||
79 | Default ctor. | |
80 | ||
142b3bc2 VS |
81 | \wxheading{Note} |
82 | ||
83 | The preferred way of creating a wxFontMapper instance is to call | |
84 | \helpref{wxFontMapper::Get}{wxfontmapperget}. | |
85 | ||
910b9fc5 | 86 | |
04a4a2af VS |
87 | \membersection{wxFontMapper::\destruct{wxFontMapper}}\label{wxfontmapperdtor} |
88 | ||
89 | \func{}{\destruct{wxFontMapper}}{\void} | |
90 | ||
91 | Virtual dtor for a base class. | |
92 | ||
910b9fc5 VZ |
93 | |
94 | \membersection{wxFontMapper::CharsetToEncoding}\label{wxfontmappercharsettoencoding} | |
95 | ||
96 | \func{wxFontEncoding}{CharsetToEncoding}{\param{const wxString\& }{charset}, \param{bool }{interactive = true}} | |
97 | ||
98 | Returns the encoding for the given charset (in the form of RFC 2046) or | |
99 | \texttt{wxFONTENCODING\_SYSTEM} if couldn't decode it. | |
100 | ||
101 | Be careful when using this function with \arg{interactive} set to \true | |
102 | (default value) as the function then may show a dialog box to the user which | |
103 | may lead to unexpected reentrancies and may also take a significantly longer | |
104 | time than a simple function call. For these reasons, it is almost always a bad | |
105 | idea to call this function from the event handlers for repeatedly generated | |
106 | events such as \texttt{EVT\_PAINT}. | |
107 | ||
108 | ||
142b3bc2 VS |
109 | \membersection{wxFontMapper::Get}\label{wxfontmapperget} |
110 | ||
111 | \func{static wxFontMapper *}{Get}{\void} | |
112 | ||
113 | Get the current font mapper object. If there is no current object, creates | |
114 | one. | |
115 | ||
116 | \wxheading{See also} | |
117 | ||
118 | \helpref{wxFontMapper::Set}{wxfontmapperset} | |
119 | ||
910b9fc5 | 120 | |
f69e752c | 121 | \membersection{wxFontMapper::GetAllEncodingNames}\label{wxfontmappergetallencodingnames} |
fa4bc07c VZ |
122 | |
123 | \func{static const wxChar**}{GetAllEncodingNames}{\param{wxFontEncoding }{encoding}} | |
124 | ||
125 | Returns the array of all possible names for the given encoding. The array is | |
126 | \NULL-terminated. IF it isn't empty, the first name in it is the canonical | |
127 | encoding name, i.e. the same string as returned by | |
128 | \helpref{GetEncodingName()}{wxfontmappergetencodingname}. | |
129 | ||
130 | ||
04a4a2af VS |
131 | \membersection{wxFontMapper::GetAltForEncoding}\label{wxfontmappergetaltforencoding} |
132 | ||
cc81d32f | 133 | \func{bool}{GetAltForEncoding}{\param{wxFontEncoding }{encoding}, \param{wxNativeEncodingInfo* }{info}, \param{const wxString\& }{facename = wxEmptyString}, \param{bool }{interactive = true}} |
04a4a2af | 134 | |
cc81d32f | 135 | \func{bool}{GetAltForEncoding}{\param{wxFontEncoding }{encoding}, \param{wxFontEncoding* }{alt\_encoding}, \param{const wxString\& }{facename = wxEmptyString}, \param{bool }{interactive = true}} |
04a4a2af VS |
136 | |
137 | Find an alternative for the given encoding (which is supposed to not be | |
cc81d32f | 138 | available on this system). If successful, return true and fill info |
04a4a2af | 139 | structure with the parameters required to create the font, otherwise |
cc81d32f | 140 | return false. |
04a4a2af | 141 | |
fc2171bd | 142 | The first form is for wxWidgets' internal use while the second one |
04a4a2af VS |
143 | is better suitable for general use -- it returns wxFontEncoding which |
144 | can consequently be passed to wxFont constructor. | |
145 | ||
04a4a2af | 146 | |
bf43ff9a VZ |
147 | \membersection{wxFontMapper::GetEncoding}\label{wxfontmappergetencoding} |
148 | ||
149 | \func{static wxFontEncoding}{GetEncoding}{\param{size\_t }{n}} | |
150 | ||
151 | Returns the {\it n}-th supported encoding. Together with | |
152 | \helpref{GetSupportedEncodingsCount()}{wxfontmappergetsupportedencodingscount} | |
153 | this method may be used to get all supported encodings. | |
154 | ||
155 | ||
910b9fc5 VZ |
156 | \membersection{wxFontMapper::GetEncodingDescription}\label{wxfontmappergetencodingdescription} |
157 | ||
158 | \func{static wxString}{GetEncodingDescription}{\param{wxFontEncoding }{encoding}} | |
159 | ||
160 | Return user-readable string describing the given encoding. | |
161 | ||
162 | ||
163 | \membersection{wxFontMapper::GetEncodingFromName}\label{wxfontmappergetencodingfromname} | |
164 | ||
165 | \func{static wxFontEncoding}{GetEncodingFromName}{\param{const wxString\& }{encoding}} | |
166 | ||
167 | Return the encoding corresponding to the given internal name. This function is | |
168 | the inverse of \helpref{GetEncodingName}{wxfontmappergetencodingname} and is | |
169 | intentionally less general than | |
170 | \helpref{CharsetToEncoding}{wxfontmappercharsettoencoding}, i.e. it doesn't | |
171 | try to make any guesses nor ever asks the user. It is meant just as a way of | |
172 | restoring objects previously serialized using | |
173 | \helpref{GetEncodingName}{wxfontmappergetencodingname}. | |
174 | ||
175 | ||
04a4a2af VS |
176 | \membersection{wxFontMapper::GetEncodingName}\label{wxfontmappergetencodingname} |
177 | ||
178 | \func{static wxString}{GetEncodingName}{\param{wxFontEncoding }{encoding}} | |
179 | ||
fa482912 | 180 | Return internal string identifier for the encoding (see also |
04a4a2af VS |
181 | \helpref{GetEncodingDescription()}{wxfontmappergetencodingdescription}) |
182 | ||
910b9fc5 | 183 | \wxheading{See also} |
04a4a2af | 184 | |
910b9fc5 | 185 | \helpref{GetEncodingFromName}{wxfontmappergetencodingfromname} |
04a4a2af | 186 | |
04a4a2af | 187 | |
bf43ff9a VZ |
188 | \membersection{wxFontMapper::GetSupportedEncodingsCount}\label{wxfontmappergetsupportedencodingscount} |
189 | ||
190 | \func{static size\_t}{GetSupportedEncodingsCount}{\void} | |
191 | ||
192 | Returns the number of the font encodings supported by this class. Together with | |
193 | \helpref{GetEncoding}{wxfontmappergetencoding} this method may be used to get | |
194 | all supported encodings. | |
195 | ||
196 | ||
910b9fc5 VZ |
197 | \membersection{wxFontMapper::IsEncodingAvailable}\label{wxfontmapperisencodingavailable} |
198 | ||
199 | \func{bool}{IsEncodingAvailable}{\param{wxFontEncoding }{encoding}, \param{const wxString\& }{facename = wxEmptyString}} | |
200 | ||
201 | Check whether given encoding is available in given face or not. | |
202 | If no facename is given, find {\it any} font in this encoding. | |
203 | ||
204 | ||
04a4a2af VS |
205 | \membersection{wxFontMapper::SetDialogParent}\label{wxfontmappersetdialogparent} |
206 | ||
207 | \func{void}{SetDialogParent}{\param{wxWindow* }{parent}} | |
208 | ||
209 | The parent window for modal dialogs. | |
210 | ||
910b9fc5 | 211 | |
04a4a2af VS |
212 | \membersection{wxFontMapper::SetDialogTitle}\label{wxfontmappersetdialogtitle} |
213 | ||
214 | \func{void}{SetDialogTitle}{\param{const wxString\& }{title}} | |
215 | ||
216 | The title for the dialogs (note that default is quite reasonable). | |
217 | ||
910b9fc5 | 218 | |
142b3bc2 VS |
219 | \membersection{wxFontMapper::Set}\label{wxfontmapperset} |
220 | ||
221 | \func{static wxFontMapper *}{Set}{\param{wxFontMapper *}{mapper}} | |
222 | ||
223 | Set the current font mapper object and return previous one (may be NULL). | |
224 | This method is only useful if you want to plug-in an alternative font mapper | |
fc2171bd | 225 | into wxWidgets. |
142b3bc2 VS |
226 | |
227 | \wxheading{See also} | |
228 | ||
229 | \helpref{wxFontMapper::Get}{wxfontmapperget} | |
230 | ||
910b9fc5 | 231 | |
04a4a2af VS |
232 | \membersection{wxFontMapper::SetConfig}\label{wxfontmappersetconfig} |
233 | ||
234 | \func{void}{SetConfig}{\param{wxConfigBase* }{config}} | |
235 | ||
236 | Set the config object to use (may be NULL to use default). | |
237 | ||
238 | By default, the global one (from wxConfigBase::Get() will be used) | |
239 | and the default root path for the config settings is the string returned by | |
240 | GetDefaultConfigPath(). | |
241 | ||
910b9fc5 | 242 | |
04a4a2af VS |
243 | \membersection{wxFontMapper::SetConfigPath}\label{wxfontmappersetconfigpath} |
244 | ||
245 | \func{void}{SetConfigPath}{\param{const wxString\& }{prefix}} | |
246 | ||
247 | Set the root config path to use (should be an absolute path). | |
cd77c085 | 248 |