pass 0, not NULL, to SendMsg() which takes long to avoid gcc warnings
[wxWidgets.git] / src / stc / stc.cpp
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: stc.cpp
3 // Purpose: A wxWidgets 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 // For compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
20
21 #ifdef __BORLANDC__
22 #pragma hdrstop
23 #endif
24
25
26 #ifndef WX_PRECOMP
27 #endif // WX_PRECOMP
28
29 #include <ctype.h>
30
31 #include "wx/wx.h"
32 #include "wx/tokenzr.h"
33 #include "wx/mstream.h"
34 #include "wx/image.h"
35 #include "wx/file.h"
36
37 #include "wx/stc/stc.h"
38 #include "ScintillaWX.h"
39
40 //----------------------------------------------------------------------
41
42 const wxChar* wxSTCNameStr = wxT("stcwindow");
43
44 #ifdef MAKELONG
45 #undef MAKELONG
46 #endif
47
48 #define MAKELONG(a, b) ((a) | ((b) << 16))
49
50
51 static long wxColourAsLong(const wxColour& co) {
52 return (((long)co.Blue() << 16) |
53 ((long)co.Green() << 8) |
54 ((long)co.Red()));
55 }
56
57 static wxColour wxColourFromLong(long c) {
58 wxColour clr;
59 clr.Set((unsigned char)(c & 0xff),
60 (unsigned char)((c >> 8) & 0xff),
61 (unsigned char)((c >> 16) & 0xff));
62 return clr;
63 }
64
65
66 static wxColour wxColourFromSpec(const wxString& spec) {
67 // spec should be a colour name or "#RRGGBB"
68 if (spec.GetChar(0) == wxT('#')) {
69
70 long red, green, blue;
71 red = green = blue = 0;
72 spec.Mid(1,2).ToLong(&red, 16);
73 spec.Mid(3,2).ToLong(&green, 16);
74 spec.Mid(5,2).ToLong(&blue, 16);
75 return wxColour((unsigned char)red,
76 (unsigned char)green,
77 (unsigned char)blue);
78 }
79 else
80 return wxColour(spec);
81 }
82
83 //----------------------------------------------------------------------
84
85 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
86 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
87 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
88 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
89 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
90 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
91 DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
92 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
93 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
94 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
95 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
96 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
97 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
98 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
99 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
100 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
101 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
102 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
103 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
104 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
105 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
106 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM )
107 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
108 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
109 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
110 DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION )
111
112
113
114 BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
115 EVT_PAINT (wxStyledTextCtrl::OnPaint)
116 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
117 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
118 EVT_SIZE (wxStyledTextCtrl::OnSize)
119 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
120 // Let Scintilla see the double click as a second click
121 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
122 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
123 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
124 #if defined(__WXGTK__) || defined(__WXMAC__)
125 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
126 #else
127 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
128 #endif
129 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
130 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
131 EVT_CHAR (wxStyledTextCtrl::OnChar)
132 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
133 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
134 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
135 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
136 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
137 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
138 EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
139 END_EVENT_TABLE()
140
141
142 IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
143 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
144
145 #ifdef LINK_LEXERS
146 // forces the linking of the lexer modules
147 int Scintilla_LinkLexers();
148 #endif
149
150 //----------------------------------------------------------------------
151 // Constructor and Destructor
152
153 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
154 wxWindowID id,
155 const wxPoint& pos,
156 const wxSize& size,
157 long style,
158 const wxString& name)
159 {
160 m_swx = NULL;
161 Create(parent, id, pos, size, style, name);
162 }
163
164
165 bool wxStyledTextCtrl::Create(wxWindow *parent,
166 wxWindowID id,
167 const wxPoint& pos,
168 const wxSize& size,
169 long style,
170 const wxString& name)
171 {
172 style |= wxVSCROLL | wxHSCROLL;
173 if (!wxControl::Create(parent, id, pos, size,
174 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
175 wxDefaultValidator, name))
176 return false;
177
178 #ifdef LINK_LEXERS
179 Scintilla_LinkLexers();
180 #endif
181 m_swx = new ScintillaWX(this);
182 m_stopWatch.Start();
183 m_lastKeyDownConsumed = false;
184 m_vScrollBar = NULL;
185 m_hScrollBar = NULL;
186 #if wxUSE_UNICODE
187 // Put Scintilla into unicode (UTF-8) mode
188 SetCodePage(wxSTC_CP_UTF8);
189 #endif
190
191 SetInitialSize(size);
192
193 // Reduces flicker on GTK+/X11
194 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
195 return true;
196 }
197
198
199 wxStyledTextCtrl::~wxStyledTextCtrl() {
200 delete m_swx;
201 }
202
203
204 //----------------------------------------------------------------------
205
206 long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
207
208 return m_swx->WndProc(msg, wp, lp);
209 }
210
211 //----------------------------------------------------------------------
212
213 // Set the vertical scrollbar to use instead of the ont that's built-in.
214 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
215 m_vScrollBar = bar;
216 if (bar != NULL) {
217 // ensure that the built-in scrollbar is not visible
218 SetScrollbar(wxVERTICAL, 0, 0, 0);
219 }
220 }
221
222
223 // Set the horizontal scrollbar to use instead of the ont that's built-in.
224 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
225 m_hScrollBar = bar;
226 if (bar != NULL) {
227 // ensure that the built-in scrollbar is not visible
228 SetScrollbar(wxHORIZONTAL, 0, 0, 0);
229 }
230 }
231
232 //----------------------------------------------------------------------
233 // BEGIN generated section. The following code is automatically generated
234 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
235 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
236
237
238 // Add text to the document at current position.
239 void wxStyledTextCtrl::AddText(const wxString& text) {
240 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
241 SendMsg(2001, strlen(buf), (long)(const char*)buf);
242 }
243
244 // Add array of cells to document.
245 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
246 SendMsg(2002, data.GetDataLen(), (long)data.GetData());
247 }
248
249 // Insert string at a position.
250 void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
251 SendMsg(2003, pos, (long)(const char*)wx2stc(text));
252 }
253
254 // Delete all text in the document.
255 void wxStyledTextCtrl::ClearAll() {
256 SendMsg(2004, 0, 0);
257 }
258
259 // Set all style bytes to 0, remove all folding information.
260 void wxStyledTextCtrl::ClearDocumentStyle() {
261 SendMsg(2005, 0, 0);
262 }
263
264 // Returns the number of characters in the document.
265 int wxStyledTextCtrl::GetLength() {
266 return SendMsg(2006, 0, 0);
267 }
268
269 // Returns the character byte at the position.
270 int wxStyledTextCtrl::GetCharAt(int pos) {
271 return (unsigned char)SendMsg(2007, pos, 0);
272 }
273
274 // Returns the position of the caret.
275 int wxStyledTextCtrl::GetCurrentPos() {
276 return SendMsg(2008, 0, 0);
277 }
278
279 // Returns the position of the opposite end of the selection to the caret.
280 int wxStyledTextCtrl::GetAnchor() {
281 return SendMsg(2009, 0, 0);
282 }
283
284 // Returns the style byte at the position.
285 int wxStyledTextCtrl::GetStyleAt(int pos) {
286 return (unsigned char)SendMsg(2010, pos, 0);
287 }
288
289 // Redoes the next action on the undo history.
290 void wxStyledTextCtrl::Redo() {
291 SendMsg(2011, 0, 0);
292 }
293
294 // Choose between collecting actions into the undo
295 // history and discarding them.
296 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
297 SendMsg(2012, collectUndo, 0);
298 }
299
300 // Select all the text in the document.
301 void wxStyledTextCtrl::SelectAll() {
302 SendMsg(2013, 0, 0);
303 }
304
305 // Remember the current position in the undo history as the position
306 // at which the document was saved.
307 void wxStyledTextCtrl::SetSavePoint() {
308 SendMsg(2014, 0, 0);
309 }
310
311 // Retrieve a buffer of cells.
312 wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
313 wxMemoryBuffer buf;
314 if (endPos < startPos) {
315 int temp = startPos;
316 startPos = endPos;
317 endPos = temp;
318 }
319 int len = endPos - startPos;
320 if (!len) return buf;
321 TextRange tr;
322 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
323 tr.chrg.cpMin = startPos;
324 tr.chrg.cpMax = endPos;
325 len = SendMsg(2015, 0, (long)&tr);
326 buf.UngetWriteBuf(len);
327 return buf;
328 }
329
330 // Are there any redoable actions in the undo history?
331 bool wxStyledTextCtrl::CanRedo() {
332 return SendMsg(2016, 0, 0) != 0;
333 }
334
335 // Retrieve the line number at which a particular marker is located.
336 int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
337 return SendMsg(2017, handle, 0);
338 }
339
340 // Delete a marker.
341 void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
342 SendMsg(2018, handle, 0);
343 }
344
345 // Is undo history being collected?
346 bool wxStyledTextCtrl::GetUndoCollection() {
347 return SendMsg(2019, 0, 0) != 0;
348 }
349
350 // Are white space characters currently visible?
351 // Returns one of SCWS_* constants.
352 int wxStyledTextCtrl::GetViewWhiteSpace() {
353 return SendMsg(2020, 0, 0);
354 }
355
356 // Make white space characters invisible, always visible or visible outside indentation.
357 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
358 SendMsg(2021, viewWS, 0);
359 }
360
361 // Find the position from a point within the window.
362 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
363 return SendMsg(2022, pt.x, pt.y);
364 }
365
366 // Find the position from a point within the window but return
367 // INVALID_POSITION if not close to text.
368 int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
369 return SendMsg(2023, x, y);
370 }
371
372 // Set caret to start of a line and ensure it is visible.
373 void wxStyledTextCtrl::GotoLine(int line) {
374 SendMsg(2024, line, 0);
375 }
376
377 // Set caret to a position and ensure it is visible.
378 void wxStyledTextCtrl::GotoPos(int pos) {
379 SendMsg(2025, pos, 0);
380 }
381
382 // Set the selection anchor to a position. The anchor is the opposite
383 // end of the selection from the caret.
384 void wxStyledTextCtrl::SetAnchor(int posAnchor) {
385 SendMsg(2026, posAnchor, 0);
386 }
387
388 // Retrieve the text of the line containing the caret.
389 // Returns the index of the caret on the line.
390 wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
391 int len = LineLength(GetCurrentLine());
392 if (!len) {
393 if (linePos) *linePos = 0;
394 return wxEmptyString;
395 }
396
397 wxMemoryBuffer mbuf(len+1);
398 char* buf = (char*)mbuf.GetWriteBuf(len+1);
399
400 int pos = SendMsg(2027, len+1, (long)buf);
401 mbuf.UngetWriteBuf(len);
402 mbuf.AppendByte(0);
403 if (linePos) *linePos = pos;
404 return stc2wx(buf);
405 }
406
407 // Retrieve the position of the last correctly styled character.
408 int wxStyledTextCtrl::GetEndStyled() {
409 return SendMsg(2028, 0, 0);
410 }
411
412 // Convert all line endings in the document to one mode.
413 void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
414 SendMsg(2029, eolMode, 0);
415 }
416
417 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
418 int wxStyledTextCtrl::GetEOLMode() {
419 return SendMsg(2030, 0, 0);
420 }
421
422 // Set the current end of line mode.
423 void wxStyledTextCtrl::SetEOLMode(int eolMode) {
424 SendMsg(2031, eolMode, 0);
425 }
426
427 // Set the current styling position to pos and the styling mask to mask.
428 // The styling mask can be used to protect some bits in each styling byte from modification.
429 void wxStyledTextCtrl::StartStyling(int pos, int mask) {
430 SendMsg(2032, pos, mask);
431 }
432
433 // Change style from current styling position for length characters to a style
434 // and move the current styling position to after this newly styled segment.
435 void wxStyledTextCtrl::SetStyling(int length, int style) {
436 SendMsg(2033, length, style);
437 }
438
439 // Is drawing done first into a buffer or direct to the screen?
440 bool wxStyledTextCtrl::GetBufferedDraw() {
441 return SendMsg(2034, 0, 0) != 0;
442 }
443
444 // If drawing is buffered then each line of text is drawn into a bitmap buffer
445 // before drawing it to the screen to avoid flicker.
446 void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
447 SendMsg(2035, buffered, 0);
448 }
449
450 // Change the visible size of a tab to be a multiple of the width of a space character.
451 void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
452 SendMsg(2036, tabWidth, 0);
453 }
454
455 // Retrieve the visible size of a tab.
456 int wxStyledTextCtrl::GetTabWidth() {
457 return SendMsg(2121, 0, 0);
458 }
459
460 // Set the code page used to interpret the bytes of the document as characters.
461 void wxStyledTextCtrl::SetCodePage(int codePage) {
462 #if wxUSE_UNICODE
463 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
464 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
465 #else
466 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
467 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
468 #endif
469 SendMsg(2037, codePage);
470 }
471
472 // Set the symbol used for a particular marker number,
473 // and optionally the fore and background colours.
474 void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
475 const wxColour& foreground,
476 const wxColour& background) {
477
478 SendMsg(2040, markerNumber, markerSymbol);
479 if (foreground.Ok())
480 MarkerSetForeground(markerNumber, foreground);
481 if (background.Ok())
482 MarkerSetBackground(markerNumber, background);
483 }
484
485 // Set the foreground colour used for a particular marker number.
486 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
487 SendMsg(2041, markerNumber, wxColourAsLong(fore));
488 }
489
490 // Set the background colour used for a particular marker number.
491 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
492 SendMsg(2042, markerNumber, wxColourAsLong(back));
493 }
494
495 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
496 int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
497 return SendMsg(2043, line, markerNumber);
498 }
499
500 // Delete a marker from a line.
501 void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
502 SendMsg(2044, line, markerNumber);
503 }
504
505 // Delete all markers with a particular number from all lines.
506 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
507 SendMsg(2045, markerNumber, 0);
508 }
509
510 // Get a bit mask of all the markers set on a line.
511 int wxStyledTextCtrl::MarkerGet(int line) {
512 return SendMsg(2046, line, 0);
513 }
514
515 // Find the next line after lineStart that includes a marker in mask.
516 int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
517 return SendMsg(2047, lineStart, markerMask);
518 }
519
520 // Find the previous line before lineStart that includes a marker in mask.
521 int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
522 return SendMsg(2048, lineStart, markerMask);
523 }
524
525 // Define a marker from a bitmap
526 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
527 // convert bmp to a xpm in a string
528 wxMemoryOutputStream strm;
529 wxImage img = bmp.ConvertToImage();
530 if (img.HasAlpha())
531 img.ConvertAlphaToMask();
532 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
533 size_t len = strm.GetSize();
534 char* buff = new char[len+1];
535 strm.CopyTo(buff, len);
536 buff[len] = 0;
537 SendMsg(2049, markerNumber, (long)buff);
538 delete [] buff;
539
540 }
541
542 // Add a set of markers to a line.
543 void wxStyledTextCtrl::MarkerAddSet(int line, int set) {
544 SendMsg(2466, line, set);
545 }
546
547 // Set the alpha used for a marker that is drawn in the text area, not the margin.
548 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha) {
549 SendMsg(2476, markerNumber, alpha);
550 }
551
552 // Set a margin to be either numeric or symbolic.
553 void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
554 SendMsg(2240, margin, marginType);
555 }
556
557 // Retrieve the type of a margin.
558 int wxStyledTextCtrl::GetMarginType(int margin) {
559 return SendMsg(2241, margin, 0);
560 }
561
562 // Set the width of a margin to a width expressed in pixels.
563 void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
564 SendMsg(2242, margin, pixelWidth);
565 }
566
567 // Retrieve the width of a margin in pixels.
568 int wxStyledTextCtrl::GetMarginWidth(int margin) {
569 return SendMsg(2243, margin, 0);
570 }
571
572 // Set a mask that determines which markers are displayed in a margin.
573 void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
574 SendMsg(2244, margin, mask);
575 }
576
577 // Retrieve the marker mask of a margin.
578 int wxStyledTextCtrl::GetMarginMask(int margin) {
579 return SendMsg(2245, margin, 0);
580 }
581
582 // Make a margin sensitive or insensitive to mouse clicks.
583 void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
584 SendMsg(2246, margin, sensitive);
585 }
586
587 // Retrieve the mouse click sensitivity of a margin.
588 bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
589 return SendMsg(2247, margin, 0) != 0;
590 }
591
592 // Clear all the styles and make equivalent to the global default style.
593 void wxStyledTextCtrl::StyleClearAll() {
594 SendMsg(2050, 0, 0);
595 }
596
597 // Set the foreground colour of a style.
598 void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
599 SendMsg(2051, style, wxColourAsLong(fore));
600 }
601
602 // Set the background colour of a style.
603 void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
604 SendMsg(2052, style, wxColourAsLong(back));
605 }
606
607 // Set a style to be bold or not.
608 void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
609 SendMsg(2053, style, bold);
610 }
611
612 // Set a style to be italic or not.
613 void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
614 SendMsg(2054, style, italic);
615 }
616
617 // Set the size of characters of a style.
618 void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
619 SendMsg(2055, style, sizePoints);
620 }
621
622 // Set the font of a style.
623 void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
624 SendMsg(2056, style, (long)(const char*)wx2stc(fontName));
625 }
626
627 // Set a style to have its end of line filled or not.
628 void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
629 SendMsg(2057, style, filled);
630 }
631
632 // Reset the default style to its state at startup
633 void wxStyledTextCtrl::StyleResetDefault() {
634 SendMsg(2058, 0, 0);
635 }
636
637 // Set a style to be underlined or not.
638 void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
639 SendMsg(2059, style, underline);
640 }
641
642 // Set a style to be mixed case, or to force upper or lower case.
643 void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
644 SendMsg(2060, style, caseForce);
645 }
646
647 // Set a style to be a hotspot or not.
648 void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) {
649 SendMsg(2409, style, hotspot);
650 }
651
652 // Set the foreground colour of the selection and whether to use this setting.
653 void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
654 SendMsg(2067, useSetting, wxColourAsLong(fore));
655 }
656
657 // Set the background colour of the selection and whether to use this setting.
658 void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
659 SendMsg(2068, useSetting, wxColourAsLong(back));
660 }
661
662 // Get the alpha of the selection.
663 int wxStyledTextCtrl::GetSelAlpha() {
664 return SendMsg(2477, 0, 0);
665 }
666
667 // Set the alpha of the selection.
668 void wxStyledTextCtrl::SetSelAlpha(int alpha) {
669 SendMsg(2478, alpha, 0);
670 }
671
672 // Set the foreground colour of the caret.
673 void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
674 SendMsg(2069, wxColourAsLong(fore), 0);
675 }
676
677 // When key+modifier combination km is pressed perform msg.
678 void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
679 SendMsg(2070, MAKELONG(key, modifiers), cmd);
680 }
681
682 // When key+modifier combination km is pressed do nothing.
683 void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
684 SendMsg(2071, MAKELONG(key, modifiers));
685 }
686
687 // Drop all key mappings.
688 void wxStyledTextCtrl::CmdKeyClearAll() {
689 SendMsg(2072, 0, 0);
690 }
691
692 // Set the styles for a segment of the document.
693 void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
694 SendMsg(2073, length, (long)styleBytes);
695 }
696
697 // Set a style to be visible or not.
698 void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
699 SendMsg(2074, style, visible);
700 }
701
702 // Get the time in milliseconds that the caret is on and off.
703 int wxStyledTextCtrl::GetCaretPeriod() {
704 return SendMsg(2075, 0, 0);
705 }
706
707 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
708 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
709 SendMsg(2076, periodMilliseconds, 0);
710 }
711
712 // Set the set of characters making up words for when moving or selecting by word.
713 // First sets deaults like SetCharsDefault.
714 void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
715 SendMsg(2077, 0, (long)(const char*)wx2stc(characters));
716 }
717
718 // Start a sequence of actions that is undone and redone as a unit.
719 // May be nested.
720 void wxStyledTextCtrl::BeginUndoAction() {
721 SendMsg(2078, 0, 0);
722 }
723
724 // End a sequence of actions that is undone and redone as a unit.
725 void wxStyledTextCtrl::EndUndoAction() {
726 SendMsg(2079, 0, 0);
727 }
728
729 // Set an indicator to plain, squiggle or TT.
730 void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
731 SendMsg(2080, indic, style);
732 }
733
734 // Retrieve the style of an indicator.
735 int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
736 return SendMsg(2081, indic, 0);
737 }
738
739 // Set the foreground colour of an indicator.
740 void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
741 SendMsg(2082, indic, wxColourAsLong(fore));
742 }
743
744 // Retrieve the foreground colour of an indicator.
745 wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
746 long c = SendMsg(2083, indic, 0);
747 return wxColourFromLong(c);
748 }
749
750 // Set the foreground colour of all whitespace and whether to use this setting.
751 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) {
752 SendMsg(2084, useSetting, wxColourAsLong(fore));
753 }
754
755 // Set the background colour of all whitespace and whether to use this setting.
756 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) {
757 SendMsg(2085, useSetting, wxColourAsLong(back));
758 }
759
760 // Divide each styling byte into lexical class bits (default: 5) and indicator
761 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
762 // is used to expand the possible states.
763 void wxStyledTextCtrl::SetStyleBits(int bits) {
764 SendMsg(2090, bits, 0);
765 }
766
767 // Retrieve number of bits in style bytes used to hold the lexical state.
768 int wxStyledTextCtrl::GetStyleBits() {
769 return SendMsg(2091, 0, 0);
770 }
771
772 // Used to hold extra styling information for each line.
773 void wxStyledTextCtrl::SetLineState(int line, int state) {
774 SendMsg(2092, line, state);
775 }
776
777 // Retrieve the extra styling information for a line.
778 int wxStyledTextCtrl::GetLineState(int line) {
779 return SendMsg(2093, line, 0);
780 }
781
782 // Retrieve the last line number that has line state.
783 int wxStyledTextCtrl::GetMaxLineState() {
784 return SendMsg(2094, 0, 0);
785 }
786
787 // Is the background of the line containing the caret in a different colour?
788 bool wxStyledTextCtrl::GetCaretLineVisible() {
789 return SendMsg(2095, 0, 0) != 0;
790 }
791
792 // Display the background of the line containing the caret in a different colour.
793 void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
794 SendMsg(2096, show, 0);
795 }
796
797 // Get the colour of the background of the line containing the caret.
798 wxColour wxStyledTextCtrl::GetCaretLineBackground() {
799 long c = SendMsg(2097, 0, 0);
800 return wxColourFromLong(c);
801 }
802
803 // Set the colour of the background of the line containing the caret.
804 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back) {
805 SendMsg(2098, wxColourAsLong(back), 0);
806 }
807
808 // Set a style to be changeable or not (read only).
809 // Experimental feature, currently buggy.
810 void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
811 SendMsg(2099, style, changeable);
812 }
813
814 // Display a auto-completion list.
815 // The lenEntered parameter indicates how many characters before
816 // the caret should be used to provide context.
817 void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
818 SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList));
819 }
820
821 // Remove the auto-completion list from the screen.
822 void wxStyledTextCtrl::AutoCompCancel() {
823 SendMsg(2101, 0, 0);
824 }
825
826 // Is there an auto-completion list visible?
827 bool wxStyledTextCtrl::AutoCompActive() {
828 return SendMsg(2102, 0, 0) != 0;
829 }
830
831 // Retrieve the position of the caret when the auto-completion list was displayed.
832 int wxStyledTextCtrl::AutoCompPosStart() {
833 return SendMsg(2103, 0, 0);
834 }
835
836 // User has selected an item so remove the list and insert the selection.
837 void wxStyledTextCtrl::AutoCompComplete() {
838 SendMsg(2104, 0, 0);
839 }
840
841 // Define a set of character that when typed cancel the auto-completion list.
842 void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
843 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet));
844 }
845
846 // Change the separator character in the string setting up an auto-completion list.
847 // Default is space but can be changed if items contain space.
848 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
849 SendMsg(2106, separatorCharacter, 0);
850 }
851
852 // Retrieve the auto-completion list separator character.
853 int wxStyledTextCtrl::AutoCompGetSeparator() {
854 return SendMsg(2107, 0, 0);
855 }
856
857 // Select the item in the auto-completion list that starts with a string.
858 void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
859 SendMsg(2108, 0, (long)(const char*)wx2stc(text));
860 }
861
862 // Should the auto-completion list be cancelled if the user backspaces to a
863 // position before where the box was created.
864 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
865 SendMsg(2110, cancel, 0);
866 }
867
868 // Retrieve whether auto-completion cancelled by backspacing before start.
869 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
870 return SendMsg(2111, 0, 0) != 0;
871 }
872
873 // Define a set of characters that when typed will cause the autocompletion to
874 // choose the selected item.
875 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
876 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet));
877 }
878
879 // Should a single item auto-completion list automatically choose the item.
880 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
881 SendMsg(2113, chooseSingle, 0);
882 }
883
884 // Retrieve whether a single item auto-completion list automatically choose the item.
885 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
886 return SendMsg(2114, 0, 0) != 0;
887 }
888
889 // Set whether case is significant when performing auto-completion searches.
890 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
891 SendMsg(2115, ignoreCase, 0);
892 }
893
894 // Retrieve state of ignore case flag.
895 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
896 return SendMsg(2116, 0, 0) != 0;
897 }
898
899 // Display a list of strings and send notification when user chooses one.
900 void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
901 SendMsg(2117, listType, (long)(const char*)wx2stc(itemList));
902 }
903
904 // Set whether or not autocompletion is hidden automatically when nothing matches.
905 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
906 SendMsg(2118, autoHide, 0);
907 }
908
909 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
910 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
911 return SendMsg(2119, 0, 0) != 0;
912 }
913
914 // Set whether or not autocompletion deletes any word characters
915 // after the inserted text upon completion.
916 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
917 SendMsg(2270, dropRestOfWord, 0);
918 }
919
920 // Retrieve whether or not autocompletion deletes any word characters
921 // after the inserted text upon completion.
922 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
923 return SendMsg(2271, 0, 0) != 0;
924 }
925
926 // Register an image for use in autocompletion lists.
927 void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
928 // convert bmp to a xpm in a string
929 wxMemoryOutputStream strm;
930 wxImage img = bmp.ConvertToImage();
931 if (img.HasAlpha())
932 img.ConvertAlphaToMask();
933 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
934 size_t len = strm.GetSize();
935 char* buff = new char[len+1];
936 strm.CopyTo(buff, len);
937 buff[len] = 0;
938 SendMsg(2405, type, (long)buff);
939 delete [] buff;
940
941 }
942
943 // Clear all the registered images.
944 void wxStyledTextCtrl::ClearRegisteredImages() {
945 SendMsg(2408, 0, 0);
946 }
947
948 // Retrieve the auto-completion list type-separator character.
949 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
950 return SendMsg(2285, 0, 0);
951 }
952
953 // Change the type-separator character in the string setting up an auto-completion list.
954 // Default is '?' but can be changed if items contain '?'.
955 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) {
956 SendMsg(2286, separatorCharacter, 0);
957 }
958
959 // Set the maximum width, in characters, of auto-completion and user lists.
960 // Set to 0 to autosize to fit longest item, which is the default.
961 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount) {
962 SendMsg(2208, characterCount, 0);
963 }
964
965 // Get the maximum width, in characters, of auto-completion and user lists.
966 int wxStyledTextCtrl::AutoCompGetMaxWidth() {
967 return SendMsg(2209, 0, 0);
968 }
969
970 // Set the maximum height, in rows, of auto-completion and user lists.
971 // The default is 5 rows.
972 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount) {
973 SendMsg(2210, rowCount, 0);
974 }
975
976 // Set the maximum height, in rows, of auto-completion and user lists.
977 int wxStyledTextCtrl::AutoCompGetMaxHeight() {
978 return SendMsg(2211, 0, 0);
979 }
980
981 // Set the number of spaces used for one level of indentation.
982 void wxStyledTextCtrl::SetIndent(int indentSize) {
983 SendMsg(2122, indentSize, 0);
984 }
985
986 // Retrieve indentation size.
987 int wxStyledTextCtrl::GetIndent() {
988 return SendMsg(2123, 0, 0);
989 }
990
991 // Indentation will only use space characters if useTabs is false, otherwise
992 // it will use a combination of tabs and spaces.
993 void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
994 SendMsg(2124, useTabs, 0);
995 }
996
997 // Retrieve whether tabs will be used in indentation.
998 bool wxStyledTextCtrl::GetUseTabs() {
999 return SendMsg(2125, 0, 0) != 0;
1000 }
1001
1002 // Change the indentation of a line to a number of columns.
1003 void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
1004 SendMsg(2126, line, indentSize);
1005 }
1006
1007 // Retrieve the number of columns that a line is indented.
1008 int wxStyledTextCtrl::GetLineIndentation(int line) {
1009 return SendMsg(2127, line, 0);
1010 }
1011
1012 // Retrieve the position before the first non indentation character on a line.
1013 int wxStyledTextCtrl::GetLineIndentPosition(int line) {
1014 return SendMsg(2128, line, 0);
1015 }
1016
1017 // Retrieve the column number of a position, taking tab width into account.
1018 int wxStyledTextCtrl::GetColumn(int pos) {
1019 return SendMsg(2129, pos, 0);
1020 }
1021
1022 // Show or hide the horizontal scroll bar.
1023 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
1024 SendMsg(2130, show, 0);
1025 }
1026
1027 // Is the horizontal scroll bar visible?
1028 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
1029 return SendMsg(2131, 0, 0) != 0;
1030 }
1031
1032 // Show or hide indentation guides.
1033 void wxStyledTextCtrl::SetIndentationGuides(bool show) {
1034 SendMsg(2132, show, 0);
1035 }
1036
1037 // Are the indentation guides visible?
1038 bool wxStyledTextCtrl::GetIndentationGuides() {
1039 return SendMsg(2133, 0, 0) != 0;
1040 }
1041
1042 // Set the highlighted indentation guide column.
1043 // 0 = no highlighted guide.
1044 void wxStyledTextCtrl::SetHighlightGuide(int column) {
1045 SendMsg(2134, column, 0);
1046 }
1047
1048 // Get the highlighted indentation guide column.
1049 int wxStyledTextCtrl::GetHighlightGuide() {
1050 return SendMsg(2135, 0, 0);
1051 }
1052
1053 // Get the position after the last visible characters on a line.
1054 int wxStyledTextCtrl::GetLineEndPosition(int line) {
1055 return SendMsg(2136, line, 0);
1056 }
1057
1058 // Get the code page used to interpret the bytes of the document as characters.
1059 int wxStyledTextCtrl::GetCodePage() {
1060 return SendMsg(2137, 0, 0);
1061 }
1062
1063 // Get the foreground colour of the caret.
1064 wxColour wxStyledTextCtrl::GetCaretForeground() {
1065 long c = SendMsg(2138, 0, 0);
1066 return wxColourFromLong(c);
1067 }
1068
1069 // In read-only mode?
1070 bool wxStyledTextCtrl::GetReadOnly() {
1071 return SendMsg(2140, 0, 0) != 0;
1072 }
1073
1074 // Sets the position of the caret.
1075 void wxStyledTextCtrl::SetCurrentPos(int pos) {
1076 SendMsg(2141, pos, 0);
1077 }
1078
1079 // Sets the position that starts the selection - this becomes the anchor.
1080 void wxStyledTextCtrl::SetSelectionStart(int pos) {
1081 SendMsg(2142, pos, 0);
1082 }
1083
1084 // Returns the position at the start of the selection.
1085 int wxStyledTextCtrl::GetSelectionStart() {
1086 return SendMsg(2143, 0, 0);
1087 }
1088
1089 // Sets the position that ends the selection - this becomes the currentPosition.
1090 void wxStyledTextCtrl::SetSelectionEnd(int pos) {
1091 SendMsg(2144, pos, 0);
1092 }
1093
1094 // Returns the position at the end of the selection.
1095 int wxStyledTextCtrl::GetSelectionEnd() {
1096 return SendMsg(2145, 0, 0);
1097 }
1098
1099 // Sets the print magnification added to the point size of each style for printing.
1100 void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
1101 SendMsg(2146, magnification, 0);
1102 }
1103
1104 // Returns the print magnification.
1105 int wxStyledTextCtrl::GetPrintMagnification() {
1106 return SendMsg(2147, 0, 0);
1107 }
1108
1109 // Modify colours when printing for clearer printed text.
1110 void wxStyledTextCtrl::SetPrintColourMode(int mode) {
1111 SendMsg(2148, mode, 0);
1112 }
1113
1114 // Returns the print colour mode.
1115 int wxStyledTextCtrl::GetPrintColourMode() {
1116 return SendMsg(2149, 0, 0);
1117 }
1118
1119 // Find some text in the document.
1120 int wxStyledTextCtrl::FindText(int minPos, int maxPos,
1121 const wxString& text,
1122 int flags) {
1123 TextToFind ft;
1124 ft.chrg.cpMin = minPos;
1125 ft.chrg.cpMax = maxPos;
1126 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1127 ft.lpstrText = (char*)(const char*)buf;
1128
1129 return SendMsg(2150, flags, (long)&ft);
1130 }
1131
1132 // On Windows, will draw the document into a display context such as a printer.
1133 int wxStyledTextCtrl::FormatRange(bool doDraw,
1134 int startPos,
1135 int endPos,
1136 wxDC* draw,
1137 wxDC* target,
1138 wxRect renderRect,
1139 wxRect pageRect) {
1140 RangeToFormat fr;
1141
1142 if (endPos < startPos) {
1143 int temp = startPos;
1144 startPos = endPos;
1145 endPos = temp;
1146 }
1147 fr.hdc = draw;
1148 fr.hdcTarget = target;
1149 fr.rc.top = renderRect.GetTop();
1150 fr.rc.left = renderRect.GetLeft();
1151 fr.rc.right = renderRect.GetRight();
1152 fr.rc.bottom = renderRect.GetBottom();
1153 fr.rcPage.top = pageRect.GetTop();
1154 fr.rcPage.left = pageRect.GetLeft();
1155 fr.rcPage.right = pageRect.GetRight();
1156 fr.rcPage.bottom = pageRect.GetBottom();
1157 fr.chrg.cpMin = startPos;
1158 fr.chrg.cpMax = endPos;
1159
1160 return SendMsg(2151, doDraw, (long)&fr);
1161 }
1162
1163 // Retrieve the display line at the top of the display.
1164 int wxStyledTextCtrl::GetFirstVisibleLine() {
1165 return SendMsg(2152, 0, 0);
1166 }
1167
1168 // Retrieve the contents of a line.
1169 wxString wxStyledTextCtrl::GetLine(int line) {
1170 int len = LineLength(line);
1171 if (!len) return wxEmptyString;
1172
1173 wxMemoryBuffer mbuf(len+1);
1174 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1175 SendMsg(2153, line, (long)buf);
1176 mbuf.UngetWriteBuf(len);
1177 mbuf.AppendByte(0);
1178 return stc2wx(buf);
1179 }
1180
1181 // Returns the number of lines in the document. There is always at least one.
1182 int wxStyledTextCtrl::GetLineCount() {
1183 return SendMsg(2154, 0, 0);
1184 }
1185
1186 // Sets the size in pixels of the left margin.
1187 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
1188 SendMsg(2155, 0, pixelWidth);
1189 }
1190
1191 // Returns the size in pixels of the left margin.
1192 int wxStyledTextCtrl::GetMarginLeft() {
1193 return SendMsg(2156, 0, 0);
1194 }
1195
1196 // Sets the size in pixels of the right margin.
1197 void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
1198 SendMsg(2157, 0, pixelWidth);
1199 }
1200
1201 // Returns the size in pixels of the right margin.
1202 int wxStyledTextCtrl::GetMarginRight() {
1203 return SendMsg(2158, 0, 0);
1204 }
1205
1206 // Is the document different from when it was last saved?
1207 bool wxStyledTextCtrl::GetModify() {
1208 return SendMsg(2159, 0, 0) != 0;
1209 }
1210
1211 // Select a range of text.
1212 void wxStyledTextCtrl::SetSelection(int start, int end) {
1213 SendMsg(2160, start, end);
1214 }
1215
1216 // Retrieve the selected text.
1217 wxString wxStyledTextCtrl::GetSelectedText() {
1218 int start;
1219 int end;
1220
1221 GetSelection(&start, &end);
1222 int len = end - start;
1223 if (!len) return wxEmptyString;
1224
1225 wxMemoryBuffer mbuf(len+2);
1226 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1227 SendMsg(2161, 0, (long)buf);
1228 mbuf.UngetWriteBuf(len);
1229 mbuf.AppendByte(0);
1230 return stc2wx(buf);
1231 }
1232
1233 // Retrieve a range of text.
1234 wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1235 if (endPos < startPos) {
1236 int temp = startPos;
1237 startPos = endPos;
1238 endPos = temp;
1239 }
1240 int len = endPos - startPos;
1241 if (!len) return wxEmptyString;
1242 wxMemoryBuffer mbuf(len+1);
1243 char* buf = (char*)mbuf.GetWriteBuf(len);
1244 TextRange tr;
1245 tr.lpstrText = buf;
1246 tr.chrg.cpMin = startPos;
1247 tr.chrg.cpMax = endPos;
1248 SendMsg(2162, 0, (long)&tr);
1249 mbuf.UngetWriteBuf(len);
1250 mbuf.AppendByte(0);
1251 return stc2wx(buf);
1252 }
1253
1254 // Draw the selection in normal style or with selection highlighted.
1255 void wxStyledTextCtrl::HideSelection(bool normal) {
1256 SendMsg(2163, normal, 0);
1257 }
1258
1259 // Retrieve the line containing a position.
1260 int wxStyledTextCtrl::LineFromPosition(int pos) {
1261 return SendMsg(2166, pos, 0);
1262 }
1263
1264 // Retrieve the position at the start of a line.
1265 int wxStyledTextCtrl::PositionFromLine(int line) {
1266 return SendMsg(2167, line, 0);
1267 }
1268
1269 // Scroll horizontally and vertically.
1270 void wxStyledTextCtrl::LineScroll(int columns, int lines) {
1271 SendMsg(2168, columns, lines);
1272 }
1273
1274 // Ensure the caret is visible.
1275 void wxStyledTextCtrl::EnsureCaretVisible() {
1276 SendMsg(2169, 0, 0);
1277 }
1278
1279 // Replace the selected text with the argument text.
1280 void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
1281 SendMsg(2170, 0, (long)(const char*)wx2stc(text));
1282 }
1283
1284 // Set to read only or read write.
1285 void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1286 SendMsg(2171, readOnly, 0);
1287 }
1288
1289 // Will a paste succeed?
1290 bool wxStyledTextCtrl::CanPaste() {
1291 return SendMsg(2173, 0, 0) != 0;
1292 }
1293
1294 // Are there any undoable actions in the undo history?
1295 bool wxStyledTextCtrl::CanUndo() {
1296 return SendMsg(2174, 0, 0) != 0;
1297 }
1298
1299 // Delete the undo history.
1300 void wxStyledTextCtrl::EmptyUndoBuffer() {
1301 SendMsg(2175, 0, 0);
1302 }
1303
1304 // Undo one action in the undo history.
1305 void wxStyledTextCtrl::Undo() {
1306 SendMsg(2176, 0, 0);
1307 }
1308
1309 // Cut the selection to the clipboard.
1310 void wxStyledTextCtrl::Cut() {
1311 SendMsg(2177, 0, 0);
1312 }
1313
1314 // Copy the selection to the clipboard.
1315 void wxStyledTextCtrl::Copy() {
1316 SendMsg(2178, 0, 0);
1317 }
1318
1319 // Paste the contents of the clipboard into the document replacing the selection.
1320 void wxStyledTextCtrl::Paste() {
1321 SendMsg(2179, 0, 0);
1322 }
1323
1324 // Clear the selection.
1325 void wxStyledTextCtrl::Clear() {
1326 SendMsg(2180, 0, 0);
1327 }
1328
1329 // Replace the contents of the document with the argument text.
1330 void wxStyledTextCtrl::SetText(const wxString& text) {
1331 SendMsg(2181, 0, (long)(const char*)wx2stc(text));
1332 }
1333
1334 // Retrieve all the text in the document.
1335 wxString wxStyledTextCtrl::GetText() {
1336 int len = GetTextLength();
1337 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1338 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1339 SendMsg(2182, len+1, (long)buf);
1340 mbuf.UngetWriteBuf(len);
1341 mbuf.AppendByte(0);
1342 return stc2wx(buf);
1343 }
1344
1345 // Retrieve the number of characters in the document.
1346 int wxStyledTextCtrl::GetTextLength() {
1347 return SendMsg(2183, 0, 0);
1348 }
1349
1350 // Set to overtype (true) or insert mode.
1351 void wxStyledTextCtrl::SetOvertype(bool overtype) {
1352 SendMsg(2186, overtype, 0);
1353 }
1354
1355 // Returns true if overtype mode is active otherwise false is returned.
1356 bool wxStyledTextCtrl::GetOvertype() {
1357 return SendMsg(2187, 0, 0) != 0;
1358 }
1359
1360 // Set the width of the insert mode caret.
1361 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
1362 SendMsg(2188, pixelWidth, 0);
1363 }
1364
1365 // Returns the width of the insert mode caret.
1366 int wxStyledTextCtrl::GetCaretWidth() {
1367 return SendMsg(2189, 0, 0);
1368 }
1369
1370 // Sets the position that starts the target which is used for updating the
1371 // document without affecting the scroll position.
1372 void wxStyledTextCtrl::SetTargetStart(int pos) {
1373 SendMsg(2190, pos, 0);
1374 }
1375
1376 // Get the position that starts the target.
1377 int wxStyledTextCtrl::GetTargetStart() {
1378 return SendMsg(2191, 0, 0);
1379 }
1380
1381 // Sets the position that ends the target which is used for updating the
1382 // document without affecting the scroll position.
1383 void wxStyledTextCtrl::SetTargetEnd(int pos) {
1384 SendMsg(2192, pos, 0);
1385 }
1386
1387 // Get the position that ends the target.
1388 int wxStyledTextCtrl::GetTargetEnd() {
1389 return SendMsg(2193, 0, 0);
1390 }
1391
1392 // Replace the target text with the argument text.
1393 // Text is counted so it can contain NULs.
1394 // Returns the length of the replacement text.
1395
1396 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1397 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1398 return SendMsg(2194, strlen(buf), (long)(const char*)buf);
1399 }
1400
1401 // Replace the target text with the argument text after \d processing.
1402 // Text is counted so it can contain NULs.
1403 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1404 // matched in the last search operation which were surrounded by \( and \).
1405 // Returns the length of the replacement text including any change
1406 // caused by processing the \d patterns.
1407
1408 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1409 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1410 return SendMsg(2195, strlen(buf), (long)(const char*)buf);
1411 }
1412
1413 // Search for a counted string in the target and set the target to the found
1414 // range. Text is counted so it can contain NULs.
1415 // Returns length of range or -1 for failure in which case target is not moved.
1416
1417 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1418 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1419 return SendMsg(2197, strlen(buf), (long)(const char*)buf);
1420 }
1421
1422 // Set the search flags used by SearchInTarget.
1423 void wxStyledTextCtrl::SetSearchFlags(int flags) {
1424 SendMsg(2198, flags, 0);
1425 }
1426
1427 // Get the search flags used by SearchInTarget.
1428 int wxStyledTextCtrl::GetSearchFlags() {
1429 return SendMsg(2199, 0, 0);
1430 }
1431
1432 // Show a call tip containing a definition near position pos.
1433 void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
1434 SendMsg(2200, pos, (long)(const char*)wx2stc(definition));
1435 }
1436
1437 // Remove the call tip from the screen.
1438 void wxStyledTextCtrl::CallTipCancel() {
1439 SendMsg(2201, 0, 0);
1440 }
1441
1442 // Is there an active call tip?
1443 bool wxStyledTextCtrl::CallTipActive() {
1444 return SendMsg(2202, 0, 0) != 0;
1445 }
1446
1447 // Retrieve the position where the caret was before displaying the call tip.
1448 int wxStyledTextCtrl::CallTipPosAtStart() {
1449 return SendMsg(2203, 0, 0);
1450 }
1451
1452 // Highlight a segment of the definition.
1453 void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
1454 SendMsg(2204, start, end);
1455 }
1456
1457 // Set the background colour for the call tip.
1458 void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1459 SendMsg(2205, wxColourAsLong(back), 0);
1460 }
1461
1462 // Set the foreground colour for the call tip.
1463 void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore) {
1464 SendMsg(2206, wxColourAsLong(fore), 0);
1465 }
1466
1467 // Set the foreground colour for the highlighted part of the call tip.
1468 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) {
1469 SendMsg(2207, wxColourAsLong(fore), 0);
1470 }
1471
1472 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1473 void wxStyledTextCtrl::CallTipUseStyle(int tabSize) {
1474 SendMsg(2212, tabSize, 0);
1475 }
1476
1477 // Find the display line of a document line taking hidden lines into account.
1478 int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1479 return SendMsg(2220, line, 0);
1480 }
1481
1482 // Find the document line of a display line taking hidden lines into account.
1483 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1484 return SendMsg(2221, lineDisplay, 0);
1485 }
1486
1487 // The number of display lines needed to wrap a document line
1488 int wxStyledTextCtrl::WrapCount(int line) {
1489 return SendMsg(2235, line, 0);
1490 }
1491
1492 // Set the fold level of a line.
1493 // This encodes an integer level along with flags indicating whether the
1494 // line is a header and whether it is effectively white space.
1495 void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1496 SendMsg(2222, line, level);
1497 }
1498
1499 // Retrieve the fold level of a line.
1500 int wxStyledTextCtrl::GetFoldLevel(int line) {
1501 return SendMsg(2223, line, 0);
1502 }
1503
1504 // Find the last child line of a header line.
1505 int wxStyledTextCtrl::GetLastChild(int line, int level) {
1506 return SendMsg(2224, line, level);
1507 }
1508
1509 // Find the parent line of a child line.
1510 int wxStyledTextCtrl::GetFoldParent(int line) {
1511 return SendMsg(2225, line, 0);
1512 }
1513
1514 // Make a range of lines visible.
1515 void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1516 SendMsg(2226, lineStart, lineEnd);
1517 }
1518
1519 // Make a range of lines invisible.
1520 void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1521 SendMsg(2227, lineStart, lineEnd);
1522 }
1523
1524 // Is a line visible?
1525 bool wxStyledTextCtrl::GetLineVisible(int line) {
1526 return SendMsg(2228, line, 0) != 0;
1527 }
1528
1529 // Show the children of a header line.
1530 void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1531 SendMsg(2229, line, expanded);
1532 }
1533
1534 // Is a header line expanded?
1535 bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1536 return SendMsg(2230, line, 0) != 0;
1537 }
1538
1539 // Switch a header line between expanded and contracted.
1540 void wxStyledTextCtrl::ToggleFold(int line) {
1541 SendMsg(2231, line, 0);
1542 }
1543
1544 // Ensure a particular line is visible by expanding any header line hiding it.
1545 void wxStyledTextCtrl::EnsureVisible(int line) {
1546 SendMsg(2232, line, 0);
1547 }
1548
1549 // Set some style options for folding.
1550 void wxStyledTextCtrl::SetFoldFlags(int flags) {
1551 SendMsg(2233, flags, 0);
1552 }
1553
1554 // Ensure a particular line is visible by expanding any header line hiding it.
1555 // Use the currently set visibility policy to determine which range to display.
1556 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
1557 SendMsg(2234, line, 0);
1558 }
1559
1560 // Sets whether a tab pressed when caret is within indentation indents.
1561 void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
1562 SendMsg(2260, tabIndents, 0);
1563 }
1564
1565 // Does a tab pressed when caret is within indentation indent?
1566 bool wxStyledTextCtrl::GetTabIndents() {
1567 return SendMsg(2261, 0, 0) != 0;
1568 }
1569
1570 // Sets whether a backspace pressed when caret is within indentation unindents.
1571 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
1572 SendMsg(2262, bsUnIndents, 0);
1573 }
1574
1575 // Does a backspace pressed when caret is within indentation unindent?
1576 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1577 return SendMsg(2263, 0, 0) != 0;
1578 }
1579
1580 // Sets the time the mouse must sit still to generate a mouse dwell event.
1581 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
1582 SendMsg(2264, periodMilliseconds, 0);
1583 }
1584
1585 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1586 int wxStyledTextCtrl::GetMouseDwellTime() {
1587 return SendMsg(2265, 0, 0);
1588 }
1589
1590 // Get position of start of word.
1591 int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
1592 return SendMsg(2266, pos, onlyWordCharacters);
1593 }
1594
1595 // Get position of end of word.
1596 int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
1597 return SendMsg(2267, pos, onlyWordCharacters);
1598 }
1599
1600 // Sets whether text is word wrapped.
1601 void wxStyledTextCtrl::SetWrapMode(int mode) {
1602 SendMsg(2268, mode, 0);
1603 }
1604
1605 // Retrieve whether text is word wrapped.
1606 int wxStyledTextCtrl::GetWrapMode() {
1607 return SendMsg(2269, 0, 0);
1608 }
1609
1610 // Set the display mode of visual flags for wrapped lines.
1611 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags) {
1612 SendMsg(2460, wrapVisualFlags, 0);
1613 }
1614
1615 // Retrive the display mode of visual flags for wrapped lines.
1616 int wxStyledTextCtrl::GetWrapVisualFlags() {
1617 return SendMsg(2461, 0, 0);
1618 }
1619
1620 // Set the location of visual flags for wrapped lines.
1621 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation) {
1622 SendMsg(2462, wrapVisualFlagsLocation, 0);
1623 }
1624
1625 // Retrive the location of visual flags for wrapped lines.
1626 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1627 return SendMsg(2463, 0, 0);
1628 }
1629
1630 // Set the start indent for wrapped lines.
1631 void wxStyledTextCtrl::SetWrapStartIndent(int indent) {
1632 SendMsg(2464, indent, 0);
1633 }
1634
1635 // Retrive the start indent for wrapped lines.
1636 int wxStyledTextCtrl::GetWrapStartIndent() {
1637 return SendMsg(2465, 0, 0);
1638 }
1639
1640 // Sets the degree of caching of layout information.
1641 void wxStyledTextCtrl::SetLayoutCache(int mode) {
1642 SendMsg(2272, mode, 0);
1643 }
1644
1645 // Retrieve the degree of caching of layout information.
1646 int wxStyledTextCtrl::GetLayoutCache() {
1647 return SendMsg(2273, 0, 0);
1648 }
1649
1650 // Sets the document width assumed for scrolling.
1651 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth) {
1652 SendMsg(2274, pixelWidth, 0);
1653 }
1654
1655 // Retrieve the document width assumed for scrolling.
1656 int wxStyledTextCtrl::GetScrollWidth() {
1657 return SendMsg(2275, 0, 0);
1658 }
1659
1660 // Measure the pixel width of some text in a particular style.
1661 // NUL terminated text argument.
1662 // Does not handle tab or control characters.
1663 int wxStyledTextCtrl::TextWidth(int style, const wxString& text) {
1664 return SendMsg(2276, style, (long)(const char*)wx2stc(text));
1665 }
1666
1667 // Sets the scroll range so that maximum scroll position has
1668 // the last line at the bottom of the view (default).
1669 // Setting this to false allows scrolling one page below the last line.
1670 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine) {
1671 SendMsg(2277, endAtLastLine, 0);
1672 }
1673
1674 // Retrieve whether the maximum scroll position has the last
1675 // line at the bottom of the view.
1676 bool wxStyledTextCtrl::GetEndAtLastLine() {
1677 return SendMsg(2278, 0, 0) != 0;
1678 }
1679
1680 // Retrieve the height of a particular line of text in pixels.
1681 int wxStyledTextCtrl::TextHeight(int line) {
1682 return SendMsg(2279, line, 0);
1683 }
1684
1685 // Show or hide the vertical scroll bar.
1686 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show) {
1687 SendMsg(2280, show, 0);
1688 }
1689
1690 // Is the vertical scroll bar visible?
1691 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1692 return SendMsg(2281, 0, 0) != 0;
1693 }
1694
1695 // Append a string to the end of the document without changing the selection.
1696 void wxStyledTextCtrl::AppendText(const wxString& text) {
1697 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1698 SendMsg(2282, strlen(buf), (long)(const char*)buf);
1699 }
1700
1701 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1702 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1703 return SendMsg(2283, 0, 0) != 0;
1704 }
1705
1706 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1707 // and then the foreground. This avoids chopping off characters that overlap the next run.
1708 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) {
1709 SendMsg(2284, twoPhase, 0);
1710 }
1711
1712 // Make the target range start and end be the same as the selection range start and end.
1713 void wxStyledTextCtrl::TargetFromSelection() {
1714 SendMsg(2287, 0, 0);
1715 }
1716
1717 // Join the lines in the target.
1718 void wxStyledTextCtrl::LinesJoin() {
1719 SendMsg(2288, 0, 0);
1720 }
1721
1722 // Split the lines in the target into lines that are less wide than pixelWidth
1723 // where possible.
1724 void wxStyledTextCtrl::LinesSplit(int pixelWidth) {
1725 SendMsg(2289, pixelWidth, 0);
1726 }
1727
1728 // Set the colours used as a chequerboard pattern in the fold margin
1729 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) {
1730 SendMsg(2290, useSetting, wxColourAsLong(back));
1731 }
1732 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) {
1733 SendMsg(2291, useSetting, wxColourAsLong(fore));
1734 }
1735
1736 // Move caret down one line.
1737 void wxStyledTextCtrl::LineDown() {
1738 SendMsg(2300, 0, 0);
1739 }
1740
1741 // Move caret down one line extending selection to new caret position.
1742 void wxStyledTextCtrl::LineDownExtend() {
1743 SendMsg(2301, 0, 0);
1744 }
1745
1746 // Move caret up one line.
1747 void wxStyledTextCtrl::LineUp() {
1748 SendMsg(2302, 0, 0);
1749 }
1750
1751 // Move caret up one line extending selection to new caret position.
1752 void wxStyledTextCtrl::LineUpExtend() {
1753 SendMsg(2303, 0, 0);
1754 }
1755
1756 // Move caret left one character.
1757 void wxStyledTextCtrl::CharLeft() {
1758 SendMsg(2304, 0, 0);
1759 }
1760
1761 // Move caret left one character extending selection to new caret position.
1762 void wxStyledTextCtrl::CharLeftExtend() {
1763 SendMsg(2305, 0, 0);
1764 }
1765
1766 // Move caret right one character.
1767 void wxStyledTextCtrl::CharRight() {
1768 SendMsg(2306, 0, 0);
1769 }
1770
1771 // Move caret right one character extending selection to new caret position.
1772 void wxStyledTextCtrl::CharRightExtend() {
1773 SendMsg(2307, 0, 0);
1774 }
1775
1776 // Move caret left one word.
1777 void wxStyledTextCtrl::WordLeft() {
1778 SendMsg(2308, 0, 0);
1779 }
1780
1781 // Move caret left one word extending selection to new caret position.
1782 void wxStyledTextCtrl::WordLeftExtend() {
1783 SendMsg(2309, 0, 0);
1784 }
1785
1786 // Move caret right one word.
1787 void wxStyledTextCtrl::WordRight() {
1788 SendMsg(2310, 0, 0);
1789 }
1790
1791 // Move caret right one word extending selection to new caret position.
1792 void wxStyledTextCtrl::WordRightExtend() {
1793 SendMsg(2311, 0, 0);
1794 }
1795
1796 // Move caret to first position on line.
1797 void wxStyledTextCtrl::Home() {
1798 SendMsg(2312, 0, 0);
1799 }
1800
1801 // Move caret to first position on line extending selection to new caret position.
1802 void wxStyledTextCtrl::HomeExtend() {
1803 SendMsg(2313, 0, 0);
1804 }
1805
1806 // Move caret to last position on line.
1807 void wxStyledTextCtrl::LineEnd() {
1808 SendMsg(2314, 0, 0);
1809 }
1810
1811 // Move caret to last position on line extending selection to new caret position.
1812 void wxStyledTextCtrl::LineEndExtend() {
1813 SendMsg(2315, 0, 0);
1814 }
1815
1816 // Move caret to first position in document.
1817 void wxStyledTextCtrl::DocumentStart() {
1818 SendMsg(2316, 0, 0);
1819 }
1820
1821 // Move caret to first position in document extending selection to new caret position.
1822 void wxStyledTextCtrl::DocumentStartExtend() {
1823 SendMsg(2317, 0, 0);
1824 }
1825
1826 // Move caret to last position in document.
1827 void wxStyledTextCtrl::DocumentEnd() {
1828 SendMsg(2318, 0, 0);
1829 }
1830
1831 // Move caret to last position in document extending selection to new caret position.
1832 void wxStyledTextCtrl::DocumentEndExtend() {
1833 SendMsg(2319, 0, 0);
1834 }
1835
1836 // Move caret one page up.
1837 void wxStyledTextCtrl::PageUp() {
1838 SendMsg(2320, 0, 0);
1839 }
1840
1841 // Move caret one page up extending selection to new caret position.
1842 void wxStyledTextCtrl::PageUpExtend() {
1843 SendMsg(2321, 0, 0);
1844 }
1845
1846 // Move caret one page down.
1847 void wxStyledTextCtrl::PageDown() {
1848 SendMsg(2322, 0, 0);
1849 }
1850
1851 // Move caret one page down extending selection to new caret position.
1852 void wxStyledTextCtrl::PageDownExtend() {
1853 SendMsg(2323, 0, 0);
1854 }
1855
1856 // Switch from insert to overtype mode or the reverse.
1857 void wxStyledTextCtrl::EditToggleOvertype() {
1858 SendMsg(2324, 0, 0);
1859 }
1860
1861 // Cancel any modes such as call tip or auto-completion list display.
1862 void wxStyledTextCtrl::Cancel() {
1863 SendMsg(2325, 0, 0);
1864 }
1865
1866 // Delete the selection or if no selection, the character before the caret.
1867 void wxStyledTextCtrl::DeleteBack() {
1868 SendMsg(2326, 0, 0);
1869 }
1870
1871 // If selection is empty or all on one line replace the selection with a tab character.
1872 // If more than one line selected, indent the lines.
1873 void wxStyledTextCtrl::Tab() {
1874 SendMsg(2327, 0, 0);
1875 }
1876
1877 // Dedent the selected lines.
1878 void wxStyledTextCtrl::BackTab() {
1879 SendMsg(2328, 0, 0);
1880 }
1881
1882 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1883 void wxStyledTextCtrl::NewLine() {
1884 SendMsg(2329, 0, 0);
1885 }
1886
1887 // Insert a Form Feed character.
1888 void wxStyledTextCtrl::FormFeed() {
1889 SendMsg(2330, 0, 0);
1890 }
1891
1892 // Move caret to before first visible character on line.
1893 // If already there move to first character on line.
1894 void wxStyledTextCtrl::VCHome() {
1895 SendMsg(2331, 0, 0);
1896 }
1897
1898 // Like VCHome but extending selection to new caret position.
1899 void wxStyledTextCtrl::VCHomeExtend() {
1900 SendMsg(2332, 0, 0);
1901 }
1902
1903 // Magnify the displayed text by increasing the sizes by 1 point.
1904 void wxStyledTextCtrl::ZoomIn() {
1905 SendMsg(2333, 0, 0);
1906 }
1907
1908 // Make the displayed text smaller by decreasing the sizes by 1 point.
1909 void wxStyledTextCtrl::ZoomOut() {
1910 SendMsg(2334, 0, 0);
1911 }
1912
1913 // Delete the word to the left of the caret.
1914 void wxStyledTextCtrl::DelWordLeft() {
1915 SendMsg(2335, 0, 0);
1916 }
1917
1918 // Delete the word to the right of the caret.
1919 void wxStyledTextCtrl::DelWordRight() {
1920 SendMsg(2336, 0, 0);
1921 }
1922
1923 // Cut the line containing the caret.
1924 void wxStyledTextCtrl::LineCut() {
1925 SendMsg(2337, 0, 0);
1926 }
1927
1928 // Delete the line containing the caret.
1929 void wxStyledTextCtrl::LineDelete() {
1930 SendMsg(2338, 0, 0);
1931 }
1932
1933 // Switch the current line with the previous.
1934 void wxStyledTextCtrl::LineTranspose() {
1935 SendMsg(2339, 0, 0);
1936 }
1937
1938 // Duplicate the current line.
1939 void wxStyledTextCtrl::LineDuplicate() {
1940 SendMsg(2404, 0, 0);
1941 }
1942
1943 // Transform the selection to lower case.
1944 void wxStyledTextCtrl::LowerCase() {
1945 SendMsg(2340, 0, 0);
1946 }
1947
1948 // Transform the selection to upper case.
1949 void wxStyledTextCtrl::UpperCase() {
1950 SendMsg(2341, 0, 0);
1951 }
1952
1953 // Scroll the document down, keeping the caret visible.
1954 void wxStyledTextCtrl::LineScrollDown() {
1955 SendMsg(2342, 0, 0);
1956 }
1957
1958 // Scroll the document up, keeping the caret visible.
1959 void wxStyledTextCtrl::LineScrollUp() {
1960 SendMsg(2343, 0, 0);
1961 }
1962
1963 // Delete the selection or if no selection, the character before the caret.
1964 // Will not delete the character before at the start of a line.
1965 void wxStyledTextCtrl::DeleteBackNotLine() {
1966 SendMsg(2344, 0, 0);
1967 }
1968
1969 // Move caret to first position on display line.
1970 void wxStyledTextCtrl::HomeDisplay() {
1971 SendMsg(2345, 0, 0);
1972 }
1973
1974 // Move caret to first position on display line extending selection to
1975 // new caret position.
1976 void wxStyledTextCtrl::HomeDisplayExtend() {
1977 SendMsg(2346, 0, 0);
1978 }
1979
1980 // Move caret to last position on display line.
1981 void wxStyledTextCtrl::LineEndDisplay() {
1982 SendMsg(2347, 0, 0);
1983 }
1984
1985 // Move caret to last position on display line extending selection to new
1986 // caret position.
1987 void wxStyledTextCtrl::LineEndDisplayExtend() {
1988 SendMsg(2348, 0, 0);
1989 }
1990
1991 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1992 // except they behave differently when word-wrap is enabled:
1993 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1994 // The difference is that, the cursor is already at the point, it goes on to the start
1995 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1996 void wxStyledTextCtrl::HomeWrap() {
1997 SendMsg(2349, 0, 0);
1998 }
1999 void wxStyledTextCtrl::HomeWrapExtend() {
2000 SendMsg(2450, 0, 0);
2001 }
2002 void wxStyledTextCtrl::LineEndWrap() {
2003 SendMsg(2451, 0, 0);
2004 }
2005 void wxStyledTextCtrl::LineEndWrapExtend() {
2006 SendMsg(2452, 0, 0);
2007 }
2008 void wxStyledTextCtrl::VCHomeWrap() {
2009 SendMsg(2453, 0, 0);
2010 }
2011 void wxStyledTextCtrl::VCHomeWrapExtend() {
2012 SendMsg(2454, 0, 0);
2013 }
2014
2015 // Copy the line containing the caret.
2016 void wxStyledTextCtrl::LineCopy() {
2017 SendMsg(2455, 0, 0);
2018 }
2019
2020 // Move the caret inside current view if it's not there already.
2021 void wxStyledTextCtrl::MoveCaretInsideView() {
2022 SendMsg(2401, 0, 0);
2023 }
2024
2025 // How many characters are on a line, not including end of line characters?
2026 int wxStyledTextCtrl::LineLength(int line) {
2027 return SendMsg(2350, line, 0);
2028 }
2029
2030 // Highlight the characters at two positions.
2031 void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
2032 SendMsg(2351, pos1, pos2);
2033 }
2034
2035 // Highlight the character at a position indicating there is no matching brace.
2036 void wxStyledTextCtrl::BraceBadLight(int pos) {
2037 SendMsg(2352, pos, 0);
2038 }
2039
2040 // Find the position of a matching brace or INVALID_POSITION if no match.
2041 int wxStyledTextCtrl::BraceMatch(int pos) {
2042 return SendMsg(2353, pos, 0);
2043 }
2044
2045 // Are the end of line characters visible?
2046 bool wxStyledTextCtrl::GetViewEOL() {
2047 return SendMsg(2355, 0, 0) != 0;
2048 }
2049
2050 // Make the end of line characters visible or invisible.
2051 void wxStyledTextCtrl::SetViewEOL(bool visible) {
2052 SendMsg(2356, visible, 0);
2053 }
2054
2055 // Retrieve a pointer to the document object.
2056 void* wxStyledTextCtrl::GetDocPointer() {
2057 return (void*)SendMsg(2357);
2058 }
2059
2060 // Change the document object used.
2061 void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
2062 SendMsg(2358, 0, (long)docPointer);
2063 }
2064
2065 // Set which document modification events are sent to the container.
2066 void wxStyledTextCtrl::SetModEventMask(int mask) {
2067 SendMsg(2359, mask, 0);
2068 }
2069
2070 // Retrieve the column number which text should be kept within.
2071 int wxStyledTextCtrl::GetEdgeColumn() {
2072 return SendMsg(2360, 0, 0);
2073 }
2074
2075 // Set the column number of the edge.
2076 // If text goes past the edge then it is highlighted.
2077 void wxStyledTextCtrl::SetEdgeColumn(int column) {
2078 SendMsg(2361, column, 0);
2079 }
2080
2081 // Retrieve the edge highlight mode.
2082 int wxStyledTextCtrl::GetEdgeMode() {
2083 return SendMsg(2362, 0, 0);
2084 }
2085
2086 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2087 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2088 void wxStyledTextCtrl::SetEdgeMode(int mode) {
2089 SendMsg(2363, mode, 0);
2090 }
2091
2092 // Retrieve the colour used in edge indication.
2093 wxColour wxStyledTextCtrl::GetEdgeColour() {
2094 long c = SendMsg(2364, 0, 0);
2095 return wxColourFromLong(c);
2096 }
2097
2098 // Change the colour used in edge indication.
2099 void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
2100 SendMsg(2365, wxColourAsLong(edgeColour), 0);
2101 }
2102
2103 // Sets the current caret position to be the search anchor.
2104 void wxStyledTextCtrl::SearchAnchor() {
2105 SendMsg(2366, 0, 0);
2106 }
2107
2108 // Find some text starting at the search anchor.
2109 // Does not ensure the selection is visible.
2110 int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
2111 return SendMsg(2367, flags, (long)(const char*)wx2stc(text));
2112 }
2113
2114 // Find some text starting at the search anchor and moving backwards.
2115 // Does not ensure the selection is visible.
2116 int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
2117 return SendMsg(2368, flags, (long)(const char*)wx2stc(text));
2118 }
2119
2120 // Retrieves the number of lines completely visible.
2121 int wxStyledTextCtrl::LinesOnScreen() {
2122 return SendMsg(2370, 0, 0);
2123 }
2124
2125 // Set whether a pop up menu is displayed automatically when the user presses
2126 // the wrong mouse button.
2127 void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
2128 SendMsg(2371, allowPopUp, 0);
2129 }
2130
2131 // Is the selection rectangular? The alternative is the more common stream selection.
2132 bool wxStyledTextCtrl::SelectionIsRectangle() {
2133 return SendMsg(2372, 0, 0) != 0;
2134 }
2135
2136 // Set the zoom level. This number of points is added to the size of all fonts.
2137 // It may be positive to magnify or negative to reduce.
2138 void wxStyledTextCtrl::SetZoom(int zoom) {
2139 SendMsg(2373, zoom, 0);
2140 }
2141
2142 // Retrieve the zoom level.
2143 int wxStyledTextCtrl::GetZoom() {
2144 return SendMsg(2374, 0, 0);
2145 }
2146
2147 // Create a new document object.
2148 // Starts with reference count of 1 and not selected into editor.
2149 void* wxStyledTextCtrl::CreateDocument() {
2150 return (void*)SendMsg(2375);
2151 }
2152
2153 // Extend life of document.
2154 void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
2155 SendMsg(2376, 0, (long)docPointer);
2156 }
2157
2158 // Release a reference to the document, deleting document if it fades to black.
2159 void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
2160 SendMsg(2377, 0, (long)docPointer);
2161 }
2162
2163 // Get which document modification events are sent to the container.
2164 int wxStyledTextCtrl::GetModEventMask() {
2165 return SendMsg(2378, 0, 0);
2166 }
2167
2168 // Change internal focus flag.
2169 void wxStyledTextCtrl::SetSTCFocus(bool focus) {
2170 SendMsg(2380, focus, 0);
2171 }
2172
2173 // Get internal focus flag.
2174 bool wxStyledTextCtrl::GetSTCFocus() {
2175 return SendMsg(2381, 0, 0) != 0;
2176 }
2177
2178 // Change error status - 0 = OK.
2179 void wxStyledTextCtrl::SetStatus(int statusCode) {
2180 SendMsg(2382, statusCode, 0);
2181 }
2182
2183 // Get error status.
2184 int wxStyledTextCtrl::GetStatus() {
2185 return SendMsg(2383, 0, 0);
2186 }
2187
2188 // Set whether the mouse is captured when its button is pressed.
2189 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
2190 SendMsg(2384, captures, 0);
2191 }
2192
2193 // Get whether mouse gets captured.
2194 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2195 return SendMsg(2385, 0, 0) != 0;
2196 }
2197
2198 // Sets the cursor to one of the SC_CURSOR* values.
2199 void wxStyledTextCtrl::SetSTCCursor(int cursorType) {
2200 SendMsg(2386, cursorType, 0);
2201 }
2202
2203 // Get cursor type.
2204 int wxStyledTextCtrl::GetSTCCursor() {
2205 return SendMsg(2387, 0, 0);
2206 }
2207
2208 // Change the way control characters are displayed:
2209 // If symbol is < 32, keep the drawn way, else, use the given character.
2210 void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
2211 SendMsg(2388, symbol, 0);
2212 }
2213
2214 // Get the way control characters are displayed.
2215 int wxStyledTextCtrl::GetControlCharSymbol() {
2216 return SendMsg(2389, 0, 0);
2217 }
2218
2219 // Move to the previous change in capitalisation.
2220 void wxStyledTextCtrl::WordPartLeft() {
2221 SendMsg(2390, 0, 0);
2222 }
2223
2224 // Move to the previous change in capitalisation extending selection
2225 // to new caret position.
2226 void wxStyledTextCtrl::WordPartLeftExtend() {
2227 SendMsg(2391, 0, 0);
2228 }
2229
2230 // Move to the change next in capitalisation.
2231 void wxStyledTextCtrl::WordPartRight() {
2232 SendMsg(2392, 0, 0);
2233 }
2234
2235 // Move to the next change in capitalisation extending selection
2236 // to new caret position.
2237 void wxStyledTextCtrl::WordPartRightExtend() {
2238 SendMsg(2393, 0, 0);
2239 }
2240
2241 // Set the way the display area is determined when a particular line
2242 // is to be moved to by Find, FindNext, GotoLine, etc.
2243 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
2244 SendMsg(2394, visiblePolicy, visibleSlop);
2245 }
2246
2247 // Delete back from the current position to the start of the line.
2248 void wxStyledTextCtrl::DelLineLeft() {
2249 SendMsg(2395, 0, 0);
2250 }
2251
2252 // Delete forwards from the current position to the end of the line.
2253 void wxStyledTextCtrl::DelLineRight() {
2254 SendMsg(2396, 0, 0);
2255 }
2256
2257 // Get and Set the xOffset (ie, horizonal scroll position).
2258 void wxStyledTextCtrl::SetXOffset(int newOffset) {
2259 SendMsg(2397, newOffset, 0);
2260 }
2261 int wxStyledTextCtrl::GetXOffset() {
2262 return SendMsg(2398, 0, 0);
2263 }
2264
2265 // Set the last x chosen value to be the caret x position.
2266 void wxStyledTextCtrl::ChooseCaretX() {
2267 SendMsg(2399, 0, 0);
2268 }
2269
2270 // Set the way the caret is kept visible when going sideway.
2271 // The exclusion zone is given in pixels.
2272 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) {
2273 SendMsg(2402, caretPolicy, caretSlop);
2274 }
2275
2276 // Set the way the line the caret is on is kept visible.
2277 // The exclusion zone is given in lines.
2278 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) {
2279 SendMsg(2403, caretPolicy, caretSlop);
2280 }
2281
2282 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2283 void wxStyledTextCtrl::SetPrintWrapMode(int mode) {
2284 SendMsg(2406, mode, 0);
2285 }
2286
2287 // Is printing line wrapped?
2288 int wxStyledTextCtrl::GetPrintWrapMode() {
2289 return SendMsg(2407, 0, 0);
2290 }
2291
2292 // Set a fore colour for active hotspots.
2293 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) {
2294 SendMsg(2410, useSetting, wxColourAsLong(fore));
2295 }
2296
2297 // Set a back colour for active hotspots.
2298 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) {
2299 SendMsg(2411, useSetting, wxColourAsLong(back));
2300 }
2301
2302 // Enable / Disable underlining active hotspots.
2303 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) {
2304 SendMsg(2412, underline, 0);
2305 }
2306
2307 // Limit hotspots to single line so hotspots on two lines don't merge.
2308 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) {
2309 SendMsg(2421, singleLine, 0);
2310 }
2311
2312 // Move caret between paragraphs (delimited by empty lines).
2313 void wxStyledTextCtrl::ParaDown() {
2314 SendMsg(2413, 0, 0);
2315 }
2316 void wxStyledTextCtrl::ParaDownExtend() {
2317 SendMsg(2414, 0, 0);
2318 }
2319 void wxStyledTextCtrl::ParaUp() {
2320 SendMsg(2415, 0, 0);
2321 }
2322 void wxStyledTextCtrl::ParaUpExtend() {
2323 SendMsg(2416, 0, 0);
2324 }
2325
2326 // Given a valid document position, return the previous position taking code
2327 // page into account. Returns 0 if passed 0.
2328 int wxStyledTextCtrl::PositionBefore(int pos) {
2329 return SendMsg(2417, pos, 0);
2330 }
2331
2332 // Given a valid document position, return the next position taking code
2333 // page into account. Maximum value returned is the last position in the document.
2334 int wxStyledTextCtrl::PositionAfter(int pos) {
2335 return SendMsg(2418, pos, 0);
2336 }
2337
2338 // Copy a range of text to the clipboard. Positions are clipped into the document.
2339 void wxStyledTextCtrl::CopyRange(int start, int end) {
2340 SendMsg(2419, start, end);
2341 }
2342
2343 // Copy argument text to the clipboard.
2344 void wxStyledTextCtrl::CopyText(int length, const wxString& text) {
2345 SendMsg(2420, length, (long)(const char*)wx2stc(text));
2346 }
2347
2348 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2349 // by lines (SC_SEL_LINES).
2350 void wxStyledTextCtrl::SetSelectionMode(int mode) {
2351 SendMsg(2422, mode, 0);
2352 }
2353
2354 // Get the mode of the current selection.
2355 int wxStyledTextCtrl::GetSelectionMode() {
2356 return SendMsg(2423, 0, 0);
2357 }
2358
2359 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2360 int wxStyledTextCtrl::GetLineSelStartPosition(int line) {
2361 return SendMsg(2424, line, 0);
2362 }
2363
2364 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2365 int wxStyledTextCtrl::GetLineSelEndPosition(int line) {
2366 return SendMsg(2425, line, 0);
2367 }
2368
2369 // Move caret down one line, extending rectangular selection to new caret position.
2370 void wxStyledTextCtrl::LineDownRectExtend() {
2371 SendMsg(2426, 0, 0);
2372 }
2373
2374 // Move caret up one line, extending rectangular selection to new caret position.
2375 void wxStyledTextCtrl::LineUpRectExtend() {
2376 SendMsg(2427, 0, 0);
2377 }
2378
2379 // Move caret left one character, extending rectangular selection to new caret position.
2380 void wxStyledTextCtrl::CharLeftRectExtend() {
2381 SendMsg(2428, 0, 0);
2382 }
2383
2384 // Move caret right one character, extending rectangular selection to new caret position.
2385 void wxStyledTextCtrl::CharRightRectExtend() {
2386 SendMsg(2429, 0, 0);
2387 }
2388
2389 // Move caret to first position on line, extending rectangular selection to new caret position.
2390 void wxStyledTextCtrl::HomeRectExtend() {
2391 SendMsg(2430, 0, 0);
2392 }
2393
2394 // Move caret to before first visible character on line.
2395 // If already there move to first character on line.
2396 // In either case, extend rectangular selection to new caret position.
2397 void wxStyledTextCtrl::VCHomeRectExtend() {
2398 SendMsg(2431, 0, 0);
2399 }
2400
2401 // Move caret to last position on line, extending rectangular selection to new caret position.
2402 void wxStyledTextCtrl::LineEndRectExtend() {
2403 SendMsg(2432, 0, 0);
2404 }
2405
2406 // Move caret one page up, extending rectangular selection to new caret position.
2407 void wxStyledTextCtrl::PageUpRectExtend() {
2408 SendMsg(2433, 0, 0);
2409 }
2410
2411 // Move caret one page down, extending rectangular selection to new caret position.
2412 void wxStyledTextCtrl::PageDownRectExtend() {
2413 SendMsg(2434, 0, 0);
2414 }
2415
2416 // Move caret to top of page, or one page up if already at top of page.
2417 void wxStyledTextCtrl::StutteredPageUp() {
2418 SendMsg(2435, 0, 0);
2419 }
2420
2421 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2422 void wxStyledTextCtrl::StutteredPageUpExtend() {
2423 SendMsg(2436, 0, 0);
2424 }
2425
2426 // Move caret to bottom of page, or one page down if already at bottom of page.
2427 void wxStyledTextCtrl::StutteredPageDown() {
2428 SendMsg(2437, 0, 0);
2429 }
2430
2431 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2432 void wxStyledTextCtrl::StutteredPageDownExtend() {
2433 SendMsg(2438, 0, 0);
2434 }
2435
2436 // Move caret left one word, position cursor at end of word.
2437 void wxStyledTextCtrl::WordLeftEnd() {
2438 SendMsg(2439, 0, 0);
2439 }
2440
2441 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2442 void wxStyledTextCtrl::WordLeftEndExtend() {
2443 SendMsg(2440, 0, 0);
2444 }
2445
2446 // Move caret right one word, position cursor at end of word.
2447 void wxStyledTextCtrl::WordRightEnd() {
2448 SendMsg(2441, 0, 0);
2449 }
2450
2451 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2452 void wxStyledTextCtrl::WordRightEndExtend() {
2453 SendMsg(2442, 0, 0);
2454 }
2455
2456 // Set the set of characters making up whitespace for when moving or selecting by word.
2457 // Should be called after SetWordChars.
2458 void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) {
2459 SendMsg(2443, 0, (long)(const char*)wx2stc(characters));
2460 }
2461
2462 // Reset the set of characters for whitespace and word characters to the defaults.
2463 void wxStyledTextCtrl::SetCharsDefault() {
2464 SendMsg(2444, 0, 0);
2465 }
2466
2467 // Get currently selected item position in the auto-completion list
2468 int wxStyledTextCtrl::AutoCompGetCurrent() {
2469 return SendMsg(2445, 0, 0);
2470 }
2471
2472 // Enlarge the document to a particular size of text bytes.
2473 void wxStyledTextCtrl::Allocate(int bytes) {
2474 SendMsg(2446, bytes, 0);
2475 }
2476
2477 // Find the position of a column on a line taking into account tabs and
2478 // multi-byte characters. If beyond end of line, return line end position.
2479 int wxStyledTextCtrl::FindColumn(int line, int column) {
2480 return SendMsg(2456, line, column);
2481 }
2482
2483 // Can the caret preferred x position only be changed by explicit movement commands?
2484 bool wxStyledTextCtrl::GetCaretSticky() {
2485 return SendMsg(2457, 0, 0) != 0;
2486 }
2487
2488 // Stop the caret preferred x position changing when the user types.
2489 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour) {
2490 SendMsg(2458, useCaretStickyBehaviour, 0);
2491 }
2492
2493 // Switch between sticky and non-sticky: meant to be bound to a key.
2494 void wxStyledTextCtrl::ToggleCaretSticky() {
2495 SendMsg(2459, 0, 0);
2496 }
2497
2498 // Enable/Disable convert-on-paste for line endings
2499 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert) {
2500 SendMsg(2467, convert, 0);
2501 }
2502
2503 // Get convert-on-paste setting
2504 bool wxStyledTextCtrl::GetPasteConvertEndings() {
2505 return SendMsg(2468, 0, 0) != 0;
2506 }
2507
2508 // Duplicate the selection. If selection empty duplicate the line containing the caret.
2509 void wxStyledTextCtrl::SelectionDuplicate() {
2510 SendMsg(2469, 0, 0);
2511 }
2512
2513 // Set background alpha of the caret line.
2514 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha) {
2515 SendMsg(2470, alpha, 0);
2516 }
2517
2518 // Get the background alpha of the caret line.
2519 int wxStyledTextCtrl::GetCaretLineBackAlpha() {
2520 return SendMsg(2471, 0, 0);
2521 }
2522
2523 // Start notifying the container of all key presses and commands.
2524 void wxStyledTextCtrl::StartRecord() {
2525 SendMsg(3001, 0, 0);
2526 }
2527
2528 // Stop notifying the container of all key presses and commands.
2529 void wxStyledTextCtrl::StopRecord() {
2530 SendMsg(3002, 0, 0);
2531 }
2532
2533 // Set the lexing language of the document.
2534 void wxStyledTextCtrl::SetLexer(int lexer) {
2535 SendMsg(4001, lexer, 0);
2536 }
2537
2538 // Retrieve the lexing language of the document.
2539 int wxStyledTextCtrl::GetLexer() {
2540 return SendMsg(4002, 0, 0);
2541 }
2542
2543 // Colourise a segment of the document using the current lexing language.
2544 void wxStyledTextCtrl::Colourise(int start, int end) {
2545 SendMsg(4003, start, end);
2546 }
2547
2548 // Set up a value that may be used by a lexer for some optional feature.
2549 void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
2550 SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value));
2551 }
2552
2553 // Set up the key words used by the lexer.
2554 void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
2555 SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords));
2556 }
2557
2558 // Set the lexing language of the document based on string name.
2559 void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
2560 SendMsg(4006, 0, (long)(const char*)wx2stc(language));
2561 }
2562
2563 // Retrieve a 'property' value previously set with SetProperty.
2564 wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
2565 int len = SendMsg(SCI_GETPROPERTY, (long)(const char*)wx2stc(key), 0);
2566 if (!len) return wxEmptyString;
2567
2568 wxMemoryBuffer mbuf(len+1);
2569 char* buf = (char*)mbuf.GetWriteBuf(len+1);
2570 SendMsg(4008, (long)(const char*)wx2stc(key), (long)buf);
2571 mbuf.UngetWriteBuf(len);
2572 mbuf.AppendByte(0);
2573 return stc2wx(buf);
2574 }
2575
2576 // Retrieve a 'property' value previously set with SetProperty,
2577 // with '$()' variable replacement on returned buffer.
2578 wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
2579 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (long)(const char*)wx2stc(key), 0);
2580 if (!len) return wxEmptyString;
2581
2582 wxMemoryBuffer mbuf(len+1);
2583 char* buf = (char*)mbuf.GetWriteBuf(len+1);
2584 SendMsg(4009, (long)(const char*)wx2stc(key), (long)buf);
2585 mbuf.UngetWriteBuf(len);
2586 mbuf.AppendByte(0);
2587 return stc2wx(buf);
2588 }
2589
2590 // Retrieve a 'property' value previously set with SetProperty,
2591 // interpreted as an int AFTER any '$()' variable replacement.
2592 int wxStyledTextCtrl::GetPropertyInt(const wxString& key) {
2593 return SendMsg(4010, (long)(const char*)wx2stc(key), 0);
2594 }
2595
2596 // Retrieve the number of bits the current lexer needs for styling.
2597 int wxStyledTextCtrl::GetStyleBitsNeeded() {
2598 return SendMsg(4011, 0, 0);
2599 }
2600
2601 // END of generated section
2602 //----------------------------------------------------------------------
2603
2604
2605 // Returns the line number of the line with the caret.
2606 int wxStyledTextCtrl::GetCurrentLine() {
2607 int line = LineFromPosition(GetCurrentPos());
2608 return line;
2609 }
2610
2611
2612 // Extract style settings from a spec-string which is composed of one or
2613 // more of the following comma separated elements:
2614 //
2615 // bold turns on bold
2616 // italic turns on italics
2617 // fore:[name or #RRGGBB] sets the foreground colour
2618 // back:[name or #RRGGBB] sets the background colour
2619 // face:[facename] sets the font face name to use
2620 // size:[num] sets the font size in points
2621 // eol turns on eol filling
2622 // underline turns on underlining
2623 //
2624 void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
2625
2626 wxStringTokenizer tkz(spec, wxT(","));
2627 while (tkz.HasMoreTokens()) {
2628 wxString token = tkz.GetNextToken();
2629
2630 wxString option = token.BeforeFirst(':');
2631 wxString val = token.AfterFirst(':');
2632
2633 if (option == wxT("bold"))
2634 StyleSetBold(styleNum, true);
2635
2636 else if (option == wxT("italic"))
2637 StyleSetItalic(styleNum, true);
2638
2639 else if (option == wxT("underline"))
2640 StyleSetUnderline(styleNum, true);
2641
2642 else if (option == wxT("eol"))
2643 StyleSetEOLFilled(styleNum, true);
2644
2645 else if (option == wxT("size")) {
2646 long points;
2647 if (val.ToLong(&points))
2648 StyleSetSize(styleNum, points);
2649 }
2650
2651 else if (option == wxT("face"))
2652 StyleSetFaceName(styleNum, val);
2653
2654 else if (option == wxT("fore"))
2655 StyleSetForeground(styleNum, wxColourFromSpec(val));
2656
2657 else if (option == wxT("back"))
2658 StyleSetBackground(styleNum, wxColourFromSpec(val));
2659 }
2660 }
2661
2662
2663 // Set style size, face, bold, italic, and underline attributes from
2664 // a wxFont's attributes.
2665 void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
2666 #ifdef __WXGTK__
2667 // Ensure that the native font is initialized
2668 int x, y;
2669 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
2670 #endif
2671 int size = font.GetPointSize();
2672 wxString faceName = font.GetFaceName();
2673 bool bold = font.GetWeight() == wxBOLD;
2674 bool italic = font.GetStyle() != wxNORMAL;
2675 bool under = font.GetUnderlined();
2676 wxFontEncoding encoding = font.GetEncoding();
2677
2678 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
2679 }
2680
2681 // Set all font style attributes at once.
2682 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
2683 const wxString& faceName,
2684 bool bold, bool italic,
2685 bool underline,
2686 wxFontEncoding encoding) {
2687 StyleSetSize(styleNum, size);
2688 StyleSetFaceName(styleNum, faceName);
2689 StyleSetBold(styleNum, bold);
2690 StyleSetItalic(styleNum, italic);
2691 StyleSetUnderline(styleNum, underline);
2692 StyleSetFontEncoding(styleNum, encoding);
2693 }
2694
2695
2696 // Set the character set of the font in a style. Converts the Scintilla
2697 // character set values to a wxFontEncoding.
2698 void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
2699 {
2700 wxFontEncoding encoding;
2701
2702 // Translate the Scintilla characterSet to a wxFontEncoding
2703 switch (characterSet) {
2704 default:
2705 case wxSTC_CHARSET_ANSI:
2706 case wxSTC_CHARSET_DEFAULT:
2707 encoding = wxFONTENCODING_DEFAULT;
2708 break;
2709
2710 case wxSTC_CHARSET_BALTIC:
2711 encoding = wxFONTENCODING_ISO8859_13;
2712 break;
2713
2714 case wxSTC_CHARSET_CHINESEBIG5:
2715 encoding = wxFONTENCODING_CP950;
2716 break;
2717
2718 case wxSTC_CHARSET_EASTEUROPE:
2719 encoding = wxFONTENCODING_ISO8859_2;
2720 break;
2721
2722 case wxSTC_CHARSET_GB2312:
2723 encoding = wxFONTENCODING_CP936;
2724 break;
2725
2726 case wxSTC_CHARSET_GREEK:
2727 encoding = wxFONTENCODING_ISO8859_7;
2728 break;
2729
2730 case wxSTC_CHARSET_HANGUL:
2731 encoding = wxFONTENCODING_CP949;
2732 break;
2733
2734 case wxSTC_CHARSET_MAC:
2735 encoding = wxFONTENCODING_DEFAULT;
2736 break;
2737
2738 case wxSTC_CHARSET_OEM:
2739 encoding = wxFONTENCODING_DEFAULT;
2740 break;
2741
2742 case wxSTC_CHARSET_RUSSIAN:
2743 encoding = wxFONTENCODING_KOI8;
2744 break;
2745
2746 case wxSTC_CHARSET_SHIFTJIS:
2747 encoding = wxFONTENCODING_CP932;
2748 break;
2749
2750 case wxSTC_CHARSET_SYMBOL:
2751 encoding = wxFONTENCODING_DEFAULT;
2752 break;
2753
2754 case wxSTC_CHARSET_TURKISH:
2755 encoding = wxFONTENCODING_ISO8859_9;
2756 break;
2757
2758 case wxSTC_CHARSET_JOHAB:
2759 encoding = wxFONTENCODING_DEFAULT;
2760 break;
2761
2762 case wxSTC_CHARSET_HEBREW:
2763 encoding = wxFONTENCODING_ISO8859_8;
2764 break;
2765
2766 case wxSTC_CHARSET_ARABIC:
2767 encoding = wxFONTENCODING_ISO8859_6;
2768 break;
2769
2770 case wxSTC_CHARSET_VIETNAMESE:
2771 encoding = wxFONTENCODING_DEFAULT;
2772 break;
2773
2774 case wxSTC_CHARSET_THAI:
2775 encoding = wxFONTENCODING_ISO8859_11;
2776 break;
2777
2778 case wxSTC_CHARSET_CYRILLIC:
2779 encoding = wxFONTENCODING_ISO8859_5;
2780 break;
2781
2782 case wxSTC_CHARSET_8859_15:
2783 encoding = wxFONTENCODING_ISO8859_15;;
2784 break;
2785 }
2786
2787 // We just have Scintilla track the wxFontEncoding for us. It gets used
2788 // in Font::Create in PlatWX.cpp. We add one to the value so that the
2789 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
2790 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
2791 // to wxFONENCODING_DEFAULT in Font::Create.
2792 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
2793 }
2794
2795
2796 // Set the font encoding to be used by a style.
2797 void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
2798 {
2799 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
2800 }
2801
2802
2803 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2804 void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
2805 SendMsg(cmd);
2806 }
2807
2808
2809 // Set the left and right margin in the edit area, measured in pixels.
2810 void wxStyledTextCtrl::SetMargins(int left, int right) {
2811 SetMarginLeft(left);
2812 SetMarginRight(right);
2813 }
2814
2815
2816 // Retrieve the start and end positions of the current selection.
2817 void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
2818 if (startPos != NULL)
2819 *startPos = SendMsg(SCI_GETSELECTIONSTART);
2820 if (endPos != NULL)
2821 *endPos = SendMsg(SCI_GETSELECTIONEND);
2822 }
2823
2824
2825 // Retrieve the point in the window where a position is displayed.
2826 wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
2827 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
2828 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
2829 return wxPoint(x, y);
2830 }
2831
2832 // Scroll enough to make the given line visible
2833 void wxStyledTextCtrl::ScrollToLine(int line) {
2834 m_swx->DoScrollToLine(line);
2835 }
2836
2837
2838 // Scroll enough to make the given column visible
2839 void wxStyledTextCtrl::ScrollToColumn(int column) {
2840 m_swx->DoScrollToColumn(column);
2841 }
2842
2843
2844 bool wxStyledTextCtrl::SaveFile(const wxString& filename)
2845 {
2846 wxFile file(filename, wxFile::write);
2847
2848 if (!file.IsOpened())
2849 return false;
2850
2851 bool success = file.Write(GetText(), *wxConvCurrent);
2852
2853 if (success)
2854 SetSavePoint();
2855
2856 return success;
2857 }
2858
2859 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
2860 {
2861 bool success = false;
2862 wxFile file(filename, wxFile::read);
2863
2864 if (file.IsOpened())
2865 {
2866 wxString contents;
2867 // get the file size (assume it is not huge file...)
2868 ssize_t len = (ssize_t)file.Length();
2869
2870 if (len > 0)
2871 {
2872 #if wxUSE_UNICODE
2873 wxMemoryBuffer buffer(len+1);
2874 success = (file.Read(buffer.GetData(), len) == len);
2875 if (success) {
2876 ((char*)buffer.GetData())[len] = 0;
2877 contents = wxString(buffer, *wxConvCurrent, len);
2878 }
2879 #else
2880 wxString buffer;
2881 success = (file.Read(wxStringBuffer(buffer, len), len) == len);
2882 contents = buffer;
2883 #endif
2884 }
2885 else
2886 {
2887 if (len == 0)
2888 success = true; // empty file is ok
2889 else
2890 success = false; // len == wxInvalidOffset
2891 }
2892
2893 if (success)
2894 {
2895 SetText(contents);
2896 EmptyUndoBuffer();
2897 SetSavePoint();
2898 }
2899 }
2900
2901 return success;
2902 }
2903
2904
2905 #if wxUSE_DRAG_AND_DROP
2906 wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
2907 return m_swx->DoDragOver(x, y, def);
2908 }
2909
2910
2911 bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
2912 return m_swx->DoDropText(x, y, data);
2913 }
2914 #endif
2915
2916
2917 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
2918 m_swx->SetUseAntiAliasing(useAA);
2919 }
2920
2921 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2922 return m_swx->GetUseAntiAliasing();
2923 }
2924
2925
2926
2927
2928
2929 void wxStyledTextCtrl::AddTextRaw(const char* text)
2930 {
2931 SendMsg(SCI_ADDTEXT, strlen(text), (long)text);
2932 }
2933
2934 void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
2935 {
2936 SendMsg(SCI_INSERTTEXT, pos, (long)text);
2937 }
2938
2939 wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
2940 {
2941 int len = LineLength(GetCurrentLine());
2942 if (!len) {
2943 if (linePos) *linePos = 0;
2944 wxCharBuffer empty;
2945 return empty;
2946 }
2947
2948 wxCharBuffer buf(len);
2949 int pos = SendMsg(SCI_GETCURLINE, len, (long)buf.data());
2950 if (linePos) *linePos = pos;
2951 return buf;
2952 }
2953
2954 wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
2955 {
2956 int len = LineLength(line);
2957 if (!len) {
2958 wxCharBuffer empty;
2959 return empty;
2960 }
2961
2962 wxCharBuffer buf(len);
2963 SendMsg(SCI_GETLINE, line, (long)buf.data());
2964 return buf;
2965 }
2966
2967 wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
2968 {
2969 int start;
2970 int end;
2971
2972 GetSelection(&start, &end);
2973 int len = end - start;
2974 if (!len) {
2975 wxCharBuffer empty;
2976 return empty;
2977 }
2978
2979 wxCharBuffer buf(len);
2980 SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
2981 return buf;
2982 }
2983
2984 wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
2985 {
2986 if (endPos < startPos) {
2987 int temp = startPos;
2988 startPos = endPos;
2989 endPos = temp;
2990 }
2991 int len = endPos - startPos;
2992 if (!len) {
2993 wxCharBuffer empty;
2994 return empty;
2995 }
2996
2997 wxCharBuffer buf(len);
2998 TextRange tr;
2999 tr.lpstrText = buf.data();
3000 tr.chrg.cpMin = startPos;
3001 tr.chrg.cpMax = endPos;
3002 SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr);
3003 return buf;
3004 }
3005
3006 void wxStyledTextCtrl::SetTextRaw(const char* text)
3007 {
3008 SendMsg(SCI_SETTEXT, 0, (long)text);
3009 }
3010
3011 wxCharBuffer wxStyledTextCtrl::GetTextRaw()
3012 {
3013 int len = GetTextLength();
3014 wxCharBuffer buf(len);
3015 SendMsg(SCI_GETTEXT, len, (long)buf.data());
3016 return buf;
3017 }
3018
3019 void wxStyledTextCtrl::AppendTextRaw(const char* text)
3020 {
3021 SendMsg(SCI_APPENDTEXT, strlen(text), (long)text);
3022 }
3023
3024
3025
3026
3027
3028 //----------------------------------------------------------------------
3029 // Event handlers
3030
3031 void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
3032 wxPaintDC dc(this);
3033 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
3034 }
3035
3036 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
3037 if (evt.GetOrientation() == wxHORIZONTAL)
3038 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
3039 else
3040 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
3041 }
3042
3043 void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
3044 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
3045 if (sb) {
3046 if (sb->IsVertical())
3047 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
3048 else
3049 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
3050 }
3051 }
3052
3053 void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
3054 if (m_swx) {
3055 wxSize sz = GetClientSize();
3056 m_swx->DoSize(sz.x, sz.y);
3057 }
3058 }
3059
3060 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
3061 SetFocus();
3062 wxPoint pt = evt.GetPosition();
3063 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
3064 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
3065 }
3066
3067 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
3068 wxPoint pt = evt.GetPosition();
3069 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
3070 }
3071
3072 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
3073 wxPoint pt = evt.GetPosition();
3074 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
3075 evt.ControlDown());
3076 }
3077
3078
3079 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
3080 wxPoint pt = evt.GetPosition();
3081 m_swx->DoContextMenu(Point(pt.x, pt.y));
3082 }
3083
3084
3085 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
3086 wxPoint pt = evt.GetPosition();
3087 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
3088 }
3089
3090 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
3091 wxPoint pt = evt.GetPosition();
3092 ScreenToClient(&pt.x, &pt.y);
3093 /*
3094 Show context menu at event point if it's within the window,
3095 or at caret location if not
3096 */
3097 wxHitTest ht = this->HitTest(pt);
3098 if (ht != wxHT_WINDOW_INSIDE) {
3099 pt = this->PointFromPosition(this->GetCurrentPos());
3100 }
3101 m_swx->DoContextMenu(Point(pt.x, pt.y));
3102 }
3103
3104
3105 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
3106 m_swx->DoMouseWheel(evt.GetWheelRotation(),
3107 evt.GetWheelDelta(),
3108 evt.GetLinesPerAction(),
3109 evt.ControlDown(),
3110 evt.IsPageScroll());
3111 }
3112
3113
3114 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
3115 // On (some?) non-US PC keyboards the AltGr key is required to enter some
3116 // common characters. It comes to us as both Alt and Ctrl down so we need
3117 // to let the char through in that case, otherwise if only ctrl or only
3118 // alt let's skip it.
3119 bool ctrl = evt.ControlDown();
3120 #ifdef __WXMAC__
3121 // On the Mac the Alt key is just a modifier key (like Shift) so we need
3122 // to allow the char events to be processed when Alt is pressed.
3123 // TODO: Should we check MetaDown instead in this case?
3124 bool alt = false;
3125 #else
3126 bool alt = evt.AltDown();
3127 #endif
3128 bool skip = ((ctrl || alt) && ! (ctrl && alt));
3129
3130 #if wxUSE_UNICODE
3131 // apparently if we don't do this, Unicode keys pressed after non-char
3132 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
3133 if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255)
3134 m_lastKeyDownConsumed = false;
3135 #endif
3136
3137 if (!m_lastKeyDownConsumed && !skip) {
3138 #if wxUSE_UNICODE
3139 int key = evt.GetUnicodeKey();
3140 bool keyOk = true;
3141
3142 // if the unicode key code is not really a unicode character (it may
3143 // be a function key or etc., the platforms appear to always give us a
3144 // small value in this case) then fallback to the ascii key code but
3145 // don't do anything for function keys or etc.
3146 if (key <= 127) {
3147 key = evt.GetKeyCode();
3148 keyOk = (key <= 127);
3149 }
3150 if (keyOk) {
3151 m_swx->DoAddChar(key);
3152 return;
3153 }
3154 #else
3155 int key = evt.GetKeyCode();
3156 if (key <= WXK_START || key > WXK_COMMAND) {
3157 m_swx->DoAddChar(key);
3158 return;
3159 }
3160 #endif
3161 }
3162
3163 evt.Skip();
3164 }
3165
3166
3167 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
3168 int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
3169 if (!processed && !m_lastKeyDownConsumed)
3170 evt.Skip();
3171 }
3172
3173
3174 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
3175 m_swx->DoLoseFocus();
3176 evt.Skip();
3177 }
3178
3179
3180 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
3181 m_swx->DoGainFocus();
3182 evt.Skip();
3183 }
3184
3185
3186 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
3187 m_swx->DoSysColourChange();
3188 }
3189
3190
3191 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
3192 // do nothing to help avoid flashing
3193 }
3194
3195
3196
3197 void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
3198 m_swx->DoCommand(evt.GetId());
3199 }
3200
3201
3202 void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
3203 m_swx->DoOnListBox();
3204 }
3205
3206
3207 void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
3208 m_swx->DoOnIdle(evt);
3209 }
3210
3211
3212 wxSize wxStyledTextCtrl::DoGetBestSize() const
3213 {
3214 // What would be the best size for a wxSTC?
3215 // Just give a reasonable minimum until something else can be figured out.
3216 return wxSize(200,100);
3217 }
3218
3219
3220 //----------------------------------------------------------------------
3221 // Turn notifications from Scintilla into events
3222
3223
3224 void wxStyledTextCtrl::NotifyChange() {
3225 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
3226 evt.SetEventObject(this);
3227 GetEventHandler()->ProcessEvent(evt);
3228 }
3229
3230
3231 static void SetEventText(wxStyledTextEvent& evt, const char* text,
3232 size_t length) {
3233 if(!text) return;
3234
3235 evt.SetText(stc2wx(text, length));
3236 }
3237
3238
3239 void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
3240 SCNotification& scn = *_scn;
3241 wxStyledTextEvent evt(0, GetId());
3242
3243 evt.SetEventObject(this);
3244 evt.SetPosition(scn.position);
3245 evt.SetKey(scn.ch);
3246 evt.SetModifiers(scn.modifiers);
3247
3248 switch (scn.nmhdr.code) {
3249 case SCN_STYLENEEDED:
3250 evt.SetEventType(wxEVT_STC_STYLENEEDED);
3251 break;
3252
3253 case SCN_CHARADDED:
3254 evt.SetEventType(wxEVT_STC_CHARADDED);
3255 break;
3256
3257 case SCN_SAVEPOINTREACHED:
3258 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
3259 break;
3260
3261 case SCN_SAVEPOINTLEFT:
3262 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
3263 break;
3264
3265 case SCN_MODIFYATTEMPTRO:
3266 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
3267 break;
3268
3269 case SCN_KEY:
3270 evt.SetEventType(wxEVT_STC_KEY);
3271 break;
3272
3273 case SCN_DOUBLECLICK:
3274 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
3275 break;
3276
3277 case SCN_UPDATEUI:
3278 evt.SetEventType(wxEVT_STC_UPDATEUI);
3279 break;
3280
3281 case SCN_MODIFIED:
3282 evt.SetEventType(wxEVT_STC_MODIFIED);
3283 evt.SetModificationType(scn.modificationType);
3284 SetEventText(evt, scn.text, scn.length);
3285 evt.SetLength(scn.length);
3286 evt.SetLinesAdded(scn.linesAdded);
3287 evt.SetLine(scn.line);
3288 evt.SetFoldLevelNow(scn.foldLevelNow);
3289 evt.SetFoldLevelPrev(scn.foldLevelPrev);
3290 break;
3291
3292 case SCN_MACRORECORD:
3293 evt.SetEventType(wxEVT_STC_MACRORECORD);
3294 evt.SetMessage(scn.message);
3295 evt.SetWParam(scn.wParam);
3296 evt.SetLParam(scn.lParam);
3297 break;
3298
3299 case SCN_MARGINCLICK:
3300 evt.SetEventType(wxEVT_STC_MARGINCLICK);
3301 evt.SetMargin(scn.margin);
3302 break;
3303
3304 case SCN_NEEDSHOWN:
3305 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
3306 evt.SetLength(scn.length);
3307 break;
3308
3309 case SCN_PAINTED:
3310 evt.SetEventType(wxEVT_STC_PAINTED);
3311 break;
3312
3313 case SCN_AUTOCSELECTION:
3314 evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION);
3315 evt.SetListType(scn.listType);
3316 SetEventText(evt, scn.text, strlen(scn.text));
3317 evt.SetPosition(scn.lParam);
3318 break;
3319
3320 case SCN_USERLISTSELECTION:
3321 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
3322 evt.SetListType(scn.listType);
3323 SetEventText(evt, scn.text, strlen(scn.text));
3324 evt.SetPosition(scn.lParam);
3325 break;
3326
3327 case SCN_URIDROPPED:
3328 evt.SetEventType(wxEVT_STC_URIDROPPED);
3329 SetEventText(evt, scn.text, strlen(scn.text));
3330 break;
3331
3332 case SCN_DWELLSTART:
3333 evt.SetEventType(wxEVT_STC_DWELLSTART);
3334 evt.SetX(scn.x);
3335 evt.SetY(scn.y);
3336 break;
3337
3338 case SCN_DWELLEND:
3339 evt.SetEventType(wxEVT_STC_DWELLEND);
3340 evt.SetX(scn.x);
3341 evt.SetY(scn.y);
3342 break;
3343
3344 case SCN_ZOOM:
3345 evt.SetEventType(wxEVT_STC_ZOOM);
3346 break;
3347
3348 case SCN_HOTSPOTCLICK:
3349 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
3350 break;
3351
3352 case SCN_HOTSPOTDOUBLECLICK:
3353 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
3354 break;
3355
3356 case SCN_CALLTIPCLICK:
3357 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
3358 break;
3359
3360 default:
3361 return;
3362 }
3363
3364 GetEventHandler()->ProcessEvent(evt);
3365 }
3366
3367
3368 //----------------------------------------------------------------------
3369 //----------------------------------------------------------------------
3370 //----------------------------------------------------------------------
3371
3372 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
3373 : wxCommandEvent(commandType, id)
3374 {
3375 m_position = 0;
3376 m_key = 0;
3377 m_modifiers = 0;
3378 m_modificationType = 0;
3379 m_length = 0;
3380 m_linesAdded = 0;
3381 m_line = 0;
3382 m_foldLevelNow = 0;
3383 m_foldLevelPrev = 0;
3384 m_margin = 0;
3385 m_message = 0;
3386 m_wParam = 0;
3387 m_lParam = 0;
3388 m_listType = 0;
3389 m_x = 0;
3390 m_y = 0;
3391 m_dragAllowMove = false;
3392 #if wxUSE_DRAG_AND_DROP
3393 m_dragResult = wxDragNone;
3394 #endif
3395 }
3396
3397 bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
3398 bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
3399 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
3400
3401
3402 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
3403 wxCommandEvent(event)
3404 {
3405 m_position = event.m_position;
3406 m_key = event.m_key;
3407 m_modifiers = event.m_modifiers;
3408 m_modificationType = event.m_modificationType;
3409 m_text = event.m_text;
3410 m_length = event.m_length;
3411 m_linesAdded = event.m_linesAdded;
3412 m_line = event.m_line;
3413 m_foldLevelNow = event.m_foldLevelNow;
3414 m_foldLevelPrev = event.m_foldLevelPrev;
3415
3416 m_margin = event.m_margin;
3417
3418 m_message = event.m_message;
3419 m_wParam = event.m_wParam;
3420 m_lParam = event.m_lParam;
3421
3422 m_listType = event.m_listType;
3423 m_x = event.m_x;
3424 m_y = event.m_y;
3425
3426 m_dragText = event.m_dragText;
3427 m_dragAllowMove =event.m_dragAllowMove;
3428 #if wxUSE_DRAG_AND_DROP
3429 m_dragResult = event.m_dragResult;
3430 #endif
3431 }
3432
3433 //----------------------------------------------------------------------
3434 //----------------------------------------------------------------------
3435
3436
3437
3438
3439
3440
3441
3442
3443