]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/src/_font.i
Version
[wxWidgets.git] / wxPython / src / _font.i
index fc4d975bbf1609920ac2f73c1ae93c1e0e4830ba..7ee9fd9540423d0742b7c5017bf268fbae58db46 100644 (file)
@@ -118,7 +118,8 @@ enum wxFontEncoding
     wxFONTENCODING_ISO8859_MAX,
 
     // Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
-    wxFONTENCODING_KOI8,            // we don't support any of KOI8 variants
+    wxFONTENCODING_KOI8,            // KOI8 Russian
+    wxFONTENCODING_KOI8_U,          // KOI8 Ukrainian
     wxFONTENCODING_ALTERNATIVE,     // same as MS-DOS CP866
     wxFONTENCODING_BULGARIAN,       // used under Linux in Bulgaria
 
@@ -154,45 +155,45 @@ enum wxFontEncoding
     wxFONTENCODING_UTF32LE,         // UTF-32 Little Endian Unicode encoding
 
     wxFONTENCODING_MACROMAN,        // the standard mac encodings
-    wxFONTENCODING_MACJAPANESE,      
-    wxFONTENCODING_MACCHINESETRAD,   
-    wxFONTENCODING_MACKOREAN,       
-    wxFONTENCODING_MACARABIC,       
-    wxFONTENCODING_MACHEBREW,        
-    wxFONTENCODING_MACGREEK,       
-    wxFONTENCODING_MACCYRILLIC,      
-    wxFONTENCODING_MACDEVANAGARI,      
-    wxFONTENCODING_MACGURMUKHI,      
-    wxFONTENCODING_MACGUJARATI,     
-    wxFONTENCODING_MACORIYA,       
-    wxFONTENCODING_MACBENGALI,       
-    wxFONTENCODING_MACTAMIL,       
-    wxFONTENCODING_MACTELUGU,        
-    wxFONTENCODING_MACKANNADA,        
-    wxFONTENCODING_MACMALAJALAM,        
-    wxFONTENCODING_MACSINHALESE,        
-    wxFONTENCODING_MACBURMESE,       
-    wxFONTENCODING_MACKHMER,        
-    wxFONTENCODING_MACTHAI,        
-    wxFONTENCODING_MACLAOTIAN,        
-    wxFONTENCODING_MACGEORGIAN,        
-    wxFONTENCODING_MACARMENIAN,        
-    wxFONTENCODING_MACCHINESESIMP,        
-    wxFONTENCODING_MACTIBETAN,        
-    wxFONTENCODING_MACMONGOLIAN,        
-    wxFONTENCODING_MACETHIOPIC,        
-    wxFONTENCODING_MACCENTRALEUR,        
-    wxFONTENCODING_MACVIATNAMESE,        
-    wxFONTENCODING_MACARABICEXT,        
-    wxFONTENCODING_MACSYMBOL,        
-    wxFONTENCODING_MACDINGBATS,        
-    wxFONTENCODING_MACTURKISH,        
-    wxFONTENCODING_MACCROATIAN,        
-    wxFONTENCODING_MACICELANDIC,        
-    wxFONTENCODING_MACROMANIAN,        
-    wxFONTENCODING_MACCELTIC,        
-    wxFONTENCODING_MACGAELIC,        
-    wxFONTENCODING_MACKEYBOARD,       
+    wxFONTENCODING_MACJAPANESE,
+    wxFONTENCODING_MACCHINESETRAD,
+    wxFONTENCODING_MACKOREAN,
+    wxFONTENCODING_MACARABIC,
+    wxFONTENCODING_MACHEBREW,
+    wxFONTENCODING_MACGREEK,
+    wxFONTENCODING_MACCYRILLIC,
+    wxFONTENCODING_MACDEVANAGARI,
+    wxFONTENCODING_MACGURMUKHI,
+    wxFONTENCODING_MACGUJARATI,
+    wxFONTENCODING_MACORIYA,
+    wxFONTENCODING_MACBENGALI,
+    wxFONTENCODING_MACTAMIL,
+    wxFONTENCODING_MACTELUGU,
+    wxFONTENCODING_MACKANNADA,
+    wxFONTENCODING_MACMALAJALAM,
+    wxFONTENCODING_MACSINHALESE,
+    wxFONTENCODING_MACBURMESE,
+    wxFONTENCODING_MACKHMER,
+    wxFONTENCODING_MACTHAI,
+    wxFONTENCODING_MACLAOTIAN,
+    wxFONTENCODING_MACGEORGIAN,
+    wxFONTENCODING_MACARMENIAN,
+    wxFONTENCODING_MACCHINESESIMP,
+    wxFONTENCODING_MACTIBETAN,
+    wxFONTENCODING_MACMONGOLIAN,
+    wxFONTENCODING_MACETHIOPIC,
+    wxFONTENCODING_MACCENTRALEUR,
+    wxFONTENCODING_MACVIATNAMESE,
+    wxFONTENCODING_MACARABICEXT,
+    wxFONTENCODING_MACSYMBOL,
+    wxFONTENCODING_MACDINGBATS,
+    wxFONTENCODING_MACTURKISH,
+    wxFONTENCODING_MACCROATIAN,
+    wxFONTENCODING_MACICELANDIC,
+    wxFONTENCODING_MACROMANIAN,
+    wxFONTENCODING_MACCELTIC,
+    wxFONTENCODING_MACGAELIC,
+    wxFONTENCODING_MACKEYBOARD,
 
     wxFONTENCODING_MACMIN = wxFONTENCODING_MACROMAN ,
     wxFONTENCODING_MACMAX = wxFONTENCODING_MACKEYBOARD ,
