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