]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/stc/stc.cpp.in
Patch from Joe "shmengie" Brown joebrown@podiatryfl.com
[wxWidgets.git] / src / stc / stc.cpp.in
... / ...
CommitLineData
1////////////////////////////////////////////////////////////////////////////
2// Name: stc.cpp
3// Purpose: A wxWidgets implementation of Scintilla. This class is the
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
15// Licence: wxWindows license
16/////////////////////////////////////////////////////////////////////////////
17
18#include <ctype.h>
19
20#include <wx/wx.h>
21#include <wx/tokenzr.h>
22#include <wx/mstream.h>
23#include <wx/image.h>
24#include <wx/file.h>
25
26#include "wx/stc/stc.h"
27#include "ScintillaWX.h"
28
29//----------------------------------------------------------------------
30
31const wxChar* wxSTCNameStr = wxT("stcwindow");
32
33#ifdef MAKELONG
34#undef MAKELONG
35#endif
36
37#define MAKELONG(a, b) ((a) | ((b) << 16))
38
39
40static long wxColourAsLong(const wxColour& co) {
41 return (((long)co.Blue() << 16) |
42 ((long)co.Green() << 8) |
43 ((long)co.Red()));
44}
45
46static wxColour wxColourFromLong(long c) {
47 wxColour clr;
48 clr.Set((unsigned char)(c & 0xff),
49 (unsigned char)((c >> 8) & 0xff),
50 (unsigned char)((c >> 16) & 0xff));
51 return clr;
52}
53
54
55static wxColour wxColourFromSpec(const wxString& spec) {
56 // spec should be a colour name or "#RRGGBB"
57 if (spec.GetChar(0) == wxT('#')) {
58
59 long red, green, blue;
60 red = green = blue = 0;
61 spec.Mid(1,2).ToLong(&red, 16);
62 spec.Mid(3,2).ToLong(&green, 16);
63 spec.Mid(5,2).ToLong(&blue, 16);
64 return wxColour((unsigned char)red,
65 (unsigned char)green,
66 (unsigned char)blue);
67 }
68 else
69 return wxColour(spec);
70}
71
72//----------------------------------------------------------------------
73
74DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
75DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
76DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
77DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
78DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
79DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
80DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
81DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
82DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
83DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
84DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
85DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
86DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
87DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
88DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
89DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
90DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
91DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
92DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
93DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
94DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
95DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM )
96DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
97DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
98DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
99
100
101
102BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
103 EVT_PAINT (wxStyledTextCtrl::OnPaint)
104 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
105 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
106 EVT_SIZE (wxStyledTextCtrl::OnSize)
107 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
108 // Let Scintilla see the double click as a second click
109 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
110 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
111 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
112#if defined(__WXGTK__) || defined(__WXMAC__)
113 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
114#else
115 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
116#endif
117 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
118 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
119 EVT_CHAR (wxStyledTextCtrl::OnChar)
120 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
121 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
122 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
123 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
124 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
125 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
126 EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
127END_EVENT_TABLE()
128
129
130IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
131IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
132
133#ifdef LINK_LEXERS
134// forces the linking of the lexer modules
135int Scintilla_LinkLexers();
136#endif
137
138//----------------------------------------------------------------------
139// Constructor and Destructor
140
141wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
142 wxWindowID id,
143 const wxPoint& pos,
144 const wxSize& size,
145 long style,
146 const wxString& name)
147{
148 m_swx = NULL;
149 Create(parent, id, pos, size, style, name);
150}
151
152
153bool wxStyledTextCtrl::Create(wxWindow *parent,
154 wxWindowID id,
155 const wxPoint& pos,
156 const wxSize& size,
157 long style,
158 const wxString& name)
159{
160#ifdef __WXMAC__
161 style |= wxVSCROLL | wxHSCROLL;
162#endif
163 if (!wxControl::Create(parent, id, pos, size,
164 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
165 wxDefaultValidator, name))
166 return false;
167
168#ifdef LINK_LEXERS
169 Scintilla_LinkLexers();
170#endif
171 m_swx = new ScintillaWX(this);
172 m_stopWatch.Start();
173 m_lastKeyDownConsumed = false;
174 m_vScrollBar = NULL;
175 m_hScrollBar = NULL;
176#if wxUSE_UNICODE
177 // Put Scintilla into unicode (UTF-8) mode
178 SetCodePage(wxSTC_CP_UTF8);
179#endif
180
181 SetBestFittingSize(size);
182
183 // Reduces flicker on GTK+/X11
184 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
185 return true;
186}
187
188
189wxStyledTextCtrl::~wxStyledTextCtrl() {
190 delete m_swx;
191}
192
193
194//----------------------------------------------------------------------
195
196long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
197
198 return m_swx->WndProc(msg, wp, lp);
199}
200
201//----------------------------------------------------------------------
202
203// Set the vertical scrollbar to use instead of the ont that's built-in.
204void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
205 m_vScrollBar = bar;
206 if (bar != NULL) {
207 // ensure that the built-in scrollbar is not visible
208 SetScrollbar(wxVERTICAL, 0, 0, 0);
209 }
210}
211
212
213// Set the horizontal scrollbar to use instead of the ont that's built-in.
214void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
215 m_hScrollBar = bar;
216 if (bar != NULL) {
217 // ensure that the built-in scrollbar is not visible
218 SetScrollbar(wxHORIZONTAL, 0, 0, 0);
219 }
220}
221
222//----------------------------------------------------------------------
223// BEGIN generated section. The following code is automatically generated
224// by gen_iface.py from the contents of Scintilla.iface. Do not edit
225// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
226
227%(METHOD_IMPS)s
228
229// END of generated section
230//----------------------------------------------------------------------
231
232
233// Returns the line number of the line with the caret.
234int wxStyledTextCtrl::GetCurrentLine() {
235 int line = LineFromPosition(GetCurrentPos());
236 return line;
237}
238
239
240// Extract style settings from a spec-string which is composed of one or
241// more of the following comma separated elements:
242//
243// bold turns on bold
244// italic turns on italics
245// fore:[name or #RRGGBB] sets the foreground colour
246// back:[name or #RRGGBB] sets the background colour
247// face:[facename] sets the font face name to use
248// size:[num] sets the font size in points
249// eol turns on eol filling
250// underline turns on underlining
251//
252void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
253
254 wxStringTokenizer tkz(spec, wxT(","));
255 while (tkz.HasMoreTokens()) {
256 wxString token = tkz.GetNextToken();
257
258 wxString option = token.BeforeFirst(':');
259 wxString val = token.AfterFirst(':');
260
261 if (option == wxT("bold"))
262 StyleSetBold(styleNum, true);
263
264 else if (option == wxT("italic"))
265 StyleSetItalic(styleNum, true);
266
267 else if (option == wxT("underline"))
268 StyleSetUnderline(styleNum, true);
269
270 else if (option == wxT("eol"))
271 StyleSetEOLFilled(styleNum, true);
272
273 else if (option == wxT("size")) {
274 long points;
275 if (val.ToLong(&points))
276 StyleSetSize(styleNum, points);
277 }
278
279 else if (option == wxT("face"))
280 StyleSetFaceName(styleNum, val);
281
282 else if (option == wxT("fore"))
283 StyleSetForeground(styleNum, wxColourFromSpec(val));
284
285 else if (option == wxT("back"))
286 StyleSetBackground(styleNum, wxColourFromSpec(val));
287 }
288}
289
290
291// Set style size, face, bold, italic, and underline attributes from
292// a wxFont's attributes.
293void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
294#ifdef __WXGTK__
295 // Ensure that the native font is initialized
296 int x, y;
297 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
298#endif
299 int size = font.GetPointSize();
300 wxString faceName = font.GetFaceName();
301 bool bold = font.GetWeight() == wxBOLD;
302 bool italic = font.GetStyle() != wxNORMAL;
303 bool under = font.GetUnderlined();
304
305 // TODO: add encoding/charset mapping
306 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
307}
308
309// Set all font style attributes at once.
310void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
311 const wxString& faceName,
312 bool bold, bool italic,
313 bool underline) {
314 StyleSetSize(styleNum, size);
315 StyleSetFaceName(styleNum, faceName);
316 StyleSetBold(styleNum, bold);
317 StyleSetItalic(styleNum, italic);
318 StyleSetUnderline(styleNum, underline);
319
320 // TODO: add encoding/charset mapping
321}
322
323
324// Perform one of the operations defined by the wxSTC_CMD_* constants.
325void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
326 SendMsg(cmd);
327}
328
329
330// Set the left and right margin in the edit area, measured in pixels.
331void wxStyledTextCtrl::SetMargins(int left, int right) {
332 SetMarginLeft(left);
333 SetMarginRight(right);
334}
335
336
337// Retrieve the start and end positions of the current selection.
338void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
339 if (startPos != NULL)
340 *startPos = SendMsg(SCI_GETSELECTIONSTART);
341 if (endPos != NULL)
342 *endPos = SendMsg(SCI_GETSELECTIONEND);
343}
344
345
346// Retrieve the point in the window where a position is displayed.
347wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
348 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
349 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
350 return wxPoint(x, y);
351}
352
353// Scroll enough to make the given line visible
354void wxStyledTextCtrl::ScrollToLine(int line) {
355 m_swx->DoScrollToLine(line);
356}
357
358
359// Scroll enough to make the given column visible
360void wxStyledTextCtrl::ScrollToColumn(int column) {
361 m_swx->DoScrollToColumn(column);
362}
363
364
365bool wxStyledTextCtrl::SaveFile(const wxString& filename)
366{
367 wxFile file(filename, wxFile::write);
368
369 if (!file.IsOpened())
370 return false;
371
372 bool success = file.Write(GetText(), *wxConvCurrent);
373
374 if (success)
375 SetSavePoint();
376
377 return success;
378}
379
380bool wxStyledTextCtrl::LoadFile(const wxString& filename)
381{
382 bool success = false;
383 wxFile file(filename, wxFile::read);
384
385 if (file.IsOpened())
386 {
387 wxString contents;
388 // get the file size (assume it is not huge file...)
389 ssize_t len = (ssize_t)file.Length();
390
391 if (len > 0)
392 {
393#if wxUSE_UNICODE
394 wxMemoryBuffer buffer(len+1);
395 success = (file.Read(buffer.GetData(), len) == len);
396 if (success) {
397 ((char*)buffer.GetData())[len] = 0;
398 contents = wxString(buffer, *wxConvCurrent, len);
399 }
400#else
401 wxString buffer;
402 success = (file.Read(wxStringBuffer(buffer, len), len) == len);
403 contents = buffer;
404#endif
405 }
406 else
407 {
408 if (len == 0)
409 success = true; // empty file is ok
410 else
411 success = false; // len == wxInvalidOffset
412 }
413
414 if (success)
415 {
416 SetText(contents);
417 EmptyUndoBuffer();
418 SetSavePoint();
419 }
420 }
421
422 return success;
423}
424
425
426#if wxUSE_DRAG_AND_DROP
427wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
428 return m_swx->DoDragOver(x, y, def);
429}
430
431
432bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
433 return m_swx->DoDropText(x, y, data);
434}
435#endif
436
437
438void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
439 m_swx->SetUseAntiAliasing(useAA);
440}
441
442bool wxStyledTextCtrl::GetUseAntiAliasing() {
443 return m_swx->GetUseAntiAliasing();
444}
445
446//----------------------------------------------------------------------
447// Event handlers
448
449void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
450 wxPaintDC dc(this);
451 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
452}
453
454void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
455 if (evt.GetOrientation() == wxHORIZONTAL)
456 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
457 else
458 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
459}
460
461void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
462 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
463 if (sb) {
464 if (sb->IsVertical())
465 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
466 else
467 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
468 }
469}
470
471void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
472 if (m_swx) {
473 wxSize sz = GetClientSize();
474 m_swx->DoSize(sz.x, sz.y);
475 }
476}
477
478void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
479 SetFocus();
480 wxPoint pt = evt.GetPosition();
481 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
482 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
483}
484
485void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
486 wxPoint pt = evt.GetPosition();
487 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
488}
489
490void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
491 wxPoint pt = evt.GetPosition();
492 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
493 evt.ControlDown());
494}
495
496
497void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
498 wxPoint pt = evt.GetPosition();
499 m_swx->DoContextMenu(Point(pt.x, pt.y));
500}
501
502
503void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
504 wxPoint pt = evt.GetPosition();
505 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
506}
507
508void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
509 wxPoint pt = evt.GetPosition();
510 ScreenToClient(&pt.x, &pt.y);
511 /*
512 Show context menu at event point if it's within the window,
513 or at caret location if not
514 */
515 wxHitTest ht = this->HitTest(pt);
516 if (ht != wxHT_WINDOW_INSIDE) {
517 pt = this->PointFromPosition(this->GetCurrentPos());
518 }
519 m_swx->DoContextMenu(Point(pt.x, pt.y));
520}
521
522
523void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
524 m_swx->DoMouseWheel(evt.GetWheelRotation(),
525 evt.GetWheelDelta(),
526 evt.GetLinesPerAction(),
527 evt.ControlDown(),
528 evt.IsPageScroll());
529}
530
531
532void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
533 // On (some?) non-US PC keyboards the AltGr key is required to enter some
534 // common characters. It comes to us as both Alt and Ctrl down so we need
535 // to let the char through in that case, otherwise if only ctrl or only
536 // alt let's skip it.
537 bool ctrl = evt.ControlDown();
538#ifdef __WXMAC__
539 // On the Mac the Alt key is just a modifier key (like Shift) so we need
540 // to allow the char events to be processed when Alt is pressed.
541 // TODO: Should we check MetaDown instead in this case?
542 bool alt = false;
543#else
544 bool alt = evt.AltDown();
545#endif
546 bool skip = ((ctrl || alt) && ! (ctrl && alt));
547
548 if (!m_lastKeyDownConsumed && !skip) {
549#if wxUSE_UNICODE
550 int key = evt.GetUnicodeKey();
551 bool keyOk = true;
552
553 // if the unicode key code is not really a unicode character (it may
554 // be a function key or etc., the platforms appear to always give us a
555 // small value in this case) then fallback to the ascii key code but
556 // don't do anything for function keys or etc.
557 if (key <= 127) {
558 key = evt.GetKeyCode();
559 keyOk = (key <= 127);
560 }
561 if (keyOk) {
562 m_swx->DoAddChar(key);
563 return;
564 }
565#else
566 int key = evt.GetKeyCode();
567 if (key <= WXK_START || key > WXK_COMMAND) {
568 m_swx->DoAddChar(key);
569 return;
570 }
571#endif
572 }
573
574 evt.Skip();
575}
576
577
578void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
579 int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
580 if (!processed && !m_lastKeyDownConsumed)
581 evt.Skip();
582}
583
584
585void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
586 m_swx->DoLoseFocus();
587 evt.Skip();
588}
589
590
591void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
592 m_swx->DoGainFocus();
593 evt.Skip();
594}
595
596
597void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
598 m_swx->DoSysColourChange();
599}
600
601
602void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
603 // do nothing to help avoid flashing
604}
605
606
607
608void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
609 m_swx->DoCommand(evt.GetId());
610}
611
612
613void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
614 m_swx->DoOnListBox();
615}
616
617
618void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
619 m_swx->DoOnIdle(evt);
620}
621
622
623wxSize wxStyledTextCtrl::DoGetBestSize() const
624{
625 // What would be the best size for a wxSTC?
626 // Just give a reasonable minimum until something else can be figured out.
627 return wxSize(200,100);
628}
629
630
631//----------------------------------------------------------------------
632// Turn notifications from Scintilla into events
633
634
635void wxStyledTextCtrl::NotifyChange() {
636 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
637 evt.SetEventObject(this);
638 GetEventHandler()->ProcessEvent(evt);
639}
640
641
642static void SetEventText(wxStyledTextEvent& evt, const char* text,
643 size_t length) {
644 if(!text) return;
645
646 // The unicode conversion MUST have a null byte to terminate the
647 // string so move it into a buffer first and give it one.
648 wxMemoryBuffer buf(length+1);
649 buf.AppendData((void*)text, length);
650 buf.AppendByte(0);
651 evt.SetText(stc2wx(buf));
652}
653
654
655void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
656 SCNotification& scn = *_scn;
657 wxStyledTextEvent evt(0, GetId());
658
659 evt.SetEventObject(this);
660 evt.SetPosition(scn.position);
661 evt.SetKey(scn.ch);
662 evt.SetModifiers(scn.modifiers);
663
664 switch (scn.nmhdr.code) {
665 case SCN_STYLENEEDED:
666 evt.SetEventType(wxEVT_STC_STYLENEEDED);
667 break;
668
669 case SCN_CHARADDED:
670 evt.SetEventType(wxEVT_STC_CHARADDED);
671 break;
672
673 case SCN_SAVEPOINTREACHED:
674 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
675 break;
676
677 case SCN_SAVEPOINTLEFT:
678 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
679 break;
680
681 case SCN_MODIFYATTEMPTRO:
682 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
683 break;
684
685 case SCN_KEY:
686 evt.SetEventType(wxEVT_STC_KEY);
687 break;
688
689 case SCN_DOUBLECLICK:
690 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
691 break;
692
693 case SCN_UPDATEUI:
694 evt.SetEventType(wxEVT_STC_UPDATEUI);
695 break;
696
697 case SCN_MODIFIED:
698 evt.SetEventType(wxEVT_STC_MODIFIED);
699 evt.SetModificationType(scn.modificationType);
700 SetEventText(evt, scn.text, scn.length);
701 evt.SetLength(scn.length);
702 evt.SetLinesAdded(scn.linesAdded);
703 evt.SetLine(scn.line);
704 evt.SetFoldLevelNow(scn.foldLevelNow);
705 evt.SetFoldLevelPrev(scn.foldLevelPrev);
706 break;
707
708 case SCN_MACRORECORD:
709 evt.SetEventType(wxEVT_STC_MACRORECORD);
710 evt.SetMessage(scn.message);
711 evt.SetWParam(scn.wParam);
712 evt.SetLParam(scn.lParam);
713 break;
714
715 case SCN_MARGINCLICK:
716 evt.SetEventType(wxEVT_STC_MARGINCLICK);
717 evt.SetMargin(scn.margin);
718 break;
719
720 case SCN_NEEDSHOWN:
721 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
722 evt.SetLength(scn.length);
723 break;
724
725 case SCN_PAINTED:
726 evt.SetEventType(wxEVT_STC_PAINTED);
727 break;
728
729 case SCN_USERLISTSELECTION:
730 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
731 evt.SetListType(scn.listType);
732 SetEventText(evt, scn.text, strlen(scn.text));
733 break;
734
735 case SCN_URIDROPPED:
736 evt.SetEventType(wxEVT_STC_URIDROPPED);
737 SetEventText(evt, scn.text, strlen(scn.text));
738 break;
739
740 case SCN_DWELLSTART:
741 evt.SetEventType(wxEVT_STC_DWELLSTART);
742 evt.SetX(scn.x);
743 evt.SetY(scn.y);
744 break;
745
746 case SCN_DWELLEND:
747 evt.SetEventType(wxEVT_STC_DWELLEND);
748 evt.SetX(scn.x);
749 evt.SetY(scn.y);
750 break;
751
752 case SCN_ZOOM:
753 evt.SetEventType(wxEVT_STC_ZOOM);
754 break;
755
756 case SCN_HOTSPOTCLICK:
757 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
758 break;
759
760 case SCN_HOTSPOTDOUBLECLICK:
761 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
762 break;
763
764 case SCN_CALLTIPCLICK:
765 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
766 break;
767
768 default:
769 return;
770 }
771
772 GetEventHandler()->ProcessEvent(evt);
773}
774
775
776//----------------------------------------------------------------------
777//----------------------------------------------------------------------
778//----------------------------------------------------------------------
779
780wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
781 : wxCommandEvent(commandType, id)
782{
783 m_position = 0;
784 m_key = 0;
785 m_modifiers = 0;
786 m_modificationType = 0;
787 m_length = 0;
788 m_linesAdded = 0;
789 m_line = 0;
790 m_foldLevelNow = 0;
791 m_foldLevelPrev = 0;
792 m_margin = 0;
793 m_message = 0;
794 m_wParam = 0;
795 m_lParam = 0;
796 m_listType = 0;
797 m_x = 0;
798 m_y = 0;
799 m_dragAllowMove = false;
800#if wxUSE_DRAG_AND_DROP
801 m_dragResult = wxDragNone;
802#endif
803}
804
805bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
806bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
807bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
808
809
810wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
811 wxCommandEvent(event)
812{
813 m_position = event.m_position;
814 m_key = event.m_key;
815 m_modifiers = event.m_modifiers;
816 m_modificationType = event.m_modificationType;
817 m_text = event.m_text;
818 m_length = event.m_length;
819 m_linesAdded = event.m_linesAdded;
820 m_line = event.m_line;
821 m_foldLevelNow = event.m_foldLevelNow;
822 m_foldLevelPrev = event.m_foldLevelPrev;
823
824 m_margin = event.m_margin;
825
826 m_message = event.m_message;
827 m_wParam = event.m_wParam;
828 m_lParam = event.m_lParam;
829
830 m_listType = event.m_listType;
831 m_x = event.m_x;
832 m_y = event.m_y;
833
834 m_dragText = event.m_dragText;
835 m_dragAllowMove =event.m_dragAllowMove;
836#if wxUSE_DRAG_AND_DROP
837 m_dragResult = event.m_dragResult;
838#endif
839}
840
841//----------------------------------------------------------------------
842//----------------------------------------------------------------------
843
844
845
846
847
848
849
850
851