]> git.saurik.com Git - wxWidgets.git/blob - src/stc/stc.cpp
Use the data scheme to load resources in the WebKitGTK+ implementation, rather than...
[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_lastWheelTimestamp = 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_CUSTOM);
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 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
262 SendMsg(2001, strlen(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 wxWX2MBbuf buf = (wxWX2MBbuf)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 long start;
1508 long end;
1509
1510 GetSelection(&start, &end);
1511 int len = end - start;
1512 if (!len) return wxEmptyString;
1513
1514 wxMemoryBuffer mbuf(len+2);
1515 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1516 SendMsg(2161, 0, (sptr_t)buf);
1517 mbuf.UngetWriteBuf(len);
1518 mbuf.AppendByte(0);
1519 return stc2wx(buf);
1520 }
1521
1522 // Retrieve a range of text.
1523 wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1524 if (endPos < startPos) {
1525 int temp = startPos;
1526 startPos = endPos;
1527 endPos = temp;
1528 }
1529 int len = endPos - startPos;
1530 if (!len) return wxEmptyString;
1531 wxMemoryBuffer mbuf(len+1);
1532 char* buf = (char*)mbuf.GetWriteBuf(len);
1533 TextRange tr;
1534 tr.lpstrText = buf;
1535 tr.chrg.cpMin = startPos;
1536 tr.chrg.cpMax = endPos;
1537 SendMsg(2162, 0, (sptr_t)&tr);
1538 mbuf.UngetWriteBuf(len);
1539 mbuf.AppendByte(0);
1540 return stc2wx(buf);
1541 }
1542
1543 // Draw the selection in normal style or with selection highlighted.
1544 void wxStyledTextCtrl::HideSelection(bool normal)
1545 {
1546 SendMsg(2163, normal, 0);
1547 }
1548
1549 // Retrieve the line containing a position.
1550 int wxStyledTextCtrl::LineFromPosition(int pos) const
1551 {
1552 return SendMsg(2166, pos, 0);
1553 }
1554
1555 // Retrieve the position at the start of a line.
1556 int wxStyledTextCtrl::PositionFromLine(int line) const
1557 {
1558 return SendMsg(2167, line, 0);
1559 }
1560
1561 // Scroll horizontally and vertically.
1562 void wxStyledTextCtrl::LineScroll(int columns, int lines)
1563 {
1564 SendMsg(2168, columns, lines);
1565 }
1566
1567 // Ensure the caret is visible.
1568 void wxStyledTextCtrl::EnsureCaretVisible()
1569 {
1570 SendMsg(2169, 0, 0);
1571 }
1572
1573 // Replace the selected text with the argument text.
1574 void wxStyledTextCtrl::ReplaceSelection(const wxString& text)
1575 {
1576 SendMsg(2170, 0, (sptr_t)(const char*)wx2stc(text));
1577 }
1578
1579 // Set to read only or read write.
1580 void wxStyledTextCtrl::SetReadOnly(bool readOnly)
1581 {
1582 SendMsg(2171, readOnly, 0);
1583 }
1584
1585 // Will a paste succeed?
1586 bool wxStyledTextCtrl::CanPaste() const
1587 {
1588 return SendMsg(2173, 0, 0) != 0;
1589 }
1590
1591 // Are there any undoable actions in the undo history?
1592 bool wxStyledTextCtrl::CanUndo() const
1593 {
1594 return SendMsg(2174, 0, 0) != 0;
1595 }
1596
1597 // Delete the undo history.
1598 void wxStyledTextCtrl::EmptyUndoBuffer()
1599 {
1600 SendMsg(2175, 0, 0);
1601 }
1602
1603 // Undo one action in the undo history.
1604 void wxStyledTextCtrl::Undo()
1605 {
1606 SendMsg(2176, 0, 0);
1607 }
1608
1609 // Cut the selection to the clipboard.
1610 void wxStyledTextCtrl::Cut()
1611 {
1612 SendMsg(2177, 0, 0);
1613 }
1614
1615 // Copy the selection to the clipboard.
1616 void wxStyledTextCtrl::Copy()
1617 {
1618 SendMsg(2178, 0, 0);
1619 }
1620
1621 // Paste the contents of the clipboard into the document replacing the selection.
1622 void wxStyledTextCtrl::Paste()
1623 {
1624 SendMsg(2179, 0, 0);
1625 }
1626
1627 // Clear the selection.
1628 void wxStyledTextCtrl::Clear()
1629 {
1630 SendMsg(2180, 0, 0);
1631 }
1632
1633 // Replace the contents of the document with the argument text.
1634 void wxStyledTextCtrl::SetText(const wxString& text)
1635 {
1636 SendMsg(2181, 0, (sptr_t)(const char*)wx2stc(text));
1637 }
1638
1639 // Retrieve all the text in the document.
1640 wxString wxStyledTextCtrl::GetText() const {
1641 int len = GetTextLength();
1642 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1643 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1644 SendMsg(2182, len+1, (sptr_t)buf);
1645 mbuf.UngetWriteBuf(len);
1646 mbuf.AppendByte(0);
1647 return stc2wx(buf);
1648 }
1649
1650 // Retrieve the number of characters in the document.
1651 int wxStyledTextCtrl::GetTextLength() const
1652 {
1653 return SendMsg(2183, 0, 0);
1654 }
1655
1656 // Set to overtype (true) or insert mode.
1657 void wxStyledTextCtrl::SetOvertype(bool overtype)
1658 {
1659 SendMsg(2186, overtype, 0);
1660 }
1661
1662 // Returns true if overtype mode is active otherwise false is returned.
1663 bool wxStyledTextCtrl::GetOvertype() const
1664 {
1665 return SendMsg(2187, 0, 0) != 0;
1666 }
1667
1668 // Set the width of the insert mode caret.
1669 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth)
1670 {
1671 SendMsg(2188, pixelWidth, 0);
1672 }
1673
1674 // Returns the width of the insert mode caret.
1675 int wxStyledTextCtrl::GetCaretWidth() const
1676 {
1677 return SendMsg(2189, 0, 0);
1678 }
1679
1680 // Sets the position that starts the target which is used for updating the
1681 // document without affecting the scroll position.
1682 void wxStyledTextCtrl::SetTargetStart(int pos)
1683 {
1684 SendMsg(2190, pos, 0);
1685 }
1686
1687 // Get the position that starts the target.
1688 int wxStyledTextCtrl::GetTargetStart() const
1689 {
1690 return SendMsg(2191, 0, 0);
1691 }
1692
1693 // Sets the position that ends the target which is used for updating the
1694 // document without affecting the scroll position.
1695 void wxStyledTextCtrl::SetTargetEnd(int pos)
1696 {
1697 SendMsg(2192, pos, 0);
1698 }
1699
1700 // Get the position that ends the target.
1701 int wxStyledTextCtrl::GetTargetEnd() const
1702 {
1703 return SendMsg(2193, 0, 0);
1704 }
1705
1706 // Replace the target text with the argument text.
1707 // Text is counted so it can contain NULs.
1708 // Returns the length of the replacement text.
1709
1710 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1711 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1712 return SendMsg(2194, strlen(buf), (sptr_t)(const char*)buf);
1713 }
1714
1715 // Replace the target text with the argument text after \d processing.
1716 // Text is counted so it can contain NULs.
1717 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1718 // matched in the last search operation which were surrounded by \( and \).
1719 // Returns the length of the replacement text including any change
1720 // caused by processing the \d patterns.
1721
1722 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1723 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1724 return SendMsg(2195, strlen(buf), (sptr_t)(const char*)buf);
1725 }
1726
1727 // Search for a counted string in the target and set the target to the found
1728 // range. Text is counted so it can contain NULs.
1729 // Returns length of range or -1 for failure in which case target is not moved.
1730
1731 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1732 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1733 return SendMsg(2197, strlen(buf), (sptr_t)(const char*)buf);
1734 }
1735
1736 // Set the search flags used by SearchInTarget.
1737 void wxStyledTextCtrl::SetSearchFlags(int flags)
1738 {
1739 SendMsg(2198, flags, 0);
1740 }
1741
1742 // Get the search flags used by SearchInTarget.
1743 int wxStyledTextCtrl::GetSearchFlags() const
1744 {
1745 return SendMsg(2199, 0, 0);
1746 }
1747
1748 // Show a call tip containing a definition near position pos.
1749 void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition)
1750 {
1751 SendMsg(2200, pos, (sptr_t)(const char*)wx2stc(definition));
1752 }
1753
1754 // Remove the call tip from the screen.
1755 void wxStyledTextCtrl::CallTipCancel()
1756 {
1757 SendMsg(2201, 0, 0);
1758 }
1759
1760 // Is there an active call tip?
1761 bool wxStyledTextCtrl::CallTipActive()
1762 {
1763 return SendMsg(2202, 0, 0) != 0;
1764 }
1765
1766 // Retrieve the position where the caret was before displaying the call tip.
1767 int wxStyledTextCtrl::CallTipPosAtStart()
1768 {
1769 return SendMsg(2203, 0, 0);
1770 }
1771
1772 // Highlight a segment of the definition.
1773 void wxStyledTextCtrl::CallTipSetHighlight(int start, int end)
1774 {
1775 SendMsg(2204, start, end);
1776 }
1777
1778 // Set the background colour for the call tip.
1779 void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back)
1780 {
1781 SendMsg(2205, wxColourAsLong(back), 0);
1782 }
1783
1784 // Set the foreground colour for the call tip.
1785 void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore)
1786 {
1787 SendMsg(2206, wxColourAsLong(fore), 0);
1788 }
1789
1790 // Set the foreground colour for the highlighted part of the call tip.
1791 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore)
1792 {
1793 SendMsg(2207, wxColourAsLong(fore), 0);
1794 }
1795
1796 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1797 void wxStyledTextCtrl::CallTipUseStyle(int tabSize)
1798 {
1799 SendMsg(2212, tabSize, 0);
1800 }
1801
1802 // Find the display line of a document line taking hidden lines into account.
1803 int wxStyledTextCtrl::VisibleFromDocLine(int line)
1804 {
1805 return SendMsg(2220, line, 0);
1806 }
1807
1808 // Find the document line of a display line taking hidden lines into account.
1809 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay)
1810 {
1811 return SendMsg(2221, lineDisplay, 0);
1812 }
1813
1814 // The number of display lines needed to wrap a document line
1815 int wxStyledTextCtrl::WrapCount(int line)
1816 {
1817 return SendMsg(2235, line, 0);
1818 }
1819
1820 // Set the fold level of a line.
1821 // This encodes an integer level along with flags indicating whether the
1822 // line is a header and whether it is effectively white space.
1823 void wxStyledTextCtrl::SetFoldLevel(int line, int level)
1824 {
1825 SendMsg(2222, line, level);
1826 }
1827
1828 // Retrieve the fold level of a line.
1829 int wxStyledTextCtrl::GetFoldLevel(int line) const
1830 {
1831 return SendMsg(2223, line, 0);
1832 }
1833
1834 // Find the last child line of a header line.
1835 int wxStyledTextCtrl::GetLastChild(int line, int level) const
1836 {
1837 return SendMsg(2224, line, level);
1838 }
1839
1840 // Find the parent line of a child line.
1841 int wxStyledTextCtrl::GetFoldParent(int line) const
1842 {
1843 return SendMsg(2225, line, 0);
1844 }
1845
1846 // Make a range of lines visible.
1847 void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd)
1848 {
1849 SendMsg(2226, lineStart, lineEnd);
1850 }
1851
1852 // Make a range of lines invisible.
1853 void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd)
1854 {
1855 SendMsg(2227, lineStart, lineEnd);
1856 }
1857
1858 // Is a line visible?
1859 bool wxStyledTextCtrl::GetLineVisible(int line) const
1860 {
1861 return SendMsg(2228, line, 0) != 0;
1862 }
1863
1864 // Show the children of a header line.
1865 void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded)
1866 {
1867 SendMsg(2229, line, expanded);
1868 }
1869
1870 // Is a header line expanded?
1871 bool wxStyledTextCtrl::GetFoldExpanded(int line) const
1872 {
1873 return SendMsg(2230, line, 0) != 0;
1874 }
1875
1876 // Switch a header line between expanded and contracted.
1877 void wxStyledTextCtrl::ToggleFold(int line)
1878 {
1879 SendMsg(2231, line, 0);
1880 }
1881
1882 // Ensure a particular line is visible by expanding any header line hiding it.
1883 void wxStyledTextCtrl::EnsureVisible(int line)
1884 {
1885 SendMsg(2232, line, 0);
1886 }
1887
1888 // Set some style options for folding.
1889 void wxStyledTextCtrl::SetFoldFlags(int flags)
1890 {
1891 SendMsg(2233, flags, 0);
1892 }
1893
1894 // Ensure a particular line is visible by expanding any header line hiding it.
1895 // Use the currently set visibility policy to determine which range to display.
1896 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line)
1897 {
1898 SendMsg(2234, line, 0);
1899 }
1900
1901 // Sets whether a tab pressed when caret is within indentation indents.
1902 void wxStyledTextCtrl::SetTabIndents(bool tabIndents)
1903 {
1904 SendMsg(2260, tabIndents, 0);
1905 }
1906
1907 // Does a tab pressed when caret is within indentation indent?
1908 bool wxStyledTextCtrl::GetTabIndents() const
1909 {
1910 return SendMsg(2261, 0, 0) != 0;
1911 }
1912
1913 // Sets whether a backspace pressed when caret is within indentation unindents.
1914 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents)
1915 {
1916 SendMsg(2262, bsUnIndents, 0);
1917 }
1918
1919 // Does a backspace pressed when caret is within indentation unindent?
1920 bool wxStyledTextCtrl::GetBackSpaceUnIndents() const
1921 {
1922 return SendMsg(2263, 0, 0) != 0;
1923 }
1924
1925 // Sets the time the mouse must sit still to generate a mouse dwell event.
1926 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds)
1927 {
1928 SendMsg(2264, periodMilliseconds, 0);
1929 }
1930
1931 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1932 int wxStyledTextCtrl::GetMouseDwellTime() const
1933 {
1934 return SendMsg(2265, 0, 0);
1935 }
1936
1937 // Get position of start of word.
1938 int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters)
1939 {
1940 return SendMsg(2266, pos, onlyWordCharacters);
1941 }
1942
1943 // Get position of end of word.
1944 int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters)
1945 {
1946 return SendMsg(2267, pos, onlyWordCharacters);
1947 }
1948
1949 // Sets whether text is word wrapped.
1950 void wxStyledTextCtrl::SetWrapMode(int mode)
1951 {
1952 SendMsg(2268, mode, 0);
1953 }
1954
1955 // Retrieve whether text is word wrapped.
1956 int wxStyledTextCtrl::GetWrapMode() const
1957 {
1958 return SendMsg(2269, 0, 0);
1959 }
1960
1961 // Set the display mode of visual flags for wrapped lines.
1962 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags)
1963 {
1964 SendMsg(2460, wrapVisualFlags, 0);
1965 }
1966
1967 // Retrive the display mode of visual flags for wrapped lines.
1968 int wxStyledTextCtrl::GetWrapVisualFlags() const
1969 {
1970 return SendMsg(2461, 0, 0);
1971 }
1972
1973 // Set the location of visual flags for wrapped lines.
1974 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation)
1975 {
1976 SendMsg(2462, wrapVisualFlagsLocation, 0);
1977 }
1978
1979 // Retrive the location of visual flags for wrapped lines.
1980 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const
1981 {
1982 return SendMsg(2463, 0, 0);
1983 }
1984
1985 // Set the start indent for wrapped lines.
1986 void wxStyledTextCtrl::SetWrapStartIndent(int indent)
1987 {
1988 SendMsg(2464, indent, 0);
1989 }
1990
1991 // Retrive the start indent for wrapped lines.
1992 int wxStyledTextCtrl::GetWrapStartIndent() const
1993 {
1994 return SendMsg(2465, 0, 0);
1995 }
1996
1997 // Sets how wrapped sublines are placed. Default is fixed.
1998 void wxStyledTextCtrl::SetWrapIndentMode(int mode)
1999 {
2000 SendMsg(2472, mode, 0);
2001 }
2002
2003 // Retrieve how wrapped sublines are placed. Default is fixed.
2004 int wxStyledTextCtrl::GetWrapIndentMode() const
2005 {
2006 return SendMsg(2473, 0, 0);
2007 }
2008
2009 // Sets the degree of caching of layout information.
2010 void wxStyledTextCtrl::SetLayoutCache(int mode)
2011 {
2012 SendMsg(2272, mode, 0);
2013 }
2014
2015 // Retrieve the degree of caching of layout information.
2016 int wxStyledTextCtrl::GetLayoutCache() const
2017 {
2018 return SendMsg(2273, 0, 0);
2019 }
2020
2021 // Sets the document width assumed for scrolling.
2022 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth)
2023 {
2024 SendMsg(2274, pixelWidth, 0);
2025 }
2026
2027 // Retrieve the document width assumed for scrolling.
2028 int wxStyledTextCtrl::GetScrollWidth() const
2029 {
2030 return SendMsg(2275, 0, 0);
2031 }
2032
2033 // Sets whether the maximum width line displayed is used to set scroll width.
2034 void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking)
2035 {
2036 SendMsg(2516, tracking, 0);
2037 }
2038
2039 // Retrieve whether the scroll width tracks wide lines.
2040 bool wxStyledTextCtrl::GetScrollWidthTracking() const
2041 {
2042 return SendMsg(2517, 0, 0) != 0;
2043 }
2044
2045 // Measure the pixel width of some text in a particular style.
2046 // NUL terminated text argument.
2047 // Does not handle tab or control characters.
2048 int wxStyledTextCtrl::TextWidth(int style, const wxString& text)
2049 {
2050 return SendMsg(2276, style, (sptr_t)(const char*)wx2stc(text));
2051 }
2052
2053 // Sets the scroll range so that maximum scroll position has
2054 // the last line at the bottom of the view (default).
2055 // Setting this to false allows scrolling one page below the last line.
2056 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine)
2057 {
2058 SendMsg(2277, endAtLastLine, 0);
2059 }
2060
2061 // Retrieve whether the maximum scroll position has the last
2062 // line at the bottom of the view.
2063 bool wxStyledTextCtrl::GetEndAtLastLine() const
2064 {
2065 return SendMsg(2278, 0, 0) != 0;
2066 }
2067
2068 // Retrieve the height of a particular line of text in pixels.
2069 int wxStyledTextCtrl::TextHeight(int line)
2070 {
2071 return SendMsg(2279, line, 0);
2072 }
2073
2074 // Show or hide the vertical scroll bar.
2075 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show)
2076 {
2077 SendMsg(2280, show, 0);
2078 }
2079
2080 // Is the vertical scroll bar visible?
2081 bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
2082 {
2083 return SendMsg(2281, 0, 0) != 0;
2084 }
2085
2086 // Append a string to the end of the document without changing the selection.
2087 void wxStyledTextCtrl::AppendText(const wxString& text) {
2088 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
2089 SendMsg(2282, strlen(buf), (sptr_t)(const char*)buf);
2090 }
2091
2092 // Is drawing done in two phases with backgrounds drawn before foregrounds?
2093 bool wxStyledTextCtrl::GetTwoPhaseDraw() const
2094 {
2095 return SendMsg(2283, 0, 0) != 0;
2096 }
2097
2098 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
2099 // and then the foreground. This avoids chopping off characters that overlap the next run.
2100 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase)
2101 {
2102 SendMsg(2284, twoPhase, 0);
2103 }
2104
2105 // Scroll so that a display line is at the top of the display.
2106 void wxStyledTextCtrl::SetFirstVisibleLine(int lineDisplay)
2107 {
2108 SendMsg(2613, lineDisplay, 0);
2109 }
2110
2111 // Make the target range start and end be the same as the selection range start and end.
2112 void wxStyledTextCtrl::TargetFromSelection()
2113 {
2114 SendMsg(2287, 0, 0);
2115 }
2116
2117 // Join the lines in the target.
2118 void wxStyledTextCtrl::LinesJoin()
2119 {
2120 SendMsg(2288, 0, 0);
2121 }
2122
2123 // Split the lines in the target into lines that are less wide than pixelWidth
2124 // where possible.
2125 void wxStyledTextCtrl::LinesSplit(int pixelWidth)
2126 {
2127 SendMsg(2289, pixelWidth, 0);
2128 }
2129
2130 // Set the colours used as a chequerboard pattern in the fold margin
2131 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back)
2132 {
2133 SendMsg(2290, useSetting, wxColourAsLong(back));
2134 }
2135 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore)
2136 {
2137 SendMsg(2291, useSetting, wxColourAsLong(fore));
2138 }
2139
2140 // Move caret down one line.
2141 void wxStyledTextCtrl::LineDown()
2142 {
2143 SendMsg(2300, 0, 0);
2144 }
2145
2146 // Move caret down one line extending selection to new caret position.
2147 void wxStyledTextCtrl::LineDownExtend()
2148 {
2149 SendMsg(2301, 0, 0);
2150 }
2151
2152 // Move caret up one line.
2153 void wxStyledTextCtrl::LineUp()
2154 {
2155 SendMsg(2302, 0, 0);
2156 }
2157
2158 // Move caret up one line extending selection to new caret position.
2159 void wxStyledTextCtrl::LineUpExtend()
2160 {
2161 SendMsg(2303, 0, 0);
2162 }
2163
2164 // Move caret left one character.
2165 void wxStyledTextCtrl::CharLeft()
2166 {
2167 SendMsg(2304, 0, 0);
2168 }
2169
2170 // Move caret left one character extending selection to new caret position.
2171 void wxStyledTextCtrl::CharLeftExtend()
2172 {
2173 SendMsg(2305, 0, 0);
2174 }
2175
2176 // Move caret right one character.
2177 void wxStyledTextCtrl::CharRight()
2178 {
2179 SendMsg(2306, 0, 0);
2180 }
2181
2182 // Move caret right one character extending selection to new caret position.
2183 void wxStyledTextCtrl::CharRightExtend()
2184 {
2185 SendMsg(2307, 0, 0);
2186 }
2187
2188 // Move caret left one word.
2189 void wxStyledTextCtrl::WordLeft()
2190 {
2191 SendMsg(2308, 0, 0);
2192 }
2193
2194 // Move caret left one word extending selection to new caret position.
2195 void wxStyledTextCtrl::WordLeftExtend()
2196 {
2197 SendMsg(2309, 0, 0);
2198 }
2199
2200 // Move caret right one word.
2201 void wxStyledTextCtrl::WordRight()
2202 {
2203 SendMsg(2310, 0, 0);
2204 }
2205
2206 // Move caret right one word extending selection to new caret position.
2207 void wxStyledTextCtrl::WordRightExtend()
2208 {
2209 SendMsg(2311, 0, 0);
2210 }
2211
2212 // Move caret to first position on line.
2213 void wxStyledTextCtrl::Home()
2214 {
2215 SendMsg(2312, 0, 0);
2216 }
2217
2218 // Move caret to first position on line extending selection to new caret position.
2219 void wxStyledTextCtrl::HomeExtend()
2220 {
2221 SendMsg(2313, 0, 0);
2222 }
2223
2224 // Move caret to last position on line.
2225 void wxStyledTextCtrl::LineEnd()
2226 {
2227 SendMsg(2314, 0, 0);
2228 }
2229
2230 // Move caret to last position on line extending selection to new caret position.
2231 void wxStyledTextCtrl::LineEndExtend()
2232 {
2233 SendMsg(2315, 0, 0);
2234 }
2235
2236 // Move caret to first position in document.
2237 void wxStyledTextCtrl::DocumentStart()
2238 {
2239 SendMsg(2316, 0, 0);
2240 }
2241
2242 // Move caret to first position in document extending selection to new caret position.
2243 void wxStyledTextCtrl::DocumentStartExtend()
2244 {
2245 SendMsg(2317, 0, 0);
2246 }
2247
2248 // Move caret to last position in document.
2249 void wxStyledTextCtrl::DocumentEnd()
2250 {
2251 SendMsg(2318, 0, 0);
2252 }
2253
2254 // Move caret to last position in document extending selection to new caret position.
2255 void wxStyledTextCtrl::DocumentEndExtend()
2256 {
2257 SendMsg(2319, 0, 0);
2258 }
2259
2260 // Move caret one page up.
2261 void wxStyledTextCtrl::PageUp()
2262 {
2263 SendMsg(2320, 0, 0);
2264 }
2265
2266 // Move caret one page up extending selection to new caret position.
2267 void wxStyledTextCtrl::PageUpExtend()
2268 {
2269 SendMsg(2321, 0, 0);
2270 }
2271
2272 // Move caret one page down.
2273 void wxStyledTextCtrl::PageDown()
2274 {
2275 SendMsg(2322, 0, 0);
2276 }
2277
2278 // Move caret one page down extending selection to new caret position.
2279 void wxStyledTextCtrl::PageDownExtend()
2280 {
2281 SendMsg(2323, 0, 0);
2282 }
2283
2284 // Switch from insert to overtype mode or the reverse.
2285 void wxStyledTextCtrl::EditToggleOvertype()
2286 {
2287 SendMsg(2324, 0, 0);
2288 }
2289
2290 // Cancel any modes such as call tip or auto-completion list display.
2291 void wxStyledTextCtrl::Cancel()
2292 {
2293 SendMsg(2325, 0, 0);
2294 }
2295
2296 // Delete the selection or if no selection, the character before the caret.
2297 void wxStyledTextCtrl::DeleteBack()
2298 {
2299 SendMsg(2326, 0, 0);
2300 }
2301
2302 // If selection is empty or all on one line replace the selection with a tab character.
2303 // If more than one line selected, indent the lines.
2304 void wxStyledTextCtrl::Tab()
2305 {
2306 SendMsg(2327, 0, 0);
2307 }
2308
2309 // Dedent the selected lines.
2310 void wxStyledTextCtrl::BackTab()
2311 {
2312 SendMsg(2328, 0, 0);
2313 }
2314
2315 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
2316 void wxStyledTextCtrl::NewLine()
2317 {
2318 SendMsg(2329, 0, 0);
2319 }
2320
2321 // Insert a Form Feed character.
2322 void wxStyledTextCtrl::FormFeed()
2323 {
2324 SendMsg(2330, 0, 0);
2325 }
2326
2327 // Move caret to before first visible character on line.
2328 // If already there move to first character on line.
2329 void wxStyledTextCtrl::VCHome()
2330 {
2331 SendMsg(2331, 0, 0);
2332 }
2333
2334 // Like VCHome but extending selection to new caret position.
2335 void wxStyledTextCtrl::VCHomeExtend()
2336 {
2337 SendMsg(2332, 0, 0);
2338 }
2339
2340 // Magnify the displayed text by increasing the sizes by 1 point.
2341 void wxStyledTextCtrl::ZoomIn()
2342 {
2343 SendMsg(2333, 0, 0);
2344 }
2345
2346 // Make the displayed text smaller by decreasing the sizes by 1 point.
2347 void wxStyledTextCtrl::ZoomOut()
2348 {
2349 SendMsg(2334, 0, 0);
2350 }
2351
2352 // Delete the word to the left of the caret.
2353 void wxStyledTextCtrl::DelWordLeft()
2354 {
2355 SendMsg(2335, 0, 0);
2356 }
2357
2358 // Delete the word to the right of the caret.
2359 void wxStyledTextCtrl::DelWordRight()
2360 {
2361 SendMsg(2336, 0, 0);
2362 }
2363
2364 // Delete the word to the right of the caret, but not the trailing non-word characters.
2365 void wxStyledTextCtrl::DelWordRightEnd()
2366 {
2367 SendMsg(2518, 0, 0);
2368 }
2369
2370 // Cut the line containing the caret.
2371 void wxStyledTextCtrl::LineCut()
2372 {
2373 SendMsg(2337, 0, 0);
2374 }
2375
2376 // Delete the line containing the caret.
2377 void wxStyledTextCtrl::LineDelete()
2378 {
2379 SendMsg(2338, 0, 0);
2380 }
2381
2382 // Switch the current line with the previous.
2383 void wxStyledTextCtrl::LineTranspose()
2384 {
2385 SendMsg(2339, 0, 0);
2386 }
2387
2388 // Duplicate the current line.
2389 void wxStyledTextCtrl::LineDuplicate()
2390 {
2391 SendMsg(2404, 0, 0);
2392 }
2393
2394 // Transform the selection to lower case.
2395 void wxStyledTextCtrl::LowerCase()
2396 {
2397 SendMsg(2340, 0, 0);
2398 }
2399
2400 // Transform the selection to upper case.
2401 void wxStyledTextCtrl::UpperCase()
2402 {
2403 SendMsg(2341, 0, 0);
2404 }
2405
2406 // Scroll the document down, keeping the caret visible.
2407 void wxStyledTextCtrl::LineScrollDown()
2408 {
2409 SendMsg(2342, 0, 0);
2410 }
2411
2412 // Scroll the document up, keeping the caret visible.
2413 void wxStyledTextCtrl::LineScrollUp()
2414 {
2415 SendMsg(2343, 0, 0);
2416 }
2417
2418 // Delete the selection or if no selection, the character before the caret.
2419 // Will not delete the character before at the start of a line.
2420 void wxStyledTextCtrl::DeleteBackNotLine()
2421 {
2422 SendMsg(2344, 0, 0);
2423 }
2424
2425 // Move caret to first position on display line.
2426 void wxStyledTextCtrl::HomeDisplay()
2427 {
2428 SendMsg(2345, 0, 0);
2429 }
2430
2431 // Move caret to first position on display line extending selection to
2432 // new caret position.
2433 void wxStyledTextCtrl::HomeDisplayExtend()
2434 {
2435 SendMsg(2346, 0, 0);
2436 }
2437
2438 // Move caret to last position on display line.
2439 void wxStyledTextCtrl::LineEndDisplay()
2440 {
2441 SendMsg(2347, 0, 0);
2442 }
2443
2444 // Move caret to last position on display line extending selection to new
2445 // caret position.
2446 void wxStyledTextCtrl::LineEndDisplayExtend()
2447 {
2448 SendMsg(2348, 0, 0);
2449 }
2450
2451 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
2452 // except they behave differently when word-wrap is enabled:
2453 // They go first to the start / end of the display line, like (Home|LineEnd)Display
2454 // The difference is that, the cursor is already at the point, it goes on to the start
2455 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
2456 void wxStyledTextCtrl::HomeWrap()
2457 {
2458 SendMsg(2349, 0, 0);
2459 }
2460 void wxStyledTextCtrl::HomeWrapExtend()
2461 {
2462 SendMsg(2450, 0, 0);
2463 }
2464 void wxStyledTextCtrl::LineEndWrap()
2465 {
2466 SendMsg(2451, 0, 0);
2467 }
2468 void wxStyledTextCtrl::LineEndWrapExtend()
2469 {
2470 SendMsg(2452, 0, 0);
2471 }
2472 void wxStyledTextCtrl::VCHomeWrap()
2473 {
2474 SendMsg(2453, 0, 0);
2475 }
2476 void wxStyledTextCtrl::VCHomeWrapExtend()
2477 {
2478 SendMsg(2454, 0, 0);
2479 }
2480
2481 // Copy the line containing the caret.
2482 void wxStyledTextCtrl::LineCopy()
2483 {
2484 SendMsg(2455, 0, 0);
2485 }
2486
2487 // Move the caret inside current view if it's not there already.
2488 void wxStyledTextCtrl::MoveCaretInsideView()
2489 {
2490 SendMsg(2401, 0, 0);
2491 }
2492
2493 // How many characters are on a line, including end of line characters?
2494 int wxStyledTextCtrl::LineLength(int line) const
2495 {
2496 return SendMsg(2350, line, 0);
2497 }
2498
2499 // Highlight the characters at two positions.
2500 void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2)
2501 {
2502 SendMsg(2351, pos1, pos2);
2503 }
2504
2505 // Highlight the character at a position indicating there is no matching brace.
2506 void wxStyledTextCtrl::BraceBadLight(int pos)
2507 {
2508 SendMsg(2352, pos, 0);
2509 }
2510
2511 // Find the position of a matching brace or INVALID_POSITION if no match.
2512 int wxStyledTextCtrl::BraceMatch(int pos)
2513 {
2514 return SendMsg(2353, pos, 0);
2515 }
2516
2517 // Are the end of line characters visible?
2518 bool wxStyledTextCtrl::GetViewEOL() const
2519 {
2520 return SendMsg(2355, 0, 0) != 0;
2521 }
2522
2523 // Make the end of line characters visible or invisible.
2524 void wxStyledTextCtrl::SetViewEOL(bool visible)
2525 {
2526 SendMsg(2356, visible, 0);
2527 }
2528
2529 // Retrieve a pointer to the document object.
2530 void* wxStyledTextCtrl::GetDocPointer() {
2531 return (void*)SendMsg(2357);
2532 }
2533
2534 // Change the document object used.
2535 void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
2536 SendMsg(2358, 0, (sptr_t)docPointer);
2537 }
2538
2539 // Set which document modification events are sent to the container.
2540 void wxStyledTextCtrl::SetModEventMask(int mask)
2541 {
2542 SendMsg(2359, mask, 0);
2543 }
2544
2545 // Retrieve the column number which text should be kept within.
2546 int wxStyledTextCtrl::GetEdgeColumn() const
2547 {
2548 return SendMsg(2360, 0, 0);
2549 }
2550
2551 // Set the column number of the edge.
2552 // If text goes past the edge then it is highlighted.
2553 void wxStyledTextCtrl::SetEdgeColumn(int column)
2554 {
2555 SendMsg(2361, column, 0);
2556 }
2557
2558 // Retrieve the edge highlight mode.
2559 int wxStyledTextCtrl::GetEdgeMode() const
2560 {
2561 return SendMsg(2362, 0, 0);
2562 }
2563
2564 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2565 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2566 void wxStyledTextCtrl::SetEdgeMode(int mode)
2567 {
2568 SendMsg(2363, mode, 0);
2569 }
2570
2571 // Retrieve the colour used in edge indication.
2572 wxColour wxStyledTextCtrl::GetEdgeColour() const
2573 {
2574 long c = SendMsg(2364, 0, 0);
2575 return wxColourFromLong(c);
2576 }
2577
2578 // Change the colour used in edge indication.
2579 void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour)
2580 {
2581 SendMsg(2365, wxColourAsLong(edgeColour), 0);
2582 }
2583
2584 // Sets the current caret position to be the search anchor.
2585 void wxStyledTextCtrl::SearchAnchor()
2586 {
2587 SendMsg(2366, 0, 0);
2588 }
2589
2590 // Find some text starting at the search anchor.
2591 // Does not ensure the selection is visible.
2592 int wxStyledTextCtrl::SearchNext(int flags, const wxString& text)
2593 {
2594 return SendMsg(2367, flags, (sptr_t)(const char*)wx2stc(text));
2595 }
2596
2597 // Find some text starting at the search anchor and moving backwards.
2598 // Does not ensure the selection is visible.
2599 int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text)
2600 {
2601 return SendMsg(2368, flags, (sptr_t)(const char*)wx2stc(text));
2602 }
2603
2604 // Retrieves the number of lines completely visible.
2605 int wxStyledTextCtrl::LinesOnScreen() const
2606 {
2607 return SendMsg(2370, 0, 0);
2608 }
2609
2610 // Set whether a pop up menu is displayed automatically when the user presses
2611 // the wrong mouse button.
2612 void wxStyledTextCtrl::UsePopUp(bool allowPopUp)
2613 {
2614 SendMsg(2371, allowPopUp, 0);
2615 }
2616
2617 // Is the selection rectangular? The alternative is the more common stream selection.
2618 bool wxStyledTextCtrl::SelectionIsRectangle() const
2619 {
2620 return SendMsg(2372, 0, 0) != 0;
2621 }
2622
2623 // Set the zoom level. This number of points is added to the size of all fonts.
2624 // It may be positive to magnify or negative to reduce.
2625 void wxStyledTextCtrl::SetZoom(int zoom)
2626 {
2627 SendMsg(2373, zoom, 0);
2628 }
2629
2630 // Retrieve the zoom level.
2631 int wxStyledTextCtrl::GetZoom() const
2632 {
2633 return SendMsg(2374, 0, 0);
2634 }
2635
2636 // Create a new document object.
2637 // Starts with reference count of 1 and not selected into editor.
2638 void* wxStyledTextCtrl::CreateDocument() {
2639 return (void*)SendMsg(2375);
2640 }
2641
2642 // Extend life of document.
2643 void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
2644 SendMsg(2376, 0, (sptr_t)docPointer);
2645 }
2646
2647 // Release a reference to the document, deleting document if it fades to black.
2648 void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
2649 SendMsg(2377, 0, (sptr_t)docPointer);
2650 }
2651
2652 // Get which document modification events are sent to the container.
2653 int wxStyledTextCtrl::GetModEventMask() const
2654 {
2655 return SendMsg(2378, 0, 0);
2656 }
2657
2658 // Change internal focus flag.
2659 void wxStyledTextCtrl::SetSTCFocus(bool focus)
2660 {
2661 SendMsg(2380, focus, 0);
2662 }
2663
2664 // Get internal focus flag.
2665 bool wxStyledTextCtrl::GetSTCFocus() const
2666 {
2667 return SendMsg(2381, 0, 0) != 0;
2668 }
2669
2670 // Change error status - 0 = OK.
2671 void wxStyledTextCtrl::SetStatus(int statusCode)
2672 {
2673 SendMsg(2382, statusCode, 0);
2674 }
2675
2676 // Get error status.
2677 int wxStyledTextCtrl::GetStatus() const
2678 {
2679 return SendMsg(2383, 0, 0);
2680 }
2681
2682 // Set whether the mouse is captured when its button is pressed.
2683 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures)
2684 {
2685 SendMsg(2384, captures, 0);
2686 }
2687
2688 // Get whether mouse gets captured.
2689 bool wxStyledTextCtrl::GetMouseDownCaptures() const
2690 {
2691 return SendMsg(2385, 0, 0) != 0;
2692 }
2693
2694 // Sets the cursor to one of the SC_CURSOR* values.
2695 void wxStyledTextCtrl::SetSTCCursor(int cursorType)
2696 {
2697 SendMsg(2386, cursorType, 0);
2698 }
2699
2700 // Get cursor type.
2701 int wxStyledTextCtrl::GetSTCCursor() const
2702 {
2703 return SendMsg(2387, 0, 0);
2704 }
2705
2706 // Change the way control characters are displayed:
2707 // If symbol is < 32, keep the drawn way, else, use the given character.
2708 void wxStyledTextCtrl::SetControlCharSymbol(int symbol)
2709 {
2710 SendMsg(2388, symbol, 0);
2711 }
2712
2713 // Get the way control characters are displayed.
2714 int wxStyledTextCtrl::GetControlCharSymbol() const
2715 {
2716 return SendMsg(2389, 0, 0);
2717 }
2718
2719 // Move to the previous change in capitalisation.
2720 void wxStyledTextCtrl::WordPartLeft()
2721 {
2722 SendMsg(2390, 0, 0);
2723 }
2724
2725 // Move to the previous change in capitalisation extending selection
2726 // to new caret position.
2727 void wxStyledTextCtrl::WordPartLeftExtend()
2728 {
2729 SendMsg(2391, 0, 0);
2730 }
2731
2732 // Move to the change next in capitalisation.
2733 void wxStyledTextCtrl::WordPartRight()
2734 {
2735 SendMsg(2392, 0, 0);
2736 }
2737
2738 // Move to the next change in capitalisation extending selection
2739 // to new caret position.
2740 void wxStyledTextCtrl::WordPartRightExtend()
2741 {
2742 SendMsg(2393, 0, 0);
2743 }
2744
2745 // Set the way the display area is determined when a particular line
2746 // is to be moved to by Find, FindNext, GotoLine, etc.
2747 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop)
2748 {
2749 SendMsg(2394, visiblePolicy, visibleSlop);
2750 }
2751
2752 // Delete back from the current position to the start of the line.
2753 void wxStyledTextCtrl::DelLineLeft()
2754 {
2755 SendMsg(2395, 0, 0);
2756 }
2757
2758 // Delete forwards from the current position to the end of the line.
2759 void wxStyledTextCtrl::DelLineRight()
2760 {
2761 SendMsg(2396, 0, 0);
2762 }
2763
2764 // Get and Set the xOffset (ie, horizonal scroll position).
2765 void wxStyledTextCtrl::SetXOffset(int newOffset)
2766 {
2767 SendMsg(2397, newOffset, 0);
2768 }
2769 int wxStyledTextCtrl::GetXOffset() const
2770 {
2771 return SendMsg(2398, 0, 0);
2772 }
2773
2774 // Set the last x chosen value to be the caret x position.
2775 void wxStyledTextCtrl::ChooseCaretX()
2776 {
2777 SendMsg(2399, 0, 0);
2778 }
2779
2780 // Set the way the caret is kept visible when going sideway.
2781 // The exclusion zone is given in pixels.
2782 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop)
2783 {
2784 SendMsg(2402, caretPolicy, caretSlop);
2785 }
2786
2787 // Set the way the line the caret is on is kept visible.
2788 // The exclusion zone is given in lines.
2789 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop)
2790 {
2791 SendMsg(2403, caretPolicy, caretSlop);
2792 }
2793
2794 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2795 void wxStyledTextCtrl::SetPrintWrapMode(int mode)
2796 {
2797 SendMsg(2406, mode, 0);
2798 }
2799
2800 // Is printing line wrapped?
2801 int wxStyledTextCtrl::GetPrintWrapMode() const
2802 {
2803 return SendMsg(2407, 0, 0);
2804 }
2805
2806 // Set a fore colour for active hotspots.
2807 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore)
2808 {
2809 SendMsg(2410, useSetting, wxColourAsLong(fore));
2810 }
2811
2812 // Get the fore colour for active hotspots.
2813 wxColour wxStyledTextCtrl::GetHotspotActiveForeground() const
2814 {
2815 long c = SendMsg(2494, 0, 0);
2816 return wxColourFromLong(c);
2817 }
2818
2819 // Set a back colour for active hotspots.
2820 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back)
2821 {
2822 SendMsg(2411, useSetting, wxColourAsLong(back));
2823 }
2824
2825 // Get the back colour for active hotspots.
2826 wxColour wxStyledTextCtrl::GetHotspotActiveBackground() const
2827 {
2828 long c = SendMsg(2495, 0, 0);
2829 return wxColourFromLong(c);
2830 }
2831
2832 // Enable / Disable underlining active hotspots.
2833 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline)
2834 {
2835 SendMsg(2412, underline, 0);
2836 }
2837
2838 // Get whether underlining for active hotspots.
2839 bool wxStyledTextCtrl::GetHotspotActiveUnderline() const
2840 {
2841 return SendMsg(2496, 0, 0) != 0;
2842 }
2843
2844 // Limit hotspots to single line so hotspots on two lines don't merge.
2845 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine)
2846 {
2847 SendMsg(2421, singleLine, 0);
2848 }
2849
2850 // Get the HotspotSingleLine property
2851 bool wxStyledTextCtrl::GetHotspotSingleLine() const
2852 {
2853 return SendMsg(2497, 0, 0) != 0;
2854 }
2855
2856 // Move caret between paragraphs (delimited by empty lines).
2857 void wxStyledTextCtrl::ParaDown()
2858 {
2859 SendMsg(2413, 0, 0);
2860 }
2861 void wxStyledTextCtrl::ParaDownExtend()
2862 {
2863 SendMsg(2414, 0, 0);
2864 }
2865 void wxStyledTextCtrl::ParaUp()
2866 {
2867 SendMsg(2415, 0, 0);
2868 }
2869 void wxStyledTextCtrl::ParaUpExtend()
2870 {
2871 SendMsg(2416, 0, 0);
2872 }
2873
2874 // Given a valid document position, return the previous position taking code
2875 // page into account. Returns 0 if passed 0.
2876 int wxStyledTextCtrl::PositionBefore(int pos)
2877 {
2878 return SendMsg(2417, pos, 0);
2879 }
2880
2881 // Given a valid document position, return the next position taking code
2882 // page into account. Maximum value returned is the last position in the document.
2883 int wxStyledTextCtrl::PositionAfter(int pos)
2884 {
2885 return SendMsg(2418, pos, 0);
2886 }
2887
2888 // Copy a range of text to the clipboard. Positions are clipped into the document.
2889 void wxStyledTextCtrl::CopyRange(int start, int end)
2890 {
2891 SendMsg(2419, start, end);
2892 }
2893
2894 // Copy argument text to the clipboard.
2895 void wxStyledTextCtrl::CopyText(int length, const wxString& text)
2896 {
2897 SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text));
2898 }
2899
2900 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or
2901 // by lines (SC_SEL_LINES).
2902 void wxStyledTextCtrl::SetSelectionMode(int mode)
2903 {
2904 SendMsg(2422, mode, 0);
2905 }
2906
2907 // Get the mode of the current selection.
2908 int wxStyledTextCtrl::GetSelectionMode() const
2909 {
2910 return SendMsg(2423, 0, 0);
2911 }
2912
2913 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2914 int wxStyledTextCtrl::GetLineSelStartPosition(int line)
2915 {
2916 return SendMsg(2424, line, 0);
2917 }
2918
2919 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2920 int wxStyledTextCtrl::GetLineSelEndPosition(int line)
2921 {
2922 return SendMsg(2425, line, 0);
2923 }
2924
2925 // Move caret down one line, extending rectangular selection to new caret position.
2926 void wxStyledTextCtrl::LineDownRectExtend()
2927 {
2928 SendMsg(2426, 0, 0);
2929 }
2930
2931 // Move caret up one line, extending rectangular selection to new caret position.
2932 void wxStyledTextCtrl::LineUpRectExtend()
2933 {
2934 SendMsg(2427, 0, 0);
2935 }
2936
2937 // Move caret left one character, extending rectangular selection to new caret position.
2938 void wxStyledTextCtrl::CharLeftRectExtend()
2939 {
2940 SendMsg(2428, 0, 0);
2941 }
2942
2943 // Move caret right one character, extending rectangular selection to new caret position.
2944 void wxStyledTextCtrl::CharRightRectExtend()
2945 {
2946 SendMsg(2429, 0, 0);
2947 }
2948
2949 // Move caret to first position on line, extending rectangular selection to new caret position.
2950 void wxStyledTextCtrl::HomeRectExtend()
2951 {
2952 SendMsg(2430, 0, 0);
2953 }
2954
2955 // Move caret to before first visible character on line.
2956 // If already there move to first character on line.
2957 // In either case, extend rectangular selection to new caret position.
2958 void wxStyledTextCtrl::VCHomeRectExtend()
2959 {
2960 SendMsg(2431, 0, 0);
2961 }
2962
2963 // Move caret to last position on line, extending rectangular selection to new caret position.
2964 void wxStyledTextCtrl::LineEndRectExtend()
2965 {
2966 SendMsg(2432, 0, 0);
2967 }
2968
2969 // Move caret one page up, extending rectangular selection to new caret position.
2970 void wxStyledTextCtrl::PageUpRectExtend()
2971 {
2972 SendMsg(2433, 0, 0);
2973 }
2974
2975 // Move caret one page down, extending rectangular selection to new caret position.
2976 void wxStyledTextCtrl::PageDownRectExtend()
2977 {
2978 SendMsg(2434, 0, 0);
2979 }
2980
2981 // Move caret to top of page, or one page up if already at top of page.
2982 void wxStyledTextCtrl::StutteredPageUp()
2983 {
2984 SendMsg(2435, 0, 0);
2985 }
2986
2987 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2988 void wxStyledTextCtrl::StutteredPageUpExtend()
2989 {
2990 SendMsg(2436, 0, 0);
2991 }
2992
2993 // Move caret to bottom of page, or one page down if already at bottom of page.
2994 void wxStyledTextCtrl::StutteredPageDown()
2995 {
2996 SendMsg(2437, 0, 0);
2997 }
2998
2999 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
3000 void wxStyledTextCtrl::StutteredPageDownExtend()
3001 {
3002 SendMsg(2438, 0, 0);
3003 }
3004
3005 // Move caret left one word, position cursor at end of word.
3006 void wxStyledTextCtrl::WordLeftEnd()
3007 {
3008 SendMsg(2439, 0, 0);
3009 }
3010
3011 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
3012 void wxStyledTextCtrl::WordLeftEndExtend()
3013 {
3014 SendMsg(2440, 0, 0);
3015 }
3016
3017 // Move caret right one word, position cursor at end of word.
3018 void wxStyledTextCtrl::WordRightEnd()
3019 {
3020 SendMsg(2441, 0, 0);
3021 }
3022
3023 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
3024 void wxStyledTextCtrl::WordRightEndExtend()
3025 {
3026 SendMsg(2442, 0, 0);
3027 }
3028
3029 // Set the set of characters making up whitespace for when moving or selecting by word.
3030 // Should be called after SetWordChars.
3031 void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters)
3032 {
3033 SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters));
3034 }
3035
3036 // Reset the set of characters for whitespace and word characters to the defaults.
3037 void wxStyledTextCtrl::SetCharsDefault()
3038 {
3039 SendMsg(2444, 0, 0);
3040 }
3041
3042 // Get currently selected item position in the auto-completion list
3043 int wxStyledTextCtrl::AutoCompGetCurrent()
3044 {
3045 return SendMsg(2445, 0, 0);
3046 }
3047
3048 // Enlarge the document to a particular size of text bytes.
3049 void wxStyledTextCtrl::Allocate(int bytes)
3050 {
3051 SendMsg(2446, bytes, 0);
3052 }
3053
3054 // Find the position of a column on a line taking into account tabs and
3055 // multi-byte characters. If beyond end of line, return line end position.
3056 int wxStyledTextCtrl::FindColumn(int line, int column)
3057 {
3058 return SendMsg(2456, line, column);
3059 }
3060
3061 // Can the caret preferred x position only be changed by explicit movement commands?
3062 bool wxStyledTextCtrl::GetCaretSticky() const
3063 {
3064 return SendMsg(2457, 0, 0) != 0;
3065 }
3066
3067 // Stop the caret preferred x position changing when the user types.
3068 void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour)
3069 {
3070 SendMsg(2458, useCaretStickyBehaviour, 0);
3071 }
3072
3073 // Switch between sticky and non-sticky: meant to be bound to a key.
3074 void wxStyledTextCtrl::ToggleCaretSticky()
3075 {
3076 SendMsg(2459, 0, 0);
3077 }
3078
3079 // Enable/Disable convert-on-paste for line endings
3080 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert)
3081 {
3082 SendMsg(2467, convert, 0);
3083 }
3084
3085 // Get convert-on-paste setting
3086 bool wxStyledTextCtrl::GetPasteConvertEndings() const
3087 {
3088 return SendMsg(2468, 0, 0) != 0;
3089 }
3090
3091 // Duplicate the selection. If selection empty duplicate the line containing the caret.
3092 void wxStyledTextCtrl::SelectionDuplicate()
3093 {
3094 SendMsg(2469, 0, 0);
3095 }
3096
3097 // Set background alpha of the caret line.
3098 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha)
3099 {
3100 SendMsg(2470, alpha, 0);
3101 }
3102
3103 // Get the background alpha of the caret line.
3104 int wxStyledTextCtrl::GetCaretLineBackAlpha() const
3105 {
3106 return SendMsg(2471, 0, 0);
3107 }
3108
3109 // Set the style of the caret to be drawn.
3110 void wxStyledTextCtrl::SetCaretStyle(int caretStyle)
3111 {
3112 SendMsg(2512, caretStyle, 0);
3113 }
3114
3115 // Returns the current style of the caret.
3116 int wxStyledTextCtrl::GetCaretStyle() const
3117 {
3118 return SendMsg(2513, 0, 0);
3119 }
3120
3121 // Set the indicator used for IndicatorFillRange and IndicatorClearRange
3122 void wxStyledTextCtrl::SetIndicatorCurrent(int indicator)
3123 {
3124 SendMsg(2500, indicator, 0);
3125 }
3126
3127 // Get the current indicator
3128 int wxStyledTextCtrl::GetIndicatorCurrent() const
3129 {
3130 return SendMsg(2501, 0, 0);
3131 }
3132
3133 // Set the value used for IndicatorFillRange
3134 void wxStyledTextCtrl::SetIndicatorValue(int value)
3135 {
3136 SendMsg(2502, value, 0);
3137 }
3138
3139 // Get the current indicator vaue
3140 int wxStyledTextCtrl::GetIndicatorValue() const
3141 {
3142 return SendMsg(2503, 0, 0);
3143 }
3144
3145 // Turn a indicator on over a range.
3146 void wxStyledTextCtrl::IndicatorFillRange(int position, int fillLength)
3147 {
3148 SendMsg(2504, position, fillLength);
3149 }
3150
3151 // Turn a indicator off over a range.
3152 void wxStyledTextCtrl::IndicatorClearRange(int position, int clearLength)
3153 {
3154 SendMsg(2505, position, clearLength);
3155 }
3156
3157 // Are any indicators present at position?
3158 int wxStyledTextCtrl::IndicatorAllOnFor(int position)
3159 {
3160 return SendMsg(2506, position, 0);
3161 }
3162
3163 // What value does a particular indicator have at at a position?
3164 int wxStyledTextCtrl::IndicatorValueAt(int indicator, int position)
3165 {
3166 return SendMsg(2507, indicator, position);
3167 }
3168
3169 // Where does a particular indicator start?
3170 int wxStyledTextCtrl::IndicatorStart(int indicator, int position)
3171 {
3172 return SendMsg(2508, indicator, position);
3173 }
3174
3175 // Where does a particular indicator end?
3176 int wxStyledTextCtrl::IndicatorEnd(int indicator, int position)
3177 {
3178 return SendMsg(2509, indicator, position);
3179 }
3180
3181 // Set number of entries in position cache
3182 void wxStyledTextCtrl::SetPositionCacheSize(int size)
3183 {
3184 SendMsg(2514, size, 0);
3185 }
3186
3187 // How many entries are allocated to the position cache?
3188 int wxStyledTextCtrl::GetPositionCacheSize() const
3189 {
3190 return SendMsg(2515, 0, 0);
3191 }
3192
3193 // Copy the selection, if selection empty copy the line with the caret
3194 void wxStyledTextCtrl::CopyAllowLine()
3195 {
3196 SendMsg(2519, 0, 0);
3197 }
3198
3199 // Compact the document buffer and return a read-only pointer to the
3200 // characters in the document.
3201 const char* wxStyledTextCtrl::GetCharacterPointer() {
3202 return (const char*)SendMsg(2520, 0, 0);
3203 }
3204
3205 // Always interpret keyboard input as Unicode
3206 void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode)
3207 {
3208 SendMsg(2521, keysUnicode, 0);
3209 }
3210
3211 // Are keys always interpreted as Unicode?
3212 bool wxStyledTextCtrl::GetKeysUnicode() const
3213 {
3214 return SendMsg(2522, 0, 0) != 0;
3215 }
3216
3217 // Set the alpha fill colour of the given indicator.
3218 void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha)
3219 {
3220 SendMsg(2523, indicator, alpha);
3221 }
3222
3223 // Get the alpha fill colour of the given indicator.
3224 int wxStyledTextCtrl::IndicatorGetAlpha(int indicator) const
3225 {
3226 return SendMsg(2524, indicator, 0);
3227 }
3228
3229 // Set extra ascent for each line
3230 void wxStyledTextCtrl::SetExtraAscent(int extraAscent)
3231 {
3232 SendMsg(2525, extraAscent, 0);
3233 }
3234
3235 // Get extra ascent for each line
3236 int wxStyledTextCtrl::GetExtraAscent() const
3237 {
3238 return SendMsg(2526, 0, 0);
3239 }
3240
3241 // Set extra descent for each line
3242 void wxStyledTextCtrl::SetExtraDescent(int extraDescent)
3243 {
3244 SendMsg(2527, extraDescent, 0);
3245 }
3246
3247 // Get extra descent for each line
3248 int wxStyledTextCtrl::GetExtraDescent() const
3249 {
3250 return SendMsg(2528, 0, 0);
3251 }
3252
3253 // Which symbol was defined for markerNumber with MarkerDefine
3254 int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber)
3255 {
3256 return SendMsg(2529, markerNumber, 0);
3257 }
3258
3259 // Set the text in the text margin for a line
3260 void wxStyledTextCtrl::MarginSetText(int line, const wxString& text)
3261 {
3262 SendMsg(2530, line, (sptr_t)(const char*)wx2stc(text));
3263 }
3264
3265 // Get the text in the text margin for a line
3266 wxString wxStyledTextCtrl::MarginGetText(int line) const {
3267 long msg = 2531;
3268 long len = SendMsg(msg, line, 0);
3269
3270 wxMemoryBuffer mbuf(len+1);
3271 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3272 SendMsg(msg, line, (sptr_t)buf);
3273 mbuf.UngetWriteBuf(len);
3274 mbuf.AppendByte(0);
3275 return stc2wx(buf);
3276 }
3277
3278 // Set the style number for the text margin for a line
3279 void wxStyledTextCtrl::MarginSetStyle(int line, int style)
3280 {
3281 SendMsg(2532, line, style);
3282 }
3283
3284 // Get the style number for the text margin for a line
3285 int wxStyledTextCtrl::MarginGetStyle(int line) const
3286 {
3287 return SendMsg(2533, line, 0);
3288 }
3289
3290 // Set the style in the text margin for a line
3291 void wxStyledTextCtrl::MarginSetStyles(int line, const wxString& styles)
3292 {
3293 SendMsg(2534, line, (sptr_t)(const char*)wx2stc(styles));
3294 }
3295
3296 // Get the styles in the text margin for a line
3297 wxString wxStyledTextCtrl::MarginGetStyles(int line) const {
3298 long msg = 2535;
3299 long len = SendMsg(msg, line, 0);
3300
3301 wxMemoryBuffer mbuf(len+1);
3302 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3303 SendMsg(msg, line, (sptr_t)buf);
3304 mbuf.UngetWriteBuf(len);
3305 mbuf.AppendByte(0);
3306 return stc2wx(buf);
3307 }
3308
3309 // Clear the margin text on all lines
3310 void wxStyledTextCtrl::MarginTextClearAll()
3311 {
3312 SendMsg(2536, 0, 0);
3313 }
3314
3315 // Get the start of the range of style numbers used for margin text
3316 void wxStyledTextCtrl::MarginSetStyleOffset(int style)
3317 {
3318 SendMsg(2537, style, 0);
3319 }
3320
3321 // Get the start of the range of style numbers used for margin text
3322 int wxStyledTextCtrl::MarginGetStyleOffset() const
3323 {
3324 return SendMsg(2538, 0, 0);
3325 }
3326
3327 // Set the annotation text for a line
3328 void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text)
3329 {
3330 SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text));
3331 }
3332
3333 // Get the annotation text for a line
3334 wxString wxStyledTextCtrl::AnnotationGetText(int line) const {
3335 long msg = 2541;
3336 long len = SendMsg(msg, line, 0);
3337
3338 wxMemoryBuffer mbuf(len+1);
3339 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3340 SendMsg(msg, line, (sptr_t)buf);
3341 mbuf.UngetWriteBuf(len);
3342 mbuf.AppendByte(0);
3343 return stc2wx(buf);
3344 }
3345
3346 // Set the style number for the annotations for a line
3347 void wxStyledTextCtrl::AnnotationSetStyle(int line, int style)
3348 {
3349 SendMsg(2542, line, style);
3350 }
3351
3352 // Get the style number for the annotations for a line
3353 int wxStyledTextCtrl::AnnotationGetStyle(int line) const
3354 {
3355 return SendMsg(2543, line, 0);
3356 }
3357
3358 // Set the annotation styles for a line
3359 void wxStyledTextCtrl::AnnotationSetStyles(int line, const wxString& styles)
3360 {
3361 SendMsg(2544, line, (sptr_t)(const char*)wx2stc(styles));
3362 }
3363
3364 // Get the annotation styles for a line
3365 wxString wxStyledTextCtrl::AnnotationGetStyles(int line) const {
3366 long msg = 2545;
3367 long len = SendMsg(msg, line, 0);
3368
3369 wxMemoryBuffer mbuf(len+1);
3370 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3371 SendMsg(msg, line, (sptr_t)buf);
3372 mbuf.UngetWriteBuf(len);
3373 mbuf.AppendByte(0);
3374 return stc2wx(buf);
3375 }
3376
3377 // Get the number of annotation lines for a line
3378 int wxStyledTextCtrl::AnnotationGetLines(int line) const
3379 {
3380 return SendMsg(2546, line, 0);
3381 }
3382
3383 // Clear the annotations from all lines
3384 void wxStyledTextCtrl::AnnotationClearAll()
3385 {
3386 SendMsg(2547, 0, 0);
3387 }
3388
3389 // Set the visibility for the annotations for a view
3390 void wxStyledTextCtrl::AnnotationSetVisible(int visible)
3391 {
3392 SendMsg(2548, visible, 0);
3393 }
3394
3395 // Get the visibility for the annotations for a view
3396 int wxStyledTextCtrl::AnnotationGetVisible() const
3397 {
3398 return SendMsg(2549, 0, 0);
3399 }
3400
3401 // Get the start of the range of style numbers used for annotations
3402 void wxStyledTextCtrl::AnnotationSetStyleOffset(int style)
3403 {
3404 SendMsg(2550, style, 0);
3405 }
3406
3407 // Get the start of the range of style numbers used for annotations
3408 int wxStyledTextCtrl::AnnotationGetStyleOffset() const
3409 {
3410 return SendMsg(2551, 0, 0);
3411 }
3412
3413 // Add a container action to the undo stack
3414 void wxStyledTextCtrl::AddUndoAction(int token, int flags)
3415 {
3416 SendMsg(2560, token, flags);
3417 }
3418
3419 // Find the position of a character from a point within the window.
3420 int wxStyledTextCtrl::CharPositionFromPoint(int x, int y)
3421 {
3422 return SendMsg(2561, x, y);
3423 }
3424
3425 // Find the position of a character from a point within the window.
3426 // Return INVALID_POSITION if not close to text.
3427 int wxStyledTextCtrl::CharPositionFromPointClose(int x, int y)
3428 {
3429 return SendMsg(2562, x, y);
3430 }
3431
3432 // Set whether multiple selections can be made
3433 void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection)
3434 {
3435 SendMsg(2563, multipleSelection, 0);
3436 }
3437
3438 // Whether multiple selections can be made
3439 bool wxStyledTextCtrl::GetMultipleSelection() const
3440 {
3441 return SendMsg(2564, 0, 0) != 0;
3442 }
3443
3444 // Set whether typing can be performed into multiple selections
3445 void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping)
3446 {
3447 SendMsg(2565, additionalSelectionTyping, 0);
3448 }
3449
3450 // Whether typing can be performed into multiple selections
3451 bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const
3452 {
3453 return SendMsg(2566, 0, 0) != 0;
3454 }
3455
3456 // Set whether additional carets will blink
3457 void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink)
3458 {
3459 SendMsg(2567, additionalCaretsBlink, 0);
3460 }
3461
3462 // Whether additional carets will blink
3463 bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const
3464 {
3465 return SendMsg(2568, 0, 0) != 0;
3466 }
3467
3468 // Set whether additional carets are visible
3469 void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink)
3470 {
3471 SendMsg(2608, additionalCaretsBlink, 0);
3472 }
3473
3474 // Whether additional carets are visible
3475 bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const
3476 {
3477 return SendMsg(2609, 0, 0) != 0;
3478 }
3479
3480 // How many selections are there?
3481 int wxStyledTextCtrl::GetSelections() const
3482 {
3483 return SendMsg(2570, 0, 0);
3484 }
3485
3486 // Clear selections to a single empty stream selection
3487 void wxStyledTextCtrl::ClearSelections()
3488 {
3489 SendMsg(2571, 0, 0);
3490 }
3491
3492 // Add a selection
3493 int wxStyledTextCtrl::AddSelection(int caret, int anchor)
3494 {
3495 return SendMsg(2573, caret, anchor);
3496 }
3497
3498 // Set the main selection
3499 void wxStyledTextCtrl::SetMainSelection(int selection)
3500 {
3501 SendMsg(2574, selection, 0);
3502 }
3503
3504 // Which selection is the main selection
3505 int wxStyledTextCtrl::GetMainSelection() const
3506 {
3507 return SendMsg(2575, 0, 0);
3508 }
3509 void wxStyledTextCtrl::SetSelectionNCaret(int selection, int pos)
3510 {
3511 SendMsg(2576, selection, pos);
3512 }
3513 int wxStyledTextCtrl::GetSelectionNCaret(int selection) const
3514 {
3515 return SendMsg(2577, selection, 0);
3516 }
3517 void wxStyledTextCtrl::SetSelectionNAnchor(int selection, int posAnchor)
3518 {
3519 SendMsg(2578, selection, posAnchor);
3520 }
3521 int wxStyledTextCtrl::GetSelectionNAnchor(int selection) const
3522 {
3523 return SendMsg(2579, selection, 0);
3524 }
3525 void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space)
3526 {
3527 SendMsg(2580, selection, space);
3528 }
3529 int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection) const
3530 {
3531 return SendMsg(2581, selection, 0);
3532 }
3533 void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space)
3534 {
3535 SendMsg(2582, selection, space);
3536 }
3537 int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) const
3538 {
3539 return SendMsg(2583, selection, 0);
3540 }
3541
3542 // Sets the position that starts the selection - this becomes the anchor.
3543 void wxStyledTextCtrl::SetSelectionNStart(int selection, int pos)
3544 {
3545 SendMsg(2584, selection, pos);
3546 }
3547
3548 // Returns the position at the start of the selection.
3549 int wxStyledTextCtrl::GetSelectionNStart(int selection) const
3550 {
3551 return SendMsg(2585, selection, 0);
3552 }
3553
3554 // Sets the position that ends the selection - this becomes the currentPosition.
3555 void wxStyledTextCtrl::SetSelectionNEnd(int selection, int pos)
3556 {
3557 SendMsg(2586, selection, pos);
3558 }
3559
3560 // Returns the position at the end of the selection.
3561 int wxStyledTextCtrl::GetSelectionNEnd(int selection) const
3562 {
3563 return SendMsg(2587, selection, 0);
3564 }
3565 void wxStyledTextCtrl::SetRectangularSelectionCaret(int pos)
3566 {
3567 SendMsg(2588, pos, 0);
3568 }
3569 int wxStyledTextCtrl::GetRectangularSelectionCaret() const
3570 {
3571 return SendMsg(2589, 0, 0);
3572 }
3573 void wxStyledTextCtrl::SetRectangularSelectionAnchor(int posAnchor)
3574 {
3575 SendMsg(2590, posAnchor, 0);
3576 }
3577 int wxStyledTextCtrl::GetRectangularSelectionAnchor() const
3578 {
3579 return SendMsg(2591, 0, 0);
3580 }
3581 void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space)
3582 {
3583 SendMsg(2592, space, 0);
3584 }
3585 int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const
3586 {
3587 return SendMsg(2593, 0, 0);
3588 }
3589 void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space)
3590 {
3591 SendMsg(2594, space, 0);
3592 }
3593 int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const
3594 {
3595 return SendMsg(2595, 0, 0);
3596 }
3597 void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions)
3598 {
3599 SendMsg(2596, virtualSpaceOptions, 0);
3600 }
3601 int wxStyledTextCtrl::GetVirtualSpaceOptions() const
3602 {
3603 return SendMsg(2597, 0, 0);
3604 }
3605
3606 // On GTK+, allow selecting the modifier key to use for mouse-based
3607 // rectangular selection. Often the window manager requires Alt+Mouse Drag
3608 // for moving windows.
3609 // Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.
3610 void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier)
3611 {
3612 SendMsg(2598, modifier, 0);
3613 }
3614
3615 // Get the modifier key used for rectangular selection.
3616 int wxStyledTextCtrl::GetRectangularSelectionModifier() const
3617 {
3618 return SendMsg(2599, 0, 0);
3619 }
3620
3621 // Set the foreground colour of additional selections.
3622 // Must have previously called SetSelFore with non-zero first argument for this to have an effect.
3623 void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour& fore)
3624 {
3625 SendMsg(2600, wxColourAsLong(fore), 0);
3626 }
3627
3628 // Set the background colour of additional selections.
3629 // Must have previously called SetSelBack with non-zero first argument for this to have an effect.
3630 void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour& back)
3631 {
3632 SendMsg(2601, wxColourAsLong(back), 0);
3633 }
3634
3635 // Set the alpha of the selection.
3636 void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha)
3637 {
3638 SendMsg(2602, alpha, 0);
3639 }
3640
3641 // Get the alpha of the selection.
3642 int wxStyledTextCtrl::GetAdditionalSelAlpha() const
3643 {
3644 return SendMsg(2603, 0, 0);
3645 }
3646
3647 // Set the foreground colour of additional carets.
3648 void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour& fore)
3649 {
3650 SendMsg(2604, wxColourAsLong(fore), 0);
3651 }
3652
3653 // Get the foreground colour of additional carets.
3654 wxColour wxStyledTextCtrl::GetAdditionalCaretForeground() const
3655 {
3656 long c = SendMsg(2605, 0, 0);
3657 return wxColourFromLong(c);
3658 }
3659
3660 // Set the main selection to the next selection.
3661 void wxStyledTextCtrl::RotateSelection()
3662 {
3663 SendMsg(2606, 0, 0);
3664 }
3665
3666 // Swap that caret and anchor of the main selection.
3667 void wxStyledTextCtrl::SwapMainAnchorCaret()
3668 {
3669 SendMsg(2607, 0, 0);
3670 }
3671
3672 // Start notifying the container of all key presses and commands.
3673 void wxStyledTextCtrl::StartRecord()
3674 {
3675 SendMsg(3001, 0, 0);
3676 }
3677
3678 // Stop notifying the container of all key presses and commands.
3679 void wxStyledTextCtrl::StopRecord()
3680 {
3681 SendMsg(3002, 0, 0);
3682 }
3683
3684 // Set the lexing language of the document.
3685 void wxStyledTextCtrl::SetLexer(int lexer)
3686 {
3687 SendMsg(4001, lexer, 0);
3688 }
3689
3690 // Retrieve the lexing language of the document.
3691 int wxStyledTextCtrl::GetLexer() const
3692 {
3693 return SendMsg(4002, 0, 0);
3694 }
3695
3696 // Colourise a segment of the document using the current lexing language.
3697 void wxStyledTextCtrl::Colourise(int start, int end)
3698 {
3699 SendMsg(4003, start, end);
3700 }
3701
3702 // Set up a value that may be used by a lexer for some optional feature.
3703 void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
3704 {
3705 SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
3706 }
3707
3708 // Set up the key words used by the lexer.
3709 void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords)
3710 {
3711 SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords));
3712 }
3713
3714 // Set the lexing language of the document based on string name.
3715 void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
3716 {
3717 SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language));
3718 }
3719
3720 // Retrieve a 'property' value previously set with SetProperty.
3721 wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
3722 int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0);
3723 if (!len) return wxEmptyString;
3724
3725 wxMemoryBuffer mbuf(len+1);
3726 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3727 SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
3728 mbuf.UngetWriteBuf(len);
3729 mbuf.AppendByte(0);
3730 return stc2wx(buf);
3731 }
3732
3733 // Retrieve a 'property' value previously set with SetProperty,
3734 // with '$()' variable replacement on returned buffer.
3735 wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
3736 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0);
3737 if (!len) return wxEmptyString;
3738
3739 wxMemoryBuffer mbuf(len+1);
3740 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3741 SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
3742 mbuf.UngetWriteBuf(len);
3743 mbuf.AppendByte(0);
3744 return stc2wx(buf);
3745 }
3746
3747 // Retrieve a 'property' value previously set with SetProperty,
3748 // interpreted as an int AFTER any '$()' variable replacement.
3749 int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const
3750 {
3751 return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0);
3752 }
3753
3754 // Retrieve the number of bits the current lexer needs for styling.
3755 int wxStyledTextCtrl::GetStyleBitsNeeded() const
3756 {
3757 return SendMsg(4011, 0, 0);
3758 }
3759
3760 //}}}
3761 //----------------------------------------------------------------------
3762
3763
3764 // Returns the line number of the line with the caret.
3765 int wxStyledTextCtrl::GetCurrentLine() {
3766 int line = LineFromPosition(GetCurrentPos());
3767 return line;
3768 }
3769
3770
3771 // Extract style settings from a spec-string which is composed of one or
3772 // more of the following comma separated elements:
3773 //
3774 // bold turns on bold
3775 // italic turns on italics
3776 // fore:[name or #RRGGBB] sets the foreground colour
3777 // back:[name or #RRGGBB] sets the background colour
3778 // face:[facename] sets the font face name to use
3779 // size:[num] sets the font size in points
3780 // eol turns on eol filling
3781 // underline turns on underlining
3782 //
3783 void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
3784
3785 wxStringTokenizer tkz(spec, wxT(","));
3786 while (tkz.HasMoreTokens()) {
3787 wxString token = tkz.GetNextToken();
3788
3789 wxString option = token.BeforeFirst(':');
3790 wxString val = token.AfterFirst(':');
3791
3792 if (option == wxT("bold"))
3793 StyleSetBold(styleNum, true);
3794
3795 else if (option == wxT("italic"))
3796 StyleSetItalic(styleNum, true);
3797
3798 else if (option == wxT("underline"))
3799 StyleSetUnderline(styleNum, true);
3800
3801 else if (option == wxT("eol"))
3802 StyleSetEOLFilled(styleNum, true);
3803
3804 else if (option == wxT("size")) {
3805 long points;
3806 if (val.ToLong(&points))
3807 StyleSetSize(styleNum, points);
3808 }
3809
3810 else if (option == wxT("face"))
3811 StyleSetFaceName(styleNum, val);
3812
3813 else if (option == wxT("fore"))
3814 StyleSetForeground(styleNum, wxColourFromSpec(val));
3815
3816 else if (option == wxT("back"))
3817 StyleSetBackground(styleNum, wxColourFromSpec(val));
3818 }
3819 }
3820
3821
3822 // Get the font of a style
3823 wxFont wxStyledTextCtrl::StyleGetFont(int style) {
3824 wxFont font;
3825 font.SetPointSize(StyleGetSize(style));
3826 font.SetFaceName(StyleGetFaceName(style));
3827 if( StyleGetBold(style) )
3828 font.SetWeight(wxFONTWEIGHT_BOLD);
3829 else
3830 font.SetWeight(wxFONTWEIGHT_NORMAL);
3831
3832 if( StyleGetItalic(style) )
3833 font.SetStyle(wxFONTSTYLE_ITALIC);
3834 else
3835 font.SetStyle(wxFONTSTYLE_NORMAL);
3836
3837 return font;
3838 }
3839
3840
3841 // Set style size, face, bold, italic, and underline attributes from
3842 // a wxFont's attributes.
3843 void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
3844 #ifdef __WXGTK__
3845 // Ensure that the native font is initialized
3846 int x, y;
3847 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
3848 #endif
3849 int size = font.GetPointSize();
3850 wxString faceName = font.GetFaceName();
3851 bool bold = font.GetWeight() == wxBOLD;
3852 bool italic = font.GetStyle() != wxNORMAL;
3853 bool under = font.GetUnderlined();
3854 wxFontEncoding encoding = font.GetEncoding();
3855
3856 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
3857 }
3858
3859 // Set all font style attributes at once.
3860 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
3861 const wxString& faceName,
3862 bool bold, bool italic,
3863 bool underline,
3864 wxFontEncoding encoding) {
3865 StyleSetSize(styleNum, size);
3866 StyleSetFaceName(styleNum, faceName);
3867 StyleSetBold(styleNum, bold);
3868 StyleSetItalic(styleNum, italic);
3869 StyleSetUnderline(styleNum, underline);
3870 StyleSetFontEncoding(styleNum, encoding);
3871 }
3872
3873
3874 // Set the character set of the font in a style. Converts the Scintilla
3875 // character set values to a wxFontEncoding.
3876 void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
3877 {
3878 wxFontEncoding encoding;
3879
3880 // Translate the Scintilla characterSet to a wxFontEncoding
3881 switch (characterSet) {
3882 default:
3883 case wxSTC_CHARSET_ANSI:
3884 case wxSTC_CHARSET_DEFAULT:
3885 encoding = wxFONTENCODING_DEFAULT;
3886 break;
3887
3888 case wxSTC_CHARSET_BALTIC:
3889 encoding = wxFONTENCODING_ISO8859_13;
3890 break;
3891
3892 case wxSTC_CHARSET_CHINESEBIG5:
3893 encoding = wxFONTENCODING_CP950;
3894 break;
3895
3896 case wxSTC_CHARSET_EASTEUROPE:
3897 encoding = wxFONTENCODING_ISO8859_2;
3898 break;
3899
3900 case wxSTC_CHARSET_GB2312:
3901 encoding = wxFONTENCODING_CP936;
3902 break;
3903
3904 case wxSTC_CHARSET_GREEK:
3905 encoding = wxFONTENCODING_ISO8859_7;
3906 break;
3907
3908 case wxSTC_CHARSET_HANGUL:
3909 encoding = wxFONTENCODING_CP949;
3910 break;
3911
3912 case wxSTC_CHARSET_MAC:
3913 encoding = wxFONTENCODING_DEFAULT;
3914 break;
3915
3916 case wxSTC_CHARSET_OEM:
3917 encoding = wxFONTENCODING_DEFAULT;
3918 break;
3919
3920 case wxSTC_CHARSET_RUSSIAN:
3921 encoding = wxFONTENCODING_KOI8;
3922 break;
3923
3924 case wxSTC_CHARSET_SHIFTJIS:
3925 encoding = wxFONTENCODING_CP932;
3926 break;
3927
3928 case wxSTC_CHARSET_SYMBOL:
3929 encoding = wxFONTENCODING_DEFAULT;
3930 break;
3931
3932 case wxSTC_CHARSET_TURKISH:
3933 encoding = wxFONTENCODING_ISO8859_9;
3934 break;
3935
3936 case wxSTC_CHARSET_JOHAB:
3937 encoding = wxFONTENCODING_DEFAULT;
3938 break;
3939
3940 case wxSTC_CHARSET_HEBREW:
3941 encoding = wxFONTENCODING_ISO8859_8;
3942 break;
3943
3944 case wxSTC_CHARSET_ARABIC:
3945 encoding = wxFONTENCODING_ISO8859_6;
3946 break;
3947
3948 case wxSTC_CHARSET_VIETNAMESE:
3949 encoding = wxFONTENCODING_DEFAULT;
3950 break;
3951
3952 case wxSTC_CHARSET_THAI:
3953 encoding = wxFONTENCODING_ISO8859_11;
3954 break;
3955
3956 case wxSTC_CHARSET_CYRILLIC:
3957 encoding = wxFONTENCODING_ISO8859_5;
3958 break;
3959
3960 case wxSTC_CHARSET_8859_15:
3961 encoding = wxFONTENCODING_ISO8859_15;;
3962 break;
3963 }
3964
3965 // We just have Scintilla track the wxFontEncoding for us. It gets used
3966 // in Font::Create in PlatWX.cpp. We add one to the value so that the
3967 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
3968 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
3969 // to wxFONENCODING_DEFAULT in Font::Create.
3970 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
3971 }
3972
3973
3974 // Set the font encoding to be used by a style.
3975 void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
3976 {
3977 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
3978 }
3979
3980
3981 // Perform one of the operations defined by the wxSTC_CMD_* constants.
3982 void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
3983 SendMsg(cmd);
3984 }
3985
3986
3987 // Set the left and right margin in the edit area, measured in pixels.
3988 void wxStyledTextCtrl::SetMargins(int left, int right) {
3989 SetMarginLeft(left);
3990 SetMarginRight(right);
3991 }
3992
3993
3994 // Retrieve the point in the window where a position is displayed.
3995 wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
3996 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
3997 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
3998 return wxPoint(x, y);
3999 }
4000
4001 // Scroll enough to make the given line visible
4002 void wxStyledTextCtrl::ScrollToLine(int line) {
4003 m_swx->DoScrollToLine(line);
4004 }
4005
4006
4007 // Scroll enough to make the given column visible
4008 void wxStyledTextCtrl::ScrollToColumn(int column) {
4009 m_swx->DoScrollToColumn(column);
4010 }
4011
4012
4013 #if wxUSE_TEXTCTRL
4014 bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType)
4015 {
4016 bool ok = wxTextAreaBase::DoSaveFile(filename, fileType);
4017 #else
4018 bool wxStyledTextCtrl::SaveFile(const wxString& filename)
4019 {
4020 #if wxUSE_FFILE
4021 wxFFile file(filename, wxT("w"));
4022 bool ok = file.IsOpened() && file.Write(GetValue(), *wxConvCurrent);
4023 #else
4024 bool ok = false;
4025 #endif // wxUSE_FFILE
4026 #endif
4027 if (ok)
4028 {
4029 SetSavePoint();
4030 }
4031 return ok;
4032 }
4033
4034 #if wxUSE_TEXTCTRL
4035 bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int fileType)
4036 {
4037 bool ok = wxTextAreaBase::DoLoadFile(filename, fileType);
4038 #else
4039 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
4040 {
4041 #if wxUSE_FFILE
4042 wxFFile file(filename);
4043 bool ok = file.IsOpened();
4044 if (ok)
4045 {
4046 wxString text;
4047 ok = file.ReadAll(&text, *wxConvCurrent);
4048 if (ok)
4049 {
4050 SetValue(text);
4051 }
4052 }
4053 #else
4054 bool ok = false;
4055 #endif // wxUSE_FFILE
4056 #endif
4057 if (ok)
4058 {
4059 EmptyUndoBuffer();
4060 SetSavePoint();
4061 }
4062 return ok;
4063 }
4064
4065 #if wxUSE_DRAG_AND_DROP
4066 wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
4067 return m_swx->DoDragOver(x, y, def);
4068 }
4069
4070
4071 bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
4072 return m_swx->DoDropText(x, y, data);
4073 }
4074 #endif
4075
4076
4077 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
4078 m_swx->SetUseAntiAliasing(useAA);
4079 }
4080
4081 bool wxStyledTextCtrl::GetUseAntiAliasing() {
4082 return m_swx->GetUseAntiAliasing();
4083 }
4084
4085
4086
4087
4088
4089 void wxStyledTextCtrl::AddTextRaw(const char* text)
4090 {
4091 SendMsg(SCI_ADDTEXT, strlen(text), (sptr_t)text);
4092 }
4093
4094 void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
4095 {
4096 SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text);
4097 }
4098
4099 wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
4100 {
4101 int len = LineLength(GetCurrentLine());
4102 if (!len) {
4103 if (linePos) *linePos = 0;
4104 wxCharBuffer empty;
4105 return empty;
4106 }
4107
4108 wxCharBuffer buf(len);
4109 int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data());
4110 if (linePos) *linePos = pos;
4111 return buf;
4112 }
4113
4114 wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
4115 {
4116 int len = LineLength(line);
4117 if (!len) {
4118 wxCharBuffer empty;
4119 return empty;
4120 }
4121
4122 wxCharBuffer buf(len);
4123 SendMsg(SCI_GETLINE, line, (sptr_t)buf.data());
4124 return buf;
4125 }
4126
4127 wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
4128 {
4129 long start;
4130 long end;
4131
4132 GetSelection(&start, &end);
4133 int len = end - start;
4134 if (!len) {
4135 wxCharBuffer empty;
4136 return empty;
4137 }
4138
4139 wxCharBuffer buf(len);
4140 SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
4141 return buf;
4142 }
4143
4144 wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
4145 {
4146 if (endPos < startPos) {
4147 int temp = startPos;
4148 startPos = endPos;
4149 endPos = temp;
4150 }
4151 int len = endPos - startPos;
4152 if (!len) {
4153 wxCharBuffer empty;
4154 return empty;
4155 }
4156
4157 wxCharBuffer buf(len);
4158 TextRange tr;
4159 tr.lpstrText = buf.data();
4160 tr.chrg.cpMin = startPos;
4161 tr.chrg.cpMax = endPos;
4162 SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
4163 return buf;
4164 }
4165
4166 void wxStyledTextCtrl::SetTextRaw(const char* text)
4167 {
4168 SendMsg(SCI_SETTEXT, 0, (sptr_t)text);
4169 }
4170
4171 wxCharBuffer wxStyledTextCtrl::GetTextRaw()
4172 {
4173 int len = GetTextLength();
4174 wxCharBuffer buf(len); // adds 1 for NUL automatically
4175 SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data());
4176 return buf;
4177 }
4178
4179 void wxStyledTextCtrl::AppendTextRaw(const char* text)
4180 {
4181 SendMsg(SCI_APPENDTEXT, strlen(text), (sptr_t)text);
4182 }
4183
4184
4185
4186
4187
4188 //----------------------------------------------------------------------
4189 // Event handlers
4190
4191 void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
4192 wxPaintDC dc(this);
4193 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
4194 }
4195
4196 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
4197 if (evt.GetOrientation() == wxHORIZONTAL)
4198 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4199 else
4200 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4201 }
4202
4203 void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
4204 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
4205 if (sb) {
4206 if (sb->IsVertical())
4207 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4208 else
4209 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4210 }
4211 }
4212
4213 void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
4214 if (m_swx) {
4215 wxSize sz = GetClientSize();
4216 m_swx->DoSize(sz.x, sz.y);
4217 }
4218 }
4219
4220 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
4221 SetFocus();
4222 wxPoint pt = evt.GetPosition();
4223 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
4224 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
4225 }
4226
4227 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
4228 wxPoint pt = evt.GetPosition();
4229 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
4230 }
4231
4232 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
4233 wxPoint pt = evt.GetPosition();
4234 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
4235 evt.ControlDown());
4236 }
4237
4238
4239 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
4240 wxPoint pt = evt.GetPosition();
4241 m_swx->DoContextMenu(Point(pt.x, pt.y));
4242 }
4243
4244
4245 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
4246 wxPoint pt = evt.GetPosition();
4247 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
4248 }
4249
4250 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
4251 wxPoint pt = evt.GetPosition();
4252 ScreenToClient(&pt.x, &pt.y);
4253 /*
4254 Show context menu at event point if it's within the window,
4255 or at caret location if not
4256 */
4257 wxHitTest ht = this->HitTest(pt);
4258 if (ht != wxHT_WINDOW_INSIDE) {
4259 pt = this->PointFromPosition(this->GetCurrentPos());
4260 }
4261 m_swx->DoContextMenu(Point(pt.x, pt.y));
4262 }
4263
4264
4265 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
4266 {
4267 // prevent having an event queue with wheel events that cannot be processed
4268 // reasonably fast (see ticket #9057)
4269 if ( m_lastWheelTimestamp <= evt.GetTimestamp() )
4270 {
4271 m_lastWheelTimestamp = m_stopWatch.Time();
4272 m_swx->DoMouseWheel(evt.GetWheelRotation(),
4273 evt.GetWheelDelta(),
4274 evt.GetLinesPerAction(),
4275 evt.ControlDown(),
4276 evt.IsPageScroll());
4277 m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp;
4278 m_lastWheelTimestamp += evt.GetTimestamp();
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