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