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