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