]> git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/stc.cpp
Added DnD related events to wxSTC
[wxWidgets.git] / contrib / src / stc / stc.cpp
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
25 // The following code forces a reference to all of the Scintilla lexers.
26 // If we don't do something like this, then the linker tends to "optimize"
27 // them away. (eric@sourcegear.com)
28
29 int wxForceScintillaLexers(void)
30 {
31 extern LexerModule lmAda;
32 extern LexerModule lmAVE;
33 extern LexerModule lmConf;
34 extern LexerModule lmCPP;
35 extern LexerModule lmNncrontab;
36 extern LexerModule lmEiffel;
37 extern LexerModule lmHTML;
38 extern LexerModule lmLISP;
39 extern LexerModule lmLua;
40 extern LexerModule lmBatch; // In LexOthers.cxx
41 extern LexerModule lmPascal;
42 extern LexerModule lmPerl;
43 extern LexerModule lmPython;
44 extern LexerModule lmRuby;
45 extern LexerModule lmSQL;
46 extern LexerModule lmVB;
47
48 if ( &lmAda
49 && &lmAVE
50 && &lmConf
51 && &lmCPP
52 && &lmNncrontab
53 && &lmEiffel
54 && &lmHTML
55 && &lmLISP
56 && &lmLua
57 && &lmBatch
58 && &lmPascal
59 && &lmPerl
60 && &lmPython
61 && &lmRuby
62 && &lmSQL
63 && &lmVB )
64 {
65 return 1;
66 }
67 else
68 {
69 return 0;
70 }
71 }
72
73 //----------------------------------------------------------------------
74
75 const wxChar* wxSTCNameStr = "stcwindow";
76
77 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
78 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
79 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
80 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
81 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
82 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
83 DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
84 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
85 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
86 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
87 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
88 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
89 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
90 DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
91 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
92 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
93 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
94 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
95 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
96 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
97 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
98 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
99
100
101 BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
102 EVT_PAINT (wxStyledTextCtrl::OnPaint)
103 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
104 EVT_SIZE (wxStyledTextCtrl::OnSize)
105 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
106 #ifdef __WXMSW__
107 // Let Scintilla see the double click as a second click
108 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
109 #endif
110 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
111 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
112 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
113 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
114 EVT_CHAR (wxStyledTextCtrl::OnChar)
115 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
116 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
117 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
118 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
119 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
120 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
121 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
122 END_EVENT_TABLE()
123
124
125 IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
126 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
127
128 //----------------------------------------------------------------------
129 // Constructor and Destructor
130
131 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
132 wxWindowID id,
133 const wxPoint& pos,
134 const wxSize& size,
135 long style,
136 const wxString& name) :
137 wxControl(parent, id, pos, size,
138 style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
139 wxDefaultValidator, name)
140 {
141 m_swx = new ScintillaWX(this);
142 m_stopWatch.Start();
143 m_lastKeyDownConsumed = FALSE;
144 }
145
146
147 wxStyledTextCtrl::~wxStyledTextCtrl() {
148 delete m_swx;
149 }
150
151
152 //----------------------------------------------------------------------
153
154 long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
155
156 return m_swx->WndProc(msg, wp, lp);
157 }
158
159
160 #ifdef MAKELONG
161 #undef MAKELONG
162 #endif
163
164 #define MAKELONG(a, b) ((a) | ((b) << 16))
165
166
167 static long wxColourAsLong(const wxColour& co) {
168 return (((long)co.Blue() << 16) |
169 ((long)co.Green() << 8) |
170 ((long)co.Red()));
171 }
172
173 static wxColour wxColourFromLong(long c) {
174 wxColour clr;
175 clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
176 return clr;
177 }
178
179
180 static wxColour wxColourFromSpec(const wxString& spec) {
181 // spec should be #RRGGBB
182 char* junk;
183 int red = strtol(spec.Mid(1,2), &junk, 16);
184 int green = strtol(spec.Mid(3,2), &junk, 16);
185 int blue = strtol(spec.Mid(5,2), &junk, 16);
186 return wxColour(red, green, blue);
187 }
188
189
190 //----------------------------------------------------------------------
191 // BEGIN generated section. The following code is automatically generated
192 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
193 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
194
195
196 // Add text to the document
197 void wxStyledTextCtrl::AddText(const wxString& text) {
198 SendMsg(2001, text.Len(), (long)text.c_str());
199 }
200
201 // Add array of cells to document
202 void wxStyledTextCtrl::AddStyledText(const wxString& text) {
203 SendMsg(2002, text.Len(), (long)text.c_str());
204 }
205
206 // Insert string at a position
207 void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
208 SendMsg(2003, pos, (long)text.c_str());
209 }
210
211 // Delete all text in the document
212 void wxStyledTextCtrl::ClearAll() {
213 SendMsg(2004, 0, 0);
214 }
215
216 // Set all style bytes to 0, remove all folding information
217 void wxStyledTextCtrl::ClearDocumentStyle() {
218 SendMsg(2005, 0, 0);
219 }
220
221 // The number of characters in the document
222 int wxStyledTextCtrl::GetLength() {
223 return SendMsg(2006, 0, 0);
224 }
225
226 // Returns the character byte at the position
227 int wxStyledTextCtrl::GetCharAt(int pos) {
228 return SendMsg(2007, pos, 0);
229 }
230
231 // Returns the position of the caret
232 int wxStyledTextCtrl::GetCurrentPos() {
233 return SendMsg(2008, 0, 0);
234 }
235
236 // Returns the position of the opposite end of the selection to the caret
237 int wxStyledTextCtrl::GetAnchor() {
238 return SendMsg(2009, 0, 0);
239 }
240
241 // Returns the style byte at the position
242 int wxStyledTextCtrl::GetStyleAt(int pos) {
243 return SendMsg(2010, pos, 0);
244 }
245
246 // Redoes the next action on the undo history
247 void wxStyledTextCtrl::Redo() {
248 SendMsg(2011, 0, 0);
249 }
250
251 // Choose between collecting actions into the undo
252 // history and discarding them.
253 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
254 SendMsg(2012, collectUndo, 0);
255 }
256
257 // Select all the text in the document.
258 void wxStyledTextCtrl::SelectAll() {
259 SendMsg(2013, 0, 0);
260 }
261
262 // Remember the current position in the undo history as the position
263 // at which the document was saved.
264 void wxStyledTextCtrl::SetSavePoint() {
265 SendMsg(2014, 0, 0);
266 }
267
268 // Retrieve a buffer of cells.
269 wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
270 wxString text;
271 int len = endPos - startPos;
272 if (!len) return "";
273 TextRange tr;
274 tr.lpstrText = text.GetWriteBuf(len*2);
275 tr.chrg.cpMin = startPos;
276 tr.chrg.cpMax = endPos;
277 SendMsg(2015, 0, (long)&tr);
278 text.UngetWriteBuf(len*2);
279 return text;
280 }
281
282 // Are there any redoable actions in the undo history.
283 bool wxStyledTextCtrl::CanRedo() {
284 return SendMsg(2016, 0, 0) != 0;
285 }
286
287 // Retrieve the line number at which a particular marker is located
288 int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
289 return SendMsg(2017, handle, 0);
290 }
291
292 // Delete a marker.
293 void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
294 SendMsg(2018, handle, 0);
295 }
296
297 // Is undo history being collected?
298 bool wxStyledTextCtrl::GetUndoCollection() {
299 return SendMsg(2019, 0, 0) != 0;
300 }
301
302 // Are white space characters currently visible?
303 // Returns one of SCWS_* constants.
304 int wxStyledTextCtrl::GetViewWhiteSpace() {
305 return SendMsg(2020, 0, 0);
306 }
307
308 // Make white space characters invisible, always visible or visible outside indentation.
309 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
310 SendMsg(2021, viewWS, 0);
311 }
312
313 // Find the position from a point within the window.
314 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
315 return SendMsg(2022, pt.x, pt.y);
316 }
317
318 // Find the position from a point within the window but return
319 // INVALID_POSITION if not close to text.
320 int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
321 return SendMsg(2023, x, y);
322 }
323
324 // Set caret to start of a line and ensure it is visible.
325 void wxStyledTextCtrl::GotoLine(int line) {
326 SendMsg(2024, line, 0);
327 }
328
329 // Set caret to a position and ensure it is visible.
330 void wxStyledTextCtrl::GotoPos(int pos) {
331 SendMsg(2025, pos, 0);
332 }
333
334 // Set the selection anchor to a position. The anchor is the opposite
335 // end of the selection from the caret.
336 void wxStyledTextCtrl::SetAnchor(int posAnchor) {
337 SendMsg(2026, posAnchor, 0);
338 }
339
340 // Retrieve the text of the line containing the caret.
341 // Returns the index of the caret on the line.
342 wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
343 wxString text;
344 int len = LineLength(GetCurrentLine());
345 if (!len) {
346 if (linePos) *linePos = 0;
347 return "";
348 }
349 // Need an extra byte because SCI_GETCURLINE writes a null to the string
350 char* buf = text.GetWriteBuf(len+1);
351
352 int pos = SendMsg(2027, len+1, (long)buf);
353 text.UngetWriteBuf(len);
354 if (linePos) *linePos = pos;
355
356 return text;
357 }
358
359 // Retrieve the position of the last correctly styled character.
360 int wxStyledTextCtrl::GetEndStyled() {
361 return SendMsg(2028, 0, 0);
362 }
363
364 // Convert all line endings in the document to one mode.
365 void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
366 SendMsg(2029, eolMode, 0);
367 }
368
369 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
370 int wxStyledTextCtrl::GetEOLMode() {
371 return SendMsg(2030, 0, 0);
372 }
373
374 // Set the current end of line mode.
375 void wxStyledTextCtrl::SetEOLMode(int eolMode) {
376 SendMsg(2031, eolMode, 0);
377 }
378
379 // Set the current styling position to pos and the styling mask to mask.
380 // The styling mask can be used to protect some bits in each styling byte from
381 // modification.
382 void wxStyledTextCtrl::StartStyling(int pos, int mask) {
383 SendMsg(2032, pos, mask);
384 }
385
386 // Change style from current styling position for length characters to a style
387 // and move the current styling position to after this newly styled segment.
388 void wxStyledTextCtrl::SetStyling(int length, int style) {
389 SendMsg(2033, length, style);
390 }
391
392 // Is drawing done first into a buffer or direct to the screen.
393 bool wxStyledTextCtrl::GetBufferedDraw() {
394 return SendMsg(2034, 0, 0) != 0;
395 }
396
397 // If drawing is buffered then each line of text is drawn into a bitmap buffer
398 // before drawing it to the screen to avoid flicker.
399 void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
400 SendMsg(2035, buffered, 0);
401 }
402
403 // Change the visible size of a tab to be a multiple of the width of a space
404 // character.
405 void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
406 SendMsg(2036, tabWidth, 0);
407 }
408
409 // Retrieve the visible size of a tab.
410 int wxStyledTextCtrl::GetTabWidth() {
411 return SendMsg(2121, 0, 0);
412 }
413
414 // Set the code page used to interpret the bytes of the document as characters.
415 // The SC_CP_UTF8 value can be used to enter Unicode mode.
416 void wxStyledTextCtrl::SetCodePage(int codePage) {
417 SendMsg(2037, codePage, 0);
418 }
419
420 // Set the symbol used for a particular marker number,
421 // and optionally the for and background colours.
422 void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
423 const wxColour& foreground,
424 const wxColour& background) {
425
426 SendMsg(2040, markerNumber, markerSymbol);
427 if (foreground.Ok())
428 MarkerSetForeground(markerNumber, foreground);
429 if (background.Ok())
430 MarkerSetBackground(markerNumber, background);
431 }
432
433 // Set the foreground colour used for a particular marker number.
434 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
435 SendMsg(2041, markerNumber, wxColourAsLong(fore));
436 }
437
438 // Set the background colour used for a particular marker number.
439 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
440 SendMsg(2042, markerNumber, wxColourAsLong(back));
441 }
442
443 // Add a marker to a line.
444 void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
445 SendMsg(2043, line, markerNumber);
446 }
447
448 // Delete a marker from a line
449 void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
450 SendMsg(2044, line, markerNumber);
451 }
452
453 // Delete all markers with a particular number from all lines
454 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
455 SendMsg(2045, markerNumber, 0);
456 }
457
458 // Get a bit mask of all the markers set on a line.
459 int wxStyledTextCtrl::MarkerGet(int line) {
460 return SendMsg(2046, line, 0);
461 }
462
463 // Find the next line after lineStart that includes a marker in mask.
464 int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
465 return SendMsg(2047, lineStart, markerMask);
466 }
467
468 // Find the previous line before lineStart that includes a marker in mask.
469 int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
470 return SendMsg(2048, lineStart, markerMask);
471 }
472
473 // Set a margin to be either numeric or symbolic.
474 void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
475 SendMsg(2240, margin, marginType);
476 }
477
478 // Retrieve the type of a margin.
479 int wxStyledTextCtrl::GetMarginType(int margin) {
480 return SendMsg(2241, margin, 0);
481 }
482
483 // Set the width of a margin to a width expressed in pixels.
484 void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
485 SendMsg(2242, margin, pixelWidth);
486 }
487
488 // Retrieve the width of a margin in pixels.
489 int wxStyledTextCtrl::GetMarginWidth(int margin) {
490 return SendMsg(2243, margin, 0);
491 }
492
493 // Set a mask that determines which markers are displayed in a margin.
494 void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
495 SendMsg(2244, margin, mask);
496 }
497
498 // Retrieve the marker mask of a margin.
499 int wxStyledTextCtrl::GetMarginMask(int margin) {
500 return SendMsg(2245, margin, 0);
501 }
502
503 // Make a margin sensitive or insensitive to mouse clicks.
504 void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
505 SendMsg(2246, margin, sensitive);
506 }
507
508 // Retrieve the mouse click sensitivity of a margin.
509 bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
510 return SendMsg(2247, margin, 0) != 0;
511 }
512
513 // Clear all the styles and make equivalent to the global default style.
514 void wxStyledTextCtrl::StyleClearAll() {
515 SendMsg(2050, 0, 0);
516 }
517
518 // Set the foreground colour of a style.
519 void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
520 SendMsg(2051, style, wxColourAsLong(fore));
521 }
522
523 // Set the background colour of a style.
524 void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
525 SendMsg(2052, style, wxColourAsLong(back));
526 }
527
528 // Set a style to be bold or not.
529 void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
530 SendMsg(2053, style, bold);
531 }
532
533 // Set a style to be italic or not.
534 void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
535 SendMsg(2054, style, italic);
536 }
537
538 // Set the size of characters of a style.
539 void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
540 SendMsg(2055, style, sizePoints);
541 }
542
543 // Set the font of a style.
544 void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
545 SendMsg(2056, style, (long)fontName.c_str());
546 }
547
548 // Set a style to have its end of line filled or not.
549 void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
550 SendMsg(2057, style, filled);
551 }
552
553 // Reset the default style to its state at startup
554 void wxStyledTextCtrl::StyleResetDefault() {
555 SendMsg(2058, 0, 0);
556 }
557
558 // Set a style to be underlined or not.
559 void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
560 SendMsg(2059, style, underline);
561 }
562
563 // Set a style to be mixed case, or to force upper or lower case.
564 void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
565 SendMsg(2060, style, caseForce);
566 }
567
568 // Set the foreground colour of the selection and whether to use this setting.
569 void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
570 SendMsg(2067, useSetting, wxColourAsLong(fore));
571 }
572
573 // Set the background colour of the selection and whether to use this setting.
574 void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
575 SendMsg(2068, useSetting, wxColourAsLong(back));
576 }
577
578 // Set the foreground colour of the caret.
579 void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
580 SendMsg(2069, wxColourAsLong(fore), 0);
581 }
582
583 // When key+modifier combination km is pressed perform msg.
584 void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
585 SendMsg(2070, MAKELONG(key, modifiers), cmd);
586 }
587
588 // When key+modifier combination km do nothing.
589 void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
590 SendMsg(2071, MAKELONG(key, modifiers));
591 }
592
593 // Drop all key mappings.
594 void wxStyledTextCtrl::CmdKeyClearAll() {
595 SendMsg(2072, 0, 0);
596 }
597
598 // Set the styles for a segment of the document.
599 void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
600 SendMsg(2073, length, (long)styleBytes);
601 }
602
603 // Set a style to be visible or not.
604 void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
605 SendMsg(2074, style, visible);
606 }
607
608 // Get the time in milliseconds that the caret is on and off.
609 int wxStyledTextCtrl::GetCaretPeriod() {
610 return SendMsg(2075, 0, 0);
611 }
612
613 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
614 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
615 SendMsg(2076, periodMilliseconds, 0);
616 }
617
618 // Set the set of characters making up words for when moving or selecting
619 // by word.
620 void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
621 SendMsg(2077, 0, (long)characters.c_str());
622 }
623
624 // Start a sequence of actions that is undone and redone as a unit.
625 // May be nested.
626 void wxStyledTextCtrl::BeginUndoAction() {
627 SendMsg(2078, 0, 0);
628 }
629
630 // End a sequence of actions that is undone and redone as a unit.
631 void wxStyledTextCtrl::EndUndoAction() {
632 SendMsg(2079, 0, 0);
633 }
634
635 // Set an indicator to plain, squiggle or TT.
636 void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
637 SendMsg(2080, indic, style);
638 }
639
640 // Retrieve the style of an indicator.
641 int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
642 return SendMsg(2081, indic, 0);
643 }
644
645 // Set the foreground colour of an indicator.
646 void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
647 SendMsg(2082, indic, wxColourAsLong(fore));
648 }
649
650 // Retrieve the foreground colour of an indicator.
651 wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
652 long c = SendMsg(2083, indic, 0);
653 return wxColourFromLong(c);
654 }
655
656 // Divide each styling byte into lexical class bits (default:5) and indicator
657 // bits (default:3). If a lexer requires more than 32 lexical states, then this
658 // is used to expand the possible states.
659 void wxStyledTextCtrl::SetStyleBits(int bits) {
660 SendMsg(2090, bits, 0);
661 }
662
663 // Retrieve number of bits in style bytes used to hold the lexical state.
664 int wxStyledTextCtrl::GetStyleBits() {
665 return SendMsg(2091, 0, 0);
666 }
667
668 // Used to hold extra styling information for each line.
669 void wxStyledTextCtrl::SetLineState(int line, int state) {
670 SendMsg(2092, line, state);
671 }
672
673 // Retrieve the extra styling information for a line.
674 int wxStyledTextCtrl::GetLineState(int line) {
675 return SendMsg(2093, line, 0);
676 }
677
678 // Retrieve the last line number that has line state.
679 int wxStyledTextCtrl::GetMaxLineState() {
680 return SendMsg(2094, 0, 0);
681 }
682
683 // Is the background of the line containing the caret in a different colour?
684 bool wxStyledTextCtrl::GetCaretLineVisible() {
685 return SendMsg(2095, 0, 0) != 0;
686 }
687
688 // Display the background of the line containing the caret in a different colour.
689 void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
690 SendMsg(2096, show, 0);
691 }
692
693 // Get the colour of the background of the line containing the caret.
694 wxColour wxStyledTextCtrl::GetCaretLineBack() {
695 long c = SendMsg(2097, 0, 0);
696 return wxColourFromLong(c);
697 }
698
699 // Set the colour of the background of the line containing the caret.
700 void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
701 SendMsg(2098, wxColourAsLong(back), 0);
702 }
703
704 // Display a auto-completion list.
705 // The lenEntered parameter indicates how many characters before
706 // the caret should be used to provide context.
707 void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
708 SendMsg(2100, lenEntered, (long)itemList.c_str());
709 }
710
711 // Remove the auto-completion list from the screen.
712 void wxStyledTextCtrl::AutoCompCancel() {
713 SendMsg(2101, 0, 0);
714 }
715
716 // Is there an auto-completion list visible?
717 bool wxStyledTextCtrl::AutoCompActive() {
718 return SendMsg(2102, 0, 0) != 0;
719 }
720
721 // Retrieve the position of the caret when the auto-completion list was
722 // displayed.
723 int wxStyledTextCtrl::AutoCompPosStart() {
724 return SendMsg(2103, 0, 0);
725 }
726
727 // User has selected an item so remove the list and insert the selection.
728 void wxStyledTextCtrl::AutoCompComplete() {
729 SendMsg(2104, 0, 0);
730 }
731
732 // Define a set of character that when typed cancel the auto-completion list.
733 void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
734 SendMsg(2105, 0, (long)characterSet.c_str());
735 }
736
737 // Change the separator character in the string setting up an auto-completion
738 // list. Default is space but can be changed if items contain space.
739 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
740 SendMsg(2106, separatorCharacter, 0);
741 }
742
743 // Retrieve the auto-completion list separator character.
744 int wxStyledTextCtrl::AutoCompGetSeparator() {
745 return SendMsg(2107, 0, 0);
746 }
747
748 // Select the item in the auto-completion list that starts with a string.
749 void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
750 SendMsg(2108, 0, (long)text.c_str());
751 }
752
753 // Should the auto-completion list be cancelled if the user backspaces to a
754 // position before where the box was created.
755 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
756 SendMsg(2110, cancel, 0);
757 }
758
759 // Retrieve whether auto-completion cancelled by backspacing before start.
760 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
761 return SendMsg(2111, 0, 0) != 0;
762 }
763
764 // Define a set of character that when typed fills up the selected word.
765 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
766 SendMsg(2112, 0, (long)characterSet.c_str());
767 }
768
769 // Should a single item auto-completion list automatically choose the item.
770 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
771 SendMsg(2113, chooseSingle, 0);
772 }
773
774 // Retrieve whether a single item auto-completion list automatically choose the item.
775 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
776 return SendMsg(2114, 0, 0) != 0;
777 }
778
779 // Set whether case is significant when performing auto-completion searches.
780 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
781 SendMsg(2115, ignoreCase, 0);
782 }
783
784 // Retrieve state of ignore case flag.
785 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
786 return SendMsg(2116, 0, 0) != 0;
787 }
788
789 // Display a list of strings and send notification when user chooses one.
790 void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
791 SendMsg(2117, listType, (long)itemList.c_str());
792 }
793
794 // Set whether or not autocompletion is hidden automatically when nothing matches
795 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
796 SendMsg(2118, autoHide, 0);
797 }
798
799 // Retrieve whether or not autocompletion is hidden automatically when nothing matches
800 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
801 return SendMsg(2119, 0, 0) != 0;
802 }
803
804 // Set the number of spaces used for one level of indentation.
805 void wxStyledTextCtrl::SetIndent(int indentSize) {
806 SendMsg(2122, indentSize, 0);
807 }
808
809 // Retrieve indentation size.
810 int wxStyledTextCtrl::GetIndent() {
811 return SendMsg(2123, 0, 0);
812 }
813
814 // Indentation will only use space characters if useTabs is false, otherwise
815 // it will use a combination of tabs and spaces.
816 void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
817 SendMsg(2124, useTabs, 0);
818 }
819
820 // Retrieve whether tabs will be used in indentation.
821 bool wxStyledTextCtrl::GetUseTabs() {
822 return SendMsg(2125, 0, 0) != 0;
823 }
824
825 // Change the indentation of a line to a number of columns.
826 void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
827 SendMsg(2126, line, indentSize);
828 }
829
830 // Retrieve the number of columns that a line is indented.
831 int wxStyledTextCtrl::GetLineIndentation(int line) {
832 return SendMsg(2127, line, 0);
833 }
834
835 // Retrieve the position before the first non indentation character on a line.
836 int wxStyledTextCtrl::GetLineIndentPosition(int line) {
837 return SendMsg(2128, line, 0);
838 }
839
840 // Retrieve the column number of a position, taking tab width into account.
841 int wxStyledTextCtrl::GetColumn(int pos) {
842 return SendMsg(2129, pos, 0);
843 }
844
845 // Show or hide the horizontal scroll bar.
846 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
847 SendMsg(2130, show, 0);
848 }
849
850 // Is the horizontal scroll bar visible?
851 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
852 return SendMsg(2131, 0, 0) != 0;
853 }
854
855 // Show or hide indentation guides.
856 void wxStyledTextCtrl::SetIndentationGuides(bool show) {
857 SendMsg(2132, show, 0);
858 }
859
860 // Are the indentation guides visible?
861 bool wxStyledTextCtrl::GetIndentationGuides() {
862 return SendMsg(2133, 0, 0) != 0;
863 }
864
865 // Set the highlighted indentation guide column.
866 // 0 = no highlighted guide.
867 void wxStyledTextCtrl::SetHighlightGuide(int column) {
868 SendMsg(2134, column, 0);
869 }
870
871 // Get the highlighted indentation guide column.
872 int wxStyledTextCtrl::GetHighlightGuide() {
873 return SendMsg(2135, 0, 0);
874 }
875
876 // Get the position after the last visible characters on a line.
877 int wxStyledTextCtrl::GetLineEndPosition(int line) {
878 return SendMsg(2136, line, 0);
879 }
880
881 // Get the code page used to interpret the bytes of the document as characters.
882 int wxStyledTextCtrl::GetCodePage() {
883 return SendMsg(2137, 0, 0);
884 }
885
886 // Get the foreground colour of the caret.
887 wxColour wxStyledTextCtrl::GetCaretForeground() {
888 long c = SendMsg(2138, 0, 0);
889 return wxColourFromLong(c);
890 }
891
892 // In read-only mode?
893 bool wxStyledTextCtrl::GetReadOnly() {
894 return SendMsg(2140, 0, 0) != 0;
895 }
896
897 // Sets the position of the caret.
898 void wxStyledTextCtrl::SetCurrentPos(int pos) {
899 SendMsg(2141, pos, 0);
900 }
901
902 // Sets the position that starts the selection - this becomes the anchor.
903 void wxStyledTextCtrl::SetSelectionStart(int pos) {
904 SendMsg(2142, pos, 0);
905 }
906
907 // Returns the position at the start of the selection.
908 int wxStyledTextCtrl::GetSelectionStart() {
909 return SendMsg(2143, 0, 0);
910 }
911
912 // Sets the position that ends the selection - this becomes the currentPosition.
913 void wxStyledTextCtrl::SetSelectionEnd(int pos) {
914 SendMsg(2144, pos, 0);
915 }
916
917 // Returns the position at the end of the selection.
918 int wxStyledTextCtrl::GetSelectionEnd() {
919 return SendMsg(2145, 0, 0);
920 }
921
922 // Sets the print magnification added to the point size of each style for printing.
923 void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
924 SendMsg(2146, magnification, 0);
925 }
926
927 // Returns the print magnification.
928 int wxStyledTextCtrl::GetPrintMagnification() {
929 return SendMsg(2147, 0, 0);
930 }
931
932 // Modify colours when printing for clearer printed text.
933 void wxStyledTextCtrl::SetPrintColourMode(int mode) {
934 SendMsg(2148, mode, 0);
935 }
936
937 // Returns the print colour mode.
938 int wxStyledTextCtrl::GetPrintColourMode() {
939 return SendMsg(2149, 0, 0);
940 }
941
942 // Find some text in the document.
943 int wxStyledTextCtrl::FindText(int minPos, int maxPos,
944 const wxString& text,
945 bool caseSensitive, bool wholeWord) {
946 TextToFind ft;
947 int flags = 0;
948
949 flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
950 flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
951 ft.chrg.cpMin = minPos;
952 ft.chrg.cpMax = maxPos;
953 ft.lpstrText = (char*)text.c_str();
954
955 return SendMsg(2150, flags, (long)&ft);
956 }
957
958 // On Windows will draw the document into a display context such as a printer.
959 int wxStyledTextCtrl::FormatRange(bool doDraw,
960 int startPos,
961 int endPos,
962 wxDC* draw,
963 wxDC* target, // Why does it use two? Can they be the same?
964 wxRect renderRect,
965 wxRect pageRect) {
966 RangeToFormat fr;
967
968 fr.hdc = draw;
969 fr.hdcTarget = target;
970 fr.rc.top = renderRect.GetTop();
971 fr.rc.left = renderRect.GetLeft();
972 fr.rc.right = renderRect.GetRight();
973 fr.rc.bottom = renderRect.GetBottom();
974 fr.rcPage.top = pageRect.GetTop();
975 fr.rcPage.left = pageRect.GetLeft();
976 fr.rcPage.right = pageRect.GetRight();
977 fr.rcPage.bottom = pageRect.GetBottom();
978 fr.chrg.cpMin = startPos;
979 fr.chrg.cpMax = endPos;
980
981 return SendMsg(2151, doDraw, (long)&fr);
982 }
983
984 // Retrieve the line at the top of the display.
985 int wxStyledTextCtrl::GetFirstVisibleLine() {
986 return SendMsg(2152, 0, 0);
987 }
988
989 // Retrieve the contents of a line.
990 wxString wxStyledTextCtrl::GetLine(int line) {
991 wxString text;
992 int len = LineLength(line);
993 if (!len) return "";
994 char* buf = text.GetWriteBuf(len);
995
996 int pos = SendMsg(2153, line, (long)buf);
997 text.UngetWriteBuf(len);
998
999 return text;
1000 }
1001
1002 // Returns the number of lines in the document. There is always at least one.
1003 int wxStyledTextCtrl::GetLineCount() {
1004 return SendMsg(2154, 0, 0);
1005 }
1006
1007 // Sets the size in pixels of the left margin.
1008 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
1009 SendMsg(2155, 0, pixelWidth);
1010 }
1011
1012 // Returns the size in pixels of the left margin.
1013 int wxStyledTextCtrl::GetMarginLeft() {
1014 return SendMsg(2156, 0, 0);
1015 }
1016
1017 // Sets the size in pixels of the right margin.
1018 void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
1019 SendMsg(2157, 0, pixelWidth);
1020 }
1021
1022 // Returns the size in pixels of the right margin.
1023 int wxStyledTextCtrl::GetMarginRight() {
1024 return SendMsg(2158, 0, 0);
1025 }
1026
1027 // Is the document different from when it was last saved?
1028 bool wxStyledTextCtrl::GetModify() {
1029 return SendMsg(2159, 0, 0) != 0;
1030 }
1031
1032 // Select a range of text.
1033 void wxStyledTextCtrl::SetSelection(int start, int end) {
1034 SendMsg(2160, start, end);
1035 }
1036
1037 // Retrieve the selected text.
1038 wxString wxStyledTextCtrl::GetSelectedText() {
1039 wxString text;
1040 int start;
1041 int end;
1042
1043 GetSelection(&start, &end);
1044 int len = end - start;
1045 if (!len) return "";
1046 char* buff = text.GetWriteBuf(len);
1047
1048 SendMsg(2161, 0, (long)buff);
1049 text.UngetWriteBuf(len);
1050 return text;
1051 }
1052
1053 // Retrieve a range of text.
1054 wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1055 wxString text;
1056 int len = endPos - startPos;
1057 if (!len) return "";
1058 char* buff = text.GetWriteBuf(len);
1059 TextRange tr;
1060 tr.lpstrText = buff;
1061 tr.chrg.cpMin = startPos;
1062 tr.chrg.cpMax = endPos;
1063
1064 SendMsg(2162, 0, (long)&tr);
1065 text.UngetWriteBuf(len);
1066 return text;
1067 }
1068
1069 // Draw the selection in normal style or with selection highlighted.
1070 void wxStyledTextCtrl::HideSelection(bool normal) {
1071 SendMsg(2163, normal, 0);
1072 }
1073
1074 // Retrieve the line containing a position.
1075 int wxStyledTextCtrl::LineFromPosition(int pos) {
1076 return SendMsg(2166, pos, 0);
1077 }
1078
1079 // Retrieve the position at the start of a line.
1080 int wxStyledTextCtrl::PositionFromLine(int line) {
1081 return SendMsg(2167, line, 0);
1082 }
1083
1084 // Scroll horizontally and vertically.
1085 void wxStyledTextCtrl::LineScroll(int columns, int lines) {
1086 SendMsg(2168, columns, lines);
1087 }
1088
1089 // Ensure the caret is visible.
1090 void wxStyledTextCtrl::EnsureCaretVisible() {
1091 SendMsg(2169, 0, 0);
1092 }
1093
1094 // Replace the selected text with the argument text.
1095 void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
1096 SendMsg(2170, 0, (long)text.c_str());
1097 }
1098
1099 // Set to read only or read write.
1100 void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1101 SendMsg(2171, readOnly, 0);
1102 }
1103
1104 // Will a paste succeed?
1105 bool wxStyledTextCtrl::CanPaste() {
1106 return SendMsg(2173, 0, 0) != 0;
1107 }
1108
1109 // Are there any undoable actions in the undo history.
1110 bool wxStyledTextCtrl::CanUndo() {
1111 return SendMsg(2174, 0, 0) != 0;
1112 }
1113
1114 // Delete the undo history.
1115 void wxStyledTextCtrl::EmptyUndoBuffer() {
1116 SendMsg(2175, 0, 0);
1117 }
1118
1119 // Undo one action in the undo history.
1120 void wxStyledTextCtrl::Undo() {
1121 SendMsg(2176, 0, 0);
1122 }
1123
1124 // Cut the selection to the clipboard.
1125 void wxStyledTextCtrl::Cut() {
1126 SendMsg(2177, 0, 0);
1127 }
1128
1129 // Copy the selection to the clipboard.
1130 void wxStyledTextCtrl::Copy() {
1131 SendMsg(2178, 0, 0);
1132 }
1133
1134 // Paste the contents of the clipboard into the document replacing the selection.
1135 void wxStyledTextCtrl::Paste() {
1136 SendMsg(2179, 0, 0);
1137 }
1138
1139 // Clear the selection.
1140 void wxStyledTextCtrl::Clear() {
1141 SendMsg(2180, 0, 0);
1142 }
1143
1144 // Replace the contents of the document with the argument text.
1145 void wxStyledTextCtrl::SetText(const wxString& text) {
1146 SendMsg(2181, 0, (long)text.c_str());
1147 }
1148
1149 // Retrieve all the text in the document.
1150 wxString wxStyledTextCtrl::GetText() {
1151 wxString text;
1152 int len = GetTextLength();
1153 char* buff = text.GetWriteBuf(len+1); // leave room for the null...
1154
1155 SendMsg(2182, len+1, (long)buff);
1156 text.UngetWriteBuf(len);
1157 return text;
1158 }
1159
1160 // Retrieve the number of characters in the document.
1161 int wxStyledTextCtrl::GetTextLength() {
1162 return SendMsg(2183, 0, 0);
1163 }
1164
1165 // Set to overtype (true) or insert mode
1166 void wxStyledTextCtrl::SetOvertype(bool overtype) {
1167 SendMsg(2186, overtype, 0);
1168 }
1169
1170 // Returns true if overtype mode is active otherwise false is returned.
1171 bool wxStyledTextCtrl::GetOvertype() {
1172 return SendMsg(2187, 0, 0) != 0;
1173 }
1174
1175 // Set the width of the insert mode caret
1176 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
1177 SendMsg(2188, pixelWidth, 0);
1178 }
1179
1180 // Returns the width of the insert mode caret
1181 int wxStyledTextCtrl::GetCaretWidth() {
1182 return SendMsg(2189, 0, 0);
1183 }
1184
1185 // Sets the position that starts the target which is used for updating the
1186 // document without affecting the scroll position.
1187 void wxStyledTextCtrl::SetTargetStart(int pos) {
1188 SendMsg(2190, pos, 0);
1189 }
1190
1191 // Get the position that starts the target.
1192 int wxStyledTextCtrl::GetTargetStart() {
1193 return SendMsg(2191, 0, 0);
1194 }
1195
1196 // Sets the position that ends the target which is used for updating the
1197 // document without affecting the scroll position.
1198 void wxStyledTextCtrl::SetTargetEnd(int pos) {
1199 SendMsg(2192, pos, 0);
1200 }
1201
1202 // Get the position that ends the target.
1203 int wxStyledTextCtrl::GetTargetEnd() {
1204 return SendMsg(2193, 0, 0);
1205 }
1206
1207 // Replace the target text with the argument text.
1208 // Text is counted so it can contain nulls.
1209 // Returns the length of the replacement text.
1210
1211 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1212 return SendMsg(2194, text.Len(), (long)text.c_str());
1213
1214 }
1215
1216 // Replace the target text with the argument text after \d processing.
1217 // Text is counted so it can contain nulls.
1218 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1219 // matched in the last search operation which were surrounded by \( and \).
1220 // Returns the length of the replacement text including any change
1221 // caused by processing the \d patterns.
1222
1223 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1224 return SendMsg(2195, text.Len(), (long)text.c_str());
1225
1226 }
1227
1228 // Search for a counted string in the target and set the target to the found
1229 // range. Text is counted so it can contain nulls.
1230 // Returns length of range or -1 for failure in which case target is not moved.
1231
1232 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1233 return SendMsg(2197, text.Len(), (long)text.c_str());
1234
1235 }
1236
1237 // Set the search flags used by SearchInTarget
1238 void wxStyledTextCtrl::SetSearchFlags(int flags) {
1239 SendMsg(2198, flags, 0);
1240 }
1241
1242 // Get the search flags used by SearchInTarget
1243 int wxStyledTextCtrl::GetSearchFlags() {
1244 return SendMsg(2199, 0, 0);
1245 }
1246
1247 // Show a call tip containing a definition near position pos.
1248 void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
1249 SendMsg(2200, pos, (long)definition.c_str());
1250 }
1251
1252 // Remove the call tip from the screen.
1253 void wxStyledTextCtrl::CallTipCancel() {
1254 SendMsg(2201, 0, 0);
1255 }
1256
1257 // Is there an active call tip?
1258 bool wxStyledTextCtrl::CallTipActive() {
1259 return SendMsg(2202, 0, 0) != 0;
1260 }
1261
1262 // Retrieve the position where the caret was before displaying the call tip.
1263 int wxStyledTextCtrl::CallTipPosAtStart() {
1264 return SendMsg(2203, 0, 0);
1265 }
1266
1267 // Highlight a segment of the definition.
1268 void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
1269 SendMsg(2204, start, end);
1270 }
1271
1272 // Set the background colour for the call tip.
1273 void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1274 SendMsg(2205, wxColourAsLong(back), 0);
1275 }
1276
1277 // Find the display line of a document line taking hidden lines into account.
1278 int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1279 return SendMsg(2220, line, 0);
1280 }
1281
1282 // Find the document line of a display line taking hidden lines into account.
1283 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1284 return SendMsg(2221, lineDisplay, 0);
1285 }
1286
1287 // Set the fold level of a line.
1288 // This encodes an integer level along with flags indicating whether the
1289 // line is a header and whether it is effectively white space.
1290 void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1291 SendMsg(2222, line, level);
1292 }
1293
1294 // Retrieve the fold level of a line.
1295 int wxStyledTextCtrl::GetFoldLevel(int line) {
1296 return SendMsg(2223, line, 0);
1297 }
1298
1299 // Find the last child line of a header line.
1300 int wxStyledTextCtrl::GetLastChild(int line, int level) {
1301 return SendMsg(2224, line, level);
1302 }
1303
1304 // Find the parent line of a child line.
1305 int wxStyledTextCtrl::GetFoldParent(int line) {
1306 return SendMsg(2225, line, 0);
1307 }
1308
1309 // Make a range of lines visible.
1310 void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1311 SendMsg(2226, lineStart, lineEnd);
1312 }
1313
1314 // Make a range of lines invisible.
1315 void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1316 SendMsg(2227, lineStart, lineEnd);
1317 }
1318
1319 // Is a line visible?
1320 bool wxStyledTextCtrl::GetLineVisible(int line) {
1321 return SendMsg(2228, line, 0) != 0;
1322 }
1323
1324 // Show the children of a header line.
1325 void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1326 SendMsg(2229, line, expanded);
1327 }
1328
1329 // Is a header line expanded?
1330 bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1331 return SendMsg(2230, line, 0) != 0;
1332 }
1333
1334 // Switch a header line between expanded and contracted.
1335 void wxStyledTextCtrl::ToggleFold(int line) {
1336 SendMsg(2231, line, 0);
1337 }
1338
1339 // Ensure a particular line is visible by expanding any header line hiding it.
1340 void wxStyledTextCtrl::EnsureVisible(int line) {
1341 SendMsg(2232, line, 0);
1342 }
1343
1344 // Set some debugging options for folding
1345 void wxStyledTextCtrl::SetFoldFlags(int flags) {
1346 SendMsg(2233, flags, 0);
1347 }
1348
1349 // Ensure a particular line is visible by expanding any header line hiding it.
1350 // Use the currently set visibility policy to determine which range to display.
1351 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
1352 SendMsg(2234, line, 0);
1353 }
1354
1355 // Sets whether a tab pressed when caret is within indentation indents
1356 void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
1357 SendMsg(2260, tabIndents, 0);
1358 }
1359
1360 // Does a tab pressed when caret is within indentation indent?
1361 bool wxStyledTextCtrl::GetTabIndents() {
1362 return SendMsg(2261, 0, 0) != 0;
1363 }
1364
1365 // Sets whether a backspace pressed when caret is within indentation unindents
1366 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
1367 SendMsg(2262, bsUnIndents, 0);
1368 }
1369
1370 // Does a backspace pressed when caret is within indentation unindent?
1371 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1372 return SendMsg(2263, 0, 0) != 0;
1373 }
1374
1375 // Sets the time the mouse must sit still to generate a mouse dwell event
1376 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
1377 SendMsg(2264, periodMilliseconds, 0);
1378 }
1379
1380 // Retrieve the time the mouse must sit still to generate a mouse dwell event
1381 int wxStyledTextCtrl::GetMouseDwellTime() {
1382 return SendMsg(2265, 0, 0);
1383 }
1384
1385 // Move the caret inside current view if it's not there already
1386 void wxStyledTextCtrl::MoveCaretInsideView() {
1387 SendMsg(2401, 0, 0);
1388 }
1389
1390 // How many characters are on a line, not including end of line characters.
1391 int wxStyledTextCtrl::LineLength(int line) {
1392 return SendMsg(2350, line, 0);
1393 }
1394
1395 // Highlight the characters at two positions.
1396 void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
1397 SendMsg(2351, pos1, pos2);
1398 }
1399
1400 // Highlight the character at a position indicating there is no matching brace.
1401 void wxStyledTextCtrl::BraceBadLight(int pos) {
1402 SendMsg(2352, pos, 0);
1403 }
1404
1405 // Find the position of a matching brace or INVALID_POSITION if no match.
1406 int wxStyledTextCtrl::BraceMatch(int pos) {
1407 return SendMsg(2353, pos, 0);
1408 }
1409
1410 // Are the end of line characters visible.
1411 bool wxStyledTextCtrl::GetViewEOL() {
1412 return SendMsg(2355, 0, 0) != 0;
1413 }
1414
1415 // Make the end of line characters visible or invisible
1416 void wxStyledTextCtrl::SetViewEOL(bool visible) {
1417 SendMsg(2356, visible, 0);
1418 }
1419
1420 // Retrieve a pointer to the document object.
1421 void* wxStyledTextCtrl::GetDocPointer() {
1422 return (void*)SendMsg(2357);
1423 }
1424
1425 // Change the document object used.
1426 void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
1427 SendMsg(2358, 0, (long)docPointer);
1428 }
1429
1430 // Set which document modification events are sent to the container.
1431 void wxStyledTextCtrl::SetModEventMask(int mask) {
1432 SendMsg(2359, mask, 0);
1433 }
1434
1435 // Retrieve the column number which text should be kept within.
1436 int wxStyledTextCtrl::GetEdgeColumn() {
1437 return SendMsg(2360, 0, 0);
1438 }
1439
1440 // Set the column number of the edge.
1441 // If text goes past the edge then it is highlighted.
1442 void wxStyledTextCtrl::SetEdgeColumn(int column) {
1443 SendMsg(2361, column, 0);
1444 }
1445
1446 // Retrieve the edge highlight mode.
1447 int wxStyledTextCtrl::GetEdgeMode() {
1448 return SendMsg(2362, 0, 0);
1449 }
1450
1451 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1452 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1453 void wxStyledTextCtrl::SetEdgeMode(int mode) {
1454 SendMsg(2363, mode, 0);
1455 }
1456
1457 // Retrieve the colour used in edge indication.
1458 wxColour wxStyledTextCtrl::GetEdgeColour() {
1459 long c = SendMsg(2364, 0, 0);
1460 return wxColourFromLong(c);
1461 }
1462
1463 // Change the colour used in edge indication.
1464 void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
1465 SendMsg(2365, wxColourAsLong(edgeColour), 0);
1466 }
1467
1468 // Sets the current caret position to be the search anchor.
1469 void wxStyledTextCtrl::SearchAnchor() {
1470 SendMsg(2366, 0, 0);
1471 }
1472
1473 // Find some text starting at the search anchor.
1474 // Does not ensure the selection is visible.
1475 int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
1476 return SendMsg(2367, flags, (long)text.c_str());
1477 }
1478
1479 // Find some text starting at the search anchor and moving backwards.
1480 // Does not ensure the selection is visible.
1481 int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
1482 return SendMsg(2368, flags, (long)text.c_str());
1483 }
1484
1485 // Set the way the line the caret is on is kept visible.
1486 void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy, int caretSlop) {
1487 SendMsg(2369, caretPolicy, caretSlop);
1488 }
1489
1490 // Retrieves the number of lines completely visible.
1491 int wxStyledTextCtrl::LinesOnScreen() {
1492 return SendMsg(2370, 0, 0);
1493 }
1494
1495 // Set whether a pop up menu is displayed automatically when the user presses
1496 // the wrong mouse button.
1497 void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
1498 SendMsg(2371, allowPopUp, 0);
1499 }
1500
1501 // Is the selection a rectangular. The alternative is the more common stream selection.
1502 bool wxStyledTextCtrl::SelectionIsRectangle() {
1503 return SendMsg(2372, 0, 0) != 0;
1504 }
1505
1506 // Set the zoom level. This number of points is added to the size of all fonts.
1507 // It may be positive to magnify or negative to reduce.
1508 void wxStyledTextCtrl::SetZoom(int zoom) {
1509 SendMsg(2373, zoom, 0);
1510 }
1511
1512 // Retrieve the zoom level.
1513 int wxStyledTextCtrl::GetZoom() {
1514 return SendMsg(2374, 0, 0);
1515 }
1516
1517 // Create a new document object.
1518 // Starts with reference count of 1 and not selected into editor.
1519 void* wxStyledTextCtrl::CreateDocument() {
1520 return (void*)SendMsg(2375);
1521 }
1522
1523 // Extend life of document.
1524 void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
1525 SendMsg(2376, (long)docPointer);
1526 }
1527
1528 // Release a reference to the document, deleting document if it fades to black.
1529 void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
1530 SendMsg(2377, (long)docPointer);
1531 }
1532
1533 // Get which document modification events are sent to the container.
1534 int wxStyledTextCtrl::GetModEventMask() {
1535 return SendMsg(2378, 0, 0);
1536 }
1537
1538 // Change internal focus flag
1539 void wxStyledTextCtrl::SetSTCFocus(bool focus) {
1540 SendMsg(2380, focus, 0);
1541 }
1542
1543 // Get internal focus flag
1544 bool wxStyledTextCtrl::GetSTCFocus() {
1545 return SendMsg(2381, 0, 0) != 0;
1546 }
1547
1548 // Change error status - 0 = OK
1549 void wxStyledTextCtrl::SetStatus(int statusCode) {
1550 SendMsg(2382, statusCode, 0);
1551 }
1552
1553 // Get error status
1554 int wxStyledTextCtrl::GetStatus() {
1555 return SendMsg(2383, 0, 0);
1556 }
1557
1558 // Set whether the mouse is captured when its button is pressed
1559 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
1560 SendMsg(2384, captures, 0);
1561 }
1562
1563 // Get whether mouse gets captured
1564 bool wxStyledTextCtrl::GetMouseDownCaptures() {
1565 return SendMsg(2385, 0, 0) != 0;
1566 }
1567
1568 // Sets the cursor to one of the SC_CURSOR* values
1569 void wxStyledTextCtrl::SetCursor(int cursorType) {
1570 SendMsg(2386, cursorType, 0);
1571 }
1572
1573 // Get cursor type
1574 int wxStyledTextCtrl::GetCursor() {
1575 return SendMsg(2387, 0, 0);
1576 }
1577
1578 // Move to the previous change in capitalistion
1579 void wxStyledTextCtrl::WordPartLeft() {
1580 SendMsg(2390, 0, 0);
1581 }
1582
1583 // Move to the previous change in capitalistion extending selection to new caret position.
1584 void wxStyledTextCtrl::WordPartLeftExtend() {
1585 SendMsg(2391, 0, 0);
1586 }
1587
1588 // Move to the change next in capitalistion
1589 void wxStyledTextCtrl::WordPartRight() {
1590 SendMsg(2392, 0, 0);
1591 }
1592
1593 // Move to the next change in capitalistion extending selection to new caret position.
1594 void wxStyledTextCtrl::WordPartRightExtend() {
1595 SendMsg(2393, 0, 0);
1596 }
1597
1598 // Set the way the display area is determined when a particular line is to be moved to.
1599 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
1600 SendMsg(2394, visiblePolicy, visibleSlop);
1601 }
1602
1603 // Delete back from the current position to the start of the line
1604 void wxStyledTextCtrl::DelLineLeft() {
1605 SendMsg(2395, 0, 0);
1606 }
1607
1608 // Delete forwards from the current position to the end of the line
1609 void wxStyledTextCtrl::DelLineRight() {
1610 SendMsg(2396, 0, 0);
1611 }
1612
1613 // Start notifying the container of all key presses and commands.
1614 void wxStyledTextCtrl::StartRecord() {
1615 SendMsg(3001, 0, 0);
1616 }
1617
1618 // Stop notifying the container of all key presses and commands.
1619 void wxStyledTextCtrl::StopRecord() {
1620 SendMsg(3002, 0, 0);
1621 }
1622
1623 // Set the lexing language of the document.
1624 void wxStyledTextCtrl::SetLexer(int lexer) {
1625 SendMsg(4001, lexer, 0);
1626 }
1627
1628 // Retrieve the lexing language of the document.
1629 int wxStyledTextCtrl::GetLexer() {
1630 return SendMsg(4002, 0, 0);
1631 }
1632
1633 // Colourise a segment of the document using the current lexing language.
1634 void wxStyledTextCtrl::Colourise(int start, int end) {
1635 SendMsg(4003, start, end);
1636 }
1637
1638 // Set up a value that may be used by a lexer for some optional feature.
1639 void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
1640 SendMsg(4004, (long)key.c_str(), (long)value.c_str());
1641 }
1642
1643 // Set up the key words used by the lexer.
1644 void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
1645 SendMsg(4005, keywordSet, (long)keyWords.c_str());
1646 }
1647
1648 // Set the lexing language of the document based on string name.
1649 void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
1650 SendMsg(4006, 0, (long)language.c_str());
1651 }
1652
1653 // END of generated section
1654 //----------------------------------------------------------------------
1655
1656
1657 // Returns the line number of the line with the caret.
1658 int wxStyledTextCtrl::GetCurrentLine() {
1659 int line = LineFromPosition(GetCurrentPos());
1660 return line;
1661 }
1662
1663
1664 // Extract style settings from a spec-string which is composed of one or
1665 // more of the following comma separated elements:
1666 //
1667 // bold turns on bold
1668 // italic turns on italics
1669 // fore:#RRGGBB sets the foreground colour
1670 // back:#RRGGBB sets the background colour
1671 // face:[facename] sets the font face name to use
1672 // size:[num] sets the font size in points
1673 // eol turns on eol filling
1674 // underline turns on underlining
1675 //
1676 void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
1677
1678 wxStringTokenizer tkz(spec, ",");
1679 while (tkz.HasMoreTokens()) {
1680 wxString token = tkz.GetNextToken();
1681
1682 wxString option = token.BeforeFirst(':');
1683 wxString val = token.AfterFirst(':');
1684
1685 if (option == "bold")
1686 StyleSetBold(styleNum, true);
1687
1688 else if (option == "italic")
1689 StyleSetItalic(styleNum, true);
1690
1691 else if (option == "underline")
1692 StyleSetUnderline(styleNum, true);
1693
1694 else if (option == "eol")
1695 StyleSetEOLFilled(styleNum, true);
1696
1697 else if (option == "size") {
1698 long points;
1699 if (val.ToLong(&points))
1700 StyleSetSize(styleNum, points);
1701 }
1702
1703 else if (option == "face")
1704 StyleSetFaceName(styleNum, val);
1705
1706 else if (option == "fore")
1707 StyleSetForeground(styleNum, wxColourFromSpec(val));
1708
1709 else if (option == "back")
1710 StyleSetBackground(styleNum, wxColourFromSpec(val));
1711 }
1712 }
1713
1714
1715 // Set style size, face, bold, italic, and underline attributes from
1716 // a wxFont's attributes.
1717 void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
1718 int size = font.GetPointSize();
1719 wxString faceName = font.GetFaceName();
1720 bool bold = font.GetWeight() == wxBOLD;
1721 bool italic = font.GetStyle() != wxNORMAL;
1722 bool under = font.GetUnderlined();
1723
1724 // TODO: add encoding/charset mapping
1725 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
1726 }
1727
1728 // Set all font style attributes at once.
1729 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
1730 const wxString& faceName,
1731 bool bold, bool italic,
1732 bool underline) {
1733 StyleSetSize(styleNum, size);
1734 StyleSetFaceName(styleNum, faceName);
1735 StyleSetBold(styleNum, bold);
1736 StyleSetItalic(styleNum, italic);
1737 StyleSetUnderline(styleNum, underline);
1738
1739 // TODO: add encoding/charset mapping
1740 }
1741
1742
1743 // Perform one of the operations defined by the wxSTC_CMD_* constants.
1744 void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
1745 SendMsg(cmd);
1746 }
1747
1748
1749 // Set the left and right margin in the edit area, measured in pixels.
1750 void wxStyledTextCtrl::SetMargins(int left, int right) {
1751 SetMarginLeft(left);
1752 SetMarginRight(right);
1753 }
1754
1755
1756 // Retrieve the start and end positions of the current selection.
1757 void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
1758 if (startPos != NULL)
1759 *startPos = SendMsg(SCI_GETSELECTIONSTART);
1760 if (endPos != NULL)
1761 *endPos = SendMsg(SCI_GETSELECTIONEND);
1762 }
1763
1764
1765 // Retrieve the point in the window where a position is displayed.
1766 wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
1767 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
1768 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
1769 return wxPoint(x, y);
1770 }
1771
1772 // Scroll enough to make the given line visible
1773 void wxStyledTextCtrl::ScrollToLine(int line) {
1774 m_swx->DoScrollToLine(line);
1775 }
1776
1777
1778 // Scroll enough to make the given column visible
1779 void wxStyledTextCtrl::ScrollToColumn(int column) {
1780 m_swx->DoScrollToColumn(column);
1781 }
1782
1783
1784
1785 //----------------------------------------------------------------------
1786 // Event handlers
1787
1788 void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
1789 wxPaintDC dc(this);
1790 wxRegion region = GetUpdateRegion();
1791
1792 m_swx->DoPaint(&dc, region.GetBox());
1793 }
1794
1795 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
1796 if (evt.GetOrientation() == wxHORIZONTAL)
1797 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
1798 else
1799 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
1800 }
1801
1802 void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
1803 wxSize sz = GetClientSize();
1804 m_swx->DoSize(sz.x, sz.y);
1805 }
1806
1807 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
1808 wxPoint pt = evt.GetPosition();
1809 m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
1810 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
1811 }
1812
1813 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
1814 wxPoint pt = evt.GetPosition();
1815 m_swx->DoButtonMove(Point(pt.x, pt.y));
1816 }
1817
1818 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
1819 wxPoint pt = evt.GetPosition();
1820 m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
1821 evt.ControlDown());
1822 }
1823
1824
1825 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
1826 wxPoint pt = evt.GetPosition();
1827 ScreenToClient(&pt.x, &pt.y);
1828 m_swx->DoContextMenu(Point(pt.x, pt.y));
1829 }
1830
1831
1832 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
1833 m_swx->DoMouseWheel(evt.GetWheelRotation(),
1834 evt.GetWheelDelta(),
1835 evt.GetLinesPerAction(),
1836 evt.ControlDown());
1837 }
1838
1839
1840 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
1841 long key = evt.KeyCode();
1842
1843 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d\n",
1844 // key, m_lastKeyDownConsumed, evt.ControlDown(), evt.AltDown());
1845
1846 // AltGr keys???
1847 // \|@#¬[]{}?£$~ ã,õ,Ã,Õ, ñ, Ñ
1848
1849 // On (some?) non-US keyboards the AltGr key is required to enter some
1850 // common characters. It comes to us as both Alt and Ctrl down so we need
1851 // to let the char through in that case, otherwise if only ctrl or only
1852 // alt let's skip it.
1853 bool ctrl = evt.ControlDown();
1854 bool alt = evt.AltDown();
1855 bool skip = (ctrl || alt && ! (ctrl && alt));
1856
1857 if (key <= 0xff && !iscntrl(key) && !m_lastKeyDownConsumed && !skip) {
1858 m_swx->DoAddChar(key);
1859 return;
1860 }
1861 evt.Skip();
1862 }
1863
1864
1865 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
1866 long key = evt.KeyCode();
1867 bool shift = evt.ShiftDown(),
1868 ctrl = evt.ControlDown(),
1869 alt = evt.AltDown();
1870
1871 int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
1872
1873 // printf("key: %d shift: %d ctrl: %d alt: %d processed: %d consumed: %d\n",
1874 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
1875
1876 if (!processed && !m_lastKeyDownConsumed)
1877 evt.Skip();
1878 }
1879
1880
1881 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
1882 m_swx->DoLoseFocus();
1883 }
1884
1885
1886 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
1887 m_swx->DoGainFocus();
1888 }
1889
1890
1891 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
1892 m_swx->DoSysColourChange();
1893 }
1894
1895
1896 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
1897 // do nothing to help avoid flashing
1898 }
1899
1900
1901
1902 void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
1903 m_swx->DoCommand(evt.GetId());
1904 }
1905
1906
1907 void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
1908 m_swx->DoOnListBox();
1909 }
1910
1911
1912 //----------------------------------------------------------------------
1913 // Turn notifications from Scintilla into events
1914
1915
1916 void wxStyledTextCtrl::NotifyChange() {
1917 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
1918 evt.SetEventObject(this);
1919 GetEventHandler()->ProcessEvent(evt);
1920 }
1921
1922 void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
1923 SCNotification& scn = *_scn;
1924 wxStyledTextEvent evt(0, GetId());
1925
1926 evt.SetEventObject(this);
1927 evt.SetPosition(scn.position);
1928 evt.SetKey(scn.ch);
1929 evt.SetModifiers(scn.modifiers);
1930
1931 switch (scn.nmhdr.code) {
1932 case SCN_STYLENEEDED:
1933 evt.SetEventType(wxEVT_STC_STYLENEEDED);
1934 break;
1935
1936 case SCN_CHARADDED:
1937 evt.SetEventType(wxEVT_STC_CHARADDED);
1938 break;
1939
1940 case SCN_SAVEPOINTREACHED:
1941 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
1942 break;
1943
1944 case SCN_SAVEPOINTLEFT:
1945 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
1946 break;
1947
1948 case SCN_MODIFYATTEMPTRO:
1949 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
1950 break;
1951
1952 case SCN_KEY:
1953 evt.SetEventType(wxEVT_STC_KEY);
1954 break;
1955
1956 case SCN_DOUBLECLICK:
1957 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
1958 break;
1959
1960 case SCN_UPDATEUI:
1961 evt.SetEventType(wxEVT_STC_UPDATEUI);
1962 break;
1963
1964 case SCN_MODIFIED:
1965 evt.SetEventType(wxEVT_STC_MODIFIED);
1966 evt.SetModificationType(scn.modificationType);
1967 if (scn.text)
1968 evt.SetText(wxString(scn.text, scn.length));
1969 evt.SetLength(scn.length);
1970 evt.SetLinesAdded(scn.linesAdded);
1971 evt.SetLine(scn.line);
1972 evt.SetFoldLevelNow(scn.foldLevelNow);
1973 evt.SetFoldLevelPrev(scn.foldLevelPrev);
1974 break;
1975
1976 case SCN_MACRORECORD:
1977 evt.SetEventType(wxEVT_STC_MACRORECORD);
1978 evt.SetMessage(scn.message);
1979 evt.SetWParam(scn.wParam);
1980 evt.SetLParam(scn.lParam);
1981 break;
1982
1983 case SCN_MARGINCLICK:
1984 evt.SetEventType(wxEVT_STC_MARGINCLICK);
1985 evt.SetMargin(scn.margin);
1986 break;
1987
1988 case SCN_NEEDSHOWN:
1989 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
1990 evt.SetLength(scn.length);
1991 break;
1992
1993 case SCN_POSCHANGED:
1994 evt.SetEventType(wxEVT_STC_POSCHANGED);
1995 break;
1996
1997 case SCN_PAINTED:
1998 evt.SetEventType(wxEVT_STC_PAINTED);
1999 break;
2000
2001 case SCN_USERLISTSELECTION:
2002 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
2003 evt.SetListType(scn.listType);
2004 evt.SetText(scn.text);
2005 break;
2006
2007 case SCN_URIDROPPED:
2008 evt.SetEventType(wxEVT_STC_URIDROPPED);
2009 evt.SetText(scn.text);
2010 break;
2011
2012 case SCN_DWELLSTART:
2013 evt.SetEventType(wxEVT_STC_DWELLSTART);
2014 evt.SetX(scn.x);
2015 evt.SetY(scn.y);
2016 break;
2017
2018 case SCN_DWELLEND:
2019 evt.SetEventType(wxEVT_STC_DWELLEND);
2020 evt.SetX(scn.x);
2021 evt.SetY(scn.y);
2022 break;
2023
2024 default:
2025 return;
2026 }
2027
2028 GetEventHandler()->ProcessEvent(evt);
2029 }
2030
2031
2032 //----------------------------------------------------------------------
2033 //----------------------------------------------------------------------
2034 //----------------------------------------------------------------------
2035
2036 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
2037 : wxCommandEvent(commandType, id)
2038 {
2039 m_position = 0;
2040 m_key = 0;
2041 m_modifiers = 0;
2042 m_modificationType = 0;
2043 m_length = 0;
2044 m_linesAdded = 0;
2045 m_line = 0;
2046 m_foldLevelNow = 0;
2047 m_foldLevelPrev = 0;
2048 m_margin = 0;
2049 m_message = 0;
2050 m_wParam = 0;
2051 m_lParam = 0;
2052 m_listType = 0;
2053 m_x = 0;
2054 m_y = 0;
2055 m_dragAllowMove = FALSE;
2056 m_dragResult = wxDragNone;
2057 }
2058
2059 bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
2060 bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
2061 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
2062
2063 void wxStyledTextEvent::CopyObject(wxObject& obj) const {
2064 wxCommandEvent::CopyObject(obj);
2065
2066 wxStyledTextEvent* o = (wxStyledTextEvent*)&obj;
2067 o->m_position = m_position;
2068 o->m_key = m_key;
2069 o->m_modifiers = m_modifiers;
2070 o->m_modificationType = m_modificationType;
2071 o->m_text = m_text;
2072 o->m_length = m_length;
2073 o->m_linesAdded = m_linesAdded;
2074 o->m_line = m_line;
2075 o->m_foldLevelNow = m_foldLevelNow;
2076 o->m_foldLevelPrev = m_foldLevelPrev;
2077
2078 o->m_margin = m_margin;
2079
2080 o->m_message = m_message;
2081 o->m_wParam = m_wParam;
2082 o->m_lParam = m_lParam;
2083
2084 o->m_listType = m_listType;
2085 o->m_x = m_x;
2086 o->m_y = m_y;
2087
2088 o->m_dragText = m_dragText;
2089 o->m_dragAllowMove =m_dragAllowMove;
2090 o->m_dragResult = m_dragResult;
2091 }
2092
2093 //----------------------------------------------------------------------
2094 //----------------------------------------------------------------------
2095
2096
2097
2098