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