]>
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 | |
64 | wxFONTFLAG_DEFAULT = 0, | |
65 | ||
66 | // slant flags (default: no slant) | |
67 | wxFONTFLAG_ITALIC = 1 << 0, | |
68 | wxFONTFLAG_SLANT = 1 << 1, | |
69 | ||
70 | // weight flags (default: medium) | |
71 | wxFONTFLAG_LIGHT = 1 << 2, | |
72 | wxFONTFLAG_BOLD = 1 << 3, | |
73 | ||
74 | // anti-aliasing flag: force on or off (default: the current system default) | |
75 | wxFONTFLAG_ANTIALIASED = 1 << 4, | |
76 | wxFONTFLAG_NOT_ANTIALIASED = 1 << 5, | |
77 | ||
78 | // underlined/strikethrough flags (default: no lines) | |
79 | wxFONTFLAG_UNDERLINED = 1 << 6, | |
80 | wxFONTFLAG_STRIKETHROUGH = 1 << 7, | |
81 | ||
82 | // the mask of all currently used flags | |
83 | wxFONTFLAG_MASK = wxFONTFLAG_ITALIC | | |
84 | wxFONTFLAG_SLANT | | |
85 | wxFONTFLAG_LIGHT | | |
86 | wxFONTFLAG_BOLD | | |
87 | wxFONTFLAG_ANTIALIASED | | |
88 | wxFONTFLAG_NOT_ANTIALIASED | | |
89 | wxFONTFLAG_UNDERLINED | | |
90 | wxFONTFLAG_STRIKETHROUGH | |
91 | }; | |
92 | ||
93 | ||
94 | // font encodings | |
95 | enum wxFontEncoding | |
96 | { | |
97 | wxFONTENCODING_SYSTEM = -1, // system default | |
98 | wxFONTENCODING_DEFAULT, // current default encoding | |
99 | ||
100 | // ISO8859 standard defines a number of single-byte charsets | |
101 | wxFONTENCODING_ISO8859_1, // West European (Latin1) | |
102 | wxFONTENCODING_ISO8859_2, // Central and East European (Latin2) | |
103 | wxFONTENCODING_ISO8859_3, // Esperanto (Latin3) | |
104 | wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4) | |
105 | wxFONTENCODING_ISO8859_5, // Cyrillic | |
106 | wxFONTENCODING_ISO8859_6, // Arabic | |
107 | wxFONTENCODING_ISO8859_7, // Greek | |
108 | wxFONTENCODING_ISO8859_8, // Hebrew | |
109 | wxFONTENCODING_ISO8859_9, // Turkish (Latin5) | |
110 | wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6) | |
111 | wxFONTENCODING_ISO8859_11, // Thai | |
112 | wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it | |
113 | // here anyhow to make all ISO8859 | |
114 | // consecutive numbers | |
115 | wxFONTENCODING_ISO8859_13, // Baltic (Latin7) | |
116 | wxFONTENCODING_ISO8859_14, // Latin8 | |
117 | wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro) | |
118 | wxFONTENCODING_ISO8859_MAX, | |
119 | ||
120 | // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html) | |
56e63286 RD |
121 | wxFONTENCODING_KOI8, // KOI8 Russian |
122 | wxFONTENCODING_KOI8_U, // KOI8 Ukrainian | |
d14a1e28 RD |
123 | wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866 |
124 | wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria | |
125 | ||
126 | // what would we do without Microsoft? They have their own encodings | |
127 | // for DOS | |
128 | wxFONTENCODING_CP437, // original MS-DOS codepage | |
129 | wxFONTENCODING_CP850, // CP437 merged with Latin1 | |
130 | wxFONTENCODING_CP852, // CP437 merged with Latin2 | |
131 | wxFONTENCODING_CP855, // another cyrillic encoding | |
132 | wxFONTENCODING_CP866, // and another one | |
133 | // and for Windows | |
134 | wxFONTENCODING_CP874, // WinThai | |
135 | wxFONTENCODING_CP932, // Japanese (shift-JIS) | |
136 | wxFONTENCODING_CP936, // Chinese simplified (GB) | |
137 | wxFONTENCODING_CP949, // Korean (Hangul charset) | |
138 | wxFONTENCODING_CP950, // Chinese (traditional - Big5) | |
139 | wxFONTENCODING_CP1250, // WinLatin2 | |
140 | wxFONTENCODING_CP1251, // WinCyrillic | |
141 | wxFONTENCODING_CP1252, // WinLatin1 | |
142 | wxFONTENCODING_CP1253, // WinGreek (8859-7) | |
143 | wxFONTENCODING_CP1254, // WinTurkish | |
144 | wxFONTENCODING_CP1255, // WinHebrew | |
145 | wxFONTENCODING_CP1256, // WinArabic | |
146 | wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7) | |
147 | wxFONTENCODING_CP12_MAX, | |
148 | ||
149 | wxFONTENCODING_UTF7, // UTF-7 Unicode encoding | |
150 | wxFONTENCODING_UTF8, // UTF-8 Unicode encoding | |
151 | wxFONTENCODING_EUC_JP, // Extended Unix Codepage for Japanese | |
152 | wxFONTENCODING_UTF16BE, // UTF-16 Big Endian Unicode encoding | |
153 | wxFONTENCODING_UTF16LE, // UTF-16 Little Endian Unicode encoding | |
154 | wxFONTENCODING_UTF32BE, // UTF-32 Big Endian Unicode encoding | |
155 | wxFONTENCODING_UTF32LE, // UTF-32 Little Endian Unicode encoding | |
156 | ||
9cca52ba | 157 | wxFONTENCODING_MACROMAN, // the standard mac encodings |
c5f01dea RD |
158 | wxFONTENCODING_MACJAPANESE, |
159 | wxFONTENCODING_MACCHINESETRAD, | |
160 | wxFONTENCODING_MACKOREAN, | |
161 | wxFONTENCODING_MACARABIC, | |
162 | wxFONTENCODING_MACHEBREW, | |
163 | wxFONTENCODING_MACGREEK, | |
164 | wxFONTENCODING_MACCYRILLIC, | |
165 | wxFONTENCODING_MACDEVANAGARI, | |
166 | wxFONTENCODING_MACGURMUKHI, | |
167 | wxFONTENCODING_MACGUJARATI, | |
168 | wxFONTENCODING_MACORIYA, | |
169 | wxFONTENCODING_MACBENGALI, | |
170 | wxFONTENCODING_MACTAMIL, | |
171 | wxFONTENCODING_MACTELUGU, | |
172 | wxFONTENCODING_MACKANNADA, | |
173 | wxFONTENCODING_MACMALAJALAM, | |
174 | wxFONTENCODING_MACSINHALESE, | |
175 | wxFONTENCODING_MACBURMESE, | |
176 | wxFONTENCODING_MACKHMER, | |
177 | wxFONTENCODING_MACTHAI, | |
178 | wxFONTENCODING_MACLAOTIAN, | |
179 | wxFONTENCODING_MACGEORGIAN, | |
180 | wxFONTENCODING_MACARMENIAN, | |
181 | wxFONTENCODING_MACCHINESESIMP, | |
182 | wxFONTENCODING_MACTIBETAN, | |
183 | wxFONTENCODING_MACMONGOLIAN, | |
184 | wxFONTENCODING_MACETHIOPIC, | |
185 | wxFONTENCODING_MACCENTRALEUR, | |
186 | wxFONTENCODING_MACVIATNAMESE, | |
187 | wxFONTENCODING_MACARABICEXT, | |
188 | wxFONTENCODING_MACSYMBOL, | |
189 | wxFONTENCODING_MACDINGBATS, | |
190 | wxFONTENCODING_MACTURKISH, | |
191 | wxFONTENCODING_MACCROATIAN, | |
192 | wxFONTENCODING_MACICELANDIC, | |
193 | wxFONTENCODING_MACROMANIAN, | |
194 | wxFONTENCODING_MACCELTIC, | |
195 | wxFONTENCODING_MACGAELIC, | |
196 | wxFONTENCODING_MACKEYBOARD, | |
9cca52ba RD |
197 | |
198 | wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN , | |
199 | wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD , | |
f0cd63d2 | 200 | |
d14a1e28 RD |
201 | wxFONTENCODING_MAX, // highest enumerated encoding value |
202 | ||
203 | ||
204 | // aliases for endian-dependent UTF encodings | |
205 | wxFONTENCODING_UTF16, // native UTF-16 | |
206 | wxFONTENCODING_UTF32, // native UTF-32 | |
207 | ||
208 | // alias for the native Unicode encoding on this platform | |
209 | // (this is used by wxEncodingConverter and wxUTFFile only for now) | |
210 | wxFONTENCODING_UNICODE = wxFONTENCODING_UTF16, | |
211 | ||
212 | // alternative names for Far Eastern encodings | |
213 | // Chinese | |
214 | wxFONTENCODING_GB2312 = wxFONTENCODING_CP936, // Simplified Chinese | |
215 | wxFONTENCODING_BIG5 = wxFONTENCODING_CP950, // Traditional Chinese | |
216 | ||
217 | // Japanese (see http://zsigri.tripod.com/fontboard/cjk/jis.html) | |
218 | wxFONTENCODING_SHIFT_JIS = wxFONTENCODING_CP932 // Shift JIS | |
219 | }; | |
220 | ||
221 | //--------------------------------------------------------------------------- | |
222 | %newgroup | |
223 | ||
224 | // wxNativeFontInfo is platform-specific font representation: this struct | |
225 | // should be considered as opaque font description only used by the native | |
226 | // functions, the user code can only get the objects of this type from | |
227 | // somewhere and pass it somewhere else (possibly save them somewhere using | |
228 | // ToString() and restore them using FromString()) | |
229 | struct wxNativeFontInfo | |
230 | { | |
231 | public: | |
232 | wxNativeFontInfo(); | |
233 | ~wxNativeFontInfo(); | |
234 | ||
235 | // reset to the default state | |
236 | void Init(); | |
237 | ||
238 | // init with the parameters of the given font | |
239 | void InitFromFont(const wxFont& font); | |
240 | ||
241 | // accessors and modifiers for the font elements | |
242 | int GetPointSize() const; | |
c5f01dea | 243 | wxSize GetPixelSize() const; |
d14a1e28 RD |
244 | wxFontStyle GetStyle() const; |
245 | wxFontWeight GetWeight() const; | |
246 | bool GetUnderlined() const; | |
247 | wxString GetFaceName() const; | |
248 | wxFontFamily GetFamily() const; | |
249 | wxFontEncoding GetEncoding() const; | |
250 | ||
251 | void SetPointSize(int pointsize); | |
c5f01dea | 252 | void SetPixelSize(const wxSize& pixelSize); |
d14a1e28 RD |
253 | void SetStyle(wxFontStyle style); |
254 | void SetWeight(wxFontWeight weight); | |
255 | void SetUnderlined(bool underlined); | |
256 | void SetFaceName(wxString facename); | |
257 | void SetFamily(wxFontFamily family); | |
258 | void SetEncoding(wxFontEncoding encoding); | |
259 | ||
260 | // it is important to be able to serialize wxNativeFontInfo objects to be | |
261 | // able to store them (in config file, for example) | |
262 | bool FromString(const wxString& s); | |
263 | wxString ToString() const; | |
264 | ||
265 | %extend { | |
266 | wxString __str__() { | |
267 | return self->ToString(); | |
268 | } | |
269 | } | |
270 | ||
271 | // we also want to present the native font descriptions to the user in some | |
272 | // human-readable form (it is not platform independent neither, but can | |
273 | // hopefully be understood by the user) | |
274 | bool FromUserString(const wxString& s); | |
275 | wxString ToUserString() const; | |
276 | }; | |
277 | ||
278 | ||
279 | ||
280 | ||
281 | struct wxNativeEncodingInfo | |
282 | { | |
283 | wxString facename; // may be empty meaning "any" | |
284 | wxFontEncoding encoding; // so that we know what this struct represents | |
285 | ||
286 | wxNativeEncodingInfo(); | |
287 | ~wxNativeEncodingInfo(); | |
c5f01dea | 288 | |
d14a1e28 RD |
289 | // this struct is saved in config by wxFontMapper, so it should know to |
290 | // serialise itself (implemented in platform-specific code) | |
291 | bool FromString(const wxString& s); | |
292 | wxString ToString() const; | |
293 | }; | |
294 | ||
295 | ||
296 | #ifndef __WXMSW__ | |
297 | // translate a wxFontEncoding into native encoding parameter (defined above), | |
298 | // returning a wxNativeEncodingInfo if an (exact) match could be found, NULL | |
299 | // otherwise. | |
300 | %inline %{ | |
301 | wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding) { | |
302 | static wxNativeEncodingInfo info; | |
303 | if ( wxGetNativeFontEncoding(encoding, &info) ) | |
304 | return &info; | |
305 | else | |
306 | return NULL; | |
307 | } | |
308 | %} | |
309 | ||
310 | // test for the existence of the font described by this facename/encoding, | |
dd9f7fea | 311 | // return True if such font(s) exist, False otherwise |
d14a1e28 RD |
312 | bool wxTestFontEncoding(const wxNativeEncodingInfo& info); |
313 | ||
314 | #else | |
315 | ||
316 | %inline %{ | |
317 | wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding) | |
81cfe5e1 | 318 | { wxPyRaiseNotImplemented(); return NULL; } |
c5f01dea | 319 | |
d14a1e28 | 320 | bool wxTestFontEncoding(const wxNativeEncodingInfo& info) |
a72f4631 | 321 | { wxPyRaiseNotImplemented(); return false; } |
d14a1e28 RD |
322 | %} |
323 | #endif | |
324 | ||
325 | //--------------------------------------------------------------------------- | |
326 | %newgroup | |
327 | ||
328 | // wxFontMapper manages user-definable correspondence between logical font | |
329 | // names and the fonts present on the machine. | |
330 | // | |
331 | // The default implementations of all functions will ask the user if they are | |
332 | // not capable of finding the answer themselves and store the answer in a | |
333 | // config file (configurable via SetConfigXXX functions). This behaviour may | |
dd9f7fea | 334 | // be disabled by giving the value of False to "interactive" parameter. |
d14a1e28 RD |
335 | // However, the functions will always consult the config file to allow the |
336 | // user-defined values override the default logic and there is no way to | |
337 | // disable this - which shouldn't be ever needed because if "interactive" was | |
dd9f7fea | 338 | // never True, the config file is never created anyhow. |
d14a1e28 RD |
339 | // |
340 | // This is a singleton class, font mapper objects can only be accessed using | |
341 | // wxFontMapper::Get(). | |
342 | ||
343 | class wxFontMapper | |
344 | { | |
345 | public: | |
346 | wxFontMapper(); | |
347 | ~wxFontMapper(); | |
348 | ||
349 | // return instance of the wxFontMapper singleton | |
350 | static wxFontMapper *Get(); | |
351 | // set the sigleton to 'mapper' instance and return previous one | |
352 | static wxFontMapper *Set(wxFontMapper *mapper); | |
353 | ||
354 | ||
355 | // returns the encoding for the given charset (in the form of RFC 2046) or | |
356 | // wxFONTENCODING_SYSTEM if couldn't decode it | |
357 | // | |
358 | // interactive parameter is ignored in the base class, we behave as if it | |
dd9f7fea | 359 | // were always False |
d14a1e28 | 360 | virtual wxFontEncoding CharsetToEncoding(const wxString& charset, |
a72f4631 | 361 | bool interactive = true); |
d14a1e28 RD |
362 | |
363 | ||
364 | // get the number of font encodings we know about | |
365 | static size_t GetSupportedEncodingsCount(); | |
366 | ||
367 | // get the n-th supported encoding | |
368 | static wxFontEncoding GetEncoding(size_t n); | |
369 | ||
370 | // return internal string identifier for the encoding (see also | |
371 | // GetEncodingDescription()) | |
372 | static wxString GetEncodingName(wxFontEncoding encoding); | |
373 | ||
374 | // return user-readable string describing the given encoding | |
375 | // | |
376 | // NB: hard-coded now, but might change later (read it from config?) | |
377 | static wxString GetEncodingDescription(wxFontEncoding encoding); | |
378 | ||
56e63286 RD |
379 | // find the encoding corresponding to the given name, inverse of |
380 | // GetEncodingName() and less general than CharsetToEncoding() | |
381 | // | |
382 | // returns wxFONTENCODING_MAX if the name is not a supported encoding | |
383 | static wxFontEncoding GetEncodingFromName(const wxString& name); | |
384 | ||
d14a1e28 RD |
385 | |
386 | // set the config object to use (may be NULL to use default) | |
387 | void SetConfig(wxConfigBase *config); | |
388 | ||
389 | // set the root config path to use (should be an absolute path) | |
390 | void SetConfigPath(const wxString& prefix); | |
391 | ||
392 | // return default config path | |
393 | static const wxString GetDefaultConfigPath(); | |
394 | ||
395 | ||
396 | ||
397 | // Find an alternative for the given encoding (which is supposed to not be | |
398 | // available on this system). If successful, returns the encoding otherwise | |
399 | // returns None. | |
400 | %extend { | |
401 | PyObject* GetAltForEncoding(wxFontEncoding encoding, | |
402 | const wxString& facename = wxPyEmptyString, | |
a72f4631 | 403 | bool interactive = true) { |
d14a1e28 RD |
404 | wxFontEncoding alt_enc; |
405 | if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive)) | |
406 | return PyInt_FromLong(alt_enc); | |
407 | else { | |
408 | Py_INCREF(Py_None); | |
409 | return Py_None; | |
410 | } | |
411 | } | |
412 | } | |
413 | ||
414 | ||
415 | // checks whether given encoding is available in given face or not. | |
56e63286 RD |
416 | // If no facename is given (default), return true if it's available in any |
417 | // facename at all. | |
d14a1e28 RD |
418 | bool IsEncodingAvailable(wxFontEncoding encoding, |
419 | const wxString& facename = wxPyEmptyString); | |
420 | ||
421 | // the parent window for modal dialogs | |
422 | void SetDialogParent(wxWindow *parent); | |
423 | ||
424 | // the title for the dialogs (note that default is quite reasonable) | |
425 | void SetDialogTitle(const wxString& title); | |
426 | ||
427 | }; | |
428 | ||
429 | ||
430 | ||
431 | //--------------------------------------------------------------------------- | |
432 | %newgroup | |
433 | ||
434 | ||
ab1f7d2a RD |
435 | MustHaveApp(wxFont); |
436 | MustHaveApp(wxFont::GetDefaultEncoding); | |
437 | MustHaveApp(wxFont::SetDefaultEncoding); | |
438 | ||
d14a1e28 RD |
439 | class wxFont : public wxGDIObject { |
440 | public: | |
b60f943b RD |
441 | %pythonPrepend wxFont "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']" |
442 | ||
d14a1e28 | 443 | wxFont( int pointSize, int family, int style, int weight, |
a72f4631 | 444 | bool underline=false, const wxString& face = wxPyEmptyString, |
d14a1e28 RD |
445 | wxFontEncoding encoding=wxFONTENCODING_DEFAULT); |
446 | ~wxFont(); | |
447 | ||
448 | %name(FontFromNativeInfo) wxFont(const wxNativeFontInfo& info); | |
449 | %extend { | |
450 | %name(FontFromNativeInfoString) wxFont(const wxString& info) { | |
451 | wxNativeFontInfo nfi; | |
452 | nfi.FromString(info); | |
453 | return new wxFont(nfi); | |
454 | } | |
455 | ||
456 | %name(Font2) wxFont(int pointSize, | |
b60f943b RD |
457 | wxFontFamily family, |
458 | int flags = wxFONTFLAG_DEFAULT, | |
459 | const wxString& face = wxPyEmptyString, | |
460 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) { | |
d14a1e28 RD |
461 | return wxFont::New(pointSize, family, flags, face, encoding); |
462 | } | |
463 | } | |
464 | ||
c5f01dea RD |
465 | // There is a real ctor for this on wxMSW, but not the others, so just use |
466 | // the factory funciton in all cases. | |
467 | %extend { | |
468 | %name(FontFromPixelSize) wxFont(const wxSize& pixelSize, | |
469 | int family, | |
470 | int style, | |
471 | int weight, | |
472 | bool underlined = false, | |
473 | const wxString& face = wxEmptyString, | |
474 | wxFontEncoding encoding = wxFONTENCODING_DEFAULT) { | |
475 | return wxFontBase::New(pixelSize, family, | |
476 | style, weight, underlined, | |
477 | face, encoding); | |
478 | } | |
479 | } | |
480 | ||
481 | ||
d14a1e28 RD |
482 | |
483 | // was the font successfully created? | |
484 | bool Ok() const; | |
485 | %pythoncode { def __nonzero__(self): return self.Ok() } | |
486 | ||
487 | // comparison | |
22faec7d | 488 | %extend { |
a72f4631 RD |
489 | bool __eq__(const wxFont* other) { return other ? (*self == *other) : false; } |
490 | bool __ne__(const wxFont* other) { return other ? (*self != *other) : true; } | |
22faec7d | 491 | } |
d14a1e28 RD |
492 | |
493 | // accessors: get the font characteristics | |
494 | virtual int GetPointSize() const; | |
c5f01dea RD |
495 | virtual wxSize GetPixelSize() const; |
496 | virtual bool IsUsingSizeInPixels() const; | |
d14a1e28 RD |
497 | virtual int GetFamily() const; |
498 | virtual int GetStyle() const; | |
499 | virtual int GetWeight() const; | |
500 | virtual bool GetUnderlined() const; | |
501 | virtual wxString GetFaceName() const; | |
502 | virtual wxFontEncoding GetEncoding() const; | |
503 | virtual const wxNativeFontInfo *GetNativeFontInfo() const; | |
504 | ||
505 | virtual bool IsFixedWidth() const; | |
506 | ||
507 | wxString GetNativeFontInfoDesc() const; | |
508 | wxString GetNativeFontInfoUserDesc() const; | |
509 | ||
510 | // change the font characteristics | |
511 | virtual void SetPointSize( int pointSize ); | |
c5f01dea | 512 | virtual void SetPixelSize( const wxSize& pixelSize ); |
d14a1e28 RD |
513 | virtual void SetFamily( int family ); |
514 | virtual void SetStyle( int style ); | |
515 | virtual void SetWeight( int weight ); | |
516 | virtual void SetFaceName( const wxString& faceName ); | |
517 | virtual void SetUnderlined( bool underlined ); | |
518 | virtual void SetEncoding(wxFontEncoding encoding); | |
519 | void SetNativeFontInfo(const wxNativeFontInfo& info); | |
520 | %name(SetNativeFontInfoFromString) void SetNativeFontInfo(const wxString& info); | |
521 | void SetNativeFontInfoUserDesc(const wxString& info); | |
522 | ||
523 | // translate the fonts into human-readable string (i.e. GetStyleString() | |
524 | // will return "wxITALIC" for an italic font, ...) | |
525 | wxString GetFamilyString() const; | |
526 | wxString GetStyleString() const; | |
527 | wxString GetWeightString() const; | |
528 | ||
529 | // Unofficial API, don't use | |
a72f4631 | 530 | virtual void SetNoAntiAliasing( bool no = true ); |
5a319c5c | 531 | virtual bool GetNoAntiAliasing() const; |
d14a1e28 RD |
532 | |
533 | // the default encoding is used for creating all fonts with default | |
534 | // encoding parameter | |
535 | static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; } | |
536 | static void SetDefaultEncoding(wxFontEncoding encoding); | |
c5f01dea | 537 | }; |
d14a1e28 RD |
538 | |
539 | ||
540 | ||
541 | //--------------------------------------------------------------------------- | |
542 | %newgroup | |
543 | ||
544 | // wxFontEnumerator | |
545 | %{ | |
546 | class wxPyFontEnumerator : public wxFontEnumerator { | |
547 | public: | |
548 | wxPyFontEnumerator() {} | |
549 | ~wxPyFontEnumerator() {} | |
550 | ||
551 | DEC_PYCALLBACK_BOOL_STRING(OnFacename); | |
552 | DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding); | |
553 | ||
554 | PYPRIVATE; | |
555 | }; | |
556 | ||
557 | IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename); | |
558 | IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding); | |
559 | ||
560 | %} | |
561 | ||
ab1f7d2a RD |
562 | MustHaveApp(wxPyFontEnumerator); |
563 | ||
d14a1e28 RD |
564 | %name(FontEnumerator) class wxPyFontEnumerator { |
565 | public: | |
2b9048c5 | 566 | %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)" |
d14a1e28 RD |
567 | |
568 | wxPyFontEnumerator(); | |
569 | ~wxPyFontEnumerator(); | |
570 | void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref); | |
571 | ||
572 | bool EnumerateFacenames( | |
573 | wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all | |
a72f4631 | 574 | bool fixedWidthOnly = false); |
d14a1e28 RD |
575 | |
576 | bool EnumerateEncodings(const wxString& facename = wxPyEmptyString); | |
577 | ||
578 | //wxArrayString* GetEncodings(); | |
579 | //wxArrayString* GetFacenames(); | |
580 | %extend { | |
581 | PyObject* GetEncodings() { | |
582 | wxArrayString* arr = self->GetEncodings(); | |
5a319c5c RD |
583 | if (arr) |
584 | return wxArrayString2PyList_helper(*arr); | |
585 | else | |
586 | return PyList_New(0); | |
d14a1e28 RD |
587 | } |
588 | ||
589 | PyObject* GetFacenames() { | |
590 | wxArrayString* arr = self->GetFacenames(); | |
5a319c5c RD |
591 | if (arr) |
592 | return wxArrayString2PyList_helper(*arr); | |
593 | else | |
594 | return PyList_New(0); | |
d14a1e28 RD |
595 | } |
596 | } | |
597 | }; | |
598 | ||
599 | ||
600 | ||
601 | %init %{ | |
602 | wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator"); | |
603 | %} | |
604 | ||
605 | //--------------------------------------------------------------------------- |