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