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