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