]> git.saurik.com Git - wxWidgets.git/commitdiff
Allow to set a style's wxFontEncoding
authorRobin Dunn <robin@alldunn.com>
Tue, 19 Apr 2005 22:30:40 +0000 (22:30 +0000)
committerRobin Dunn <robin@alldunn.com>
Tue, 19 Apr 2005 22:30:40 +0000 (22:30 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33767 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

16 files changed:
contrib/include/wx/stc/stc.h
contrib/src/stc/PlatWX.cpp
contrib/src/stc/gen_iface.py
contrib/src/stc/stc.cpp
contrib/src/stc/stc.cpp.in
contrib/src/stc/stc.h.in
include/wx/stc/stc.h
src/stc/PlatWX.cpp
src/stc/gen_iface.py
src/stc/stc.cpp
src/stc/stc.cpp.in
src/stc/stc.h.in
wxPython/contrib/stc/_stc_docstrings.i
wxPython/contrib/stc/_stc_gendocs.i
wxPython/contrib/stc/stc.i
wxPython/demo/StyledTextCtrl_1.py

index f797285132d6f16dd11f79b1b558ac1884bc7410..30c0655dcd1fae245e0cdb29d47435df6604f22c 100644 (file)
@@ -1736,9 +1736,6 @@ public:
     // Set a style to be mixed case, or to force upper or lower case.
     void StyleSetCase(int style, int caseForce);
 
-    // Set the character set of the font in a style.
-    void StyleSetCharacterSet(int style, int characterSet);
-
     // Set a style to be a hotspot or not.
     void StyleSetHotSpot(int style, bool hotspot);
 
@@ -2838,15 +2835,22 @@ public:
     void StyleSetFontAttr(int styleNum, int size,
                           const wxString& faceName,
                           bool bold, bool italic,
-                          bool underline);
+                          bool underline,
+                          wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
+
 
+    // Set the character set of the font in a style.  Converts the Scintilla
+    // character set values to a wxFontEncoding.
+    void StyleSetCharacterSet(int style, int characterSet);
 
+    // Set the font encoding to be used by a style.
+    void StyleSetFontEncoding(int style, wxFontEncoding encoding);
+    
 
     // Perform one of the operations defined by the wxSTC_CMD_* constants.
     void CmdKeyExecute(int cmd);
 
 
-
     // Set the left and right margin in the edit area, measured in pixels.
     void SetMargins(int left, int right);
 
index dfa9435994b395fd2d717e63294fcecb5572ef27..2e5309ef256b9d6fe163181416a32a2d5f45ed56 100644 (file)
@@ -99,86 +99,15 @@ Font::~Font() {
 }
 
 void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic, bool extraFontFlag) {
-    wxFontEncoding encoding;
 
     Release();
 
-    switch (characterSet) {
-        default:
-        case wxSTC_CHARSET_ANSI:
-        case wxSTC_CHARSET_DEFAULT:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_BALTIC:
-            encoding = wxFONTENCODING_ISO8859_13;
-            break;
-
-        case wxSTC_CHARSET_CHINESEBIG5:
-            encoding = wxFONTENCODING_CP950;
-            break;
-
-        case wxSTC_CHARSET_EASTEUROPE:
-            encoding = wxFONTENCODING_ISO8859_2;
-            break;
-
-        case wxSTC_CHARSET_GB2312:
-            encoding = wxFONTENCODING_CP936;
-            break;
-
-        case wxSTC_CHARSET_GREEK:
-            encoding = wxFONTENCODING_ISO8859_7;
-            break;
-
-        case wxSTC_CHARSET_HANGUL:
-            encoding = wxFONTENCODING_CP949;
-            break;
-
-        case wxSTC_CHARSET_MAC:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_OEM:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_RUSSIAN:
-            encoding = wxFONTENCODING_KOI8;
-            break;
-
-        case wxSTC_CHARSET_SHIFTJIS:
-            encoding = wxFONTENCODING_CP932;
-            break;
-
-        case wxSTC_CHARSET_SYMBOL:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_TURKISH:
-            encoding = wxFONTENCODING_ISO8859_9;
-            break;
-
-        case wxSTC_CHARSET_JOHAB:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_HEBREW:
-            encoding = wxFONTENCODING_ISO8859_8;
-            break;
-
-        case wxSTC_CHARSET_ARABIC:
-            encoding = wxFONTENCODING_ISO8859_6;
-            break;
-
-        case wxSTC_CHARSET_VIETNAMESE:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_THAI:
-            encoding = wxFONTENCODING_ISO8859_11;
-            break;
-    }
-
+    // The minus one is done because since Scintilla uses SC_SHARSET_DEFAULT
+    // internally and we need to have wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT
+    // so we adjust the encoding before passing it to Scintilla.  See also
+    // wxStyledTextCtrl::StyleSetCharacterSet
+    wxFontEncoding encoding = (wxFontEncoding)(characterSet-1);
+    
     wxFontEncodingArray ea = wxEncodingConverter::GetPlatformEquivalents(encoding);
     if (ea.GetCount())
         encoding = ea[0];
index 67df43a35859a3326ff62e6f169ad1d78eeb5849..9a6c18820040dde28e84dfae1f9e2302e62da976 100644 (file)
@@ -229,7 +229,8 @@ methodOverrideMap = {
     'SetSelBack' : ('SetSelBackground', 0, 0, 0),
     'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
     'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
-
+    'StyleSetCharacterSet' : (None, 0, 0, 0),
+    
     'AssignCmdKey' :
     ('CmdKeyAssign',
      'void %s(int key, int modifiers, int cmd);',
index cb33d568a919b86afba16f16a6283b75142d9ad4..1bd4e080d6b960e9909fd56206fa615b2ecbecec 100644 (file)
@@ -622,11 +622,6 @@ void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
     SendMsg(2060, style, caseForce);
 }
 
-// Set the character set of the font in a style.
-void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
-    SendMsg(2066, style, characterSet);
-}
-
 // Set a style to be a hotspot or not.
 void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) {
     SendMsg(2409, style, hotspot);
@@ -2543,14 +2538,113 @@ void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
                                         const wxString& faceName,
                                         bool bold, bool italic,
-                                        bool underline) {
+                                        bool underline,
+                                        wxFontEncoding encoding) {
     StyleSetSize(styleNum, size);
     StyleSetFaceName(styleNum, faceName);
     StyleSetBold(styleNum, bold);
     StyleSetItalic(styleNum, italic);
     StyleSetUnderline(styleNum, underline);
+    StyleSetFontEncoding(styleNum, encoding);
+}
 
