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