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