-    // TODO: add encoding/charset mapping
+
+// Set the character set of the font in a style.  Converts the Scintilla
+// character set values to a wxFontEncoding.
+void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
+{
+    wxFontEncoding encoding;
+
+    // Translate the Scintilla characterSet to a wxFontEncoding
+    switch (characterSet) {
+        default:
+        case wxSTC_CHARSET_ANSI:
+        case wxSTC_CHARSET_DEFAULT:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_BALTIC:
+            encoding = wxFONTENCODING_ISO8859_13;
+            break;
+
+        case wxSTC_CHARSET_CHINESEBIG5:
+            encoding = wxFONTENCODING_CP950;
+            break;
+
+        case wxSTC_CHARSET_EASTEUROPE:
+            encoding = wxFONTENCODING_ISO8859_2;
+            break;
+
+        case wxSTC_CHARSET_GB2312:
+            encoding = wxFONTENCODING_CP936;
+            break;
+
+        case wxSTC_CHARSET_GREEK:
+            encoding = wxFONTENCODING_ISO8859_7;
+            break;
+
+        case wxSTC_CHARSET_HANGUL:
+            encoding = wxFONTENCODING_CP949;
+            break;
+
+        case wxSTC_CHARSET_MAC:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_OEM:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_RUSSIAN:
+            encoding = wxFONTENCODING_KOI8;
+            break;
+
+        case wxSTC_CHARSET_SHIFTJIS:
+            encoding = wxFONTENCODING_CP932;
+            break;
+
+        case wxSTC_CHARSET_SYMBOL:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_TURKISH:
+            encoding = wxFONTENCODING_ISO8859_9;
+            break;
+
+        case wxSTC_CHARSET_JOHAB:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_HEBREW:
+            encoding = wxFONTENCODING_ISO8859_8;
+            break;
+
+        case wxSTC_CHARSET_ARABIC:
+            encoding = wxFONTENCODING_ISO8859_6;
+            break;
+
+        case wxSTC_CHARSET_VIETNAMESE:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_THAI:
+            encoding = wxFONTENCODING_ISO8859_11;
+            break;
+    }
+
+    // We just have Scintilla track the wxFontEncoding for us.  It gets used
+    // in Font::Create in PlatWX.cpp.  We add one to the value so that the
+    // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
+    // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
+    // to wxFONENCODING_DEFAULT in Font::Create.
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
+}
+
+
+// Set the font encoding to be used by a style.
+void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
+{
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
 }
 
 