@@ -239,6 +240,9 @@ public:
 
     // accessors and modifiers for the font elements
     int GetPointSize() const;
+#ifdef __WXMSW__
+    wxSize GetPixelSize() const;
+#endif
     wxFontStyle GetStyle() const;
     wxFontWeight GetWeight() const;
     bool GetUnderlined() const;
@@ -247,6 +251,9 @@ public:
     wxFontEncoding GetEncoding() const;
 
     void SetPointSize(int pointsize);
+#ifdef __WXMSW__
+    void SetPixelSize(const wxSize& pixelSize);
+#endif
     void SetStyle(wxFontStyle style);
     void SetWeight(wxFontWeight weight);
     void SetUnderlined(bool underlined);
@@ -282,7 +289,7 @@ struct wxNativeEncodingInfo
 
     wxNativeEncodingInfo();
     ~wxNativeEncodingInfo();
-    
+
     // this struct is saved in config by wxFontMapper, so it should know to
     // serialise itself (implemented in platform-specific code)
     bool FromString(const wxString& s);
@@ -313,9 +320,9 @@ bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
 %inline %{
     wxNativeEncodingInfo* wxGetNativeFontEncoding(wxFontEncoding encoding)
         { wxPyRaiseNotImplemented(); return NULL; }
-    
+
     bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
-        { wxPyRaiseNotImplemented(); return False; }
+        { wxPyRaiseNotImplemented(); return false; }
 %}
 #endif
 
@@ -355,7 +362,7 @@ public:
     // interactive parameter is ignored in the base class, we behave as if it
     // were always False
     virtual wxFontEncoding CharsetToEncoding(const wxString& charset,
-                                             bool interactive = True);
+                                             bool interactive = true);
 
 
     // get the number of font encodings we know about
@@ -373,6 +380,12 @@ public:
     // NB: hard-coded now, but might change later (read it from config?)
     static wxString GetEncodingDescription(wxFontEncoding encoding);
 
+    // find the encoding corresponding to the given name, inverse of
+    // GetEncodingName() and less general than CharsetToEncoding()
+    //
+    // returns wxFONTENCODING_MAX if the name is not a supported encoding
+    static wxFontEncoding GetEncodingFromName(const wxString& name);
+
 
     // set the config object to use (may be NULL to use default)
     void SetConfig(wxConfigBase *config);
