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