]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/src/_font.i
adapt to wxGLCanvas changes
[wxWidgets.git] / wxPython / src / _font.i
... / ...
CommitLineData
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
28enum 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
42enum wxFontStyle
43{
44 wxFONTSTYLE_NORMAL = wxNORMAL,
45 wxFONTSTYLE_ITALIC = wxITALIC,
46 wxFONTSTYLE_SLANT = wxSLANT,
47 wxFONTSTYLE_MAX
48};
49
50// font weights
51enum 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
61enum
62{
63 // no special flags: font with default weight/slant/anti-aliasing
64 wxFONTFLAG_DEFAULT,
65
66 // slant flags (default: no slant)
67 wxFONTFLAG_ITALIC,
68 wxFONTFLAG_SLANT,
69
70 // weight flags (default: medium)
71 wxFONTFLAG_LIGHT,
72 wxFONTFLAG_BOLD,
73
74 // anti-aliasing flag: force on or off (default: the current system default)
75 wxFONTFLAG_ANTIALIASED,
76 wxFONTFLAG_NOT_ANTIALIASED,
77
78 // underlined/strikethrough flags (default: no lines)
79 wxFONTFLAG_UNDERLINED,
80 wxFONTFLAG_STRIKETHROUGH,
81
82 // the mask of all currently used flags
83 wxFONTFLAG_MASK
84};
85
86
87// font encodings
88enum 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)
114 wxFONTENCODING_KOI8, // KOI8 Russian
115 wxFONTENCODING_KOI8_U, // KOI8 Ukrainian
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
150 wxFONTENCODING_MACROMAN, // the standard mac encodings
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,
190
191 wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN ,
192 wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD ,
193
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())
222struct wxNativeFontInfo
223{
224public:
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;
236#ifdef __WXMSW__
237 wxSize GetPixelSize() const;
238#endif
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);
247#ifdef __WXMSW__
248 void SetPixelSize(const wxSize& pixelSize);
249#endif
250 void SetStyle(wxFontStyle style);
251 void SetWeight(wxFontWeight weight);
252 void SetUnderlined(bool underlined);
253 bool SetFaceName(wxString facename);
254 void SetFamily(wxFontFamily family);
255 void SetEncoding(wxFontEncoding encoding);
256
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
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
286struct 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();
293
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,
316// return True if such font(s) exist, False otherwise
317bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
318
319#else
320
321%inline %{
322 wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding)
323 { wxPyRaiseNotImplemented(); return NULL; }
324
325 bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
326 { wxPyRaiseNotImplemented(); return false; }
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
339// be disabled by giving the value of False to "interactive" parameter.
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
343// never True, the config file is never created anyhow.
344//
345// This is a singleton class, font mapper objects can only be accessed using
346// wxFontMapper::Get().
347
348class wxFontMapper
349{
350public:
351 wxFontMapper();
352 ~wxFontMapper();
353
354 // return instance of the wxFontMapper singleton
355 static wxFontMapper *Get();
356 // set the singleton to 'mapper' instance and return previous one
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
364 // were always False
365 virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
366 bool interactive = true);
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
375 // return canonical name of this encoding (this is a short string,
376 // GetEncodingDescription() returns a longer one)
377 static wxString GetEncodingName(wxFontEncoding encoding);
378
379// // return a list of all names of this encoding (see GetEncodingName)
380// static const wxChar** GetAllEncodingNames(wxFontEncoding encoding);
381
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
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
393
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,
408 bool interactive = true) {
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.
421 // If no facename is given (default), return true if it's available in any
422 // facename at all.
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 %property(AltForEncoding, GetAltForEncoding, doc="See `GetAltForEncoding`");
434};
435
436
437
438//---------------------------------------------------------------------------
439%newgroup
440
441
442MustHaveApp(wxFont);
443MustHaveApp(wxFont::GetDefaultEncoding);
444MustHaveApp(wxFont::SetDefaultEncoding);
445
446DocStr(wxFont,
447"A font is an object which determines the appearance of text. Fonts are
448used for drawing text to a device context, and setting the appearance
449of a window's text.
450
451You can retrieve the current system font settings with `wx.SystemSettings`.", "
452
453The 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
465The possible values for the weight parameter are:
466
467 ==================== ==
468 wx.FONTWEIGHT_NORMAL
469 wx.FONTWEIGHT_LIGHT
470 wx.FONTWEIGHT_BOLD
471 ==================== ==
472
473The 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
518class wxFont : public wxGDIObject {
519public:
520 %pythonPrepend wxFont "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']"
521
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", "");
554
555 ~wxFont();
556
557 %RenameDocCtor(
558 FontFromNativeInfo,
559 "Construct a `wx.Font` from a `wx.NativeFontInfo` object.", "",
560 wxFont(const wxNativeFontInfo& info));
561
562 %extend {
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 }
573 }
574
575
576 %extend {
577 %RenameDocCtor(
578 FFont,
579 "A bit of a simpler way to create a `wx.Font` using flags instead of
580individual attribute settings. The value of flags can be a
581combination 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 }
605
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
613platform API support for this then it is used, otherwise a font with
614the 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
633platform API support for this then it is used, otherwise a font with
634the 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 }
645 }
646
647
648
649 // was the font successfully created?
650 DocDeclStr(
651 bool , Ok() const,
652 "Returns ``True`` if this font was successfully created.", "");
653 %pythoncode { def __nonzero__(self): return self.Ok() }
654
655
656 // comparison
657 %extend {
658 bool __eq__(const wxFont* other) { return other ? (*self == *other) : false; }
659 bool __ne__(const wxFont* other) { return other ? (*self != *other) : true; }
660 }
661
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
670size.", "");
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
696string 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
706
707 DocDeclStr(
708 virtual bool , IsFixedWidth() const,
709 "Returns true if the font is a fixed width (or monospaced) font, false
710if it is a proportional one or font is invalid.", "");
711
712
713 DocDeclStr(
714 wxString , GetNativeFontInfoDesc() const,
715 "Returns the platform-dependent string completely describing this font
716or 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
722
723 // change the font characteristics
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
731support for this then it is used, otherwise a font with the closest
732size 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(
747 virtual bool , SetFaceName( const wxString& faceName ),
748 "Sets the facename for the font. The facename, which should be a valid
749font installed on the end-user's system.
750
751To avoid portability problems, don't rely on a specific face, but
752specify the font family instead or as well. A suitable font will be
753found on the end-user's system. If both the family and the facename
754are specified, wxWidgets will first search for the specific face, and
755then 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(
771 bool , SetNativeFontInfo(const wxString& info),
772 "Set the font's attributes from string representation of a
773`wx.NativeFontInfo` object.", "",
774 SetNativeFontInfoFromString);
775
776 DocDeclStr(
777 bool , SetNativeFontInfoUserDesc(const wxString& info),
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
795 virtual void SetNoAntiAliasing( bool no = true );
796 virtual bool GetNoAntiAliasing() const;
797
798 // the default encoding is used for creating all fonts with default
799 // encoding parameter
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.", "");
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`");
824
825};
826
827%pythoncode { Font2 = wx._deprecated(FFont, "Use `wx.FFont` instead.") }
828
829//---------------------------------------------------------------------------
830%newgroup
831
832// wxFontEnumerator
833%{
834class wxPyFontEnumerator : public wxFontEnumerator {
835public:
836 wxPyFontEnumerator() {}
837 ~wxPyFontEnumerator() {}
838
839 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
840 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
841
842 PYPRIVATE;
843};
844
845IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
846IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
847
848%}
849
850MustHaveApp(wxPyFontEnumerator);
851
852%rename(FontEnumerator) wxPyFontEnumerator;
853class wxPyFontEnumerator {
854public:
855 %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)"
856
857 wxPyFontEnumerator();
858 ~wxPyFontEnumerator();
859 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
860
861 bool EnumerateFacenames(
862 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
863 bool fixedWidthOnly = false);
864
865 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
866
867 %extend {
868 static PyObject* GetEncodings() {
869 PyObject* ret;
870 wxArrayString arr = wxFontEnumerator::GetEncodings();
871 wxPyBlock_t blocked = wxPyBeginBlockThreads();
872 ret = wxArrayString2PyList_helper(arr);
873 wxPyEndBlockThreads(blocked);
874 return ret;
875 }
876
877 static PyObject* GetFacenames() {
878 PyObject* ret;
879 wxArrayString arr = wxFontEnumerator::GetFacenames();
880 wxPyBlock_t blocked = wxPyBeginBlockThreads();
881 ret = wxArrayString2PyList_helper(arr);
882 wxPyEndBlockThreads(blocked);
883 return ret;
884 }
885 }
886
887 DocDeclStr(
888 static bool , IsValidFacename(const wxString &str),
889 "Convenience function that returns true if the given face name exist in
890the user's system", "");
891
892};
893
894
895
896%init %{
897 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
898%}
899
900//---------------------------------------------------------------------------