@@ -391,7 +404,7 @@ public:
     %extend {
         PyObject* GetAltForEncoding(wxFontEncoding encoding,
                                     const wxString& facename = wxPyEmptyString,
-                                    bool interactive = True) {
+                                    bool interactive = true) {
             wxFontEncoding alt_enc;
             if (self->GetAltForEncoding(encoding, &alt_enc, facename, interactive))
                 return PyInt_FromLong(alt_enc);
@@ -404,7 +417,8 @@ public:
 
 
     // checks whether given encoding is available in given face or not.
-    // If no facename is given,
+    // If no facename is given (default), return true if it's available in any
+    // facename at all.
     bool IsEncodingAvailable(wxFontEncoding encoding,
                              const wxString& facename = wxPyEmptyString);
 
@@ -422,41 +436,71 @@ public:
 %newgroup
 
 
+MustHaveApp(wxFont);
+MustHaveApp(wxFont::GetDefaultEncoding);
+MustHaveApp(wxFont::SetDefaultEncoding);
+
 class wxFont : public wxGDIObject {
 public:
+    %pythonPrepend wxFont   "if kwargs.has_key('faceName'): kwargs['face'] = kwargs['faceName'];del kwargs['faceName']"
+
     wxFont( int pointSize, int family, int style, int weight,
-            bool underline=False, const wxString& face = wxPyEmptyString,
+            bool underline=false, const wxString& face = wxPyEmptyString,
             wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
     ~wxFont();
 
-    %name(FontFromNativeInfo) wxFont(const wxNativeFontInfo& info);
+    %RenameCtor(FontFromNativeInfo,  wxFont(const wxNativeFontInfo& info));
     %extend {
-        %name(FontFromNativeInfoString) wxFont(const wxString& info) {
+        %RenameCtor(FontFromNativeInfoString, wxFont(const wxString& info))
+        {
             wxNativeFontInfo nfi;
             nfi.FromString(info);
             return new wxFont(nfi);
         }
 
-        %name(Font2) wxFont(int pointSize,
-                              wxFontFamily family,
-                              int flags = wxFONTFLAG_DEFAULT,
-                              const wxString& face = wxPyEmptyString,
-                              wxFontEncoding encoding = wxFONTENCODING_DEFAULT) {
+        %RenameCtor(Font2,  wxFont(int pointSize,
+                                   wxFontFamily family,
+                                   int flags = wxFONTFLAG_DEFAULT,
+                                   const wxString& face = wxPyEmptyString,
+                                   wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
+        {
             return wxFont::New(pointSize, family, flags, face, encoding);
         }
     }
 
+    // There is a real ctor for this on wxMSW, but not the others, so just use
+    // the factory funciton in all cases.
+    %extend {
+        %RenameCtor(FontFromPixelSize, wxFont(const wxSize& pixelSize,
+                                              int family,
+                                              int style,
+                                              int weight,
+                                              bool underlined = false,
+                                              const wxString& face = wxEmptyString,
+                                              wxFontEncoding encoding = wxFONTENCODING_DEFAULT))
+        {
+            return wxFontBase::New(pixelSize, family,
+                                   style, weight, underlined,
+                                   face, encoding);
+        }
+    }
+
+    
 
     // was the font successfully created?
     bool Ok() const;
     %pythoncode { def __nonzero__(self): return self.Ok() }
 
     // comparison
-    bool operator == (const wxFont& font) const;
-    bool operator != (const wxFont& font) const;
+    %extend {
+        bool __eq__(const wxFont* other) { return other ? (*self == *other) : false; }
+        bool __ne__(const wxFont* other) { return other ? (*self != *other) : true;  }
+    }
 
     // accessors: get the font characteristics
     virtual int GetPointSize() const;
+    virtual wxSize GetPixelSize() const;
+    virtual bool IsUsingSizeInPixels() const;
     virtual int GetFamily() const;
     virtual int GetStyle() const;
     virtual int GetWeight() const;
@@ -472,6 +516,7 @@ public:
 
     // change the font characteristics
     virtual void SetPointSize( int pointSize );
+    virtual void SetPixelSize( const wxSize& pixelSize );
     virtual void SetFamily( int family );
     virtual void SetStyle( int style );
     virtual void SetWeight( int weight );
@@ -479,7 +524,7 @@ public:
     virtual void SetUnderlined( bool underlined );
     virtual void SetEncoding(wxFontEncoding encoding);
     void SetNativeFontInfo(const wxNativeFontInfo& info);
-    %name(SetNativeFontInfoFromString) void SetNativeFontInfo(const wxString& info);
+    %Rename(SetNativeFontInfoFromString, void, SetNativeFontInfo(const wxString& info));
     void SetNativeFontInfoUserDesc(const wxString& info);
 
     // translate the fonts into human-readable string (i.e. GetStyleString()
@@ -489,14 +534,14 @@ public:
     wxString GetWeightString() const;
 
     // Unofficial API, don't use
-    virtual void SetNoAntiAliasing( bool no = True );
-    virtual bool GetNoAntiAliasing();
+    virtual void SetNoAntiAliasing( bool no = true );
+    virtual bool GetNoAntiAliasing() const;
 
     // the default encoding is used for creating all fonts with default
     // encoding parameter
     static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
     static void SetDefaultEncoding(wxFontEncoding encoding);
-};    
+};
 
 
 
@@ -521,9 +566,12 @@ IMP_PYCALLBACK_BOOL_STRINGSTRING(wxPyFontEnumerator, wxFontEnumerator, OnFontEnc
 
 %}
 
-%name(FontEnumerator) class wxPyFontEnumerator {
+MustHaveApp(wxPyFontEnumerator);
+
+%rename(FontEnumerator) wxPyFontEnumerator;
+class wxPyFontEnumerator {
 public:
-    %addtofunc wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)"
+    %pythonAppend wxPyFontEnumerator "self._setCallbackInfo(self, FontEnumerator, 0)"
 
     wxPyFontEnumerator();
     ~wxPyFontEnumerator();
@@ -531,7 +579,7 @@ public:
 
     bool EnumerateFacenames(
         wxFontEncoding encoding = wxFONTENCODING_SYSTEM, // all
-        bool fixedWidthOnly = False);
+        bool fixedWidthOnly = false);
 
     bool EnumerateEncodings(const wxString& facename = wxPyEmptyString);
 
@@ -540,12 +588,18 @@ public:
     %extend {
         PyObject* GetEncodings() {
             wxArrayString* arr = self->GetEncodings();
-            return wxArrayString2PyList_helper(*arr);
+            if (arr)
+                return wxArrayString2PyList_helper(*arr);
+            else
+                return PyList_New(0);
         }
 
         PyObject* GetFacenames() {
             wxArrayString* arr = self->GetFacenames();
-            return wxArrayString2PyList_helper(*arr);
+            if (arr)
+                return wxArrayString2PyList_helper(*arr);
+            else
+                return PyList_New(0);
         }
     }
 };