index 18901c41f8d9aef6018834cc572a9458e480af49..989a49401bf42536a577464d472d73068725e7b6 100644 (file)
@@ -310,14 +310,113 @@ void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
                                         const wxString& faceName,
                                         bool bold, bool italic,
-                                        bool underline) {
+                                        bool underline,
+                                        wxFontEncoding encoding) {
     StyleSetSize(styleNum, size);
     StyleSetFaceName(styleNum, faceName);
     StyleSetBold(styleNum, bold);
     StyleSetItalic(styleNum, italic);
     StyleSetUnderline(styleNum, underline);
+    StyleSetFontEncoding(styleNum, encoding);
+}
 
-    // TODO: add encoding/charset mapping
+
+// Set the character set of the font in a style.  Converts the Scintilla
+// character set values to a wxFontEncoding.
+void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
+{
+    wxFontEncoding encoding;
+
+    // Translate the Scintilla characterSet to a wxFontEncoding
+    switch (characterSet) {
+        default:
+        case wxSTC_CHARSET_ANSI:
+        case wxSTC_CHARSET_DEFAULT:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_BALTIC:
+            encoding = wxFONTENCODING_ISO8859_13;
+            break;
+
+        case wxSTC_CHARSET_CHINESEBIG5:
+            encoding = wxFONTENCODING_CP950;
+            break;
+
+        case wxSTC_CHARSET_EASTEUROPE:
+            encoding = wxFONTENCODING_ISO8859_2;
+            break;
+
+        case wxSTC_CHARSET_GB2312:
+            encoding = wxFONTENCODING_CP936;
+            break;
+
+        case wxSTC_CHARSET_GREEK:
+            encoding = wxFONTENCODING_ISO8859_7;
+            break;
+
+        case wxSTC_CHARSET_HANGUL:
+            encoding = wxFONTENCODING_CP949;
+            break;
+
+        case wxSTC_CHARSET_MAC:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_OEM:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_RUSSIAN:
+            encoding = wxFONTENCODING_KOI8;
+            break;
+
+        case wxSTC_CHARSET_SHIFTJIS:
+            encoding = wxFONTENCODING_CP932;
+            break;
+
+        case wxSTC_CHARSET_SYMBOL:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_TURKISH:
+            encoding = wxFONTENCODING_ISO8859_9;
+            break;
+
+        case wxSTC_CHARSET_JOHAB:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_HEBREW:
+            encoding = wxFONTENCODING_ISO8859_8;
+            break;
+
+        case wxSTC_CHARSET_ARABIC:
+            encoding = wxFONTENCODING_ISO8859_6;
+            break;
+
+        case wxSTC_CHARSET_VIETNAMESE:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_THAI:
+            encoding = wxFONTENCODING_ISO8859_11;
+            break;
+    }
+
+    // We just have Scintilla track the wxFontEncoding for us.  It gets used
+    // in Font::Create in PlatWX.cpp.  We add one to the value so that the
+    // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
+    // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
+    // to wxFONENCODING_DEFAULT in Font::Create.
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
+}
+
+
+// Set the font encoding to be used by a style.
+void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
+{
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
 }
 
 
