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