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