]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/_font.i
Added wxRichTextCtrl XRC handler
[wxWidgets.git] / wxPython / src / _font.i
CommitLineData
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
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
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
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)
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())
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;
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;
203bfdca
RD
281
282 %property(Encoding, GetEncoding, SetEncoding, doc="See `GetEncoding` and `SetEncoding`");
283 %property(FaceName, GetFaceName, SetFaceName, doc="See `GetFaceName` and `SetFaceName`");
284 %property(Family, GetFamily, SetFamily, doc="See `GetFamily` and `SetFamily`");
285 %property(PointSize, GetPointSize, SetPointSize, doc="See `GetPointSize` and `SetPointSize`");
286 %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`");
287 %property(Underlined, GetUnderlined, SetUnderlined, doc="See `GetUnderlined` and `SetUnderlined`");
288 %property(Weight, GetWeight, SetWeight, doc="See `GetWeight` and `SetWeight`");
d14a1e28
RD
289};
290
291
292
293
294struct wxNativeEncodingInfo
295{
296 wxString facename; // may be empty meaning "any"
297 wxFontEncoding encoding; // so that we know what this struct represents
298
299 wxNativeEncodingInfo();
300 ~wxNativeEncodingInfo();
c5f01dea 301
d14a1e28
RD
302 // this struct is saved in config by wxFontMapper, so it should know to
303 // serialise itself (implemented in platform-specific code)
304 bool FromString(const wxString& s);
305 wxString ToString() const;
306};
307
308
309#ifndef __WXMSW__
310// translate a wxFontEncoding into native encoding parameter (defined above),
311// returning a wxNativeEncodingInfo if an (exact) match could be found, NULL
312// otherwise.
313%inline %{
314 wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding) {
315 static wxNativeEncodingInfo info;
316 if ( wxGetNativeFontEncoding(encoding, &info) )
317 return &info;
318 else
319 return NULL;
320 }
321%}
322
323// test for the existence of the font described by this facename/encoding,
dd9f7fea 324// return True if such font(s) exist, False otherwise
d14a1e28
RD
325bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
326
327#else
328
329%inline %{
330 wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding)
81cfe5e1 331 { wxPyRaiseNotImplemented(); return NULL; }
c5f01dea 332
d14a1e28 333 bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
a72f4631 334 { wxPyRaiseNotImplemented(); return false; }
d14a1e28
RD
335%}
336#endif
337
338//---------------------------------------------------------------------------
339%newgroup
340
341// wxFontMapper manages user-definable correspondence between logical font
342// names and the fonts present on the machine.
343//
344// The default implementations of all functions will ask the user if they are
345// not capable of finding the answer themselves and store the answer in a
346// config file (configurable via SetConfigXXX functions). This behaviour may
dd9f7fea 347// be disabled by giving the value of False to "interactive" parameter.
d14a1e28
RD
348// However, the functions will always consult the config file to allow the
349// user-defined values override the default logic and there is no way to
350// disable this - which shouldn't be ever needed because if "interactive" was
dd9f7fea 351// never True, the config file is never created anyhow.
d14a1e28
RD
352//
353// This is a singleton class, font mapper objects can only be accessed using
354// wxFontMapper::Get().
355
356class wxFontMapper
357{
358public:
359 wxFontMapper();
360 ~wxFontMapper();
361
362 // return instance of the wxFontMapper singleton
363 static wxFontMapper *Get();
02b800ce 364 // set the singleton to 'mapper' instance and return previous one
d14a1e28
RD
365 static wxFontMapper *Set(wxFontMapper *mapper);
366
367
368 // returns the encoding for the given charset (in the form of RFC 2046) or
369 // wxFONTENCODING_SYSTEM if couldn't decode it
370 //
371 // interactive parameter is ignored in the base class, we behave as if it
dd9f7fea 372 // were always False
d14a1e28 373 virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
a72f4631 374 bool interactive = true);
d14a1e28
RD
375
376
377 // get the number of font encodings we know about
378 static size_t GetSupportedEncodingsCount();
379
380 // get the n-th supported encoding
381 static wxFontEncoding GetEncoding(size_t n);
382
02b800ce
RD
383 // return canonical name of this encoding (this is a short string,
384 // GetEncodingDescription() returns a longer one)
d14a1e28
RD
385 static wxString GetEncodingName(wxFontEncoding encoding);
386
02b800ce
RD
387// // return a list of all names of this encoding (see GetEncodingName)
388// static const wxChar** GetAllEncodingNames(wxFontEncoding encoding);
389
d14a1e28
RD
390 // return user-readable string describing the given encoding
391 //
392 // NB: hard-coded now, but might change later (read it from config?)
393 static wxString GetEncodingDescription(wxFontEncoding encoding);
394
56e63286
RD
395 // find the encoding corresponding to the given name, inverse of
396 // GetEncodingName() and less general than CharsetToEncoding()
397 //
398 // returns wxFONTENCODING_MAX if the name is not a supported encoding
399 static wxFontEncoding GetEncodingFromName(const wxString& name);
400
d14a1e28 401
d14a1e28
RD
402 // set the root config path to use (should be an absolute path)
403 void SetConfigPath(const wxString& prefix);
404
405 // return default config path
406 static const wxString GetDefaultConfigPath();
407
408
409
410 // Find an alternative for the given encoding (which is supposed to not be
411 // available on this system). If successful, returns the encoding otherwise
412 // returns None.
413 %extend {
414 PyObject* GetAltForEncoding(wxFontEncoding encoding,
415 const wxString& facename = wxPyEmptyString,
a72f4631 416 bool interactive = true) {
d14a1e28
RD
417 wxFontEncoding alt_enc;
418 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
419 return PyInt_FromLong(alt_enc);
420 else {
421 Py_INCREF(Py_None);
422 return Py_None;
423 }
424 }
425 }
426
427
428 // checks whether given encoding is available in given face or not.
56e63286
RD
429 // If no facename is given (default), return true if it's available in any
430 // facename at all.
d14a1e28
RD
431 bool IsEncodingAvailable(wxFontEncoding encoding,
432 const wxString& facename = wxPyEmptyString);
433
434 // the parent window for modal dialogs
435 void SetDialogParent(wxWindow *parent);
436
437 // the title for the dialogs (note that default is quite reasonable)
438 void SetDialogTitle(const wxString& title);
439
42e2bbb9
RD
440
441 %property(AltForEncoding, GetAltForEncoding, doc="See `GetAltForEncoding`");
d14a1e28
RD
442};
443
444
445
446//---------------------------------------------------------------------------
447%newgroup
448
449
ab1f7d2a
RD
450MustHaveApp(wxFont);
451MustHaveApp(wxFont::GetDefaultEncoding);
452MustHaveApp(wxFont::SetDefaultEncoding);
453
5e4c653f
RD
454DocStr(wxFont,
455"A font is an object which determines the appearance of text. Fonts are
456used for drawing text to a device context, and setting the appearance
457of a window's text.
458
459You can retrieve the current system font settings with `wx.SystemSettings`.", "
460
461The possible values for the family parameter of wx.Font constructor are:
462
463 ======================== =============================
464 wx.FONTFAMILY_DEFAULT Chooses a default font.
465 wx.FONTFAMILY_DECORATIVE A decorative font.
466 wx.FONTFAMILY_ROMAN A formal, serif font.
467 wx.FONTFAMILY_SCRIPT A handwriting font.
468 wx.FONTFAMILY_SWISS A sans-serif font.
469 wx.FONTFAMILY_MODERN Usually a fixed pitch font.
470 wx.FONTFAMILY_TELETYPE A teletype font.
471 ======================== =============================
472
473The possible values for the weight parameter are:
474
475 ==================== ==
476 wx.FONTWEIGHT_NORMAL
477 wx.FONTWEIGHT_LIGHT
478 wx.FONTWEIGHT_BOLD
479 ==================== ==
480
481The known font encodings are:
482
483 =========================== ====================================
484 wx.FONTENCODING_SYSTEM system default
485 wx.FONTENCODING_DEFAULT current default encoding
486 wx.FONTENCODING_ISO8859_1 West European (Latin1)
487 wx.FONTENCODING_ISO8859_2 Central and East European (Latin2)
488 wx.FONTENCODING_ISO8859_3 Esperanto (Latin3)
489 wx.FONTENCODING_ISO8859_4 Baltic (old) (Latin4)
490 wx.FONTENCODING_ISO8859_5 Cyrillic
491 wx.FONTENCODING_ISO8859_6 Arabic
492 wx.FONTENCODING_ISO8859_7 Greek
493 wx.FONTENCODING_ISO8859_8 Hebrew
494 wx.FONTENCODING_ISO8859_9 Turkish (Latin5)
495 wx.FONTENCODING_ISO8859_10 Variation of Latin4 (Latin6)
496 wx.FONTENCODING_ISO8859_11 Thai
497 wx.FONTENCODING_ISO8859_12 doesn't exist currently, but put it
498 here anyhow to make all ISO8859
499 consecutive numbers
500 wx.FONTENCODING_ISO8859_13 Baltic (Latin7)
501 wx.FONTENCODING_ISO8859_14 Latin8
502 wx.FONTENCODING_ISO8859_15 Latin9 (a.k.a. Latin0, includes euro)
503 wx.FONTENCODING_KOI8 Cyrillic charset
504 wx.FONTENCODING_ALTERNATIVE same as MS-DOS CP866
505 wx.FONTENCODING_BULGARIAN used under Linux in Bulgaria
506 wx.FONTENCODING_CP437 original MS-DOS codepage
507 wx.FONTENCODING_CP850 CP437 merged with Latin1
508 wx.FONTENCODING_CP852 CP437 merged with Latin2
509 wx.FONTENCODING_CP855 another cyrillic encoding
510 wx.FONTENCODING_CP866 and another one
511 wx.FONTENCODING_CP874 WinThai
512 wx.FONTENCODING_CP1250 WinLatin2
513 wx.FONTENCODING_CP1251 WinCyrillic
514 wx.FONTENCODING_CP1252 WinLatin1
515 wx.FONTENCODING_CP1253 WinGreek (8859-7)
516 wx.FONTENCODING_CP1254 WinTurkish
517 wx.FONTENCODING_CP1255 WinHebrew
518 wx.FONTENCODING_CP1256 WinArabic
519 wx.FONTENCODING_CP1257 WinBaltic (same as Latin 7)
520 wx.FONTENCODING_UTF7 UTF-7 Unicode encoding
521 wx.FONTENCODING_UTF8 UTF-8 Unicode encoding
522 =========================== ====================================
523
524");
525
d14a1e28
RD
526class wxFont : public wxGDIObject {
527public:
b60f943b
RD
528 %pythonPrepend wxFont "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']"
529
5e4c653f
RD
530 DocCtorStr(
531 wxFont( int pointSize, int family, int style, int weight,
532 bool underline=false, const wxString& face = wxPyEmptyString,
533 wxFontEncoding encoding = wxFONTENCODING_DEFAULT),
534 "Creates a font object with the specified attributes.
535
536 :param pointSize: The size of the font in points.
537
538 :param family: Font family. A generic way of referring to fonts
539 without specifying actual facename. It can be One of
540 the ``wx.FONTFAMILY_xxx`` constants.
541
542 :param style: One of the ``wx.FONTSTYLE_xxx`` constants.
543
544 :param weight: Font weight, sometimes also referred to as font
545 boldness. One of the ``wx.FONTWEIGHT_xxx`` constants.
546
547 :param underline: The value can be ``True`` or ``False`` and
548 indicates whether the font will include an underline. This
549 may not be supported on all platforms.
550
551 :param face: An optional string specifying the actual typeface to
552 be used. If it is an empty string, a default typeface will be
553 chosen based on the family.
554
555 :param encoding: An encoding which may be one of the
556 ``wx.FONTENCODING_xxx`` constants. If the specified encoding isn't
557 available, no font is created.
558
559:see: `wx.FFont`, `wx.FontFromPixelSize`, `wx.FFontFromPixelSize`,
560 `wx.FontFromNativeInfoString`, `wx.FontFromNativeInfo`
561", "");
293dc374 562
d14a1e28
RD
563 ~wxFont();
564
5e4c653f
RD
565 %RenameDocCtor(
566 FontFromNativeInfo,
567 "Construct a `wx.Font` from a `wx.NativeFontInfo` object.", "",
568 wxFont(const wxNativeFontInfo& info));
569
d14a1e28 570 %extend {
5e4c653f
RD
571 %RenameDocCtor(
572 FontFromNativeInfoString,
573 "Construct a `wx.Font` from the string representation of a
574`wx.NativeFontInfo` object.", "",
575 wxFont(const wxString& info))
576 {
577 wxNativeFontInfo nfi;
578 nfi.FromString(info);
579 return new wxFont(nfi);
580 }
d14a1e28
RD
581 }
582
5e4c653f
RD
583
584 %extend {
585 %RenameDocCtor(
586 FFont,
587 "A bit of a simpler way to create a `wx.Font` using flags instead of
588individual attribute settings. The value of flags can be a
589combination of the following:
590
591 ============================ ==
592 wx.FONTFLAG_DEFAULT
593 wx.FONTFLAG_ITALIC
594 wx.FONTFLAG_SLANT
595 wx.FONTFLAG_LIGHT
596 wx.FONTFLAG_BOLD
597 wx.FONTFLAG_ANTIALIASED
598 wx.FONTFLAG_NOT_ANTIALIASED
599 wx.FONTFLAG_UNDERLINED
600 wx.FONTFLAG_STRIKETHROUGH
601 ============================ ==
602
603:see: `wx.Font.__init__`", "",
604
605 wxFont(int pointSize,
606 wxFontFamily family,
607 int flags = wxFONTFLAG_DEFAULT,
608 const wxString& face = wxPyEmptyString,
609 wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
610 {
611 return wxFont::New(pointSize, family, flags, face, encoding);
612 }
293dc374 613
5e4c653f
RD
614
615 // There is a real ctor for this on wxMSW, but not the others, so just
616 // use the factory function in all cases.
617
618 %RenameDocCtor(
619 FontFromPixelSize,
620 "Creates a font using a size in pixels rather than points. If there is
621platform API support for this then it is used, otherwise a font with
622the closest size is found using a binary search.
623
624:see: `wx.Font.__init__`", "",
625 wxFont(const wxSize& pixelSize,
626 int family,
627 int style,
628 int weight,
629 bool underlined = false,
630 const wxString& face = wxEmptyString,
631 wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
632 {
633 return wxFontBase::New(pixelSize, family,
634 style, weight, underlined,
635 face, encoding);
636 }
637
638 %RenameDocCtor(
639 FFontFromPixelSize,
640 "Creates a font using a size in pixels rather than points. If there is
641platform API support for this then it is used, otherwise a font with
642the closest size is found using a binary search.
643
644:see: `wx.Font.__init__`, `wx.FFont`", "",
645 wxFont(const wxSize& pixelSize,
646 wxFontFamily family,
647 int flags = wxFONTFLAG_DEFAULT,
648 const wxString& face = wxEmptyString,
649 wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
650 {
651 return wxFontBase::New(pixelSize, family, flags, face, encoding);
652 }
c5f01dea
RD
653 }
654
655
d14a1e28
RD
656
657 // was the font successfully created?
5e4c653f 658 DocDeclStr(
6c2dd16f 659 bool , IsOk() const,
5e4c653f 660 "Returns ``True`` if this font was successfully created.", "");
6c2dd16f
RD
661 %pythoncode { Ok = IsOk }
662 %pythoncode { def __nonzero__(self): return self.IsOk() }
d14a1e28 663
5e4c653f 664
d14a1e28 665 // comparison
22faec7d 666 %extend {
a72f4631
RD
667 bool __eq__(const wxFont* other) { return other ? (*self == *other) : false; }
668 bool __ne__(const wxFont* other) { return other ? (*self != *other) : true; }
22faec7d 669 }
d14a1e28 670
5e4c653f
RD
671
672 DocDeclStr(
673 virtual int , GetPointSize() const,
674 "Gets the point size.", "");
675
676 DocDeclStr(
677 virtual wxSize , GetPixelSize() const,
678 "Returns the size in pixels if the font was constructed with a pixel
679size.", "");
680
681 DocDeclStr(
682 virtual bool , IsUsingSizeInPixels() const,
683 "Returns ``True`` if the font is using a pixelSize.", "");
684
685
686 DocDeclStr(
687 virtual int , GetFamily() const,
688 "Gets the font family. ", "");
689
690 DocDeclStr(
691 virtual int , GetStyle() const,
692 "Gets the font style.", "");
693
694 DocDeclStr(
695 virtual int , GetWeight() const,
696 "Gets the font weight. ", "");
697
698 DocDeclStr(
699 virtual bool , GetUnderlined() const,
700 "Returns ``True`` if the font is underlined, ``False`` otherwise.", "");
701
702 DocDeclStr(
703 virtual wxString , GetFaceName() const,
704 "Returns the typeface name associated with the font, or the empty
705string if there is no typeface information.", "");
706
707 DocDeclStr(
708 virtual wxFontEncoding , GetEncoding() const,
709 "Get the font's encoding.", "");
710
711 DocDeclStr(
712 virtual const wxNativeFontInfo *, GetNativeFontInfo() const,
713 "Constructs a `wx.NativeFontInfo` object from this font.", "");
714
d14a1e28 715
5e4c653f
RD
716 DocDeclStr(
717 virtual bool , IsFixedWidth() const,
718 "Returns true if the font is a fixed width (or monospaced) font, false
719if it is a proportional one or font is invalid.", "");
720
d14a1e28 721
5e4c653f
RD
722 DocDeclStr(
723 wxString , GetNativeFontInfoDesc() const,
724 "Returns the platform-dependent string completely describing this font
725or an empty string if the font isn't valid.", "");
726
727 DocDeclStr(
728 wxString , GetNativeFontInfoUserDesc() const,
729 "Returns a human readable version of `GetNativeFontInfoDesc`.", "");
730
d14a1e28
RD
731
732 // change the font characteristics
5e4c653f
RD
733 DocDeclStr(
734 virtual void , SetPointSize( int pointSize ),
735 "Sets the point size.", "");
736
737 DocDeclStr(
738 virtual void , SetPixelSize( const wxSize& pixelSize ),
739 "Sets the size in pixels rather than points. If there is platform API
740support for this then it is used, otherwise a font with the closest
741size is found using a binary search.", "");
742
743 DocDeclStr(
744 virtual void , SetFamily( int family ),
745 "Sets the font family.", "");
746
747 DocDeclStr(
748 virtual void , SetStyle( int style ),
749 "Sets the font style.", "");
750
751 DocDeclStr(
752 virtual void , SetWeight( int weight ),
753 "Sets the font weight.", "");
754
755 DocDeclStr(
d0e2ede0 756 virtual bool , SetFaceName( const wxString& faceName ),
5e4c653f
RD
757 "Sets the facename for the font. The facename, which should be a valid
758font installed on the end-user's system.
759
760To avoid portability problems, don't rely on a specific face, but
761specify the font family instead or as well. A suitable font will be
762found on the end-user's system. If both the family and the facename
763are specified, wxWidgets will first search for the specific face, and
764then for a font belonging to the same family.", "");
765
766 DocDeclStr(
767 virtual void , SetUnderlined( bool underlined ),
768 "Sets underlining.", "");
769
770 DocDeclStr(
771 virtual void , SetEncoding(wxFontEncoding encoding),
772 "Set the font encoding.", "");
773
774 DocDeclStr(
775 void , SetNativeFontInfo(const wxNativeFontInfo& info),
776 "Set the font's attributes from a `wx.NativeFontInfo` object.", "");
777
778
779 DocDeclStrName(
d0e2ede0 780 bool , SetNativeFontInfo(const wxString& info),
5e4c653f
RD
781 "Set the font's attributes from string representation of a
782`wx.NativeFontInfo` object.", "",
783 SetNativeFontInfoFromString);
784
785 DocDeclStr(
d0e2ede0 786 bool , SetNativeFontInfoUserDesc(const wxString& info),
5e4c653f
RD
787 "Set the font's attributes from a string formerly returned from
788`GetNativeFontInfoDesc`.", "");
789
790
791 DocDeclStr(
792 wxString , GetFamilyString() const,
793 "Returns a string representation of the font family.", "");
794
795 DocDeclStr(
796 wxString , GetStyleString() const,
797 "Returns a string representation of the font style.", "");
798
799 DocDeclStr(
800 wxString , GetWeightString() const,
801 "Return a string representation of the font weight.", "");
802
803
a72f4631 804 virtual void SetNoAntiAliasing( bool no = true );
5a319c5c 805 virtual bool GetNoAntiAliasing() const;
d14a1e28
RD
806
807 // the default encoding is used for creating all fonts with default
808 // encoding parameter
5e4c653f
RD
809 DocDeclStr(
810 static wxFontEncoding , GetDefaultEncoding(),
811 "Returns the encoding used for all fonts created with an encoding of
812``wx.FONTENCODING_DEFAULT``.", "");
813
814 DocDeclStr(
815 static void , SetDefaultEncoding(wxFontEncoding encoding),
816 "Sets the default font encoding.", "");
42e2bbb9
RD
817
818 %property(Encoding, GetEncoding, SetEncoding, doc="See `GetEncoding` and `SetEncoding`");
819 %property(FaceName, GetFaceName, SetFaceName, doc="See `GetFaceName` and `SetFaceName`");
820 %property(Family, GetFamily, SetFamily, doc="See `GetFamily` and `SetFamily`");
821 %property(FamilyString, GetFamilyString, doc="See `GetFamilyString`");
822 %property(NativeFontInfo, GetNativeFontInfo, SetNativeFontInfo, doc="See `GetNativeFontInfo` and `SetNativeFontInfo`");
823 %property(NativeFontInfoDesc, GetNativeFontInfoDesc, doc="See `GetNativeFontInfoDesc`");
824 %property(NativeFontInfoUserDesc, GetNativeFontInfoUserDesc, SetNativeFontInfoUserDesc, doc="See `GetNativeFontInfoUserDesc` and `SetNativeFontInfoUserDesc`");
825 %property(NoAntiAliasing, GetNoAntiAliasing, SetNoAntiAliasing, doc="See `GetNoAntiAliasing` and `SetNoAntiAliasing`");
826 %property(PixelSize, GetPixelSize, SetPixelSize, doc="See `GetPixelSize` and `SetPixelSize`");
827 %property(PointSize, GetPointSize, SetPointSize, doc="See `GetPointSize` and `SetPointSize`");
828 %property(Style, GetStyle, SetStyle, doc="See `GetStyle` and `SetStyle`");
829 %property(StyleString, GetStyleString, doc="See `GetStyleString`");
830 %property(Underlined, GetUnderlined, SetUnderlined, doc="See `GetUnderlined` and `SetUnderlined`");
831 %property(Weight, GetWeight, SetWeight, doc="See `GetWeight` and `SetWeight`");
832 %property(WeightString, GetWeightString, doc="See `GetWeightString`");
5e4c653f 833
c5f01dea 834};
d14a1e28 835
5e4c653f 836%pythoncode { Font2 = wx._deprecated(FFont, "Use `wx.FFont` instead.") }
d14a1e28
RD
837
838//---------------------------------------------------------------------------
839%newgroup
840
841// wxFontEnumerator
842%{
843class wxPyFontEnumerator : public wxFontEnumerator {
844public:
845 wxPyFontEnumerator() {}
846 ~wxPyFontEnumerator() {}
847
848 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
849 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
850
851 PYPRIVATE;
852};
853
854IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
855IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
856
857%}
858
ab1f7d2a
RD
859MustHaveApp(wxPyFontEnumerator);
860
1b8c7ba6
RD
861%rename(FontEnumerator) wxPyFontEnumerator;
862class wxPyFontEnumerator {
d14a1e28 863public:
2b9048c5 864 %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)"
d14a1e28
RD
865
866 wxPyFontEnumerator();
867 ~wxPyFontEnumerator();
868 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
869
870 bool EnumerateFacenames(
871 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
a72f4631 872 bool fixedWidthOnly = false);
d14a1e28
RD
873
874 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
875
d14a1e28 876 %extend {
d0e2ede0 877 static PyObject* GetEncodings() {
e6f85a85 878 PyObject* ret;
d0e2ede0 879 wxArrayString arr = wxFontEnumerator::GetEncodings();
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 886 static PyObject* GetFacenames() {
e6f85a85 887 PyObject* ret;
d0e2ede0 888 wxArrayString arr = wxFontEnumerator::GetFacenames();
e6f85a85 889 wxPyBlock_t blocked = wxPyBeginBlockThreads();
d0e2ede0 890 ret = wxArrayString2PyList_helper(arr);
e6f85a85
RD
891 wxPyEndBlockThreads(blocked);
892 return ret;
d14a1e28
RD
893 }
894 }
d0e2ede0
RD
895
896 DocDeclStr(
897 static bool , IsValidFacename(const wxString &str),
898 "Convenience function that returns true if the given face name exist in
899the user's system", "");
900
d14a1e28
RD
901};
902
903
904
905%init %{
906 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
907%}
908
909//---------------------------------------------------------------------------