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