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