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