]>
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 | ||
42e2bbb9 RD |
432 | |
433 | %property(AltForEncoding, GetAltForEncoding, doc="See `GetAltForEncoding`"); | |
d14a1e28 RD |
434 | }; |
435 | ||
436 | ||
437 | ||
438 | //--------------------------------------------------------------------------- | |
439 | %newgroup | |
440 | ||
441 | ||
ab1f7d2a RD |
442 | MustHaveApp(wxFont); |
443 | MustHaveApp(wxFont::GetDefaultEncoding); | |
444 | MustHaveApp(wxFont::SetDefaultEncoding); | |
445 | ||
5e4c653f RD |
446 | DocStr(wxFont, |
447 | "A font is an object which determines the appearance of text. Fonts are | |
448 | used for drawing text to a device context, and setting the appearance | |
449 | of a window's text. | |
450 | ||
451 | You can retrieve the current system font settings with `wx.SystemSettings`.", " | |
452 | ||
453 | The possible values for the family parameter of wx.Font constructor are: | |
454 | ||
455 | ======================== ============================= | |
456 | wx.FONTFAMILY_DEFAULT Chooses a default font. | |
457 | wx.FONTFAMILY_DECORATIVE A decorative font. | |
458 | wx.FONTFAMILY_ROMAN A formal, serif font. | |
459 | wx.FONTFAMILY_SCRIPT A handwriting font. | |
460 | wx.FONTFAMILY_SWISS A sans-serif font. | |
461 | wx.FONTFAMILY_MODERN Usually a fixed pitch font. | |
462 | wx.FONTFAMILY_TELETYPE A teletype font. | |
463 | ======================== ============================= | |
464 | ||
465 | The possible values for the weight parameter are: | |
466 | ||
467 | ==================== == | |
468 | wx.FONTWEIGHT_NORMAL | |
469 | wx.FONTWEIGHT_LIGHT | |
470 | wx.FONTWEIGHT_BOLD | |
471 | ==================== == | |
472 | ||
473 | The known font encodings are: | |
474 | ||
475 | =========================== ==================================== | |
476 | wx.FONTENCODING_SYSTEM system default | |
477 | wx.FONTENCODING_DEFAULT current default encoding | |
478 | wx.FONTENCODING_ISO8859_1 West European (Latin1) | |
479 | wx.FONTENCODING_ISO8859_2 Central and East European (Latin2) | |
480 | wx.FONTENCODING_ISO8859_3 Esperanto (Latin3) | |
481 | wx.FONTENCODING_ISO8859_4 Baltic (old) (Latin4) | |
482 | wx.FONTENCODING_ISO8859_5 Cyrillic | |
483 | wx.FONTENCODING_ISO8859_6 Arabic | |
484 | wx.FONTENCODING_ISO8859_7 Greek | |
485 | wx.FONTENCODING_ISO8859_8 Hebrew | |
486 | wx.FONTENCODING_ISO8859_9 Turkish (Latin5) | |
487 | wx.FONTENCODING_ISO8859_10 Variation of Latin4 (Latin6) | |
488 | wx.FONTENCODING_ISO8859_11 Thai | |
489 | wx.FONTENCODING_ISO8859_12 doesn't exist currently, but put it | |
490 | here anyhow to make all ISO8859 | |
491 | consecutive numbers | |
492 | wx.FONTENCODING_ISO8859_13 Baltic (Latin7) | |
493 | wx.FONTENCODING_ISO8859_14 Latin8 | |
494 | wx.FONTENCODING_ISO8859_15 Latin9 (a.k.a. Latin0, includes euro) | |
495 | wx.FONTENCODING_KOI8 Cyrillic charset | |
496 | wx.FONTENCODING_ALTERNATIVE same as MS-DOS CP866 | |
497 | wx.FONTENCODING_BULGARIAN used under Linux in Bulgaria | |
498 | wx.FONTENCODING_CP437 original MS-DOS codepage | |
499 | wx.FONTENCODING_CP850 CP437 merged with Latin1 | |
500 | wx.FONTENCODING_CP852 CP437 merged with Latin2 | |
501 | wx.FONTENCODING_CP855 another cyrillic encoding | |
502 | wx.FONTENCODING_CP866 and another one | |
503 | wx.FONTENCODING_CP874 WinThai | |
504 | wx.FONTENCODING_CP1250 WinLatin2 | |
505 | wx.FONTENCODING_CP1251 WinCyrillic | |
506 | wx.FONTENCODING_CP1252 WinLatin1 | |
507 | wx.FONTENCODING_CP1253 WinGreek (8859-7) | |
508 | wx.FONTENCODING_CP1254 WinTurkish | |
509 | wx.FONTENCODING_CP1255 WinHebrew | |
510 | wx.FONTENCODING_CP1256 WinArabic | |
511 | wx.FONTENCODING_CP1257 WinBaltic (same as Latin 7) | |
512 | wx.FONTENCODING_UTF7 UTF-7 Unicode encoding | |
513 | wx.FONTENCODING_UTF8 UTF-8 Unicode encoding | |
514 | =========================== ==================================== | |
515 | ||
516 | "); | |
517 | ||
d14a1e28 RD |
518 | class wxFont : public wxGDIObject { |
519 | public: | |
b60f943b RD |
520 | %pythonPrepend wxFont "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']" |
521 | ||
5e4c653f RD |
522 | DocCtorStr( |
523 | wxFont( int pointSize, int family, int style, int weight, | |
524 | bool underline=false, const wxString& face = wxPyEmptyString, | |
525 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT), | |
526 | "Creates a font object with the specified attributes. | |
527 | ||
528 | :param pointSize: The size of the font in points. | |
529 | ||
530 | :param family: Font family. A generic way of referring to fonts | |
531 | without specifying actual facename. It can be One of | |
532 | the ``wx.FONTFAMILY_xxx`` constants. | |
533 | ||
534 | :param style: One of the ``wx.FONTSTYLE_xxx`` constants. | |
535 | ||
536 | :param weight: Font weight, sometimes also referred to as font | |
537 | boldness. One of the ``wx.FONTWEIGHT_xxx`` constants. | |
538 | ||
539 | :param underline: The value can be ``True`` or ``False`` and | |
540 | indicates whether the font will include an underline. This | |
541 | may not be supported on all platforms. | |
542 | ||
543 | :param face: An optional string specifying the actual typeface to | |
544 | be used. If it is an empty string, a default typeface will be | |
545 | chosen based on the family. | |
546 | ||
547 | :param encoding: An encoding which may be one of the | |
548 | ``wx.FONTENCODING_xxx`` constants. If the specified encoding isn't | |
549 | available, no font is created. | |
550 | ||
551 | :see: `wx.FFont`, `wx.FontFromPixelSize`, `wx.FFontFromPixelSize`, | |
552 | `wx.FontFromNativeInfoString`, `wx.FontFromNativeInfo` | |
553 | ", ""); | |
293dc374 | 554 | |
d14a1e28 RD |
555 | ~wxFont(); |
556 | ||
5e4c653f RD |
557 | %RenameDocCtor( |
558 | FontFromNativeInfo, | |
559 | "Construct a `wx.Font` from a `wx.NativeFontInfo` object.", "", | |
560 | wxFont(const wxNativeFontInfo& info)); | |
561 | ||
d14a1e28 | 562 | %extend { |
5e4c653f RD |
563 | %RenameDocCtor( |
564 | FontFromNativeInfoString, | |
565 | "Construct a `wx.Font` from the string representation of a | |
566 | `wx.NativeFontInfo` object.", "", | |
567 | wxFont(const wxString& info)) | |
568 | { | |
569 | wxNativeFontInfo nfi; | |
570 | nfi.FromString(info); | |
571 | return new wxFont(nfi); | |
572 | } | |
d14a1e28 RD |
573 | } |
574 | ||
5e4c653f RD |
575 | |
576 | %extend { | |
577 | %RenameDocCtor( | |
578 | FFont, | |
579 | "A bit of a simpler way to create a `wx.Font` using flags instead of | |
580 | individual attribute settings. The value of flags can be a | |
581 | combination of the following: | |
582 | ||
583 | ============================ == | |
584 | wx.FONTFLAG_DEFAULT | |
585 | wx.FONTFLAG_ITALIC | |
586 | wx.FONTFLAG_SLANT | |
587 | wx.FONTFLAG_LIGHT | |
588 | wx.FONTFLAG_BOLD | |
589 | wx.FONTFLAG_ANTIALIASED | |
590 | wx.FONTFLAG_NOT_ANTIALIASED | |
591 | wx.FONTFLAG_UNDERLINED | |
592 | wx.FONTFLAG_STRIKETHROUGH | |
593 | ============================ == | |
594 | ||
595 | :see: `wx.Font.__init__`", "", | |
596 | ||
597 | wxFont(int pointSize, | |
598 | wxFontFamily family, | |
599 | int flags = wxFONTFLAG_DEFAULT, | |
600 | const wxString& face = wxPyEmptyString, | |
601 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT)) | |
602 | { | |
603 | return wxFont::New(pointSize, family, flags, face, encoding); | |
604 | } | |
293dc374 | 605 | |
5e4c653f RD |
606 | |
607 | // There is a real ctor for this on wxMSW, but not the others, so just | |
608 | // use the factory function in all cases. | |
609 | ||
610 | %RenameDocCtor( | |
611 | FontFromPixelSize, | |
612 | "Creates a font using a size in pixels rather than points. If there is | |
613 | platform API support for this then it is used, otherwise a font with | |
614 | the closest size is found using a binary search. | |
615 | ||
616 | :see: `wx.Font.__init__`", "", | |
617 | wxFont(const wxSize& pixelSize, | |
618 | int family, | |
619 | int style, | |
620 | int weight, | |
621 | bool underlined = false, | |
622 | const wxString& face = wxEmptyString, | |
623 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT)) | |
624 | { | |
625 | return wxFontBase::New(pixelSize, family, | |
626 | style, weight, underlined, | |
627 | face, encoding); | |
628 | } | |
629 | ||
630 | %RenameDocCtor( | |
631 | FFontFromPixelSize, | |
632 | "Creates a font using a size in pixels rather than points. If there is | |
633 | platform API support for this then it is used, otherwise a font with | |
634 | the closest size is found using a binary search. | |
635 | ||
636 | :see: `wx.Font.__init__`, `wx.FFont`", "", | |
637 | wxFont(const wxSize& pixelSize, | |
638 | wxFontFamily family, | |
639 | int flags = wxFONTFLAG_DEFAULT, | |
640 | const wxString& face = wxEmptyString, | |
641 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT)) | |
642 | { | |
643 | return wxFontBase::New(pixelSize, family, flags, face, encoding); | |
644 | } | |
c5f01dea RD |
645 | } |
646 | ||
647 | ||
d14a1e28 RD |
648 | |
649 | // was the font successfully created? | |
5e4c653f RD |
650 | DocDeclStr( |
651 | bool , Ok() const, | |
652 | "Returns ``True`` if this font was successfully created.", ""); | |
d14a1e28 RD |
653 | %pythoncode { def __nonzero__(self): return self.Ok() } |
654 | ||
5e4c653f | 655 | |
d14a1e28 | 656 | // comparison |
22faec7d | 657 | %extend { |
a72f4631 RD |
658 | bool __eq__(const wxFont* other) { return other ? (*self == *other) : false; } |
659 | bool __ne__(const wxFont* other) { return other ? (*self != *other) : true; } | |
22faec7d | 660 | } |
d14a1e28 | 661 | |
5e4c653f RD |
662 | |
663 | DocDeclStr( | |
664 | virtual int , GetPointSize() const, | |
665 | "Gets the point size.", ""); | |
666 | ||
667 | DocDeclStr( | |
668 | virtual wxSize , GetPixelSize() const, | |
669 | "Returns the size in pixels if the font was constructed with a pixel | |
670 | size.", ""); | |
671 | ||
672 | DocDeclStr( | |
673 | virtual bool , IsUsingSizeInPixels() const, | |
674 | "Returns ``True`` if the font is using a pixelSize.", ""); | |
675 | ||
676 | ||
677 | DocDeclStr( | |
678 | virtual int , GetFamily() const, | |
679 | "Gets the font family. ", ""); | |
680 | ||
681 | DocDeclStr( | |
682 | virtual int , GetStyle() const, | |
683 | "Gets the font style.", ""); | |
684 | ||
685 | DocDeclStr( | |
686 | virtual int , GetWeight() const, | |
687 | "Gets the font weight. ", ""); | |
688 | ||
689 | DocDeclStr( | |
690 | virtual bool , GetUnderlined() const, | |
691 | "Returns ``True`` if the font is underlined, ``False`` otherwise.", ""); | |
692 | ||
693 | DocDeclStr( | |
694 | virtual wxString , GetFaceName() const, | |
695 | "Returns the typeface name associated with the font, or the empty | |
696 | string if there is no typeface information.", ""); | |
697 | ||
698 | DocDeclStr( | |
699 | virtual wxFontEncoding , GetEncoding() const, | |
700 | "Get the font's encoding.", ""); | |
701 | ||
702 | DocDeclStr( | |
703 | virtual const wxNativeFontInfo *, GetNativeFontInfo() const, | |
704 | "Constructs a `wx.NativeFontInfo` object from this font.", ""); | |
705 | ||
d14a1e28 | 706 | |
5e4c653f RD |
707 | DocDeclStr( |
708 | virtual bool , IsFixedWidth() const, | |
709 | "Returns true if the font is a fixed width (or monospaced) font, false | |
710 | if it is a proportional one or font is invalid.", ""); | |
711 | ||
d14a1e28 | 712 | |
5e4c653f RD |
713 | DocDeclStr( |
714 | wxString , GetNativeFontInfoDesc() const, | |
715 | "Returns the platform-dependent string completely describing this font | |
716 | or an empty string if the font isn't valid.", ""); | |
717 | ||
718 | DocDeclStr( | |
719 | wxString , GetNativeFontInfoUserDesc() const, | |
720 | "Returns a human readable version of `GetNativeFontInfoDesc`.", ""); | |
721 | ||
d14a1e28 RD |
722 | |
723 | // change the font characteristics | |
5e4c653f RD |
724 | DocDeclStr( |
725 | virtual void , SetPointSize( int pointSize ), | |
726 | "Sets the point size.", ""); | |
727 | ||
728 | DocDeclStr( | |
729 | virtual void , SetPixelSize( const wxSize& pixelSize ), | |
730 | "Sets the size in pixels rather than points. If there is platform API | |
731 | support for this then it is used, otherwise a font with the closest | |
732 | size is found using a binary search.", ""); | |
733 | ||
734 | DocDeclStr( | |
735 | virtual void , SetFamily( int family ), | |
736 | "Sets the font family.", ""); | |
737 | ||
738 | DocDeclStr( | |
739 | virtual void , SetStyle( int style ), | |
740 | "Sets the font style.", ""); | |
741 | ||
742 | DocDeclStr( | |
743 | virtual void , SetWeight( int weight ), | |
744 | "Sets the font weight.", ""); | |
745 | ||
746 | DocDeclStr( | |
d0e2ede0 | 747 | virtual bool , SetFaceName( const wxString& faceName ), |
5e4c653f RD |
748 | "Sets the facename for the font. The facename, which should be a valid |
749 | font installed on the end-user's system. | |
750 | ||
751 | To avoid portability problems, don't rely on a specific face, but | |
752 | specify the font family instead or as well. A suitable font will be | |
753 | found on the end-user's system. If both the family and the facename | |
754 | are specified, wxWidgets will first search for the specific face, and | |
755 | then for a font belonging to the same family.", ""); | |
756 | ||
757 | DocDeclStr( | |
758 | virtual void , SetUnderlined( bool underlined ), | |
759 | "Sets underlining.", ""); | |
760 | ||
761 | DocDeclStr( | |
762 | virtual void , SetEncoding(wxFontEncoding encoding), | |
763 | "Set the font encoding.", ""); | |
764 | ||
765 | DocDeclStr( | |
766 | void , SetNativeFontInfo(const wxNativeFontInfo& info), | |
767 | "Set the font's attributes from a `wx.NativeFontInfo` object.", ""); | |
768 | ||
769 | ||
770 | DocDeclStrName( | |
d0e2ede0 | 771 | bool , SetNativeFontInfo(const wxString& info), |
5e4c653f RD |
772 | "Set the font's attributes from string representation of a |
773 | `wx.NativeFontInfo` object.", "", | |
774 | SetNativeFontInfoFromString); | |
775 | ||
776 | DocDeclStr( | |
d0e2ede0 | 777 | bool , SetNativeFontInfoUserDesc(const wxString& info), |
5e4c653f RD |
778 | "Set the font's attributes from a string formerly returned from |
779 | `GetNativeFontInfoDesc`.", ""); | |
780 | ||
781 | ||
782 | DocDeclStr( | |
783 | wxString , GetFamilyString() const, | |
784 | "Returns a string representation of the font family.", ""); | |
785 | ||
786 | DocDeclStr( | |
787 | wxString , GetStyleString() const, | |
788 | "Returns a string representation of the font style.", ""); | |
789 | ||
790 | DocDeclStr( | |
791 | wxString , GetWeightString() const, | |
792 | "Return a string representation of the font weight.", ""); | |
793 | ||
794 | ||
a72f4631 | 795 | virtual void SetNoAntiAliasing( bool no = true ); |
5a319c5c | 796 | virtual bool GetNoAntiAliasing() const; |
d14a1e28 RD |
797 | |
798 | // the default encoding is used for creating all fonts with default | |
799 | // encoding parameter | |
5e4c653f RD |
800 | DocDeclStr( |
801 | static wxFontEncoding , GetDefaultEncoding(), | |
802 | "Returns the encoding used for all fonts created with an encoding of | |
803 | ``wx.FONTENCODING_DEFAULT``.", ""); | |
804 | ||
805 | DocDeclStr( | |
806 | static void , SetDefaultEncoding(wxFontEncoding encoding), | |
807 | "Sets the default font encoding.", ""); | |
42e2bbb9 RD |
808 | |
809 | %property(Encoding, GetEncoding, SetEncoding, doc="See `GetEncoding` and `SetEncoding`"); | |
810 | %property(FaceName, GetFaceName, SetFaceName, doc="See `GetFaceName` and `SetFaceName`"); | |
811 | %property(Family, GetFamily, SetFamily, doc="See `GetFamily` and `SetFamily`"); | |
812 | %property(FamilyString, GetFamilyString, doc="See `GetFamilyString`"); | |
813 | %property(NativeFontInfo, GetNativeFontInfo, SetNativeFontInfo, doc="See `GetNativeFontInfo` and `SetNativeFontInfo`"); | |
814 | %property(NativeFontInfoDesc, GetNativeFontInfoDesc, doc="See `GetNativeFontInfoDesc`"); | |
815 | %property(NativeFontInfoUserDesc, GetNativeFontInfoUserDesc, SetNativeFontInfoUserDesc, doc="See `GetNativeFontInfoUserDesc` and `SetNativeFontInfoUserDesc`"); | |
816 | %property(NoAntiAliasing, GetNoAntiAliasing, SetNoAntiAliasing, doc="See `GetNoAntiAliasing` and `SetNoAntiAliasing`"); | |
817 | %property(PixelSize, GetPixelSize, SetPixelSize, doc="See `GetPixelSize` and `SetPixelSize`"); | |
818 | %property(PointSize, GetPointSize, SetPointSize, doc="See `GetPointSize` and `SetPointSize`"); | |
819 | %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`"); | |
820 | %property(StyleString, GetStyleString, doc="See `GetStyleString`"); | |
821 | %property(Underlined, GetUnderlined, SetUnderlined, doc="See `GetUnderlined` and `SetUnderlined`"); | |
822 | %property(Weight, GetWeight, SetWeight, doc="See `GetWeight` and `SetWeight`"); | |
823 | %property(WeightString, GetWeightString, doc="See `GetWeightString`"); | |
5e4c653f | 824 | |
c5f01dea | 825 | }; |
d14a1e28 | 826 | |
5e4c653f | 827 | %pythoncode { Font2 = wx._deprecated(FFont, "Use `wx.FFont` instead.") } |
d14a1e28 RD |
828 | |
829 | //--------------------------------------------------------------------------- | |
830 | %newgroup | |
831 | ||
832 | // wxFontEnumerator | |
833 | %{ | |
834 | class wxPyFontEnumerator : public wxFontEnumerator { | |
835 | public: | |
836 | wxPyFontEnumerator() {} | |
837 | ~wxPyFontEnumerator() {} | |
838 | ||
839 | DEC_PYCALLBACK_BOOL_STRING(OnFacename); | |
840 | DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding); | |
841 | ||
842 | PYPRIVATE; | |
843 | }; | |
844 | ||
845 | IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename); | |
846 | IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding); | |
847 | ||
848 | %} | |
849 | ||
ab1f7d2a RD |
850 | MustHaveApp(wxPyFontEnumerator); |
851 | ||
1b8c7ba6 RD |
852 | %rename(FontEnumerator) wxPyFontEnumerator; |
853 | class wxPyFontEnumerator { | |
d14a1e28 | 854 | public: |
2b9048c5 | 855 | %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)" |
d14a1e28 RD |
856 | |
857 | wxPyFontEnumerator(); | |
858 | ~wxPyFontEnumerator(); | |
859 | void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref); | |
860 | ||
861 | bool EnumerateFacenames( | |
862 | wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all | |
a72f4631 | 863 | bool fixedWidthOnly = false); |
d14a1e28 RD |
864 | |
865 | bool EnumerateEncodings(const wxString& facename = wxPyEmptyString); | |
866 | ||
d14a1e28 | 867 | %extend { |
d0e2ede0 | 868 | static PyObject* GetEncodings() { |
e6f85a85 | 869 | PyObject* ret; |
d0e2ede0 | 870 | wxArrayString arr = wxFontEnumerator::GetEncodings(); |
e6f85a85 | 871 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d0e2ede0 | 872 | ret = wxArrayString2PyList_helper(arr); |
e6f85a85 RD |
873 | wxPyEndBlockThreads(blocked); |
874 | return ret; | |
d14a1e28 RD |
875 | } |
876 | ||
d0e2ede0 | 877 | static PyObject* GetFacenames() { |
e6f85a85 | 878 | PyObject* ret; |
d0e2ede0 | 879 | wxArrayString arr = wxFontEnumerator::GetFacenames(); |
e6f85a85 | 880 | wxPyBlock_t blocked = wxPyBeginBlockThreads(); |
d0e2ede0 | 881 | ret = wxArrayString2PyList_helper(arr); |
e6f85a85 RD |
882 | wxPyEndBlockThreads(blocked); |
883 | return ret; | |
d14a1e28 RD |
884 | } |
885 | } | |
d0e2ede0 RD |
886 | |
887 | DocDeclStr( | |
888 | static bool , IsValidFacename(const wxString &str), | |
889 | "Convenience function that returns true if the given face name exist in | |
890 | the user's system", ""); | |
891 | ||
d14a1e28 RD |
892 | }; |
893 | ||
894 | ||
895 | ||
896 | %init %{ | |
897 | wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator"); | |
898 | %} | |
899 | ||
900 | //--------------------------------------------------------------------------- |