]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: _font.i | |
3 | // Purpose: SWIG interface file for wxFont and related classes | |
4 | // | |
5 | // Author: Robin Dunn | |
6 | // | |
7 | // Created: 1-Apr-2002 | |
8 | // RCS-ID: $Id$ | |
9 | // Copyright: (c) 2002 by Total Control Software | |
10 | // Licence: wxWindows license | |
11 | ///////////////////////////////////////////////////////////////////////////// | |
12 | ||
13 | // Not a %module | |
14 | ||
15 | ||
16 | //--------------------------------------------------------------------------- | |
17 | ||
18 | %{ | |
19 | #include <wx/fontutil.h> | |
20 | #include <wx/fontmap.h> | |
21 | #include <wx/fontenum.h> | |
22 | %} | |
23 | ||
24 | //--------------------------------------------------------------------------- | |
25 | %newgroup | |
26 | ||
27 | ||
28 | enum wxFontFamily | |
29 | { | |
30 | wxFONTFAMILY_DEFAULT = wxDEFAULT, | |
31 | wxFONTFAMILY_DECORATIVE = wxDECORATIVE, | |
32 | wxFONTFAMILY_ROMAN = wxROMAN, | |
33 | wxFONTFAMILY_SCRIPT = wxSCRIPT, | |
34 | wxFONTFAMILY_SWISS = wxSWISS, | |
35 | wxFONTFAMILY_MODERN = wxMODERN, | |
36 | wxFONTFAMILY_TELETYPE = wxTELETYPE, | |
37 | wxFONTFAMILY_MAX, | |
38 | wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX | |
39 | }; | |
40 | ||
41 | // font styles | |
42 | enum wxFontStyle | |
43 | { | |
44 | wxFONTSTYLE_NORMAL = wxNORMAL, | |
45 | wxFONTSTYLE_ITALIC = wxITALIC, | |
46 | wxFONTSTYLE_SLANT = wxSLANT, | |
47 | wxFONTSTYLE_MAX | |
48 | }; | |
49 | ||
50 | // font weights | |
51 | enum wxFontWeight | |
52 | { | |
53 | wxFONTWEIGHT_NORMAL = wxNORMAL, | |
54 | wxFONTWEIGHT_LIGHT = wxLIGHT, | |
55 | wxFONTWEIGHT_BOLD = wxBOLD, | |
56 | wxFONTWEIGHT_MAX | |
57 | }; | |
58 | ||
59 | ||
60 | // the font flag bits for the new font ctor accepting one combined flags word | |
61 | enum | |
62 | { | |
63 | // no special flags: font with default weight/slant/anti-aliasing | |
293dc374 | 64 | wxFONTFLAG_DEFAULT, |
d14a1e28 RD |
65 | |
66 | // slant flags (default: no slant) | |
293dc374 RD |
67 | wxFONTFLAG_ITALIC, |
68 | wxFONTFLAG_SLANT, | |
d14a1e28 RD |
69 | |
70 | // weight flags (default: medium) | |
293dc374 RD |
71 | wxFONTFLAG_LIGHT, |
72 | wxFONTFLAG_BOLD, | |
d14a1e28 RD |
73 | |
74 | // anti-aliasing flag: force on or off (default: the current system default) | |
293dc374 RD |
75 | wxFONTFLAG_ANTIALIASED, |
76 | wxFONTFLAG_NOT_ANTIALIASED, | |
d14a1e28 RD |
77 | |
78 | // underlined/strikethrough flags (default: no lines) | |
293dc374 RD |
79 | wxFONTFLAG_UNDERLINED, |
80 | wxFONTFLAG_STRIKETHROUGH, | |
d14a1e28 RD |
81 | |
82 | // the mask of all currently used flags | |
293dc374 | 83 | wxFONTFLAG_MASK |
d14a1e28 RD |
84 | }; |
85 | ||
86 | ||
87 | // font encodings | |
88 | enum wxFontEncoding | |
89 | { | |
90 | wxFONTENCODING_SYSTEM = -1, // system default | |
91 | wxFONTENCODING_DEFAULT, // current default encoding | |
92 | ||
93 | // ISO8859 standard defines a number of single-byte charsets | |
94 | wxFONTENCODING_ISO8859_1, // West European (Latin1) | |
95 | wxFONTENCODING_ISO8859_2, // Central and East European (Latin2) | |
96 | wxFONTENCODING_ISO8859_3, // Esperanto (Latin3) | |
97 | wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4) | |
98 | wxFONTENCODING_ISO8859_5, // Cyrillic | |
99 | wxFONTENCODING_ISO8859_6, // Arabic | |
100 | wxFONTENCODING_ISO8859_7, // Greek | |
101 | wxFONTENCODING_ISO8859_8, // Hebrew | |
102 | wxFONTENCODING_ISO8859_9, // Turkish (Latin5) | |
103 | wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6) | |
104 | wxFONTENCODING_ISO8859_11, // Thai | |
105 | wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it | |
106 | // here anyhow to make all ISO8859 | |
107 | // consecutive numbers | |
108 | wxFONTENCODING_ISO8859_13, // Baltic (Latin7) | |
109 | wxFONTENCODING_ISO8859_14, // Latin8 | |
110 | wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro) | |
111 | wxFONTENCODING_ISO8859_MAX, | |
112 | ||
113 | // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html) | |
56e63286 RD |
114 | wxFONTENCODING_KOI8, // KOI8 Russian |
115 | wxFONTENCODING_KOI8_U, // KOI8 Ukrainian | |
d14a1e28 RD |
116 | wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866 |
117 | wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria | |
118 | ||
119 | // what would we do without Microsoft? They have their own encodings | |
120 | // for DOS | |
121 | wxFONTENCODING_CP437, // original MS-DOS codepage | |
122 | wxFONTENCODING_CP850, // CP437 merged with Latin1 | |
123 | wxFONTENCODING_CP852, // CP437 merged with Latin2 | |
124 | wxFONTENCODING_CP855, // another cyrillic encoding | |
125 | wxFONTENCODING_CP866, // and another one | |
126 | // and for Windows | |
127 | wxFONTENCODING_CP874, // WinThai | |
128 | wxFONTENCODING_CP932, // Japanese (shift-JIS) | |
129 | wxFONTENCODING_CP936, // Chinese simplified (GB) | |
130 | wxFONTENCODING_CP949, // Korean (Hangul charset) | |
131 | wxFONTENCODING_CP950, // Chinese (traditional - Big5) | |
132 | wxFONTENCODING_CP1250, // WinLatin2 | |
133 | wxFONTENCODING_CP1251, // WinCyrillic | |
134 | wxFONTENCODING_CP1252, // WinLatin1 | |
135 | wxFONTENCODING_CP1253, // WinGreek (8859-7) | |
136 | wxFONTENCODING_CP1254, // WinTurkish | |
137 | wxFONTENCODING_CP1255, // WinHebrew | |
138 | wxFONTENCODING_CP1256, // WinArabic | |
139 | wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7) | |
140 | wxFONTENCODING_CP12_MAX, | |
141 | ||
142 | wxFONTENCODING_UTF7, // UTF-7 Unicode encoding | |
143 | wxFONTENCODING_UTF8, // UTF-8 Unicode encoding | |
144 | wxFONTENCODING_EUC_JP, // Extended Unix Codepage for Japanese | |
145 | wxFONTENCODING_UTF16BE, // UTF-16 Big Endian Unicode encoding | |
146 | wxFONTENCODING_UTF16LE, // UTF-16 Little Endian Unicode encoding | |
147 | wxFONTENCODING_UTF32BE, // UTF-32 Big Endian Unicode encoding | |
148 | wxFONTENCODING_UTF32LE, // UTF-32 Little Endian Unicode encoding | |
149 | ||
9cca52ba | 150 | wxFONTENCODING_MACROMAN, // the standard mac encodings |
c5f01dea RD |
151 | wxFONTENCODING_MACJAPANESE, |
152 | wxFONTENCODING_MACCHINESETRAD, | |
153 | wxFONTENCODING_MACKOREAN, | |
154 | wxFONTENCODING_MACARABIC, | |
155 | wxFONTENCODING_MACHEBREW, | |
156 | wxFONTENCODING_MACGREEK, | |
157 | wxFONTENCODING_MACCYRILLIC, | |
158 | wxFONTENCODING_MACDEVANAGARI, | |
159 | wxFONTENCODING_MACGURMUKHI, | |
160 | wxFONTENCODING_MACGUJARATI, | |
161 | wxFONTENCODING_MACORIYA, | |
162 | wxFONTENCODING_MACBENGALI, | |
163 | wxFONTENCODING_MACTAMIL, | |
164 | wxFONTENCODING_MACTELUGU, | |
165 | wxFONTENCODING_MACKANNADA, | |
166 | wxFONTENCODING_MACMALAJALAM, | |
167 | wxFONTENCODING_MACSINHALESE, | |
168 | wxFONTENCODING_MACBURMESE, | |
169 | wxFONTENCODING_MACKHMER, | |
170 | wxFONTENCODING_MACTHAI, | |
171 | wxFONTENCODING_MACLAOTIAN, | |
172 | wxFONTENCODING_MACGEORGIAN, | |
173 | wxFONTENCODING_MACARMENIAN, | |
174 | wxFONTENCODING_MACCHINESESIMP, | |
175 | wxFONTENCODING_MACTIBETAN, | |
176 | wxFONTENCODING_MACMONGOLIAN, | |
177 | wxFONTENCODING_MACETHIOPIC, | |
178 | wxFONTENCODING_MACCENTRALEUR, | |
179 | wxFONTENCODING_MACVIATNAMESE, | |
180 | wxFONTENCODING_MACARABICEXT, | |
181 | wxFONTENCODING_MACSYMBOL, | |
182 | wxFONTENCODING_MACDINGBATS, | |
183 | wxFONTENCODING_MACTURKISH, | |
184 | wxFONTENCODING_MACCROATIAN, | |
185 | wxFONTENCODING_MACICELANDIC, | |
186 | wxFONTENCODING_MACROMANIAN, | |
187 | wxFONTENCODING_MACCELTIC, | |
188 | wxFONTENCODING_MACGAELIC, | |
189 | wxFONTENCODING_MACKEYBOARD, | |
9cca52ba RD |
190 | |
191 | wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN , | |
192 | wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD , | |
f0cd63d2 | 193 | |
d14a1e28 RD |
194 | wxFONTENCODING_MAX, // highest enumerated encoding value |
195 | ||
196 | ||
197 | // aliases for endian-dependent UTF encodings | |
198 | wxFONTENCODING_UTF16, // native UTF-16 | |
199 | wxFONTENCODING_UTF32, // native UTF-32 | |
200 | ||
201 | // alias for the native Unicode encoding on this platform | |
202 | // (this is used by wxEncodingConverter and wxUTFFile only for now) | |
203 | wxFONTENCODING_UNICODE = wxFONTENCODING_UTF16, | |
204 | ||
205 | // alternative names for Far Eastern encodings | |
206 | // Chinese | |
207 | wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese | |
208 | wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese | |
209 | ||
210 | // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html) | |
211 | wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932 // Shift JIS | |
212 | }; | |
213 | ||
214 | //--------------------------------------------------------------------------- | |
215 | %newgroup | |
216 | ||
217 | // wxNativeFontInfo is platform-specific font representation: this struct | |
218 | // should be considered as opaque font description only used by the native | |
219 | // functions, the user code can only get the objects of this type from | |
220 | // somewhere and pass it somewhere else (possibly save them somewhere using | |
221 | // ToString() and restore them using FromString()) | |
222 | struct wxNativeFontInfo | |
223 | { | |
224 | public: | |
225 | wxNativeFontInfo(); | |
226 | ~wxNativeFontInfo(); | |
227 | ||
228 | // reset to the default state | |
229 | void Init(); | |
230 | ||
231 | // init with the parameters of the given font | |
232 | void InitFromFont(const wxFont& font); | |
233 | ||
234 | // accessors and modifiers for the font elements | |
235 | int GetPointSize() const; | |
8674d3b5 | 236 | #ifdef __WXMSW__ |
c5f01dea | 237 | wxSize GetPixelSize() const; |
8674d3b5 | 238 | #endif |
d14a1e28 RD |
239 | wxFontStyle GetStyle() const; |
240 | wxFontWeight GetWeight() const; | |
241 | bool GetUnderlined() const; | |
242 | wxString GetFaceName() const; | |
243 | wxFontFamily GetFamily() const; | |
244 | wxFontEncoding GetEncoding() const; | |
245 | ||
246 | void SetPointSize(int pointsize); | |
8674d3b5 | 247 | #ifdef __WXMSW__ |
c5f01dea | 248 | void SetPixelSize(const wxSize& pixelSize); |
8674d3b5 | 249 | #endif |
d14a1e28 RD |
250 | void SetStyle(wxFontStyle style); |
251 | void SetWeight(wxFontWeight weight); | |
252 | void SetUnderlined(bool underlined); | |
d0e2ede0 | 253 | bool SetFaceName(wxString facename); |
d14a1e28 RD |
254 | void SetFamily(wxFontFamily family); |
255 | void SetEncoding(wxFontEncoding encoding); | |
256 | ||
d0e2ede0 RD |
257 | // TODO: |
258 | // // sets the first facename in the given array which is found | |
259 | // // to be valid. If no valid facename is given, sets the | |
260 | // // first valid facename returned by wxFontEnumerator::GetFacenames(). | |
261 | // // Does not return a bool since it cannot fail. | |
262 | // void SetFaceName(const wxArrayString &facenames); | |
263 | ||
264 | ||
d14a1e28 RD |
265 | // it is important to be able to serialize wxNativeFontInfo objects to be |
266 | // able to store them (in config file, for example) | |
267 | bool FromString(const wxString& s); | |
268 | wxString ToString() const; | |
269 | ||
270 | %extend { | |
271 | wxString __str__() { | |
272 | return self->ToString(); | |
273 | } | |
274 | } | |
275 | ||
276 | // we also want to present the native font descriptions to the user in some | |
277 | // human-readable form (it is not platform independent neither, but can | |
278 | // hopefully be understood by the user) | |
279 | bool FromUserString(const wxString& s); | |
280 | wxString ToUserString() const; | |
281 | }; | |
282 | ||
283 | ||
284 | ||
285 | ||
286 | struct wxNativeEncodingInfo | |
287 | { | |
288 | wxString facename; // may be empty meaning "any" | |
289 | wxFontEncoding encoding; // so that we know what this struct represents | |
290 | ||
291 | wxNativeEncodingInfo(); | |
292 | ~wxNativeEncodingInfo(); | |
c5f01dea | 293 | |
d14a1e28 RD |
294 | // this struct is saved in config by wxFontMapper, so it should know to |
295 | // serialise itself (implemented in platform-specific code) | |
296 | bool FromString(const wxString& s); | |
297 | wxString ToString() const; | |
298 | }; | |
299 | ||
300 | ||
301 | #ifndef __WXMSW__ | |
302 | // translate a wxFontEncoding into native encoding parameter (defined above), | |
303 | // returning a wxNativeEncodingInfo if an (exact) match could be found, NULL | |
304 | // otherwise. | |
305 | %inline %{ | |
306 | wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding) { | |
307 | static wxNativeEncodingInfo info; | |
308 | if ( wxGetNativeFontEncoding(encoding, &info) ) | |
309 | return &info; | |
310 | else | |
311 | return NULL; | |
312 | } | |
313 | %} | |
314 | ||
315 | // test for the existence of the font described by this facename/encoding, | |
dd9f7fea | 316 | // return True if such font(s) exist, False otherwise |
d14a1e28 RD |
317 | bool wxTestFontEncoding(const wxNativeEncodingInfo& info); |
318 | ||
319 | #else | |
320 | ||
321 | %inline %{ | |
322 | wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding) | |
81cfe5e1 | 323 | { wxPyRaiseNotImplemented(); return NULL; } |
c5f01dea | 324 | |
d14a1e28 | 325 | bool wxTestFontEncoding(const wxNativeEncodingInfo& info) |
a72f4631 | 326 | { wxPyRaiseNotImplemented(); return false; } |
d14a1e28 RD |
327 | %} |
328 | #endif | |
329 | ||
330 | //--------------------------------------------------------------------------- | |
331 | %newgroup | |
332 | ||
333 | // wxFontMapper manages user-definable correspondence between logical font | |
334 | // names and the fonts present on the machine. | |
335 | // | |
336 | // The default implementations of all functions will ask the user if they are | |
337 | // not capable of finding the answer themselves and store the answer in a | |
338 | // config file (configurable via SetConfigXXX functions). This behaviour may | |
dd9f7fea | 339 | // be disabled by giving the value of False to "interactive" parameter. |
d14a1e28 RD |
340 | // However, the functions will always consult the config file to allow the |
341 | // user-defined values override the default logic and there is no way to | |
342 | // disable this - which shouldn't be ever needed because if "interactive" was | |
dd9f7fea | 343 | // never True, the config file is never created anyhow. |
d14a1e28 RD |
344 | // |
345 | // This is a singleton class, font mapper objects can only be accessed using | |
346 | // wxFontMapper::Get(). | |
347 | ||
348 | class wxFontMapper | |
349 | { | |
350 | public: | |
351 | wxFontMapper(); | |
352 | ~wxFontMapper(); | |
353 | ||
354 | // return instance of the wxFontMapper singleton | |
355 | static wxFontMapper *Get(); | |
02b800ce | 356 | // set the singleton to 'mapper' instance and return previous one |
d14a1e28 RD |
357 | static wxFontMapper *Set(wxFontMapper *mapper); |
358 | ||
359 | ||
360 | // returns the encoding for the given charset (in the form of RFC 2046) or | |
361 | // wxFONTENCODING_SYSTEM if couldn't decode it | |
362 | // | |
363 | // interactive parameter is ignored in the base class, we behave as if it | |
dd9f7fea | 364 | // were always False |
d14a1e28 | 365 | virtual wxFontEncoding CharsetToEncoding(const wxString& charset, |
a72f4631 | 366 | bool interactive = true); |
d14a1e28 RD |
367 | |
368 | ||
369 | // get the number of font encodings we know about | |
370 | static size_t GetSupportedEncodingsCount(); | |
371 | ||
372 | // get the n-th supported encoding | |
373 | static wxFontEncoding GetEncoding(size_t n); | |
374 | ||
02b800ce RD |
375 | // return canonical name of this encoding (this is a short string, |
376 | // GetEncodingDescription() returns a longer one) | |
d14a1e28 RD |
377 | static wxString GetEncodingName(wxFontEncoding encoding); |
378 | ||
02b800ce RD |
379 | // // return a list of all names of this encoding (see GetEncodingName) |
380 | // static const wxChar** GetAllEncodingNames(wxFontEncoding encoding); | |
381 | ||
d14a1e28 RD |
382 | // return user-readable string describing the given encoding |
383 | // | |
384 | // NB: hard-coded now, but might change later (read it from config?) | |
385 | static wxString GetEncodingDescription(wxFontEncoding encoding); | |
386 | ||
56e63286 RD |
387 | // find the encoding corresponding to the given name, inverse of |
388 | // GetEncodingName() and less general than CharsetToEncoding() | |
389 | // | |
390 | // returns wxFONTENCODING_MAX if the name is not a supported encoding | |
391 | static wxFontEncoding GetEncodingFromName(const wxString& name); | |
392 | ||
d14a1e28 | 393 | |
d14a1e28 RD |
394 | // set the root config path to use (should be an absolute path) |
395 | void SetConfigPath(const wxString& prefix); | |
396 | ||
397 | // return default config path | |
398 | static const wxString GetDefaultConfigPath(); | |
399 | ||
400 | ||
401 | ||
402 | // Find an alternative for the given encoding (which is supposed to not be | |
403 | // available on this system). If successful, returns the encoding otherwise | |
404 | // returns None. | |
405 | %extend { | |
406 | PyObject* GetAltForEncoding(wxFontEncoding encoding, | |
407 | const wxString& facename = wxPyEmptyString, | |
a72f4631 | 408 | bool interactive = true) { |
d14a1e28 RD |
409 | wxFontEncoding alt_enc; |
410 | if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive)) | |
411 | return PyInt_FromLong(alt_enc); | |
412 | else { | |
413 | Py_INCREF(Py_None); | |
414 | return Py_None; | |
415 | } | |
416 | } | |
417 | } | |
418 | ||
419 | ||
420 | // checks whether given encoding is available in given face or not. | |
56e63286 RD |
421 | // If no facename is given (default), return true if it's available in any |
422 | // facename at all. | |
d14a1e28 RD |
423 | bool IsEncodingAvailable(wxFontEncoding encoding, |
424 | const wxString& facename = wxPyEmptyString); | |
425 | ||
426 | // the parent window for modal dialogs | |
427 | void SetDialogParent(wxWindow *parent); | |
428 | ||
429 | // the title for the dialogs (note that default is quite reasonable) | |
430 | void SetDialogTitle(const wxString& title); | |
431 | ||
432 | }; | |
433 | ||
434 | ||
435 | ||
436 | //--------------------------------------------------------------------------- | |
437 | %newgroup | |
438 | ||
439 | ||
ab1f7d2a RD |
440 | MustHaveApp(wxFont); |
441 | MustHaveApp(wxFont::GetDefaultEncoding); | |
442 | MustHaveApp(wxFont::SetDefaultEncoding); | |
443 | ||
5e4c653f RD |
444 | DocStr(wxFont, |
445 | "A font is an object which determines the appearance of text. Fonts are | |
446 | used for drawing text to a device context, and setting the appearance | |
447 | of a window's text. | |
448 | ||
449 | You can retrieve the current system font settings with `wx.SystemSettings`.", " | |
450 | ||
451 | The possible values for the family parameter of wx.Font constructor are: | |
452 | ||
453 | ======================== ============================= | |
454 | wx.FONTFAMILY_DEFAULT Chooses a default font. | |
455 | wx.FONTFAMILY_DECORATIVE A decorative font. | |
456 | wx.FONTFAMILY_ROMAN A formal, serif font. | |
457 | wx.FONTFAMILY_SCRIPT A handwriting font. | |
458 | wx.FONTFAMILY_SWISS A sans-serif font. | |
459 | wx.FONTFAMILY_MODERN Usually a fixed pitch font. | |
460 | wx.FONTFAMILY_TELETYPE A teletype font. | |
461 | ======================== ============================= | |
462 | ||
463 | The possible values for the weight parameter are: | |
464 | ||
465 | ==================== == | |
466 | wx.FONTWEIGHT_NORMAL | |
467 | wx.FONTWEIGHT_LIGHT | |
468 | wx.FONTWEIGHT_BOLD | |
469 | ==================== == | |
470 | ||
471 | The known font encodings are: | |
472 | ||
473 | =========================== ==================================== | |
474 | wx.FONTENCODING_SYSTEM system default | |
475 | wx.FONTENCODING_DEFAULT current default encoding | |
476 | wx.FONTENCODING_ISO8859_1 West European (Latin1) | |
477 | wx.FONTENCODING_ISO8859_2 Central and East European (Latin2) | |
478 | wx.FONTENCODING_ISO8859_3 Esperanto (Latin3) | |
479 | wx.FONTENCODING_ISO8859_4 Baltic (old) (Latin4) | |
480 | wx.FONTENCODING_ISO8859_5 Cyrillic | |
481 | wx.FONTENCODING_ISO8859_6 Arabic | |
482 | wx.FONTENCODING_ISO8859_7 Greek | |
483 | wx.FONTENCODING_ISO8859_8 Hebrew | |
484 | wx.FONTENCODING_ISO8859_9 Turkish (Latin5) | |
485 | wx.FONTENCODING_ISO8859_10 Variation of Latin4 (Latin6) | |
486 | wx.FONTENCODING_ISO8859_11 Thai | |
487 | wx.FONTENCODING_ISO8859_12 doesn't exist currently, but put it | |
488 | here anyhow to make all ISO8859 | |
489 | consecutive numbers | |
490 | wx.FONTENCODING_ISO8859_13 Baltic (Latin7) | |
491 | wx.FONTENCODING_ISO8859_14 Latin8 | |
492 | wx.FONTENCODING_ISO8859_15 Latin9 (a.k.a. Latin0, includes euro) | |
493 | wx.FONTENCODING_KOI8 Cyrillic charset | |
494 | wx.FONTENCODING_ALTERNATIVE same as MS-DOS CP866 | |
495 | wx.FONTENCODING_BULGARIAN used under Linux in Bulgaria | |
496 | wx.FONTENCODING_CP437 original MS-DOS codepage | |
497 | wx.FONTENCODING_CP850 CP437 merged with Latin1 | |
498 | wx.FONTENCODING_CP852 CP437 merged with Latin2 | |
499 | wx.FONTENCODING_CP855 another cyrillic encoding | |
500 | wx.FONTENCODING_CP866 and another one | |
501 | wx.FONTENCODING_CP874 WinThai | |
502 | wx.FONTENCODING_CP1250 WinLatin2 | |
503 | wx.FONTENCODING_CP1251 WinCyrillic | |
504 | wx.FONTENCODING_CP1252 WinLatin1 | |
505 | wx.FONTENCODING_CP1253 WinGreek (8859-7) | |
506 | wx.FONTENCODING_CP1254 WinTurkish | |
507 | wx.FONTENCODING_CP1255 WinHebrew | |
508 | wx.FONTENCODING_CP1256 WinArabic | |
509 | wx.FONTENCODING_CP1257 WinBaltic (same as Latin 7) | |
510 | wx.FONTENCODING_UTF7 UTF-7 Unicode encoding | |
511 | wx.FONTENCODING_UTF8 UTF-8 Unicode encoding | |
512 | =========================== ==================================== | |
513 | ||
514 | "); | |
515 | ||
d14a1e28 RD |
516 | class wxFont : public wxGDIObject { |
517 | public: | |
b60f943b RD |
518 | %pythonPrepend wxFont "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']" |
519 | ||
5e4c653f RD |
520 | DocCtorStr( |
521 | wxFont( int pointSize, int family, int style, int weight, | |
522 | bool underline=false, const wxString& face = wxPyEmptyString, | |
523 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT), | |
524 | "Creates a font object with the specified attributes. | |
525 | ||
526 | :param pointSize: The size of the font in points. | |
527 | ||
528 | :param family: Font family. A generic way of referring to fonts | |
529 | without specifying actual facename. It can be One of | |
530 | the ``wx.FONTFAMILY_xxx`` constants. | |
531 | ||
532 | :param style: One of the ``wx.FONTSTYLE_xxx`` constants. | |
533 | ||
534 | :param weight: Font weight, sometimes also referred to as font | |
535 | boldness. One of the ``wx.FONTWEIGHT_xxx`` constants. | |
536 | ||
537 | :param underline: The value can be ``True`` or ``False`` and | |
538 | indicates whether the font will include an underline. This | |
539 | may not be supported on all platforms. | |
540 | ||
541 | :param face: An optional string specifying the actual typeface to | |
542 | be used. If it is an empty string, a default typeface will be | |
543 | chosen based on the family. | |
544 | ||
545 | :param encoding: An encoding which may be one of the | |
546 | ``wx.FONTENCODING_xxx`` constants. If the specified encoding isn't | |
547 | available, no font is created. | |
548 | ||
549 | :see: `wx.FFont`, `wx.FontFromPixelSize`, `wx.FFontFromPixelSize`, | |
550 | `wx.FontFromNativeInfoString`, `wx.FontFromNativeInfo` | |
551 | ", ""); | |
293dc374 | 552 | |
d14a1e28 RD |
553 | ~wxFont(); |
554 | ||
5e4c653f RD |
555 | %RenameDocCtor( |
556 | FontFromNativeInfo, | |
557 | "Construct a `wx.Font` from a `wx.NativeFontInfo` object.", "", | |
558 | wxFont(const wxNativeFontInfo& info)); | |
559 | ||
d14a1e28 | 560 | %extend { |
5e4c653f RD |
561 | %RenameDocCtor( |
562 | FontFromNativeInfoString, | |
563 | "Construct a `wx.Font` from the string representation of a | |
564 | `wx.NativeFontInfo` object.", "", | |
565 | wxFont(const wxString& info)) | |
566 | { | |
567 | wxNativeFontInfo nfi; | |
568 | nfi.FromString(info); | |
569 | return new wxFont(nfi); | |
570 | } | |
d14a1e28 RD |
571 | } |
572 | ||
5e4c653f RD |
573 | |
574 | %extend { | |
575 | %RenameDocCtor( | |
576 | FFont, | |
577 | "A bit of a simpler way to create a `wx.Font` using flags instead of | |
578 | individual attribute settings. The value of flags can be a | |
579 | combination of the following: | |
580 | ||
581 | ============================ == | |
582 | wx.FONTFLAG_DEFAULT | |
583 | wx.FONTFLAG_ITALIC | |
584 | wx.FONTFLAG_SLANT | |
585 | wx.FONTFLAG_LIGHT | |
586 | wx.FONTFLAG_BOLD | |
587 | wx.FONTFLAG_ANTIALIASED | |
588 | wx.FONTFLAG_NOT_ANTIALIASED | |
589 | wx.FONTFLAG_UNDERLINED | |
590 | wx.FONTFLAG_STRIKETHROUGH | |
591 | ============================ == | |
592 | ||
593 | :see: `wx.Font.__init__`", "", | |
594 | ||
595 | wxFont(int pointSize, | |
596 | wxFontFamily family, | |
597 | int flags = wxFONTFLAG_DEFAULT, | |
598 | const wxString& face = wxPyEmptyString, | |
599 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT)) | |
600 | { | |
601 | return wxFont::New(pointSize, family, flags, face, encoding); | |
602 | } | |
293dc374 | 603 | |
5e4c653f RD |
604 | |
605 | // There is a real ctor for this on wxMSW, but not the others, so just | |
606 | // use the factory function in all cases. | |
607 | ||
608 | %RenameDocCtor( | |
609 | FontFromPixelSize, | |
610 | "Creates a font using a size in pixels rather than points. If there is | |
611 | platform API support for this then it is used, otherwise a font with | |
612 | the closest size is found using a binary search. | |
613 | ||
614 | :see: `wx.Font.__init__`", "", | |
615 | wxFont(const wxSize& pixelSize, | |
616 | int family, | |
617 | int style, | |
618 | int weight, | |
619 | bool underlined = false, | |
620 | const wxString& face = wxEmptyString, | |
621 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT)) | |
622 | { | |
623 | return wxFontBase::New(pixelSize, family, | |
624 | style, weight, underlined, | |
625 | face, encoding); | |
626 | } | |
627 | ||
628 | %RenameDocCtor( | |
629 | FFontFromPixelSize, | |
630 | "Creates a font using a size in pixels rather than points. If there is | |
631 | platform API support for this then it is used, otherwise a font with | |
632 | the closest size is found using a binary search. | |
633 | ||
634 | :see: `wx.Font.__init__`, `wx.FFont`", "", | |
635 | wxFont(const wxSize& pixelSize, | |
636 | wxFontFamily family, | |
637 | int flags = wxFONTFLAG_DEFAULT, | |
638 | const wxString& face = wxEmptyString, | |
639 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT)) | |
640 | { | |
641 | return wxFontBase::New(pixelSize, family, flags, face, encoding); | |
642 | } | |
c5f01dea RD |
643 | } |
644 | ||
645 | ||
d14a1e28 RD |
646 | |
647 | // was the font successfully created? | |
5e4c653f RD |
648 | DocDeclStr( |
649 | bool , Ok() const, | |
650 | "Returns ``True`` if this font was successfully created.", ""); | |
d14a1e28 RD |
651 | %pythoncode { def __nonzero__(self): return self.Ok() } |
652 | ||
5e4c653f | 653 | |
d14a1e28 | 654 | // comparison |
22faec7d | 655 | %extend { |
a72f4631 RD |
656 | bool __eq__(const wxFont* other) { return other ? (*self == *other) : false; } |
657 | bool __ne__(const wxFont* other) { return other ? (*self != *other) : true; } | |
22faec7d | 658 | } |
d14a1e28 | 659 | |
5e4c653f RD |
660 | |
661 | DocDeclStr( | |
662 | virtual int , GetPointSize() const, | |
663 | "Gets the point size.", ""); | |
664 | ||
665 | DocDeclStr( | |
666 | virtual wxSize , GetPixelSize() const, | |
667 | "Returns the size in pixels if the font was constructed with a pixel | |
668 | size.", ""); | |
669 | ||
670 | DocDeclStr( | |
671 | virtual bool , IsUsingSizeInPixels() const, | |
672 | "Returns ``True`` if the font is using a pixelSize.", ""); | |
673 | ||
674 | ||
675 | DocDeclStr( | |
676 | virtual int , GetFamily() const, | |
677 | "Gets the font family. ", ""); | |
678 | ||
679 | DocDeclStr( | |
680 | virtual int , GetStyle() const, | |
681 | "Gets the font style.", ""); | |
682 | ||
683 | DocDeclStr( | |
684 | virtual int , GetWeight() const, | |
685 | "Gets the font weight. ", ""); | |
686 | ||
687 | DocDeclStr( | |
688 | virtual bool , GetUnderlined() const, | |
689 | "Returns ``True`` if the font is underlined, ``False`` otherwise.", ""); | |
690 | ||
691 | DocDeclStr( | |
692 | virtual wxString , GetFaceName() const, | |
693 | "Returns the typeface name associated with the font, or the empty | |
694 | string if there is no typeface information.", ""); | |
695 | ||
696 | DocDeclStr( | |
697 | virtual wxFontEncoding , GetEncoding() const, | |
698 | "Get the font's encoding.", ""); | |
699 | ||
700 | DocDeclStr( | |
701 | virtual const wxNativeFontInfo *, GetNativeFontInfo() const, | |
702 | "Constructs a `wx.NativeFontInfo` object from this font.", ""); | |
703 | ||
d14a1e28 | 704 | |
5e4c653f RD |
705 | DocDeclStr( |
706 | virtual bool , IsFixedWidth() const, | |
707 | "Returns true if the font is a fixed width (or monospaced) font, false | |
708 | if it is a proportional one or font is invalid.", ""); | |
709 | ||
d14a1e28 | 710 | |
5e4c653f RD |
711 | DocDeclStr( |
712 | wxString , GetNativeFontInfoDesc() const, | |
713 | "Returns the platform-dependent string completely describing this font | |
714 | or an empty string if the font isn't valid.", ""); | |
715 | ||
716 | DocDeclStr( | |
717 | wxString , GetNativeFontInfoUserDesc() const, | |
718 | "Returns a human readable version of `GetNativeFontInfoDesc`.", ""); | |
719 | ||
d14a1e28 RD |
720 | |
721 | // change the font characteristics | |
5e4c653f RD |
722 | DocDeclStr( |
723 | virtual void , SetPointSize( int pointSize ), | |
724 | "Sets the point size.", ""); | |
725 | ||
726 | DocDeclStr( | |
727 | virtual void , SetPixelSize( const wxSize& pixelSize ), | |
728 | "Sets the size in pixels rather than points. If there is platform API | |
729 | support for this then it is used, otherwise a font with the closest | |
730 | size is found using a binary search.", ""); | |
731 | ||
732 | DocDeclStr( | |
733 | virtual void , SetFamily( int family ), | |
734 | "Sets the font family.", ""); | |
735 | ||
736 | DocDeclStr( | |
737 | virtual void , SetStyle( int style ), | |
738 | "Sets the font style.", ""); | |
739 | ||
740 | DocDeclStr( | |
741 | virtual void , SetWeight( int weight ), | |
742 | "Sets the font weight.", ""); | |
743 | ||
744 | DocDeclStr( | |
d0e2ede0 | 745 | virtual bool , SetFaceName( const wxString& faceName ), |
5e4c653f RD |
746 | "Sets the facename for the font. The facename, which should be a valid |
747 | font installed on the end-user's system. | |
748 | ||
749 | To avoid portability problems, don't rely on a specific face, but | |
750 | specify the font family instead or as well. A suitable font will be | |
751 | found on the end-user's system. If both the family and the facename | |
752 | are specified, wxWidgets will first search for the specific face, and | |
753 | then for a font belonging to the same family.", ""); | |
754 | ||
755 | DocDeclStr( | |
756 | virtual void , SetUnderlined( bool underlined ), | |
757 | "Sets underlining.", ""); | |
758 | ||
759 | DocDeclStr( | |
760 | virtual void , SetEncoding(wxFontEncoding encoding), | |
761 | "Set the font encoding.", ""); | |
762 | ||
763 | DocDeclStr( | |
764 | void , SetNativeFontInfo(const wxNativeFontInfo& info), | |
765 | "Set the font's attributes from a `wx.NativeFontInfo` object.", ""); | |
766 | ||
767 | ||
768 | DocDeclStrName( | |
d0e2ede0 | 769 | bool , SetNativeFontInfo(const wxString& info), |
5e4c653f RD |
770 | "Set the font's attributes from string representation of a |
771 | `wx.NativeFontInfo` object.", "", | |
772 | SetNativeFontInfoFromString); | |
773 | ||
774 | DocDeclStr( | |
d0e2ede0 | 775 | bool , SetNativeFontInfoUserDesc(const wxString& info), |
5e4c653f RD |
776 | "Set the font's attributes from a string formerly returned from |
777 | `GetNativeFontInfoDesc`.", ""); | |
778 | ||
779 | ||
780 | DocDeclStr( | |
781 | wxString , GetFamilyString() const, | |
782 | "Returns a string representation of the font family.", ""); | |
783 | ||
784 | DocDeclStr( | |
785 | wxString , GetStyleString() const, | |
786 | "Returns a string representation of the font style.", ""); | |
787 | ||
788 | DocDeclStr( | |
789 | wxString , GetWeightString() const, | |
790 | "Return a string representation of the font weight.", ""); | |
791 | ||
792 | ||
a72f4631 | 793 | virtual void SetNoAntiAliasing( bool no = true ); |
5a319c5c | 794 | virtual bool GetNoAntiAliasing() const; |
d14a1e28 RD |
795 | |
796 | // the default encoding is used for creating all fonts with default | |
797 | // encoding parameter | |
5e4c653f RD |
798 | DocDeclStr( |
799 | static wxFontEncoding , GetDefaultEncoding(), | |
800 | "Returns the encoding used for all fonts created with an encoding of | |
801 | ``wx.FONTENCODING_DEFAULT``.", ""); | |
802 | ||
803 | DocDeclStr( | |
804 | static void , SetDefaultEncoding(wxFontEncoding encoding), | |
805 | "Sets the default font encoding.", ""); | |
806 | ||
c5f01dea | 807 | }; |
d14a1e28 | 808 | |
5e4c653f | 809 | %pythoncode { Font2 = wx._deprecated(FFont, "Use `wx.FFont` instead.") } |
d14a1e28 RD |
810 | |
811 | //--------------------------------------------------------------------------- | |
812 | %newgroup | |
813 | ||
814 | // wxFontEnumerator | |
815 | %{ | |
816 | class wxPyFontEnumerator : public wxFontEnumerator { | |
817 | public: | |
818 | wxPyFontEnumerator() {} | |
819 | ~wxPyFontEnumerator() {} | |
820 | ||
821 | DEC_PYCALLBACK_BOOL_STRING(OnFacename); | |
822 | DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding); | |
823 | ||
824 | PYPRIVATE; | |
825 | }; | |
826 | ||
827 | IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename); | |
828 | IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding); | |
829 | ||
830 | %} | |
831 | ||
ab1f7d2a RD |
832 | MustHaveApp(wxPyFontEnumerator); |
833 | ||
1b8c7ba6 RD |
834 | %rename(FontEnumerator) wxPyFontEnumerator; |
835 | class wxPyFontEnumerator { | |
d14a1e28 | 836 | public: |
2b9048c5 | 837 | %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)" |
d14a1e28 RD |
838 | |
839 | wxPyFontEnumerator(); | |
840 | ~wxPyFontEnumerator(); | |
841 | void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref); | |
842 | ||
843 | bool EnumerateFacenames( | |
844 | wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all | |
a72f4631 | 845 | bool fixedWidthOnly = false); |
d14a1e28 RD |
846 | |
847 | bool EnumerateEncodings(const wxString& facename = wxPyEmptyString); | |
848 | ||
d14a1e28 | 849 | %extend { |
d0e2ede0 | 850 | static PyObject* GetEncodings() { |
e6f85a85 | 851 | PyObject* ret; |
d0e2ede0 | 852 | wxArrayString arr = wxFontEnumerator::GetEncodings(); |
e6f85a85 | 853 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d0e2ede0 | 854 | ret = wxArrayString2PyList_helper(arr); |
e6f85a85 RD |
855 | wxPyEndBlockThreads(blocked); |
856 | return ret; | |
d14a1e28 RD |
857 | } |
858 | ||
d0e2ede0 | 859 | static PyObject* GetFacenames() { |
e6f85a85 | 860 | PyObject* ret; |
d0e2ede0 | 861 | wxArrayString arr = wxFontEnumerator::GetFacenames(); |
e6f85a85 | 862 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d0e2ede0 | 863 | ret = wxArrayString2PyList_helper(arr); |
e6f85a85 RD |
864 | wxPyEndBlockThreads(blocked); |
865 | return ret; | |
d14a1e28 RD |
866 | } |
867 | } | |
d0e2ede0 RD |
868 | |
869 | DocDeclStr( | |
870 | static bool , IsValidFacename(const wxString &str), | |
871 | "Convenience function that returns true if the given face name exist in | |
872 | the user's system", ""); | |
873 | ||
d14a1e28 RD |
874 | }; |
875 | ||
876 | ||
877 | ||
878 | %init %{ | |
879 | wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator"); | |
880 | %} | |
881 | ||
882 | //--------------------------------------------------------------------------- |