index 0df1ebccf055bb0416ce156114005095616dc971..35983ed91ca5141c1d0710268dc4a7e59762c5c9 100644 (file)
@@ -149,15 +149,22 @@ public:
     void StyleSetFontAttr(int styleNum, int size,
                           const wxString& faceName,
                           bool bold, bool italic,
-                          bool underline);
+                          bool underline,
+                          wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
 
 
+    // Set the character set of the font in a style.  Converts the Scintilla
+    // character set values to a wxFontEncoding.
+    void StyleSetCharacterSet(int style, int characterSet);
+
+    // Set the font encoding to be used by a style.
+    void StyleSetFontEncoding(int style, wxFontEncoding encoding);
+    
 
     // Perform one of the operations defined by the wxSTC_CMD_* constants.
     void CmdKeyExecute(int cmd);
 
 
-
     // Set the left and right margin in the edit area, measured in pixels.
     void SetMargins(int left, int right);
 
index f797285132d6f16dd11f79b1b558ac1884bc7410..30c0655dcd1fae245e0cdb29d47435df6604f22c 100644 (file)
@@ -1736,9 +1736,6 @@ public:
     // Set a style to be mixed case, or to force upper or lower case.
     void StyleSetCase(int style, int caseForce);
 
-    // Set the character set of the font in a style.
-    void StyleSetCharacterSet(int style, int characterSet);
-
     // Set a style to be a hotspot or not.
     void StyleSetHotSpot(int style, bool hotspot);
 
@@ -2838,15 +2835,22 @@ public:
     void StyleSetFontAttr(int styleNum, int size,
                           const wxString& faceName,
                           bool bold, bool italic,
-                          bool underline);
+                          bool underline,
+                          wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
+
 
+    // Set the character set of the font in a style.  Converts the Scintilla
+    // character set values to a wxFontEncoding.
+    void StyleSetCharacterSet(int style, int characterSet);
 
+    // Set the font encoding to be used by a style.
+    void StyleSetFontEncoding(int style, wxFontEncoding encoding);
+    
 
     // Perform one of the operations defined by the wxSTC_CMD_* constants.
     void CmdKeyExecute(int cmd);
 
 
-
     // Set the left and right margin in the edit area, measured in pixels.
     void SetMargins(int left, int right);
 
