]> git.saurik.com Git - wxWidgets.git/blame - wxPython/src/fonts.i
Added a few new flags, etc.
[wxWidgets.git] / wxPython / src / fonts.i
CommitLineData
68bc8549
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: fonts.i
3// Purpose: SWIG interface file wxFont, local, converters, etc.
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
14%module fonts
15
16%{
17#include "helpers.h"
18#include <wx/fontmap.h>
19#include <wx/fontenc.h>
20#include <wx/fontmap.h>
21#include <wx/fontutil.h>
22#include <wx/fontenum.h>
23#include <wx/intl.h>
24#include <wx/encconv.h>
25%}
26
27//----------------------------------------------------------------------
28
29%include typemaps.i
30%include my_typemaps.i
31
32// Import some definitions of other classes, etc.
33%import _defs.i
34%import misc.i
35
36
37//---------------------------------------------------------------------------
38%{
39 // Put some wx default wxChar* values into wxStrings.
40 static const wxString wxPyEmptyString(wxT(""));
41%}
42//---------------------------------------------------------------------------
43
44
45
46enum wxFontFamily
47{
48 wxFONTFAMILY_DEFAULT = wxDEFAULT,
49 wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
50 wxFONTFAMILY_ROMAN = wxROMAN,
51 wxFONTFAMILY_SCRIPT = wxSCRIPT,
52 wxFONTFAMILY_SWISS = wxSWISS,
53 wxFONTFAMILY_MODERN = wxMODERN,
54 wxFONTFAMILY_TELETYPE = wxTELETYPE,
55 wxFONTFAMILY_MAX,
56 wxFONTFAMILY_UNKNOWN
57};
58
59// font styles
60enum wxFontStyle
61{
62 wxFONTSTYLE_NORMAL = wxNORMAL,
63 wxFONTSTYLE_ITALIC = wxITALIC,
64 wxFONTSTYLE_SLANT = wxSLANT,
65 wxFONTSTYLE_MAX
66};
67
68// font weights
69enum wxFontWeight
70{
71 wxFONTWEIGHT_NORMAL = wxNORMAL,
72 wxFONTWEIGHT_LIGHT = wxLIGHT,
73 wxFONTWEIGHT_BOLD = wxBOLD,
74 wxFONTWEIGHT_MAX
75};
76
77
78// font encodings
79enum wxFontEncoding
80{
81 wxFONTENCODING_SYSTEM = -1, // system default
82 wxFONTENCODING_DEFAULT, // current default encoding
83
84 // ISO8859 standard defines a number of single-byte charsets
85 wxFONTENCODING_ISO8859_1, // West European (Latin1)
86 wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
87 wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
88 wxFONTENCODING_ISO8859_4, // Baltic (old) (Latin4)
89 wxFONTENCODING_ISO8859_5, // Cyrillic
90 wxFONTENCODING_ISO8859_6, // Arabic
91 wxFONTENCODING_ISO8859_7, // Greek
92 wxFONTENCODING_ISO8859_8, // Hebrew
93 wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
94 wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
95 wxFONTENCODING_ISO8859_11, // Thai
96 wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
97 // here anyhow to make all ISO8859
98 // consecutive numbers
99 wxFONTENCODING_ISO8859_13, // Baltic (Latin7)
100 wxFONTENCODING_ISO8859_14, // Latin8
101 wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
102 wxFONTENCODING_ISO8859_MAX,
103
104 // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
105 wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
106 wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
107 wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
108
109 // what would we do without Microsoft? They have their own encodings
110 // for DOS
111 wxFONTENCODING_CP437, // original MS-DOS codepage
112 wxFONTENCODING_CP850, // CP437 merged with Latin1
113 wxFONTENCODING_CP852, // CP437 merged with Latin2
114 wxFONTENCODING_CP855, // another cyrillic encoding
115 wxFONTENCODING_CP866, // and another one
116 // and for Windows
117 wxFONTENCODING_CP874, // WinThai
118 wxFONTENCODING_CP932, // Japanese (shift-JIS)
119 wxFONTENCODING_CP936, // Chiniese simplified (GB)
120 wxFONTENCODING_CP949, // Korean (Hangul charset)
121 wxFONTENCODING_CP950, // Chinese (traditional - Big5)
122 wxFONTENCODING_CP1250, // WinLatin2
123 wxFONTENCODING_CP1251, // WinCyrillic
124 wxFONTENCODING_CP1252, // WinLatin1
125 wxFONTENCODING_CP1253, // WinGreek (8859-7)
126 wxFONTENCODING_CP1254, // WinTurkish
127 wxFONTENCODING_CP1255, // WinHebrew
128 wxFONTENCODING_CP1256, // WinArabic
129 wxFONTENCODING_CP1257, // WinBaltic (same as Latin 7)
130 wxFONTENCODING_CP12_MAX,
131
132 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
133 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
134
135 wxFONTENCODING_UNICODE, // Unicode - currently used only by
136 // wxEncodingConverter class
137
138 wxFONTENCODING_MAX
139};
140
141
142
143//---------------------------------------------------------------------------
144// wxNativeFontInfo is platform-specific font representation: this struct
145// should be considered as opaque font description only used by the native
146// functions, the user code can only get the objects of this type from
147// somewhere and pass it somewhere else (possibly save them somewhere using
148// ToString() and restore them using FromString())
149struct wxNativeFontInfo
150{
151#ifdef __WXGTK__
152 // init the elements from an XLFD, return TRUE if ok
153 bool FromXFontName(const wxString& xFontName);
154
155 // return false if we were never initialized with a valid XLFD
156 bool IsDefault() const;
157
158 // generate an XLFD using the fontElements
159 wxString GetXFontName() const;
160
161 // set the XFLD
162 void SetXFontName(const wxString& xFontName);
163#endif
164
165 wxNativeFontInfo() { Init(); }
166
167 // reset to the default state
168 void Init();
169
170#ifndef __WXGTK__
171 // accessors and modifiers for the font elements
172 int GetPointSize() const;
173 wxFontStyle GetStyle() const;
174 wxFontWeight GetWeight() const;
175 bool GetUnderlined() const;
176 wxString GetFaceName() const;
177 wxFontFamily GetFamily() const;
178 wxFontEncoding GetEncoding() const;
179
180 void SetPointSize(int pointsize);
181 void SetStyle(wxFontStyle style);
182 void SetWeight(wxFontWeight weight);
183 void SetUnderlined(bool underlined);
184 void SetFaceName(wxString facename);
185 void SetFamily(wxFontFamily family);
186 void SetEncoding(wxFontEncoding encoding);
187#endif
188
189 // it is important to be able to serialize wxNativeFontInfo objects to be
190 // able to store them (in config file, for example)
191 bool FromString(const wxString& s);
192 wxString ToString() const;
193
194 %addmethods {
195 wxString __str__() {
196 return self->ToString();
197 }
198 }
199
200 // we also want to present the native font descriptions to the user in some
201 // human-readable form (it is not platform independent neither, but can
202 // hopefully be understood by the user)
203 bool FromUserString(const wxString& s);
204 wxString ToUserString() const;
205};
206
207
208//---------------------------------------------------------------------------
209// wxFontMapper manages user-definable correspondence between logical font
210// names and the fonts present on the machine.
211//
212// The default implementations of all functions will ask the user if they are
213// not capable of finding the answer themselves and store the answer in a
214// config file (configurable via SetConfigXXX functions). This behaviour may
215// be disabled by giving the value of FALSE to "interactive" parameter.
216// However, the functions will always consult the config file to allow the
217// user-defined values override the default logic and there is no way to
218// disable this - which shouldn't be ever needed because if "interactive" was
219// never TRUE, the config file is never created anyhow.
220class wxFontMapper
221{
222public:
223 wxFontMapper();
224 ~wxFontMapper();
225
226
227 // find an alternative for the given encoding (which is supposed to not be
228 // available on this system). If successful, return TRUE and rwxFontEcoding
229 // that can be used it wxFont ctor otherwise return FALSE
230 //bool GetAltForEncoding(wxFontEncoding encoding,
231 // wxFontEncoding *alt_encoding,
232 // const wxString& facename = wxPyEmptyString,
233 // bool interactive = TRUE);
234
235
236 // Find an alternative for the given encoding (which is supposed to not be
237 // available on this system). If successful, returns the encoding otherwise
238 // returns None.
239 %addmethods {
240 PyObject* GetAltForEncoding(wxFontEncoding encoding,
241 const wxString& facename = wxPyEmptyString,
242 bool interactive = TRUE) {
243 wxFontEncoding alt_enc;
244 if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
245 return PyInt_FromLong(alt_enc);
246 else {
247 Py_INCREF(Py_None);
248 return Py_None;
249 }
250 }
251 }
252
253
254 // checks whether given encoding is available in given face or not.
255 // If no facename is given,
256 bool IsEncodingAvailable(wxFontEncoding encoding,
257 const wxString& facename = wxPyEmptyString);
258
259 // returns the encoding for the given charset (in the form of RFC 2046) or
260 // wxFONTENCODING_SYSTEM if couldn't decode it
261 wxFontEncoding CharsetToEncoding(const wxString& charset,
262 bool interactive = TRUE);
263
264 // return internal string identifier for the encoding (see also
265 // GetEncodingDescription())
266 static wxString GetEncodingName(wxFontEncoding encoding);
267
268 // return user-readable string describing the given encoding
269 //
270 // NB: hard-coded now, but might change later (read it from config?)
271 static wxString GetEncodingDescription(wxFontEncoding encoding);
272
273 // the parent window for modal dialogs
274 void SetDialogParent(wxWindow *parent);
275
276 // the title for the dialogs (note that default is quite reasonable)
277 void SetDialogTitle(const wxString& title);
278
279 // functions which allow to configure the config object used: by default,
280 // the global one (from wxConfigBase::Get() will be used) and the default
281 // root path for the config settings is the string returned by
282 // GetDefaultConfigPath()
283
284
285 // set the config object to use (may be NULL to use default)
286 void SetConfig(wxConfigBase *config);
287
288 // set the root config path to use (should be an absolute path)
289 void SetConfigPath(const wxString& prefix);
290
291 // return default config path
292 static wxString GetDefaultConfigPath();
293};
294
295
296
297//---------------------------------------------------------------------------
298
299class wxFont : public wxObject {
300public:
301 wxFont( int pointSize, int family, int style, int weight,
302 int underline=FALSE, const wxString& faceName = wxPyEmptyString,
303 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
304
305 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
306
307 ~wxFont();
308
309 bool Ok() const;
310 int GetPointSize() const;
311 int GetFamily() const;
312 int GetStyle() const;
313 int GetWeight() const;
314 bool GetUnderlined() const;
315 wxString GetFaceName() const;
316 wxFontEncoding GetEncoding() const;
317
318 bool IsFixedWidth();
319
320 wxNativeFontInfo* GetNativeFontInfo() const;
321 wxString GetNativeFontInfoDesc() const;
322 wxString GetNativeFontInfoUserDesc() const;
323
324 void SetPointSize(int pointSize);
325 void SetFamily(int family);
326 void SetStyle(int style);
327 void SetWeight(int weight);
328 void SetFaceName(const wxString& faceName);
329 void SetUnderlined(bool underlined);
330 void SetEncoding(wxFontEncoding encoding);
331 void SetNativeFontInfo(const wxNativeFontInfo& info);
332 // void SetNativeFontInfo(const wxString& info);
333 void SetNativeFontInfoUserDesc(const wxString& info);
334
335 wxString GetFamilyString() const;
336 wxString GetStyleString() const;
337 wxString GetWeightString() const;
338
339 static wxFontEncoding GetDefaultEncoding();
340 static void SetDefaultEncoding(wxFontEncoding encoding);
341
342};
343
344
345class wxFontList : public wxObject {
346public:
347
348 void AddFont(wxFont* font);
349 wxFont * FindOrCreateFont(int point_size, int family, int style, int weight,
350 bool underline = FALSE, const wxString& facename = wxPyEmptyString,
351 wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
352 void RemoveFont(wxFont *font);
353
354 int GetCount();
355};
356
357
358//----------------------------------------------------------------------
359// wxFontEnumerator
360
361%{
362class wxPyFontEnumerator : public wxFontEnumerator {
363public:
364 wxPyFontEnumerator() {}
365 ~wxPyFontEnumerator() {}
366
367 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
368 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
369
370 PYPRIVATE;
371};
372
373IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
374IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
375
376%}
377
378%name(wxFontEnumerator) class wxPyFontEnumerator {
379public:
380 wxPyFontEnumerator();
381 ~wxPyFontEnumerator();
382 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
383 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
384
385 bool EnumerateFacenames(
386 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
387 bool fixedWidthOnly = FALSE);
388 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
389
390 //wxArrayString* GetEncodings();
391 //wxArrayString* GetFacenames();
392 %addmethods {
393 PyObject* GetEncodings() {
394 wxArrayString* arr = self->GetEncodings();
395 return wxArrayString2PyList_helper(*arr);
396 }
397
398 PyObject* GetFacenames() {
399 wxArrayString* arr = self->GetFacenames();
400 return wxArrayString2PyList_helper(*arr);
401 }
402 }
403};
404
405//---------------------------------------------------------------------------
406// wxLocale. Not really font related, but close enough
407
408
409enum wxLanguage
410{
411 wxLANGUAGE_DEFAULT,
412 wxLANGUAGE_UNKNOWN,
413
414 wxLANGUAGE_ABKHAZIAN,
415 wxLANGUAGE_AFAR,
416 wxLANGUAGE_AFRIKAANS,
417 wxLANGUAGE_ALBANIAN,
418 wxLANGUAGE_AMHARIC,
419 wxLANGUAGE_ARABIC,
420 wxLANGUAGE_ARABIC_ALGERIA,
421 wxLANGUAGE_ARABIC_BAHRAIN,
422 wxLANGUAGE_ARABIC_EGYPT,
423 wxLANGUAGE_ARABIC_IRAQ,
424 wxLANGUAGE_ARABIC_JORDAN,
425 wxLANGUAGE_ARABIC_KUWAIT,
426 wxLANGUAGE_ARABIC_LEBANON,
427 wxLANGUAGE_ARABIC_LIBYA,
428 wxLANGUAGE_ARABIC_MOROCCO,
429 wxLANGUAGE_ARABIC_OMAN,
430 wxLANGUAGE_ARABIC_QATAR,
431 wxLANGUAGE_ARABIC_SAUDI_ARABIA,
432 wxLANGUAGE_ARABIC_SUDAN,
433 wxLANGUAGE_ARABIC_SYRIA,
434 wxLANGUAGE_ARABIC_TUNISIA,
435 wxLANGUAGE_ARABIC_UAE,
436 wxLANGUAGE_ARABIC_YEMEN,
437 wxLANGUAGE_ARMENIAN,
438 wxLANGUAGE_ASSAMESE,
439 wxLANGUAGE_AYMARA,
440 wxLANGUAGE_AZERI,
441 wxLANGUAGE_AZERI_CYRILLIC,
442 wxLANGUAGE_AZERI_LATIN,
443 wxLANGUAGE_BASHKIR,
444 wxLANGUAGE_BASQUE,
445 wxLANGUAGE_BELARUSIAN,
446 wxLANGUAGE_BENGALI,
447 wxLANGUAGE_BHUTANI,
448 wxLANGUAGE_BIHARI,
449 wxLANGUAGE_BISLAMA,
450 wxLANGUAGE_BRETON,
451 wxLANGUAGE_BULGARIAN,
452 wxLANGUAGE_BURMESE,
453 wxLANGUAGE_CAMBODIAN,
454 wxLANGUAGE_CATALAN,
455 wxLANGUAGE_CHINESE,
456 wxLANGUAGE_CHINESE_SIMPLIFIED,
457 wxLANGUAGE_CHINESE_TRADITIONAL,
458 wxLANGUAGE_CHINESE_HONGKONG,
459 wxLANGUAGE_CHINESE_MACAU,
460 wxLANGUAGE_CHINESE_SINGAPORE,
461 wxLANGUAGE_CHINESE_TAIWAN,
462 wxLANGUAGE_CORSICAN,
463 wxLANGUAGE_CROATIAN,
464 wxLANGUAGE_CZECH,
465 wxLANGUAGE_DANISH,
466 wxLANGUAGE_DUTCH,
467 wxLANGUAGE_DUTCH_BELGIAN,
468 wxLANGUAGE_ENGLISH,
469 wxLANGUAGE_ENGLISH_UK,
470 wxLANGUAGE_ENGLISH_US,
471 wxLANGUAGE_ENGLISH_AUSTRALIA,
472 wxLANGUAGE_ENGLISH_BELIZE,
473 wxLANGUAGE_ENGLISH_BOTSWANA,
474 wxLANGUAGE_ENGLISH_CANADA,
475 wxLANGUAGE_ENGLISH_CARIBBEAN,
476 wxLANGUAGE_ENGLISH_DENMARK,
477 wxLANGUAGE_ENGLISH_EIRE,
478 wxLANGUAGE_ENGLISH_JAMAICA,
479 wxLANGUAGE_ENGLISH_NEW_ZEALAND,
480 wxLANGUAGE_ENGLISH_PHILIPPINES,
481 wxLANGUAGE_ENGLISH_SOUTH_AFRICA,
482 wxLANGUAGE_ENGLISH_TRINIDAD,
483 wxLANGUAGE_ENGLISH_ZIMBABWE,
484 wxLANGUAGE_ESPERANTO,
485 wxLANGUAGE_ESTONIAN,
486 wxLANGUAGE_FAEROESE,
487 wxLANGUAGE_FARSI,
488 wxLANGUAGE_FIJI,
489 wxLANGUAGE_FINNISH,
490 wxLANGUAGE_FRENCH,
491 wxLANGUAGE_FRENCH_BELGIAN,
492 wxLANGUAGE_FRENCH_CANADIAN,
493 wxLANGUAGE_FRENCH_LUXEMBOURG,
494 wxLANGUAGE_FRENCH_MONACO,
495 wxLANGUAGE_FRENCH_SWISS,
496 wxLANGUAGE_FRISIAN,
497 wxLANGUAGE_GALICIAN,
498 wxLANGUAGE_GEORGIAN,
499 wxLANGUAGE_GERMAN,
500 wxLANGUAGE_GERMAN_AUSTRIAN,
501 wxLANGUAGE_GERMAN_BELGIUM,
502 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
503 wxLANGUAGE_GERMAN_LUXEMBOURG,
504 wxLANGUAGE_GERMAN_SWISS,
505 wxLANGUAGE_GREEK,
506 wxLANGUAGE_GREENLANDIC,
507 wxLANGUAGE_GUARANI,
508 wxLANGUAGE_GUJARATI,
509 wxLANGUAGE_HAUSA,
510 wxLANGUAGE_HEBREW,
511 wxLANGUAGE_HINDI,
512 wxLANGUAGE_HUNGARIAN,
513 wxLANGUAGE_ICELANDIC,
514 wxLANGUAGE_INDONESIAN,
515 wxLANGUAGE_INTERLINGUA,
516 wxLANGUAGE_INTERLINGUE,
517 wxLANGUAGE_INUKTITUT,
518 wxLANGUAGE_INUPIAK,
519 wxLANGUAGE_IRISH,
520 wxLANGUAGE_ITALIAN,
521 wxLANGUAGE_ITALIAN_SWISS,
522 wxLANGUAGE_JAPANESE,
523 wxLANGUAGE_JAVANESE,
524 wxLANGUAGE_KANNADA,
525 wxLANGUAGE_KASHMIRI,
526 wxLANGUAGE_KASHMIRI_INDIA,
527 wxLANGUAGE_KAZAKH,
528 wxLANGUAGE_KERNEWEK,
529 wxLANGUAGE_KINYARWANDA,
530 wxLANGUAGE_KIRGHIZ,
531 wxLANGUAGE_KIRUNDI,
532 wxLANGUAGE_KONKANI,
533 wxLANGUAGE_KOREAN,
534 wxLANGUAGE_KURDISH,
535 wxLANGUAGE_LAOTHIAN,
536 wxLANGUAGE_LATIN,
537 wxLANGUAGE_LATVIAN,
538 wxLANGUAGE_LINGALA,
539 wxLANGUAGE_LITHUANIAN,
540 wxLANGUAGE_MACEDONIAN,
541 wxLANGUAGE_MALAGASY,
542 wxLANGUAGE_MALAY,
543 wxLANGUAGE_MALAYALAM,
544 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
545 wxLANGUAGE_MALAY_MALAYSIA,
546 wxLANGUAGE_MALTESE,
547 wxLANGUAGE_MANIPURI,
548 wxLANGUAGE_MAORI,
549 wxLANGUAGE_MARATHI,
550 wxLANGUAGE_MOLDAVIAN,
551 wxLANGUAGE_MONGOLIAN,
552 wxLANGUAGE_NAURU,
553 wxLANGUAGE_NEPALI,
554 wxLANGUAGE_NEPALI_INDIA,
555 wxLANGUAGE_NORWEGIAN_BOKMAL,
556 wxLANGUAGE_NORWEGIAN_NYNORSK,
557 wxLANGUAGE_OCCITAN,
558 wxLANGUAGE_ORIYA,
559 wxLANGUAGE_OROMO,
560 wxLANGUAGE_PASHTO,
561 wxLANGUAGE_POLISH,
562 wxLANGUAGE_PORTUGUESE,
563 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
564 wxLANGUAGE_PUNJABI,
565 wxLANGUAGE_QUECHUA,
566 wxLANGUAGE_RHAETO_ROMANCE,
567 wxLANGUAGE_ROMANIAN,
568 wxLANGUAGE_RUSSIAN,
569 wxLANGUAGE_RUSSIAN_UKRAINE,
570 wxLANGUAGE_SAMOAN,
571 wxLANGUAGE_SANGHO,
572 wxLANGUAGE_SANSKRIT,
573 wxLANGUAGE_SCOTS_GAELIC,
574 wxLANGUAGE_SERBIAN,
575 wxLANGUAGE_SERBIAN_CYRILLIC,
576 wxLANGUAGE_SERBIAN_LATIN,
577 wxLANGUAGE_SERBO_CROATIAN,
578 wxLANGUAGE_SESOTHO,
579 wxLANGUAGE_SETSWANA,
580 wxLANGUAGE_SHONA,
581 wxLANGUAGE_SINDHI,
582 wxLANGUAGE_SINHALESE,
583 wxLANGUAGE_SISWATI,
584 wxLANGUAGE_SLOVAK,
585 wxLANGUAGE_SLOVENIAN,
586 wxLANGUAGE_SOMALI,
587 wxLANGUAGE_SPANISH,
588 wxLANGUAGE_SPANISH_ARGENTINA,
589 wxLANGUAGE_SPANISH_BOLIVIA,
590 wxLANGUAGE_SPANISH_CHILE,
591 wxLANGUAGE_SPANISH_COLOMBIA,
592 wxLANGUAGE_SPANISH_COSTA_RICA,
593 wxLANGUAGE_SPANISH_DOMINICAN_REPUBLIC,
594 wxLANGUAGE_SPANISH_ECUADOR,
595 wxLANGUAGE_SPANISH_EL_SALVADOR,
596 wxLANGUAGE_SPANISH_GUATEMALA,
597 wxLANGUAGE_SPANISH_HONDURAS,
598 wxLANGUAGE_SPANISH_MEXICAN,
599 wxLANGUAGE_SPANISH_MODERN,
600 wxLANGUAGE_SPANISH_NICARAGUA,
601 wxLANGUAGE_SPANISH_PANAMA,
602 wxLANGUAGE_SPANISH_PARAGUAY,
603 wxLANGUAGE_SPANISH_PERU,
604 wxLANGUAGE_SPANISH_PUERTO_RICO,
605 wxLANGUAGE_SPANISH_URUGUAY,
606 wxLANGUAGE_SPANISH_US,
607 wxLANGUAGE_SPANISH_VENEZUELA,
608 wxLANGUAGE_SUNDANESE,
609 wxLANGUAGE_SWAHILI,
610 wxLANGUAGE_SWEDISH,
611 wxLANGUAGE_SWEDISH_FINLAND,
612 wxLANGUAGE_TAGALOG,
613 wxLANGUAGE_TAJIK,
614 wxLANGUAGE_TAMIL,
615 wxLANGUAGE_TATAR,
616 wxLANGUAGE_TELUGU,
617 wxLANGUAGE_THAI,
618 wxLANGUAGE_TIBETAN,
619 wxLANGUAGE_TIGRINYA,
620 wxLANGUAGE_TONGA,
621 wxLANGUAGE_TSONGA,
622 wxLANGUAGE_TURKISH,
623 wxLANGUAGE_TURKMEN,
624 wxLANGUAGE_TWI,
625 wxLANGUAGE_UIGHUR,
626 wxLANGUAGE_UKRAINIAN,
627 wxLANGUAGE_URDU,
628 wxLANGUAGE_URDU_INDIA,
629 wxLANGUAGE_URDU_PAKISTAN,
630 wxLANGUAGE_UZBEK,
631 wxLANGUAGE_UZBEK_CYRILLIC,
632 wxLANGUAGE_UZBEK_LATIN,
633 wxLANGUAGE_VIETNAMESE,
634 wxLANGUAGE_VOLAPUK,
635 wxLANGUAGE_WELSH,
636 wxLANGUAGE_WOLOF,
637 wxLANGUAGE_XHOSA,
638 wxLANGUAGE_YIDDISH,
639 wxLANGUAGE_YORUBA,
640 wxLANGUAGE_ZHUANG,
641 wxLANGUAGE_ZULU,
642
643 // for custom, user-defined languages:
644 wxLANGUAGE_USER_DEFINED
645};
646
647// wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
648// translation information
649class wxLanguageInfo
650{
651public:
652 int Language; // wxLanguage id
653 wxString CanonicalName; // Canonical name, e.g. fr_FR
654 wxString Description; // human-readable name of the language
655};
656
657// wxLocaleCategory: the category of locale settings
658enum wxLocaleCategory
659{
660 wxLOCALE_CAT_NUMBER,
661 wxLOCALE_CAT_DATE,
662 wxLOCALE_CAT_MONEY,
663 wxLOCALE_CAT_MAX
664};
665
666// wxLocaleInfo: the items understood by wxLocale::GetInfo()
667enum wxLocaleInfo
668{
669 wxLOCALE_THOUSANDS_SEP,
670 wxLOCALE_DECIMAL_POINT
671
672};
673
674// wxLocale: encapsulates all language dependent settings, including current
675// message catalogs, date, time and currency formats (TODO) &c
676enum wxLocaleInitFlags
677{
678 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
679 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
680};
681
682class wxLocale
683{
684public:
685 // ctor & dtor
686 // -----------
687 wxLocale(int language = wxLANGUAGE_DEFAULT,
688 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
689
690 // the same as a function (returns TRUE on success)
691 bool Init(const wxString& szName,
692 const wxString& szShort = wxPyEmptyString,
693 const wxString& szLocale = wxPyEmptyString,
694 bool bLoadDefault = TRUE,
695 bool bConvertEncoding = FALSE);
696
697 // restores old locale
698 ~wxLocale();
699
700 // Try to get user's (or OS's) prefered language setting.
701 // Return wxLANGUAGE_UNKNOWN if language-guessing algorithm failed
702 static int GetSystemLanguage();
703
704 // get the encoding used by default for text on this system, returns
705 // wxFONTENCODING_SYSTEM if it couldn't be determined
706 static wxFontEncoding GetSystemEncoding();
707
708 // get the string describing the system encoding, return empty string if
709 // couldn't be determined
710 static wxString GetSystemEncodingName();
711
712
713 // THIS ONE IS COMMENTED OUT IN src/common/intl.cpp
714 // get the values of the given locale-dependent datum: the current locale
715 // is used, the US default value is returned if everything else fails
716 // static wxString GetInfo(wxLocaleInfo index, wxLocaleCategory cat);
717
718 // return TRUE if the locale was set successfully
719 bool IsOk() const;
720
721 // returns locale name
722 wxString GetLocale() const;
723
724 // return current locale wxLanguage value
725 int GetLanguage() const;
726
727 // return locale name to be passed to setlocale()
728 wxString GetSysName() const;
729
730 // return 'canonical' name, i.e. in the form of xx[_YY], where xx is
731 // language code according to ISO 639 and YY is country name
732 // as specified by ISO 3166.
733 wxString GetCanonicalName() const;
734
735 // add a prefix to the catalog lookup path: the message catalog files will be
736 // looked up under prefix/<lang>/LC_MESSAGES, prefix/LC_MESSAGES and prefix
737 // (in this order).
738 //
739 // This only applies to subsequent invocations of AddCatalog()!
740 static void AddCatalogLookupPathPrefix(const wxString& prefix);
741
742 // add a catalog: it's searched for in standard places (current directory
743 // first, system one after), but the you may prepend additional directories to
744 // the search path with AddCatalogLookupPathPrefix().
745 //
746 // The loaded catalog will be used for message lookup by GetString().
747 //
748 // Returns 'true' if it was successfully loaded
749 bool AddCatalog(const wxString& szDomain);
750
751 // check if the given catalog is loaded
752 bool IsLoaded(const wxString& szDomain) const;
753
754 // Add custom language to the list of known languages.
755 // Notes: 1) wxLanguageInfo contains platform-specific data
756 // 2) must be called before Init to have effect
757 static void AddLanguage(const wxLanguageInfo& info);
758
759 // retrieve the translation for a string in all loaded domains unless
760 // the szDomain parameter is specified (and then only this domain is
761 // searched)
762 //
763 // return original string if translation is not available
764 // (in this case an error message is generated the first time
765 // a string is not found; use wxLogNull to suppress it)
766 //
767 // domains are searched in the last to first order, i.e. catalogs
768 // added later override those added before.
769 wxString GetString(const wxString& szOrigString,
770 const wxString& szDomain = wxPyEmptyString) const;
771
772 // Returns the current short name for the locale
773 const wxString& GetName() const;
774
775};
776
777
778
779// get the current locale object (note that it may be NULL!)
780wxLocale* wxGetLocale();
781
782// get the translation of the string in the current locale
783wxString wxGetTranslation(const wxString& sz);
784
785
786//----------------------------------------------------------------------
787// wxEncodingConverter
788// This class is capable of converting strings between any two
789// 8bit encodings/charsets. It can also convert from/to Unicode
790
791
792%typemap(python, out) wxFontEncodingArray {
793 $target = PyList_New(0);
794 for (size_t i=0; i < $source->GetCount(); i++) {
795 PyObject* number = PyInt_FromLong($source->Item(i));
796 PyList_Append($target, number);
797 Py_DECREF(number);
798 }
799}
800
801
802enum
803{
804 wxCONVERT_STRICT,
805 wxCONVERT_SUBSTITUTE
806};
807
808
809enum
810{
811 wxPLATFORM_CURRENT = -1,
812
813 wxPLATFORM_UNIX = 0,
814 wxPLATFORM_WINDOWS,
815 wxPLATFORM_OS2,
816 wxPLATFORM_MAC
817};
818
819
820class wxEncodingConverter : public wxObject
821{
822public:
823
824 wxEncodingConverter();
825 ~wxEncodingConverter();
826
827
828 // Initialize convertion. Both output or input encoding may
829 // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
830 //
831 // All subsequent calls to Convert() will interpret it's argument
832 // as a string in input_enc encoding and will output string in
833 // output_enc encoding.
834 //
835 // You must call this method before calling Convert. You may call
836 // it more than once in order to switch to another conversion
837 //
838 // Method affects behaviour of Convert() in case input character
839 // cannot be converted because it does not exist in output encoding:
840 // wxCONVERT_STRICT --
841 // follow behaviour of GNU Recode - just copy unconvertable
842 // characters to output and don't change them (it's integer
843 // value will stay the same)
844 // wxCONVERT_SUBSTITUTE --
845 // try some (lossy) substitutions - e.g. replace
846 // unconvertable latin capitals with acute by ordinary
847 // capitals, replace en-dash or em-dash by '-' etc.
848 // both modes gurantee that output string will have same length
849 // as input string
850 //
851 // Returns FALSE if given conversion is impossible, TRUE otherwise
852 // (conversion may be impossible either if you try to convert
853 // to Unicode with non-Unicode build of wxWindows or if input
854 // or output encoding is not supported.)
855 bool Init(wxFontEncoding input_enc, wxFontEncoding output_enc, int method = wxCONVERT_STRICT);
856
857 // Convert input string according to settings passed to Init.
858 // Note that you must call Init before using Convert!
859 wxString Convert(const wxString& input);
860
861 // void Convert(const char* input, char* output);
862
863// #if wxUSE_WCHAR_T
864// void Convert(const char* input, wchar_t* output);
865// void Convert(const wchar_t* input, char* output);
866// void Convert(const wchar_t* input, wchar_t* output);
867// void Convert(wchar_t* str) { Convert(str, str); }
868// #endif
869
870
871 // Return equivalent(s) for given font that are used
872 // under given platform. wxPLATFORM_CURRENT means the plaform
873 // this binary was compiled for
874 //
875 // Examples:
876 // current platform enc returned value
877 // -----------------------------------------------------
878 // unix CP1250 {ISO8859_2}
879 // unix ISO8859_2 {}
880 // windows ISO8859_2 {CP1250}
881 //
882 // Equivalence is defined in terms of convertibility:
883 // 2 encodings are equivalent if you can convert text between
884 // then without loosing information (it may - and will - happen
885 // that you loose special chars like quotation marks or em-dashes
886 // but you shouldn't loose any diacritics and language-specific
887 // characters when converting between equivalent encodings).
888 //
889 // Convert() method is not limited to converting between
890 // equivalent encodings, it can convert between arbitrary
891 // two encodings!
892 //
893 // Remember that this function does _NOT_ check for presence of
894 // fonts in system. It only tells you what are most suitable
895 // encodings. (It usually returns only one encoding)
896 //
897 // Note that argument enc itself may be present in returned array!
898 // (so that you can -- as a side effect -- detect whether the
899 // encoding is native for this platform or not)
900 static wxFontEncodingArray GetPlatformEquivalents(wxFontEncoding enc,
901 int platform = wxPLATFORM_CURRENT);
902
903 // Similar to GetPlatformEquivalent, but this one will return ALL
904 // equivalent encodings, regardless the platform, including itself.
905 static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
906
907};
908
909
910//----------------------------------------------------------------------
911//----------------------------------------------------------------------
912
913%init %{
914 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
915%}
916
917//----------------------------------------------------------------------
918