Allow to set a style's wxFontEncoding

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33767 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2005-04-19 22:30:40 +00:00
parent 6421f57a54
commit 3727c043a8
16 changed files with 477 additions and 192 deletions

View 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);

View 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];

View 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);',

View 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);
}

View 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);
}

View 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);