index dfa9435994b395fd2d717e63294fcecb5572ef27..2e5309ef256b9d6fe163181416a32a2d5f45ed56 100644 (file)
@@ -99,86 +99,15 @@ Font::~Font() {
 }
 
 void Font::Create(const char *faceName, int characterSet, int size, bool bold, bool italic, bool extraFontFlag) {
-    wxFontEncoding encoding;
 
     Release();
 
-    switch (characterSet) {
-        default:
-        case wxSTC_CHARSET_ANSI:
-        case wxSTC_CHARSET_DEFAULT:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_BALTIC:
-            encoding = wxFONTENCODING_ISO8859_13;
-            break;
-
-        case wxSTC_CHARSET_CHINESEBIG5:
-            encoding = wxFONTENCODING_CP950;
-            break;
-
-        case wxSTC_CHARSET_EASTEUROPE:
-            encoding = wxFONTENCODING_ISO8859_2;
-            break;
-
-        case wxSTC_CHARSET_GB2312:
-            encoding = wxFONTENCODING_CP936;
-            break;
-
-        case wxSTC_CHARSET_GREEK:
-            encoding = wxFONTENCODING_ISO8859_7;
-            break;
-
-        case wxSTC_CHARSET_HANGUL:
-            encoding = wxFONTENCODING_CP949;
-            break;
-
-        case wxSTC_CHARSET_MAC:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_OEM:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_RUSSIAN:
-            encoding = wxFONTENCODING_KOI8;
-            break;
-
-        case wxSTC_CHARSET_SHIFTJIS:
-            encoding = wxFONTENCODING_CP932;
-            break;
-
-        case wxSTC_CHARSET_SYMBOL:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_TURKISH:
-            encoding = wxFONTENCODING_ISO8859_9;
-            break;
-
-        case wxSTC_CHARSET_JOHAB:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_HEBREW:
-            encoding = wxFONTENCODING_ISO8859_8;
-            break;
-
-        case wxSTC_CHARSET_ARABIC:
-            encoding = wxFONTENCODING_ISO8859_6;
-            break;
-
-        case wxSTC_CHARSET_VIETNAMESE:
-            encoding = wxFONTENCODING_DEFAULT;
-            break;
-
-        case wxSTC_CHARSET_THAI:
-            encoding = wxFONTENCODING_ISO8859_11;
-            break;
-    }
-
+    // The minus one is done because since Scintilla uses SC_SHARSET_DEFAULT
+    // internally and we need to have wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT
+    // so we adjust the encoding before passing it to Scintilla.  See also
+    // wxStyledTextCtrl::StyleSetCharacterSet
+    wxFontEncoding encoding = (wxFontEncoding)(characterSet-1);
+    
     wxFontEncodingArray ea = wxEncodingConverter::GetPlatformEquivalents(encoding);
     if (ea.GetCount())
         encoding = ea[0];
index 67df43a35859a3326ff62e6f169ad1d78eeb5849..9a6c18820040dde28e84dfae1f9e2302e62da976 100644 (file)
@@ -229,7 +229,8 @@ methodOverrideMap = {
     'SetSelBack' : ('SetSelBackground', 0, 0, 0),
     'SetCaretFore' : ('SetCaretForeground', 0, 0, 0),
     'StyleSetFont' : ('StyleSetFaceName', 0, 0, 0),
-
+    'StyleSetCharacterSet' : (None, 0, 0, 0),
+    
     'AssignCmdKey' :
     ('CmdKeyAssign',
      'void %s(int key, int modifiers, int cmd);',
index cb33d568a919b86afba16f16a6283b75142d9ad4..1bd4e080d6b960e9909fd56206fa615b2ecbecec 100644 (file)
@@ -622,11 +622,6 @@ void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
     SendMsg(2060, style, caseForce);
 }
 
-// Set the character set of the font in a style.
-void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
-    SendMsg(2066, style, characterSet);
-}
-
 // Set a style to be a hotspot or not.
 void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) {
     SendMsg(2409, style, hotspot);
@@ -2543,14 +2538,113 @@ void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
                                         const wxString& faceName,
                                         bool bold, bool italic,
-                                        bool underline) {
+                                        bool underline,
+                                        wxFontEncoding encoding) {
     StyleSetSize(styleNum, size);
     StyleSetFaceName(styleNum, faceName);
     StyleSetBold(styleNum, bold);
     StyleSetItalic(styleNum, italic);
     StyleSetUnderline(styleNum, underline);
+    StyleSetFontEncoding(styleNum, encoding);
+}
 
-    // TODO: add encoding/charset mapping
+
+// Set the character set of the font in a style.  Converts the Scintilla
+// character set values to a wxFontEncoding.
+void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
+{
+    wxFontEncoding encoding;
+
+    // Translate the Scintilla characterSet to a wxFontEncoding
+    switch (characterSet) {
+        default:
+        case wxSTC_CHARSET_ANSI:
+        case wxSTC_CHARSET_DEFAULT:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_BALTIC:
+            encoding = wxFONTENCODING_ISO8859_13;
+            break;
+
+        case wxSTC_CHARSET_CHINESEBIG5:
+            encoding = wxFONTENCODING_CP950;
+            break;
+
+        case wxSTC_CHARSET_EASTEUROPE:
+            encoding = wxFONTENCODING_ISO8859_2;
+            break;
+
+        case wxSTC_CHARSET_GB2312:
+            encoding = wxFONTENCODING_CP936;
+            break;
+
+        case wxSTC_CHARSET_GREEK:
+            encoding = wxFONTENCODING_ISO8859_7;
+            break;
+
+        case wxSTC_CHARSET_HANGUL:
+            encoding = wxFONTENCODING_CP949;
+            break;
+
+        case wxSTC_CHARSET_MAC:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_OEM:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_RUSSIAN:
+            encoding = wxFONTENCODING_KOI8;
+            break;
+
+        case wxSTC_CHARSET_SHIFTJIS:
+            encoding = wxFONTENCODING_CP932;
+            break;
+
+        case wxSTC_CHARSET_SYMBOL:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_TURKISH:
+            encoding = wxFONTENCODING_ISO8859_9;
+            break;
+
+        case wxSTC_CHARSET_JOHAB:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_HEBREW:
+            encoding = wxFONTENCODING_ISO8859_8;
+            break;
+
+        case wxSTC_CHARSET_ARABIC:
+            encoding = wxFONTENCODING_ISO8859_6;
+            break;
+
+        case wxSTC_CHARSET_VIETNAMESE:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_THAI:
+            encoding = wxFONTENCODING_ISO8859_11;
+            break;
+    }
+
+    // We just have Scintilla track the wxFontEncoding for us.  It gets used
+    // in Font::Create in PlatWX.cpp.  We add one to the value so that the
+    // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
+    // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
+    // to wxFONENCODING_DEFAULT in Font::Create.
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
+}
+
+
+// Set the font encoding to be used by a style.
+void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
+{
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
 }
 
 
