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