1
///////////////////////////////////////////////////////////////////////////////
3
// Purpose: wxSTEditor Styles initialization
6
// RCS-ID: $Id: stestyls.cpp 7603 2011-11-20 15:49:42Z mortenmacfly $
7
// Copyright: (c) John Labenski, Otto Wyss
8
// Licence: wxWidgets licence
9
///////////////////////////////////////////////////////////////////////////////
12
Updated to SciTE 1.71, 7/05/05
14
Code below marked with this copyright is under this license.
15
"Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>"
17
License for Scintilla and SciTE
19
Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
23
Permission to use, copy, modify, and distribute this software and its
24
documentation for any purpose and without fee is hereby granted,
25
provided that the above copyright notice appear in all copies and that
26
both that copyright notice and this permission notice appear in
27
supporting documentation.
29
NEIL HODGSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
30
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
31
AND FITNESS, IN NO EVENT SHALL NEIL HODGSON BE LIABLE FOR ANY
32
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
33
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
34
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
35
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
36
OR PERFORMANCE OF THIS SOFTWARE.
41
#include <wx/stedit/stestyls.h>
42
#include <wx/stedit/stedit.h>
44
#include <wx/arrimpl.cpp>
45
WX_DEFINE_OBJARRAY(wxArraySTEditorStyle);
46
DEFINE_PAIRARRAY_INTKEY(wxSTEditorStyle, wxSTEPairArrayIntSTEStyle)
48
extern wxSTEditorStyles s_wxSTEditorStyles;
50
//----------------------------------------------------------------------------
51
// wxSTEditorStyles_RefData
52
//----------------------------------------------------------------------------
54
wxSTEPairArrayIntSTEStyle s_STE_PairArrayStyles;
56
class wxSTEditorStyles_RefData : public wxSTEditorPrefBase_RefData
59
wxSTEditorStyles_RefData()
61
m_pairArrayStyles = s_STE_PairArrayStyles;
64
wxSTEPairArrayIntSTEStyle m_pairArrayStyles;
67
//----------------------------------------------------------------------------
69
//----------------------------------------------------------------------------
70
IMPLEMENT_DYNAMIC_CLASS(wxSTEditorStyles, wxSTEditorPrefBase)
72
#define M_STYLEDATA ((wxSTEditorStyles_RefData *)m_refData)
74
wxSTEditorStyles& wxSTEditorStyles::GetGlobalEditorStyles()
76
return s_wxSTEditorStyles;
79
void wxSTEditorStyles::Init()
81
if (s_STE_PairArrayStyles.GetCount() != 0) return;
83
wxArrayInt &keyArr = s_STE_PairArrayStyles.GetKeys();
84
wxArraySTEditorStyle &valArr = s_STE_PairArrayStyles.GetValues();
88
keyArr.Add(STE_STYLE_DEFAULT); valArr.Add(wxSTEditorStyle(wxT("Default text"), 0x000000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, 0, STE_STYLE_USES_ALL));
89
keyArr.Add(STE_STYLE_KEYWORD1); valArr.Add(wxSTEditorStyle(wxT("Keyword 1"), 0x0000FF, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFONTSTYLE, STE_STYLE_USES_ALL));
90
keyArr.Add(STE_STYLE_KEYWORD2); valArr.Add(wxSTEditorStyle(wxT("Keyword 2"), 0x0000AA, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
91
keyArr.Add(STE_STYLE_KEYWORD3); valArr.Add(wxSTEditorStyle(wxT("Keyword 3"), 0x42426F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
92
keyArr.Add(STE_STYLE_KEYWORD4); valArr.Add(wxSTEditorStyle(wxT("Keyword 4"), 0xAA00AA, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
93
keyArr.Add(STE_STYLE_KEYWORD5); valArr.Add(wxSTEditorStyle(wxT("Keyword 5"), 0x2F2F2F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
94
keyArr.Add(STE_STYLE_KEYWORD6); valArr.Add(wxSTEditorStyle(wxT("Keyword 6"), 0x808080, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
95
keyArr.Add(STE_STYLE_COMMENT); valArr.Add(wxSTEditorStyle(wxT("Comment"), 0x238E23, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
96
keyArr.Add(STE_STYLE_COMMENTDOC); valArr.Add(wxSTEditorStyle(wxT("Comment doc"), 0x238E23, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
97
keyArr.Add(STE_STYLE_COMMENTLINE); valArr.Add(wxSTEditorStyle(wxT("Comment line"), 0x238E23, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
98
keyArr.Add(STE_STYLE_COMMENTOTHER); valArr.Add(wxSTEditorStyle(wxT("Comment other"), 0x238E23, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
99
keyArr.Add(STE_STYLE_CHARACTER); valArr.Add(wxSTEditorStyle(wxT("Character"), 0x9F9F9F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
100
keyArr.Add(STE_STYLE_CHARACTEREOL); valArr.Add(wxSTEditorStyle(wxT("Character EOL"), 0x9F9F9F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
101
keyArr.Add(STE_STYLE_STRING); valArr.Add(wxSTEditorStyle(wxT("String"), 0x2AA52A, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
102
keyArr.Add(STE_STYLE_STRINGEOL); valArr.Add(wxSTEditorStyle(wxT("String EOL"), 0x2AA52A, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
103
keyArr.Add(STE_STYLE_DELIMITER); valArr.Add(wxSTEditorStyle(wxT("Delimiter"), 0xCC3232, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
104
keyArr.Add(STE_STYLE_PUNCTUATION); valArr.Add(wxSTEditorStyle(wxT("Punctuation"), 0xCC3232, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
105
keyArr.Add(STE_STYLE_OPERATOR); valArr.Add(wxSTEditorStyle(wxT("Operator"), 0x000000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
106
keyArr.Add(STE_STYLE_BRACE); valArr.Add(wxSTEditorStyle(wxT("Brace"), 0x4F2F4F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
107
keyArr.Add(STE_STYLE_COMMAND); valArr.Add(wxSTEditorStyle(wxT("Command"), 0x0000FF, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
108
keyArr.Add(STE_STYLE_IDENTIFIER); valArr.Add(wxSTEditorStyle(wxT("Identifier"), 0x000000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
109
keyArr.Add(STE_STYLE_LABEL); valArr.Add(wxSTEditorStyle(wxT("Label"), 0x4F2F4F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
110
keyArr.Add(STE_STYLE_NUMBER); valArr.Add(wxSTEditorStyle(wxT("Number"), 0x238E6B, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
111
keyArr.Add(STE_STYLE_PARAMETER); valArr.Add(wxSTEditorStyle(wxT("Parameter"), 0x4F2F4F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
112
keyArr.Add(STE_STYLE_REGEX); valArr.Add(wxSTEditorStyle(wxT("Regular expression"), 0xDB70DB, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
113
keyArr.Add(STE_STYLE_UUID); valArr.Add(wxSTEditorStyle(wxT("UUID"), 0xDB70DB, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
114
keyArr.Add(STE_STYLE_VALUE); valArr.Add(wxSTEditorStyle(wxT("Value"), 0xDB70DB, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
115
keyArr.Add(STE_STYLE_PREPROCESSOR); valArr.Add(wxSTEditorStyle(wxT("Preprocessor"), 0x808080, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
116
keyArr.Add(STE_STYLE_SCRIPT); valArr.Add(wxSTEditorStyle(wxT("Script"), 0x2F2F2F, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
117
keyArr.Add(STE_STYLE_ERROR); valArr.Add(wxSTEditorStyle(wxT("Error"), 0xFF0000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
118
keyArr.Add(STE_STYLE_UNDEFINED); valArr.Add(wxSTEditorStyle(wxT("Undefined"), 0x32CC32, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
119
//keyArr.Add(STE_STYLE_UNUSED); valArr.Add(wxSTEditorStyle(wxT("Unused"), 0x000000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_ALL, STE_STYLE_USES_ALL));
120
//keyArr.Add(wxSTC_STYLE_DEFAULT); valArr.Add(wxSTEditorStyle(wxT("Editor default"), 0x000000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_ALL, STE_STYLE_USES_ALL));
122
keyArr.Add(STE_STYLE_LINENUMBER); valArr.Add(wxSTEditorStyle(wxT("Line numbers"), 0x000000, 0xC0C0C0, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_ALL));
123
keyArr.Add(STE_STYLE_BRACELIGHT); valArr.Add(wxSTEditorStyle(wxT("Brace hilight"), 0x0000FF, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
124
keyArr.Add(STE_STYLE_BRACEBAD); valArr.Add(wxSTEditorStyle(wxT("Brace mismatch"), 0xFF0000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
125
keyArr.Add(STE_STYLE_CONTROLCHAR); valArr.Add(wxSTEditorStyle(wxT("Control character"), 0x000000, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_ALL));
126
keyArr.Add(STE_STYLE_INDENTGUIDE); valArr.Add(wxSTEditorStyle(wxT("Indent guide"), 0x808080, 0xFFFFFF, STE_DEF_FACENAME, STE_DEF_FONTSIZE, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_COLOUR));
128
keyArr.Add(STE_STYLE_SELECTION_COLOUR); valArr.Add(wxSTEditorStyle(wxT("Selection colour"), 0xFFFFFF, 0xC0C0C0, wxEmptyString, 0, 0, STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR));
129
keyArr.Add(STE_STYLE_WHITESPACE_COLOUR); valArr.Add(wxSTEditorStyle(wxT("Whitespace colour"), 0x000000, 0xFFFFFF, wxEmptyString, 0, 0, STE_STYLE_USEDEFAULT_ALL, STE_STYLE_USES_COLOUR));
130
keyArr.Add(STE_STYLE_EDGE_COLOUR); valArr.Add(wxSTEditorStyle(wxT("Edge colour"), 0xC0C0C0, 0xFFFFFF, wxEmptyString, 0, 0, STE_STYLE_USEDEFAULT_NOFORECOLOUR, STE_STYLE_USES_FORECOLOUR));
131
keyArr.Add(STE_STYLE_CARET_COLOUR); valArr.Add(wxSTEditorStyle(wxT("Caret colour"), 0x000000, 0xF9F9F9, wxEmptyString, 0, 0, STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR));
132
keyArr.Add(STE_STYLE_FOLD_COLOUR); valArr.Add(wxSTEditorStyle(wxT("Fold margin colour"), 0xE0E0E0, 0xFFFFFF, wxEmptyString, 0, 0, STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR));
134
// defaults same as Scintilla's defaults
135
keyArr.Add(STE_STYLE_INDIC_0); valArr.Add(wxSTEditorStyle(wxT("Indicator 0"), 0x007F00, 0xFFFFFF, wxEmptyString, 0, wxSTC_INDIC_SQUIGGLE, STE_STYLE_USEDEFAULT_NOFONTSTYLE, STE_STYLE_USES_FORECOLOUR|STE_STYLE_USES_STYLE));
136
keyArr.Add(STE_STYLE_INDIC_1); valArr.Add(wxSTEditorStyle(wxT("Indicator 1"), 0x0000FF, 0xFFFFFF, wxEmptyString, 0, wxSTC_INDIC_TT, STE_STYLE_USEDEFAULT_NOFONTSTYLE, STE_STYLE_USES_FORECOLOUR|STE_STYLE_USES_STYLE));
137
keyArr.Add(STE_STYLE_INDIC_2); valArr.Add(wxSTEditorStyle(wxT("Indicator 2"), 0xFF0000, 0xFFFFFF, wxEmptyString, 0, wxSTC_INDIC_PLAIN, STE_STYLE_USEDEFAULT_NOFONTSTYLE, STE_STYLE_USES_FORECOLOUR|STE_STYLE_USES_STYLE));
139
// make sure that these are in order
140
keyArr.Add(STE_STYLE_MARKER_BOOKMARK); valArr.Add(wxSTEditorStyle(wxT("Bookmark marker"), 0x000000, 0x33AA55, wxEmptyString, 0, wxSTC_MARK_ROUNDRECT, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
141
keyArr.Add(STE_STYLE_MARKER_FOLDEREND); valArr.Add(wxSTEditorStyle(wxT("Folder End Marker"), 0xFFFFFF, 0x808080, wxEmptyString, 0, wxSTC_MARK_BOXPLUSCONNECTED, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
142
keyArr.Add(STE_STYLE_MARKER_FOLDEROPENMID); valArr.Add(wxSTEditorStyle(wxT("Folder Open Mid Marker"), 0xFFFFFF, 0x808080, wxEmptyString, 0, wxSTC_MARK_BOXMINUSCONNECTED, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
143
keyArr.Add(STE_STYLE_MARKER_FOLDERMIDTAIL); valArr.Add(wxSTEditorStyle(wxT("Folder Open Mid Tail Marker"), 0xFFFFFF, 0x808080, wxEmptyString, 0, wxSTC_MARK_TCORNER, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
144
keyArr.Add(STE_STYLE_MARKER_FOLDERTAIL); valArr.Add(wxSTEditorStyle(wxT("Folder Tail Marker"), 0xFFFFFF, 0x808080, wxEmptyString, 0, wxSTC_MARK_LCORNER, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
145
keyArr.Add(STE_STYLE_MARKER_FOLDERSUB); valArr.Add(wxSTEditorStyle(wxT("Folder Sub Marker"), 0xFFFFFF, 0x808080, wxEmptyString, 0, wxSTC_MARK_VLINE, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
146
keyArr.Add(STE_STYLE_MARKER_FOLDER); valArr.Add(wxSTEditorStyle(wxT("Folder Marker"), 0xFFFFFF, 0x808080, wxEmptyString, 0, wxSTC_MARK_BOXPLUS, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
147
keyArr.Add(STE_STYLE_MARKER_FOLDEROPEN); valArr.Add(wxSTEditorStyle(wxT("Folder Open Marker"), 0xFFFFFF, 0x808080, wxEmptyString, 0, wxSTC_MARK_BOXMINUS, STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR, STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
149
#if defined(__WXDEBUG__)
150
for (size_t n = 1; n < keyArr.GetCount(); n++) wxCHECK_RET(keyArr[n-1] < keyArr[n], wxT("styles are initialized out of order"));
151
#endif // defined(__WXDEBUG__)
154
int wxSTEditorStyles::wxColourToInt(const wxColour& c) const
156
wxCHECK_MSG(c.IsOk(), 0, wxT("Invalid colour in wxSTEditorStyles::wxColourToInt"));
157
#if STE_COLOURS_BBGGRR
158
return (int(c.Blue())<<16) | (int(c.Green())<<8) | (int(c.Red()));
160
return (int(c.Red())<<16) | (int(c.Green())<<8) | (int(c.Blue()));
163
wxColour wxSTEditorStyles::IntTowxColour(int c) const
165
#if STE_COLOURS_BBGGRR
166
return wxColour((unsigned char)((c )&0xFF),
167
(unsigned char)((c>> 8)&0xFF),
168
(unsigned char)((c>>16)&0xFF));
170
return wxColour((unsigned char)((c>>16)&0xFF),
171
(unsigned char)((c>> 8)&0xFF),
172
(unsigned char)((c )&0xFF));
176
bool wxSTEditorStyles::Create()
179
m_refData = new wxSTEditorStyles_RefData();
183
bool wxSTEditorStyles::Create(const wxSTEditorStyles &styles)
189
void wxSTEditorStyles::Copy(const wxSTEditorStyles &other)
191
wxCHECK_RET(other.IsOk(), wxT("Styles not created"));
192
if (!IsOk()) Create();
193
if (*this == other) return;
194
wxSTEditorStyles_RefData *otherStyleData = (wxSTEditorStyles_RefData *)other.GetRefData();
195
M_STYLEDATA->m_pairArrayStyles = otherStyleData->m_pairArrayStyles;
198
void wxSTEditorStyles::Reset()
200
wxCHECK_RET(IsOk(), wxT("Styles not created"));
201
wxSTEditorStyles defStyles(true);
205
bool wxSTEditorStyles::IsEqualTo(const wxSTEditorStyles &styles) const
207
wxCHECK_MSG(IsOk() && styles.IsOk(), false, wxT("Styles not created"));
208
wxSTEditorStyles_RefData *otherStyleData = (wxSTEditorStyles_RefData *)styles.GetRefData();
209
return (M_STYLEDATA->m_pairArrayStyles == otherStyleData->m_pairArrayStyles);
212
int wxSTEditorStyles::GetStyleIndex(const wxString &name) const
214
wxCHECK_MSG(IsOk(), wxNOT_FOUND, wxT("Styles not created"));
215
size_t n, count = M_STYLEDATA->m_pairArrayStyles.GetCount();
216
for (n = 0; n < count; n++)
218
if (M_STYLEDATA->m_pairArrayStyles.ItemValue(n).m_styleName == name)
219
return M_STYLEDATA->m_pairArrayStyles.ItemKey(n);
225
wxArrayInt wxSTEditorStyles::GetStylesArray(bool get_all_styles) const
228
wxCHECK_MSG(IsOk(), styles, wxT("Styles not created"));
230
size_t n, count = M_STYLEDATA->m_pairArrayStyles.GetCount();
231
for (n = 0; n < count; n++)
233
int style_n = M_STYLEDATA->m_pairArrayStyles.ItemKey(n);
234
if ((style_n >= STE_STYLE_LANG__MAX) && !get_all_styles)
243
int wxSTEditorStyles::FindNthStyle(int style_n) const
245
wxCHECK_MSG(IsOk(), wxNOT_FOUND, wxT("Styles not created"));
246
return M_STYLEDATA->m_pairArrayStyles.Index(style_n);
249
wxSTEditorStyle* wxSTEditorStyles::GetStyle(int style_n) const
251
wxCHECK_MSG(IsOk(), NULL, wxT("Styles not created"));
252
int n = FindNthStyle(style_n);
254
if (n != wxNOT_FOUND)
255
return &M_STYLEDATA->m_pairArrayStyles.ItemValue(n);
257
wxFAIL_MSG(wxT("Unknown style in wxSTEditorStyles::GetStyle"));
262
wxSTEditorStyle* wxSTEditorStyles::GetStyleUseDefault(int style_n,
263
int use_default_type) const
265
wxCHECK_MSG(IsOk(), NULL, wxT("Styles not created"));
266
wxSTEditorStyle *steStyle = GetStyle(style_n);
267
if (steStyle == NULL) return NULL;
269
if (STE_HASBIT(steStyle->m_use_default, use_default_type))
270
return GetStyle(STE_STYLE_DEFAULT);
275
wxString wxSTEditorStyles::GetStyleName(int style_n) const
277
wxSTEditorStyle* steStyle = GetStyle(style_n);
278
if (steStyle == NULL) return wxEmptyString;
279
return steStyle->m_styleName;
281
int wxSTEditorStyles::GetForegroundColourInt(int style_n, bool use_default) const
283
wxSTEditorStyle* steStyle = GetStyleUseDefault(style_n,
284
use_default ? STE_STYLE_USEDEFAULT_FORECOLOUR : 0);
285
if (steStyle == NULL) return 0;
286
return steStyle->m_fore_colour;
288
int wxSTEditorStyles::GetBackgroundColourInt(int style_n, bool use_default) const
290
wxSTEditorStyle* steStyle = GetStyleUseDefault(style_n,
291
use_default ? STE_STYLE_USEDEFAULT_BACKCOLOUR : 0);
292
if (steStyle == NULL) return 0xFFFFFF;
293
return steStyle->m_back_colour;
295
wxFont wxSTEditorStyles::GetFont(int style_n, bool use_default) const
297
wxCHECK_MSG(IsOk(), wxFont(STE_DEF_FONTSIZE, wxMODERN, wxNORMAL, wxNORMAL), wxT("Styles not created"));
299
wxFont *f = wxTheFontList->FindOrCreateFont(
300
GetSize(style_n, use_default),
301
wxMODERN, // unused using facename
302
GetItalic(style_n, use_default) ? wxITALIC : wxNORMAL,
303
GetBold(style_n, use_default) ? wxBOLD : wxNORMAL,
304
GetUnderlined(style_n, use_default),
305
GetFaceName(style_n, use_default));
307
if (!f || !f->IsOk())
308
return wxFont(STE_DEF_FONTSIZE, wxMODERN, wxNORMAL, wxNORMAL);
313
wxFont font(GetSize(style_n, use_default),
314
wxMODERN, // unused using facename
315
GetItalic(style_n, use_default) ? wxITALIC : wxNORMAL,
316
GetBold(style_n, use_default) ? wxBOLD : wxNORMAL,
317
GetUnderlined(style_n, use_default),
318
GetFaceName(style_n, use_default));
320
if (!font.IsOk()) // oops this font works though
321
return wxFont(STE_DEF_FONTSIZE, wxMODERN, wxNORMAL, wxNORMAL);
325
wxString wxSTEditorStyles::GetFaceName(int style_n, bool use_default) const
327
wxSTEditorStyle* steStyle = GetStyleUseDefault(style_n,
328
use_default ? STE_STYLE_USEDEFAULT_FACENAME : 0);
329
if (steStyle == NULL) return STE_DEF_FACENAME;
330
return steStyle->m_faceName;
332
int wxSTEditorStyles::GetSize(int style_n, bool use_default) const
334
wxSTEditorStyle* steStyle = GetStyleUseDefault(style_n,
335
use_default ? STE_STYLE_USEDEFAULT_FONTSIZE : 0);
336
if (steStyle == NULL) return STE_DEF_FONTSIZE;
337
return steStyle->m_font_size;
339
int wxSTEditorStyles::GetFontAttr(int style_n, bool use_default) const
341
wxSTEditorStyle* steStyle = GetStyleUseDefault(style_n,
342
use_default ? STE_STYLE_USEDEFAULT_FONTSTYLE : 0);
343
if (steStyle == NULL) return STE_STYLE_FONT_NONE;
344
return steStyle->m_font_attr;
346
int wxSTEditorStyles::GetCase(int style_n, bool use_default) const
348
int ste_font_attr = GetFontAttr(style_n, use_default);
350
if (STE_HASBIT(ste_font_attr, STE_STYLE_FONT_CASEUPPER))
351
return wxSTC_CASE_UPPER;
352
if (STE_HASBIT(ste_font_attr, STE_STYLE_FONT_CASELOWER))
353
return wxSTC_CASE_LOWER;
355
return wxSTC_CASE_MIXED;
357
int wxSTEditorStyles::GetUseDefault(int style_n) const
359
wxSTEditorStyle* steStyle = GetStyle(style_n);
360
if (steStyle != NULL)
361
return steStyle->m_use_default;
363
return STE_STYLE_USEDEFAULT_ALL;
365
int wxSTEditorStyles::GetStyleUsage(int style_n) const
367
wxSTEditorStyle* steStyle = GetStyle(style_n);
368
if (steStyle != NULL)
369
return steStyle->m_style_uses;
371
return STE_STYLE_USES_ALL;
374
bool wxSTEditorStyles::SetStyle( int style_n, const wxSTEditorStyle& steStyle )
376
wxCHECK_MSG(IsOk(), false, wxT("Styles not created"));
377
return s_STE_PairArrayStyles.Add(style_n, steStyle);
380
bool wxSTEditorStyles::SetInitStyle( int ste_style, const wxSTEditorStyle& steStyle ) const
382
return s_STE_PairArrayStyles.Add(ste_style, steStyle);
384
bool wxSTEditorStyles::SetInitIndicator( int indic_n, const wxString &name,
385
int fore_colour, int style) const
387
wxCHECK_STEINDIC_MSG(indic_n, false);
388
return SetInitStyle(STE_STYLE_INDIC__FIRST+indic_n,
389
wxSTEditorStyle(name, fore_colour, 0xFFFFFF,
390
STE_DEF_FACENAME, STE_DEF_FONTSIZE, style,
391
STE_STYLE_USEDEFAULT_NOFONTSTYLE, // just fore and style
392
STE_STYLE_USES_FORECOLOUR|STE_STYLE_USES_STYLE));
394
bool wxSTEditorStyles::SetInitMarker( int marker_n, const wxString &name, int style,
395
int fore_colour, int back_colour ) const
397
wxCHECK_STEMARKER_MSG(marker_n, false);
398
return SetInitStyle(STE_STYLE_MARKER__FIRST+marker_n,
399
wxSTEditorStyle(name, fore_colour, back_colour,
400
STE_DEF_FACENAME, STE_DEF_FONTSIZE, style,
401
STE_STYLE_USEDEFAULT_NOFONTSTYLE & STE_STYLE_USEDEFAULT_NOCOLOUR,
402
STE_STYLE_USES_COLOUR|STE_STYLE_USES_STYLE));
405
bool wxSTEditorStyles::RemoveInitStyle( int style_n ) const
407
return s_STE_PairArrayStyles.Remove(style_n);
410
void wxSTEditorStyles::SetForegroundColourInt(int style_n, int colour)
412
wxSTEditorStyle* steStyle = GetStyle(style_n);
413
if (steStyle != NULL)
414
steStyle->m_fore_colour = colour;
416
void wxSTEditorStyles::SetBackgroundColourInt(int style_n, int colour)
418
wxSTEditorStyle* steStyle = GetStyle(style_n);
419
if (steStyle != NULL)
420
steStyle->m_back_colour = colour;
422
void wxSTEditorStyles::SetFont(int style_n, const wxFont &font)
424
wxCHECK_RET(IsOk(), wxT("Styles not created"));
425
wxCHECK_RET(font.IsOk(), wxT("Invalid font"));
427
SetFaceName(style_n, font.GetFaceName());
428
SetSize(style_n, font.GetPointSize());
430
int ste_font_attr = font.GetWeight() == wxBOLD ? STE_STYLE_FONT_BOLD : 0;
431
ste_font_attr |= font.GetStyle() != wxNORMAL ? STE_STYLE_FONT_ITALIC : 0;
432
ste_font_attr |= font.GetUnderlined() ? STE_STYLE_FONT_UNDERLINED : 0;
434
SetFontAttr(style_n, ste_font_attr);
436
void wxSTEditorStyles::SetFaceName(int style_n, const wxString &faceName)
438
wxSTEditorStyle* steStyle = GetStyle(style_n);
439
if (steStyle != NULL)
440
steStyle->m_faceName = faceName;
442
void wxSTEditorStyles::SetSize(int style_n, int size)
444
wxSTEditorStyle* steStyle = GetStyle(style_n);
445
if (steStyle != NULL)
446
steStyle->m_font_size = size;
448
void wxSTEditorStyles::SetFontAttr(int style_n, int ste_font_attr)
450
wxSTEditorStyle* steStyle = GetStyle(style_n);
451
if (steStyle != NULL)
452
steStyle->m_font_attr = ste_font_attr;
455
void wxSTEditorStyles::SetCase(int style_n, int lcase)
457
wxCHECK_RET(IsOk(), wxT("Styles not created"));
462
case wxSTC_CASE_MIXED : steCase = STE_STYLE_FONT_CASEMIXED; break;
463
case wxSTC_CASE_UPPER : steCase = STE_STYLE_FONT_CASEUPPER; break;
464
case wxSTC_CASE_LOWER : steCase = STE_STYLE_FONT_CASELOWER; break;
467
wxCHECK_RET(steCase != -1, wxT("Invalid letter case for style"));
468
int fontStyle = GetFontAttr(style_n, true);
470
if ((fontStyle & steCase) != 0)
474
fontStyle &= ~(STE_STYLE_FONT_CASEMIXED|STE_STYLE_FONT_CASEUPPER|STE_STYLE_FONT_CASELOWER);
475
SetFontAttr(style_n, fontStyle|steCase);
478
void wxSTEditorStyles::SetUseDefault(int style_n, int mask, bool use_default)
480
wxCHECK_RET(IsOk(), wxT("Styles not created"));
481
int def = GetUseDefault(style_n);
482
def = use_default ? (def | mask) : (def & (~mask));
483
wxSTEditorStyle* steStyle = GetStyle(style_n);
484
if (steStyle != NULL)
485
steStyle->m_use_default = def;
488
bool wxSTEditorStyles::RemoveStyle(int style_n)
490
wxCHECK_MSG(IsOk(), false, wxT("Styles not created"));
491
return M_STYLEDATA->m_pairArrayStyles.Remove(style_n);
494
bool wxSTEditorStyles::SetFoldMarkerStyle(int fold_style)
496
// Copyright 1998-2003 by Neil Hodgson <neilh@scintilla.org>
497
// This code originally in SciTE/src/SciTEProps.cxx
500
case STE_FOLDMARGIN_STYLE_ARROWS : // "..." for contracted folders, arrow pointing down for expanded
502
SetMarker(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, *wxBLACK, *wxBLACK);
503
SetMarker(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_DOTDOTDOT, *wxBLACK, *wxBLACK);
504
SetMarker(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, *wxBLACK, *wxBLACK);
505
SetMarker(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, *wxBLACK, *wxBLACK);
506
SetMarker(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_DOTDOTDOT, *wxBLACK, *wxWHITE);
507
SetMarker(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_ARROWDOWN, *wxBLACK, *wxWHITE);
508
SetMarker(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, *wxBLACK, *wxBLACK);
510
// Arrow pointing right for contracted folders, arrow pointing down for expanded
511
editor->MarkerDefine(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_ARROWDOWN, *wxBLACK, *wxBLACK);
512
editor->MarkerDefine(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_ARROW, *wxBLACK, *wxBLACK);
513
editor->MarkerDefine(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, *wxBLACK, *wxBLACK);
514
editor->MarkerDefine(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, *wxBLACK, *wxBLACK);
515
editor->MarkerDefine(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
516
editor->MarkerDefine(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
517
editor->MarkerDefine(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
521
case STE_FOLDMARGIN_STYLE_CIRCLES : // Like a flattened tree control using circular headers and curved joins
523
wxColour grey(0x40, 0x40, 0x40);
524
SetMarker(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_CIRCLEMINUS, *wxWHITE, grey);
525
SetMarker(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_CIRCLEPLUS, *wxWHITE, grey);
526
SetMarker(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, *wxWHITE, grey);
527
SetMarker(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNERCURVE, *wxWHITE, grey);
528
SetMarker(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_CIRCLEPLUSCONNECTED, *wxWHITE, grey);
529
SetMarker(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_CIRCLEMINUSCONNECTED, *wxWHITE, grey);
530
SetMarker(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNERCURVE, *wxWHITE, grey);
533
case STE_FOLDMARGIN_STYLE_SQUARES : // Like a flattened tree control using square headers
535
wxColour grey(0x80, 0x80, 0x80);
536
SetMarker(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_BOXMINUS, *wxWHITE, grey);
537
SetMarker(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS, *wxWHITE, grey);
538
SetMarker(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_VLINE, *wxWHITE, grey);
539
SetMarker(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_LCORNER, *wxWHITE, grey);
540
SetMarker(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_BOXPLUSCONNECTED, *wxWHITE, grey);
541
SetMarker(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_BOXMINUSCONNECTED, *wxWHITE, grey);
542
SetMarker(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_TCORNER, *wxWHITE, grey);
545
case STE_FOLDMARGIN_STYLE_PLUSMINUS : // Plus for contracted folders, minus for expanded
547
SetMarker(wxSTC_MARKNUM_FOLDEROPEN, wxSTC_MARK_MINUS, *wxWHITE, *wxBLACK);
548
SetMarker(wxSTC_MARKNUM_FOLDER, wxSTC_MARK_PLUS, *wxWHITE, *wxBLACK);
549
SetMarker(wxSTC_MARKNUM_FOLDERSUB, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
550
SetMarker(wxSTC_MARKNUM_FOLDERTAIL, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
551
SetMarker(wxSTC_MARKNUM_FOLDEREND, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
552
SetMarker(wxSTC_MARKNUM_FOLDEROPENMID, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
553
SetMarker(wxSTC_MARKNUM_FOLDERMIDTAIL, wxSTC_MARK_EMPTY, *wxWHITE, *wxBLACK);
556
default : return false; // unknown
562
void wxSTEditorStyles::AppendAddedInitStyles()
564
wxCHECK_RET(IsOk(), wxT("Styles not created"));
565
size_t n, count = s_STE_PairArrayStyles.GetCount();
566
for (n = 0; n < count; n++)
568
int ste_style = s_STE_PairArrayStyles.ItemKey(n);
569
if (!HasStyle(int(ste_style)))
570
AddStyle(ste_style, s_STE_PairArrayStyles.ItemValue(n));
574
void wxSTEditorStyles::SetEditorStyle( int stc_style, int ste_style,
578
wxCHECK_RET(IsOk(), wxT("Styles not created"));
579
wxCHECK_RET(HasStyle(ste_style), wxT("Invalid STE style"));
580
wxCHECK_RET(editor, wxT("Invalid editor"));
582
if (GetStyleUses(ste_style, STE_STYLE_USES_FORECOLOUR) &&
583
(force || !GetUsesDefault(ste_style, STE_STYLE_USEDEFAULT_FORECOLOUR)))
584
editor->StyleSetForeground(stc_style, GetForegroundColour(ste_style));
585
if (GetStyleUses(ste_style, STE_STYLE_USES_BACKCOLOUR) &&
586
(force || !GetUsesDefault(ste_style, STE_STYLE_USEDEFAULT_BACKCOLOUR)))
587
editor->StyleSetBackground(stc_style, GetBackgroundColour(ste_style));
589
if (GetStyleUses(ste_style, STE_STYLE_USES_FACENAME) &&
590
(force || !GetUsesDefault(ste_style, STE_STYLE_USEDEFAULT_FACENAME)))
591
editor->StyleSetFaceName(stc_style, GetFaceName(ste_style));
592
if (GetStyleUses(ste_style, STE_STYLE_USES_FONTSIZE) &&
593
(force || !GetUsesDefault(ste_style, STE_STYLE_USEDEFAULT_FONTSIZE)))
594
editor->StyleSetSize(stc_style, GetSize(ste_style));
596
if (GetStyleUses(ste_style, STE_STYLE_USES_FONTSTYLE) &&
597
(force || !GetUsesDefault(ste_style, STE_STYLE_USEDEFAULT_FONTSTYLE)))
599
const int ste_font_attr = GetFontAttr(ste_style);
600
editor->StyleSetBold(stc_style, STE_HASBIT(ste_font_attr, STE_STYLE_FONT_BOLD));
601
editor->StyleSetUnderline(stc_style, STE_HASBIT(ste_font_attr, STE_STYLE_FONT_UNDERLINED));
602
editor->StyleSetItalic(stc_style, STE_HASBIT(ste_font_attr, STE_STYLE_FONT_ITALIC));
603
editor->StyleSetVisible(stc_style, !STE_HASBIT(ste_font_attr, STE_STYLE_FONT_HIDDEN));
604
editor->StyleSetEOLFilled(stc_style, STE_HASBIT(ste_font_attr, STE_STYLE_FONT_EOLFILLED));
605
editor->StyleSetCase(stc_style, GetCase(ste_style));
608
//void StyleSetChangeable(int style, bool changeable); // Experimental feature, currently buggy.
609
//void StyleSetCharacterSet(int style, int characterSet);
610
//void StyleSetFontEncoding(int style, wxFontEncoding encoding);
611
//void StyleSetHotSpot(int style, bool hotspot);
614
if ((ste_style == STE_STYLE_CHARACTEREOL) || (ste_style == STE_STYLE_STRINGEOL))
615
editor->StyleSetEOLFilled(stc_style, true);
617
editor->StyleSetEOLFilled(stc_style, false);
621
void wxSTEditorStyles::UpdateEditor( wxSTEditor *editor )
623
wxCHECK_RET(IsOk(), wxT("Styles not created"));
624
wxCHECK_RET(editor, wxT("Invalid editor"));
626
// Start with default and then the fixed Scintilla styles, 32-37
627
if (HasStyle(STE_STYLE_DEFAULT))
628
SetEditorStyle(wxSTC_STYLE_DEFAULT, STE_STYLE_DEFAULT, editor, true);
630
editor->StyleClearAll(); // do this to update defaults for all styles
632
if (HasStyle(STE_STYLE_LINENUMBER))
633
SetEditorStyle(wxSTC_STYLE_LINENUMBER, STE_STYLE_LINENUMBER, editor, true);
634
if (HasStyle(STE_STYLE_BRACELIGHT))
635
SetEditorStyle(wxSTC_STYLE_BRACELIGHT, STE_STYLE_BRACELIGHT, editor);
636
if (HasStyle(STE_STYLE_BRACEBAD))
637
SetEditorStyle(wxSTC_STYLE_BRACEBAD, STE_STYLE_BRACEBAD, editor);
638
if (HasStyle(STE_STYLE_CONTROLCHAR))
639
SetEditorStyle(wxSTC_STYLE_CONTROLCHAR, STE_STYLE_CONTROLCHAR, editor);
640
if (HasStyle(STE_STYLE_INDENTGUIDE))
641
SetEditorStyle(wxSTC_STYLE_INDENTGUIDE, STE_STYLE_INDENTGUIDE, editor, true);
643
if (HasStyle(STE_STYLE_SELECTION_COLOUR))
645
editor->SetSelForeground(true, GetForegroundColour(STE_STYLE_SELECTION_COLOUR, true));
646
editor->SetSelBackground(true, GetBackgroundColour(STE_STYLE_SELECTION_COLOUR, true));
649
if (HasStyle(STE_STYLE_EDGE_COLOUR))
650
editor->SetEdgeColour(GetForegroundColour(STE_STYLE_EDGE_COLOUR, true));
652
if (HasStyle(STE_STYLE_CARET_COLOUR))
654
editor->SetCaretForeground(GetForegroundColour(STE_STYLE_CARET_COLOUR, true));
655
editor->SetCaretLineBackground(GetBackgroundColour(STE_STYLE_CARET_COLOUR, true));
658
if (HasStyle(STE_STYLE_FOLD_COLOUR))
660
editor->SetFoldMarginColour(true, GetForegroundColour(STE_STYLE_FOLD_COLOUR, true));
661
editor->SetFoldMarginHiColour(true, GetBackgroundColour(STE_STYLE_FOLD_COLOUR, true));
664
if (HasStyle(STE_STYLE_WHITESPACE_COLOUR))
666
editor->SetWhitespaceForeground(true, GetForegroundColour(STE_STYLE_WHITESPACE_COLOUR, true));
667
editor->SetWhitespaceBackground(true, GetBackgroundColour(STE_STYLE_WHITESPACE_COLOUR, true));
670
if (HasIndicatorStyle(0))
672
editor->IndicatorSetStyle(wxSTC_INDIC0_MASK, GetIndicatorStyle(0));
673
editor->IndicatorSetForeground(wxSTC_INDIC0_MASK, GetIndicatorForeground(0));
675
if (HasIndicatorStyle(1))
677
editor->IndicatorSetStyle(wxSTC_INDIC1_MASK, GetIndicatorStyle(1));
678
editor->IndicatorSetForeground(wxSTC_INDIC1_MASK, GetIndicatorForeground(1));
680
if (HasIndicatorStyle(2))
682
editor->IndicatorSetStyle(wxSTC_INDIC2_MASK, GetIndicatorStyle(2));
683
editor->IndicatorSetForeground(wxSTC_INDIC2_MASK, GetIndicatorForeground(2));
686
// try to set fold flags, if the fold style is invalid, this does nothing
687
if (editor->GetEditorPrefs().IsOk())
688
SetFoldMarkerStyle(editor->GetEditorPrefs().GetPrefInt(STE_PREF_FOLDMARGIN_STYLE));
690
// now set all the marker styles, if any
691
wxArrayInt styleArray = GetStylesArray(true);
692
size_t n, count = styleArray.GetCount();
693
for (n = 0; n < count; n++)
695
if ((styleArray[n] >= STE_STYLE_MARKER__FIRST) &&
696
(styleArray[n] <= STE_STYLE_MARKER__LAST))
698
int marker_n = styleArray[n] - STE_STYLE_MARKER__FIRST;
699
editor->MarkerDefine(marker_n, GetMarkerSymbol(marker_n),
700
GetMarkerForeground(marker_n),
701
GetMarkerBackground(marker_n));
706
wxString wxSTEditorStyles::LoadConfig( wxConfigBase &config,
707
const wxString &configPath )
709
wxCHECK_MSG(IsOk(), wxEmptyString, wxT("Styles not created"));
710
wxString oldConfigPath = config.GetPath();
711
wxString group = wxSTEditorOptions::FixConfigPath(configPath, false);
712
config.SetPath(group);
718
if (config.GetFirstEntry(key, index))
722
if (config.Read(key, &value))
724
// We get all sorts of config lines here, not only styles. Skip past others.
725
if (value.Find(wxT(":")) != wxNOT_FOUND)
726
errorMsg += ParseConfigLine(key, value);
728
} while (config.GetNextEntry(key, index));
732
if (errorMsg.Length())
734
wxString msg = _("Error loading editor config data, would you like to repair it?\n\n") + errorMsg;
736
int ret = wxMessageBox( msg,
737
_("Config load error"),
743
config.SetPath(oldConfigPath);
744
if (config.HasGroup(group))
745
config.DeleteGroup(group);
747
SaveConfig(config, configPath);
751
config.SetPath(oldConfigPath);
756
wxString wxSTEditorStyles::ParseConfigLine(const wxString &key, const wxString &value)
758
wxCHECK_MSG(IsOk(), wxEmptyString, wxT("Styles not created"));
762
name.Replace(wxT("_"), wxT(" "), true);
765
wxString option, val;
766
int style_n = GetStyleIndex(name);
768
// FIXME oops - no style number
770
return _("Unknown style name in '")+name+wxT("'\n");
772
for (wxStringTokenizer tkz(value, wxT(","));
776
wxString token = tkz.GetNextToken();
777
option = token.BeforeFirst(wxT(':')).Strip(wxString::both);
778
val = token.AfterFirst(wxT(':')).Strip(wxString::both);
782
errorMsg += _("Empty style option '") + option + _("' in style '")+name+wxT("'\n");
785
bool def = (val.GetChar(0) == wxT('*'));
787
val = val.AfterFirst(wxT('*')).Strip(wxString::leading);
789
if (option == wxT("fore"))
791
if (val.ToLong(&long_val, 16))
793
SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FORECOLOUR, def);
794
SetForegroundColourInt(style_n, (int)long_val);
797
errorMsg += _("Invalid foreground colour in style '")+name+wxT("'\n");
799
else if (option == wxT("back"))
801
if (val.ToLong(&long_val, 16))
803
SetUseDefault(style_n, STE_STYLE_USEDEFAULT_BACKCOLOUR, def);
804
SetBackgroundColourInt(style_n, (int)long_val);
807
errorMsg += _("Invalid background colour in style '")+name+wxT("'\n");
809
else if (option == wxT("face"))
811
SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FACENAME, def);
812
SetFaceName(style_n, val);
814
else if (option == wxT("size"))
816
if (val.ToLong(&long_val))
818
SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSIZE, def);
819
SetSize(style_n, long_val);
822
errorMsg += _("Invalid font size in style '")+name+wxT("'\n");
824
else if (option == wxT("bold"))
826
SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
827
SetBold(style_n, val != wxT("0"));
829
else if (option == wxT("italic"))
831
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
832
SetItalic(style_n, val != wxT("0"));
834
else if (option == wxT("underline"))
836
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
837
SetUnderlined(style_n, val != wxT("0"));
839
else if (option == wxT("hidden"))
841
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
842
SetUnderlined(style_n, val != wxT("0"));
844
else if (option == wxT("eol"))
846
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
847
SetEOLFilled(style_n, val != wxT("0"));
849
else if (option == wxT("hotspot"))
851
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
852
SetHotSpot(style_n, val != wxT("0"));
854
else if (option == wxT("case"))
856
if (val.ToLong(&long_val) &&
857
((long_val == wxSTC_CASE_MIXED)||(long_val == wxSTC_CASE_UPPER)||(long_val == wxSTC_CASE_LOWER)))
859
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
860
SetCase(style_n, int(long_val));
863
errorMsg += _("Invalid letter case for style '")+name+wxT("'.\n");
865
else if (option == wxT("style")) // only for indicators & markers
867
if ((style_n >= STE_STYLE_INDIC__FIRST) && (style_n <= STE_STYLE_INDIC__LAST))
869
if (val.ToLong(&long_val) && (long_val >= 0) && (long_val < wxSTC_INDIC_MAX))
871
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
872
SetIndicatorStyle(style_n - STE_STYLE_INDIC__FIRST, (int)long_val);
875
errorMsg += _("Invalid indicator style in '")+name+wxT("'\n");
877
else if ((style_n >= STE_STYLE_MARKER__FIRST) && (style_n <= STE_STYLE_MARKER__LAST))
879
if (val.ToLong(&long_val) && (long_val >= 0)) // && (long_val < wxSTC_MARKER_MAX))
881
//SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, def);
882
SetMarkerSymbol(style_n - STE_STYLE_MARKER__FIRST, (int)long_val);
885
errorMsg += _("Invalid marker style in '")+name+wxT("'\n");
889
errorMsg += _("Style set for non indicator or marker in '")+name+wxT("'\n");
894
// maybe they really want this style separate, though identical?
896
// SetUseDefault(style_n, STE_STYLE_USEDEFAULT_FONTSTYLE, (GetFontAttr(style_n) == GetFontAttr(0)));
901
//Default_text=fore:0x000000,back:0xFFFFFF,face:courier,size:12,bold:0,italic:0,underline:0,eol:0,hotspot:0,case:0 [style:0 only for indicators]
903
#define BOOL_CFG(val) ((val) ? wxString(wxT("1")) : wxString(wxT("0")))
904
#define DEF_CFG(mask) wxString(GetUsesDefault(n, mask) ? wxDEFAULT_ASTERISK : wxEmptyString)
906
wxString wxSTEditorStyles::CreateConfigLine(int n) const
908
wxCHECK_MSG(IsOk(), wxEmptyString, wxT("Styles not created"));
909
wxString line; // = wxString::Format(wxT("type:%d,"), n);
911
if (GetStyleUses(n, STE_STYLE_USES_FORECOLOUR))
912
line += wxT("fore:") + DEF_CFG(STE_STYLE_USEDEFAULT_FORECOLOUR) + wxString::Format(wxT("0x%06X"), GetForegroundColourInt(n)) + wxT(",");
913
if (GetStyleUses(n, STE_STYLE_USES_BACKCOLOUR))
914
line += wxT("back:") + DEF_CFG(STE_STYLE_USEDEFAULT_BACKCOLOUR) + wxString::Format(wxT("0x%06X"), GetBackgroundColourInt(n)) + wxT(",");
916
if (GetStyleUses(n, STE_STYLE_USES_FACENAME))
917
line += wxT("face:") + DEF_CFG(STE_STYLE_USEDEFAULT_FACENAME) + GetFaceName(n) + wxT(",");
918
if (GetStyleUses(n, STE_STYLE_USES_FONTSIZE))
919
line += wxT("size:") + DEF_CFG(STE_STYLE_USEDEFAULT_FONTSIZE) + wxString::Format(wxT("%d,"), GetSize(n));
920
if (GetStyleUses(n, STE_STYLE_USES_FONTSTYLE))
922
line += wxT("bold:") + DEF_CFG(STE_STYLE_USEDEFAULT_FONTSTYLE) + BOOL_CFG(GetBold(n)) + wxT(",");
923
line += wxT("italic:") + DEF_CFG(STE_STYLE_USEDEFAULT_FONTSTYLE) + BOOL_CFG(GetItalic(n)) + wxT(",");
924
line += wxT("underline:") + DEF_CFG(STE_STYLE_USEDEFAULT_FONTSTYLE) + BOOL_CFG(GetUnderlined(n)) + wxT(",");
925
line += wxT("eol:") + DEF_CFG(STE_STYLE_USEDEFAULT_FONTSTYLE) + BOOL_CFG(GetEOLFilled(n)) + wxT(",");
926
line += wxT("hotspot:") + DEF_CFG(STE_STYLE_USEDEFAULT_FONTSTYLE) + BOOL_CFG(GetHotSpot(n)) + wxT(",");
927
line += wxT("case:") + wxString::Format(wxT("%d"), GetCase(n));
929
else if (GetStyleUses(n, STE_STYLE_USES_STYLE))
931
line += wxT("style:") + wxString::Format(wxT("%d"), GetFontAttr(n)); // style stored here
934
if ((line.Length() > 0u) && (line.Last() == wxT(',')))
935
line = line.BeforeLast(wxT(','));
940
void wxSTEditorStyles::SaveConfig( wxConfigBase &config,
941
const wxString &configPath,
944
wxCHECK_RET(IsOk(), wxT("Styles not created"));
945
wxString key = wxSTEditorOptions::FixConfigPath(configPath, true);
947
wxArrayInt stylesArray = GetStylesArray(true);
949
wxSTEditorStyles defaultStyles(true);
951
for (size_t n = 0; n < stylesArray.GetCount(); n++)
953
int style_n = stylesArray[n];
954
wxString name = GetStyleName(style_n);
955
name.Replace(wxT(" "), wxT("_"), true);
957
wxString value = CreateConfigLine(style_n);
958
wxString defValue = defaultStyles.CreateConfigLine(style_n);
960
if (((flags && STE_CONFIG_SAVE_DIFFS) == 0) || (value != defValue))
961
config.Write(key + name, value);
965
// global precreated wxSTEditorStyles
966
wxSTEditorStyles s_wxSTEditorStyles(true);