index 18901c41f8d9aef6018834cc572a9458e480af49..989a49401bf42536a577464d472d73068725e7b6 100644 (file)
@@ -310,14 +310,113 @@ void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
                                         const wxString& faceName,
                                         bool bold, bool italic,
-                                        bool underline) {
+                                        bool underline,
+                                        wxFontEncoding encoding) {
     StyleSetSize(styleNum, size);
     StyleSetFaceName(styleNum, faceName);
     StyleSetBold(styleNum, bold);
     StyleSetItalic(styleNum, italic);
     StyleSetUnderline(styleNum, underline);
+    StyleSetFontEncoding(styleNum, encoding);
+}
 
-    // TODO: add encoding/charset mapping
+
+// Set the character set of the font in a style.  Converts the Scintilla
+// character set values to a wxFontEncoding.
+void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
+{
+    wxFontEncoding encoding;
+
+    // Translate the Scintilla characterSet to a wxFontEncoding
+    switch (characterSet) {
+        default:
+        case wxSTC_CHARSET_ANSI:
+        case wxSTC_CHARSET_DEFAULT:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_BALTIC:
+            encoding = wxFONTENCODING_ISO8859_13;
+            break;
+
+        case wxSTC_CHARSET_CHINESEBIG5:
+            encoding = wxFONTENCODING_CP950;
+            break;
+
+        case wxSTC_CHARSET_EASTEUROPE:
+            encoding = wxFONTENCODING_ISO8859_2;
+            break;
+
+        case wxSTC_CHARSET_GB2312:
+            encoding = wxFONTENCODING_CP936;
+            break;
+
+        case wxSTC_CHARSET_GREEK:
+            encoding = wxFONTENCODING_ISO8859_7;
+            break;
+
+        case wxSTC_CHARSET_HANGUL:
+            encoding = wxFONTENCODING_CP949;
+            break;
+
+        case wxSTC_CHARSET_MAC:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_OEM:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_RUSSIAN:
+            encoding = wxFONTENCODING_KOI8;
+            break;
+
+        case wxSTC_CHARSET_SHIFTJIS:
+            encoding = wxFONTENCODING_CP932;
+            break;
+
+        case wxSTC_CHARSET_SYMBOL:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_TURKISH:
+            encoding = wxFONTENCODING_ISO8859_9;
+            break;
+
+        case wxSTC_CHARSET_JOHAB:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_HEBREW:
+            encoding = wxFONTENCODING_ISO8859_8;
+            break;
+
+        case wxSTC_CHARSET_ARABIC:
+            encoding = wxFONTENCODING_ISO8859_6;
+            break;
+
+        case wxSTC_CHARSET_VIETNAMESE:
+            encoding = wxFONTENCODING_DEFAULT;
+            break;
+
+        case wxSTC_CHARSET_THAI:
+            encoding = wxFONTENCODING_ISO8859_11;
+            break;
+    }
+
+    // We just have Scintilla track the wxFontEncoding for us.  It gets used
+    // in Font::Create in PlatWX.cpp.  We add one to the value so that the
+    // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
+    // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
+    // to wxFONENCODING_DEFAULT in Font::Create.
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
+}
+
+
+// Set the font encoding to be used by a style.
+void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
+{
+    SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
 }
 
 
