Update the wxVersionInfo, and don't forget to initialize the new attributes of the...
[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 licence
16 /////////////////////////////////////////////////////////////////////////////
17
18 /*
19 IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from
20 src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be
21 lost after the next regeneration, edit stc.cpp.in and rerun the
22 gen_iface.py script instead!
23
24 Parts of this file generated by the script are found in between
25 the special "{{{" and "}}}" markers, the rest of it is copied
26 verbatim from src.h.in.
27 */
28
29 // For compilers that support precompilation, includes "wx.h".
30 #include "wx/wxprec.h"
31
32 #ifdef __BORLANDC__
33 #pragma hdrstop
34 #endif
35
36 #if wxUSE_STC
37
38 #include "wx/stc/stc.h"
39 #include "wx/stc/private.h"
40
41 #ifndef WX_PRECOMP
42 #include "wx/wx.h"
43 #endif // WX_PRECOMP
44
45 #include <ctype.h>
46
47 #include "wx/tokenzr.h"
48 #include "wx/mstream.h"
49 #include "wx/image.h"
50 #include "wx/ffile.h"
51
52 #include "ScintillaWX.h"
53
54 //----------------------------------------------------------------------
55
56 const char wxSTCNameStr[] = "stcwindow";
57
58 #ifdef MAKELONG
59 #undef MAKELONG
60 #endif
61
62 #define MAKELONG(a, b) ((a) | ((b) << 16))
63
64
65 static long wxColourAsLong(const wxColour& co) {
66 return (((long)co.Blue() << 16) |
67 ((long)co.Green() << 8) |
68 ((long)co.Red()));
69 }
70
71 static wxColour wxColourFromLong(long c) {
72 wxColour clr;
73 clr.Set((unsigned char)(c & 0xff),
74 (unsigned char)((c >> 8) & 0xff),
75 (unsigned char)((c >> 16) & 0xff));
76 return clr;
77 }
78
79
80 static wxColour wxColourFromSpec(const wxString& spec) {
81 // spec should be a colour name or "#RRGGBB"
82 if (spec.GetChar(0) == wxT('#')) {
83
84 long red, green, blue;
85 red = green = blue = 0;
86 spec.Mid(1,2).ToLong(&red, 16);
87 spec.Mid(3,2).ToLong(&green, 16);
88 spec.Mid(5,2).ToLong(&blue, 16);
89 return wxColour((unsigned char)red,
90 (unsigned char)green,
91 (unsigned char)blue);
92 }
93 else
94 return wxColour(spec);
95 }
96
97 //----------------------------------------------------------------------
98
99 wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent );
100 wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent );
101 wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent );
102 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent );
103 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent );
104 wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent );
105 wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent );
106 wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent );
107 wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent );
108 wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent );
109 wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent );
110 wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent );
111 wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent );
112 wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent );
113 wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent );
114 wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent );
115 wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent );
116 wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent );
117 wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent );
118 wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent );
119 wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent );
120 wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent );
121 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent );
122 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent );
123 wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent );
124 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent );
125 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent );
126 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent );
127 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent );
128 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent );
129 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent );
130
131
132
133 BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
134 EVT_PAINT (wxStyledTextCtrl::OnPaint)
135 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
136 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
137 EVT_SIZE (wxStyledTextCtrl::OnSize)
138 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
139 // Let Scintilla see the double click as a second click
140 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
141 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
142 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
143 #if defined(__WXGTK__) || defined(__WXMAC__)
144 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
145 #else
146 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
147 #endif
148 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
149 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
150 EVT_CHAR (wxStyledTextCtrl::OnChar)
151 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
152 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
153 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
154 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
155 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
156 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
157 EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
158 END_EVENT_TABLE()
159
160
161 IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
162 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
163
164 #ifdef LINK_LEXERS
165 // forces the linking of the lexer modules
166 int Scintilla_LinkLexers();
167 #endif
168
169 //----------------------------------------------------------------------
170 // Constructor and Destructor
171
172 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
173 wxWindowID id,
174 const wxPoint& pos,
175 const wxSize& size,
176 long style,
177 const wxString& name)
178 {
179 m_swx = NULL;
180 Create(parent, id, pos, size, style, name);
181 }
182
183
184 bool wxStyledTextCtrl::Create(wxWindow *parent,
185 wxWindowID id,
186 const wxPoint& pos,
187 const wxSize& size,
188 long style,
189 const wxString& name)
190 {
191 style |= wxVSCROLL | wxHSCROLL;
192 if (!wxControl::Create(parent, id, pos, size,
193 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
194 wxDefaultValidator, name))
195 return false;
196
197 #ifdef LINK_LEXERS
198 Scintilla_LinkLexers();
199 #endif
200 m_swx = new ScintillaWX(this);
201 m_stopWatch.Start();
202 m_lastKeyDownConsumed = false;
203 m_vScrollBar = NULL;
204 m_hScrollBar = NULL;
205 #if wxUSE_UNICODE
206 // Put Scintilla into unicode (UTF-8) mode
207 SetCodePage(wxSTC_CP_UTF8);
208 #endif
209
210 SetInitialSize(size);
211
212 // Reduces flicker on GTK+/X11
213 SetBackgroundStyle(wxBG_STYLE_PAINT);
214
215 // Make sure it can take the focus
216 SetCanFocus(true);
217
218 return true;
219 }
220
221
222 wxStyledTextCtrl::~wxStyledTextCtrl() {
223 delete m_swx;
224 }
225
226
227 //----------------------------------------------------------------------
228
229 wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const
230 {
231 return m_swx->WndProc(msg, wp, lp);
232 }
233
234 //----------------------------------------------------------------------
235
236 // Set the vertical scrollbar to use instead of the ont that's built-in.
237 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
238 m_vScrollBar = bar;
239 if (bar != NULL) {
240 // ensure that the built-in scrollbar is not visible
241 SetScrollbar(wxVERTICAL, 0, 0, 0);
242 }
243 }
244
245
246 // Set the horizontal scrollbar to use instead of the ont that's built-in.
247 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
248 m_hScrollBar = bar;
249 if (bar != NULL) {
250 // ensure that the built-in scrollbar is not visible
251 SetScrollbar(wxHORIZONTAL, 0, 0, 0);
252 }
253 }
254
255 //----------------------------------------------------------------------
256 // Generated methods implementation section {{{
257
258
259 // Add text to the document at current position.
260 void wxStyledTextCtrl::AddText(const wxString& text) {
261 const wxWX2MBbuf buf = wx2stc(text);
262 SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf);
263 }
264
265 // Add array of cells to document.
266 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
267 SendMsg(2002, data.GetDataLen(), (sptr_t)data.GetData());
268 }
269
270 // Insert string at a position.
271 void wxStyledTextCtrl::InsertText(int pos, const wxString& text)
272 {
273 SendMsg(2003, pos, (sptr_t)(const char*)wx2stc(text));
274 }
275
276 // Delete all text in the document.
277 void wxStyledTextCtrl::ClearAll()
278 {
279 SendMsg(2004, 0, 0);
280 }
281
282 // Delete a range of text in the document.
283 void wxStyledTextCtrl::DeleteRange(int pos, int deleteLength)
284 {
285 SendMsg(2645, pos, deleteLength);
286 }
287
288 // Set all style bytes to 0, remove all folding information.
289 void wxStyledTextCtrl::ClearDocumentStyle()
290 {
291 SendMsg(2005, 0, 0);
292 }
293
294 // Returns the number of bytes in the document.
295 int wxStyledTextCtrl::GetLength() const
296 {
297 return SendMsg(2006, 0, 0);
298 }
299
300 // Returns the character byte at the position.
301 int wxStyledTextCtrl::GetCharAt(int pos) const {
302 return (unsigned char)SendMsg(2007, pos, 0);
303 }
304
305 // Returns the position of the caret.
306 int wxStyledTextCtrl::GetCurrentPos() const
307 {
308 return SendMsg(2008, 0, 0);
309 }
310
311 // Returns the position of the opposite end of the selection to the caret.
312 int wxStyledTextCtrl::GetAnchor() const
313 {
314 return SendMsg(2009, 0, 0);
315 }
316
317 // Returns the style byte at the position.
318 int wxStyledTextCtrl::GetStyleAt(int pos) const {
319 return (unsigned char)SendMsg(2010, pos, 0);
320 }
321
322 // Redoes the next action on the undo history.
323 void wxStyledTextCtrl::Redo()
324 {
325 SendMsg(2011, 0, 0);
326 }
327
328 // Choose between collecting actions into the undo
329 // history and discarding them.
330 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo)
331 {
332 SendMsg(2012, collectUndo, 0);
333 }
334
335 // Select all the text in the document.
336 void wxStyledTextCtrl::SelectAll()
337 {
338 SendMsg(2013, 0, 0);
339 }
340
341 // Remember the current position in the undo history as the position
342 // at which the document was saved.
343 void wxStyledTextCtrl::SetSavePoint()
344 {
345 SendMsg(2014, 0, 0);
346 }
347
348 // Retrieve a buffer of cells.
349 wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
350 wxMemoryBuffer buf;
351 if (endPos < startPos) {
352 int temp = startPos;
353 startPos = endPos;
354 endPos = temp;
355 }
356 int len = endPos - startPos;
357 if (!len) return buf;
358 TextRange tr;
359 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
360 tr.chrg.cpMin = startPos;
361 tr.chrg.cpMax = endPos;
362 len = SendMsg(2015, 0, (sptr_t)&tr);
363 buf.UngetWriteBuf(len);
364 return buf;
365 }
366
367 // Are there any redoable actions in the undo history?
368 bool wxStyledTextCtrl::CanRedo() const
369 {
370 return SendMsg(2016, 0, 0) != 0;
371 }
372
373 // Retrieve the line number at which a particular marker is located.
374 int wxStyledTextCtrl::MarkerLineFromHandle(int handle)
375 {
376 return SendMsg(2017, handle, 0);
377 }
378
379 // Delete a marker.
380 void wxStyledTextCtrl::MarkerDeleteHandle(int handle)
381 {
382 SendMsg(2018, handle, 0);
383 }
384
385 // Is undo history being collected?
386 bool wxStyledTextCtrl::GetUndoCollection() const
387 {
388 return SendMsg(2019, 0, 0) != 0;
389 }
390
391 // Are white space characters currently visible?
392 // Returns one of SCWS_* constants.
393 int wxStyledTextCtrl::GetViewWhiteSpace() const
394 {
395 return SendMsg(2020, 0, 0);
396 }
397
398 // Make white space characters invisible, always visible or visible outside indentation.
399 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS)
400 {
401 SendMsg(2021, viewWS, 0);
402 }
403
404 // Find the position from a point within the window.
405 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const {
406 return SendMsg(2022, pt.x, pt.y);
407 }
408
409 // Find the position from a point within the window but return
410 // INVALID_POSITION if not close to text.
411 int wxStyledTextCtrl::PositionFromPointClose(int x, int y)
412 {
413 return SendMsg(2023, x, y);
414 }
415
416 // Set caret to start of a line and ensure it is visible.
417 void wxStyledTextCtrl::GotoLine(int line)
418 {
419 SendMsg(2024, line, 0);
420 }
421
422 // Set caret to a position and ensure it is visible.
423 void wxStyledTextCtrl::GotoPos(int pos)
424 {
425 SendMsg(2025, pos, 0);
426 }
427
428 // Set the selection anchor to a position. The anchor is the opposite
429 // end of the selection from the caret.
430 void wxStyledTextCtrl::SetAnchor(int posAnchor)
431 {
432 SendMsg(2026, posAnchor, 0);
433 }
434
435 // Retrieve the text of the line containing the caret.
436 // Returns the index of the caret on the line.
437 wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
438 int len = LineLength(GetCurrentLine());
439 if (!len) {
440 if (linePos) *linePos = 0;
441 return wxEmptyString;
442 }
443
444 wxMemoryBuffer mbuf(len+1);
445 char* buf = (char*)mbuf.GetWriteBuf(len+1);
446
447 int pos = SendMsg(2027, len+1, (sptr_t)buf);
448 mbuf.UngetWriteBuf(len);
449 mbuf.AppendByte(0);
450 if (linePos) *linePos = pos;
451 return stc2wx(buf);
452 }
453
454 // Retrieve the position of the last correctly styled character.
455 int wxStyledTextCtrl::GetEndStyled() const
456 {
457 return SendMsg(2028, 0, 0);
458 }
459
460 // Convert all line endings in the document to one mode.
461 void wxStyledTextCtrl::ConvertEOLs(int eolMode)
462 {
463 SendMsg(2029, eolMode, 0);
464 }
465
466 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
467 int wxStyledTextCtrl::GetEOLMode() const
468 {
469 return SendMsg(2030, 0, 0);
470 }
471
472 // Set the current end of line mode.
473 void wxStyledTextCtrl::SetEOLMode(int eolMode)
474 {
475 SendMsg(2031, eolMode, 0);
476 }
477
478 // Set the current styling position to pos and the styling mask to mask.
479 // The styling mask can be used to protect some bits in each styling byte from modification.
480 void wxStyledTextCtrl::StartStyling(int pos, int mask)
481 {
482 SendMsg(2032, pos, mask);
483 }
484
485 // Change style from current styling position for length characters to a style
486 // and move the current styling position to after this newly styled segment.
487 void wxStyledTextCtrl::SetStyling(int length, int style)
488 {
489 SendMsg(2033, length, style);
490 }
491
492 // Is drawing done first into a buffer or direct to the screen?
493 bool wxStyledTextCtrl::GetBufferedDraw() const
494 {
495 return SendMsg(2034, 0, 0) != 0;
496 }
497
498 // If drawing is buffered then each line of text is drawn into a bitmap buffer
499 // before drawing it to the screen to avoid flicker.
500 void wxStyledTextCtrl::SetBufferedDraw(bool buffered)
501 {
502 SendMsg(2035, buffered, 0);
503 }
504
505 // Change the visible size of a tab to be a multiple of the width of a space character.
506 void wxStyledTextCtrl::SetTabWidth(int tabWidth)
507 {
508 SendMsg(2036, tabWidth, 0);
509 }
510
511 // Retrieve the visible size of a tab.
512 int wxStyledTextCtrl::GetTabWidth() const
513 {
514 return SendMsg(2121, 0, 0);
515 }
516
517 // Set the code page used to interpret the bytes of the document as characters.
518 void wxStyledTextCtrl::SetCodePage(int codePage) {
519 #if wxUSE_UNICODE
520 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
521 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
522 #else
523 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
524 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
525 #endif
526 SendMsg(2037, codePage);
527 }
528
529 // Set the symbol used for a particular marker number,
530 // and optionally the fore and background colours.
531 void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
532 const wxColour& foreground,
533 const wxColour& background) {
534
535 SendMsg(2040, markerNumber, markerSymbol);
536 if (foreground.IsOk())
537 MarkerSetForeground(markerNumber, foreground);
538 if (background.IsOk())
539 MarkerSetBackground(markerNumber, background);
540 }
541
542 // Set the foreground colour used for a particular marker number.
543 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore)
544 {
545 SendMsg(2041, markerNumber, wxColourAsLong(fore));
546 }
547
548 // Set the background colour used for a particular marker number.
549 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back)
550 {
551 SendMsg(2042, markerNumber, wxColourAsLong(back));
552 }
553
554 // Set the background colour used for a particular marker number when its folding block is selected.
555 void wxStyledTextCtrl::MarkerSetBackgroundSelected(int markerNumber, const wxColour& back)
556 {
557 SendMsg(2292, markerNumber, wxColourAsLong(back));
558 }
559
560 // Enable/disable highlight for current folding bloc (smallest one that contains the caret)
561 void wxStyledTextCtrl::MarkerEnableHighlight(bool enabled)
562 {
563 SendMsg(2293, enabled, 0);
564 }
565
566 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
567 int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber)
568 {
569 return SendMsg(2043, line, markerNumber);
570 }
571
572 // Delete a marker from a line.
573 void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber)
574 {
575 SendMsg(2044, line, markerNumber);
576 }
577
578 // Delete all markers with a particular number from all lines.
579 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber)
580 {
581 SendMsg(2045, markerNumber, 0);
582 }
583
584 // Get a bit mask of all the markers set on a line.
585 int wxStyledTextCtrl::MarkerGet(int line)
586 {
587 return SendMsg(2046, line, 0);
588 }
589
590 // Find the next line at or after lineStart that includes a marker in mask.
591 // Return -1 when no more lines.
592 int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask)
593 {
594 return SendMsg(2047, lineStart, markerMask);
595 }
596
597 // Find the previous line before lineStart that includes a marker in mask.
598 int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask)
599 {
600 return SendMsg(2048, lineStart, markerMask);
601 }
602
603 // Define a marker from a bitmap
604 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
605 // convert bmp to a xpm in a string
606 wxMemoryOutputStream strm;
607 wxImage img = bmp.ConvertToImage();
608 if (img.HasAlpha())
609 img.ConvertAlphaToMask();
610 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
611 size_t len = strm.GetSize();
612 char* buff = new char[len+1];
613 strm.CopyTo(buff, len);
614 buff[len] = 0;
615 SendMsg(2049, markerNumber, (sptr_t)buff);
616 delete [] buff;
617
618 }
619
620 // Add a set of markers to a line.
621 void wxStyledTextCtrl::MarkerAddSet(int line, int set)
622 {
623 SendMsg(2466, line, set);
624 }
625
626 // Set the alpha used for a marker that is drawn in the text area, not the margin.
627 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha)
628 {
629 SendMsg(2476, markerNumber, alpha);
630 }
631
632 // Set a margin to be either numeric or symbolic.
633 void wxStyledTextCtrl::SetMarginType(int margin, int marginType)
634 {
635 SendMsg(2240, margin, marginType);
636 }
637
638 // Retrieve the type of a margin.
639 int wxStyledTextCtrl::GetMarginType(int margin) const
640 {
641 return SendMsg(2241, margin, 0);
642 }
643
644 // Set the width of a margin to a width expressed in pixels.
645 void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth)
646 {
647 SendMsg(2242, margin, pixelWidth);
648 }
649
650 // Retrieve the width of a margin in pixels.
651 int wxStyledTextCtrl::GetMarginWidth(int margin) const
652 {
653 return SendMsg(2243, margin, 0);
654 }
655
656 // Set a mask that determines which markers are displayed in a margin.
657 void wxStyledTextCtrl::SetMarginMask(int margin, int mask)
658 {
659 SendMsg(2244, margin, mask);
660 }
661
662 // Retrieve the marker mask of a margin.
663 int wxStyledTextCtrl::GetMarginMask(int margin) const
664 {
665 return SendMsg(2245, margin, 0);
666 }
667
668 // Make a margin sensitive or insensitive to mouse clicks.
669 void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive)
670 {
671 SendMsg(2246, margin, sensitive);
672 }
673
674 // Retrieve the mouse click sensitivity of a margin.
675 bool wxStyledTextCtrl::GetMarginSensitive(int margin) const
676 {
677 return SendMsg(2247, margin, 0) != 0;
678 }
679
680 // Set the cursor shown when the mouse is inside a margin.
681 void wxStyledTextCtrl::SetMarginCursor(int margin, int cursor)
682 {
683 SendMsg(2248, margin, cursor);
684 }
685
686 // Retrieve the cursor shown in a margin.
687 int wxStyledTextCtrl::GetMarginCursor(int margin) const
688 {
689 return SendMsg(2249, margin, 0);
690 }
691
692 // Clear all the styles and make equivalent to the global default style.
693 void wxStyledTextCtrl::StyleClearAll()
694 {
695 SendMsg(2050, 0, 0);
696 }
697
698 // Set the foreground colour of a style.
699 void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore)
700 {
701 SendMsg(2051, style, wxColourAsLong(fore));
702 }
703
704 // Set the background colour of a style.
705 void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back)
706 {
707 SendMsg(2052, style, wxColourAsLong(back));
708 }
709
710 // Set a style to be bold or not.
711 void wxStyledTextCtrl::StyleSetBold(int style, bool bold)
712 {
713 SendMsg(2053, style, bold);
714 }
715
716 // Set a style to be italic or not.
717 void wxStyledTextCtrl::StyleSetItalic(int style, bool italic)
718 {
719 SendMsg(2054, style, italic);
720 }
721
722 // Set the size of characters of a style.
723 void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints)
724 {
725 SendMsg(2055, style, sizePoints);
726 }
727
728 // Set the font of a style.
729 void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName)
730 {
731 SendMsg(2056, style, (sptr_t)(const char*)wx2stc(fontName));
732 }
733
734 // Set a style to have its end of line filled or not.
735 void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled)
736 {
737 SendMsg(2057, style, filled);
738 }
739
740 // Reset the default style to its state at startup
741 void wxStyledTextCtrl::StyleResetDefault()
742 {
743 SendMsg(2058, 0, 0);
744 }
745
746 // Set a style to be underlined or not.
747 void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline)
748 {
749 SendMsg(2059, style, underline);
750 }
751
752 // Get the foreground colour of a style.
753 wxColour wxStyledTextCtrl::StyleGetForeground(int style) const
754 {
755 long c = SendMsg(2481, style, 0);
756 return wxColourFromLong(c);
757 }
758
759 // Get the background colour of a style.
760 wxColour wxStyledTextCtrl::StyleGetBackground(int style) const
761 {
762 long c = SendMsg(2482, style, 0);
763 return wxColourFromLong(c);
764 }
765
766 // Get is a style bold or not.
767 bool wxStyledTextCtrl::StyleGetBold(int style) const
768 {
769 return SendMsg(2483, style, 0) != 0;
770 }
771
772 // Get is a style italic or not.
773 bool wxStyledTextCtrl::StyleGetItalic(int style) const
774 {
775 return SendMsg(2484, style, 0) != 0;
776 }
777
778 // Get the size of characters of a style.
779 int wxStyledTextCtrl::StyleGetSize(int style) const
780 {
781 return SendMsg(2485, style, 0);
782 }
783
784 // Get the font facename of a style
785 wxString wxStyledTextCtrl::StyleGetFaceName(int style) {
786 long msg = 2486;
787 long len = SendMsg(msg, style, 0);
788 wxMemoryBuffer mbuf(len+1);
789 char* buf = (char*)mbuf.GetWriteBuf(len+1);
790 SendMsg(msg, style, (sptr_t)buf);
791 mbuf.UngetWriteBuf(len);
792 mbuf.AppendByte(0);
793 return stc2wx(buf);
794 }
795
796 // Get is a style to have its end of line filled or not.
797 bool wxStyledTextCtrl::StyleGetEOLFilled(int style) const
798 {
799 return SendMsg(2487, style, 0) != 0;
800 }
801
802 // Get is a style underlined or not.
803 bool wxStyledTextCtrl::StyleGetUnderline(int style) const
804 {
805 return SendMsg(2488, style, 0) != 0;
806 }
807
808 // Get is a style mixed case, or to force upper or lower case.
809 int wxStyledTextCtrl::StyleGetCase(int style) const
810 {
811 return SendMsg(2489, style, 0);
812 }
813
814 // Get the character set of the font in a style.
815 int wxStyledTextCtrl::StyleGetCharacterSet(int style) const
816 {
817 return SendMsg(2490, style, 0);
818 }
819
820 // Get is a style visible or not.
821 bool wxStyledTextCtrl::StyleGetVisible(int style) const
822 {
823 return SendMsg(2491, style, 0) != 0;
824 }
825
826 // Get is a style changeable or not (read only).
827 // Experimental feature, currently buggy.
828 bool wxStyledTextCtrl::StyleGetChangeable(int style) const
829 {
830 return SendMsg(2492, style, 0) != 0;
831 }
832
833 // Get is a style a hotspot or not.
834 bool wxStyledTextCtrl::StyleGetHotSpot(int style) const
835 {
836 return SendMsg(2493, style, 0) != 0;
837 }
838
839 // Set a style to be mixed case, or to force upper or lower case.
840 void wxStyledTextCtrl::StyleSetCase(int style, int caseForce)
841 {
842 SendMsg(2060, style, caseForce);
843 }
844
845 // Set the size of characters of a style. Size is in points multiplied by 100.
846 void wxStyledTextCtrl::StyleSetSizeFractional(int style, int caseForce)
847 {
848 SendMsg(2061, style, caseForce);
849 }
850
851 // Get the size of characters of a style in points multiplied by 100
852 int wxStyledTextCtrl::StyleGetSizeFractional(int style) const
853 {
854 return SendMsg(2062, style, 0);
855 }
856
857 // Set the weight of characters of a style.
858 void wxStyledTextCtrl::StyleSetWeight(int style, int weight)
859 {
860 SendMsg(2063, style, weight);
861 }
862
863 // Get the weight of characters of a style.
864 int wxStyledTextCtrl::StyleGetWeight(int style) const
865 {
866 return SendMsg(2064, style, 0);
867 }
868
869 // Set a style to be a hotspot or not.
870 void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot)
871 {
872 SendMsg(2409, style, hotspot);
873 }
874
875 // Set the foreground colour of the main and additional selections and whether to use this setting.
876 void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore)
877 {
878 SendMsg(2067, useSetting, wxColourAsLong(fore));
879 }
880
881 // Set the background colour of the main and additional selections and whether to use this setting.
882 void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back)
883 {
884 SendMsg(2068, useSetting, wxColourAsLong(back));
885 }
886
887 // Get the alpha of the selection.
888 int wxStyledTextCtrl::GetSelAlpha() const
889 {
890 return SendMsg(2477, 0, 0);
891 }
892
893 // Set the alpha of the selection.
894 void wxStyledTextCtrl::SetSelAlpha(int alpha)
895 {
896 SendMsg(2478, alpha, 0);
897 }
898
899 // Is the selection end of line filled?
900 bool wxStyledTextCtrl::GetSelEOLFilled() const
901 {
902 return SendMsg(2479, 0, 0) != 0;
903 }
904
905 // Set the selection to have its end of line filled or not.
906 void wxStyledTextCtrl::SetSelEOLFilled(bool filled)
907 {
908 SendMsg(2480, filled, 0);
909 }
910
911 // Set the foreground colour of the caret.
912 void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore)
913 {
914 SendMsg(2069, wxColourAsLong(fore), 0);
915 }
916
917 // When key+modifier combination km is pressed perform msg.
918 void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
919 SendMsg(2070, MAKELONG(key, modifiers), cmd);
920 }
921
922 // When key+modifier combination km is pressed do nothing.
923 void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
924 SendMsg(2071, MAKELONG(key, modifiers));
925 }
926
927 // Drop all key mappings.
928 void wxStyledTextCtrl::CmdKeyClearAll()
929 {
930 SendMsg(2072, 0, 0);
931 }
932
933 // Set the styles for a segment of the document.
934 void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
935 SendMsg(2073, length, (sptr_t)styleBytes);
936 }
937
938 // Set a style to be visible or not.
939 void wxStyledTextCtrl::StyleSetVisible(int style, bool visible)
940 {
941 SendMsg(2074, style, visible);
942 }
943
944 // Get the time in milliseconds that the caret is on and off.
945 int wxStyledTextCtrl::GetCaretPeriod() const
946 {
947 return SendMsg(2075, 0, 0);
948 }
949
950 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
951 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds)
952 {
953 SendMsg(2076, periodMilliseconds, 0);
954 }
955
956 // Set the set of characters making up words for when moving or selecting by word.
957 // First sets defaults like SetCharsDefault.
958 void wxStyledTextCtrl::SetWordChars(const wxString& characters)
959 {
960 SendMsg(2077, 0, (sptr_t)(const char*)wx2stc(characters));
961 }
962
963 // Get the set of characters making up words for when moving or selecting by word.
964 wxString wxStyledTextCtrl::GetWordChars() const {
965 int msg = 2646;
966 int len = SendMsg(msg, 0, NULL);
967 if (!len) return wxEmptyString;
968
969 wxMemoryBuffer mbuf(len+1);
970 char* buf = (char*)mbuf.GetWriteBuf(len+1);
971 SendMsg(msg, 0, (sptr_t)buf);
972 mbuf.UngetWriteBuf(len);
973 mbuf.AppendByte(0);
974 return stc2wx(buf);
975 }
976
977 // Start a sequence of actions that is undone and redone as a unit.
978 // May be nested.
979 void wxStyledTextCtrl::BeginUndoAction()
980 {
981 SendMsg(2078, 0, 0);
982 }
983
984 // End a sequence of actions that is undone and redone as a unit.
985 void wxStyledTextCtrl::EndUndoAction()
986 {
987 SendMsg(2079, 0, 0);
988 }
989
990 // Set an indicator to plain, squiggle or TT.
991 void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style)
992 {
993 SendMsg(2080, indic, style);
994 }
995
996 // Retrieve the style of an indicator.
997 int wxStyledTextCtrl::IndicatorGetStyle(int indic) const
998 {
999 return SendMsg(2081, indic, 0);
1000 }
1001
1002 // Set the foreground colour of an indicator.
1003 void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore)
1004 {
1005 SendMsg(2082, indic, wxColourAsLong(fore));
1006 }
1007
1008 // Retrieve the foreground colour of an indicator.
1009 wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) const
1010 {
1011 long c = SendMsg(2083, indic, 0);
1012 return wxColourFromLong(c);
1013 }
1014
1015 // Set an indicator to draw under text or over(default).
1016 void wxStyledTextCtrl::IndicatorSetUnder(int indic, bool under)
1017 {
1018 SendMsg(2510, indic, under);
1019 }
1020
1021 // Retrieve whether indicator drawn under or over text.
1022 bool wxStyledTextCtrl::IndicatorGetUnder(int indic) const
1023 {
1024 return SendMsg(2511, indic, 0) != 0;
1025 }
1026
1027 // Set the foreground colour of all whitespace and whether to use this setting.
1028 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore)
1029 {
1030 SendMsg(2084, useSetting, wxColourAsLong(fore));
1031 }
1032
1033 // Set the background colour of all whitespace and whether to use this setting.
1034 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back)
1035 {
1036 SendMsg(2085, useSetting, wxColourAsLong(back));
1037 }
1038
1039 // Set the size of the dots used to mark space characters.
1040 void wxStyledTextCtrl::SetWhitespaceSize(int size)
1041 {
1042 SendMsg(2086, size, 0);
1043 }
1044
1045 // Get the size of the dots used to mark space characters.
1046 int wxStyledTextCtrl::GetWhitespaceSize() const
1047 {
1048 return SendMsg(2087, 0, 0);
1049 }
1050
1051 // Divide each styling byte into lexical class bits (default: 5) and indicator
1052 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
1053 // is used to expand the possible states.
1054 void wxStyledTextCtrl::SetStyleBits(int bits)
1055 {
1056 SendMsg(2090, bits, 0);
1057 }
1058
1059 // Retrieve number of bits in style bytes used to hold the lexical state.
1060 int wxStyledTextCtrl::GetStyleBits() const
1061 {
1062 return SendMsg(2091, 0, 0);
1063 }
1064
1065 // Used to hold extra styling information for each line.
1066 void wxStyledTextCtrl::SetLineState(int line, int state)
1067 {
1068 SendMsg(2092, line, state);
1069 }
1070
1071 // Retrieve the extra styling information for a line.
1072 int wxStyledTextCtrl::GetLineState(int line) const
1073 {
1074 return SendMsg(2093, line, 0);
1075 }
1076
1077 // Retrieve the last line number that has line state.
1078 int wxStyledTextCtrl::GetMaxLineState() const
1079 {
1080 return SendMsg(2094, 0, 0);
1081 }
1082
1083 // Is the background of the line containing the caret in a different colour?
1084 bool wxStyledTextCtrl::GetCaretLineVisible() const
1085 {
1086 return SendMsg(2095, 0, 0) != 0;
1087 }
1088
1089 // Display the background of the line containing the caret in a different colour.
1090 void wxStyledTextCtrl::SetCaretLineVisible(bool show)
1091 {
1092 SendMsg(2096, show, 0);
1093 }
1094
1095 // Get the colour of the background of the line containing the caret.
1096 wxColour wxStyledTextCtrl::GetCaretLineBackground() const
1097 {
1098 long c = SendMsg(2097, 0, 0);
1099 return wxColourFromLong(c);
1100 }
1101
1102 // Set the colour of the background of the line containing the caret.
1103 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back)
1104 {
1105 SendMsg(2098, wxColourAsLong(back), 0);
1106 }
1107
1108 // Set a style to be changeable or not (read only).
1109 // Experimental feature, currently buggy.
1110 void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable)
1111 {
1112 SendMsg(2099, style, changeable);
1113 }
1114
1115 // Display a auto-completion list.
1116 // The lenEntered parameter indicates how many characters before
1117 // the caret should be used to provide context.
1118 void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList)
1119 {
1120 SendMsg(2100, lenEntered, (sptr_t)(const char*)wx2stc(itemList));
1121 }
1122
1123 // Remove the auto-completion list from the screen.
1124 void wxStyledTextCtrl::AutoCompCancel()
1125 {
1126 SendMsg(2101, 0, 0);
1127 }
1128
1129 // Is there an auto-completion list visible?
1130 bool wxStyledTextCtrl::AutoCompActive()
1131 {
1132 return SendMsg(2102, 0, 0) != 0;
1133 }
1134
1135 // Retrieve the position of the caret when the auto-completion list was displayed.
1136 int wxStyledTextCtrl::AutoCompPosStart()
1137 {
1138 return SendMsg(2103, 0, 0);
1139 }
1140
1141 // User has selected an item so remove the list and insert the selection.
1142 void wxStyledTextCtrl::AutoCompComplete()
1143 {
1144 SendMsg(2104, 0, 0);
1145 }
1146
1147 // Define a set of character that when typed cancel the auto-completion list.
1148 void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet)
1149 {
1150 SendMsg(2105, 0, (sptr_t)(const char*)wx2stc(characterSet));
1151 }
1152
1153 // Change the separator character in the string setting up an auto-completion list.
1154 // Default is space but can be changed if items contain space.
1155 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter)
1156 {
1157 SendMsg(2106, separatorCharacter, 0);
1158 }
1159
1160 // Retrieve the auto-completion list separator character.
1161 int wxStyledTextCtrl::AutoCompGetSeparator() const
1162 {
1163 return SendMsg(2107, 0, 0);
1164 }
1165
1166 // Select the item in the auto-completion list that starts with a string.
1167 void wxStyledTextCtrl::AutoCompSelect(const wxString& text)
1168 {
1169 SendMsg(2108, 0, (sptr_t)(const char*)wx2stc(text));
1170 }
1171
1172 // Should the auto-completion list be cancelled if the user backspaces to a
1173 // position before where the box was created.
1174 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel)
1175 {
1176 SendMsg(2110, cancel, 0);
1177 }
1178
1179 // Retrieve whether auto-completion cancelled by backspacing before start.
1180 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() const
1181 {
1182 return SendMsg(2111, 0, 0) != 0;
1183 }
1184
1185 // Define a set of characters that when typed will cause the autocompletion to
1186 // choose the selected item.
1187 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet)
1188 {
1189 SendMsg(2112, 0, (sptr_t)(const char*)wx2stc(characterSet));
1190 }
1191
1192 // Should a single item auto-completion list automatically choose the item.
1193 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle)
1194 {
1195 SendMsg(2113, chooseSingle, 0);
1196 }
1197
1198 // Retrieve whether a single item auto-completion list automatically choose the item.
1199 bool wxStyledTextCtrl::AutoCompGetChooseSingle() const
1200 {
1201 return SendMsg(2114, 0, 0) != 0;
1202 }
1203
1204 // Set whether case is significant when performing auto-completion searches.
1205 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase)
1206 {
1207 SendMsg(2115, ignoreCase, 0);
1208 }
1209
1210 // Retrieve state of ignore case flag.
1211 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() const
1212 {
1213 return SendMsg(2116, 0, 0) != 0;
1214 }
1215
1216 // Display a list of strings and send notification when user chooses one.
1217 void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList)
1218 {
1219 SendMsg(2117, listType, (sptr_t)(const char*)wx2stc(itemList));
1220 }
1221
1222 // Set whether or not autocompletion is hidden automatically when nothing matches.
1223 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide)
1224 {
1225 SendMsg(2118, autoHide, 0);
1226 }
1227
1228 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
1229 bool wxStyledTextCtrl::AutoCompGetAutoHide() const
1230 {
1231 return SendMsg(2119, 0, 0) != 0;
1232 }
1233
1234 // Set whether or not autocompletion deletes any word characters
1235 // after the inserted text upon completion.
1236 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord)
1237 {
1238 SendMsg(2270, dropRestOfWord, 0);
1239 }
1240
1241 // Retrieve whether or not autocompletion deletes any word characters
1242 // after the inserted text upon completion.
1243 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() const
1244 {
1245 return SendMsg(2271, 0, 0) != 0;
1246 }
1247
1248 // Register an image for use in autocompletion lists.
1249 void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
1250 // convert bmp to a xpm in a string
1251 wxMemoryOutputStream strm;
1252 wxImage img = bmp.ConvertToImage();
1253 if (img.HasAlpha())
1254 img.ConvertAlphaToMask();
1255 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
1256 size_t len = strm.GetSize();
1257 char* buff = new char[len+1];
1258 strm.CopyTo(buff, len);
1259 buff[len] = 0;
1260 SendMsg(2405, type, (sptr_t)buff);
1261 delete [] buff;
1262
1263 }
1264
1265 // Clear all the registered images.
1266 void wxStyledTextCtrl::ClearRegisteredImages()
1267 {
1268 SendMsg(2408, 0, 0);
1269 }
1270
1271 // Retrieve the auto-completion list type-separator character.
1272 int wxStyledTextCtrl::AutoCompGetTypeSeparator() const
1273 {
1274 return SendMsg(2285, 0, 0);
1275 }
1276
1277 // Change the type-separator character in the string setting up an auto-completion list.
1278 // Default is '?' but can be changed if items contain '?'.
1279 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter)
1280 {
1281 SendMsg(2286, separatorCharacter, 0);
1282 }
1283
1284 // Set the maximum width, in characters, of auto-completion and user lists.
1285 // Set to 0 to autosize to fit longest item, which is the default.
1286 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount)
1287 {
1288 SendMsg(2208, characterCount, 0);
1289 }
1290
1291 // Get the maximum width, in characters, of auto-completion and user lists.
1292 int wxStyledTextCtrl::AutoCompGetMaxWidth() const
1293 {
1294 return SendMsg(2209, 0, 0);
1295 }
1296
1297 // Set the maximum height, in rows, of auto-completion and user lists.
1298 // The default is 5 rows.
1299 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount)
1300 {
1301 SendMsg(2210, rowCount, 0);
1302 }
1303
1304 // Set the maximum height, in rows, of auto-completion and user lists.
1305 int wxStyledTextCtrl::AutoCompGetMaxHeight() const
1306 {
1307 return SendMsg(2211, 0, 0);
1308 }
1309
1310 // Set the number of spaces used for one level of indentation.
1311 void wxStyledTextCtrl::SetIndent(int indentSize)
1312 {
1313 SendMsg(2122, indentSize, 0);
1314 }
1315
1316 // Retrieve indentation size.
1317 int wxStyledTextCtrl::GetIndent() const
1318 {
1319 return SendMsg(2123, 0, 0);
1320 }
1321
1322 // Indentation will only use space characters if useTabs is false, otherwise
1323 // it will use a combination of tabs and spaces.
1324 void wxStyledTextCtrl::SetUseTabs(bool useTabs)
1325 {
1326 SendMsg(2124, useTabs, 0);
1327 }
1328
1329 // Retrieve whether tabs will be used in indentation.
1330 bool wxStyledTextCtrl::GetUseTabs() const
1331 {
1332 return SendMsg(2125, 0, 0) != 0;
1333 }
1334
1335 // Change the indentation of a line to a number of columns.
1336 void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize)
1337 {
1338 SendMsg(2126, line, indentSize);
1339 }
1340
1341 // Retrieve the number of columns that a line is indented.
1342 int wxStyledTextCtrl::GetLineIndentation(int line) const
1343 {
1344 return SendMsg(2127, line, 0);
1345 }
1346
1347 // Retrieve the position before the first non indentation character on a line.
1348 int wxStyledTextCtrl::GetLineIndentPosition(int line) const
1349 {
1350 return SendMsg(2128, line, 0);
1351 }
1352
1353 // Retrieve the column number of a position, taking tab width into account.
1354 int wxStyledTextCtrl::GetColumn(int pos) const
1355 {
1356 return SendMsg(2129, pos, 0);
1357 }
1358
1359 // Count characters between two positions.
1360 int wxStyledTextCtrl::CountCharacters(int startPos, int endPos)
1361 {
1362 return SendMsg(2633, startPos, endPos);
1363 }
1364
1365 // Show or hide the horizontal scroll bar.
1366 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show)
1367 {
1368 SendMsg(2130, show, 0);
1369 }
1370
1371 // Is the horizontal scroll bar visible?
1372 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() const
1373 {
1374 return SendMsg(2131, 0, 0) != 0;
1375 }
1376
1377 // Show or hide indentation guides.
1378 void wxStyledTextCtrl::SetIndentationGuides(int indentView)
1379 {
1380 SendMsg(2132, indentView, 0);
1381 }
1382
1383 // Are the indentation guides visible?
1384 int wxStyledTextCtrl::GetIndentationGuides() const
1385 {
1386 return SendMsg(2133, 0, 0);
1387 }
1388
1389 // Set the highlighted indentation guide column.
1390 // 0 = no highlighted guide.
1391 void wxStyledTextCtrl::SetHighlightGuide(int column)
1392 {
1393 SendMsg(2134, column, 0);
1394 }
1395
1396 // Get the highlighted indentation guide column.
1397 int wxStyledTextCtrl::GetHighlightGuide() const
1398 {
1399 return SendMsg(2135, 0, 0);
1400 }
1401
1402 // Get the position after the last visible characters on a line.
1403 int wxStyledTextCtrl::GetLineEndPosition(int line) const
1404 {
1405 return SendMsg(2136, line, 0);
1406 }
1407
1408 // Get the code page used to interpret the bytes of the document as characters.
1409 int wxStyledTextCtrl::GetCodePage() const
1410 {
1411 return SendMsg(2137, 0, 0);
1412 }
1413
1414 // Get the foreground colour of the caret.
1415 wxColour wxStyledTextCtrl::GetCaretForeground() const
1416 {
1417 long c = SendMsg(2138, 0, 0);
1418 return wxColourFromLong(c);
1419 }
1420
1421 // In read-only mode?
1422 bool wxStyledTextCtrl::GetReadOnly() const
1423 {
1424 return SendMsg(2140, 0, 0) != 0;
1425 }
1426
1427 // Sets the position of the caret.
1428 void wxStyledTextCtrl::SetCurrentPos(int pos)
1429 {
1430 SendMsg(2141, pos, 0);
1431 }
1432
1433 // Sets the position that starts the selection - this becomes the anchor.
1434 void wxStyledTextCtrl::SetSelectionStart(int pos)
1435 {
1436 SendMsg(2142, pos, 0);
1437 }
1438
1439 // Returns the position at the start of the selection.
1440 int wxStyledTextCtrl::GetSelectionStart() const
1441 {
1442 return SendMsg(2143, 0, 0);
1443 }
1444
1445 // Sets the position that ends the selection - this becomes the currentPosition.
1446 void wxStyledTextCtrl::SetSelectionEnd(int pos)
1447 {
1448 SendMsg(2144, pos, 0);
1449 }
1450
1451 // Returns the position at the end of the selection.
1452 int wxStyledTextCtrl::GetSelectionEnd() const
1453 {
1454 return SendMsg(2145, 0, 0);
1455 }
1456
1457 // Set caret to a position, while removing any existing selection.
1458 void wxStyledTextCtrl::SetEmptySelection(int pos)
1459 {
1460 SendMsg(2556, pos, 0);
1461 }
1462
1463 // Sets the print magnification added to the point size of each style for printing.
1464 void wxStyledTextCtrl::SetPrintMagnification(int magnification)
1465 {
1466 SendMsg(2146, magnification, 0);
1467 }
1468
1469 // Returns the print magnification.
1470 int wxStyledTextCtrl::GetPrintMagnification() const
1471 {
1472 return SendMsg(2147, 0, 0);
1473 }
1474
1475 // Modify colours when printing for clearer printed text.
1476 void wxStyledTextCtrl::SetPrintColourMode(int mode)
1477 {
1478 SendMsg(2148, mode, 0);
1479 }
1480
1481 // Returns the print colour mode.
1482 int wxStyledTextCtrl::GetPrintColourMode() const
1483 {
1484 return SendMsg(2149, 0, 0);
1485 }
1486
1487 // Find some text in the document.
1488 int wxStyledTextCtrl::FindText(int minPos, int maxPos,
1489 const wxString& text,
1490 int flags) {
1491 TextToFind ft;
1492 ft.chrg.cpMin = minPos;
1493 ft.chrg.cpMax = maxPos;
1494 const wxWX2MBbuf buf = wx2stc(text);
1495 ft.lpstrText = (char*)(const char*)buf;
1496
1497 return SendMsg(2150, flags, (sptr_t)&ft);
1498 }
1499
1500 // On Windows, will draw the document into a display context such as a printer.
1501 int wxStyledTextCtrl::FormatRange(bool doDraw,
1502 int startPos,
1503 int endPos,
1504 wxDC* draw,
1505 wxDC* target,
1506 wxRect renderRect,
1507 wxRect pageRect) {
1508 RangeToFormat fr;
1509
1510 if (endPos < startPos) {
1511 int temp = startPos;
1512 startPos = endPos;
1513 endPos = temp;
1514 }
1515 fr.hdc = draw;
1516 fr.hdcTarget = target;
1517 fr.rc.top = renderRect.GetTop();
1518 fr.rc.left = renderRect.GetLeft();
1519 fr.rc.right = renderRect.GetRight();
1520 fr.rc.bottom = renderRect.GetBottom();
1521 fr.rcPage.top = pageRect.GetTop();
1522 fr.rcPage.left = pageRect.GetLeft();
1523 fr.rcPage.right = pageRect.GetRight();
1524 fr.rcPage.bottom = pageRect.GetBottom();
1525 fr.chrg.cpMin = startPos;
1526 fr.chrg.cpMax = endPos;
1527
1528 return SendMsg(2151, doDraw, (sptr_t)&fr);
1529 }
1530
1531 // Retrieve the display line at the top of the display.
1532 int wxStyledTextCtrl::GetFirstVisibleLine() const
1533 {
1534 return SendMsg(2152, 0, 0);
1535 }
1536
1537 // Retrieve the contents of a line.
1538 wxString wxStyledTextCtrl::GetLine(int line) const {
1539 int len = LineLength(line);
1540 if (!len) return wxEmptyString;
1541
1542 wxMemoryBuffer mbuf(len+1);
1543 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1544 SendMsg(2153, line, (sptr_t)buf);
1545 mbuf.UngetWriteBuf(len);
1546 mbuf.AppendByte(0);
1547 return stc2wx(buf);
1548 }
1549
1550 // Returns the number of lines in the document. There is always at least one.
1551 int wxStyledTextCtrl::GetLineCount() const
1552 {
1553 return SendMsg(2154, 0, 0);
1554 }
1555
1556 // Sets the size in pixels of the left margin.
1557 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth)
1558 {
1559 SendMsg(2155, 0, pixelWidth);
1560 }
1561
1562 // Returns the size in pixels of the left margin.
1563 int wxStyledTextCtrl::GetMarginLeft() const
1564 {
1565 return SendMsg(2156, 0, 0);
1566 }
1567
1568 // Sets the size in pixels of the right margin.
1569 void wxStyledTextCtrl::SetMarginRight(int pixelWidth)
1570 {
1571 SendMsg(2157, 0, pixelWidth);
1572 }
1573
1574 // Returns the size in pixels of the right margin.
1575 int wxStyledTextCtrl::GetMarginRight() const
1576 {
1577 return SendMsg(2158, 0, 0);
1578 }
1579
1580 // Is the document different from when it was last saved?
1581 bool wxStyledTextCtrl::GetModify() const
1582 {
1583 return SendMsg(2159, 0, 0) != 0;
1584 }
1585
1586 // Retrieve the selected text.
1587 wxString wxStyledTextCtrl::GetSelectedText() {
1588 const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
1589 if (!len) return wxEmptyString;
1590
1591 wxMemoryBuffer mbuf(len+2);
1592 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1593 SendMsg(2161, 0, (sptr_t)buf);
1594 mbuf.UngetWriteBuf(len);
1595 mbuf.AppendByte(0);
1596 return stc2wx(buf);
1597 }
1598
1599 // Retrieve a range of text.
1600 wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1601 if (endPos < startPos) {
1602 int temp = startPos;
1603 startPos = endPos;
1604 endPos = temp;
1605 }
1606 int len = endPos - startPos;
1607 if (!len) return wxEmptyString;
1608 wxMemoryBuffer mbuf(len+1);
1609 char* buf = (char*)mbuf.GetWriteBuf(len);
1610 TextRange tr;
1611 tr.lpstrText = buf;
1612 tr.chrg.cpMin = startPos;
1613 tr.chrg.cpMax = endPos;
1614 SendMsg(2162, 0, (sptr_t)&tr);
1615 mbuf.UngetWriteBuf(len);
1616 mbuf.AppendByte(0);
1617 return stc2wx(buf);
1618 }
1619
1620 // Draw the selection in normal style or with selection highlighted.
1621 void wxStyledTextCtrl::HideSelection(bool normal)
1622 {
1623 SendMsg(2163, normal, 0);
1624 }
1625
1626 // Retrieve the line containing a position.
1627 int wxStyledTextCtrl::LineFromPosition(int pos) const
1628 {
1629 return SendMsg(2166, pos, 0);
1630 }
1631
1632 // Retrieve the position at the start of a line.
1633 int wxStyledTextCtrl::PositionFromLine(int line) const
1634 {
1635 return SendMsg(2167, line, 0);
1636 }
1637
1638 // Scroll horizontally and vertically.
1639 void wxStyledTextCtrl::LineScroll(int columns, int lines)
1640 {
1641 SendMsg(2168, columns, lines);
1642 }
1643
1644 // Ensure the caret is visible.
1645 void wxStyledTextCtrl::EnsureCaretVisible()
1646 {
1647 SendMsg(2169, 0, 0);
1648 }
1649
1650 // Replace the selected text with the argument text.
1651 void wxStyledTextCtrl::ReplaceSelection(const wxString& text)
1652 {
1653 SendMsg(2170, 0, (sptr_t)(const char*)wx2stc(text));
1654 }
1655
1656 // Set to read only or read write.
1657 void wxStyledTextCtrl::SetReadOnly(bool readOnly)
1658 {
1659 SendMsg(2171, readOnly, 0);
1660 }
1661
1662 // Will a paste succeed?
1663 bool wxStyledTextCtrl::CanPaste() const
1664 {
1665 return SendMsg(2173, 0, 0) != 0;
1666 }
1667
1668 // Are there any undoable actions in the undo history?
1669 bool wxStyledTextCtrl::CanUndo() const
1670 {
1671 return SendMsg(2174, 0, 0) != 0;
1672 }
1673
1674 // Delete the undo history.
1675 void wxStyledTextCtrl::EmptyUndoBuffer()
1676 {
1677 SendMsg(2175, 0, 0);
1678 }
1679
1680 // Undo one action in the undo history.
1681 void wxStyledTextCtrl::Undo()
1682 {
1683 SendMsg(2176, 0, 0);
1684 }
1685
1686 // Cut the selection to the clipboard.
1687 void wxStyledTextCtrl::Cut()
1688 {
1689 SendMsg(2177, 0, 0);
1690 }
1691
1692 // Copy the selection to the clipboard.
1693 void wxStyledTextCtrl::Copy()
1694 {
1695 SendMsg(2178, 0, 0);
1696 }
1697
1698 // Paste the contents of the clipboard into the document replacing the selection.
1699 void wxStyledTextCtrl::Paste()
1700 {
1701 SendMsg(2179, 0, 0);
1702 }
1703
1704 // Clear the selection.
1705 void wxStyledTextCtrl::Clear()
1706 {
1707 SendMsg(2180, 0, 0);
1708 }
1709
1710 // Replace the contents of the document with the argument text.
1711 void wxStyledTextCtrl::SetText(const wxString& text)
1712 {
1713 SendMsg(2181, 0, (sptr_t)(const char*)wx2stc(text));
1714 }
1715
1716 // Retrieve all the text in the document.
1717 wxString wxStyledTextCtrl::GetText() const {
1718 int len = GetTextLength();
1719 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1720 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1721 SendMsg(2182, len+1, (sptr_t)buf);
1722 mbuf.UngetWriteBuf(len);
1723 mbuf.AppendByte(0);
1724 return stc2wx(buf);
1725 }
1726
1727 // Retrieve the number of characters in the document.
1728 int wxStyledTextCtrl::GetTextLength() const
1729 {
1730 return SendMsg(2183, 0, 0);
1731 }
1732
1733 // Set to overtype (true) or insert mode.
1734 void wxStyledTextCtrl::SetOvertype(bool overtype)
1735 {
1736 SendMsg(2186, overtype, 0);
1737 }
1738
1739 // Returns true if overtype mode is active otherwise false is returned.
1740 bool wxStyledTextCtrl::GetOvertype() const
1741 {
1742 return SendMsg(2187, 0, 0) != 0;
1743 }
1744
1745 // Set the width of the insert mode caret.
1746 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth)
1747 {
1748 SendMsg(2188, pixelWidth, 0);
1749 }
1750
1751 // Returns the width of the insert mode caret.
1752 int wxStyledTextCtrl::GetCaretWidth() const
1753 {
1754 return SendMsg(2189, 0, 0);
1755 }
1756
1757 // Sets the position that starts the target which is used for updating the
1758 // document without affecting the scroll position.
1759 void wxStyledTextCtrl::SetTargetStart(int pos)
1760 {
1761 SendMsg(2190, pos, 0);
1762 }
1763
1764 // Get the position that starts the target.
1765 int wxStyledTextCtrl::GetTargetStart() const
1766 {
1767 return SendMsg(2191, 0, 0);
1768 }
1769
1770 // Sets the position that ends the target which is used for updating the
1771 // document without affecting the scroll position.
1772 void wxStyledTextCtrl::SetTargetEnd(int pos)
1773 {
1774 SendMsg(2192, pos, 0);
1775 }
1776
1777 // Get the position that ends the target.
1778 int wxStyledTextCtrl::GetTargetEnd() const
1779 {
1780 return SendMsg(2193, 0, 0);
1781 }
1782
1783 // Replace the target text with the argument text.
1784 // Text is counted so it can contain NULs.
1785 // Returns the length of the replacement text.
1786
1787 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1788 const wxWX2MBbuf buf = wx2stc(text);
1789 return SendMsg(2194, wx2stclen(text, buf), (sptr_t)(const char*)buf);
1790 }
1791
1792 // Replace the target text with the argument text after \d processing.
1793 // Text is counted so it can contain NULs.
1794 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1795 // matched in the last search operation which were surrounded by \( and \).
1796 // Returns the length of the replacement text including any change
1797 // caused by processing the \d patterns.
1798
1799 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1800 const wxWX2MBbuf buf = wx2stc(text);
1801 return SendMsg(2195, wx2stclen(text, buf), (sptr_t)(const char*)buf);
1802 }
1803
1804 // Search for a counted string in the target and set the target to the found
1805 // range. Text is counted so it can contain NULs.
1806 // Returns length of range or -1 for failure in which case target is not moved.
1807
1808 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1809 const wxWX2MBbuf buf = wx2stc(text);
1810 return SendMsg(2197, wx2stclen(text, buf), (sptr_t)(const char*)buf);
1811 }
1812
1813 // Set the search flags used by SearchInTarget.
1814 void wxStyledTextCtrl::SetSearchFlags(int flags)
1815 {
1816 SendMsg(2198, flags, 0);
1817 }
1818
1819 // Get the search flags used by SearchInTarget.
1820 int wxStyledTextCtrl::GetSearchFlags() const
1821 {
1822 return SendMsg(2199, 0, 0);
1823 }
1824
1825 // Show a call tip containing a definition near position pos.
1826 void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition)
1827 {
1828 SendMsg(2200, pos, (sptr_t)(const char*)wx2stc(definition));
1829 }
1830
1831 // Remove the call tip from the screen.
1832 void wxStyledTextCtrl::CallTipCancel()
1833 {
1834 SendMsg(2201, 0, 0);
1835 }
1836
1837 // Is there an active call tip?
1838 bool wxStyledTextCtrl::CallTipActive()
1839 {
1840 return SendMsg(2202, 0, 0) != 0;
1841 }
1842
1843 // Retrieve the position where the caret was before displaying the call tip.
1844 int wxStyledTextCtrl::CallTipPosAtStart()
1845 {
1846 return SendMsg(2203, 0, 0);
1847 }
1848
1849 // Highlight a segment of the definition.
1850 void wxStyledTextCtrl::CallTipSetHighlight(int start, int end)
1851 {
1852 SendMsg(2204, start, end);
1853 }
1854
1855 // Set the background colour for the call tip.
1856 void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back)
1857 {
1858 SendMsg(2205, wxColourAsLong(back), 0);
1859 }
1860
1861 // Set the foreground colour for the call tip.
1862 void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore)
1863 {
1864 SendMsg(2206, wxColourAsLong(fore), 0);
1865 }
1866
1867 // Set the foreground colour for the highlighted part of the call tip.
1868 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore)
1869 {
1870 SendMsg(2207, wxColourAsLong(fore), 0);
1871 }
1872
1873 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1874 void wxStyledTextCtrl::CallTipUseStyle(int tabSize)
1875 {
1876 SendMsg(2212, tabSize, 0);
1877 }
1878
1879 // Set position of calltip, above or below text.
1880 void wxStyledTextCtrl::CallTipSetPosition(bool above)
1881 {
1882 SendMsg(2213, above, 0);
1883 }
1884
1885 // Find the display line of a document line taking hidden lines into account.
1886 int wxStyledTextCtrl::VisibleFromDocLine(int line)
1887 {
1888 return SendMsg(2220, line, 0);
1889 }
1890
1891 // Find the document line of a display line taking hidden lines into account.
1892 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay)
1893 {
1894 return SendMsg(2221, lineDisplay, 0);
1895 }
1896
1897 // The number of display lines needed to wrap a document line
1898 int wxStyledTextCtrl::WrapCount(int line)
1899 {
1900 return SendMsg(2235, line, 0);
1901 }
1902
1903 // Set the fold level of a line.
1904 // This encodes an integer level along with flags indicating whether the
1905 // line is a header and whether it is effectively white space.
1906 void wxStyledTextCtrl::SetFoldLevel(int line, int level)
1907 {
1908 SendMsg(2222, line, level);
1909 }
1910
1911 // Retrieve the fold level of a line.
1912 int wxStyledTextCtrl::GetFoldLevel(int line) const
1913 {
1914 return SendMsg(2223, line, 0);
1915 }
1916
1917 // Find the last child line of a header line.
1918 int wxStyledTextCtrl::GetLastChild(int line, int level) const
1919 {
1920 return SendMsg(2224, line, level);
1921 }
1922
1923 // Find the parent line of a child line.
1924 int wxStyledTextCtrl::GetFoldParent(int line) const
1925 {
1926 return SendMsg(2225, line, 0);
1927 }
1928
1929 // Make a range of lines visible.
1930 void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd)
1931 {
1932 SendMsg(2226, lineStart, lineEnd);
1933 }
1934
1935 // Make a range of lines invisible.
1936 void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd)
1937 {
1938 SendMsg(2227, lineStart, lineEnd);
1939 }
1940
1941 // Is a line visible?
1942 bool wxStyledTextCtrl::GetLineVisible(int line) const
1943 {
1944 return SendMsg(2228, line, 0) != 0;
1945 }
1946
1947 // Are all lines visible?
1948 bool wxStyledTextCtrl::GetAllLinesVisible() const
1949 {
1950 return SendMsg(2236, 0, 0) != 0;
1951 }
1952
1953 // Show the children of a header line.
1954 void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded)
1955 {
1956 SendMsg(2229, line, expanded);
1957 }
1958
1959 // Is a header line expanded?
1960 bool wxStyledTextCtrl::GetFoldExpanded(int line) const
1961 {
1962 return SendMsg(2230, line, 0) != 0;
1963 }
1964
1965 // Switch a header line between expanded and contracted.
1966 void wxStyledTextCtrl::ToggleFold(int line)
1967 {
1968 SendMsg(2231, line, 0);
1969 }
1970
1971 // Ensure a particular line is visible by expanding any header line hiding it.
1972 void wxStyledTextCtrl::EnsureVisible(int line)
1973 {
1974 SendMsg(2232, line, 0);
1975 }
1976
1977 // Set some style options for folding.
1978 void wxStyledTextCtrl::SetFoldFlags(int flags)
1979 {
1980 SendMsg(2233, flags, 0);
1981 }
1982
1983 // Ensure a particular line is visible by expanding any header line hiding it.
1984 // Use the currently set visibility policy to determine which range to display.
1985 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line)
1986 {
1987 SendMsg(2234, line, 0);
1988 }
1989
1990 // Sets whether a tab pressed when caret is within indentation indents.
1991 void wxStyledTextCtrl::SetTabIndents(bool tabIndents)
1992 {
1993 SendMsg(2260, tabIndents, 0);
1994 }
1995
1996 // Does a tab pressed when caret is within indentation indent?
1997 bool wxStyledTextCtrl::GetTabIndents() const
1998 {
1999 return SendMsg(2261, 0, 0) != 0;
2000 }
2001
2002 // Sets whether a backspace pressed when caret is within indentation unindents.
2003 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents)
2004 {
2005 SendMsg(2262, bsUnIndents, 0);
2006 }
2007
2008 // Does a backspace pressed when caret is within indentation unindent?
2009 bool wxStyledTextCtrl::GetBackSpaceUnIndents() const
2010 {
2011 return SendMsg(2263, 0, 0) != 0;
2012 }
2013
2014 // Sets the time the mouse must sit still to generate a mouse dwell event.
2015 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds)
2016 {
2017 SendMsg(2264, periodMilliseconds, 0);
2018 }
2019
2020 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
2021 int wxStyledTextCtrl::GetMouseDwellTime() const
2022 {
2023 return SendMsg(2265, 0, 0);
2024 }
2025
2026 // Get position of start of word.
2027 int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters)
2028 {
2029 return SendMsg(2266, pos, onlyWordCharacters);
2030 }
2031
2032 // Get position of end of word.
2033 int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters)
2034 {
2035 return SendMsg(2267, pos, onlyWordCharacters);
2036 }
2037
2038 // Sets whether text is word wrapped.
2039 void wxStyledTextCtrl::SetWrapMode(int mode)
2040 {
2041 SendMsg(2268, mode, 0);
2042 }
2043
2044 // Retrieve whether text is word wrapped.
2045 int wxStyledTextCtrl::GetWrapMode() const
2046 {
2047 return SendMsg(2269, 0, 0);
2048 }
2049
2050 // Set the display mode of visual flags for wrapped lines.
2051 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags)
2052 {
2053 SendMsg(2460, wrapVisualFlags, 0);
2054 }
2055
2056 // Retrive the display mode of visual flags for wrapped lines.
2057 int wxStyledTextCtrl::GetWrapVisualFlags() const
2058 {
2059 return SendMsg(2461, 0, 0);
2060 }
2061
2062 // Set the location of visual flags for wrapped lines.
2063 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation)
2064 {
2065 SendMsg(2462, wrapVisualFlagsLocation, 0);
2066 }
2067
2068 // Retrive the location of visual flags for wrapped lines.
2069 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const
2070 {
2071 return SendMsg(2463, 0, 0);
2072 }
2073
2074 // Set the start indent for wrapped lines.
2075 void wxStyledTextCtrl::SetWrapStartIndent(int indent)
2076 {
2077 SendMsg(2464, indent, 0);
2078 }
2079
2080 // Retrive the start indent for wrapped lines.
2081 int wxStyledTextCtrl::GetWrapStartIndent() const
2082 {
2083 return SendMsg(2465, 0, 0);
2084 }
2085
2086 // Sets how wrapped sublines are placed. Default is fixed.
2087 void wxStyledTextCtrl::SetWrapIndentMode(int mode)
2088 {
2089 SendMsg(2472, mode, 0);
2090 }
2091
2092 // Retrieve how wrapped sublines are placed. Default is fixed.
2093 int wxStyledTextCtrl::GetWrapIndentMode() const
2094 {
2095 return SendMsg(2473, 0, 0);
2096 }
2097
2098 // Sets the degree of caching of layout information.
2099 void wxStyledTextCtrl::SetLayoutCache(int mode)
2100 {
2101 SendMsg(2272, mode, 0);
2102 }
2103
2104 // Retrieve the degree of caching of layout information.
2105 int wxStyledTextCtrl::GetLayoutCache() const
2106 {
2107 return SendMsg(2273, 0, 0);
2108 }
2109
2110 // Sets the document width assumed for scrolling.
2111 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth)
2112 {
2113 SendMsg(2274, pixelWidth, 0);
2114 }
2115
2116 // Retrieve the document width assumed for scrolling.
2117 int wxStyledTextCtrl::GetScrollWidth() const
2118 {
2119 return SendMsg(2275, 0, 0);
2120 }
2121
2122 // Sets whether the maximum width line displayed is used to set scroll width.
2123 void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking)
2124 {
2125 SendMsg(2516, tracking, 0);
2126 }
2127
2128 // Retrieve whether the scroll width tracks wide lines.
2129 bool wxStyledTextCtrl::GetScrollWidthTracking() const
2130 {
2131 return SendMsg(2517, 0, 0) != 0;
2132 }
2133
2134 // Measure the pixel width of some text in a particular style.
2135 // NUL terminated text argument.
2136 // Does not handle tab or control characters.
2137 int wxStyledTextCtrl::TextWidth(int style, const wxString& text)
2138 {
2139 return SendMsg(2276, style, (sptr_t)(const char*)wx2stc(text));
2140 }
2141
2142 // Sets the scroll range so that maximum scroll position has
2143 // the last line at the bottom of the view (default).
2144 // Setting this to false allows scrolling one page below the last line.
2145 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine)
2146 {
2147 SendMsg(2277, endAtLastLine, 0);
2148 }
2149
2150 // Retrieve whether the maximum scroll position has the last
2151 // line at the bottom of the view.
2152 bool wxStyledTextCtrl::GetEndAtLastLine() const
2153 {
2154 return SendMsg(2278, 0, 0) != 0;
2155 }
2156
2157 // Retrieve the height of a particular line of text in pixels.
2158 int wxStyledTextCtrl::TextHeight(int line)
2159 {
2160 return SendMsg(2279, line, 0);
2161 }
2162
2163 // Show or hide the vertical scroll bar.
2164 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show)
2165 {
2166 SendMsg(2280, show, 0);
2167 }
2168
2169 // Is the vertical scroll bar visible?
2170 bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
2171 {
2172 return SendMsg(2281, 0, 0) != 0;
2173 }
2174
2175 // Append a string to the end of the document without changing the selection.
2176 void wxStyledTextCtrl::AppendText(const wxString& text) {
2177 const wxWX2MBbuf buf = wx2stc(text);
2178 SendMsg(2282, wx2stclen(text, buf), (sptr_t)(const char*)buf);
2179 }
2180
2181 // Is drawing done in two phases with backgrounds drawn before foregrounds?
2182 bool wxStyledTextCtrl::GetTwoPhaseDraw() const
2183 {
2184 return SendMsg(2283, 0, 0) != 0;
2185 }
2186
2187 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
2188 // and then the foreground. This avoids chopping off characters that overlap the next run.
2189 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase)
2190 {
2191 SendMsg(2284, twoPhase, 0);
2192 }
2193
2194 // Scroll so that a display line is at the top of the display.
2195 void wxStyledTextCtrl::SetFirstVisibleLine(int lineDisplay)
2196 {
2197 SendMsg(2613, lineDisplay, 0);
2198 }
2199
2200 // Change the effect of pasting when there are multiple selections.
2201 void wxStyledTextCtrl::SetMultiPaste(int multiPaste)
2202 {
2203 SendMsg(2614, multiPaste, 0);
2204 }
2205
2206 // Retrieve the effect of pasting when there are multiple selections..
2207 int wxStyledTextCtrl::GetMultiPaste() const
2208 {
2209 return SendMsg(2615, 0, 0);
2210 }
2211
2212 // Retrieve the value of a tag from a regular expression search.
2213 wxString wxStyledTextCtrl::GetTag(int tagNumber) const {
2214 int msg = 2616;
2215 int len = SendMsg(msg, tagNumber, NULL);
2216 if (!len) return wxEmptyString;
2217
2218 wxMemoryBuffer mbuf(len+1);
2219 char* buf = (char*)mbuf.GetWriteBuf(len+1);
2220 SendMsg(msg, tagNumber, (sptr_t)buf);
2221 mbuf.UngetWriteBuf(len);
2222 mbuf.AppendByte(0);
2223 return stc2wx(buf);
2224 }
2225
2226 // Make the target range start and end be the same as the selection range start and end.
2227 void wxStyledTextCtrl::TargetFromSelection()
2228 {
2229 SendMsg(2287, 0, 0);
2230 }
2231
2232 // Join the lines in the target.
2233 void wxStyledTextCtrl::LinesJoin()
2234 {
2235 SendMsg(2288, 0, 0);
2236 }
2237
2238 // Split the lines in the target into lines that are less wide than pixelWidth
2239 // where possible.
2240 void wxStyledTextCtrl::LinesSplit(int pixelWidth)
2241 {
2242 SendMsg(2289, pixelWidth, 0);
2243 }
2244
2245 // Set the colours used as a chequerboard pattern in the fold margin
2246 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back)
2247 {
2248 SendMsg(2290, useSetting, wxColourAsLong(back));
2249 }
2250 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore)
2251 {
2252 SendMsg(2291, useSetting, wxColourAsLong(fore));
2253 }
2254
2255 // Move caret down one line.
2256 void wxStyledTextCtrl::LineDown()
2257 {
2258 SendMsg(2300, 0, 0);
2259 }
2260
2261 // Move caret down one line extending selection to new caret position.
2262 void wxStyledTextCtrl::LineDownExtend()
2263 {
2264 SendMsg(2301, 0, 0);
2265 }
2266
2267 // Move caret up one line.
2268 void wxStyledTextCtrl::LineUp()
2269 {
2270 SendMsg(2302, 0, 0);
2271 }
2272
2273 // Move caret up one line extending selection to new caret position.
2274 void wxStyledTextCtrl::LineUpExtend()
2275 {
2276 SendMsg(2303, 0, 0);
2277 }
2278
2279 // Move caret left one character.
2280 void wxStyledTextCtrl::CharLeft()
2281 {
2282 SendMsg(2304, 0, 0);
2283 }
2284
2285 // Move caret left one character extending selection to new caret position.
2286 void wxStyledTextCtrl::CharLeftExtend()
2287 {
2288 SendMsg(2305, 0, 0);
2289 }
2290
2291 // Move caret right one character.
2292 void wxStyledTextCtrl::CharRight()
2293 {
2294 SendMsg(2306, 0, 0);
2295 }
2296
2297 // Move caret right one character extending selection to new caret position.
2298 void wxStyledTextCtrl::CharRightExtend()
2299 {
2300 SendMsg(2307, 0, 0);
2301 }
2302
2303 // Move caret left one word.
2304 void wxStyledTextCtrl::WordLeft()
2305 {
2306 SendMsg(2308, 0, 0);
2307 }
2308
2309 // Move caret left one word extending selection to new caret position.
2310 void wxStyledTextCtrl::WordLeftExtend()
2311 {
2312 SendMsg(2309, 0, 0);
2313 }
2314
2315 // Move caret right one word.
2316 void wxStyledTextCtrl::WordRight()
2317 {
2318 SendMsg(2310, 0, 0);
2319 }
2320
2321 // Move caret right one word extending selection to new caret position.
2322 void wxStyledTextCtrl::WordRightExtend()
2323 {
2324 SendMsg(2311, 0, 0);
2325 }
2326
2327 // Move caret to first position on line.
2328 void wxStyledTextCtrl::Home()
2329 {
2330 SendMsg(2312, 0, 0);
2331 }
2332
2333 // Move caret to first position on line extending selection to new caret position.
2334 void wxStyledTextCtrl::HomeExtend()
2335 {
2336 SendMsg(2313, 0, 0);
2337 }
2338
2339 // Move caret to last position on line.
2340 void wxStyledTextCtrl::LineEnd()
2341 {
2342 SendMsg(2314, 0, 0);
2343 }
2344
2345 // Move caret to last position on line extending selection to new caret position.
2346 void wxStyledTextCtrl::LineEndExtend()
2347 {
2348 SendMsg(2315, 0, 0);
2349 }
2350
2351 // Move caret to first position in document.
2352 void wxStyledTextCtrl::DocumentStart()
2353 {
2354 SendMsg(2316, 0, 0);
2355 }
2356
2357 // Move caret to first position in document extending selection to new caret position.
2358 void wxStyledTextCtrl::DocumentStartExtend()
2359 {
2360 SendMsg(2317, 0, 0);
2361 }
2362
2363 // Move caret to last position in document.
2364 void wxStyledTextCtrl::DocumentEnd()
2365 {
2366 SendMsg(2318, 0, 0);
2367 }
2368
2369 // Move caret to last position in document extending selection to new caret position.
2370 void wxStyledTextCtrl::DocumentEndExtend()
2371 {
2372 SendMsg(2319, 0, 0);
2373 }
2374
2375 // Move caret one page up.
2376 void wxStyledTextCtrl::PageUp()
2377 {
2378 SendMsg(2320, 0, 0);
2379 }
2380
2381 // Move caret one page up extending selection to new caret position.
2382 void wxStyledTextCtrl::PageUpExtend()
2383 {
2384 SendMsg(2321, 0, 0);
2385 }
2386
2387 // Move caret one page down.
2388 void wxStyledTextCtrl::PageDown()
2389 {
2390 SendMsg(2322, 0, 0);
2391 }
2392
2393 // Move caret one page down extending selection to new caret position.
2394 void wxStyledTextCtrl::PageDownExtend()
2395 {
2396 SendMsg(2323, 0, 0);
2397 }
2398
2399 // Switch from insert to overtype mode or the reverse.
2400 void wxStyledTextCtrl::EditToggleOvertype()
2401 {
2402 SendMsg(2324, 0, 0);
2403 }
2404
2405 // Cancel any modes such as call tip or auto-completion list display.
2406 void wxStyledTextCtrl::Cancel()
2407 {
2408 SendMsg(2325, 0, 0);
2409 }
2410
2411 // Delete the selection or if no selection, the character before the caret.
2412 void wxStyledTextCtrl::DeleteBack()
2413 {
2414 SendMsg(2326, 0, 0);
2415 }
2416
2417 // If selection is empty or all on one line replace the selection with a tab character.
2418 // If more than one line selected, indent the lines.
2419 void wxStyledTextCtrl::Tab()
2420 {
2421 SendMsg(2327, 0, 0);
2422 }
2423
2424 // Dedent the selected lines.
2425 void wxStyledTextCtrl::BackTab()
2426 {
2427 SendMsg(2328, 0, 0);
2428 }
2429
2430 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
2431 void wxStyledTextCtrl::NewLine()
2432 {
2433 SendMsg(2329, 0, 0);
2434 }
2435
2436 // Insert a Form Feed character.
2437 void wxStyledTextCtrl::FormFeed()
2438 {
2439 SendMsg(2330, 0, 0);
2440 }
2441
2442 // Move caret to before first visible character on line.
2443 // If already there move to first character on line.
2444 void wxStyledTextCtrl::VCHome()
2445 {
2446 SendMsg(2331, 0, 0);
2447 }
2448
2449 // Like VCHome but extending selection to new caret position.
2450 void wxStyledTextCtrl::VCHomeExtend()
2451 {
2452 SendMsg(2332, 0, 0);
2453 }
2454
2455 // Magnify the displayed text by increasing the sizes by 1 point.
2456 void wxStyledTextCtrl::ZoomIn()
2457 {
2458 SendMsg(2333, 0, 0);
2459 }
2460
2461 // Make the displayed text smaller by decreasing the sizes by 1 point.
2462 void wxStyledTextCtrl::ZoomOut()
2463 {
2464 SendMsg(2334, 0, 0);
2465 }
2466
2467 // Delete the word to the left of the caret.
2468 void wxStyledTextCtrl::DelWordLeft()
2469 {
2470 SendMsg(2335, 0, 0);
2471 }
2472
2473 // Delete the word to the right of the caret.
2474 void wxStyledTextCtrl::DelWordRight()
2475 {
2476 SendMsg(2336, 0, 0);
2477 }
2478
2479 // Delete the word to the right of the caret, but not the trailing non-word characters.
2480 void wxStyledTextCtrl::DelWordRightEnd()
2481 {
2482 SendMsg(2518, 0, 0);
2483 }
2484
2485 // Cut the line containing the caret.
2486 void wxStyledTextCtrl::LineCut()
2487 {
2488 SendMsg(2337, 0, 0);
2489 }
2490
2491 // Delete the line containing the caret.
2492 void wxStyledTextCtrl::LineDelete()
2493 {
2494 SendMsg(2338, 0, 0);
2495 }
2496
2497 // Switch the current line with the previous.
2498 void wxStyledTextCtrl::LineTranspose()
2499 {
2500 SendMsg(2339, 0, 0);
2501 }
2502
2503 // Duplicate the current line.
2504 void wxStyledTextCtrl::LineDuplicate()
2505 {
2506 SendMsg(2404, 0, 0);
2507 }
2508
2509 // Transform the selection to lower case.
2510 void wxStyledTextCtrl::LowerCase()
2511 {
2512 SendMsg(2340, 0, 0);
2513 }
2514
2515 // Transform the selection to upper case.
2516 void wxStyledTextCtrl::UpperCase()
2517 {
2518 SendMsg(2341, 0, 0);
2519 }
2520
2521 // Scroll the document down, keeping the caret visible.
2522 void wxStyledTextCtrl::LineScrollDown()
2523 {
2524 SendMsg(2342, 0, 0);
2525 }
2526
2527 // Scroll the document up, keeping the caret visible.
2528 void wxStyledTextCtrl::LineScrollUp()
2529 {
2530 SendMsg(2343, 0, 0);
2531 }
2532
2533 // Delete the selection or if no selection, the character before the caret.
2534 // Will not delete the character before at the start of a line.
2535 void wxStyledTextCtrl::DeleteBackNotLine()
2536 {
2537 SendMsg(2344, 0, 0);
2538 }
2539
2540 // Move caret to first position on display line.
2541 void wxStyledTextCtrl::HomeDisplay()
2542 {
2543 SendMsg(2345, 0, 0);
2544 }
2545
2546 // Move caret to first position on display line extending selection to
2547 // new caret position.
2548 void wxStyledTextCtrl::HomeDisplayExtend()
2549 {
2550 SendMsg(2346, 0, 0);
2551 }
2552
2553 // Move caret to last position on display line.
2554 void wxStyledTextCtrl::LineEndDisplay()
2555 {
2556 SendMsg(2347, 0, 0);
2557 }
2558
2559 // Move caret to last position on display line extending selection to new
2560 // caret position.
2561 void wxStyledTextCtrl::LineEndDisplayExtend()
2562 {
2563 SendMsg(2348, 0, 0);
2564 }
2565
2566 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
2567 // except they behave differently when word-wrap is enabled:
2568 // They go first to the start / end of the display line, like (Home|LineEnd)Display
2569 // The difference is that, the cursor is already at the point, it goes on to the start
2570 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
2571 void wxStyledTextCtrl::HomeWrap()
2572 {
2573 SendMsg(2349, 0, 0);
2574 }
2575 void wxStyledTextCtrl::HomeWrapExtend()
2576 {
2577 SendMsg(2450, 0, 0);
2578 }
2579 void wxStyledTextCtrl::LineEndWrap()
2580 {
2581 SendMsg(2451, 0, 0);
2582 }
2583 void wxStyledTextCtrl::LineEndWrapExtend()
2584 {
2585 SendMsg(2452, 0, 0);
2586 }
2587 void wxStyledTextCtrl::VCHomeWrap()
2588 {
2589 SendMsg(2453, 0, 0);
2590 }
2591 void wxStyledTextCtrl::VCHomeWrapExtend()
2592 {
2593 SendMsg(2454, 0, 0);
2594 }
2595
2596 // Copy the line containing the caret.
2597 void wxStyledTextCtrl::LineCopy()
2598 {
2599 SendMsg(2455, 0, 0);
2600 }
2601
2602 // Move the caret inside current view if it's not there already.
2603 void wxStyledTextCtrl::MoveCaretInsideView()
2604 {
2605 SendMsg(2401, 0, 0);
2606 }
2607
2608 // How many characters are on a line, including end of line characters?
2609 int wxStyledTextCtrl::LineLength(int line) const
2610 {
2611 return SendMsg(2350, line, 0);
2612 }
2613
2614 // Highlight the characters at two positions.
2615 void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2)
2616 {
2617 SendMsg(2351, pos1, pos2);
2618 }
2619
2620 // Use specified indicator to highlight matching braces instead of changing their style.
2621 void wxStyledTextCtrl::BraceHighlightIndicator(bool useBraceHighlightIndicator, int indicator)
2622 {
2623 SendMsg(2498, useBraceHighlightIndicator, indicator);
2624 }
2625
2626 // Highlight the character at a position indicating there is no matching brace.
2627 void wxStyledTextCtrl::BraceBadLight(int pos)
2628 {
2629 SendMsg(2352, pos, 0);
2630 }
2631
2632 // Use specified indicator to highlight non matching brace instead of changing its style.
2633 void wxStyledTextCtrl::BraceBadLightIndicator(bool useBraceBadLightIndicator, int indicator)
2634 {
2635 SendMsg(2499, useBraceBadLightIndicator, indicator);
2636 }
2637
2638 // Find the position of a matching brace or INVALID_POSITION if no match.
2639 int wxStyledTextCtrl::BraceMatch(int pos)
2640 {
2641 return SendMsg(2353, pos, 0);
2642 }
2643
2644 // Are the end of line characters visible?
2645 bool wxStyledTextCtrl::GetViewEOL() const
2646 {
2647 return SendMsg(2355, 0, 0) != 0;
2648 }
2649
2650 // Make the end of line characters visible or invisible.
2651 void wxStyledTextCtrl::SetViewEOL(bool visible)
2652 {
2653 SendMsg(2356, visible, 0);
2654 }
2655
2656 // Retrieve a pointer to the document object.
2657 void* wxStyledTextCtrl::GetDocPointer() {
2658 return (void*)SendMsg(2357);
2659 }
2660
2661 // Change the document object used.
2662 void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
2663 SendMsg(2358, 0, (sptr_t)docPointer);
2664 }
2665
2666 // Set which document modification events are sent to the container.
2667 void wxStyledTextCtrl::SetModEventMask(int mask)
2668 {
2669 SendMsg(2359, mask, 0);
2670 }
2671
2672 // Retrieve the column number which text should be kept within.
2673 int wxStyledTextCtrl::GetEdgeColumn() const
2674 {
2675 return SendMsg(2360, 0, 0);
2676 }
2677
2678 // Set the column number of the edge.
2679 // If text goes past the edge then it is highlighted.
2680 void wxStyledTextCtrl::SetEdgeColumn(int column)
2681 {
2682 SendMsg(2361, column, 0);
2683 }
2684
2685 // Retrieve the edge highlight mode.
2686 int wxStyledTextCtrl::GetEdgeMode() const
2687 {
2688 return SendMsg(2362, 0, 0);
2689 }
2690
2691 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2692 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2693 void wxStyledTextCtrl::SetEdgeMode(int mode)
2694 {
2695 SendMsg(2363, mode, 0);
2696 }
2697
2698 // Retrieve the colour used in edge indication.
2699 wxColour wxStyledTextCtrl::GetEdgeColour() const
2700 {
2701 long c = SendMsg(2364, 0, 0);
2702 return wxColourFromLong(c);
2703 }
2704
2705 // Change the colour used in edge indication.
2706 void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour)
2707 {
2708 SendMsg(2365, wxColourAsLong(edgeColour), 0);
2709 }
2710
2711 // Sets the current caret position to be the search anchor.
2712 void wxStyledTextCtrl::SearchAnchor()
2713 {
2714 SendMsg(2366, 0, 0);
2715 }
2716
2717 // Find some text starting at the search anchor.
2718 // Does not ensure the selection is visible.
2719 int wxStyledTextCtrl::SearchNext(int flags, const wxString& text)
2720 {
2721 return SendMsg(2367, flags, (sptr_t)(const char*)wx2stc(text));
2722 }
2723
2724 // Find some text starting at the search anchor and moving backwards.
2725 // Does not ensure the selection is visible.
2726 int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text)
2727 {
2728 return SendMsg(2368, flags, (sptr_t)(const char*)wx2stc(text));
2729 }
2730
2731 // Retrieves the number of lines completely visible.
2732 int wxStyledTextCtrl::LinesOnScreen() const
2733 {
2734 return SendMsg(2370, 0, 0);
2735 }
2736
2737 // Set whether a pop up menu is displayed automatically when the user presses
2738 // the wrong mouse button.
2739 void wxStyledTextCtrl::UsePopUp(bool allowPopUp)
2740 {
2741 SendMsg(2371, allowPopUp, 0);
2742 }
2743
2744 // Is the selection rectangular? The alternative is the more common stream selection.
2745 bool wxStyledTextCtrl::SelectionIsRectangle() const
2746 {
2747 return SendMsg(2372, 0, 0) != 0;
2748 }
2749
2750 // Set the zoom level. This number of points is added to the size of all fonts.
2751 // It may be positive to magnify or negative to reduce.
2752 void wxStyledTextCtrl::SetZoom(int zoom)
2753 {
2754 SendMsg(2373, zoom, 0);
2755 }
2756
2757 // Retrieve the zoom level.
2758 int wxStyledTextCtrl::GetZoom() const
2759 {
2760 return SendMsg(2374, 0, 0);
2761 }
2762
2763 // Create a new document object.
2764 // Starts with reference count of 1 and not selected into editor.
2765 void* wxStyledTextCtrl::CreateDocument() {
2766 return (void*)SendMsg(2375);
2767 }
2768
2769 // Extend life of document.
2770 void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
2771 SendMsg(2376, 0, (sptr_t)docPointer);
2772 }
2773
2774 // Release a reference to the document, deleting document if it fades to black.
2775 void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
2776 SendMsg(2377, 0, (sptr_t)docPointer);
2777 }
2778
2779 // Get which document modification events are sent to the container.
2780 int wxStyledTextCtrl::GetModEventMask() const
2781 {
2782 return SendMsg(2378, 0, 0);
2783 }
2784
2785 // Change internal focus flag.
2786 void wxStyledTextCtrl::SetSTCFocus(bool focus)
2787 {
2788 SendMsg(2380, focus, 0);
2789 }
2790
2791 // Get internal focus flag.
2792 bool wxStyledTextCtrl::GetSTCFocus() const
2793 {
2794 return SendMsg(2381, 0, 0) != 0;
2795 }
2796
2797 // Change error status - 0 = OK.
2798 void wxStyledTextCtrl::SetStatus(int statusCode)
2799 {
2800 SendMsg(2382, statusCode, 0);
2801 }
2802
2803 // Get error status.
2804 int wxStyledTextCtrl::GetStatus() const
2805 {
2806 return SendMsg(2383, 0, 0);
2807 }
2808
2809 // Set whether the mouse is captured when its button is pressed.
2810 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures)
2811 {
2812 SendMsg(2384, captures, 0);
2813 }
2814
2815 // Get whether mouse gets captured.
2816 bool wxStyledTextCtrl::GetMouseDownCaptures() const
2817 {
2818 return SendMsg(2385, 0, 0) != 0;
2819 }
2820
2821 // Sets the cursor to one of the SC_CURSOR* values.
2822 void wxStyledTextCtrl::SetSTCCursor(int cursorType)
2823 {
2824 SendMsg(2386, cursorType, 0);
2825 }
2826
2827 // Get cursor type.
2828 int wxStyledTextCtrl::GetSTCCursor() const
2829 {
2830 return SendMsg(2387, 0, 0);
2831 }
2832
2833 // Change the way control characters are displayed:
2834 // If symbol is < 32, keep the drawn way, else, use the given character.
2835 void wxStyledTextCtrl::SetControlCharSymbol(int symbol)
2836 {
2837 SendMsg(2388, symbol, 0);
2838 }
2839
2840 // Get the way control characters are displayed.
2841 int wxStyledTextCtrl::GetControlCharSymbol() const
2842 {
2843 return SendMsg(2389, 0, 0);
2844 }
2845
2846 // Move to the previous change in capitalisation.
2847 void wxStyledTextCtrl::WordPartLeft()
2848 {
2849 SendMsg(2390, 0, 0);
2850 }
2851
2852 // Move to the previous change in capitalisation extending selection
2853 // to new caret position.
2854 void wxStyledTextCtrl::WordPartLeftExtend()
2855 {
2856 SendMsg(2391, 0, 0);
2857 }
2858
2859 // Move to the change next in capitalisation.
2860 void wxStyledTextCtrl::WordPartRight()
2861 {
2862 SendMsg(2392, 0, 0);
2863 }
2864
2865 // Move to the next change in capitalisation extending selection
2866 // to new caret position.
2867 void wxStyledTextCtrl::WordPartRightExtend()
2868 {
2869 SendMsg(2393, 0, 0);
2870 }
2871
2872 // Set the way the display area is determined when a particular line
2873 // is to be moved to by Find, FindNext, GotoLine, etc.
2874 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop)
2875 {
2876 SendMsg(2394, visiblePolicy, visibleSlop);
2877 }
2878
2879 // Delete back from the current position to the start of the line.
2880 void wxStyledTextCtrl::DelLineLeft()
2881 {
2882 SendMsg(2395, 0, 0);
2883 }
2884
2885 // Delete forwards from the current position to the end of the line.
2886 void wxStyledTextCtrl::DelLineRight()
2887 {
2888 SendMsg(2396, 0, 0);
2889 }
2890
2891 // Get and Set the xOffset (ie, horizontal scroll position).
2892 void wxStyledTextCtrl::SetXOffset(int newOffset)
2893 {
2894 SendMsg(2397, newOffset, 0);
2895 }
2896 int wxStyledTextCtrl::GetXOffset() const
2897 {
2898 return SendMsg(2398, 0, 0);
2899 }
2900
2901 // Set the last x chosen value to be the caret x position.
2902 void wxStyledTextCtrl::ChooseCaretX()
2903 {
2904 SendMsg(2399, 0, 0);
2905 }
2906
2907 // Set the way the caret is kept visible when going sideways.
2908 // The exclusion zone is given in pixels.
2909 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop)
2910 {
2911 SendMsg(2402, caretPolicy, caretSlop);
2912 }
2913
2914 // Set the way the line the caret is on is kept visible.
2915 // The exclusion zone is given in lines.
2916 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop)
2917 {
2918 SendMsg(2403, caretPolicy, caretSlop);
2919 }
2920
2921 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2922 void wxStyledTextCtrl::SetPrintWrapMode(int mode)
2923 {
2924 SendMsg(2406, mode, 0);
2925 }
2926
2927 // Is printing line wrapped?
2928 int wxStyledTextCtrl::GetPrintWrapMode() const
2929 {
2930 return SendMsg(2407, 0, 0);
2931 }
2932
2933 // Set a fore colour for active hotspots.
2934 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore)
2935 {
2936 SendMsg(2410, useSetting, wxColourAsLong(fore));
2937 }
2938
2939 // Get the fore colour for active hotspots.
2940 wxColour wxStyledTextCtrl::GetHotspotActiveForeground() const
2941 {
2942 long c = SendMsg(2494, 0, 0);
2943 return wxColourFromLong(c);
2944 }
2945
2946 // Set a back colour for active hotspots.
2947 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back)
2948 {
2949 SendMsg(2411, useSetting, wxColourAsLong(back));
2950 }
2951
2952 // Get the back colour for active hotspots.
2953 wxColour wxStyledTextCtrl::GetHotspotActiveBackground() const
2954 {
2955 long c = SendMsg(2495, 0, 0);
2956 return wxColourFromLong(c);
2957 }
2958
2959 // Enable / Disable underlining active hotspots.
2960 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline)
2961 {
2962 SendMsg(2412, underline, 0);
2963 }
2964
2965 // Get whether underlining for active hotspots.
2966 bool wxStyledTextCtrl::GetHotspotActiveUnderline() const
2967 {
2968 return SendMsg(2496, 0, 0) != 0;
2969 }
2970
2971 // Limit hotspots to single line so hotspots on two lines don't merge.
2972 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine)
2973 {
2974 SendMsg(2421, singleLine, 0);
2975 }
2976
2977 // Get the HotspotSingleLine property
2978 bool wxStyledTextCtrl::GetHotspotSingleLine() const
2979 {
2980 return SendMsg(2497, 0, 0) != 0;
2981 }
2982
2983 // Move caret between paragraphs (delimited by empty lines).
2984 void wxStyledTextCtrl::ParaDown()
2985 {
2986 SendMsg(2413, 0, 0);
2987 }
2988 void wxStyledTextCtrl::ParaDownExtend()
2989 {
2990 SendMsg(2414, 0, 0);
2991 }
2992 void wxStyledTextCtrl::ParaUp()
2993 {
2994 SendMsg(2415, 0, 0);
2995 }
2996 void wxStyledTextCtrl::ParaUpExtend()
2997 {
2998 SendMsg(2416, 0, 0);
2999 }
3000
3001 // Given a valid document position, return the previous position taking code
3002 // page into account. Returns 0 if passed 0.
3003 int wxStyledTextCtrl::PositionBefore(int pos)
3004 {
3005 return SendMsg(2417, pos, 0);
3006 }
3007
3008 // Given a valid document position, return the next position taking code
3009 // page into account. Maximum value returned is the last position in the document.
3010 int wxStyledTextCtrl::PositionAfter(int pos)
3011 {
3012 return SendMsg(2418, pos, 0);
3013 }
3014
3015 // Copy a range of text to the clipboard. Positions are clipped into the document.
3016 void wxStyledTextCtrl::CopyRange(int start, int end)
3017 {
3018 SendMsg(2419, start, end);
3019 }
3020
3021 // Copy argument text to the clipboard.
3022 void wxStyledTextCtrl::CopyText(int length, const wxString& text)
3023 {
3024 SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text));
3025 }
3026
3027 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or
3028 // by lines (SC_SEL_LINES).
3029 void wxStyledTextCtrl::SetSelectionMode(int mode)
3030 {
3031 SendMsg(2422, mode, 0);
3032 }
3033
3034 // Get the mode of the current selection.
3035 int wxStyledTextCtrl::GetSelectionMode() const
3036 {
3037 return SendMsg(2423, 0, 0);
3038 }
3039
3040 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
3041 int wxStyledTextCtrl::GetLineSelStartPosition(int line)
3042 {
3043 return SendMsg(2424, line, 0);
3044 }
3045
3046 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
3047 int wxStyledTextCtrl::GetLineSelEndPosition(int line)
3048 {
3049 return SendMsg(2425, line, 0);
3050 }
3051
3052 // Move caret down one line, extending rectangular selection to new caret position.
3053 void wxStyledTextCtrl::LineDownRectExtend()
3054 {
3055 SendMsg(2426, 0, 0);
3056 }
3057
3058 // Move caret up one line, extending rectangular selection to new caret position.
3059 void wxStyledTextCtrl::LineUpRectExtend()
3060 {
3061 SendMsg(2427, 0, 0);
3062 }
3063
3064 // Move caret left one character, extending rectangular selection to new caret position.
3065 void wxStyledTextCtrl::CharLeftRectExtend()
3066 {
3067 SendMsg(2428, 0, 0);
3068 }
3069
3070 // Move caret right one character, extending rectangular selection to new caret position.
3071 void wxStyledTextCtrl::CharRightRectExtend()
3072 {
3073 SendMsg(2429, 0, 0);
3074 }
3075
3076 // Move caret to first position on line, extending rectangular selection to new caret position.
3077 void wxStyledTextCtrl::HomeRectExtend()
3078 {
3079 SendMsg(2430, 0, 0);
3080 }
3081
3082 // Move caret to before first visible character on line.
3083 // If already there move to first character on line.
3084 // In either case, extend rectangular selection to new caret position.
3085 void wxStyledTextCtrl::VCHomeRectExtend()
3086 {
3087 SendMsg(2431, 0, 0);
3088 }
3089
3090 // Move caret to last position on line, extending rectangular selection to new caret position.
3091 void wxStyledTextCtrl::LineEndRectExtend()
3092 {
3093 SendMsg(2432, 0, 0);
3094 }
3095
3096 // Move caret one page up, extending rectangular selection to new caret position.
3097 void wxStyledTextCtrl::PageUpRectExtend()
3098 {
3099 SendMsg(2433, 0, 0);
3100 }
3101
3102 // Move caret one page down, extending rectangular selection to new caret position.
3103 void wxStyledTextCtrl::PageDownRectExtend()
3104 {
3105 SendMsg(2434, 0, 0);
3106 }
3107
3108 // Move caret to top of page, or one page up if already at top of page.
3109 void wxStyledTextCtrl::StutteredPageUp()
3110 {
3111 SendMsg(2435, 0, 0);
3112 }
3113
3114 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
3115 void wxStyledTextCtrl::StutteredPageUpExtend()
3116 {
3117 SendMsg(2436, 0, 0);
3118 }
3119
3120 // Move caret to bottom of page, or one page down if already at bottom of page.
3121 void wxStyledTextCtrl::StutteredPageDown()
3122 {
3123 SendMsg(2437, 0, 0);
3124 }
3125
3126 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
3127 void wxStyledTextCtrl::StutteredPageDownExtend()
3128 {
3129 SendMsg(2438, 0, 0);
3130 }
3131
3132 // Move caret left one word, position cursor at end of word.
3133 void wxStyledTextCtrl::WordLeftEnd()
3134 {
3135 SendMsg(2439, 0, 0);
3136 }
3137
3138 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
3139 void wxStyledTextCtrl::WordLeftEndExtend()
3140 {
3141 SendMsg(2440, 0, 0);
3142 }
3143
3144 // Move caret right one word, position cursor at end of word.
3145 void wxStyledTextCtrl::WordRightEnd()
3146 {
3147 SendMsg(2441, 0, 0);
3148 }
3149
3150 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
3151 void wxStyledTextCtrl::WordRightEndExtend()
3152 {
3153 SendMsg(2442, 0, 0);
3154 }
3155
3156 // Set the set of characters making up whitespace for when moving or selecting by word.
3157 // Should be called after SetWordChars.
3158 void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters)
3159 {
3160 SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters));
3161 }
3162
3163 // Get the set of characters making up whitespace for when moving or selecting by word.
3164 wxString wxStyledTextCtrl::GetWhitespaceChars() const {
3165 int msg = 2647;
3166 int len = SendMsg(msg, 0, NULL);
3167 if (!len) return wxEmptyString;
3168
3169 wxMemoryBuffer mbuf(len+1);
3170 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3171 SendMsg(msg, 0, (sptr_t)buf);
3172 mbuf.UngetWriteBuf(len);
3173 mbuf.AppendByte(0);
3174 return stc2wx(buf);
3175 }
3176
3177 // Set the set of characters making up punctuation characters
3178 // Should be called after SetWordChars.
3179 void wxStyledTextCtrl::SetPunctuationChars(const wxString& characters)
3180 {
3181 SendMsg(2648, 0, (sptr_t)(const char*)wx2stc(characters));
3182 }
3183
3184 // Get the set of characters making up punctuation characters
3185 wxString wxStyledTextCtrl::GetPunctuationChars() const {
3186 int msg = 2649;
3187 int len = SendMsg(msg, 0, NULL);
3188 if (!len) return wxEmptyString;
3189
3190 wxMemoryBuffer mbuf(len+1);
3191 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3192 SendMsg(msg, 0, (sptr_t)buf);
3193 mbuf.UngetWriteBuf(len);
3194 mbuf.AppendByte(0);
3195 return stc2wx(buf);
3196 }
3197
3198 // Reset the set of characters for whitespace and word characters to the defaults.
3199 void wxStyledTextCtrl::SetCharsDefault()
3200 {
3201 SendMsg(2444, 0, 0);
3202 }
3203
3204 // Get currently selected item position in the auto-completion list
3205 int wxStyledTextCtrl::AutoCompGetCurrent() const
3206 {
3207 return SendMsg(2445, 0, 0);
3208 }
3209
3210 // Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference.
3211 void wxStyledTextCtrl::AutoCompSetCaseInsensitiveBehaviour(int behaviour)
3212 {
3213 SendMsg(2634, behaviour, 0);
3214 }
3215
3216 // Get auto-completion case insensitive behaviour.
3217 int wxStyledTextCtrl::AutoCompGetCaseInsensitiveBehaviour() const
3218 {
3219 return SendMsg(2635, 0, 0);
3220 }
3221
3222 // Enlarge the document to a particular size of text bytes.
3223 void wxStyledTextCtrl::Allocate(int bytes)
3224 {
3225 SendMsg(2446, bytes, 0);
3226 }
3227
3228 // Find the position of a column on a line taking into account tabs and
3229 // multi-byte characters. If beyond end of line, return line end position.
3230 int wxStyledTextCtrl::FindColumn(int line, int column)
3231 {
3232 return SendMsg(2456, line, column);
3233 }
3234
3235 // Can the caret preferred x position only be changed by explicit movement commands?
3236 int wxStyledTextCtrl::GetCaretSticky() const
3237 {
3238 return SendMsg(2457, 0, 0);
3239 }
3240
3241 // Stop the caret preferred x position changing when the user types.
3242 void wxStyledTextCtrl::SetCaretSticky(int useCaretStickyBehaviour)
3243 {
3244 SendMsg(2458, useCaretStickyBehaviour, 0);
3245 }
3246
3247 // Switch between sticky and non-sticky: meant to be bound to a key.
3248 void wxStyledTextCtrl::ToggleCaretSticky()
3249 {
3250 SendMsg(2459, 0, 0);
3251 }
3252
3253 // Enable/Disable convert-on-paste for line endings
3254 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert)
3255 {
3256 SendMsg(2467, convert, 0);
3257 }
3258
3259 // Get convert-on-paste setting
3260 bool wxStyledTextCtrl::GetPasteConvertEndings() const
3261 {
3262 return SendMsg(2468, 0, 0) != 0;
3263 }
3264
3265 // Duplicate the selection. If selection empty duplicate the line containing the caret.
3266 void wxStyledTextCtrl::SelectionDuplicate()
3267 {
3268 SendMsg(2469, 0, 0);
3269 }
3270
3271 // Set background alpha of the caret line.
3272 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha)
3273 {
3274 SendMsg(2470, alpha, 0);
3275 }
3276
3277 // Get the background alpha of the caret line.
3278 int wxStyledTextCtrl::GetCaretLineBackAlpha() const
3279 {
3280 return SendMsg(2471, 0, 0);
3281 }
3282
3283 // Set the style of the caret to be drawn.
3284 void wxStyledTextCtrl::SetCaretStyle(int caretStyle)
3285 {
3286 SendMsg(2512, caretStyle, 0);
3287 }
3288
3289 // Returns the current style of the caret.
3290 int wxStyledTextCtrl::GetCaretStyle() const
3291 {
3292 return SendMsg(2513, 0, 0);
3293 }
3294
3295 // Set the indicator used for IndicatorFillRange and IndicatorClearRange
3296 void wxStyledTextCtrl::SetIndicatorCurrent(int indicator)
3297 {
3298 SendMsg(2500, indicator, 0);
3299 }
3300
3301 // Get the current indicator
3302 int wxStyledTextCtrl::GetIndicatorCurrent() const
3303 {
3304 return SendMsg(2501, 0, 0);
3305 }
3306
3307 // Set the value used for IndicatorFillRange
3308 void wxStyledTextCtrl::SetIndicatorValue(int value)
3309 {
3310 SendMsg(2502, value, 0);
3311 }
3312
3313 // Get the current indicator value
3314 int wxStyledTextCtrl::GetIndicatorValue() const
3315 {
3316 return SendMsg(2503, 0, 0);
3317 }
3318
3319 // Turn a indicator on over a range.
3320 void wxStyledTextCtrl::IndicatorFillRange(int position, int fillLength)
3321 {
3322 SendMsg(2504, position, fillLength);
3323 }
3324
3325 // Turn a indicator off over a range.
3326 void wxStyledTextCtrl::IndicatorClearRange(int position, int clearLength)
3327 {
3328 SendMsg(2505, position, clearLength);
3329 }
3330
3331 // Are any indicators present at position?
3332 int wxStyledTextCtrl::IndicatorAllOnFor(int position)
3333 {
3334 return SendMsg(2506, position, 0);
3335 }
3336
3337 // What value does a particular indicator have at at a position?
3338 int wxStyledTextCtrl::IndicatorValueAt(int indicator, int position)
3339 {
3340 return SendMsg(2507, indicator, position);
3341 }
3342
3343 // Where does a particular indicator start?
3344 int wxStyledTextCtrl::IndicatorStart(int indicator, int position)
3345 {
3346 return SendMsg(2508, indicator, position);
3347 }
3348
3349 // Where does a particular indicator end?
3350 int wxStyledTextCtrl::IndicatorEnd(int indicator, int position)
3351 {
3352 return SendMsg(2509, indicator, position);
3353 }
3354
3355 // Set number of entries in position cache
3356 void wxStyledTextCtrl::SetPositionCacheSize(int size)
3357 {
3358 SendMsg(2514, size, 0);
3359 }
3360
3361 // How many entries are allocated to the position cache?
3362 int wxStyledTextCtrl::GetPositionCacheSize() const
3363 {
3364 return SendMsg(2515, 0, 0);
3365 }
3366
3367 // Copy the selection, if selection empty copy the line with the caret
3368 void wxStyledTextCtrl::CopyAllowLine()
3369 {
3370 SendMsg(2519, 0, 0);
3371 }
3372
3373 // Compact the document buffer and return a read-only pointer to the
3374 // characters in the document.
3375 const char* wxStyledTextCtrl::GetCharacterPointer() const {
3376 return (const char*)SendMsg(2520, 0, 0);
3377 }
3378
3379 // Return a read-only pointer to a range of characters in the document.
3380 // May move the gap so that the range is contiguous, but will only move up
3381 // to rangeLength bytes.
3382 const char* wxStyledTextCtrl::GetRangePointer(int position, int rangeLength) const {
3383 return (const char*)SendMsg(2643, position, rangeLength);
3384 }
3385
3386 // Return a position which, to avoid performance costs, should not be within
3387 // the range of a call to GetRangePointer.
3388 int wxStyledTextCtrl::GetGapPosition() const
3389 {
3390 return SendMsg(2644, 0, 0);
3391 }
3392
3393 // Always interpret keyboard input as Unicode
3394 void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode)
3395 {
3396 SendMsg(2521, keysUnicode, 0);
3397 }
3398
3399 // Are keys always interpreted as Unicode?
3400 bool wxStyledTextCtrl::GetKeysUnicode() const
3401 {
3402 return SendMsg(2522, 0, 0) != 0;
3403 }
3404
3405 // Set the alpha fill colour of the given indicator.
3406 void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha)
3407 {
3408 SendMsg(2523, indicator, alpha);
3409 }
3410
3411 // Get the alpha fill colour of the given indicator.
3412 int wxStyledTextCtrl::IndicatorGetAlpha(int indicator) const
3413 {
3414 return SendMsg(2524, indicator, 0);
3415 }
3416
3417 // Set the alpha outline colour of the given indicator.
3418 void wxStyledTextCtrl::IndicatorSetOutlineAlpha(int indicator, int alpha)
3419 {
3420 SendMsg(2558, indicator, alpha);
3421 }
3422
3423 // Get the alpha outline colour of the given indicator.
3424 int wxStyledTextCtrl::IndicatorGetOutlineAlpha(int indicator) const
3425 {
3426 return SendMsg(2559, indicator, 0);
3427 }
3428
3429 // Set extra ascent for each line
3430 void wxStyledTextCtrl::SetExtraAscent(int extraAscent)
3431 {
3432 SendMsg(2525, extraAscent, 0);
3433 }
3434
3435 // Get extra ascent for each line
3436 int wxStyledTextCtrl::GetExtraAscent() const
3437 {
3438 return SendMsg(2526, 0, 0);
3439 }
3440
3441 // Set extra descent for each line
3442 void wxStyledTextCtrl::SetExtraDescent(int extraDescent)
3443 {
3444 SendMsg(2527, extraDescent, 0);
3445 }
3446
3447 // Get extra descent for each line
3448 int wxStyledTextCtrl::GetExtraDescent() const
3449 {
3450 return SendMsg(2528, 0, 0);
3451 }
3452
3453 // Which symbol was defined for markerNumber with MarkerDefine
3454 int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber)
3455 {
3456 return SendMsg(2529, markerNumber, 0);
3457 }
3458
3459 // Set the text in the text margin for a line
3460 void wxStyledTextCtrl::MarginSetText(int line, const wxString& text)
3461 {
3462 SendMsg(2530, line, (sptr_t)(const char*)wx2stc(text));
3463 }
3464
3465 // Get the text in the text margin for a line
3466 wxString wxStyledTextCtrl::MarginGetText(int line) const {
3467 long msg = 2531;
3468 long len = SendMsg(msg, line, 0);
3469
3470 wxMemoryBuffer mbuf(len+1);
3471 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3472 SendMsg(msg, line, (sptr_t)buf);
3473 mbuf.UngetWriteBuf(len);
3474 mbuf.AppendByte(0);
3475 return stc2wx(buf);
3476 }
3477
3478 // Set the style number for the text margin for a line
3479 void wxStyledTextCtrl::MarginSetStyle(int line, int style)
3480 {
3481 SendMsg(2532, line, style);
3482 }
3483
3484 // Get the style number for the text margin for a line
3485 int wxStyledTextCtrl::MarginGetStyle(int line) const
3486 {
3487 return SendMsg(2533, line, 0);
3488 }
3489
3490 // Set the style in the text margin for a line
3491 void wxStyledTextCtrl::MarginSetStyles(int line, const wxString& styles)
3492 {
3493 SendMsg(2534, line, (sptr_t)(const char*)wx2stc(styles));
3494 }
3495
3496 // Get the styles in the text margin for a line
3497 wxString wxStyledTextCtrl::MarginGetStyles(int line) const {
3498 long msg = 2535;
3499 long len = SendMsg(msg, line, 0);
3500
3501 wxMemoryBuffer mbuf(len+1);
3502 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3503 SendMsg(msg, line, (sptr_t)buf);
3504 mbuf.UngetWriteBuf(len);
3505 mbuf.AppendByte(0);
3506 return stc2wx(buf);
3507 }
3508
3509 // Clear the margin text on all lines
3510 void wxStyledTextCtrl::MarginTextClearAll()
3511 {
3512 SendMsg(2536, 0, 0);
3513 }
3514
3515 // Get the start of the range of style numbers used for margin text
3516 void wxStyledTextCtrl::MarginSetStyleOffset(int style)
3517 {
3518 SendMsg(2537, style, 0);
3519 }
3520
3521 // Get the start of the range of style numbers used for margin text
3522 int wxStyledTextCtrl::MarginGetStyleOffset() const
3523 {
3524 return SendMsg(2538, 0, 0);
3525 }
3526
3527 // Set the margin options.
3528 void wxStyledTextCtrl::SetMarginOptions(int marginOptions)
3529 {
3530 SendMsg(2539, marginOptions, 0);
3531 }
3532
3533 // Get the margin options.
3534 int wxStyledTextCtrl::GetMarginOptions() const
3535 {
3536 return SendMsg(2557, 0, 0);
3537 }
3538
3539 // Set the annotation text for a line
3540 void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text)
3541 {
3542 SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text));
3543 }
3544
3545 // Get the annotation text for a line
3546 wxString wxStyledTextCtrl::AnnotationGetText(int line) const {
3547 long msg = 2541;
3548 long len = SendMsg(msg, line, 0);
3549
3550 wxMemoryBuffer mbuf(len+1);
3551 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3552 SendMsg(msg, line, (sptr_t)buf);
3553 mbuf.UngetWriteBuf(len);
3554 mbuf.AppendByte(0);
3555 return stc2wx(buf);
3556 }
3557
3558 // Set the style number for the annotations for a line
3559 void wxStyledTextCtrl::AnnotationSetStyle(int line, int style)
3560 {
3561 SendMsg(2542, line, style);
3562 }
3563
3564 // Get the style number for the annotations for a line
3565 int wxStyledTextCtrl::AnnotationGetStyle(int line) const
3566 {
3567 return SendMsg(2543, line, 0);
3568 }
3569
3570 // Set the annotation styles for a line
3571 void wxStyledTextCtrl::AnnotationSetStyles(int line, const wxString& styles)
3572 {
3573 SendMsg(2544, line, (sptr_t)(const char*)wx2stc(styles));
3574 }
3575
3576 // Get the annotation styles for a line
3577 wxString wxStyledTextCtrl::AnnotationGetStyles(int line) const {
3578 long msg = 2545;
3579 long len = SendMsg(msg, line, 0);
3580
3581 wxMemoryBuffer mbuf(len+1);
3582 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3583 SendMsg(msg, line, (sptr_t)buf);
3584 mbuf.UngetWriteBuf(len);
3585 mbuf.AppendByte(0);
3586 return stc2wx(buf);
3587 }
3588
3589 // Get the number of annotation lines for a line
3590 int wxStyledTextCtrl::AnnotationGetLines(int line) const
3591 {
3592 return SendMsg(2546, line, 0);
3593 }
3594
3595 // Clear the annotations from all lines
3596 void wxStyledTextCtrl::AnnotationClearAll()
3597 {
3598 SendMsg(2547, 0, 0);
3599 }
3600
3601 // Set the visibility for the annotations for a view
3602 void wxStyledTextCtrl::AnnotationSetVisible(int visible)
3603 {
3604 SendMsg(2548, visible, 0);
3605 }
3606
3607 // Get the visibility for the annotations for a view
3608 int wxStyledTextCtrl::AnnotationGetVisible() const
3609 {
3610 return SendMsg(2549, 0, 0);
3611 }
3612
3613 // Get the start of the range of style numbers used for annotations
3614 void wxStyledTextCtrl::AnnotationSetStyleOffset(int style)
3615 {
3616 SendMsg(2550, style, 0);
3617 }
3618
3619 // Get the start of the range of style numbers used for annotations
3620 int wxStyledTextCtrl::AnnotationGetStyleOffset() const
3621 {
3622 return SendMsg(2551, 0, 0);
3623 }
3624
3625 // Add a container action to the undo stack
3626 void wxStyledTextCtrl::AddUndoAction(int token, int flags)
3627 {
3628 SendMsg(2560, token, flags);
3629 }
3630
3631 // Find the position of a character from a point within the window.
3632 int wxStyledTextCtrl::CharPositionFromPoint(int x, int y)
3633 {
3634 return SendMsg(2561, x, y);
3635 }
3636
3637 // Find the position of a character from a point within the window.
3638 // Return INVALID_POSITION if not close to text.
3639 int wxStyledTextCtrl::CharPositionFromPointClose(int x, int y)
3640 {
3641 return SendMsg(2562, x, y);
3642 }
3643
3644 // Set whether multiple selections can be made
3645 void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection)
3646 {
3647 SendMsg(2563, multipleSelection, 0);
3648 }
3649
3650 // Whether multiple selections can be made
3651 bool wxStyledTextCtrl::GetMultipleSelection() const
3652 {
3653 return SendMsg(2564, 0, 0) != 0;
3654 }
3655
3656 // Set whether typing can be performed into multiple selections
3657 void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping)
3658 {
3659 SendMsg(2565, additionalSelectionTyping, 0);
3660 }
3661
3662 // Whether typing can be performed into multiple selections
3663 bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const
3664 {
3665 return SendMsg(2566, 0, 0) != 0;
3666 }
3667
3668 // Set whether additional carets will blink
3669 void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink)
3670 {
3671 SendMsg(2567, additionalCaretsBlink, 0);
3672 }
3673
3674 // Whether additional carets will blink
3675 bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const
3676 {
3677 return SendMsg(2568, 0, 0) != 0;
3678 }
3679
3680 // Set whether additional carets are visible
3681 void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink)
3682 {
3683 SendMsg(2608, additionalCaretsBlink, 0);
3684 }
3685
3686 // Whether additional carets are visible
3687 bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const
3688 {
3689 return SendMsg(2609, 0, 0) != 0;
3690 }
3691
3692 // How many selections are there?
3693 int wxStyledTextCtrl::GetSelections() const
3694 {
3695 return SendMsg(2570, 0, 0);
3696 }
3697
3698 // Clear selections to a single empty stream selection
3699 void wxStyledTextCtrl::ClearSelections()
3700 {
3701 SendMsg(2571, 0, 0);
3702 }
3703
3704 // Add a selection
3705 int wxStyledTextCtrl::AddSelection(int caret, int anchor)
3706 {
3707 return SendMsg(2573, caret, anchor);
3708 }
3709
3710 // Set the main selection
3711 void wxStyledTextCtrl::SetMainSelection(int selection)
3712 {
3713 SendMsg(2574, selection, 0);
3714 }
3715
3716 // Which selection is the main selection
3717 int wxStyledTextCtrl::GetMainSelection() const
3718 {
3719 return SendMsg(2575, 0, 0);
3720 }
3721 void wxStyledTextCtrl::SetSelectionNCaret(int selection, int pos)
3722 {
3723 SendMsg(2576, selection, pos);
3724 }
3725 int wxStyledTextCtrl::GetSelectionNCaret(int selection) const
3726 {
3727 return SendMsg(2577, selection, 0);
3728 }
3729 void wxStyledTextCtrl::SetSelectionNAnchor(int selection, int posAnchor)
3730 {
3731 SendMsg(2578, selection, posAnchor);
3732 }
3733 int wxStyledTextCtrl::GetSelectionNAnchor(int selection) const
3734 {
3735 return SendMsg(2579, selection, 0);
3736 }
3737 void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space)
3738 {
3739 SendMsg(2580, selection, space);
3740 }
3741 int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection) const
3742 {
3743 return SendMsg(2581, selection, 0);
3744 }
3745 void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space)
3746 {
3747 SendMsg(2582, selection, space);
3748 }
3749 int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) const
3750 {
3751 return SendMsg(2583, selection, 0);
3752 }
3753
3754 // Sets the position that starts the selection - this becomes the anchor.
3755 void wxStyledTextCtrl::SetSelectionNStart(int selection, int pos)
3756 {
3757 SendMsg(2584, selection, pos);
3758 }
3759
3760 // Returns the position at the start of the selection.
3761 int wxStyledTextCtrl::GetSelectionNStart(int selection) const
3762 {
3763 return SendMsg(2585, selection, 0);
3764 }
3765
3766 // Sets the position that ends the selection - this becomes the currentPosition.
3767 void wxStyledTextCtrl::SetSelectionNEnd(int selection, int pos)
3768 {
3769 SendMsg(2586, selection, pos);
3770 }
3771
3772 // Returns the position at the end of the selection.
3773 int wxStyledTextCtrl::GetSelectionNEnd(int selection) const
3774 {
3775 return SendMsg(2587, selection, 0);
3776 }
3777 void wxStyledTextCtrl::SetRectangularSelectionCaret(int pos)
3778 {
3779 SendMsg(2588, pos, 0);
3780 }
3781 int wxStyledTextCtrl::GetRectangularSelectionCaret() const
3782 {
3783 return SendMsg(2589, 0, 0);
3784 }
3785 void wxStyledTextCtrl::SetRectangularSelectionAnchor(int posAnchor)
3786 {
3787 SendMsg(2590, posAnchor, 0);
3788 }
3789 int wxStyledTextCtrl::GetRectangularSelectionAnchor() const
3790 {
3791 return SendMsg(2591, 0, 0);
3792 }
3793 void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space)
3794 {
3795 SendMsg(2592, space, 0);
3796 }
3797 int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const
3798 {
3799 return SendMsg(2593, 0, 0);
3800 }
3801 void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space)
3802 {
3803 SendMsg(2594, space, 0);
3804 }
3805 int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const
3806 {
3807 return SendMsg(2595, 0, 0);
3808 }
3809 void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions)
3810 {
3811 SendMsg(2596, virtualSpaceOptions, 0);
3812 }
3813 int wxStyledTextCtrl::GetVirtualSpaceOptions() const
3814 {
3815 return SendMsg(2597, 0, 0);
3816 }
3817
3818 // On GTK+, allow selecting the modifier key to use for mouse-based
3819 // rectangular selection. Often the window manager requires Alt+Mouse Drag
3820 // for moving windows.
3821 // Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.
3822 void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier)
3823 {
3824 SendMsg(2598, modifier, 0);
3825 }
3826
3827 // Get the modifier key used for rectangular selection.
3828 int wxStyledTextCtrl::GetRectangularSelectionModifier() const
3829 {
3830 return SendMsg(2599, 0, 0);
3831 }
3832
3833 // Set the foreground colour of additional selections.
3834 // Must have previously called SetSelFore with non-zero first argument for this to have an effect.
3835 void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour& fore)
3836 {
3837 SendMsg(2600, wxColourAsLong(fore), 0);
3838 }
3839
3840 // Set the background colour of additional selections.
3841 // Must have previously called SetSelBack with non-zero first argument for this to have an effect.
3842 void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour& back)
3843 {
3844 SendMsg(2601, wxColourAsLong(back), 0);
3845 }
3846
3847 // Set the alpha of the selection.
3848 void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha)
3849 {
3850 SendMsg(2602, alpha, 0);
3851 }
3852
3853 // Get the alpha of the selection.
3854 int wxStyledTextCtrl::GetAdditionalSelAlpha() const
3855 {
3856 return SendMsg(2603, 0, 0);
3857 }
3858
3859 // Set the foreground colour of additional carets.
3860 void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour& fore)
3861 {
3862 SendMsg(2604, wxColourAsLong(fore), 0);
3863 }
3864
3865 // Get the foreground colour of additional carets.
3866 wxColour wxStyledTextCtrl::GetAdditionalCaretForeground() const
3867 {
3868 long c = SendMsg(2605, 0, 0);
3869 return wxColourFromLong(c);
3870 }
3871
3872 // Set the main selection to the next selection.
3873 void wxStyledTextCtrl::RotateSelection()
3874 {
3875 SendMsg(2606, 0, 0);
3876 }
3877
3878 // Swap that caret and anchor of the main selection.
3879 void wxStyledTextCtrl::SwapMainAnchorCaret()
3880 {
3881 SendMsg(2607, 0, 0);
3882 }
3883
3884 // Indicate that the internal state of a lexer has changed over a range and therefore
3885 // there may be a need to redraw.
3886 int wxStyledTextCtrl::ChangeLexerState(int start, int end)
3887 {
3888 return SendMsg(2617, start, end);
3889 }
3890
3891 // Find the next line at or after lineStart that is a contracted fold header line.
3892 // Return -1 when no more lines.
3893 int wxStyledTextCtrl::ContractedFoldNext(int lineStart)
3894 {
3895 return SendMsg(2618, lineStart, 0);
3896 }
3897
3898 // Centre current line in window.
3899 void wxStyledTextCtrl::VerticalCentreCaret()
3900 {
3901 SendMsg(2619, 0, 0);
3902 }
3903
3904 // Move the selected lines up one line, shifting the line above after the selection
3905 void wxStyledTextCtrl::MoveSelectedLinesUp()
3906 {
3907 SendMsg(2620, 0, 0);
3908 }
3909
3910 // Move the selected lines down one line, shifting the line below before the selection
3911 void wxStyledTextCtrl::MoveSelectedLinesDown()
3912 {
3913 SendMsg(2621, 0, 0);
3914 }
3915
3916 // Set the identifier reported as idFrom in notification messages.
3917 void wxStyledTextCtrl::SetIdentifier(int identifier)
3918 {
3919 SendMsg(2622, identifier, 0);
3920 }
3921
3922 // Get the identifier.
3923 int wxStyledTextCtrl::GetIdentifier() const
3924 {
3925 return SendMsg(2623, 0, 0);
3926 }
3927
3928 // Set the width for future RGBA image data.
3929 void wxStyledTextCtrl::RGBAImageSetWidth(int width)
3930 {
3931 SendMsg(2624, width, 0);
3932 }
3933
3934 // Set the height for future RGBA image data.
3935 void wxStyledTextCtrl::RGBAImageSetHeight(int height)
3936 {
3937 SendMsg(2625, height, 0);
3938 }
3939
3940 // Define a marker from RGBA data.
3941 // It has the width and height from RGBAImageSetWidth/Height
3942 void wxStyledTextCtrl::MarkerDefineRGBAImage(int markerNumber, const unsigned char* pixels) {
3943 SendMsg(2626, markerNumber, (sptr_t)pixels);
3944 }
3945
3946 // Register an RGBA image for use in autocompletion lists.
3947 // It has the width and height from RGBAImageSetWidth/Height
3948 void wxStyledTextCtrl::RegisterRGBAImage(int type, const unsigned char* pixels) {
3949 SendMsg(2627, type, (sptr_t)pixels);
3950 }
3951
3952 // Scroll to start of document.
3953 void wxStyledTextCtrl::ScrollToStart()
3954 {
3955 SendMsg(2628, 0, 0);
3956 }
3957
3958 // Scroll to end of document.
3959 void wxStyledTextCtrl::ScrollToEnd()
3960 {
3961 SendMsg(2629, 0, 0);
3962 }
3963
3964 // Set the technology used.
3965 void wxStyledTextCtrl::SetTechnology(int technology)
3966 {
3967 SendMsg(2630, technology, 0);
3968 }
3969
3970 // Get the tech.
3971 int wxStyledTextCtrl::GetTechnology() const
3972 {
3973 return SendMsg(2631, 0, 0);
3974 }
3975
3976 // Create an ILoader*.
3977 void* wxStyledTextCtrl::CreateLoader(int bytes) const {
3978 return (void*)(sptr_t)SendMsg(2632, bytes);
3979 }
3980
3981 // Start notifying the container of all key presses and commands.
3982 void wxStyledTextCtrl::StartRecord()
3983 {
3984 SendMsg(3001, 0, 0);
3985 }
3986
3987 // Stop notifying the container of all key presses and commands.
3988 void wxStyledTextCtrl::StopRecord()
3989 {
3990 SendMsg(3002, 0, 0);
3991 }
3992
3993 // Set the lexing language of the document.
3994 void wxStyledTextCtrl::SetLexer(int lexer)
3995 {
3996 SendMsg(4001, lexer, 0);
3997 }
3998
3999 // Retrieve the lexing language of the document.
4000 int wxStyledTextCtrl::GetLexer() const
4001 {
4002 return SendMsg(4002, 0, 0);
4003 }
4004
4005 // Colourise a segment of the document using the current lexing language.
4006 void wxStyledTextCtrl::Colourise(int start, int end)
4007 {
4008 SendMsg(4003, start, end);
4009 }
4010
4011 // Set up a value that may be used by a lexer for some optional feature.
4012 void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
4013 {
4014 SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
4015 }
4016
4017 // Set up the key words used by the lexer.
4018 void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords)
4019 {
4020 SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords));
4021 }
4022
4023 // Set the lexing language of the document based on string name.
4024 void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
4025 {
4026 SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language));
4027 }
4028
4029 // Retrieve a 'property' value previously set with SetProperty.
4030 wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
4031 int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0);
4032 if (!len) return wxEmptyString;
4033
4034 wxMemoryBuffer mbuf(len+1);
4035 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4036 SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
4037 mbuf.UngetWriteBuf(len);
4038 mbuf.AppendByte(0);
4039 return stc2wx(buf);
4040 }
4041
4042 // Retrieve a 'property' value previously set with SetProperty,
4043 // with '$()' variable replacement on returned buffer.
4044 wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
4045 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0);
4046 if (!len) return wxEmptyString;
4047
4048 wxMemoryBuffer mbuf(len+1);
4049 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4050 SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
4051 mbuf.UngetWriteBuf(len);
4052 mbuf.AppendByte(0);
4053 return stc2wx(buf);
4054 }
4055
4056 // Retrieve a 'property' value previously set with SetProperty,
4057 // interpreted as an int AFTER any '$()' variable replacement.
4058 int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const
4059 {
4060 return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0);
4061 }
4062
4063 // Retrieve the number of bits the current lexer needs for styling.
4064 int wxStyledTextCtrl::GetStyleBitsNeeded() const
4065 {
4066 return SendMsg(4011, 0, 0);
4067 }
4068
4069 // For private communication between an application and a known lexer.
4070 void* wxStyledTextCtrl::PrivateLexerCall(int operation, void* pointer) {
4071 return (void*)(sptr_t)SendMsg(4013, operation, (sptr_t)pointer);
4072 }
4073
4074 // Retrieve a '\n' separated list of properties understood by the current lexer.
4075 wxString wxStyledTextCtrl::PropertyNames() const {
4076 int msg = 4014;
4077 int len = SendMsg(msg, 0, NULL);
4078 if (!len) return wxEmptyString;
4079
4080 wxMemoryBuffer mbuf(len+1);
4081 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4082 SendMsg(msg, 0, (sptr_t)buf);
4083 mbuf.UngetWriteBuf(len);
4084 mbuf.AppendByte(0);
4085 return stc2wx(buf);
4086 }
4087
4088 // Retrieve the type of a property.
4089 int wxStyledTextCtrl::PropertyType(const wxString& name)
4090 {
4091 return SendMsg(4015, (sptr_t)(const char*)wx2stc(name), 0);
4092 }
4093
4094 // Describe a property.
4095 wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const {
4096 int msg = 4016;
4097 int len = SendMsg(msg, (sptr_t)(const char*)wx2stc(name), NULL);
4098 if (!len) return wxEmptyString;
4099
4100 wxMemoryBuffer mbuf(len+1);
4101 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4102 SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)buf);
4103 mbuf.UngetWriteBuf(len);
4104 mbuf.AppendByte(0);
4105 return stc2wx(buf);
4106 }
4107
4108 // Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
4109 wxString wxStyledTextCtrl::DescribeKeyWordSets() const {
4110 int msg = 4017;
4111 int len = SendMsg(msg, 0, NULL);
4112 if (!len) return wxEmptyString;
4113
4114 wxMemoryBuffer mbuf(len+1);
4115 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4116 SendMsg(msg, 0, (sptr_t)buf);
4117 mbuf.UngetWriteBuf(len);
4118 mbuf.AppendByte(0);
4119 return stc2wx(buf);
4120 }
4121
4122 //}}}
4123 //----------------------------------------------------------------------
4124
4125
4126 // Returns the line number of the line with the caret.
4127 int wxStyledTextCtrl::GetCurrentLine() {
4128 int line = LineFromPosition(GetCurrentPos());
4129 return line;
4130 }
4131
4132
4133 // Extract style settings from a spec-string which is composed of one or
4134 // more of the following comma separated elements:
4135 //
4136 // bold turns on bold
4137 // italic turns on italics
4138 // fore:[name or #RRGGBB] sets the foreground colour
4139 // back:[name or #RRGGBB] sets the background colour
4140 // face:[facename] sets the font face name to use
4141 // size:[num] sets the font size in points
4142 // eol turns on eol filling
4143 // underline turns on underlining
4144 //
4145 void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
4146
4147 wxStringTokenizer tkz(spec, wxT(","));
4148 while (tkz.HasMoreTokens()) {
4149 wxString token = tkz.GetNextToken();
4150
4151 wxString option = token.BeforeFirst(':');
4152 wxString val = token.AfterFirst(':');
4153
4154 if (option == wxT("bold"))
4155 StyleSetBold(styleNum, true);
4156
4157 else if (option == wxT("italic"))
4158 StyleSetItalic(styleNum, true);
4159
4160 else if (option == wxT("underline"))
4161 StyleSetUnderline(styleNum, true);
4162
4163 else if (option == wxT("eol"))
4164 StyleSetEOLFilled(styleNum, true);
4165
4166 else if (option == wxT("size")) {
4167 long points;
4168 if (val.ToLong(&points))
4169 StyleSetSize(styleNum, points);
4170 }
4171
4172 else if (option == wxT("face"))
4173 StyleSetFaceName(styleNum, val);
4174
4175 else if (option == wxT("fore"))
4176 StyleSetForeground(styleNum, wxColourFromSpec(val));
4177
4178 else if (option == wxT("back"))
4179 StyleSetBackground(styleNum, wxColourFromSpec(val));
4180 }
4181 }
4182
4183
4184 // Get the font of a style
4185 wxFont wxStyledTextCtrl::StyleGetFont(int style) {
4186 wxFont font;
4187 font.SetPointSize(StyleGetSize(style));
4188 font.SetFaceName(StyleGetFaceName(style));
4189 if( StyleGetBold(style) )
4190 font.SetWeight(wxFONTWEIGHT_BOLD);
4191 else
4192 font.SetWeight(wxFONTWEIGHT_NORMAL);
4193
4194 if( StyleGetItalic(style) )
4195 font.SetStyle(wxFONTSTYLE_ITALIC);
4196 else
4197 font.SetStyle(wxFONTSTYLE_NORMAL);
4198
4199 return font;
4200 }
4201
4202
4203 // Set style size, face, bold, italic, and underline attributes from
4204 // a wxFont's attributes.
4205 void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
4206 #ifdef __WXGTK__
4207 // Ensure that the native font is initialized
4208 int x, y;
4209 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
4210 #endif
4211 int size = font.GetPointSize();
4212 wxString faceName = font.GetFaceName();
4213 bool bold = font.GetWeight() == wxBOLD;
4214 bool italic = font.GetStyle() != wxNORMAL;
4215 bool under = font.GetUnderlined();
4216 wxFontEncoding encoding = font.GetEncoding();
4217
4218 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
4219 }
4220
4221 // Set all font style attributes at once.
4222 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
4223 const wxString& faceName,
4224 bool bold, bool italic,
4225 bool underline,
4226 wxFontEncoding encoding) {
4227 StyleSetSize(styleNum, size);
4228 StyleSetFaceName(styleNum, faceName);
4229 StyleSetBold(styleNum, bold);
4230 StyleSetItalic(styleNum, italic);
4231 StyleSetUnderline(styleNum, underline);
4232 StyleSetFontEncoding(styleNum, encoding);
4233 }
4234
4235
4236 // Set the character set of the font in a style. Converts the Scintilla
4237 // character set values to a wxFontEncoding.
4238 void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
4239 {
4240 wxFontEncoding encoding;
4241
4242 // Translate the Scintilla characterSet to a wxFontEncoding
4243 switch (characterSet) {
4244 default:
4245 case wxSTC_CHARSET_ANSI:
4246 case wxSTC_CHARSET_DEFAULT:
4247 encoding = wxFONTENCODING_DEFAULT;
4248 break;
4249
4250 case wxSTC_CHARSET_BALTIC:
4251 encoding = wxFONTENCODING_ISO8859_13;
4252 break;
4253
4254 case wxSTC_CHARSET_CHINESEBIG5:
4255 encoding = wxFONTENCODING_CP950;
4256 break;
4257
4258 case wxSTC_CHARSET_EASTEUROPE:
4259 encoding = wxFONTENCODING_ISO8859_2;
4260 break;
4261
4262 case wxSTC_CHARSET_GB2312:
4263 encoding = wxFONTENCODING_CP936;
4264 break;
4265
4266 case wxSTC_CHARSET_GREEK:
4267 encoding = wxFONTENCODING_ISO8859_7;
4268 break;
4269
4270 case wxSTC_CHARSET_HANGUL:
4271 encoding = wxFONTENCODING_CP949;
4272 break;
4273
4274 case wxSTC_CHARSET_MAC:
4275 encoding = wxFONTENCODING_DEFAULT;
4276 break;
4277
4278 case wxSTC_CHARSET_OEM:
4279 encoding = wxFONTENCODING_DEFAULT;
4280 break;
4281
4282 case wxSTC_CHARSET_RUSSIAN:
4283 encoding = wxFONTENCODING_KOI8;
4284 break;
4285
4286 case wxSTC_CHARSET_SHIFTJIS:
4287 encoding = wxFONTENCODING_CP932;
4288 break;
4289
4290 case wxSTC_CHARSET_SYMBOL:
4291 encoding = wxFONTENCODING_DEFAULT;
4292 break;
4293
4294 case wxSTC_CHARSET_TURKISH:
4295 encoding = wxFONTENCODING_ISO8859_9;
4296 break;
4297
4298 case wxSTC_CHARSET_JOHAB:
4299 encoding = wxFONTENCODING_DEFAULT;
4300 break;
4301
4302 case wxSTC_CHARSET_HEBREW:
4303 encoding = wxFONTENCODING_ISO8859_8;
4304 break;
4305
4306 case wxSTC_CHARSET_ARABIC:
4307 encoding = wxFONTENCODING_ISO8859_6;
4308 break;
4309
4310 case wxSTC_CHARSET_VIETNAMESE:
4311 encoding = wxFONTENCODING_DEFAULT;
4312 break;
4313
4314 case wxSTC_CHARSET_THAI:
4315 encoding = wxFONTENCODING_ISO8859_11;
4316 break;
4317
4318 case wxSTC_CHARSET_CYRILLIC:
4319 encoding = wxFONTENCODING_ISO8859_5;
4320 break;
4321
4322 case wxSTC_CHARSET_8859_15:
4323 encoding = wxFONTENCODING_ISO8859_15;;
4324 break;
4325 }
4326
4327 // We just have Scintilla track the wxFontEncoding for us. It gets used
4328 // in Font::Create in PlatWX.cpp. We add one to the value so that the
4329 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
4330 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
4331 // to wxFONENCODING_DEFAULT in Font::Create.
4332 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
4333 }
4334
4335
4336 // Set the font encoding to be used by a style.
4337 void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
4338 {
4339 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
4340 }
4341
4342
4343 // Perform one of the operations defined by the wxSTC_CMD_* constants.
4344 void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
4345 SendMsg(cmd);
4346 }
4347
4348
4349 // Set the left and right margin in the edit area, measured in pixels.
4350 void wxStyledTextCtrl::SetMargins(int left, int right) {
4351 SetMarginLeft(left);
4352 SetMarginRight(right);
4353 }
4354
4355
4356 // Retrieve the point in the window where a position is displayed.
4357 wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
4358 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
4359 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
4360 return wxPoint(x, y);
4361 }
4362
4363 // Scroll enough to make the given line visible
4364 void wxStyledTextCtrl::ScrollToLine(int line) {
4365 m_swx->DoScrollToLine(line);
4366 }
4367
4368
4369 // Scroll enough to make the given column visible
4370 void wxStyledTextCtrl::ScrollToColumn(int column) {
4371 m_swx->DoScrollToColumn(column);
4372 }
4373
4374
4375 #if wxUSE_TEXTCTRL
4376 bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType)
4377 {
4378 bool ok = wxTextAreaBase::DoSaveFile(filename, fileType);
4379 #else
4380 bool wxStyledTextCtrl::SaveFile(const wxString& filename)
4381 {
4382 #if wxUSE_FFILE
4383 wxFFile file(filename, wxT("w"));
4384 bool ok = file.IsOpened() && file.Write(GetValue(), *wxConvCurrent);
4385 #else
4386 bool ok = false;
4387 #endif // wxUSE_FFILE
4388 #endif
4389 if (ok)
4390 {
4391 SetSavePoint();
4392 }
4393 return ok;
4394 }
4395
4396 #if wxUSE_TEXTCTRL
4397 bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int fileType)
4398 {
4399 bool ok = wxTextAreaBase::DoLoadFile(filename, fileType);
4400 #else
4401 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
4402 {
4403 #if wxUSE_FFILE
4404 wxFFile file(filename);
4405 bool ok = file.IsOpened();
4406 if (ok)
4407 {
4408 wxString text;
4409 ok = file.ReadAll(&text, *wxConvCurrent);
4410 if (ok)
4411 {
4412 SetValue(text);
4413 }
4414 }
4415 #else
4416 bool ok = false;
4417 #endif // wxUSE_FFILE
4418 #endif
4419 if (ok)
4420 {
4421 EmptyUndoBuffer();
4422 SetSavePoint();
4423 }
4424 return ok;
4425 }
4426
4427 #if wxUSE_DRAG_AND_DROP
4428 wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
4429 return m_swx->DoDragOver(x, y, def);
4430 }
4431
4432
4433 bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
4434 return m_swx->DoDropText(x, y, data);
4435 }
4436 #endif
4437
4438
4439 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
4440 m_swx->SetUseAntiAliasing(useAA);
4441 }
4442
4443 bool wxStyledTextCtrl::GetUseAntiAliasing() {
4444 return m_swx->GetUseAntiAliasing();
4445 }
4446
4447
4448
4449
4450
4451 void wxStyledTextCtrl::AddTextRaw(const char* text, int length)
4452 {
4453 if (length == -1)
4454 length = strlen(text);
4455 SendMsg(SCI_ADDTEXT, length, (sptr_t)text);
4456 }
4457
4458 void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
4459 {
4460 SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text);
4461 }
4462
4463 wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
4464 {
4465 int len = LineLength(GetCurrentLine());
4466 if (!len) {
4467 if (linePos) *linePos = 0;
4468 wxCharBuffer empty;
4469 return empty;
4470 }
4471
4472 wxCharBuffer buf(len);
4473 int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data());
4474 if (linePos) *linePos = pos;
4475 return buf;
4476 }
4477
4478 wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
4479 {
4480 int len = LineLength(line);
4481 if (!len) {
4482 wxCharBuffer empty;
4483 return empty;
4484 }
4485
4486 wxCharBuffer buf(len);
4487 SendMsg(SCI_GETLINE, line, (sptr_t)buf.data());
4488 return buf;
4489 }
4490
4491 wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
4492 {
4493 // Calculate the length needed first.
4494 const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
4495
4496 // And then really get the data.
4497 wxCharBuffer buf(len);
4498 SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
4499 return buf;
4500 }
4501
4502 wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
4503 {
4504 if (endPos < startPos) {
4505 int temp = startPos;
4506 startPos = endPos;
4507 endPos = temp;
4508 }
4509 int len = endPos - startPos;
4510 if (!len) {
4511 wxCharBuffer empty;
4512 return empty;
4513 }
4514
4515 wxCharBuffer buf(len);
4516 TextRange tr;
4517 tr.lpstrText = buf.data();
4518 tr.chrg.cpMin = startPos;
4519 tr.chrg.cpMax = endPos;
4520 SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
4521 return buf;
4522 }
4523
4524 void wxStyledTextCtrl::SetTextRaw(const char* text)
4525 {
4526 SendMsg(SCI_SETTEXT, 0, (sptr_t)text);
4527 }
4528
4529 wxCharBuffer wxStyledTextCtrl::GetTextRaw()
4530 {
4531 int len = GetTextLength();
4532 wxCharBuffer buf(len); // adds 1 for NUL automatically
4533 SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data());
4534 return buf;
4535 }
4536
4537 void wxStyledTextCtrl::AppendTextRaw(const char* text, int length)
4538 {
4539 if (length == -1)
4540 length = strlen(text);
4541 SendMsg(SCI_APPENDTEXT, length, (sptr_t)text);
4542 }
4543
4544
4545
4546
4547
4548 //----------------------------------------------------------------------
4549 // Event handlers
4550
4551 void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
4552 wxPaintDC dc(this);
4553 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
4554 }
4555
4556 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
4557 if (evt.GetOrientation() == wxHORIZONTAL)
4558 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4559 else
4560 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4561 }
4562
4563 void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
4564 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
4565 if (sb) {
4566 if (sb->IsVertical())
4567 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4568 else
4569 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4570 }
4571 }
4572
4573 void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
4574 if (m_swx) {
4575 wxSize sz = GetClientSize();
4576 m_swx->DoSize(sz.x, sz.y);
4577 }
4578 }
4579
4580 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
4581 SetFocus();
4582 wxPoint pt = evt.GetPosition();
4583 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
4584 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
4585 }
4586
4587 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
4588 wxPoint pt = evt.GetPosition();
4589 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
4590 }
4591
4592 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
4593 wxPoint pt = evt.GetPosition();
4594 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
4595 evt.ControlDown());
4596 }
4597
4598
4599 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
4600 wxPoint pt = evt.GetPosition();
4601 m_swx->DoContextMenu(Point(pt.x, pt.y));
4602 }
4603
4604
4605 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
4606 wxPoint pt = evt.GetPosition();
4607 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
4608 }
4609
4610 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
4611 wxPoint pt = evt.GetPosition();
4612 ScreenToClient(&pt.x, &pt.y);
4613 /*
4614 Show context menu at event point if it's within the window,
4615 or at caret location if not
4616 */
4617 wxHitTest ht = this->HitTest(pt);
4618 if (ht != wxHT_WINDOW_INSIDE) {
4619 pt = this->PointFromPosition(this->GetCurrentPos());
4620 }
4621 m_swx->DoContextMenu(Point(pt.x, pt.y));
4622 }
4623
4624
4625 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
4626 {
4627 m_swx->DoMouseWheel(evt.GetWheelRotation(),
4628 evt.GetWheelDelta(),
4629 evt.GetLinesPerAction(),
4630 evt.ControlDown(),
4631 evt.IsPageScroll());
4632 }
4633
4634
4635 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
4636 // On (some?) non-US PC keyboards the AltGr key is required to enter some
4637 // common characters. It comes to us as both Alt and Ctrl down so we need
4638 // to let the char through in that case, otherwise if only ctrl or only
4639 // alt let's skip it.
4640 bool ctrl = evt.ControlDown();
4641 #ifdef __WXMAC__
4642 // On the Mac the Alt key is just a modifier key (like Shift) so we need
4643 // to allow the char events to be processed when Alt is pressed.
4644 // TODO: Should we check MetaDown instead in this case?
4645 bool alt = false;
4646 #else
4647 bool alt = evt.AltDown();
4648 #endif
4649 bool skip = ((ctrl || alt) && ! (ctrl && alt));
4650
4651 #if wxUSE_UNICODE
4652 // apparently if we don't do this, Unicode keys pressed after non-char
4653 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
4654 if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255)
4655 m_lastKeyDownConsumed = false;
4656 #endif
4657
4658 if (!m_lastKeyDownConsumed && !skip) {
4659 #if wxUSE_UNICODE
4660 int key = evt.GetUnicodeKey();
4661 bool keyOk = true;
4662
4663 // if the unicode key code is not really a unicode character (it may
4664 // be a function key or etc., the platforms appear to always give us a
4665 // small value in this case) then fallback to the ascii key code but
4666 // don't do anything for function keys or etc.
4667 if (key <= 127) {
4668 key = evt.GetKeyCode();
4669 keyOk = (key <= 127);
4670 }
4671 if (keyOk) {
4672 m_swx->DoAddChar(key);
4673 return;
4674 }
4675 #else
4676 int key = evt.GetKeyCode();
4677 if (key <= WXK_START || key > WXK_COMMAND) {
4678 m_swx->DoAddChar(key);
4679 return;
4680 }
4681 #endif
4682 }
4683
4684 evt.Skip();
4685 }
4686
4687
4688 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
4689 int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
4690 if (!processed && !m_lastKeyDownConsumed)
4691 evt.Skip();
4692 }
4693
4694
4695 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
4696 m_swx->DoLoseFocus();
4697 evt.Skip();
4698 }
4699
4700
4701 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
4702 m_swx->DoGainFocus();
4703 evt.Skip();
4704 }
4705
4706
4707 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
4708 m_swx->DoSysColourChange();
4709 }
4710
4711
4712 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
4713 // do nothing to help avoid flashing
4714 }
4715
4716
4717
4718 void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
4719 m_swx->DoCommand(evt.GetId());
4720 }
4721
4722
4723 void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
4724 m_swx->DoOnListBox();
4725 }
4726
4727
4728 void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
4729 m_swx->DoOnIdle(evt);
4730 }
4731
4732
4733 wxSize wxStyledTextCtrl::DoGetBestSize() const
4734 {
4735 // What would be the best size for a wxSTC?
4736 // Just give a reasonable minimum until something else can be figured out.
4737 return wxSize(200,100);
4738 }
4739
4740
4741 //----------------------------------------------------------------------
4742 // Turn notifications from Scintilla into events
4743
4744
4745 void wxStyledTextCtrl::NotifyChange() {
4746 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
4747 evt.SetEventObject(this);
4748 GetEventHandler()->ProcessEvent(evt);
4749 }
4750
4751
4752 static void SetEventText(wxStyledTextEvent& evt, const char* text,
4753 size_t length) {
4754 if(!text) return;
4755
4756 evt.SetText(stc2wx(text, length));
4757 }
4758
4759
4760 void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
4761 SCNotification& scn = *_scn;
4762 wxStyledTextEvent evt(0, GetId());
4763
4764 evt.SetEventObject(this);
4765 evt.SetPosition(scn.position);
4766 evt.SetKey(scn.ch);
4767 evt.SetModifiers(scn.modifiers);
4768
4769 switch (scn.nmhdr.code) {
4770 case SCN_STYLENEEDED:
4771 evt.SetEventType(wxEVT_STC_STYLENEEDED);
4772 break;
4773
4774 case SCN_CHARADDED:
4775 evt.SetEventType(wxEVT_STC_CHARADDED);
4776 break;
4777
4778 case SCN_SAVEPOINTREACHED:
4779 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
4780 break;
4781
4782 case SCN_SAVEPOINTLEFT:
4783 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
4784 break;
4785
4786 case SCN_MODIFYATTEMPTRO:
4787 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
4788 break;
4789
4790 case SCN_KEY:
4791 evt.SetEventType(wxEVT_STC_KEY);
4792 break;
4793
4794 case SCN_DOUBLECLICK:
4795 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
4796 evt.SetLine(scn.line);
4797 break;
4798
4799 case SCN_UPDATEUI:
4800 evt.SetEventType(wxEVT_STC_UPDATEUI);
4801 evt.SetUpdated(scn.updated);
4802 break;
4803
4804 case SCN_MODIFIED:
4805 evt.SetEventType(wxEVT_STC_MODIFIED);
4806 evt.SetModificationType(scn.modificationType);
4807 SetEventText(evt, scn.text, scn.length);
4808 evt.SetLength(scn.length);
4809 evt.SetLinesAdded(scn.linesAdded);
4810 evt.SetLine(scn.line);
4811 evt.SetFoldLevelNow(scn.foldLevelNow);
4812 evt.SetFoldLevelPrev(scn.foldLevelPrev);
4813 evt.SetToken(scn.token);
4814 evt.SetAnnotationLinesAdded(scn.annotationLinesAdded);
4815 break;
4816
4817 case SCN_MACRORECORD:
4818 evt.SetEventType(wxEVT_STC_MACRORECORD);
4819 evt.SetMessage(scn.message);
4820 evt.SetWParam(scn.wParam);
4821 evt.SetLParam(scn.lParam);
4822 break;
4823
4824 case SCN_MARGINCLICK:
4825 evt.SetEventType(wxEVT_STC_MARGINCLICK);
4826 evt.SetMargin(scn.margin);
4827 break;
4828
4829 case SCN_NEEDSHOWN:
4830 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
4831 evt.SetLength(scn.length);
4832 break;
4833
4834 case SCN_PAINTED:
4835 evt.SetEventType(wxEVT_STC_PAINTED);
4836 break;
4837
4838 case SCN_AUTOCSELECTION:
4839 evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION);
4840 evt.SetListType(scn.listType);
4841 SetEventText(evt, scn.text, strlen(scn.text));
4842 evt.SetPosition(scn.lParam);
4843 break;
4844
4845 case SCN_USERLISTSELECTION:
4846 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
4847 evt.SetListType(scn.listType);
4848 SetEventText(evt, scn.text, strlen(scn.text));
4849 evt.SetPosition(scn.lParam);
4850 break;
4851
4852 case SCN_URIDROPPED:
4853 evt.SetEventType(wxEVT_STC_URIDROPPED);
4854 SetEventText(evt, scn.text, strlen(scn.text));
4855 break;
4856
4857 case SCN_DWELLSTART:
4858 evt.SetEventType(wxEVT_STC_DWELLSTART);
4859 evt.SetX(scn.x);
4860 evt.SetY(scn.y);
4861 break;
4862
4863 case SCN_DWELLEND:
4864 evt.SetEventType(wxEVT_STC_DWELLEND);
4865 evt.SetX(scn.x);
4866 evt.SetY(scn.y);
4867 break;
4868
4869 case SCN_ZOOM:
4870 evt.SetEventType(wxEVT_STC_ZOOM);
4871 break;
4872
4873 case SCN_HOTSPOTCLICK:
4874 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
4875 break;
4876
4877 case SCN_HOTSPOTDOUBLECLICK:
4878 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
4879 break;
4880
4881 case SCN_CALLTIPCLICK:
4882 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
4883 break;
4884
4885 case SCN_INDICATORCLICK:
4886 evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
4887 break;
4888
4889 case SCN_INDICATORRELEASE:
4890 evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
4891 break;
4892
4893 case SCN_AUTOCCANCELLED:
4894 evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED);
4895 break;
4896
4897 case SCN_AUTOCCHARDELETED:
4898 evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED);
4899 break;
4900
4901 case SCN_HOTSPOTRELEASECLICK:
4902 evt.SetEventType(wxEVT_STC_HOTSPOT_RELEASE_CLICK);
4903 break;
4904
4905 default:
4906 return;
4907 }
4908
4909 GetEventHandler()->ProcessEvent(evt);
4910 }
4911
4912
4913 //----------------------------------------------------------------------
4914 //----------------------------------------------------------------------
4915 //----------------------------------------------------------------------
4916
4917 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
4918 : wxCommandEvent(commandType, id)
4919 {
4920 m_position = 0;
4921 m_key = 0;
4922 m_modifiers = 0;
4923 m_modificationType = 0;
4924 m_length = 0;
4925 m_linesAdded = 0;
4926 m_line = 0;
4927 m_foldLevelNow = 0;
4928 m_foldLevelPrev = 0;
4929 m_margin = 0;
4930 m_message = 0;
4931 m_wParam = 0;
4932 m_lParam = 0;
4933 m_listType = 0;
4934 m_x = 0;
4935 m_y = 0;
4936 m_token = 0;
4937 m_annotationLinesAdded = 0;
4938 m_updated = 0;
4939
4940 #if wxUSE_DRAG_AND_DROP
4941 m_dragFlags = wxDrag_CopyOnly;
4942 m_dragResult = wxDragNone;
4943 #endif
4944 }
4945
4946 bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
4947 bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
4948 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
4949
4950
4951 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
4952 wxCommandEvent(event)
4953 {
4954 m_position = event.m_position;
4955 m_key = event.m_key;
4956 m_modifiers = event.m_modifiers;
4957 m_modificationType = event.m_modificationType;
4958 m_text = event.m_text;
4959 m_length = event.m_length;
4960 m_linesAdded = event.m_linesAdded;
4961 m_line = event.m_line;
4962 m_foldLevelNow = event.m_foldLevelNow;
4963 m_foldLevelPrev = event.m_foldLevelPrev;
4964
4965 m_margin = event.m_margin;
4966
4967 m_message = event.m_message;
4968 m_wParam = event.m_wParam;
4969 m_lParam = event.m_lParam;
4970
4971 m_listType = event.m_listType;
4972 m_x = event.m_x;
4973 m_y = event.m_y;
4974
4975 m_token = event.m_token;
4976 m_annotationLinesAdded = event.m_annotationLinesAdded;
4977 m_updated = event.m_updated;
4978
4979 #if wxUSE_DRAG_AND_DROP
4980 m_dragText = event.m_dragText;
4981 m_dragFlags = event.m_dragFlags;
4982 m_dragResult = event.m_dragResult;
4983 #endif
4984 }
4985
4986 //----------------------------------------------------------------------
4987 //----------------------------------------------------------------------
4988
4989 /*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo()
4990 {
4991 return wxVersionInfo("Scintilla", 3, 21, 0, "Scintilla 3.21");
4992 }
4993
4994 #endif // wxUSE_STC