#include <ctype.h>
-#include <wx/wx.h>
-#include <wx/tokenzr.h>
-#include <wx/mstream.h>
-#include <wx/image.h>
-#include <wx/file.h>
+#include "wx/wx.h"
+#include "wx/tokenzr.h"
+#include "wx/mstream.h"
+#include "wx/image.h"
+#include "wx/file.h"
#include "wx/stc/stc.h"
#include "ScintillaWX.h"
int x, y;
GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
#endif
- int size = font.GetPointSize();
- wxString faceName = font.GetFaceName();
- bool bold = font.GetWeight() == wxBOLD;
- bool italic = font.GetStyle() != wxNORMAL;
- bool under = font.GetUnderlined();
-
- // TODO: add encoding/charset mapping
- StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
+ int size = font.GetPointSize();
+ wxString faceName = font.GetFaceName();
+ bool bold = font.GetWeight() == wxBOLD;
+ bool italic = font.GetStyle() != wxNORMAL;
+ bool under = font.GetUnderlined();
+ wxFontEncoding encoding = font.GetEncoding();
+
+ StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
}
// Set all font style attributes at once.
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);
}