index 0df1ebccf055bb0416ce156114005095616dc971..35983ed91ca5141c1d0710268dc4a7e59762c5c9 100644 (file)
@@ -149,15 +149,22 @@ public:
     void StyleSetFontAttr(int styleNum, int size,
                           const wxString& faceName,
                           bool bold, bool italic,
-                          bool underline);
+                          bool underline,
+                          wxFontEncoding encoding=wxFONTENCODING_DEFAULT);
 
 
+    // Set the character set of the font in a style.  Converts the Scintilla
+    // character set values to a wxFontEncoding.
+    void StyleSetCharacterSet(int style, int characterSet);
+
+    // Set the font encoding to be used by a style.
+    void StyleSetFontEncoding(int style, wxFontEncoding encoding);
+    
 
     // Perform one of the operations defined by the wxSTC_CMD_* constants.
     void CmdKeyExecute(int cmd);
 
 
-
     // Set the left and right margin in the edit area, measured in pixels.
     void SetMargins(int left, int right);
 
index 740638b7c8761009af5752057d6a052127d51bcf..423aebf4f69052b9b0d608c9cf0e087390c03497 100644 (file)
@@ -56,6 +56,13 @@ attributes of a `wx.Font`.", "");
 DocStr(wxStyledTextCtrl::StyleSetFontAttr,
 "Set all font style attributes at once.", "");
 
+DocStr(wxStyledTextCtrl::StyleSetCharacterSet,
+       "Set the character set of the font in a style.  Converts the Scintilla
+wx.stc.STC_CHARSET_* set values to a wxFontEncoding.", "");
+
+DocStr(wxStyledTextCtrl::StyleSetFontEncoding,
+       "Set the font encoding to be used by a style.", "");
+
 DocStr(wxStyledTextCtrl::CmdKeyExecute,
 "Perform one of the operations defined by the wx.stc.STC_CMD_* constants.", "");
 
index 0678e44e11675f995269f8d8aa8cb5443de42a9e..6cc097871c57082750015d42836220a896dfd19c 100644 (file)
@@ -209,9 +209,6 @@ DocStr(wxStyledTextCtrl::StyleSetUnderline,
 DocStr(wxStyledTextCtrl::StyleSetCase,
 "Set a style to be mixed case, or to force upper or lower case.", "");
 
-DocStr(wxStyledTextCtrl::StyleSetCharacterSet,
-"Set the character set of the font in a style.", "");
-
 DocStr(wxStyledTextCtrl::StyleSetHotSpot,
 "Set a style to be a hotspot or not.", "");
 
index 9fc7c31355f58a62a1aff84dc056f2b3874e39b4..3f11a3fc07250709501e2c3308e4390591c38b2e 100644 (file)
@@ -30,6 +30,8 @@ languages are built-in."
 
 %import core.i
 %import misc.i  // for DnD
+//%import gdi.i   // for wxFontEncoding
+
 %pythoncode { wx = _core }
 %pythoncode { __docfilter__ = wx.__DocFilter(globals()) }
 
@@ -39,6 +41,8 @@ MAKE_CONST_WXSTRING(STCNameStr);
 %include _stc_rename.i
 %include _stc_docstrings.i
 
+enum wxFontEncoding;  // forward declare
+
 MustHaveApp(wxStyledTextCtrl);
 
 //---------------------------------------------------------------------------
index b62381bfb89db4f57ebc5f0d168aa742626bde56..552aa3950237febc2b9f567d8fb119ef5e9bf7a3 100644 (file)
@@ -192,7 +192,16 @@ def runTest(frame, nb, log):
         ed.AddText('\tRussian: ')
         ed.AddText(unitext)
         ed.GotoPos(0)
-
+    #else:
+    #    #ed.StyleSetFontEncoding(stc.STC_STYLE_DEFAULT, wx.FONTENCODING_KOI8)
+    #    #text = u'\u041f\u0438\u0442\u043e\u043d - \u043b\u0443\u0447\u0448\u0438\u0439 \u044f\u0437\u044b\u043a \n\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f!'
+    #    #text = text.encode('koi8-r')
+    #    #ed.StyleSetFontEncoding(stc.STC_STYLE_DEFAULT, wx.FONTENCODING_BIG5)
+    #    #text = u'Python \u662f\u6700\u597d\u7684\u7de8\u7a0b\u8a9e\u8a00\uff01'
+    #    #text = text.encode('big5')
+    #    ed.GotoPos(ed.GetLength())
+    #    ed.AddText('\n\n' + text)
+        
     ed.EmptyUndoBuffer()
 
     # make some styles