]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/stc/stc.cpp
removed carbon printing code
[wxWidgets.git] / src / stc / stc.cpp
... / ...
CommitLineData
1////////////////////////////////////////////////////////////////////////////
2// Name: stc.cpp
3// Purpose: A wxWindows implementation of Scintilla. This class is the
4// one meant to be used directly by wx applications. It does not
5// derive directly from the Scintilla classes, but instead
6// delegates most things to the real Scintilla class.
7// This allows the use of Scintilla without polluting the
8// namespace with all the classes and identifiers from Scintilla.
9//
10// Author: Robin Dunn
11//
12// Created: 13-Jan-2000
13// RCS-ID: $Id$
14// Copyright: (c) 2000 by Total Control Software
15// Licence: wxWindows license
16/////////////////////////////////////////////////////////////////////////////
17
18#include <ctype.h>
19
20#include "wx/stc/stc.h"
21#include "ScintillaWX.h"
22
23#include <wx/wx.h>
24#include <wx/tokenzr.h>
25#include <wx/mstream.h>
26#include <wx/image.h>
27
28
29//----------------------------------------------------------------------
30
31const wxChar* wxSTCNameStr = wxT("stcwindow");
32
33#ifdef MAKELONG
34#undef MAKELONG
35#endif
36
37#define MAKELONG(a, b) ((a) | ((b) << 16))
38
39
40static long wxColourAsLong(const wxColour& co) {
41 return (((long)co.Blue() << 16) |
42 ((long)co.Green() << 8) |
43 ((long)co.Red()));
44}
45
46static wxColour wxColourFromLong(long c) {
47 wxColour clr;
48 clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
49 return clr;
50}
51
52
53static wxColour wxColourFromSpec(const wxString& spec) {
54 // spec should be "#RRGGBB"
55 long red, green, blue;
56 red = green = blue = 0;
57 spec.Mid(1,2).ToLong(&red, 16);
58 spec.Mid(3,2).ToLong(&green, 16);
59 spec.Mid(5,2).ToLong(&blue, 16);
60 return wxColour(red, green, blue);
61}
62
63//----------------------------------------------------------------------
64
65DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
66DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
67DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
68DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
69DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
70DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
71DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
72DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
73DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
74DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
75DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
76DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
77DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
78DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
79DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
80DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
81DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
82DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
83DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
84DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
85DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
86DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
87DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM )
88DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
89DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
90DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
91
92
93
94BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
95 EVT_PAINT (wxStyledTextCtrl::OnPaint)
96 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
97 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
98 EVT_SIZE (wxStyledTextCtrl::OnSize)
99 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
100 // Let Scintilla see the double click as a second click
101 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
102 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
103 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
104#if defined(__WXGTK__) || defined(__WXMAC__)
105 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
106#else
107 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
108#endif
109 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
110 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
111 EVT_CHAR (wxStyledTextCtrl::OnChar)
112 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
113 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
114 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
115 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
116 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
117 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
118 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
119END_EVENT_TABLE()
120
121
122IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
123IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
124
125#ifdef LINK_LEXERS
126// forces the linking of the lexer modules
127int Scintilla_LinkLexers();
128#endif
129
130//----------------------------------------------------------------------
131// Constructor and Destructor
132
133wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
134 wxWindowID id,
135 const wxPoint& pos,
136 const wxSize& size,
137 long style,
138 const wxString& name) :
139 wxControl(parent, id, pos, size,
140 style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
141 wxDefaultValidator, name)
142{
143#ifdef LINK_LEXERS
144 Scintilla_LinkLexers();
145#endif
146 m_swx = new ScintillaWX(this);
147 m_stopWatch.Start();
148 m_lastKeyDownConsumed = FALSE;
149 m_vScrollBar = NULL;
150 m_hScrollBar = NULL;
151#if wxUSE_UNICODE
152 // Put Scintilla into unicode (UTF-8) mode
153 SetCodePage(wxSTC_CP_UTF8);
154#endif
155}
156
157
158wxStyledTextCtrl::~wxStyledTextCtrl() {
159 delete m_swx;
160}
161
162
163//----------------------------------------------------------------------
164
165long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
166
167 return m_swx->WndProc(msg, wp, lp);
168}
169
170
171
172//----------------------------------------------------------------------
173// BEGIN generated section. The following code is automatically generated
174// by gen_iface.py from the contents of Scintilla.iface. Do not edit
175// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
176
177
178// Add text to the document.
179void wxStyledTextCtrl::AddText(const wxString& text) {
180 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
181 SendMsg(2001, strlen(buf), (long)(const char*)buf);
182}
183
184// Add array of cells to document.
185void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
186 SendMsg(2002, data.GetDataLen(), (long)data.GetData());
187}
188
189// Insert string at a position.
190void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
191 SendMsg(2003, pos, (long)(const char*)wx2stc(text));
192}
193
194// Delete all text in the document.
195void wxStyledTextCtrl::ClearAll() {
196 SendMsg(2004, 0, 0);
197}
198
199// Set all style bytes to 0, remove all folding information.
200void wxStyledTextCtrl::ClearDocumentStyle() {
201 SendMsg(2005, 0, 0);
202}
203
204// The number of characters in the document.
205int wxStyledTextCtrl::GetLength() {
206 return SendMsg(2006, 0, 0);
207}
208
209// Returns the character byte at the position.
210int wxStyledTextCtrl::GetCharAt(int pos) {
211 return (unsigned char)SendMsg(2007, pos, 0);
212}
213
214// Returns the position of the caret.
215int wxStyledTextCtrl::GetCurrentPos() {
216 return SendMsg(2008, 0, 0);
217}
218
219// Returns the position of the opposite end of the selection to the caret.
220int wxStyledTextCtrl::GetAnchor() {
221 return SendMsg(2009, 0, 0);
222}
223
224// Returns the style byte at the position.
225int wxStyledTextCtrl::GetStyleAt(int pos) {
226 return (unsigned char)SendMsg(2010, pos, 0);
227}
228
229// Redoes the next action on the undo history.
230void wxStyledTextCtrl::Redo() {
231 SendMsg(2011, 0, 0);
232}
233
234// Choose between collecting actions into the undo
235// history and discarding them.
236void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
237 SendMsg(2012, collectUndo, 0);
238}
239
240// Select all the text in the document.
241void wxStyledTextCtrl::SelectAll() {
242 SendMsg(2013, 0, 0);
243}
244
245// Remember the current position in the undo history as the position
246// at which the document was saved.
247void wxStyledTextCtrl::SetSavePoint() {
248 SendMsg(2014, 0, 0);
249}
250
251// Retrieve a buffer of cells.
252wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
253 wxMemoryBuffer buf;
254 if (endPos < startPos) {
255 int temp = startPos;
256 startPos = endPos;
257 endPos = temp;
258 }
259 int len = endPos - startPos;
260 if (!len) return buf;
261 TextRange tr;
262 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
263 tr.chrg.cpMin = startPos;
264 tr.chrg.cpMax = endPos;
265 len = SendMsg(2015, 0, (long)&tr);
266 buf.UngetWriteBuf(len);
267 return buf;
268}
269
270// Are there any redoable actions in the undo history?
271bool wxStyledTextCtrl::CanRedo() {
272 return SendMsg(2016, 0, 0) != 0;
273}
274
275// Retrieve the line number at which a particular marker is located.
276int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
277 return SendMsg(2017, handle, 0);
278}
279
280// Delete a marker.
281void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
282 SendMsg(2018, handle, 0);
283}
284
285// Is undo history being collected?
286bool wxStyledTextCtrl::GetUndoCollection() {
287 return SendMsg(2019, 0, 0) != 0;
288}
289
290// Are white space characters currently visible?
291// Returns one of SCWS_* constants.
292int wxStyledTextCtrl::GetViewWhiteSpace() {
293 return SendMsg(2020, 0, 0);
294}
295
296// Make white space characters invisible, always visible or visible outside indentation.
297void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
298 SendMsg(2021, viewWS, 0);
299}
300
301// Find the position from a point within the window.
302int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
303 return SendMsg(2022, pt.x, pt.y);
304}
305
306// Find the position from a point within the window but return
307// INVALID_POSITION if not close to text.
308int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
309 return SendMsg(2023, x, y);
310}
311
312// Set caret to start of a line and ensure it is visible.
313void wxStyledTextCtrl::GotoLine(int line) {
314 SendMsg(2024, line, 0);
315}
316
317// Set caret to a position and ensure it is visible.
318void wxStyledTextCtrl::GotoPos(int pos) {
319 SendMsg(2025, pos, 0);
320}
321
322// Set the selection anchor to a position. The anchor is the opposite
323// end of the selection from the caret.
324void wxStyledTextCtrl::SetAnchor(int posAnchor) {
325 SendMsg(2026, posAnchor, 0);
326}
327
328// Retrieve the text of the line containing the caret.
329// Returns the index of the caret on the line.
330wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
331 int len = LineLength(GetCurrentLine());
332 if (!len) {
333 if (linePos) *linePos = 0;
334 return wxEmptyString;
335 }
336
337 wxMemoryBuffer mbuf(len+1);
338 char* buf = (char*)mbuf.GetWriteBuf(len+1);
339
340 int pos = SendMsg(2027, len+1, (long)buf);
341 mbuf.UngetWriteBuf(len);
342 mbuf.AppendByte(0);
343 if (linePos) *linePos = pos;
344 return stc2wx(buf);
345}
346
347// Retrieve the position of the last correctly styled character.
348int wxStyledTextCtrl::GetEndStyled() {
349 return SendMsg(2028, 0, 0);
350}
351
352// Convert all line endings in the document to one mode.
353void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
354 SendMsg(2029, eolMode, 0);
355}
356
357// Retrieve the current end of line mode - one of CRLF, CR, or LF.
358int wxStyledTextCtrl::GetEOLMode() {
359 return SendMsg(2030, 0, 0);
360}
361
362// Set the current end of line mode.
363void wxStyledTextCtrl::SetEOLMode(int eolMode) {
364 SendMsg(2031, eolMode, 0);
365}
366
367// Set the current styling position to pos and the styling mask to mask.
368// The styling mask can be used to protect some bits in each styling byte from modification.
369void wxStyledTextCtrl::StartStyling(int pos, int mask) {
370 SendMsg(2032, pos, mask);
371}
372
373// Change style from current styling position for length characters to a style
374// and move the current styling position to after this newly styled segment.
375void wxStyledTextCtrl::SetStyling(int length, int style) {
376 SendMsg(2033, length, style);
377}
378
379// Is drawing done first into a buffer or direct to the screen?
380bool wxStyledTextCtrl::GetBufferedDraw() {
381 return SendMsg(2034, 0, 0) != 0;
382}
383
384// If drawing is buffered then each line of text is drawn into a bitmap buffer
385// before drawing it to the screen to avoid flicker.
386void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
387 SendMsg(2035, buffered, 0);
388}
389
390// Change the visible size of a tab to be a multiple of the width of a space character.
391void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
392 SendMsg(2036, tabWidth, 0);
393}
394
395// Retrieve the visible size of a tab.
396int wxStyledTextCtrl::GetTabWidth() {
397 return SendMsg(2121, 0, 0);
398}
399
400// Set the code page used to interpret the bytes of the document as characters.
401void wxStyledTextCtrl::SetCodePage(int codePage) {
402#if wxUSE_UNICODE
403 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
404 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
405#else
406 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
407 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
408#endif
409 SendMsg(2037, codePage);
410}
411
412// Set the symbol used for a particular marker number,
413// and optionally the fore and background colours.
414void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
415 const wxColour& foreground,
416 const wxColour& background) {
417
418 SendMsg(2040, markerNumber, markerSymbol);
419 if (foreground.Ok())
420 MarkerSetForeground(markerNumber, foreground);
421 if (background.Ok())
422 MarkerSetBackground(markerNumber, background);
423}
424
425// Set the foreground colour used for a particular marker number.
426void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
427 SendMsg(2041, markerNumber, wxColourAsLong(fore));
428}
429
430// Set the background colour used for a particular marker number.
431void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
432 SendMsg(2042, markerNumber, wxColourAsLong(back));
433}
434
435// Add a marker to a line, returning an ID which can be used to find or delete the marker.
436int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
437 return SendMsg(2043, line, markerNumber);
438}
439
440// Delete a marker from a line.
441void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
442 SendMsg(2044, line, markerNumber);
443}
444
445// Delete all markers with a particular number from all lines.
446void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
447 SendMsg(2045, markerNumber, 0);
448}
449
450// Get a bit mask of all the markers set on a line.
451int wxStyledTextCtrl::MarkerGet(int line) {
452 return SendMsg(2046, line, 0);
453}
454
455// Find the next line after lineStart that includes a marker in mask.
456int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
457 return SendMsg(2047, lineStart, markerMask);
458}
459
460// Find the previous line before lineStart that includes a marker in mask.
461int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
462 return SendMsg(2048, lineStart, markerMask);
463}
464
465// Define a marker from a bitmap
466void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
467 // convert bmp to a xpm in a string
468 wxMemoryOutputStream strm;
469 wxImage img = bmp.ConvertToImage();
470 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
471 size_t len = strm.GetSize();
472 char* buff = new char[len+1];
473 strm.CopyTo(buff, len);
474 buff[len] = 0;
475 SendMsg(2049, markerNumber, (long)buff);
476 delete [] buff;
477
478}
479
480// Set a margin to be either numeric or symbolic.
481void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
482 SendMsg(2240, margin, marginType);
483}
484
485// Retrieve the type of a margin.
486int wxStyledTextCtrl::GetMarginType(int margin) {
487 return SendMsg(2241, margin, 0);
488}
489
490// Set the width of a margin to a width expressed in pixels.
491void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
492 SendMsg(2242, margin, pixelWidth);
493}
494
495// Retrieve the width of a margin in pixels.
496int wxStyledTextCtrl::GetMarginWidth(int margin) {
497 return SendMsg(2243, margin, 0);
498}
499
500// Set a mask that determines which markers are displayed in a margin.
501void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
502 SendMsg(2244, margin, mask);
503}
504
505// Retrieve the marker mask of a margin.
506int wxStyledTextCtrl::GetMarginMask(int margin) {
507 return SendMsg(2245, margin, 0);
508}
509
510// Make a margin sensitive or insensitive to mouse clicks.
511void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
512 SendMsg(2246, margin, sensitive);
513}
514
515// Retrieve the mouse click sensitivity of a margin.
516bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
517 return SendMsg(2247, margin, 0) != 0;
518}
519
520// Clear all the styles and make equivalent to the global default style.
521void wxStyledTextCtrl::StyleClearAll() {
522 SendMsg(2050, 0, 0);
523}
524
525// Set the foreground colour of a style.
526void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
527 SendMsg(2051, style, wxColourAsLong(fore));
528}
529
530// Set the background colour of a style.
531void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
532 SendMsg(2052, style, wxColourAsLong(back));
533}
534
535// Set a style to be bold or not.
536void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
537 SendMsg(2053, style, bold);
538}
539
540// Set a style to be italic or not.
541void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
542 SendMsg(2054, style, italic);
543}
544
545// Set the size of characters of a style.
546void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
547 SendMsg(2055, style, sizePoints);
548}
549
550// Set the font of a style.
551void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
552 SendMsg(2056, style, (long)(const char*)wx2stc(fontName));
553}
554
555// Set a style to have its end of line filled or not.
556void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
557 SendMsg(2057, style, filled);
558}
559
560// Reset the default style to its state at startup
561void wxStyledTextCtrl::StyleResetDefault() {
562 SendMsg(2058, 0, 0);
563}
564
565// Set a style to be underlined or not.
566void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
567 SendMsg(2059, style, underline);
568}
569
570// Set a style to be mixed case, or to force upper or lower case.
571void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
572 SendMsg(2060, style, caseForce);
573}
574
575// Set the character set of the font in a style.
576void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
577 SendMsg(2066, style, characterSet);
578}
579
580// Set a style to be a hotspot or not.
581void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) {
582 SendMsg(2409, style, hotspot);
583}
584
585// Set the foreground colour of the selection and whether to use this setting.
586void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
587 SendMsg(2067, useSetting, wxColourAsLong(fore));
588}
589
590// Set the background colour of the selection and whether to use this setting.
591void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
592 SendMsg(2068, useSetting, wxColourAsLong(back));
593}
594
595// Set the foreground colour of the caret.
596void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
597 SendMsg(2069, wxColourAsLong(fore), 0);
598}
599
600// When key+modifier combination km is pressed perform msg.
601void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
602 SendMsg(2070, MAKELONG(key, modifiers), cmd);
603}
604
605// When key+modifier combination km do nothing.
606void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
607 SendMsg(2071, MAKELONG(key, modifiers));
608}
609
610// Drop all key mappings.
611void wxStyledTextCtrl::CmdKeyClearAll() {
612 SendMsg(2072, 0, 0);
613}
614
615// Set the styles for a segment of the document.
616void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
617 SendMsg(2073, length, (long)styleBytes);
618}
619
620// Set a style to be visible or not.
621void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
622 SendMsg(2074, style, visible);
623}
624
625// Get the time in milliseconds that the caret is on and off.
626int wxStyledTextCtrl::GetCaretPeriod() {
627 return SendMsg(2075, 0, 0);
628}
629
630// Get the time in milliseconds that the caret is on and off. 0 = steady on.
631void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
632 SendMsg(2076, periodMilliseconds, 0);
633}
634
635// Set the set of characters making up words for when moving or selecting by word.
636void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
637 SendMsg(2077, 0, (long)(const char*)wx2stc(characters));
638}
639
640// Start a sequence of actions that is undone and redone as a unit.
641// May be nested.
642void wxStyledTextCtrl::BeginUndoAction() {
643 SendMsg(2078, 0, 0);
644}
645
646// End a sequence of actions that is undone and redone as a unit.
647void wxStyledTextCtrl::EndUndoAction() {
648 SendMsg(2079, 0, 0);
649}
650
651// Set an indicator to plain, squiggle or TT.
652void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
653 SendMsg(2080, indic, style);
654}
655
656// Retrieve the style of an indicator.
657int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
658 return SendMsg(2081, indic, 0);
659}
660
661// Set the foreground colour of an indicator.
662void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
663 SendMsg(2082, indic, wxColourAsLong(fore));
664}
665
666// Retrieve the foreground colour of an indicator.
667wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
668 long c = SendMsg(2083, indic, 0);
669 return wxColourFromLong(c);
670}
671
672// Set the foreground colour of all whitespace and whether to use this setting.
673void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) {
674 SendMsg(2084, useSetting, wxColourAsLong(fore));
675}
676
677// Set the background colour of all whitespace and whether to use this setting.
678void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) {
679 SendMsg(2085, useSetting, wxColourAsLong(back));
680}
681
682// Divide each styling byte into lexical class bits (default: 5) and indicator
683// bits (default: 3). If a lexer requires more than 32 lexical states, then this
684// is used to expand the possible states.
685void wxStyledTextCtrl::SetStyleBits(int bits) {
686 SendMsg(2090, bits, 0);
687}
688
689// Retrieve number of bits in style bytes used to hold the lexical state.
690int wxStyledTextCtrl::GetStyleBits() {
691 return SendMsg(2091, 0, 0);
692}
693
694// Used to hold extra styling information for each line.
695void wxStyledTextCtrl::SetLineState(int line, int state) {
696 SendMsg(2092, line, state);
697}
698
699// Retrieve the extra styling information for a line.
700int wxStyledTextCtrl::GetLineState(int line) {
701 return SendMsg(2093, line, 0);
702}
703
704// Retrieve the last line number that has line state.
705int wxStyledTextCtrl::GetMaxLineState() {
706 return SendMsg(2094, 0, 0);
707}
708
709// Is the background of the line containing the caret in a different colour?
710bool wxStyledTextCtrl::GetCaretLineVisible() {
711 return SendMsg(2095, 0, 0) != 0;
712}
713
714// Display the background of the line containing the caret in a different colour.
715void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
716 SendMsg(2096, show, 0);
717}
718
719// Get the colour of the background of the line containing the caret.
720wxColour wxStyledTextCtrl::GetCaretLineBack() {
721 long c = SendMsg(2097, 0, 0);
722 return wxColourFromLong(c);
723}
724
725// Set the colour of the background of the line containing the caret.
726void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
727 SendMsg(2098, wxColourAsLong(back), 0);
728}
729
730// Set a style to be changeable or not (read only).
731// Experimental feature, currently buggy.
732void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
733 SendMsg(2099, style, changeable);
734}
735
736// Display a auto-completion list.
737// The lenEntered parameter indicates how many characters before
738// the caret should be used to provide context.
739void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
740 SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList));
741}
742
743// Remove the auto-completion list from the screen.
744void wxStyledTextCtrl::AutoCompCancel() {
745 SendMsg(2101, 0, 0);
746}
747
748// Is there an auto-completion list visible?
749bool wxStyledTextCtrl::AutoCompActive() {
750 return SendMsg(2102, 0, 0) != 0;
751}
752
753// Retrieve the position of the caret when the auto-completion list was displayed.
754int wxStyledTextCtrl::AutoCompPosStart() {
755 return SendMsg(2103, 0, 0);
756}
757
758// User has selected an item so remove the list and insert the selection.
759void wxStyledTextCtrl::AutoCompComplete() {
760 SendMsg(2104, 0, 0);
761}
762
763// Define a set of character that when typed cancel the auto-completion list.
764void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
765 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet));
766}
767
768// Change the separator character in the string setting up an auto-completion list.
769// Default is space but can be changed if items contain space.
770void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
771 SendMsg(2106, separatorCharacter, 0);
772}
773
774// Retrieve the auto-completion list separator character.
775int wxStyledTextCtrl::AutoCompGetSeparator() {
776 return SendMsg(2107, 0, 0);
777}
778
779// Select the item in the auto-completion list that starts with a string.
780void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
781 SendMsg(2108, 0, (long)(const char*)wx2stc(text));
782}
783
784// Should the auto-completion list be cancelled if the user backspaces to a
785// position before where the box was created.
786void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
787 SendMsg(2110, cancel, 0);
788}
789
790// Retrieve whether auto-completion cancelled by backspacing before start.
791bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
792 return SendMsg(2111, 0, 0) != 0;
793}
794
795// Define a set of characters that when typed will cause the autocompletion to
796// choose the selected item.
797void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
798 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet));
799}
800
801// Should a single item auto-completion list automatically choose the item.
802void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
803 SendMsg(2113, chooseSingle, 0);
804}
805
806// Retrieve whether a single item auto-completion list automatically choose the item.
807bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
808 return SendMsg(2114, 0, 0) != 0;
809}
810
811// Set whether case is significant when performing auto-completion searches.
812void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
813 SendMsg(2115, ignoreCase, 0);
814}
815
816// Retrieve state of ignore case flag.
817bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
818 return SendMsg(2116, 0, 0) != 0;
819}
820
821// Display a list of strings and send notification when user chooses one.
822void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
823 SendMsg(2117, listType, (long)(const char*)wx2stc(itemList));
824}
825
826// Set whether or not autocompletion is hidden automatically when nothing matches.
827void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
828 SendMsg(2118, autoHide, 0);
829}
830
831// Retrieve whether or not autocompletion is hidden automatically when nothing matches.
832bool wxStyledTextCtrl::AutoCompGetAutoHide() {
833 return SendMsg(2119, 0, 0) != 0;
834}
835
836// Set whether or not autocompletion deletes any word characters
837// after the inserted text upon completion.
838void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
839 SendMsg(2270, dropRestOfWord, 0);
840}
841
842// Retrieve whether or not autocompletion deletes any word characters
843// after the inserted text upon completion.
844bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
845 return SendMsg(2271, 0, 0) != 0;
846}
847
848// Register an image for use in autocompletion lists.
849void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
850 // convert bmp to a xpm in a string
851 wxMemoryOutputStream strm;
852 wxImage img = bmp.ConvertToImage();
853 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
854 size_t len = strm.GetSize();
855 char* buff = new char[len+1];
856 strm.CopyTo(buff, len);
857 buff[len] = 0;
858 SendMsg(2405, type, (long)buff);
859 delete [] buff;
860
861}
862
863// Clear all the registered images.
864void wxStyledTextCtrl::ClearRegisteredImages() {
865 SendMsg(2408, 0, 0);
866}
867
868// Retrieve the auto-completion list type-separator character.
869int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
870 return SendMsg(2285, 0, 0);
871}
872
873// Change the type-separator character in the string setting up an auto-completion list.
874// Default is '?' but can be changed if items contain '?'.
875void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) {
876 SendMsg(2286, separatorCharacter, 0);
877}
878
879// Set the number of spaces used for one level of indentation.
880void wxStyledTextCtrl::SetIndent(int indentSize) {
881 SendMsg(2122, indentSize, 0);
882}
883
884// Retrieve indentation size.
885int wxStyledTextCtrl::GetIndent() {
886 return SendMsg(2123, 0, 0);
887}
888
889// Indentation will only use space characters if useTabs is false, otherwise
890// it will use a combination of tabs and spaces.
891void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
892 SendMsg(2124, useTabs, 0);
893}
894
895// Retrieve whether tabs will be used in indentation.
896bool wxStyledTextCtrl::GetUseTabs() {
897 return SendMsg(2125, 0, 0) != 0;
898}
899
900// Change the indentation of a line to a number of columns.
901void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
902 SendMsg(2126, line, indentSize);
903}
904
905// Retrieve the number of columns that a line is indented.
906int wxStyledTextCtrl::GetLineIndentation(int line) {
907 return SendMsg(2127, line, 0);
908}
909
910// Retrieve the position before the first non indentation character on a line.
911int wxStyledTextCtrl::GetLineIndentPosition(int line) {
912 return SendMsg(2128, line, 0);
913}
914
915// Retrieve the column number of a position, taking tab width into account.
916int wxStyledTextCtrl::GetColumn(int pos) {
917 return SendMsg(2129, pos, 0);
918}
919
920// Show or hide the horizontal scroll bar.
921void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
922 SendMsg(2130, show, 0);
923}
924
925// Is the horizontal scroll bar visible?
926bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
927 return SendMsg(2131, 0, 0) != 0;
928}
929
930// Show or hide indentation guides.
931void wxStyledTextCtrl::SetIndentationGuides(bool show) {
932 SendMsg(2132, show, 0);
933}
934
935// Are the indentation guides visible?
936bool wxStyledTextCtrl::GetIndentationGuides() {
937 return SendMsg(2133, 0, 0) != 0;
938}
939
940// Set the highlighted indentation guide column.
941// 0 = no highlighted guide.
942void wxStyledTextCtrl::SetHighlightGuide(int column) {
943 SendMsg(2134, column, 0);
944}
945
946// Get the highlighted indentation guide column.
947int wxStyledTextCtrl::GetHighlightGuide() {
948 return SendMsg(2135, 0, 0);
949}
950
951// Get the position after the last visible characters on a line.
952int wxStyledTextCtrl::GetLineEndPosition(int line) {
953 return SendMsg(2136, line, 0);
954}
955
956// Get the code page used to interpret the bytes of the document as characters.
957int wxStyledTextCtrl::GetCodePage() {
958 return SendMsg(2137, 0, 0);
959}
960
961// Get the foreground colour of the caret.
962wxColour wxStyledTextCtrl::GetCaretForeground() {
963 long c = SendMsg(2138, 0, 0);
964 return wxColourFromLong(c);
965}
966
967// In read-only mode?
968bool wxStyledTextCtrl::GetReadOnly() {
969 return SendMsg(2140, 0, 0) != 0;
970}
971
972// Sets the position of the caret.
973void wxStyledTextCtrl::SetCurrentPos(int pos) {
974 SendMsg(2141, pos, 0);
975}
976
977// Sets the position that starts the selection - this becomes the anchor.
978void wxStyledTextCtrl::SetSelectionStart(int pos) {
979 SendMsg(2142, pos, 0);
980}
981
982// Returns the position at the start of the selection.
983int wxStyledTextCtrl::GetSelectionStart() {
984 return SendMsg(2143, 0, 0);
985}
986
987// Sets the position that ends the selection - this becomes the currentPosition.
988void wxStyledTextCtrl::SetSelectionEnd(int pos) {
989 SendMsg(2144, pos, 0);
990}
991
992// Returns the position at the end of the selection.
993int wxStyledTextCtrl::GetSelectionEnd() {
994 return SendMsg(2145, 0, 0);
995}
996
997// Sets the print magnification added to the point size of each style for printing.
998void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
999 SendMsg(2146, magnification, 0);
1000}
1001
1002// Returns the print magnification.
1003int wxStyledTextCtrl::GetPrintMagnification() {
1004 return SendMsg(2147, 0, 0);
1005}
1006
1007// Modify colours when printing for clearer printed text.
1008void wxStyledTextCtrl::SetPrintColourMode(int mode) {
1009 SendMsg(2148, mode, 0);
1010}
1011
1012// Returns the print colour mode.
1013int wxStyledTextCtrl::GetPrintColourMode() {
1014 return SendMsg(2149, 0, 0);
1015}
1016
1017// Find some text in the document.
1018int wxStyledTextCtrl::FindText(int minPos, int maxPos,
1019 const wxString& text,
1020 int flags) {
1021 TextToFind ft;
1022 ft.chrg.cpMin = minPos;
1023 ft.chrg.cpMax = maxPos;
1024 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1025 ft.lpstrText = (char*)(const char*)buf;
1026
1027 return SendMsg(2150, flags, (long)&ft);
1028}
1029
1030// On Windows, will draw the document into a display context such as a printer.
1031 int wxStyledTextCtrl::FormatRange(bool doDraw,
1032 int startPos,
1033 int endPos,
1034 wxDC* draw,
1035 wxDC* target, // Why does it use two? Can they be the same?
1036 wxRect renderRect,
1037 wxRect pageRect) {
1038 RangeToFormat fr;
1039
1040 if (endPos < startPos) {
1041 int temp = startPos;
1042 startPos = endPos;
1043 endPos = temp;
1044 }
1045 fr.hdc = draw;
1046 fr.hdcTarget = target;
1047 fr.rc.top = renderRect.GetTop();
1048 fr.rc.left = renderRect.GetLeft();
1049 fr.rc.right = renderRect.GetRight();
1050 fr.rc.bottom = renderRect.GetBottom();
1051 fr.rcPage.top = pageRect.GetTop();
1052 fr.rcPage.left = pageRect.GetLeft();
1053 fr.rcPage.right = pageRect.GetRight();
1054 fr.rcPage.bottom = pageRect.GetBottom();
1055 fr.chrg.cpMin = startPos;
1056 fr.chrg.cpMax = endPos;
1057
1058 return SendMsg(2151, doDraw, (long)&fr);
1059}
1060
1061// Retrieve the display line at the top of the display.
1062int wxStyledTextCtrl::GetFirstVisibleLine() {
1063 return SendMsg(2152, 0, 0);
1064}
1065
1066// Retrieve the contents of a line.
1067wxString wxStyledTextCtrl::GetLine(int line) {
1068 int len = LineLength(line);
1069 if (!len) return wxEmptyString;
1070
1071 wxMemoryBuffer mbuf(len+1);
1072 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1073 SendMsg(2153, line, (long)buf);
1074 mbuf.UngetWriteBuf(len);
1075 mbuf.AppendByte(0);
1076 return stc2wx(buf);
1077}
1078
1079// Returns the number of lines in the document. There is always at least one.
1080int wxStyledTextCtrl::GetLineCount() {
1081 return SendMsg(2154, 0, 0);
1082}
1083
1084// Sets the size in pixels of the left margin.
1085void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
1086 SendMsg(2155, 0, pixelWidth);
1087}
1088
1089// Returns the size in pixels of the left margin.
1090int wxStyledTextCtrl::GetMarginLeft() {
1091 return SendMsg(2156, 0, 0);
1092}
1093
1094// Sets the size in pixels of the right margin.
1095void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
1096 SendMsg(2157, 0, pixelWidth);
1097}
1098
1099// Returns the size in pixels of the right margin.
1100int wxStyledTextCtrl::GetMarginRight() {
1101 return SendMsg(2158, 0, 0);
1102}
1103
1104// Is the document different from when it was last saved?
1105bool wxStyledTextCtrl::GetModify() {
1106 return SendMsg(2159, 0, 0) != 0;
1107}
1108
1109// Select a range of text.
1110void wxStyledTextCtrl::SetSelection(int start, int end) {
1111 SendMsg(2160, start, end);
1112}
1113
1114// Retrieve the selected text.
1115wxString wxStyledTextCtrl::GetSelectedText() {
1116 int start;
1117 int end;
1118
1119 GetSelection(&start, &end);
1120 int len = end - start;
1121 if (!len) return wxEmptyString;
1122
1123 wxMemoryBuffer mbuf(len+1);
1124 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1125 SendMsg(2161, 0, (long)buf);
1126 mbuf.UngetWriteBuf(len);
1127 mbuf.AppendByte(0);
1128 return stc2wx(buf);
1129}
1130
1131// Retrieve a range of text.
1132wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1133 if (endPos < startPos) {
1134 int temp = startPos;
1135 startPos = endPos;
1136 endPos = temp;
1137 }
1138 int len = endPos - startPos;
1139 if (!len) return wxEmptyString;
1140 wxMemoryBuffer mbuf(len+1);
1141 char* buf = (char*)mbuf.GetWriteBuf(len);
1142 TextRange tr;
1143 tr.lpstrText = buf;
1144 tr.chrg.cpMin = startPos;
1145 tr.chrg.cpMax = endPos;
1146 SendMsg(2162, 0, (long)&tr);
1147 mbuf.UngetWriteBuf(len);
1148 mbuf.AppendByte(0);
1149 return stc2wx(buf);
1150}
1151
1152// Draw the selection in normal style or with selection highlighted.
1153void wxStyledTextCtrl::HideSelection(bool normal) {
1154 SendMsg(2163, normal, 0);
1155}
1156
1157// Retrieve the line containing a position.
1158int wxStyledTextCtrl::LineFromPosition(int pos) {
1159 return SendMsg(2166, pos, 0);
1160}
1161
1162// Retrieve the position at the start of a line.
1163int wxStyledTextCtrl::PositionFromLine(int line) {
1164 return SendMsg(2167, line, 0);
1165}
1166
1167// Scroll horizontally and vertically.
1168void wxStyledTextCtrl::LineScroll(int columns, int lines) {
1169 SendMsg(2168, columns, lines);
1170}
1171
1172// Ensure the caret is visible.
1173void wxStyledTextCtrl::EnsureCaretVisible() {
1174 SendMsg(2169, 0, 0);
1175}
1176
1177// Replace the selected text with the argument text.
1178void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
1179 SendMsg(2170, 0, (long)(const char*)wx2stc(text));
1180}
1181
1182// Set to read only or read write.
1183void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1184 SendMsg(2171, readOnly, 0);
1185}
1186
1187// Will a paste succeed?
1188bool wxStyledTextCtrl::CanPaste() {
1189 return SendMsg(2173, 0, 0) != 0;
1190}
1191
1192// Are there any undoable actions in the undo history?
1193bool wxStyledTextCtrl::CanUndo() {
1194 return SendMsg(2174, 0, 0) != 0;
1195}
1196
1197// Delete the undo history.
1198void wxStyledTextCtrl::EmptyUndoBuffer() {
1199 SendMsg(2175, 0, 0);
1200}
1201
1202// Undo one action in the undo history.
1203void wxStyledTextCtrl::Undo() {
1204 SendMsg(2176, 0, 0);
1205}
1206
1207// Cut the selection to the clipboard.
1208void wxStyledTextCtrl::Cut() {
1209 SendMsg(2177, 0, 0);
1210}
1211
1212// Copy the selection to the clipboard.
1213void wxStyledTextCtrl::Copy() {
1214 SendMsg(2178, 0, 0);
1215}
1216
1217// Paste the contents of the clipboard into the document replacing the selection.
1218void wxStyledTextCtrl::Paste() {
1219 SendMsg(2179, 0, 0);
1220}
1221
1222// Clear the selection.
1223void wxStyledTextCtrl::Clear() {
1224 SendMsg(2180, 0, 0);
1225}
1226
1227// Replace the contents of the document with the argument text.
1228void wxStyledTextCtrl::SetText(const wxString& text) {
1229 SendMsg(2181, 0, (long)(const char*)wx2stc(text));
1230}
1231
1232// Retrieve all the text in the document.
1233wxString wxStyledTextCtrl::GetText() {
1234 int len = GetTextLength();
1235 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1236 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1237 SendMsg(2182, len+1, (long)buf);
1238 mbuf.UngetWriteBuf(len);
1239 mbuf.AppendByte(0);
1240 return stc2wx(buf);
1241}
1242
1243// Retrieve the number of characters in the document.
1244int wxStyledTextCtrl::GetTextLength() {
1245 return SendMsg(2183, 0, 0);
1246}
1247
1248// Set to overtype (true) or insert mode.
1249void wxStyledTextCtrl::SetOvertype(bool overtype) {
1250 SendMsg(2186, overtype, 0);
1251}
1252
1253// Returns true if overtype mode is active otherwise false is returned.
1254bool wxStyledTextCtrl::GetOvertype() {
1255 return SendMsg(2187, 0, 0) != 0;
1256}
1257
1258// Set the width of the insert mode caret.
1259void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
1260 SendMsg(2188, pixelWidth, 0);
1261}
1262
1263// Returns the width of the insert mode caret.
1264int wxStyledTextCtrl::GetCaretWidth() {
1265 return SendMsg(2189, 0, 0);
1266}
1267
1268// Sets the position that starts the target which is used for updating the
1269// document without affecting the scroll position.
1270void wxStyledTextCtrl::SetTargetStart(int pos) {
1271 SendMsg(2190, pos, 0);
1272}
1273
1274// Get the position that starts the target.
1275int wxStyledTextCtrl::GetTargetStart() {
1276 return SendMsg(2191, 0, 0);
1277}
1278
1279// Sets the position that ends the target which is used for updating the
1280// document without affecting the scroll position.
1281void wxStyledTextCtrl::SetTargetEnd(int pos) {
1282 SendMsg(2192, pos, 0);
1283}
1284
1285// Get the position that ends the target.
1286int wxStyledTextCtrl::GetTargetEnd() {
1287 return SendMsg(2193, 0, 0);
1288}
1289
1290// Replace the target text with the argument text.
1291// Text is counted so it can contain nulls.
1292// Returns the length of the replacement text.
1293
1294 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1295 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1296 return SendMsg(2194, strlen(buf), (long)(const char*)buf);
1297}
1298
1299// Replace the target text with the argument text after \d processing.
1300// Text is counted so it can contain nulls.
1301// Looks for \d where d is between 1 and 9 and replaces these with the strings
1302// matched in the last search operation which were surrounded by \( and \).
1303// Returns the length of the replacement text including any change
1304// caused by processing the \d patterns.
1305
1306 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1307 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1308 return SendMsg(2195, strlen(buf), (long)(const char*)buf);
1309}
1310
1311// Search for a counted string in the target and set the target to the found
1312// range. Text is counted so it can contain nulls.
1313// Returns length of range or -1 for failure in which case target is not moved.
1314
1315 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1316 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1317 return SendMsg(2197, strlen(buf), (long)(const char*)buf);
1318}
1319
1320// Set the search flags used by SearchInTarget.
1321void wxStyledTextCtrl::SetSearchFlags(int flags) {
1322 SendMsg(2198, flags, 0);
1323}
1324
1325// Get the search flags used by SearchInTarget.
1326int wxStyledTextCtrl::GetSearchFlags() {
1327 return SendMsg(2199, 0, 0);
1328}
1329
1330// Show a call tip containing a definition near position pos.
1331void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
1332 SendMsg(2200, pos, (long)(const char*)wx2stc(definition));
1333}
1334
1335// Remove the call tip from the screen.
1336void wxStyledTextCtrl::CallTipCancel() {
1337 SendMsg(2201, 0, 0);
1338}
1339
1340// Is there an active call tip?
1341bool wxStyledTextCtrl::CallTipActive() {
1342 return SendMsg(2202, 0, 0) != 0;
1343}
1344
1345// Retrieve the position where the caret was before displaying the call tip.
1346int wxStyledTextCtrl::CallTipPosAtStart() {
1347 return SendMsg(2203, 0, 0);
1348}
1349
1350// Highlight a segment of the definition.
1351void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
1352 SendMsg(2204, start, end);
1353}
1354
1355// Set the background colour for the call tip.
1356void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1357 SendMsg(2205, wxColourAsLong(back), 0);
1358}
1359
1360// Set the foreground colour for the call tip.
1361void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore) {
1362 SendMsg(2206, wxColourAsLong(fore), 0);
1363}
1364
1365// Set the foreground colour for the highlighted part of the call tip.
1366void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) {
1367 SendMsg(2207, wxColourAsLong(fore), 0);
1368}
1369
1370// Find the display line of a document line taking hidden lines into account.
1371int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1372 return SendMsg(2220, line, 0);
1373}
1374
1375// Find the document line of a display line taking hidden lines into account.
1376int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1377 return SendMsg(2221, lineDisplay, 0);
1378}
1379
1380// Set the fold level of a line.
1381// This encodes an integer level along with flags indicating whether the
1382// line is a header and whether it is effectively white space.
1383void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1384 SendMsg(2222, line, level);
1385}
1386
1387// Retrieve the fold level of a line.
1388int wxStyledTextCtrl::GetFoldLevel(int line) {
1389 return SendMsg(2223, line, 0);
1390}
1391
1392// Find the last child line of a header line.
1393int wxStyledTextCtrl::GetLastChild(int line, int level) {
1394 return SendMsg(2224, line, level);
1395}
1396
1397// Find the parent line of a child line.
1398int wxStyledTextCtrl::GetFoldParent(int line) {
1399 return SendMsg(2225, line, 0);
1400}
1401
1402// Make a range of lines visible.
1403void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1404 SendMsg(2226, lineStart, lineEnd);
1405}
1406
1407// Make a range of lines invisible.
1408void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1409 SendMsg(2227, lineStart, lineEnd);
1410}
1411
1412// Is a line visible?
1413bool wxStyledTextCtrl::GetLineVisible(int line) {
1414 return SendMsg(2228, line, 0) != 0;
1415}
1416
1417// Show the children of a header line.
1418void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1419 SendMsg(2229, line, expanded);
1420}
1421
1422// Is a header line expanded?
1423bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1424 return SendMsg(2230, line, 0) != 0;
1425}
1426
1427// Switch a header line between expanded and contracted.
1428void wxStyledTextCtrl::ToggleFold(int line) {
1429 SendMsg(2231, line, 0);
1430}
1431
1432// Ensure a particular line is visible by expanding any header line hiding it.
1433void wxStyledTextCtrl::EnsureVisible(int line) {
1434 SendMsg(2232, line, 0);
1435}
1436
1437// Set some style options for folding.
1438void wxStyledTextCtrl::SetFoldFlags(int flags) {
1439 SendMsg(2233, flags, 0);
1440}
1441
1442// Ensure a particular line is visible by expanding any header line hiding it.
1443// Use the currently set visibility policy to determine which range to display.
1444void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
1445 SendMsg(2234, line, 0);
1446}
1447
1448// Sets whether a tab pressed when caret is within indentation indents.
1449void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
1450 SendMsg(2260, tabIndents, 0);
1451}
1452
1453// Does a tab pressed when caret is within indentation indent?
1454bool wxStyledTextCtrl::GetTabIndents() {
1455 return SendMsg(2261, 0, 0) != 0;
1456}
1457
1458// Sets whether a backspace pressed when caret is within indentation unindents.
1459void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
1460 SendMsg(2262, bsUnIndents, 0);
1461}
1462
1463// Does a backspace pressed when caret is within indentation unindent?
1464bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1465 return SendMsg(2263, 0, 0) != 0;
1466}
1467
1468// Sets the time the mouse must sit still to generate a mouse dwell event.
1469void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
1470 SendMsg(2264, periodMilliseconds, 0);
1471}
1472
1473// Retrieve the time the mouse must sit still to generate a mouse dwell event.
1474int wxStyledTextCtrl::GetMouseDwellTime() {
1475 return SendMsg(2265, 0, 0);
1476}
1477
1478// Get position of start of word.
1479int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
1480 return SendMsg(2266, pos, onlyWordCharacters);
1481}
1482
1483// Get position of end of word.
1484int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
1485 return SendMsg(2267, pos, onlyWordCharacters);
1486}
1487
1488// Sets whether text is word wrapped.
1489void wxStyledTextCtrl::SetWrapMode(int mode) {
1490 SendMsg(2268, mode, 0);
1491}
1492
1493// Retrieve whether text is word wrapped.
1494int wxStyledTextCtrl::GetWrapMode() {
1495 return SendMsg(2269, 0, 0);
1496}
1497
1498// Sets the degree of caching of layout information.
1499void wxStyledTextCtrl::SetLayoutCache(int mode) {
1500 SendMsg(2272, mode, 0);
1501}
1502
1503// Retrieve the degree of caching of layout information.
1504int wxStyledTextCtrl::GetLayoutCache() {
1505 return SendMsg(2273, 0, 0);
1506}
1507
1508// Sets the document width assumed for scrolling.
1509void wxStyledTextCtrl::SetScrollWidth(int pixelWidth) {
1510 SendMsg(2274, pixelWidth, 0);
1511}
1512
1513// Retrieve the document width assumed for scrolling.
1514int wxStyledTextCtrl::GetScrollWidth() {
1515 return SendMsg(2275, 0, 0);
1516}
1517
1518// Measure the pixel width of some text in a particular style.
1519// Nul terminated text argument.
1520// Does not handle tab or control characters.
1521int wxStyledTextCtrl::TextWidth(int style, const wxString& text) {
1522 return SendMsg(2276, style, (long)(const char*)wx2stc(text));
1523}
1524
1525// Sets the scroll range so that maximum scroll position has
1526// the last line at the bottom of the view (default).
1527// Setting this to false allows scrolling one page below the last line.
1528void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine) {
1529 SendMsg(2277, endAtLastLine, 0);
1530}
1531
1532// Retrieve whether the maximum scroll position has the last
1533// line at the bottom of the view.
1534int wxStyledTextCtrl::GetEndAtLastLine() {
1535 return SendMsg(2278, 0, 0);
1536}
1537
1538// Retrieve the height of a particular line of text in pixels.
1539int wxStyledTextCtrl::TextHeight(int line) {
1540 return SendMsg(2279, line, 0);
1541}
1542
1543// Show or hide the vertical scroll bar.
1544void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show) {
1545 SendMsg(2280, show, 0);
1546}
1547
1548// Is the vertical scroll bar visible?
1549bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1550 return SendMsg(2281, 0, 0) != 0;
1551}
1552
1553// Append a string to the end of the document without changing the selection.
1554void wxStyledTextCtrl::AppendText(int length, const wxString& text) {
1555 SendMsg(2282, length, (long)(const char*)wx2stc(text));
1556}
1557
1558// Is drawing done in two phases with backgrounds drawn before foregrounds?
1559bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1560 return SendMsg(2283, 0, 0) != 0;
1561}
1562
1563// In twoPhaseDraw mode, drawing is performed in two phases, first the background
1564// and then the foreground. This avoids chopping off characters that overlap the next run.
1565void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) {
1566 SendMsg(2284, twoPhase, 0);
1567}
1568
1569// Make the target range start and end be the same as the selection range start and end.
1570void wxStyledTextCtrl::TargetFromSelection() {
1571 SendMsg(2287, 0, 0);
1572}
1573
1574// Join the lines in the target.
1575void wxStyledTextCtrl::LinesJoin() {
1576 SendMsg(2288, 0, 0);
1577}
1578
1579// Split the lines in the target into lines that are less wide than pixelWidth
1580// where possible.
1581void wxStyledTextCtrl::LinesSplit(int pixelWidth) {
1582 SendMsg(2289, pixelWidth, 0);
1583}
1584
1585// Set the colours used as a chequerboard pattern in the fold margin
1586void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) {
1587 SendMsg(2290, useSetting, wxColourAsLong(back));
1588}
1589void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) {
1590 SendMsg(2291, useSetting, wxColourAsLong(fore));
1591}
1592
1593// Duplicate the current line.
1594void wxStyledTextCtrl::LineDuplicate() {
1595 SendMsg(2404, 0, 0);
1596}
1597
1598// Move caret to first position on display line.
1599void wxStyledTextCtrl::HomeDisplay() {
1600 SendMsg(2345, 0, 0);
1601}
1602
1603// Move caret to first position on display line extending selection to
1604// new caret position.
1605void wxStyledTextCtrl::HomeDisplayExtend() {
1606 SendMsg(2346, 0, 0);
1607}
1608
1609// Move caret to last position on display line.
1610void wxStyledTextCtrl::LineEndDisplay() {
1611 SendMsg(2347, 0, 0);
1612}
1613
1614// Move caret to last position on display line extending selection to new
1615// caret position.
1616void wxStyledTextCtrl::LineEndDisplayExtend() {
1617 SendMsg(2348, 0, 0);
1618}
1619
1620// Move the caret inside current view if it's not there already.
1621void wxStyledTextCtrl::MoveCaretInsideView() {
1622 SendMsg(2401, 0, 0);
1623}
1624
1625// How many characters are on a line, not including end of line characters?
1626int wxStyledTextCtrl::LineLength(int line) {
1627 return SendMsg(2350, line, 0);
1628}
1629
1630// Highlight the characters at two positions.
1631void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
1632 SendMsg(2351, pos1, pos2);
1633}
1634
1635// Highlight the character at a position indicating there is no matching brace.
1636void wxStyledTextCtrl::BraceBadLight(int pos) {
1637 SendMsg(2352, pos, 0);
1638}
1639
1640// Find the position of a matching brace or INVALID_POSITION if no match.
1641int wxStyledTextCtrl::BraceMatch(int pos) {
1642 return SendMsg(2353, pos, 0);
1643}
1644
1645// Are the end of line characters visible?
1646bool wxStyledTextCtrl::GetViewEOL() {
1647 return SendMsg(2355, 0, 0) != 0;
1648}
1649
1650// Make the end of line characters visible or invisible.
1651void wxStyledTextCtrl::SetViewEOL(bool visible) {
1652 SendMsg(2356, visible, 0);
1653}
1654
1655// Retrieve a pointer to the document object.
1656void* wxStyledTextCtrl::GetDocPointer() {
1657 return (void*)SendMsg(2357);
1658}
1659
1660// Change the document object used.
1661void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
1662 SendMsg(2358, 0, (long)docPointer);
1663}
1664
1665// Set which document modification events are sent to the container.
1666void wxStyledTextCtrl::SetModEventMask(int mask) {
1667 SendMsg(2359, mask, 0);
1668}
1669
1670// Retrieve the column number which text should be kept within.
1671int wxStyledTextCtrl::GetEdgeColumn() {
1672 return SendMsg(2360, 0, 0);
1673}
1674
1675// Set the column number of the edge.
1676// If text goes past the edge then it is highlighted.
1677void wxStyledTextCtrl::SetEdgeColumn(int column) {
1678 SendMsg(2361, column, 0);
1679}
1680
1681// Retrieve the edge highlight mode.
1682int wxStyledTextCtrl::GetEdgeMode() {
1683 return SendMsg(2362, 0, 0);
1684}
1685
1686// The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1687// goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1688void wxStyledTextCtrl::SetEdgeMode(int mode) {
1689 SendMsg(2363, mode, 0);
1690}
1691
1692// Retrieve the colour used in edge indication.
1693wxColour wxStyledTextCtrl::GetEdgeColour() {
1694 long c = SendMsg(2364, 0, 0);
1695 return wxColourFromLong(c);
1696}
1697
1698// Change the colour used in edge indication.
1699void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
1700 SendMsg(2365, wxColourAsLong(edgeColour), 0);
1701}
1702
1703// Sets the current caret position to be the search anchor.
1704void wxStyledTextCtrl::SearchAnchor() {
1705 SendMsg(2366, 0, 0);
1706}
1707
1708// Find some text starting at the search anchor.
1709// Does not ensure the selection is visible.
1710int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
1711 return SendMsg(2367, flags, (long)(const char*)wx2stc(text));
1712}
1713
1714// Find some text starting at the search anchor and moving backwards.
1715// Does not ensure the selection is visible.
1716int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
1717 return SendMsg(2368, flags, (long)(const char*)wx2stc(text));
1718}
1719
1720// Retrieves the number of lines completely visible.
1721int wxStyledTextCtrl::LinesOnScreen() {
1722 return SendMsg(2370, 0, 0);
1723}
1724
1725// Set whether a pop up menu is displayed automatically when the user presses
1726// the wrong mouse button.
1727void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
1728 SendMsg(2371, allowPopUp, 0);
1729}
1730
1731// Is the selection rectangular? The alternative is the more common stream selection.
1732bool wxStyledTextCtrl::SelectionIsRectangle() {
1733 return SendMsg(2372, 0, 0) != 0;
1734}
1735
1736// Set the zoom level. This number of points is added to the size of all fonts.
1737// It may be positive to magnify or negative to reduce.
1738void wxStyledTextCtrl::SetZoom(int zoom) {
1739 SendMsg(2373, zoom, 0);
1740}
1741
1742// Retrieve the zoom level.
1743int wxStyledTextCtrl::GetZoom() {
1744 return SendMsg(2374, 0, 0);
1745}
1746
1747// Create a new document object.
1748// Starts with reference count of 1 and not selected into editor.
1749void* wxStyledTextCtrl::CreateDocument() {
1750 return (void*)SendMsg(2375);
1751}
1752
1753// Extend life of document.
1754void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
1755 SendMsg(2376, 0, (long)docPointer);
1756}
1757
1758// Release a reference to the document, deleting document if it fades to black.
1759void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
1760 SendMsg(2377, 0, (long)docPointer);
1761}
1762
1763// Get which document modification events are sent to the container.
1764int wxStyledTextCtrl::GetModEventMask() {
1765 return SendMsg(2378, 0, 0);
1766}
1767
1768// Change internal focus flag.
1769void wxStyledTextCtrl::SetSTCFocus(bool focus) {
1770 SendMsg(2380, focus, 0);
1771}
1772
1773// Get internal focus flag.
1774bool wxStyledTextCtrl::GetSTCFocus() {
1775 return SendMsg(2381, 0, 0) != 0;
1776}
1777
1778// Change error status - 0 = OK.
1779void wxStyledTextCtrl::SetStatus(int statusCode) {
1780 SendMsg(2382, statusCode, 0);
1781}
1782
1783// Get error status.
1784int wxStyledTextCtrl::GetStatus() {
1785 return SendMsg(2383, 0, 0);
1786}
1787
1788// Set whether the mouse is captured when its button is pressed.
1789void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
1790 SendMsg(2384, captures, 0);
1791}
1792
1793// Get whether mouse gets captured.
1794bool wxStyledTextCtrl::GetMouseDownCaptures() {
1795 return SendMsg(2385, 0, 0) != 0;
1796}
1797
1798// Sets the cursor to one of the SC_CURSOR* values.
1799void wxStyledTextCtrl::SetCursor(int cursorType) {
1800 SendMsg(2386, cursorType, 0);
1801}
1802
1803// Get cursor type.
1804int wxStyledTextCtrl::GetCursor() {
1805 return SendMsg(2387, 0, 0);
1806}
1807
1808// Change the way control characters are displayed:
1809// If symbol is < 32, keep the drawn way, else, use the given character.
1810void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
1811 SendMsg(2388, symbol, 0);
1812}
1813
1814// Get the way control characters are displayed.
1815int wxStyledTextCtrl::GetControlCharSymbol() {
1816 return SendMsg(2389, 0, 0);
1817}
1818
1819// Move to the previous change in capitalisation.
1820void wxStyledTextCtrl::WordPartLeft() {
1821 SendMsg(2390, 0, 0);
1822}
1823
1824// Move to the previous change in capitalisation extending selection
1825// to new caret position.
1826void wxStyledTextCtrl::WordPartLeftExtend() {
1827 SendMsg(2391, 0, 0);
1828}
1829
1830// Move to the change next in capitalisation.
1831void wxStyledTextCtrl::WordPartRight() {
1832 SendMsg(2392, 0, 0);
1833}
1834
1835// Move to the next change in capitalisation extending selection
1836// to new caret position.
1837void wxStyledTextCtrl::WordPartRightExtend() {
1838 SendMsg(2393, 0, 0);
1839}
1840
1841// Set the way the display area is determined when a particular line
1842// is to be moved to by Find, FindNext, GotoLine, etc.
1843void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
1844 SendMsg(2394, visiblePolicy, visibleSlop);
1845}
1846
1847// Delete back from the current position to the start of the line.
1848void wxStyledTextCtrl::DelLineLeft() {
1849 SendMsg(2395, 0, 0);
1850}
1851
1852// Delete forwards from the current position to the end of the line.
1853void wxStyledTextCtrl::DelLineRight() {
1854 SendMsg(2396, 0, 0);
1855}
1856
1857// Get and Set the xOffset (ie, horizonal scroll position).
1858void wxStyledTextCtrl::SetXOffset(int newOffset) {
1859 SendMsg(2397, newOffset, 0);
1860}
1861int wxStyledTextCtrl::GetXOffset() {
1862 return SendMsg(2398, 0, 0);
1863}
1864
1865// Set the last x chosen value to be the caret x position
1866void wxStyledTextCtrl::ChooseCaretX() {
1867 SendMsg(2399, 0, 0);
1868}
1869
1870// Set the way the caret is kept visible when going sideway.
1871// The exclusion zone is given in pixels.
1872void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) {
1873 SendMsg(2402, caretPolicy, caretSlop);
1874}
1875
1876// Set the way the line the caret is on is kept visible.
1877// The exclusion zone is given in lines.
1878void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) {
1879 SendMsg(2403, caretPolicy, caretSlop);
1880}
1881
1882// Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
1883void wxStyledTextCtrl::SetPrintWrapMode(int mode) {
1884 SendMsg(2406, mode, 0);
1885}
1886
1887// Is printing line wrapped.
1888int wxStyledTextCtrl::GetPrintWrapMode() {
1889 return SendMsg(2407, 0, 0);
1890}
1891
1892// Set a fore colour for active hotspots.
1893void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) {
1894 SendMsg(2410, useSetting, wxColourAsLong(fore));
1895}
1896
1897// Set a back colour for active hotspots.
1898void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) {
1899 SendMsg(2411, useSetting, wxColourAsLong(back));
1900}
1901
1902// Enable / Disable underlining active hotspots.
1903void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) {
1904 SendMsg(2412, underline, 0);
1905}
1906
1907// Start notifying the container of all key presses and commands.
1908void wxStyledTextCtrl::StartRecord() {
1909 SendMsg(3001, 0, 0);
1910}
1911
1912// Stop notifying the container of all key presses and commands.
1913void wxStyledTextCtrl::StopRecord() {
1914 SendMsg(3002, 0, 0);
1915}
1916
1917// Set the lexing language of the document.
1918void wxStyledTextCtrl::SetLexer(int lexer) {
1919 SendMsg(4001, lexer, 0);
1920}
1921
1922// Retrieve the lexing language of the document.
1923int wxStyledTextCtrl::GetLexer() {
1924 return SendMsg(4002, 0, 0);
1925}
1926
1927// Colourise a segment of the document using the current lexing language.
1928void wxStyledTextCtrl::Colourise(int start, int end) {
1929 SendMsg(4003, start, end);
1930}
1931
1932// Set up a value that may be used by a lexer for some optional feature.
1933void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
1934 SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value));
1935}
1936
1937// Set up the key words used by the lexer.
1938void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
1939 SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords));
1940}
1941
1942// Set the lexing language of the document based on string name.
1943void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
1944 SendMsg(4006, 0, (long)(const char*)wx2stc(language));
1945}
1946
1947// END of generated section
1948//----------------------------------------------------------------------
1949
1950
1951// Returns the line number of the line with the caret.
1952int wxStyledTextCtrl::GetCurrentLine() {
1953 int line = LineFromPosition(GetCurrentPos());
1954 return line;
1955}
1956
1957
1958// Extract style settings from a spec-string which is composed of one or
1959// more of the following comma separated elements:
1960//
1961// bold turns on bold
1962// italic turns on italics
1963// fore:#RRGGBB sets the foreground colour
1964// back:#RRGGBB sets the background colour
1965// face:[facename] sets the font face name to use
1966// size:[num] sets the font size in points
1967// eol turns on eol filling
1968// underline turns on underlining
1969//
1970void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
1971
1972 wxStringTokenizer tkz(spec, wxT(","));
1973 while (tkz.HasMoreTokens()) {
1974 wxString token = tkz.GetNextToken();
1975
1976 wxString option = token.BeforeFirst(':');
1977 wxString val = token.AfterFirst(':');
1978
1979 if (option == wxT("bold"))
1980 StyleSetBold(styleNum, true);
1981
1982 else if (option == wxT("italic"))
1983 StyleSetItalic(styleNum, true);
1984
1985 else if (option == wxT("underline"))
1986 StyleSetUnderline(styleNum, true);
1987
1988 else if (option == wxT("eol"))
1989 StyleSetEOLFilled(styleNum, true);
1990
1991 else if (option == wxT("size")) {
1992 long points;
1993 if (val.ToLong(&points))
1994 StyleSetSize(styleNum, points);
1995 }
1996
1997 else if (option == wxT("face"))
1998 StyleSetFaceName(styleNum, val);
1999
2000 else if (option == wxT("fore"))
2001 StyleSetForeground(styleNum, wxColourFromSpec(val));
2002
2003 else if (option == wxT("back"))
2004 StyleSetBackground(styleNum, wxColourFromSpec(val));
2005 }
2006}
2007
2008
2009// Set style size, face, bold, italic, and underline attributes from
2010// a wxFont's attributes.
2011void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
2012 int size = font.GetPointSize();
2013 wxString faceName = font.GetFaceName();
2014 bool bold = font.GetWeight() == wxBOLD;
2015 bool italic = font.GetStyle() != wxNORMAL;
2016 bool under = font.GetUnderlined();
2017
2018 // TODO: add encoding/charset mapping
2019 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
2020}
2021
2022// Set all font style attributes at once.
2023void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
2024 const wxString& faceName,
2025 bool bold, bool italic,
2026 bool underline) {
2027 StyleSetSize(styleNum, size);
2028 StyleSetFaceName(styleNum, faceName);
2029 StyleSetBold(styleNum, bold);
2030 StyleSetItalic(styleNum, italic);
2031 StyleSetUnderline(styleNum, underline);
2032
2033 // TODO: add encoding/charset mapping
2034}
2035
2036
2037// Perform one of the operations defined by the wxSTC_CMD_* constants.
2038void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
2039 SendMsg(cmd);
2040}
2041
2042
2043// Set the left and right margin in the edit area, measured in pixels.
2044void wxStyledTextCtrl::SetMargins(int left, int right) {
2045 SetMarginLeft(left);
2046 SetMarginRight(right);
2047}
2048
2049
2050// Retrieve the start and end positions of the current selection.
2051void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
2052 if (startPos != NULL)
2053 *startPos = SendMsg(SCI_GETSELECTIONSTART);
2054 if (endPos != NULL)
2055 *endPos = SendMsg(SCI_GETSELECTIONEND);
2056}
2057
2058
2059// Retrieve the point in the window where a position is displayed.
2060wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
2061 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
2062 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
2063 return wxPoint(x, y);
2064}
2065
2066// Scroll enough to make the given line visible
2067void wxStyledTextCtrl::ScrollToLine(int line) {
2068 m_swx->DoScrollToLine(line);
2069}
2070
2071
2072// Scroll enough to make the given column visible
2073void wxStyledTextCtrl::ScrollToColumn(int column) {
2074 m_swx->DoScrollToColumn(column);
2075}
2076
2077
2078
2079//----------------------------------------------------------------------
2080// Event handlers
2081
2082void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
2083 wxPaintDC dc(this);
2084 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
2085}
2086
2087void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
2088 if (evt.GetOrientation() == wxHORIZONTAL)
2089 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
2090 else
2091 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
2092}
2093
2094void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
2095 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
2096 if (sb) {
2097 if (sb->IsVertical())
2098 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
2099 else
2100 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
2101 }
2102}
2103
2104void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
2105 wxSize sz = GetClientSize();
2106 m_swx->DoSize(sz.x, sz.y);
2107}
2108
2109void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
2110 SetFocus();
2111 wxPoint pt = evt.GetPosition();
2112 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
2113 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
2114}
2115
2116void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
2117 wxPoint pt = evt.GetPosition();
2118 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
2119}
2120
2121void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
2122 wxPoint pt = evt.GetPosition();
2123 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
2124 evt.ControlDown());
2125}
2126
2127
2128void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
2129 wxPoint pt = evt.GetPosition();
2130 m_swx->DoContextMenu(Point(pt.x, pt.y));
2131}
2132
2133
2134void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
2135 wxPoint pt = evt.GetPosition();
2136 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
2137}
2138
2139void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
2140 wxPoint pt = evt.GetPosition();
2141 ScreenToClient(&pt.x, &pt.y);
2142 m_swx->DoContextMenu(Point(pt.x, pt.y));
2143}
2144
2145
2146void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
2147 m_swx->DoMouseWheel(evt.GetWheelRotation(),
2148 evt.GetWheelDelta(),
2149 evt.GetLinesPerAction(),
2150 evt.ControlDown(),
2151 evt.IsPageScroll());
2152}
2153
2154
2155void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
2156 // On (some?) non-US keyboards the AltGr key is required to enter some
2157 // common characters. It comes to us as both Alt and Ctrl down so we need
2158 // to let the char through in that case, otherwise if only ctrl or only
2159 // alt let's skip it.
2160 bool ctrl = evt.ControlDown();
2161 bool alt = evt.AltDown();
2162 bool skip = ((ctrl || alt) && ! (ctrl && alt));
2163
2164 int key = evt.GetKeyCode();
2165
2166// printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
2167// key, m_lastKeyDownConsumed, ctrl, alt, skip);
2168
2169 if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) &&
2170 !m_lastKeyDownConsumed && !skip) {
2171 m_swx->DoAddChar(key);
2172 return;
2173 }
2174 evt.Skip();
2175}
2176
2177
2178void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
2179 int key = evt.GetKeyCode();
2180 bool shift = evt.ShiftDown(),
2181 ctrl = evt.ControlDown(),
2182 alt = evt.AltDown();
2183
2184 int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, &m_lastKeyDownConsumed);
2185
2186// printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
2187// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
2188
2189 if (!processed && !m_lastKeyDownConsumed)
2190 evt.Skip();
2191}
2192
2193
2194void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
2195 m_swx->DoLoseFocus();
2196}
2197
2198
2199void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
2200 m_swx->DoGainFocus();
2201}
2202
2203
2204void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
2205 m_swx->DoSysColourChange();
2206}
2207
2208
2209void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
2210 // do nothing to help avoid flashing
2211}
2212
2213
2214
2215void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
2216 m_swx->DoCommand(evt.GetId());
2217}
2218
2219
2220void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
2221 m_swx->DoOnListBox();
2222}
2223
2224
2225//----------------------------------------------------------------------
2226// Turn notifications from Scintilla into events
2227
2228
2229void wxStyledTextCtrl::NotifyChange() {
2230 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
2231 evt.SetEventObject(this);
2232 GetEventHandler()->ProcessEvent(evt);
2233}
2234
2235
2236static void SetEventText(wxStyledTextEvent& evt, const char* text,
2237 size_t length) {
2238 if(!text) return;
2239
2240 // The unicode conversion MUST have a null byte to terminate the
2241 // string so move it into a buffer first and give it one.
2242 wxMemoryBuffer buf(length+1);
2243 buf.AppendData((void*)text, length);
2244 buf.AppendByte(0);
2245 evt.SetText(stc2wx(buf));
2246}
2247
2248
2249void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
2250 SCNotification& scn = *_scn;
2251 wxStyledTextEvent evt(0, GetId());
2252
2253 evt.SetEventObject(this);
2254 evt.SetPosition(scn.position);
2255 evt.SetKey(scn.ch);
2256 evt.SetModifiers(scn.modifiers);
2257
2258 switch (scn.nmhdr.code) {
2259 case SCN_STYLENEEDED:
2260 evt.SetEventType(wxEVT_STC_STYLENEEDED);
2261 break;
2262
2263 case SCN_CHARADDED:
2264 evt.SetEventType(wxEVT_STC_CHARADDED);
2265 break;
2266
2267 case SCN_SAVEPOINTREACHED:
2268 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
2269 break;
2270
2271 case SCN_SAVEPOINTLEFT:
2272 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
2273 break;
2274
2275 case SCN_MODIFYATTEMPTRO:
2276 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
2277 break;
2278
2279 case SCN_KEY:
2280 evt.SetEventType(wxEVT_STC_KEY);
2281 break;
2282
2283 case SCN_DOUBLECLICK:
2284 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
2285 break;
2286
2287 case SCN_UPDATEUI:
2288 evt.SetEventType(wxEVT_STC_UPDATEUI);
2289 break;
2290
2291 case SCN_MODIFIED:
2292 evt.SetEventType(wxEVT_STC_MODIFIED);
2293 evt.SetModificationType(scn.modificationType);
2294 SetEventText(evt, scn.text, scn.length);
2295 evt.SetLength(scn.length);
2296 evt.SetLinesAdded(scn.linesAdded);
2297 evt.SetLine(scn.line);
2298 evt.SetFoldLevelNow(scn.foldLevelNow);
2299 evt.SetFoldLevelPrev(scn.foldLevelPrev);
2300 break;
2301
2302 case SCN_MACRORECORD:
2303 evt.SetEventType(wxEVT_STC_MACRORECORD);
2304 evt.SetMessage(scn.message);
2305 evt.SetWParam(scn.wParam);
2306 evt.SetLParam(scn.lParam);
2307 break;
2308
2309 case SCN_MARGINCLICK:
2310 evt.SetEventType(wxEVT_STC_MARGINCLICK);
2311 evt.SetMargin(scn.margin);
2312 break;
2313
2314 case SCN_NEEDSHOWN:
2315 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
2316 evt.SetLength(scn.length);
2317 break;
2318
2319 case SCN_PAINTED:
2320 evt.SetEventType(wxEVT_STC_PAINTED);
2321 break;
2322
2323 case SCN_USERLISTSELECTION:
2324 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
2325 evt.SetListType(scn.listType);
2326 SetEventText(evt, scn.text, strlen(scn.text));
2327 break;
2328
2329 case SCN_URIDROPPED:
2330 evt.SetEventType(wxEVT_STC_URIDROPPED);
2331 SetEventText(evt, scn.text, strlen(scn.text));
2332 break;
2333
2334 case SCN_DWELLSTART:
2335 evt.SetEventType(wxEVT_STC_DWELLSTART);
2336 evt.SetX(scn.x);
2337 evt.SetY(scn.y);
2338 break;
2339
2340 case SCN_DWELLEND:
2341 evt.SetEventType(wxEVT_STC_DWELLEND);
2342 evt.SetX(scn.x);
2343 evt.SetY(scn.y);
2344 break;
2345
2346 case SCN_ZOOM:
2347 evt.SetEventType(wxEVT_STC_ZOOM);
2348 break;
2349
2350 case SCN_HOTSPOTCLICK:
2351 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
2352 break;
2353
2354 case SCN_HOTSPOTDOUBLECLICK:
2355 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
2356 break;
2357
2358 case SCN_CALLTIPCLICK:
2359 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
2360 break;
2361
2362 default:
2363 return;
2364 }
2365
2366 GetEventHandler()->ProcessEvent(evt);
2367}
2368
2369
2370//----------------------------------------------------------------------
2371//----------------------------------------------------------------------
2372//----------------------------------------------------------------------
2373
2374wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
2375 : wxCommandEvent(commandType, id)
2376{
2377 m_position = 0;
2378 m_key = 0;
2379 m_modifiers = 0;
2380 m_modificationType = 0;
2381 m_length = 0;
2382 m_linesAdded = 0;
2383 m_line = 0;
2384 m_foldLevelNow = 0;
2385 m_foldLevelPrev = 0;
2386 m_margin = 0;
2387 m_message = 0;
2388 m_wParam = 0;
2389 m_lParam = 0;
2390 m_listType = 0;
2391 m_x = 0;
2392 m_y = 0;
2393 m_dragAllowMove = FALSE;
2394#if wxUSE_DRAG_AND_DROP
2395 m_dragResult = wxDragNone;
2396#endif
2397}
2398
2399bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
2400bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
2401bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
2402
2403
2404wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
2405 wxCommandEvent(event)
2406{
2407 m_position = event.m_position;
2408 m_key = event.m_key;
2409 m_modifiers = event.m_modifiers;
2410 m_modificationType = event.m_modificationType;
2411 m_text = event.m_text;
2412 m_length = event.m_length;
2413 m_linesAdded = event.m_linesAdded;
2414 m_line = event.m_line;
2415 m_foldLevelNow = event.m_foldLevelNow;
2416 m_foldLevelPrev = event.m_foldLevelPrev;
2417
2418 m_margin = event.m_margin;
2419
2420 m_message = event.m_message;
2421 m_wParam = event.m_wParam;
2422 m_lParam = event.m_lParam;
2423
2424 m_listType = event.m_listType;
2425 m_x = event.m_x;
2426 m_y = event.m_y;
2427
2428 m_dragText = event.m_dragText;
2429 m_dragAllowMove =event.m_dragAllowMove;
2430#if wxUSE_DRAG_AND_DROP
2431 m_dragResult = event.m_dragResult;
2432#endif
2433}
2434
2435//----------------------------------------------------------------------
2436//----------------------------------------------------------------------
2437
2438
2439
2440
2441
2442
2443
2444
2445