]>
Commit | Line | Data |
---|---|---|
f97d84a6 RD |
1 | //////////////////////////////////////////////////////////////////////////// |
2 | // Name: stc.cpp | |
be5a51fb | 3 | // Purpose: A wxWidgets implementation of Scintilla. This class is the |
f97d84a6 RD |
4 | // one meant to be used directly by wx applications. It does not |
5 | // derive directly from the Scintilla classes, but instead | |
6 | // delegates most things to the real Scintilla class. | |
7 | // This allows the use of Scintilla without polluting the | |
8 | // namespace with all the classes and identifiers from Scintilla. | |
9 | // | |
10 | // Author: Robin Dunn | |
11 | // | |
12 | // Created: 13-Jan-2000 | |
13 | // RCS-ID: $Id$ | |
14 | // Copyright: (c) 2000 by Total Control Software | |
526954c5 | 15 | // Licence: wxWindows licence |
f97d84a6 RD |
16 | ///////////////////////////////////////////////////////////////////////////// |
17 | ||
a5c2ccf2 VZ |
18 | /* |
19 | IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from | |
20 | src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be | |
21 | lost after the next regeneration, edit stc.cpp.in and rerun the | |
22 | gen_iface.py script instead! | |
23 | ||
24 | Parts of this file generated by the script are found in between | |
25 | the special "{{{" and "}}}" markers, the rest of it is copied | |
26 | verbatim from src.h.in. | |
27 | */ | |
28 | ||
54429bb3 RD |
29 | // For compilers that support precompilation, includes "wx.h". |
30 | #include "wx/wxprec.h" | |
31 | ||
32 | #ifdef __BORLANDC__ | |
33 | #pragma hdrstop | |
34 | #endif | |
35 | ||
29825f5f PC |
36 | #if wxUSE_STC |
37 | ||
38 | #include "wx/stc/stc.h" | |
4c784823 | 39 | #include "wx/stc/private.h" |
54429bb3 RD |
40 | |
41 | #ifndef WX_PRECOMP | |
29825f5f | 42 | #include "wx/wx.h" |
54429bb3 RD |
43 | #endif // WX_PRECOMP |
44 | ||
f97d84a6 RD |
45 | #include <ctype.h> |
46 | ||
d6655166 WS |
47 | #include "wx/tokenzr.h" |
48 | #include "wx/mstream.h" | |
49 | #include "wx/image.h" | |
3396739d | 50 | #include "wx/ffile.h" |
f97d84a6 | 51 | |
f9ee2e27 | 52 | #include "ScintillaWX.h" |
f97d84a6 RD |
53 | |
54 | //---------------------------------------------------------------------- | |
55 | ||
23318a53 | 56 | const char wxSTCNameStr[] = "stcwindow"; |
f97d84a6 | 57 | |
451c5cc7 RD |
58 | #ifdef MAKELONG |
59 | #undef MAKELONG | |
60 | #endif | |
61 | ||
62 | #define MAKELONG(a, b) ((a) | ((b) << 16)) | |
63 | ||
64 | ||
65 | static long wxColourAsLong(const wxColour& co) { | |
66 | return (((long)co.Blue() << 16) | | |
67 | ((long)co.Green() << 8) | | |
68 | ((long)co.Red())); | |
69 | } | |
70 | ||
71 | static wxColour wxColourFromLong(long c) { | |
72 | wxColour clr; | |
a5b274d7 WS |
73 | clr.Set((unsigned char)(c & 0xff), |
74 | (unsigned char)((c >> 8) & 0xff), | |
75 | (unsigned char)((c >> 16) & 0xff)); | |
451c5cc7 RD |
76 | return clr; |
77 | } | |
78 | ||
79 | ||
80 | static wxColour wxColourFromSpec(const wxString& spec) { | |
5ee1d760 RD |
81 | // spec should be a colour name or "#RRGGBB" |
82 | if (spec.GetChar(0) == wxT('#')) { | |
dc8005e2 | 83 | |
5ee1d760 RD |
84 | long red, green, blue; |
85 | red = green = blue = 0; | |
86 | spec.Mid(1,2).ToLong(&red, 16); | |
87 | spec.Mid(3,2).ToLong(&green, 16); | |
88 | spec.Mid(5,2).ToLong(&blue, 16); | |
a5b274d7 WS |
89 | return wxColour((unsigned char)red, |
90 | (unsigned char)green, | |
91 | (unsigned char)blue); | |
5ee1d760 RD |
92 | } |
93 | else | |
94 | return wxColour(spec); | |
451c5cc7 RD |
95 | } |
96 | ||
97 | //---------------------------------------------------------------------- | |
98 | ||
9b11752c VZ |
99 | wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent ); |
100 | wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent ); | |
101 | wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent ); | |
102 | wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent ); | |
103 | wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent ); | |
104 | wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent ); | |
105 | wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent ); | |
106 | wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent ); | |
107 | wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent ); | |
108 | wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent ); | |
109 | wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent ); | |
110 | wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent ); | |
111 | wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent ); | |
112 | wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent ); | |
113 | wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent ); | |
114 | wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent ); | |
115 | wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent ); | |
116 | wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent ); | |
117 | wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent ); | |
118 | wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent ); | |
119 | wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent ); | |
120 | wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent ); | |
121 | wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent ); | |
122 | wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent ); | |
123 | wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent ); | |
124 | wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent ); | |
125 | wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent ); | |
126 | wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent ); | |
9e96e16f RD |
127 | wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent ); |
128 | wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent ); | |
54173563 | 129 | wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent ); |
9e730a78 | 130 | |
d25f5fbb RD |
131 | |
132 | ||
f97d84a6 RD |
133 | BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) |
134 | EVT_PAINT (wxStyledTextCtrl::OnPaint) | |
135 | EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin) | |
5fa4613c | 136 | EVT_SCROLL (wxStyledTextCtrl::OnScroll) |
f97d84a6 RD |
137 | EVT_SIZE (wxStyledTextCtrl::OnSize) |
138 | EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) | |
4ceb1196 RD |
139 | // Let Scintilla see the double click as a second click |
140 | EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) | |
f97d84a6 RD |
141 | EVT_MOTION (wxStyledTextCtrl::OnMouseMove) |
142 | EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) | |
451c5cc7 | 143 | #if defined(__WXGTK__) || defined(__WXMAC__) |
ddf2da08 RD |
144 | EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) |
145 | #else | |
65ec6247 | 146 | EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) |
ddf2da08 | 147 | #endif |
37d62433 | 148 | EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) |
2b5f62a0 | 149 | EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp) |
f97d84a6 RD |
150 | EVT_CHAR (wxStyledTextCtrl::OnChar) |
151 | EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) | |
152 | EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus) | |
153 | EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus) | |
154 | EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) | |
155 | EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) | |
dd4aa550 | 156 | EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu) |
dc8005e2 | 157 | EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox) |
f97d84a6 RD |
158 | END_EVENT_TABLE() |
159 | ||
160 | ||
161 | IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl) | |
162 | IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) | |
163 | ||
40716a51 | 164 | #ifdef LINK_LEXERS |
1a2fb4cd | 165 | // forces the linking of the lexer modules |
a834585d | 166 | int Scintilla_LinkLexers(); |
40716a51 | 167 | #endif |
1a2fb4cd | 168 | |
f97d84a6 RD |
169 | //---------------------------------------------------------------------- |
170 | // Constructor and Destructor | |
171 | ||
172 | wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, | |
173 | wxWindowID id, | |
174 | const wxPoint& pos, | |
175 | const wxSize& size, | |
176 | long style, | |
39c0acb6 RD |
177 | const wxString& name) |
178 | { | |
179 | m_swx = NULL; | |
180 | Create(parent, id, pos, size, style, name); | |
181 | } | |
182 | ||
183 | ||
a48cb415 RD |
184 | bool wxStyledTextCtrl::Create(wxWindow *parent, |
185 | wxWindowID id, | |
186 | const wxPoint& pos, | |
187 | const wxSize& size, | |
188 | long style, | |
189 | const wxString& name) | |
f97d84a6 | 190 | { |
2659dad3 | 191 | style |= wxVSCROLL | wxHSCROLL; |
a48cb415 RD |
192 | if (!wxControl::Create(parent, id, pos, size, |
193 | style | wxWANTS_CHARS | wxCLIP_CHILDREN, | |
194 | wxDefaultValidator, name)) | |
195 | return false; | |
39c0acb6 | 196 | |
40716a51 | 197 | #ifdef LINK_LEXERS |
a834585d | 198 | Scintilla_LinkLexers(); |
40716a51 | 199 | #endif |
f97d84a6 RD |
200 | m_swx = new ScintillaWX(this); |
201 | m_stopWatch.Start(); | |
dc8005e2 | 202 | m_lastKeyDownConsumed = false; |
5fa4613c RD |
203 | m_vScrollBar = NULL; |
204 | m_hScrollBar = NULL; | |
10ef30eb RD |
205 | #if wxUSE_UNICODE |
206 | // Put Scintilla into unicode (UTF-8) mode | |
207 | SetCodePage(wxSTC_CP_UTF8); | |
208 | #endif | |
8ae4f086 | 209 | |
170acdc9 | 210 | SetInitialSize(size); |
f9ee2e27 RD |
211 | |
212 | // Reduces flicker on GTK+/X11 | |
c69612de | 213 | SetBackgroundStyle(wxBG_STYLE_PAINT); |
5e328f38 RD |
214 | |
215 | // Make sure it can take the focus | |
216 | SetCanFocus(true); | |
217 | ||
a48cb415 | 218 | return true; |
f97d84a6 RD |
219 | } |
220 | ||
221 | ||
222 | wxStyledTextCtrl::~wxStyledTextCtrl() { | |
223 | delete m_swx; | |
224 | } | |
225 | ||
226 | ||
227 | //---------------------------------------------------------------------- | |
228 | ||
fafd43c5 | 229 | wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const |
8e0945da | 230 | { |
f97d84a6 RD |
231 | return m_swx->WndProc(msg, wp, lp); |
232 | } | |
233 | ||
ccfc3219 RD |
234 | //---------------------------------------------------------------------- |
235 | ||
236 | // Set the vertical scrollbar to use instead of the ont that's built-in. | |
237 | void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) { | |
238 | m_vScrollBar = bar; | |
239 | if (bar != NULL) { | |
240 | // ensure that the built-in scrollbar is not visible | |
241 | SetScrollbar(wxVERTICAL, 0, 0, 0); | |
242 | } | |
243 | } | |
f97d84a6 | 244 | |
f97d84a6 | 245 | |
ccfc3219 RD |
246 | // Set the horizontal scrollbar to use instead of the ont that's built-in. |
247 | void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) { | |
248 | m_hScrollBar = bar; | |
249 | if (bar != NULL) { | |
250 | // ensure that the built-in scrollbar is not visible | |
251 | SetScrollbar(wxHORIZONTAL, 0, 0, 0); | |
252 | } | |
253 | } | |
254 | ||
f97d84a6 | 255 | //---------------------------------------------------------------------- |
a5c2ccf2 | 256 | // Generated methods implementation section {{{ |
f97d84a6 RD |
257 | |
258 | %(METHOD_IMPS)s | |
259 | ||
a5c2ccf2 | 260 | //}}} |
f97d84a6 RD |
261 | //---------------------------------------------------------------------- |
262 | ||
263 | ||
264 | // Returns the line number of the line with the caret. | |
265 | int wxStyledTextCtrl::GetCurrentLine() { | |
266 | int line = LineFromPosition(GetCurrentPos()); | |
267 | return line; | |
268 | } | |
269 | ||
270 | ||
271 | // Extract style settings from a spec-string which is composed of one or | |
272 | // more of the following comma separated elements: | |
273 | // | |
274 | // bold turns on bold | |
275 | // italic turns on italics | |
5ee1d760 RD |
276 | // fore:[name or #RRGGBB] sets the foreground colour |
277 | // back:[name or #RRGGBB] sets the background colour | |
f97d84a6 RD |
278 | // face:[facename] sets the font face name to use |
279 | // size:[num] sets the font size in points | |
280 | // eol turns on eol filling | |
281 | // underline turns on underlining | |
282 | // | |
283 | void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { | |
284 | ||
451c5cc7 | 285 | wxStringTokenizer tkz(spec, wxT(",")); |
f97d84a6 RD |
286 | while (tkz.HasMoreTokens()) { |
287 | wxString token = tkz.GetNextToken(); | |
288 | ||
289 | wxString option = token.BeforeFirst(':'); | |
290 | wxString val = token.AfterFirst(':'); | |
291 | ||
451c5cc7 | 292 | if (option == wxT("bold")) |
f97d84a6 RD |
293 | StyleSetBold(styleNum, true); |
294 | ||
451c5cc7 | 295 | else if (option == wxT("italic")) |
f97d84a6 RD |
296 | StyleSetItalic(styleNum, true); |
297 | ||
451c5cc7 | 298 | else if (option == wxT("underline")) |
f97d84a6 RD |
299 | StyleSetUnderline(styleNum, true); |
300 | ||
451c5cc7 | 301 | else if (option == wxT("eol")) |
f97d84a6 RD |
302 | StyleSetEOLFilled(styleNum, true); |
303 | ||
451c5cc7 | 304 | else if (option == wxT("size")) { |
f97d84a6 RD |
305 | long points; |
306 | if (val.ToLong(&points)) | |
307 | StyleSetSize(styleNum, points); | |
308 | } | |
309 | ||
451c5cc7 | 310 | else if (option == wxT("face")) |
f97d84a6 RD |
311 | StyleSetFaceName(styleNum, val); |
312 | ||
451c5cc7 | 313 | else if (option == wxT("fore")) |
f97d84a6 RD |
314 | StyleSetForeground(styleNum, wxColourFromSpec(val)); |
315 | ||
451c5cc7 | 316 | else if (option == wxT("back")) |
f97d84a6 RD |
317 | StyleSetBackground(styleNum, wxColourFromSpec(val)); |
318 | } | |
319 | } | |
320 | ||
321 | ||
7e0c58e9 RD |
322 | // Get the font of a style |
323 | wxFont wxStyledTextCtrl::StyleGetFont(int style) { | |
324 | wxFont font; | |
325 | font.SetPointSize(StyleGetSize(style)); | |
326 | font.SetFaceName(StyleGetFaceName(style)); | |
327 | if( StyleGetBold(style) ) | |
328 | font.SetWeight(wxFONTWEIGHT_BOLD); | |
329 | else | |
330 | font.SetWeight(wxFONTWEIGHT_NORMAL); | |
331 | ||
332 | if( StyleGetItalic(style) ) | |
333 | font.SetStyle(wxFONTSTYLE_ITALIC); | |
334 | else | |
335 | font.SetStyle(wxFONTSTYLE_NORMAL); | |
336 | ||
337 | return font; | |
338 | } | |
339 | ||
340 | ||
f97d84a6 RD |
341 | // Set style size, face, bold, italic, and underline attributes from |
342 | // a wxFont's attributes. | |
343 | void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) { | |
7475e814 RD |
344 | #ifdef __WXGTK__ |
345 | // Ensure that the native font is initialized | |
346 | int x, y; | |
347 | GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font); | |
348 | #endif | |
af0531a5 RD |
349 | int size = font.GetPointSize(); |
350 | wxString faceName = font.GetFaceName(); | |
351 | bool bold = font.GetWeight() == wxBOLD; | |
352 | bool italic = font.GetStyle() != wxNORMAL; | |
353 | bool under = font.GetUnderlined(); | |
c5bd09bf | 354 | wxFontEncoding encoding = font.GetEncoding(); |
7e0c58e9 | 355 | |
af0531a5 | 356 | StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding); |
f97d84a6 RD |
357 | } |
358 | ||
359 | // Set all font style attributes at once. | |
360 | void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, | |
361 | const wxString& faceName, | |
362 | bool bold, bool italic, | |
3727c043 RD |
363 | bool underline, |
364 | wxFontEncoding encoding) { | |
f97d84a6 RD |
365 | StyleSetSize(styleNum, size); |
366 | StyleSetFaceName(styleNum, faceName); | |
367 | StyleSetBold(styleNum, bold); | |
368 | StyleSetItalic(styleNum, italic); | |
369 | StyleSetUnderline(styleNum, underline); | |
3727c043 RD |
370 | StyleSetFontEncoding(styleNum, encoding); |
371 | } | |
f97d84a6 | 372 | |
3727c043 RD |
373 | |
374 | // Set the character set of the font in a style. Converts the Scintilla | |
375 | // character set values to a wxFontEncoding. | |
376 | void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) | |
377 | { | |
378 | wxFontEncoding encoding; | |
379 | ||
380 | // Translate the Scintilla characterSet to a wxFontEncoding | |
381 | switch (characterSet) { | |
382 | default: | |
383 | case wxSTC_CHARSET_ANSI: | |
384 | case wxSTC_CHARSET_DEFAULT: | |
385 | encoding = wxFONTENCODING_DEFAULT; | |
386 | break; | |
387 | ||
388 | case wxSTC_CHARSET_BALTIC: | |
389 | encoding = wxFONTENCODING_ISO8859_13; | |
390 | break; | |
391 | ||
392 | case wxSTC_CHARSET_CHINESEBIG5: | |
393 | encoding = wxFONTENCODING_CP950; | |
394 | break; | |
395 | ||
396 | case wxSTC_CHARSET_EASTEUROPE: | |
397 | encoding = wxFONTENCODING_ISO8859_2; | |
398 | break; | |
399 | ||
400 | case wxSTC_CHARSET_GB2312: | |
401 | encoding = wxFONTENCODING_CP936; | |
402 | break; | |
403 | ||
404 | case wxSTC_CHARSET_GREEK: | |
405 | encoding = wxFONTENCODING_ISO8859_7; | |
406 | break; | |
407 | ||
408 | case wxSTC_CHARSET_HANGUL: | |
409 | encoding = wxFONTENCODING_CP949; | |
410 | break; | |
411 | ||
412 | case wxSTC_CHARSET_MAC: | |
413 | encoding = wxFONTENCODING_DEFAULT; | |
414 | break; | |
415 | ||
416 | case wxSTC_CHARSET_OEM: | |
417 | encoding = wxFONTENCODING_DEFAULT; | |
418 | break; | |
419 | ||
420 | case wxSTC_CHARSET_RUSSIAN: | |
421 | encoding = wxFONTENCODING_KOI8; | |
422 | break; | |
423 | ||
424 | case wxSTC_CHARSET_SHIFTJIS: | |
425 | encoding = wxFONTENCODING_CP932; | |
426 | break; | |
427 | ||
428 | case wxSTC_CHARSET_SYMBOL: | |
429 | encoding = wxFONTENCODING_DEFAULT; | |
430 | break; | |
431 | ||
432 | case wxSTC_CHARSET_TURKISH: | |
433 | encoding = wxFONTENCODING_ISO8859_9; | |
434 | break; | |
435 | ||
436 | case wxSTC_CHARSET_JOHAB: | |
437 | encoding = wxFONTENCODING_DEFAULT; | |
438 | break; | |
439 | ||
440 | case wxSTC_CHARSET_HEBREW: | |
441 | encoding = wxFONTENCODING_ISO8859_8; | |
442 | break; | |
443 | ||
444 | case wxSTC_CHARSET_ARABIC: | |
445 | encoding = wxFONTENCODING_ISO8859_6; | |
446 | break; | |
447 | ||
448 | case wxSTC_CHARSET_VIETNAMESE: | |
449 | encoding = wxFONTENCODING_DEFAULT; | |
450 | break; | |
451 | ||
452 | case wxSTC_CHARSET_THAI: | |
453 | encoding = wxFONTENCODING_ISO8859_11; | |
454 | break; | |
1e9bafca RD |
455 | |
456 | case wxSTC_CHARSET_CYRILLIC: | |
457 | encoding = wxFONTENCODING_ISO8859_5; | |
458 | break; | |
7e0c58e9 | 459 | |
1e9bafca RD |
460 | case wxSTC_CHARSET_8859_15: |
461 | encoding = wxFONTENCODING_ISO8859_15;; | |
462 | break; | |
3727c043 RD |
463 | } |
464 | ||
465 | // We just have Scintilla track the wxFontEncoding for us. It gets used | |
466 | // in Font::Create in PlatWX.cpp. We add one to the value so that the | |
467 | // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when | |
468 | // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back | |
469 | // to wxFONENCODING_DEFAULT in Font::Create. | |
470 | SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); | |
471 | } | |
472 | ||
473 | ||
474 | // Set the font encoding to be used by a style. | |
475 | void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding) | |
476 | { | |
477 | SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); | |
f97d84a6 RD |
478 | } |
479 | ||
480 | ||
481 | // Perform one of the operations defined by the wxSTC_CMD_* constants. | |
482 | void wxStyledTextCtrl::CmdKeyExecute(int cmd) { | |
483 | SendMsg(cmd); | |
484 | } | |
485 | ||
486 | ||
487 | // Set the left and right margin in the edit area, measured in pixels. | |
488 | void wxStyledTextCtrl::SetMargins(int left, int right) { | |
489 | SetMarginLeft(left); | |
490 | SetMarginRight(right); | |
491 | } | |
492 | ||
493 | ||
f97d84a6 RD |
494 | // Retrieve the point in the window where a position is displayed. |
495 | wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { | |
496 | int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); | |
497 | int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); | |
498 | return wxPoint(x, y); | |
499 | } | |
500 | ||
501 | // Scroll enough to make the given line visible | |
502 | void wxStyledTextCtrl::ScrollToLine(int line) { | |
503 | m_swx->DoScrollToLine(line); | |
504 | } | |
505 | ||
506 | ||
507 | // Scroll enough to make the given column visible | |
508 | void wxStyledTextCtrl::ScrollToColumn(int column) { | |
509 | m_swx->DoScrollToColumn(column); | |
510 | } | |
511 | ||
512 | ||
2bfca191 | 513 | #if wxUSE_TEXTCTRL |
3396739d VZ |
514 | bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType) |
515 | { | |
516 | bool ok = wxTextAreaBase::DoSaveFile(filename, fileType); | |
2bfca191 | 517 | #else |
51566b0b RD |
518 | bool wxStyledTextCtrl::SaveFile(const wxString& filename) |
519 | { | |
3396739d VZ |
520 | #if wxUSE_FFILE |
521 | wxFFile file(filename, wxT("w")); | |
522 | bool ok = file.IsOpened() && file.Write(GetValue(), *wxConvCurrent); | |
523 | #else | |
524 | bool ok = false; | |
525 | #endif // wxUSE_FFILE | |
526 | #endif | |
527 | if (ok) | |
528 | { | |
51566b0b | 529 | SetSavePoint(); |
3396739d VZ |
530 | } |
531 | return ok; | |
51566b0b RD |
532 | } |
533 | ||
2bfca191 | 534 | #if wxUSE_TEXTCTRL |
3396739d VZ |
535 | bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int fileType) |
536 | { | |
537 | bool ok = wxTextAreaBase::DoLoadFile(filename, fileType); | |
2bfca191 | 538 | #else |
51566b0b RD |
539 | bool wxStyledTextCtrl::LoadFile(const wxString& filename) |
540 | { | |
3396739d VZ |
541 | #if wxUSE_FFILE |
542 | wxFFile file(filename); | |
543 | bool ok = file.IsOpened(); | |
544 | if (ok) | |
51566b0b | 545 | { |
3396739d VZ |
546 | wxString text; |
547 | ok = file.ReadAll(&text, *wxConvCurrent); | |
548 | if (ok) | |
041973c5 | 549 | { |
3396739d | 550 | SetValue(text); |
041973c5 | 551 | } |
51566b0b | 552 | } |
3396739d VZ |
553 | #else |
554 | bool ok = false; | |
555 | #endif // wxUSE_FFILE | |
556 | #endif | |
557 | if (ok) | |
558 | { | |
559 | EmptyUndoBuffer(); | |
560 | SetSavePoint(); | |
561 | } | |
562 | return ok; | |
51566b0b RD |
563 | } |
564 | ||
2fcce896 | 565 | #if wxUSE_DRAG_AND_DROP |
dc8005e2 RD |
566 | wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { |
567 | return m_swx->DoDragOver(x, y, def); | |
568 | } | |
4a65f2c8 RD |
569 | |
570 | ||
dc8005e2 | 571 | bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { |
4a65f2c8 RD |
572 | return m_swx->DoDropText(x, y, data); |
573 | } | |
2fcce896 | 574 | #endif |
4a65f2c8 RD |
575 | |
576 | ||
d1558f3d RD |
577 | void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) { |
578 | m_swx->SetUseAntiAliasing(useAA); | |
579 | } | |
580 | ||
581 | bool wxStyledTextCtrl::GetUseAntiAliasing() { | |
582 | return m_swx->GetUseAntiAliasing(); | |
583 | } | |
584 | ||
95725e35 VZ |
585 | void wxStyledTextCtrl::AnnotationClearLine(int line) { |
586 | SendMsg(SCI_ANNOTATIONSETTEXT, line, NULL); | |
587 | } | |
41a499cd RD |
588 | |
589 | ||
590 | ||
591 | ||
6f67e6d2 | 592 | void wxStyledTextCtrl::AddTextRaw(const char* text, int length) |
41a499cd | 593 | { |
6f67e6d2 RD |
594 | if (length == -1) |
595 | length = strlen(text); | |
596 | SendMsg(SCI_ADDTEXT, length, (sptr_t)text); | |
41a499cd RD |
597 | } |
598 | ||
599 | void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text) | |
600 | { | |
b796ba39 | 601 | SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text); |
41a499cd RD |
602 | } |
603 | ||
604 | wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos) | |
605 | { | |
606 | int len = LineLength(GetCurrentLine()); | |
607 | if (!len) { | |
608 | if (linePos) *linePos = 0; | |
609 | wxCharBuffer empty; | |
610 | return empty; | |
611 | } | |
612 | ||
613 | wxCharBuffer buf(len); | |
b796ba39 | 614 | int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data()); |
41a499cd RD |
615 | if (linePos) *linePos = pos; |
616 | return buf; | |
617 | } | |
618 | ||
619 | wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) | |
620 | { | |
621 | int len = LineLength(line); | |
622 | if (!len) { | |
623 | wxCharBuffer empty; | |
624 | return empty; | |
625 | } | |
626 | ||
627 | wxCharBuffer buf(len); | |
b796ba39 | 628 | SendMsg(SCI_GETLINE, line, (sptr_t)buf.data()); |
41a499cd RD |
629 | return buf; |
630 | } | |
631 | ||
632 | wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() | |
633 | { | |
1a692f0f VZ |
634 | // Calculate the length needed first. |
635 | const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0); | |
41a499cd | 636 | |
1a692f0f | 637 | // And then really get the data. |
41a499cd | 638 | wxCharBuffer buf(len); |
b796ba39 | 639 | SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data()); |
41a499cd RD |
640 | return buf; |
641 | } | |
642 | ||
643 | wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) | |
644 | { | |
645 | if (endPos < startPos) { | |
646 | int temp = startPos; | |
647 | startPos = endPos; | |
648 | endPos = temp; | |
649 | } | |
650 | int len = endPos - startPos; | |
651 | if (!len) { | |
652 | wxCharBuffer empty; | |
653 | return empty; | |
7e0c58e9 | 654 | } |
41a499cd RD |
655 | |
656 | wxCharBuffer buf(len); | |
657 | TextRange tr; | |
658 | tr.lpstrText = buf.data(); | |
659 | tr.chrg.cpMin = startPos; | |
660 | tr.chrg.cpMax = endPos; | |
b796ba39 | 661 | SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); |
41a499cd RD |
662 | return buf; |
663 | } | |
664 | ||
665 | void wxStyledTextCtrl::SetTextRaw(const char* text) | |
666 | { | |
b796ba39 | 667 | SendMsg(SCI_SETTEXT, 0, (sptr_t)text); |
41a499cd RD |
668 | } |
669 | ||
670 | wxCharBuffer wxStyledTextCtrl::GetTextRaw() | |
671 | { | |
949750de VZ |
672 | int len = GetTextLength(); |
673 | wxCharBuffer buf(len); // adds 1 for NUL automatically | |
b796ba39 | 674 | SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data()); |
41a499cd RD |
675 | return buf; |
676 | } | |
677 | ||
6f67e6d2 | 678 | void wxStyledTextCtrl::AppendTextRaw(const char* text, int length) |
41a499cd | 679 | { |
6f67e6d2 RD |
680 | if (length == -1) |
681 | length = strlen(text); | |
682 | SendMsg(SCI_APPENDTEXT, length, (sptr_t)text); | |
41a499cd RD |
683 | } |
684 | ||
685 | ||
686 | ||
687 | ||
688 | ||
f97d84a6 RD |
689 | //---------------------------------------------------------------------- |
690 | // Event handlers | |
691 | ||
88a8b04e | 692 | void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) { |
f97d84a6 | 693 | wxPaintDC dc(this); |
9e730a78 | 694 | m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); |
f97d84a6 RD |
695 | } |
696 | ||
697 | void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { | |
698 | if (evt.GetOrientation() == wxHORIZONTAL) | |
699 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
700 | else | |
701 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
702 | } | |
703 | ||
5fa4613c RD |
704 | void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) { |
705 | wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar); | |
706 | if (sb) { | |
707 | if (sb->IsVertical()) | |
708 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
709 | else | |
710 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
711 | } | |
712 | } | |
713 | ||
88a8b04e | 714 | void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) { |
39c0acb6 RD |
715 | if (m_swx) { |
716 | wxSize sz = GetClientSize(); | |
717 | m_swx->DoSize(sz.x, sz.y); | |
718 | } | |
f97d84a6 RD |
719 | } |
720 | ||
721 | void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { | |
cb1871ca | 722 | SetFocus(); |
f97d84a6 | 723 | wxPoint pt = evt.GetPosition(); |
2b5f62a0 | 724 | m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(), |
f97d84a6 RD |
725 | evt.ShiftDown(), evt.ControlDown(), evt.AltDown()); |
726 | } | |
727 | ||
728 | void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) { | |
729 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 730 | m_swx->DoLeftButtonMove(Point(pt.x, pt.y)); |
f97d84a6 RD |
731 | } |
732 | ||
733 | void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) { | |
734 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 735 | m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(), |
f97d84a6 RD |
736 | evt.ControlDown()); |
737 | } | |
738 | ||
739 | ||
ddf2da08 RD |
740 | void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { |
741 | wxPoint pt = evt.GetPosition(); | |
742 | m_swx->DoContextMenu(Point(pt.x, pt.y)); | |
743 | } | |
744 | ||
745 | ||
2b5f62a0 VZ |
746 | void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { |
747 | wxPoint pt = evt.GetPosition(); | |
748 | m_swx->DoMiddleButtonUp(Point(pt.x, pt.y)); | |
749 | } | |
750 | ||
65ec6247 | 751 | void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { |
f97d84a6 | 752 | wxPoint pt = evt.GetPosition(); |
65ec6247 | 753 | ScreenToClient(&pt.x, &pt.y); |
25484746 RD |
754 | /* |
755 | Show context menu at event point if it's within the window, | |
756 | or at caret location if not | |
757 | */ | |
758 | wxHitTest ht = this->HitTest(pt); | |
759 | if (ht != wxHT_WINDOW_INSIDE) { | |
760 | pt = this->PointFromPosition(this->GetCurrentPos()); | |
761 | } | |
f97d84a6 RD |
762 | m_swx->DoContextMenu(Point(pt.x, pt.y)); |
763 | } | |
764 | ||
37d62433 | 765 | |
60957703 VZ |
766 | void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) |
767 | { | |
42a4299b VZ |
768 | m_swx->DoMouseWheel(evt.GetWheelRotation(), |
769 | evt.GetWheelDelta(), | |
770 | evt.GetLinesPerAction(), | |
771 | evt.ControlDown(), | |
772 | evt.IsPageScroll()); | |
37d62433 RD |
773 | } |
774 | ||
775 | ||
f97d84a6 | 776 | void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { |
5fd656d5 | 777 | // On (some?) non-US PC keyboards the AltGr key is required to enter some |
f3c2c221 RD |
778 | // common characters. It comes to us as both Alt and Ctrl down so we need |
779 | // to let the char through in that case, otherwise if only ctrl or only | |
780 | // alt let's skip it. | |
781 | bool ctrl = evt.ControlDown(); | |
28e0c28e RD |
782 | #ifdef __WXMAC__ |
783 | // On the Mac the Alt key is just a modifier key (like Shift) so we need | |
784 | // to allow the char events to be processed when Alt is pressed. | |
785 | // TODO: Should we check MetaDown instead in this case? | |
786 | bool alt = false; | |
787 | #else | |
f3c2c221 | 788 | bool alt = evt.AltDown(); |
28e0c28e | 789 | #endif |
00c64037 | 790 | bool skip = ((ctrl || alt) && ! (ctrl && alt)); |
f3c2c221 | 791 | |
4358b585 VZ |
792 | #if wxUSE_UNICODE |
793 | // apparently if we don't do this, Unicode keys pressed after non-char | |
794 | // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989) | |
795 | if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255) | |
796 | m_lastKeyDownConsumed = false; | |
797 | #endif | |
798 | ||
5fd656d5 RD |
799 | if (!m_lastKeyDownConsumed && !skip) { |
800 | #if wxUSE_UNICODE | |
801 | int key = evt.GetUnicodeKey(); | |
802 | bool keyOk = true; | |
803 | ||
804 | // if the unicode key code is not really a unicode character (it may | |
805 | // be a function key or etc., the platforms appear to always give us a | |
806 | // small value in this case) then fallback to the ascii key code but | |
807 | // don't do anything for function keys or etc. | |
1b14227e | 808 | if (key <= 127) { |
5fd656d5 | 809 | key = evt.GetKeyCode(); |
1b14227e | 810 | keyOk = (key <= 127); |
5fd656d5 RD |
811 | } |
812 | if (keyOk) { | |
813 | m_swx->DoAddChar(key); | |
814 | return; | |
815 | } | |
816 | #else | |
817 | int key = evt.GetKeyCode(); | |
818 | if (key <= WXK_START || key > WXK_COMMAND) { | |
819 | m_swx->DoAddChar(key); | |
820 | return; | |
821 | } | |
822 | #endif | |
f97d84a6 | 823 | } |
7e0c58e9 | 824 | |
f3c2c221 | 825 | evt.Skip(); |
f97d84a6 RD |
826 | } |
827 | ||
d6582821 | 828 | |
f97d84a6 | 829 | void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { |
5fd656d5 | 830 | int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed); |
d6582821 | 831 | if (!processed && !m_lastKeyDownConsumed) |
f97d84a6 RD |
832 | evt.Skip(); |
833 | } | |
834 | ||
d6582821 | 835 | |
b6bfd8e8 | 836 | void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { |
ec830416 | 837 | m_swx->DoLoseFocus(); |
b6bfd8e8 | 838 | evt.Skip(); |
f97d84a6 RD |
839 | } |
840 | ||
d6582821 | 841 | |
b6bfd8e8 | 842 | void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { |
f97d84a6 | 843 | m_swx->DoGainFocus(); |
b6bfd8e8 | 844 | evt.Skip(); |
f97d84a6 RD |
845 | } |
846 | ||
d6582821 | 847 | |
88a8b04e | 848 | void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) { |
f97d84a6 RD |
849 | m_swx->DoSysColourChange(); |
850 | } | |
851 | ||
d6582821 | 852 | |
88a8b04e | 853 | void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { |
f97d84a6 RD |
854 | // do nothing to help avoid flashing |
855 | } | |
856 | ||
857 | ||
858 | ||
859 | void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) { | |
860 | m_swx->DoCommand(evt.GetId()); | |
861 | } | |
862 | ||
863 | ||
88a8b04e | 864 | void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { |
f97d84a6 RD |
865 | m_swx->DoOnListBox(); |
866 | } | |
867 | ||
868 | ||
8e54aaed RD |
869 | void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { |
870 | m_swx->DoOnIdle(evt); | |
871 | } | |
872 | ||
873 | ||
8ae4f086 RD |
874 | wxSize wxStyledTextCtrl::DoGetBestSize() const |
875 | { | |
876 | // What would be the best size for a wxSTC? | |
877 | // Just give a reasonable minimum until something else can be figured out. | |
878 | return wxSize(200,100); | |
879 | } | |
880 | ||
881 | ||
f97d84a6 RD |
882 | //---------------------------------------------------------------------- |
883 | // Turn notifications from Scintilla into events | |
884 | ||
885 | ||
886 | void wxStyledTextCtrl::NotifyChange() { | |
887 | wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); | |
a29a241f | 888 | evt.SetEventObject(this); |
f97d84a6 RD |
889 | GetEventHandler()->ProcessEvent(evt); |
890 | } | |
891 | ||
2b5f62a0 VZ |
892 | |
893 | static void SetEventText(wxStyledTextEvent& evt, const char* text, | |
894 | size_t length) { | |
895 | if(!text) return; | |
896 | ||
1c930beb | 897 | evt.SetText(stc2wx(text, length)); |
2b5f62a0 VZ |
898 | } |
899 | ||
900 | ||
f97d84a6 RD |
901 | void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { |
902 | SCNotification& scn = *_scn; | |
65ec6247 RD |
903 | wxStyledTextEvent evt(0, GetId()); |
904 | ||
a29a241f | 905 | evt.SetEventObject(this); |
65ec6247 RD |
906 | evt.SetPosition(scn.position); |
907 | evt.SetKey(scn.ch); | |
908 | evt.SetModifiers(scn.modifiers); | |
909 | ||
f97d84a6 RD |
910 | switch (scn.nmhdr.code) { |
911 | case SCN_STYLENEEDED: | |
65ec6247 | 912 | evt.SetEventType(wxEVT_STC_STYLENEEDED); |
f97d84a6 | 913 | break; |
65ec6247 | 914 | |
f97d84a6 | 915 | case SCN_CHARADDED: |
65ec6247 | 916 | evt.SetEventType(wxEVT_STC_CHARADDED); |
f97d84a6 | 917 | break; |
65ec6247 | 918 | |
f97d84a6 | 919 | case SCN_SAVEPOINTREACHED: |
65ec6247 | 920 | evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED); |
f97d84a6 | 921 | break; |
65ec6247 | 922 | |
f97d84a6 | 923 | case SCN_SAVEPOINTLEFT: |
65ec6247 | 924 | evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT); |
f97d84a6 | 925 | break; |
65ec6247 | 926 | |
f97d84a6 | 927 | case SCN_MODIFYATTEMPTRO: |
65ec6247 RD |
928 | evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT); |
929 | break; | |
930 | ||
931 | case SCN_KEY: | |
932 | evt.SetEventType(wxEVT_STC_KEY); | |
f97d84a6 | 933 | break; |
65ec6247 | 934 | |
f97d84a6 | 935 | case SCN_DOUBLECLICK: |
65ec6247 | 936 | evt.SetEventType(wxEVT_STC_DOUBLECLICK); |
54173563 | 937 | evt.SetLine(scn.line); |
f97d84a6 | 938 | break; |
65ec6247 RD |
939 | |
940 | case SCN_UPDATEUI: | |
941 | evt.SetEventType(wxEVT_STC_UPDATEUI); | |
54173563 | 942 | evt.SetUpdated(scn.updated); |
f97d84a6 | 943 | break; |
65ec6247 RD |
944 | |
945 | case SCN_MODIFIED: | |
946 | evt.SetEventType(wxEVT_STC_MODIFIED); | |
947 | evt.SetModificationType(scn.modificationType); | |
2b5f62a0 | 948 | SetEventText(evt, scn.text, scn.length); |
65ec6247 RD |
949 | evt.SetLength(scn.length); |
950 | evt.SetLinesAdded(scn.linesAdded); | |
951 | evt.SetLine(scn.line); | |
952 | evt.SetFoldLevelNow(scn.foldLevelNow); | |
953 | evt.SetFoldLevelPrev(scn.foldLevelPrev); | |
54173563 RD |
954 | evt.SetToken(scn.token); |
955 | evt.SetAnnotationLinesAdded(scn.annotationLinesAdded); | |
f97d84a6 | 956 | break; |
65ec6247 | 957 | |
f97d84a6 | 958 | case SCN_MACRORECORD: |
65ec6247 RD |
959 | evt.SetEventType(wxEVT_STC_MACRORECORD); |
960 | evt.SetMessage(scn.message); | |
961 | evt.SetWParam(scn.wParam); | |
962 | evt.SetLParam(scn.lParam); | |
f97d84a6 | 963 | break; |
65ec6247 | 964 | |
f97d84a6 | 965 | case SCN_MARGINCLICK: |
65ec6247 RD |
966 | evt.SetEventType(wxEVT_STC_MARGINCLICK); |
967 | evt.SetMargin(scn.margin); | |
f97d84a6 | 968 | break; |
65ec6247 | 969 | |
f97d84a6 | 970 | case SCN_NEEDSHOWN: |
65ec6247 RD |
971 | evt.SetEventType(wxEVT_STC_NEEDSHOWN); |
972 | evt.SetLength(scn.length); | |
f97d84a6 | 973 | break; |
65ec6247 | 974 | |
65ec6247 RD |
975 | case SCN_PAINTED: |
976 | evt.SetEventType(wxEVT_STC_PAINTED); | |
977 | break; | |
978 | ||
0daf5e6b RD |
979 | case SCN_AUTOCSELECTION: |
980 | evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION); | |
981 | evt.SetListType(scn.listType); | |
982 | SetEventText(evt, scn.text, strlen(scn.text)); | |
983 | evt.SetPosition(scn.lParam); | |
984 | break; | |
7e0c58e9 | 985 | |
65ec6247 RD |
986 | case SCN_USERLISTSELECTION: |
987 | evt.SetEventType(wxEVT_STC_USERLISTSELECTION); | |
988 | evt.SetListType(scn.listType); | |
2b5f62a0 | 989 | SetEventText(evt, scn.text, strlen(scn.text)); |
0daf5e6b | 990 | evt.SetPosition(scn.lParam); |
f97d84a6 | 991 | break; |
f97d84a6 | 992 | |
65ec6247 RD |
993 | case SCN_URIDROPPED: |
994 | evt.SetEventType(wxEVT_STC_URIDROPPED); | |
2b5f62a0 | 995 | SetEventText(evt, scn.text, strlen(scn.text)); |
65ec6247 RD |
996 | break; |
997 | ||
998 | case SCN_DWELLSTART: | |
999 | evt.SetEventType(wxEVT_STC_DWELLSTART); | |
1000 | evt.SetX(scn.x); | |
1001 | evt.SetY(scn.y); | |
1002 | break; | |
1003 | ||
1004 | case SCN_DWELLEND: | |
1005 | evt.SetEventType(wxEVT_STC_DWELLEND); | |
1006 | evt.SetX(scn.x); | |
1007 | evt.SetY(scn.y); | |
1008 | break; | |
1009 | ||
a834585d RD |
1010 | case SCN_ZOOM: |
1011 | evt.SetEventType(wxEVT_STC_ZOOM); | |
1012 | break; | |
1013 | ||
9e730a78 RD |
1014 | case SCN_HOTSPOTCLICK: |
1015 | evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK); | |
1016 | break; | |
1017 | ||
1018 | case SCN_HOTSPOTDOUBLECLICK: | |
1019 | evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK); | |
1020 | break; | |
1021 | ||
1022 | case SCN_CALLTIPCLICK: | |
1023 | evt.SetEventType(wxEVT_STC_CALLTIP_CLICK); | |
1024 | break; | |
7e0c58e9 RD |
1025 | |
1026 | case SCN_INDICATORCLICK: | |
1027 | evt.SetEventType(wxEVT_STC_INDICATOR_CLICK); | |
1028 | break; | |
1029 | ||
1030 | case SCN_INDICATORRELEASE: | |
1031 | evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE); | |
1032 | break; | |
1033 | ||
9e96e16f RD |
1034 | case SCN_AUTOCCANCELLED: |
1035 | evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED); | |
1036 | break; | |
1037 | ||
1038 | case SCN_AUTOCCHARDELETED: | |
1039 | evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED); | |
1040 | break; | |
1041 | ||
54173563 RD |
1042 | case SCN_HOTSPOTRELEASECLICK: |
1043 | evt.SetEventType(wxEVT_STC_HOTSPOT_RELEASE_CLICK); | |
1044 | break; | |
1045 | ||
65ec6247 RD |
1046 | default: |
1047 | return; | |
f97d84a6 | 1048 | } |
65ec6247 RD |
1049 | |
1050 | GetEventHandler()->ProcessEvent(evt); | |
f97d84a6 RD |
1051 | } |
1052 | ||
1053 | ||
f97d84a6 RD |
1054 | //---------------------------------------------------------------------- |
1055 | //---------------------------------------------------------------------- | |
1056 | //---------------------------------------------------------------------- | |
1057 | ||
1058 | wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) | |
1059 | : wxCommandEvent(commandType, id) | |
1060 | { | |
1061 | m_position = 0; | |
1062 | m_key = 0; | |
1063 | m_modifiers = 0; | |
1064 | m_modificationType = 0; | |
1065 | m_length = 0; | |
1066 | m_linesAdded = 0; | |
1067 | m_line = 0; | |
1068 | m_foldLevelNow = 0; | |
1069 | m_foldLevelPrev = 0; | |
1070 | m_margin = 0; | |
1071 | m_message = 0; | |
1072 | m_wParam = 0; | |
1073 | m_lParam = 0; | |
65ec6247 RD |
1074 | m_listType = 0; |
1075 | m_x = 0; | |
1076 | m_y = 0; | |
d01ca1e4 RD |
1077 | m_token = 0; |
1078 | m_annotationLinesAdded = 0; | |
1079 | m_updated = 0; | |
1080 | ||
92bbd64f | 1081 | #if wxUSE_DRAG_AND_DROP |
35f8d83d | 1082 | m_dragFlags = wxDrag_CopyOnly; |
a29a241f | 1083 | m_dragResult = wxDragNone; |
92bbd64f | 1084 | #endif |
f97d84a6 RD |
1085 | } |
1086 | ||
1087 | bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } | |
1088 | bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; } | |
1089 | bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; } | |
1090 | ||
f97d84a6 | 1091 | |
5fa4613c RD |
1092 | wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): |
1093 | wxCommandEvent(event) | |
1094 | { | |
1095 | m_position = event.m_position; | |
1096 | m_key = event.m_key; | |
1097 | m_modifiers = event.m_modifiers; | |
1098 | m_modificationType = event.m_modificationType; | |
1099 | m_text = event.m_text; | |
1100 | m_length = event.m_length; | |
1101 | m_linesAdded = event.m_linesAdded; | |
1102 | m_line = event.m_line; | |
1103 | m_foldLevelNow = event.m_foldLevelNow; | |
1104 | m_foldLevelPrev = event.m_foldLevelPrev; | |
1105 | ||
1106 | m_margin = event.m_margin; | |
1107 | ||
1108 | m_message = event.m_message; | |
1109 | m_wParam = event.m_wParam; | |
1110 | m_lParam = event.m_lParam; | |
1111 | ||
1112 | m_listType = event.m_listType; | |
1113 | m_x = event.m_x; | |
1114 | m_y = event.m_y; | |
f97d84a6 | 1115 | |
d01ca1e4 RD |
1116 | m_token = event.m_token; |
1117 | m_annotationLinesAdded = event.m_annotationLinesAdded; | |
1118 | m_updated = event.m_updated; | |
1119 | ||
92bbd64f | 1120 | #if wxUSE_DRAG_AND_DROP |
35f8d83d VZ |
1121 | m_dragText = event.m_dragText; |
1122 | m_dragFlags = event.m_dragFlags; | |
5fa4613c | 1123 | m_dragResult = event.m_dragResult; |
92bbd64f | 1124 | #endif |
f97d84a6 RD |
1125 | } |
1126 | ||
1127 | //---------------------------------------------------------------------- | |
1128 | //---------------------------------------------------------------------- | |
1129 | ||
ccec9093 VZ |
1130 | /*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo() |
1131 | { | |
d01ca1e4 | 1132 | return wxVersionInfo("Scintilla", 3, 21, 0, "Scintilla 3.21"); |
ccec9093 VZ |
1133 | } |
1134 | ||
29825f5f | 1135 | #endif // wxUSE_STC |