1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: SWIG interface file wxFont, local, converters, etc.
9 // Copyright: (c) 2002 by Total Control Software
10 // Licence: wxWindows license
11 /////////////////////////////////////////////////////////////////////////////
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>
24 #include <wx/encconv.h>
27 //----------------------------------------------------------------------
30 %include my_typemaps.i
32 // Import some definitions of other classes, etc.
37 //---------------------------------------------------------------------------
39 // Put some wx default wxChar* values into wxStrings.
40 static const wxString wxPyEmptyString(wxT(""));
42 //---------------------------------------------------------------------------
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,
62 wxFONTSTYLE_NORMAL = wxNORMAL,
63 wxFONTSTYLE_ITALIC = wxITALIC,
64 wxFONTSTYLE_SLANT = wxSLANT,
71 wxFONTWEIGHT_NORMAL = wxNORMAL,
72 wxFONTWEIGHT_LIGHT = wxLIGHT,
73 wxFONTWEIGHT_BOLD = wxBOLD,
81 wxFONTENCODING_SYSTEM = -1, // system default
82 wxFONTENCODING_DEFAULT, // current default encoding
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,
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
109 // what would we do without Microsoft? They have their own encodings
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
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,
132 wxFONTENCODING_UTF7, // UTF-7 Unicode encoding
133 wxFONTENCODING_UTF8, // UTF-8 Unicode encoding
135 wxFONTENCODING_UNICODE, // Unicode - currently used only by
136 // wxEncodingConverter class
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())
149 struct wxNativeFontInfo
152 // init the elements from an XLFD, return TRUE if ok
153 bool FromXFontName(const wxString& xFontName);
155 // return false if we were never initialized with a valid XLFD
156 bool IsDefault() const;
158 // generate an XLFD using the fontElements
159 wxString GetXFontName() const;
162 void SetXFontName(const wxString& xFontName);
165 wxNativeFontInfo() { Init(); }
167 // reset to the default state
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;
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);
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;
196 return self->ToString();
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;
208 //---------------------------------------------------------------------------
209 // wxFontMapper manages user-definable correspondence between logical font
210 // names and the fonts present on the machine.
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.
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);
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
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);
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);
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);
264 // return internal string identifier for the encoding (see also
265 // GetEncodingDescription())
266 static wxString GetEncodingName(wxFontEncoding encoding);
268 // return user-readable string describing the given encoding
270 // NB: hard-coded now, but might change later (read it from config?)
271 static wxString GetEncodingDescription(wxFontEncoding encoding);
273 // the parent window for modal dialogs
274 void SetDialogParent(wxWindow *parent);
276 // the title for the dialogs (note that default is quite reasonable)
277 void SetDialogTitle(const wxString& title);
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()
285 // set the config object to use (may be NULL to use default)
286 void SetConfig(wxConfigBase *config);
288 // set the root config path to use (should be an absolute path)
289 void SetConfigPath(const wxString& prefix);
291 // return default config path
292 static wxString GetDefaultConfigPath();
297 //---------------------------------------------------------------------------
299 class wxFont : public wxObject {
301 wxFont( int pointSize, int family, int style, int weight,
302 int underline=FALSE, const wxString& faceName = wxPyEmptyString,
303 wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
305 %name(wxFontFromNativeInfo)wxFont(const wxNativeFontInfo& info);
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;
320 wxNativeFontInfo* GetNativeFontInfo() const;
321 wxString GetNativeFontInfoDesc() const;
322 wxString GetNativeFontInfoUserDesc() const;
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);
335 wxString GetFamilyString() const;
336 wxString GetStyleString() const;
337 wxString GetWeightString() const;
339 static wxFontEncoding GetDefaultEncoding();
340 static void SetDefaultEncoding(wxFontEncoding encoding);
345 class wxFontList : public wxObject {
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);
358 //----------------------------------------------------------------------
362 class wxPyFontEnumerator : public wxFontEnumerator {
364 wxPyFontEnumerator() {}
365 ~wxPyFontEnumerator() {}
367 DEC_PYCALLBACK_BOOL_STRING(OnFacename);
368 DEC_PYCALLBACK_BOOL_STRINGSTRING(OnFontEncoding);
373 IMP_PYCALLBACK_BOOL_STRING(wxPyFontEnumerator, wxFontEnumerator, OnFacename);
374 IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEncoding);
378 %name(wxFontEnumerator) class wxPyFontEnumerator {
380 wxPyFontEnumerator();
381 ~wxPyFontEnumerator();
382 void _setCallbackInfo(PyObject* self, PyObject* _class, bool incref);
383 %pragma(python) addtomethod = "__init__:self._setCallbackInfo(self, wxFontEnumerator, 0)"
385 bool EnumerateFacenames(
386 wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
387 bool fixedWidthOnly = FALSE);
388 bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
390 //wxArrayString* GetEncodings();
391 //wxArrayString* GetFacenames();
393 PyObject* GetEncodings() {
394 wxArrayString* arr = self->GetEncodings();
395 return wxArrayString2PyList_helper(*arr);
398 PyObject* GetFacenames() {
399 wxArrayString* arr = self->GetFacenames();
400 return wxArrayString2PyList_helper(*arr);
405 //---------------------------------------------------------------------------
406 // wxLocale. Not really font related, but close enough
414 wxLANGUAGE_ABKHAZIAN,
416 wxLANGUAGE_AFRIKAANS,
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,
441 wxLANGUAGE_AZERI_CYRILLIC,
442 wxLANGUAGE_AZERI_LATIN,
445 wxLANGUAGE_BELARUSIAN,
451 wxLANGUAGE_BULGARIAN,
453 wxLANGUAGE_CAMBODIAN,
456 wxLANGUAGE_CHINESE_SIMPLIFIED,
457 wxLANGUAGE_CHINESE_TRADITIONAL,
458 wxLANGUAGE_CHINESE_HONGKONG,
459 wxLANGUAGE_CHINESE_MACAU,
460 wxLANGUAGE_CHINESE_SINGAPORE,
461 wxLANGUAGE_CHINESE_TAIWAN,
467 wxLANGUAGE_DUTCH_BELGIAN,
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,
491 wxLANGUAGE_FRENCH_BELGIAN,
492 wxLANGUAGE_FRENCH_CANADIAN,
493 wxLANGUAGE_FRENCH_LUXEMBOURG,
494 wxLANGUAGE_FRENCH_MONACO,
495 wxLANGUAGE_FRENCH_SWISS,
500 wxLANGUAGE_GERMAN_AUSTRIAN,
501 wxLANGUAGE_GERMAN_BELGIUM,
502 wxLANGUAGE_GERMAN_LIECHTENSTEIN,
503 wxLANGUAGE_GERMAN_LUXEMBOURG,
504 wxLANGUAGE_GERMAN_SWISS,
506 wxLANGUAGE_GREENLANDIC,
512 wxLANGUAGE_HUNGARIAN,
513 wxLANGUAGE_ICELANDIC,
514 wxLANGUAGE_INDONESIAN,
515 wxLANGUAGE_INTERLINGUA,
516 wxLANGUAGE_INTERLINGUE,
517 wxLANGUAGE_INUKTITUT,
521 wxLANGUAGE_ITALIAN_SWISS,
526 wxLANGUAGE_KASHMIRI_INDIA,
529 wxLANGUAGE_KINYARWANDA,
539 wxLANGUAGE_LITHUANIAN,
540 wxLANGUAGE_MACEDONIAN,
543 wxLANGUAGE_MALAYALAM,
544 wxLANGUAGE_MALAY_BRUNEI_DARUSSALAM,
545 wxLANGUAGE_MALAY_MALAYSIA,
550 wxLANGUAGE_MOLDAVIAN,
551 wxLANGUAGE_MONGOLIAN,
554 wxLANGUAGE_NEPALI_INDIA,
555 wxLANGUAGE_NORWEGIAN_BOKMAL,
556 wxLANGUAGE_NORWEGIAN_NYNORSK,
562 wxLANGUAGE_PORTUGUESE,
563 wxLANGUAGE_PORTUGUESE_BRAZILIAN,
566 wxLANGUAGE_RHAETO_ROMANCE,
569 wxLANGUAGE_RUSSIAN_UKRAINE,
573 wxLANGUAGE_SCOTS_GAELIC,
575 wxLANGUAGE_SERBIAN_CYRILLIC,
576 wxLANGUAGE_SERBIAN_LATIN,
577 wxLANGUAGE_SERBO_CROATIAN,
582 wxLANGUAGE_SINHALESE,
585 wxLANGUAGE_SLOVENIAN,
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,
611 wxLANGUAGE_SWEDISH_FINLAND,
626 wxLANGUAGE_UKRAINIAN,
628 wxLANGUAGE_URDU_INDIA,
629 wxLANGUAGE_URDU_PAKISTAN,
631 wxLANGUAGE_UZBEK_CYRILLIC,
632 wxLANGUAGE_UZBEK_LATIN,
633 wxLANGUAGE_VIETNAMESE,
643 // for custom, user-defined languages:
644 wxLANGUAGE_USER_DEFINED
647 // wxLanguageInfo: encapsulates wxLanguage to OS native lang.desc.
648 // translation information
652 int Language; // wxLanguage id
653 wxString CanonicalName; // Canonical name, e.g. fr_FR
654 wxString Description; // human-readable name of the language
657 // wxLocaleCategory: the category of locale settings
658 enum wxLocaleCategory
666 // wxLocaleInfo: the items understood by wxLocale::GetInfo()
669 wxLOCALE_THOUSANDS_SEP,
670 wxLOCALE_DECIMAL_POINT
674 // wxLocale: encapsulates all language dependent settings, including current
675 // message catalogs, date, time and currency formats (TODO) &c
676 enum wxLocaleInitFlags
678 wxLOCALE_LOAD_DEFAULT = 0x0001, // load wxwin.mo?
679 wxLOCALE_CONV_ENCODING = 0x0002 // convert encoding on the fly?
687 wxLocale(int language = wxLANGUAGE_DEFAULT,
688 int flags = wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
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);
697 // restores old locale
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();
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();
708 // get the string describing the system encoding, return empty string if
709 // couldn't be determined
710 static wxString GetSystemEncodingName();
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);
718 // return TRUE if the locale was set successfully
721 // returns locale name
722 wxString GetLocale() const;
724 // return current locale wxLanguage value
725 int GetLanguage() const;
727 // return locale name to be passed to setlocale()
728 wxString GetSysName() const;
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;
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
739 // This only applies to subsequent invocations of AddCatalog()!
740 static void AddCatalogLookupPathPrefix(const wxString& prefix);
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().
746 // The loaded catalog will be used for message lookup by GetString().
748 // Returns 'true' if it was successfully loaded
749 bool AddCatalog(const wxString& szDomain);
751 // check if the given catalog is loaded
752 bool IsLoaded(const wxString& szDomain) const;
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);
759 // retrieve the translation for a string in all loaded domains unless
760 // the szDomain parameter is specified (and then only this domain is
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)
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;
772 // Returns the current short name for the locale
773 const wxString& GetName() const;
779 // get the current locale object (note that it may be NULL!)
780 wxLocale* wxGetLocale();
782 // get the translation of the string in the current locale
783 wxString wxGetTranslation(const wxString& sz);
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
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);
811 wxPLATFORM_CURRENT = -1,
820 class wxEncodingConverter : public wxObject
824 wxEncodingConverter();
825 ~wxEncodingConverter();
828 // Initialize convertion. Both output or input encoding may
829 // be wxFONTENCODING_UNICODE, but only if wxUSE_WCHAR_T is set to 1.
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.
835 // You must call this method before calling Convert. You may call
836 // it more than once in order to switch to another conversion
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
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);
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);
861 // void Convert(const char* input, char* output);
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); }
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
876 // current platform enc returned value
877 // -----------------------------------------------------
878 // unix CP1250 {ISO8859_2}
880 // windows ISO8859_2 {CP1250}
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).
889 // Convert() method is not limited to converting between
890 // equivalent encodings, it can convert between arbitrary
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)
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);
903 // Similar to GetPlatformEquivalent, but this one will return ALL
904 // equivalent encodings, regardless the platform, including itself.
905 static wxFontEncodingArray GetAllEquivalents(wxFontEncoding enc);
910 //----------------------------------------------------------------------
911 //----------------------------------------------------------------------
914 wxPyPtrTypeMap_Add("wxFontEnumerator", "wxPyFontEnumerator");
917 //----------------------------------------------------------------------