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