-static wxColour wxColourFromSpec(const wxString& spec) {
- // spec should be #RRGGBB
- char* junk;
- int red = strtol(spec.Mid(1,2), &junk, 16);
- int green = strtol(spec.Mid(3,2), &junk, 16);
- int blue = strtol(spec.Mid(5,2), &junk, 16);
- return wxColour(red, green, blue);
-}
-
-
-void wxStyledTextCtrl::StyleClearAll() {
- SendMsg(SCI_STYLECLEARALL);
-}
-
-
-void wxStyledTextCtrl::StyleResetDefault() {
- SendMsg(SCI_STYLERESETDEFAULT);
-}
-
-
-
-// Extract style settings from a spec-string which is composed of one or
-// more of the following comma separated elements:
-//
-// bold turns on bold
-// italic turns on italics
-// fore:#RRGGBB sets the foreground colour
-// back:#RRGGBB sets the background colour
-// face:[facename] sets the font face name to use
-// size:[num] sets the font size in points
-// eol turns on eol filling
-// underline turns on underlining
-//
-
-void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
-
- wxStringTokenizer tkz(spec, ",");
- while (tkz.HasMoreTokens()) {
- wxString token = tkz.GetNextToken();
-
- wxString option = token.BeforeFirst(':');
- wxString val = token.AfterFirst(':');
-
- if (option == "bold")
- StyleSetBold(styleNum, true);
-
- else if (option == "italic")
- StyleSetItalic(styleNum, true);
-
- else if (option == "underline")
- StyleSetUnderline(styleNum, true);
-
- else if (option == "eol")
- StyleSetEOLFilled(styleNum, true);
-
- else if (option == "size") {
- long points;
- if (val.ToLong(&points))
- StyleSetSize(styleNum, points);
- }
-
- else if (option == "face")
- StyleSetFaceName(styleNum, val);
-
- else if (option == "fore")
- StyleSetForeground(styleNum, wxColourFromSpec(val));
-
- else if (option == "back")
- StyleSetBackground(styleNum, wxColourFromSpec(val));
- }
-}
-
-
-void wxStyledTextCtrl::StyleSetForeground(int styleNum, const wxColour& colour) {
- SendMsg(SCI_STYLESETFORE, styleNum, wxColourAsLong(colour));
-}
-
-
-void wxStyledTextCtrl::StyleSetBackground(int styleNum, const wxColour& colour) {
- SendMsg(SCI_STYLESETBACK, styleNum, wxColourAsLong(colour));
-}
-
-
-void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
- int size = font.GetPointSize();
- wxString faceName = font.GetFaceName();
- bool bold = font.GetWeight() == wxBOLD;
- bool italic = font.GetStyle() != wxNORMAL;
- bool under = font.GetUnderlined();
-
- StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
-}
-
-
-void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
- const wxString& faceName,
- bool bold, bool italic,
- bool underline) {
- StyleSetSize(styleNum, size);
- StyleSetFaceName(styleNum, faceName);
- StyleSetBold(styleNum, bold);
- StyleSetItalic(styleNum, italic);
- StyleSetUnderline(styleNum, underline);
-}
-
-
-void wxStyledTextCtrl::StyleSetBold(int styleNum, bool bold) {
- SendMsg(SCI_STYLESETBOLD, styleNum, bold);
-}
-
-
-void wxStyledTextCtrl::StyleSetItalic(int styleNum, bool italic) {
- SendMsg(SCI_STYLESETITALIC, styleNum, italic);
-}
-
-
-void wxStyledTextCtrl::StyleSetFaceName(int styleNum, const wxString& faceName) {
- SendMsg(SCI_STYLESETFONT, styleNum, (long)faceName.c_str());
-}
-
-
-void wxStyledTextCtrl::StyleSetSize(int styleNum, int pointSize) {
- SendMsg(SCI_STYLESETSIZE, styleNum, pointSize);
-}
-
-
-void wxStyledTextCtrl::StyleSetEOLFilled(int styleNum, bool fillEOL) {
- SendMsg(SCI_STYLESETEOLFILLED, styleNum, fillEOL);
-}
-
-
-void wxStyledTextCtrl::StyleSetUnderline(int styleNum, bool underline) {
- SendMsg(SCI_STYLESETUNDERLINE, styleNum, underline);
-}
-
-
-//----------------------------------------------------------------------
-// Margins in the edit area
-
-int wxStyledTextCtrl::GetLeftMargin() {
- return LOWORD(SendMsg(EM_GETMARGINS));