]> git.saurik.com Git - wxWidgets.git/blame - src/stc/stc.cpp
Put back wxMSW's wxStaticBitmap::DoGetBestSize because GetBitmap (used
[wxWidgets.git] / src / stc / stc.cpp
CommitLineData
9ce192d4
RD
1////////////////////////////////////////////////////////////////////////////
2// Name: stc.cpp
3// Purpose: A wxWindows implementation of Scintilla. This class is the
4// one meant to be used directly by wx applications. It does not
5// derive directly from the Scintilla classes, but instead
6// delegates most things to the real Scintilla class.
7// This allows the use of Scintilla without polluting the
f6bcfd97 8// namespace with all the classes and identifiers from Scintilla.
9ce192d4
RD
9//
10// Author: Robin Dunn
11//
12// Created: 13-Jan-2000
13// RCS-ID: $Id$
14// Copyright: (c) 2000 by Total Control Software
15// Licence: wxWindows license
16/////////////////////////////////////////////////////////////////////////////
17
f6bcfd97
BP
18#include <ctype.h>
19
9ce192d4
RD
20#include "wx/stc/stc.h"
21#include "ScintillaWX.h"
22
9e730a78 23#include <wx/wx.h>
9ce192d4 24#include <wx/tokenzr.h>
9e730a78
RD
25#include <wx/mstream.h>
26#include <wx/image.h>
51566b0b 27#include <wx/file.h>
9ce192d4 28
f6bcfd97 29
9ce192d4
RD
30//----------------------------------------------------------------------
31
10ef30eb 32const wxChar* wxSTCNameStr = wxT("stcwindow");
9ce192d4 33
451c5cc7
RD
34#ifdef MAKELONG
35#undef MAKELONG
36#endif
37
38#define MAKELONG(a, b) ((a) | ((b) << 16))
39
40
41static long wxColourAsLong(const wxColour& co) {
42 return (((long)co.Blue() << 16) |
43 ((long)co.Green() << 8) |
44 ((long)co.Red()));
45}
46
47static wxColour wxColourFromLong(long c) {
48 wxColour clr;
49 clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
50 return clr;
51}
52
53
54static wxColour wxColourFromSpec(const wxString& spec) {
55 // spec should be "#RRGGBB"
56 long red, green, blue;
57 red = green = blue = 0;
58 spec.Mid(1,2).ToLong(&red, 16);
59 spec.Mid(3,2).ToLong(&green, 16);
60 spec.Mid(5,2).ToLong(&blue, 16);
61 return wxColour(red, green, blue);
62}
63
64//----------------------------------------------------------------------
65
d25f5fbb
RD
66DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
67DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
68DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
d25f5fbb
RD
69DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
70DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
71DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
65ec6247 72DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
d25f5fbb 73DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
65ec6247 74DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
d25f5fbb 75DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
d25f5fbb
RD
76DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
77DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
78DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
79DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
65ec6247
RD
80DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
81DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
82DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
83DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
84DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
a29a241f
RD
85DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
86DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
87DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
a834585d 88DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM )
9e730a78
RD
89DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
90DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
91DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
92
d25f5fbb
RD
93
94
9ce192d4
RD
95BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
96 EVT_PAINT (wxStyledTextCtrl::OnPaint)
97 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
5fa4613c 98 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
9ce192d4
RD
99 EVT_SIZE (wxStyledTextCtrl::OnSize)
100 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
4ceb1196
RD
101 // Let Scintilla see the double click as a second click
102 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
9ce192d4
RD
103 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
104 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
451c5cc7 105#if defined(__WXGTK__) || defined(__WXMAC__)
ddf2da08
RD
106 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
107#else
65ec6247 108 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
ddf2da08 109#endif
37d62433 110 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
2b5f62a0 111 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
9ce192d4 112 EVT_CHAR (wxStyledTextCtrl::OnChar)
f6bcfd97 113 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
9ce192d4
RD
114 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
115 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
116 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
117 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
dd4aa550 118 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
f6bcfd97 119 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
9ce192d4
RD
120END_EVENT_TABLE()
121
f6bcfd97
BP
122
123IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
124IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
125
40716a51 126#ifdef LINK_LEXERS
1a2fb4cd 127// forces the linking of the lexer modules
a834585d 128int Scintilla_LinkLexers();
40716a51 129#endif
1a2fb4cd 130
9ce192d4
RD
131//----------------------------------------------------------------------
132// Constructor and Destructor
133
134wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
135 wxWindowID id,
136 const wxPoint& pos,
137 const wxSize& size,
138 long style,
39c0acb6
RD
139 const wxString& name)
140{
141 m_swx = NULL;
142 Create(parent, id, pos, size, style, name);
143}
144
145
146void wxStyledTextCtrl::Create(wxWindow *parent,
147 wxWindowID id,
148 const wxPoint& pos,
149 const wxSize& size,
150 long style,
151 const wxString& name)
9ce192d4 152{
2659dad3
RD
153#ifdef __WXMAC__
154 style |= wxVSCROLL | wxHSCROLL;
155#endif
39c0acb6 156 wxControl::Create(parent, id, pos, size,
8e54aaed 157 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
39c0acb6
RD
158 wxDefaultValidator, name);
159
40716a51 160#ifdef LINK_LEXERS
a834585d 161 Scintilla_LinkLexers();
40716a51 162#endif
9ce192d4 163 m_swx = new ScintillaWX(this);
9ce192d4 164 m_stopWatch.Start();
d6582821 165 m_lastKeyDownConsumed = FALSE;
5fa4613c
RD
166 m_vScrollBar = NULL;
167 m_hScrollBar = NULL;
10ef30eb
RD
168#if wxUSE_UNICODE
169 // Put Scintilla into unicode (UTF-8) mode
170 SetCodePage(wxSTC_CP_UTF8);
171#endif
9ce192d4
RD
172}
173
174
175wxStyledTextCtrl::~wxStyledTextCtrl() {
176 delete m_swx;
9ce192d4
RD
177}
178
179
180//----------------------------------------------------------------------
181
f6bcfd97 182long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
9ce192d4
RD
183
184 return m_swx->WndProc(msg, wp, lp);
185}
186
187
9ce192d4 188
4370573a
RD
189//----------------------------------------------------------------------
190// BEGIN generated section. The following code is automatically generated
191// by gen_iface.py from the contents of Scintilla.iface. Do not edit
192// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
9ce192d4
RD
193
194
a834585d 195// Add text to the document.
9ce192d4 196void wxStyledTextCtrl::AddText(const wxString& text) {
0c5b83b0 197 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
10ef30eb 198 SendMsg(2001, strlen(buf), (long)(const char*)buf);
9ce192d4
RD
199}
200
a834585d 201// Add array of cells to document.
10ef30eb
RD
202void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
203 SendMsg(2002, data.GetDataLen(), (long)data.GetData());
9ce192d4
RD
204}
205
a834585d 206// Insert string at a position.
9ce192d4 207void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
0c5b83b0 208 SendMsg(2003, pos, (long)(const char*)wx2stc(text));
9ce192d4
RD
209}
210
a834585d 211// Delete all text in the document.
9ce192d4 212void wxStyledTextCtrl::ClearAll() {
4370573a 213 SendMsg(2004, 0, 0);
9ce192d4
RD
214}
215
a834585d 216// Set all style bytes to 0, remove all folding information.
4370573a
RD
217void wxStyledTextCtrl::ClearDocumentStyle() {
218 SendMsg(2005, 0, 0);
9ce192d4
RD
219}
220
a834585d 221// The number of characters in the document.
4370573a
RD
222int wxStyledTextCtrl::GetLength() {
223 return SendMsg(2006, 0, 0);
9ce192d4
RD
224}
225
a834585d 226// Returns the character byte at the position.
4370573a 227int wxStyledTextCtrl::GetCharAt(int pos) {
9e730a78 228 return (unsigned char)SendMsg(2007, pos, 0);
9ce192d4
RD
229}
230
a834585d 231// Returns the position of the caret.
4370573a
RD
232int wxStyledTextCtrl::GetCurrentPos() {
233 return SendMsg(2008, 0, 0);
9ce192d4
RD
234}
235
a834585d 236// Returns the position of the opposite end of the selection to the caret.
4370573a
RD
237int wxStyledTextCtrl::GetAnchor() {
238 return SendMsg(2009, 0, 0);
9ce192d4
RD
239}
240
a834585d 241// Returns the style byte at the position.
4370573a 242int wxStyledTextCtrl::GetStyleAt(int pos) {
9e730a78 243 return (unsigned char)SendMsg(2010, pos, 0);
9ce192d4
RD
244}
245
a834585d 246// Redoes the next action on the undo history.
9ce192d4 247void wxStyledTextCtrl::Redo() {
4370573a 248 SendMsg(2011, 0, 0);
9ce192d4
RD
249}
250
4370573a
RD
251// Choose between collecting actions into the undo
252// history and discarding them.
253void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
254 SendMsg(2012, collectUndo, 0);
9ce192d4
RD
255}
256
4370573a
RD
257// Select all the text in the document.
258void wxStyledTextCtrl::SelectAll() {
259 SendMsg(2013, 0, 0);
9ce192d4
RD
260}
261
4370573a
RD
262// Remember the current position in the undo history as the position
263// at which the document was saved.
264void wxStyledTextCtrl::SetSavePoint() {
265 SendMsg(2014, 0, 0);
9ce192d4
RD
266}
267
4370573a 268// Retrieve a buffer of cells.
10ef30eb 269wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
9e730a78
RD
270 wxMemoryBuffer buf;
271 if (endPos < startPos) {
272 int temp = startPos;
273 startPos = endPos;
274 endPos = temp;
275 }
276 int len = endPos - startPos;
277 if (!len) return buf;
278 TextRange tr;
279 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
280 tr.chrg.cpMin = startPos;
281 tr.chrg.cpMax = endPos;
282 len = SendMsg(2015, 0, (long)&tr);
283 buf.UngetWriteBuf(len);
284 return buf;
9ce192d4
RD
285}
286
a834585d 287// Are there any redoable actions in the undo history?
4370573a
RD
288bool wxStyledTextCtrl::CanRedo() {
289 return SendMsg(2016, 0, 0) != 0;
9ce192d4
RD
290}
291
a834585d 292// Retrieve the line number at which a particular marker is located.
4370573a
RD
293int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
294 return SendMsg(2017, handle, 0);
9ce192d4
RD
295}
296
4370573a
RD
297// Delete a marker.
298void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
299 SendMsg(2018, handle, 0);
9ce192d4
RD
300}
301
4370573a
RD
302// Is undo history being collected?
303bool wxStyledTextCtrl::GetUndoCollection() {
304 return SendMsg(2019, 0, 0) != 0;
9ce192d4
RD
305}
306
4370573a
RD
307// Are white space characters currently visible?
308// Returns one of SCWS_* constants.
309int wxStyledTextCtrl::GetViewWhiteSpace() {
310 return SendMsg(2020, 0, 0);
9ce192d4
RD
311}
312
4370573a
RD
313// Make white space characters invisible, always visible or visible outside indentation.
314void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
315 SendMsg(2021, viewWS, 0);
9ce192d4
RD
316}
317
4370573a 318// Find the position from a point within the window.
9ce192d4 319int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
9e730a78 320 return SendMsg(2022, pt.x, pt.y);
9ce192d4
RD
321}
322
65ec6247
RD
323// Find the position from a point within the window but return
324// INVALID_POSITION if not close to text.
325int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
326 return SendMsg(2023, x, y);
327}
328
4370573a
RD
329// Set caret to start of a line and ensure it is visible.
330void wxStyledTextCtrl::GotoLine(int line) {
331 SendMsg(2024, line, 0);
9ce192d4
RD
332}
333
4370573a 334// Set caret to a position and ensure it is visible.
9ce192d4 335void wxStyledTextCtrl::GotoPos(int pos) {
4370573a 336 SendMsg(2025, pos, 0);
9ce192d4
RD
337}
338
4370573a
RD
339// Set the selection anchor to a position. The anchor is the opposite
340// end of the selection from the caret.
341void wxStyledTextCtrl::SetAnchor(int posAnchor) {
342 SendMsg(2026, posAnchor, 0);
9ce192d4
RD
343}
344
4370573a
RD
345// Retrieve the text of the line containing the caret.
346// Returns the index of the caret on the line.
347wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
9e730a78
RD
348 int len = LineLength(GetCurrentLine());
349 if (!len) {
350 if (linePos) *linePos = 0;
351 return wxEmptyString;
352 }
10ef30eb 353
9e730a78
RD
354 wxMemoryBuffer mbuf(len+1);
355 char* buf = (char*)mbuf.GetWriteBuf(len+1);
8de28db9 356
9e730a78
RD
357 int pos = SendMsg(2027, len+1, (long)buf);
358 mbuf.UngetWriteBuf(len);
359 mbuf.AppendByte(0);
360 if (linePos) *linePos = pos;
361 return stc2wx(buf);
9ce192d4
RD
362}
363
4370573a
RD
364// Retrieve the position of the last correctly styled character.
365int wxStyledTextCtrl::GetEndStyled() {
366 return SendMsg(2028, 0, 0);
9ce192d4
RD
367}
368
65ec6247
RD
369// Convert all line endings in the document to one mode.
370void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
371 SendMsg(2029, eolMode, 0);
9ce192d4
RD
372}
373
4370573a
RD
374// Retrieve the current end of line mode - one of CRLF, CR, or LF.
375int wxStyledTextCtrl::GetEOLMode() {
376 return SendMsg(2030, 0, 0);
9ce192d4
RD
377}
378
4370573a
RD
379// Set the current end of line mode.
380void wxStyledTextCtrl::SetEOLMode(int eolMode) {
381 SendMsg(2031, eolMode, 0);
9ce192d4
RD
382}
383
4370573a 384// Set the current styling position to pos and the styling mask to mask.
a834585d 385// The styling mask can be used to protect some bits in each styling byte from modification.
4370573a
RD
386void wxStyledTextCtrl::StartStyling(int pos, int mask) {
387 SendMsg(2032, pos, mask);
9ce192d4
RD
388}
389
4370573a
RD
390// Change style from current styling position for length characters to a style
391// and move the current styling position to after this newly styled segment.
392void wxStyledTextCtrl::SetStyling(int length, int style) {
393 SendMsg(2033, length, style);
f6bcfd97
BP
394}
395
a834585d 396// Is drawing done first into a buffer or direct to the screen?
4370573a
RD
397bool wxStyledTextCtrl::GetBufferedDraw() {
398 return SendMsg(2034, 0, 0) != 0;
f6bcfd97
BP
399}
400
4370573a
RD
401// If drawing is buffered then each line of text is drawn into a bitmap buffer
402// before drawing it to the screen to avoid flicker.
403void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
404 SendMsg(2035, buffered, 0);
f6bcfd97
BP
405}
406
a834585d 407// Change the visible size of a tab to be a multiple of the width of a space character.
4370573a
RD
408void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
409 SendMsg(2036, tabWidth, 0);
f6bcfd97
BP
410}
411
4370573a
RD
412// Retrieve the visible size of a tab.
413int wxStyledTextCtrl::GetTabWidth() {
414 return SendMsg(2121, 0, 0);
9ce192d4
RD
415}
416
4370573a 417// Set the code page used to interpret the bytes of the document as characters.
4370573a 418void wxStyledTextCtrl::SetCodePage(int codePage) {
10ef30eb
RD
419#if wxUSE_UNICODE
420 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
421 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
422#else
423 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
424 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
425#endif
9e730a78 426 SendMsg(2037, codePage);
9ce192d4
RD
427}
428
4370573a 429// Set the symbol used for a particular marker number,
1a2fb4cd 430// and optionally the fore and background colours.
4370573a 431void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
9e730a78
RD
432 const wxColour& foreground,
433 const wxColour& background) {
9ce192d4 434
9e730a78
RD
435 SendMsg(2040, markerNumber, markerSymbol);
436 if (foreground.Ok())
437 MarkerSetForeground(markerNumber, foreground);
438 if (background.Ok())
439 MarkerSetBackground(markerNumber, background);
9ce192d4
RD
440}
441
4370573a
RD
442// Set the foreground colour used for a particular marker number.
443void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
444 SendMsg(2041, markerNumber, wxColourAsLong(fore));
9ce192d4
RD
445}
446
4370573a
RD
447// Set the background colour used for a particular marker number.
448void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
449 SendMsg(2042, markerNumber, wxColourAsLong(back));
9ce192d4
RD
450}
451
1a2fb4cd
RD
452// Add a marker to a line, returning an ID which can be used to find or delete the marker.
453int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
454 return SendMsg(2043, line, markerNumber);
9ce192d4
RD
455}
456
a834585d 457// Delete a marker from a line.
4370573a
RD
458void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
459 SendMsg(2044, line, markerNumber);
9ce192d4
RD
460}
461
a834585d 462// Delete all markers with a particular number from all lines.
4370573a
RD
463void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
464 SendMsg(2045, markerNumber, 0);
9ce192d4
RD
465}
466
4370573a
RD
467// Get a bit mask of all the markers set on a line.
468int wxStyledTextCtrl::MarkerGet(int line) {
469 return SendMsg(2046, line, 0);
9ce192d4
RD
470}
471
4370573a
RD
472// Find the next line after lineStart that includes a marker in mask.
473int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
474 return SendMsg(2047, lineStart, markerMask);
9ce192d4
RD
475}
476
4370573a
RD
477// Find the previous line before lineStart that includes a marker in mask.
478int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
479 return SendMsg(2048, lineStart, markerMask);
9ce192d4
RD
480}
481
9e730a78
RD
482// Define a marker from a bitmap
483void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
484 // convert bmp to a xpm in a string
485 wxMemoryOutputStream strm;
486 wxImage img = bmp.ConvertToImage();
487 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
488 size_t len = strm.GetSize();
489 char* buff = new char[len+1];
490 strm.CopyTo(buff, len);
491 buff[len] = 0;
492 SendMsg(2049, markerNumber, (long)buff);
493 delete [] buff;
88a8b04e 494
9e730a78
RD
495}
496
4370573a
RD
497// Set a margin to be either numeric or symbolic.
498void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
499 SendMsg(2240, margin, marginType);
9ce192d4
RD
500}
501
4370573a
RD
502// Retrieve the type of a margin.
503int wxStyledTextCtrl::GetMarginType(int margin) {
504 return SendMsg(2241, margin, 0);
9ce192d4
RD
505}
506
4370573a
RD
507// Set the width of a margin to a width expressed in pixels.
508void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
509 SendMsg(2242, margin, pixelWidth);
9ce192d4
RD
510}
511
4370573a
RD
512// Retrieve the width of a margin in pixels.
513int wxStyledTextCtrl::GetMarginWidth(int margin) {
514 return SendMsg(2243, margin, 0);
f6bcfd97
BP
515}
516
4370573a
RD
517// Set a mask that determines which markers are displayed in a margin.
518void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
519 SendMsg(2244, margin, mask);
f6bcfd97
BP
520}
521
4370573a
RD
522// Retrieve the marker mask of a margin.
523int wxStyledTextCtrl::GetMarginMask(int margin) {
524 return SendMsg(2245, margin, 0);
9ce192d4
RD
525}
526
4370573a
RD
527// Make a margin sensitive or insensitive to mouse clicks.
528void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
529 SendMsg(2246, margin, sensitive);
9ce192d4
RD
530}
531
4370573a
RD
532// Retrieve the mouse click sensitivity of a margin.
533bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
534 return SendMsg(2247, margin, 0) != 0;
9ce192d4
RD
535}
536
4370573a 537// Clear all the styles and make equivalent to the global default style.
9ce192d4 538void wxStyledTextCtrl::StyleClearAll() {
4370573a 539 SendMsg(2050, 0, 0);
9ce192d4
RD
540}
541
4370573a
RD
542// Set the foreground colour of a style.
543void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
544 SendMsg(2051, style, wxColourAsLong(fore));
9ce192d4
RD
545}
546
4370573a
RD
547// Set the background colour of a style.
548void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
549 SendMsg(2052, style, wxColourAsLong(back));
9ce192d4
RD
550}
551
4370573a
RD
552// Set a style to be bold or not.
553void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
554 SendMsg(2053, style, bold);
9ce192d4
RD
555}
556
4370573a
RD
557// Set a style to be italic or not.
558void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
559 SendMsg(2054, style, italic);
9ce192d4
RD
560}
561
4370573a
RD
562// Set the size of characters of a style.
563void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
564 SendMsg(2055, style, sizePoints);
9ce192d4
RD
565}
566
4370573a
RD
567// Set the font of a style.
568void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
0c5b83b0 569 SendMsg(2056, style, (long)(const char*)wx2stc(fontName));
9ce192d4
RD
570}
571
4370573a
RD
572// Set a style to have its end of line filled or not.
573void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
574 SendMsg(2057, style, filled);
9ce192d4
RD
575}
576
4370573a
RD
577// Reset the default style to its state at startup
578void wxStyledTextCtrl::StyleResetDefault() {
579 SendMsg(2058, 0, 0);
9ce192d4
RD
580}
581
4370573a
RD
582// Set a style to be underlined or not.
583void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
584 SendMsg(2059, style, underline);
9ce192d4
RD
585}
586
65ec6247
RD
587// Set a style to be mixed case, or to force upper or lower case.
588void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
589 SendMsg(2060, style, caseForce);
590}
591
10ef30eb
RD
592// Set the character set of the font in a style.
593void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
594 SendMsg(2066, style, characterSet);
595}
596
9e730a78
RD
597// Set a style to be a hotspot or not.
598void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) {
599 SendMsg(2409, style, hotspot);
600}
601
4370573a
RD
602// Set the foreground colour of the selection and whether to use this setting.
603void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
604 SendMsg(2067, useSetting, wxColourAsLong(fore));
9ce192d4
RD
605}
606
4370573a
RD
607// Set the background colour of the selection and whether to use this setting.
608void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
609 SendMsg(2068, useSetting, wxColourAsLong(back));
9ce192d4
RD
610}
611
4370573a
RD
612// Set the foreground colour of the caret.
613void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
614 SendMsg(2069, wxColourAsLong(fore), 0);
9ce192d4
RD
615}
616
4370573a
RD
617// When key+modifier combination km is pressed perform msg.
618void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
9e730a78 619 SendMsg(2070, MAKELONG(key, modifiers), cmd);
9ce192d4
RD
620}
621
8e54aaed 622// When key+modifier combination km is pressed do nothing.
4370573a 623void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
9e730a78 624 SendMsg(2071, MAKELONG(key, modifiers));
9ce192d4
RD
625}
626
4370573a
RD
627// Drop all key mappings.
628void wxStyledTextCtrl::CmdKeyClearAll() {
629 SendMsg(2072, 0, 0);
630}
9ce192d4 631
4370573a
RD
632// Set the styles for a segment of the document.
633void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
9e730a78 634 SendMsg(2073, length, (long)styleBytes);
9ce192d4
RD
635}
636
4370573a
RD
637// Set a style to be visible or not.
638void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
639 SendMsg(2074, style, visible);
640}
9ce192d4 641
4370573a 642// Get the time in milliseconds that the caret is on and off.
9ce192d4 643int wxStyledTextCtrl::GetCaretPeriod() {
4370573a 644 return SendMsg(2075, 0, 0);
9ce192d4
RD
645}
646
4370573a
RD
647// Get the time in milliseconds that the caret is on and off. 0 = steady on.
648void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
649 SendMsg(2076, periodMilliseconds, 0);
650}
9ce192d4 651
a834585d 652// Set the set of characters making up words for when moving or selecting by word.
8e54aaed 653// First sets deaults like SetCharsDefault.
4370573a 654void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
0c5b83b0 655 SendMsg(2077, 0, (long)(const char*)wx2stc(characters));
9ce192d4
RD
656}
657
4370573a
RD
658// Start a sequence of actions that is undone and redone as a unit.
659// May be nested.
660void wxStyledTextCtrl::BeginUndoAction() {
661 SendMsg(2078, 0, 0);
662}
9ce192d4 663
4370573a
RD
664// End a sequence of actions that is undone and redone as a unit.
665void wxStyledTextCtrl::EndUndoAction() {
666 SendMsg(2079, 0, 0);
667}
9ce192d4 668
4370573a
RD
669// Set an indicator to plain, squiggle or TT.
670void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
671 SendMsg(2080, indic, style);
672}
9ce192d4 673
4370573a
RD
674// Retrieve the style of an indicator.
675int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
676 return SendMsg(2081, indic, 0);
677}
9ce192d4 678
4370573a
RD
679// Set the foreground colour of an indicator.
680void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
681 SendMsg(2082, indic, wxColourAsLong(fore));
9ce192d4
RD
682}
683
4370573a
RD
684// Retrieve the foreground colour of an indicator.
685wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
686 long c = SendMsg(2083, indic, 0);
687 return wxColourFromLong(c);
688}
9ce192d4 689
f114b858
RD
690// Set the foreground colour of all whitespace and whether to use this setting.
691void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) {
692 SendMsg(2084, useSetting, wxColourAsLong(fore));
693}
694
695// Set the background colour of all whitespace and whether to use this setting.
696void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) {
697 SendMsg(2085, useSetting, wxColourAsLong(back));
698}
699
a834585d
RD
700// Divide each styling byte into lexical class bits (default: 5) and indicator
701// bits (default: 3). If a lexer requires more than 32 lexical states, then this
4370573a
RD
702// is used to expand the possible states.
703void wxStyledTextCtrl::SetStyleBits(int bits) {
704 SendMsg(2090, bits, 0);
9ce192d4
RD
705}
706
4370573a
RD
707// Retrieve number of bits in style bytes used to hold the lexical state.
708int wxStyledTextCtrl::GetStyleBits() {
709 return SendMsg(2091, 0, 0);
710}
9ce192d4 711
4370573a
RD
712// Used to hold extra styling information for each line.
713void wxStyledTextCtrl::SetLineState(int line, int state) {
714 SendMsg(2092, line, state);
f6bcfd97
BP
715}
716
4370573a
RD
717// Retrieve the extra styling information for a line.
718int wxStyledTextCtrl::GetLineState(int line) {
719 return SendMsg(2093, line, 0);
720}
f6bcfd97 721
4370573a
RD
722// Retrieve the last line number that has line state.
723int wxStyledTextCtrl::GetMaxLineState() {
724 return SendMsg(2094, 0, 0);
f6bcfd97
BP
725}
726
65ec6247
RD
727// Is the background of the line containing the caret in a different colour?
728bool wxStyledTextCtrl::GetCaretLineVisible() {
729 return SendMsg(2095, 0, 0) != 0;
730}
731
a834585d 732// Display the background of the line containing the caret in a different colour.
65ec6247
RD
733void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
734 SendMsg(2096, show, 0);
735}
736
737// Get the colour of the background of the line containing the caret.
738wxColour wxStyledTextCtrl::GetCaretLineBack() {
739 long c = SendMsg(2097, 0, 0);
740 return wxColourFromLong(c);
741}
742
743// Set the colour of the background of the line containing the caret.
744void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
745 SendMsg(2098, wxColourAsLong(back), 0);
746}
747
1a2fb4cd
RD
748// Set a style to be changeable or not (read only).
749// Experimental feature, currently buggy.
750void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
751 SendMsg(2099, style, changeable);
752}
753
4370573a
RD
754// Display a auto-completion list.
755// The lenEntered parameter indicates how many characters before
756// the caret should be used to provide context.
757void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
0c5b83b0 758 SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList));
4370573a 759}
f6bcfd97 760
4370573a
RD
761// Remove the auto-completion list from the screen.
762void wxStyledTextCtrl::AutoCompCancel() {
763 SendMsg(2101, 0, 0);
f6bcfd97
BP
764}
765
4370573a
RD
766// Is there an auto-completion list visible?
767bool wxStyledTextCtrl::AutoCompActive() {
768 return SendMsg(2102, 0, 0) != 0;
769}
f6bcfd97 770
a834585d 771// Retrieve the position of the caret when the auto-completion list was displayed.
4370573a
RD
772int wxStyledTextCtrl::AutoCompPosStart() {
773 return SendMsg(2103, 0, 0);
f6bcfd97
BP
774}
775
4370573a
RD
776// User has selected an item so remove the list and insert the selection.
777void wxStyledTextCtrl::AutoCompComplete() {
778 SendMsg(2104, 0, 0);
779}
f6bcfd97 780
4370573a
RD
781// Define a set of character that when typed cancel the auto-completion list.
782void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
0c5b83b0 783 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet));
f6bcfd97
BP
784}
785
a834585d
RD
786// Change the separator character in the string setting up an auto-completion list.
787// Default is space but can be changed if items contain space.
4370573a
RD
788void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
789 SendMsg(2106, separatorCharacter, 0);
790}
f6bcfd97 791
4370573a
RD
792// Retrieve the auto-completion list separator character.
793int wxStyledTextCtrl::AutoCompGetSeparator() {
794 return SendMsg(2107, 0, 0);
9ce192d4
RD
795}
796
4370573a
RD
797// Select the item in the auto-completion list that starts with a string.
798void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
0c5b83b0 799 SendMsg(2108, 0, (long)(const char*)wx2stc(text));
4370573a 800}
9ce192d4 801
4370573a
RD
802// Should the auto-completion list be cancelled if the user backspaces to a
803// position before where the box was created.
804void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
805 SendMsg(2110, cancel, 0);
f6bcfd97
BP
806}
807
4370573a
RD
808// Retrieve whether auto-completion cancelled by backspacing before start.
809bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
810 return SendMsg(2111, 0, 0) != 0;
811}
f6bcfd97 812
1a2fb4cd
RD
813// Define a set of characters that when typed will cause the autocompletion to
814// choose the selected item.
4370573a 815void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
0c5b83b0 816 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet));
4370573a 817}
9ce192d4 818
4370573a
RD
819// Should a single item auto-completion list automatically choose the item.
820void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
821 SendMsg(2113, chooseSingle, 0);
822}
9ce192d4 823
4370573a
RD
824// Retrieve whether a single item auto-completion list automatically choose the item.
825bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
826 return SendMsg(2114, 0, 0) != 0;
9ce192d4
RD
827}
828
4370573a
RD
829// Set whether case is significant when performing auto-completion searches.
830void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
831 SendMsg(2115, ignoreCase, 0);
832}
9ce192d4 833
4370573a
RD
834// Retrieve state of ignore case flag.
835bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
836 return SendMsg(2116, 0, 0) != 0;
9ce192d4
RD
837}
838
65ec6247
RD
839// Display a list of strings and send notification when user chooses one.
840void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
0c5b83b0 841 SendMsg(2117, listType, (long)(const char*)wx2stc(itemList));
65ec6247
RD
842}
843
a834585d 844// Set whether or not autocompletion is hidden automatically when nothing matches.
65ec6247
RD
845void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
846 SendMsg(2118, autoHide, 0);
847}
848
a834585d 849// Retrieve whether or not autocompletion is hidden automatically when nothing matches.
65ec6247
RD
850bool wxStyledTextCtrl::AutoCompGetAutoHide() {
851 return SendMsg(2119, 0, 0) != 0;
852}
853
a834585d
RD
854// Set whether or not autocompletion deletes any word characters
855// after the inserted text upon completion.
1a2fb4cd
RD
856void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
857 SendMsg(2270, dropRestOfWord, 0);
858}
859
a834585d
RD
860// Retrieve whether or not autocompletion deletes any word characters
861// after the inserted text upon completion.
1a2fb4cd
RD
862bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
863 return SendMsg(2271, 0, 0) != 0;
864}
865
9e730a78
RD
866// Register an image for use in autocompletion lists.
867void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
868 // convert bmp to a xpm in a string
869 wxMemoryOutputStream strm;
870 wxImage img = bmp.ConvertToImage();
871 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
872 size_t len = strm.GetSize();
873 char* buff = new char[len+1];
874 strm.CopyTo(buff, len);
875 buff[len] = 0;
876 SendMsg(2405, type, (long)buff);
877 delete [] buff;
88a8b04e 878
9e730a78
RD
879}
880
881// Clear all the registered images.
882void wxStyledTextCtrl::ClearRegisteredImages() {
883 SendMsg(2408, 0, 0);
884}
885
886// Retrieve the auto-completion list type-separator character.
887int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
888 return SendMsg(2285, 0, 0);
889}
890
891// Change the type-separator character in the string setting up an auto-completion list.
892// Default is '?' but can be changed if items contain '?'.
893void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) {
894 SendMsg(2286, separatorCharacter, 0);
895}
896
4370573a
RD
897// Set the number of spaces used for one level of indentation.
898void wxStyledTextCtrl::SetIndent(int indentSize) {
899 SendMsg(2122, indentSize, 0);
900}
9ce192d4 901
4370573a
RD
902// Retrieve indentation size.
903int wxStyledTextCtrl::GetIndent() {
904 return SendMsg(2123, 0, 0);
9ce192d4
RD
905}
906
4370573a
RD
907// Indentation will only use space characters if useTabs is false, otherwise
908// it will use a combination of tabs and spaces.
909void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
910 SendMsg(2124, useTabs, 0);
911}
9ce192d4 912
4370573a
RD
913// Retrieve whether tabs will be used in indentation.
914bool wxStyledTextCtrl::GetUseTabs() {
915 return SendMsg(2125, 0, 0) != 0;
916}
9ce192d4 917
4370573a
RD
918// Change the indentation of a line to a number of columns.
919void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
920 SendMsg(2126, line, indentSize);
921}
9ce192d4 922
4370573a
RD
923// Retrieve the number of columns that a line is indented.
924int wxStyledTextCtrl::GetLineIndentation(int line) {
925 return SendMsg(2127, line, 0);
9ce192d4
RD
926}
927
4370573a
RD
928// Retrieve the position before the first non indentation character on a line.
929int wxStyledTextCtrl::GetLineIndentPosition(int line) {
930 return SendMsg(2128, line, 0);
931}
9ce192d4 932
4370573a
RD
933// Retrieve the column number of a position, taking tab width into account.
934int wxStyledTextCtrl::GetColumn(int pos) {
935 return SendMsg(2129, pos, 0);
9ce192d4
RD
936}
937
4370573a
RD
938// Show or hide the horizontal scroll bar.
939void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
940 SendMsg(2130, show, 0);
941}
9ce192d4 942
4370573a
RD
943// Is the horizontal scroll bar visible?
944bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
945 return SendMsg(2131, 0, 0) != 0;
9ce192d4
RD
946}
947
4370573a
RD
948// Show or hide indentation guides.
949void wxStyledTextCtrl::SetIndentationGuides(bool show) {
950 SendMsg(2132, show, 0);
951}
9ce192d4 952
4370573a
RD
953// Are the indentation guides visible?
954bool wxStyledTextCtrl::GetIndentationGuides() {
955 return SendMsg(2133, 0, 0) != 0;
9ce192d4
RD
956}
957
4370573a
RD
958// Set the highlighted indentation guide column.
959// 0 = no highlighted guide.
960void wxStyledTextCtrl::SetHighlightGuide(int column) {
961 SendMsg(2134, column, 0);
962}
9ce192d4 963
4370573a
RD
964// Get the highlighted indentation guide column.
965int wxStyledTextCtrl::GetHighlightGuide() {
966 return SendMsg(2135, 0, 0);
9ce192d4
RD
967}
968
4370573a
RD
969// Get the position after the last visible characters on a line.
970int wxStyledTextCtrl::GetLineEndPosition(int line) {
971 return SendMsg(2136, line, 0);
972}
9ce192d4 973
4370573a
RD
974// Get the code page used to interpret the bytes of the document as characters.
975int wxStyledTextCtrl::GetCodePage() {
976 return SendMsg(2137, 0, 0);
9ce192d4
RD
977}
978
4370573a
RD
979// Get the foreground colour of the caret.
980wxColour wxStyledTextCtrl::GetCaretForeground() {
981 long c = SendMsg(2138, 0, 0);
982 return wxColourFromLong(c);
983}
9ce192d4 984
4370573a
RD
985// In read-only mode?
986bool wxStyledTextCtrl::GetReadOnly() {
987 return SendMsg(2140, 0, 0) != 0;
9ce192d4
RD
988}
989
4370573a
RD
990// Sets the position of the caret.
991void wxStyledTextCtrl::SetCurrentPos(int pos) {
992 SendMsg(2141, pos, 0);
993}
9ce192d4 994
4370573a
RD
995// Sets the position that starts the selection - this becomes the anchor.
996void wxStyledTextCtrl::SetSelectionStart(int pos) {
997 SendMsg(2142, pos, 0);
9ce192d4
RD
998}
999
4370573a
RD
1000// Returns the position at the start of the selection.
1001int wxStyledTextCtrl::GetSelectionStart() {
1002 return SendMsg(2143, 0, 0);
1003}
9ce192d4 1004
4370573a
RD
1005// Sets the position that ends the selection - this becomes the currentPosition.
1006void wxStyledTextCtrl::SetSelectionEnd(int pos) {
1007 SendMsg(2144, pos, 0);
9ce192d4
RD
1008}
1009
4370573a
RD
1010// Returns the position at the end of the selection.
1011int wxStyledTextCtrl::GetSelectionEnd() {
1012 return SendMsg(2145, 0, 0);
1013}
9ce192d4 1014
4370573a
RD
1015// Sets the print magnification added to the point size of each style for printing.
1016void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
1017 SendMsg(2146, magnification, 0);
9ce192d4
RD
1018}
1019
4370573a
RD
1020// Returns the print magnification.
1021int wxStyledTextCtrl::GetPrintMagnification() {
1022 return SendMsg(2147, 0, 0);
1023}
9ce192d4 1024
4370573a
RD
1025// Modify colours when printing for clearer printed text.
1026void wxStyledTextCtrl::SetPrintColourMode(int mode) {
1027 SendMsg(2148, mode, 0);
9ce192d4
RD
1028}
1029
4370573a
RD
1030// Returns the print colour mode.
1031int wxStyledTextCtrl::GetPrintColourMode() {
1032 return SendMsg(2149, 0, 0);
1033}
9ce192d4 1034
4370573a
RD
1035// Find some text in the document.
1036int wxStyledTextCtrl::FindText(int minPos, int maxPos,
9e730a78
RD
1037 const wxString& text,
1038 int flags) {
1039 TextToFind ft;
1040 ft.chrg.cpMin = minPos;
1041 ft.chrg.cpMax = maxPos;
1042 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1043 ft.lpstrText = (char*)(const char*)buf;
4370573a 1044
9e730a78 1045 return SendMsg(2150, flags, (long)&ft);
4370573a
RD
1046}
1047
a834585d 1048// On Windows, will draw the document into a display context such as a printer.
4370573a 1049 int wxStyledTextCtrl::FormatRange(bool doDraw,
9e730a78
RD
1050 int startPos,
1051 int endPos,
1052 wxDC* draw,
8e54aaed 1053 wxDC* target,
9e730a78
RD
1054 wxRect renderRect,
1055 wxRect pageRect) {
1056 RangeToFormat fr;
1057
1058 if (endPos < startPos) {
1059 int temp = startPos;
1060 startPos = endPos;
1061 endPos = temp;
1062 }
1063 fr.hdc = draw;
1064 fr.hdcTarget = target;
1065 fr.rc.top = renderRect.GetTop();
1066 fr.rc.left = renderRect.GetLeft();
1067 fr.rc.right = renderRect.GetRight();
1068 fr.rc.bottom = renderRect.GetBottom();
1069 fr.rcPage.top = pageRect.GetTop();
1070 fr.rcPage.left = pageRect.GetLeft();
1071 fr.rcPage.right = pageRect.GetRight();
1072 fr.rcPage.bottom = pageRect.GetBottom();
1073 fr.chrg.cpMin = startPos;
1074 fr.chrg.cpMax = endPos;
1075
1076 return SendMsg(2151, doDraw, (long)&fr);
1077}
1078
1079// Retrieve the display line at the top of the display.
4370573a
RD
1080int wxStyledTextCtrl::GetFirstVisibleLine() {
1081 return SendMsg(2152, 0, 0);
9ce192d4
RD
1082}
1083
4370573a
RD
1084// Retrieve the contents of a line.
1085wxString wxStyledTextCtrl::GetLine(int line) {
9e730a78
RD
1086 int len = LineLength(line);
1087 if (!len) return wxEmptyString;
9ce192d4 1088
9e730a78
RD
1089 wxMemoryBuffer mbuf(len+1);
1090 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1091 SendMsg(2153, line, (long)buf);
1092 mbuf.UngetWriteBuf(len);
1093 mbuf.AppendByte(0);
1094 return stc2wx(buf);
4370573a
RD
1095}
1096
1097// Returns the number of lines in the document. There is always at least one.
1098int wxStyledTextCtrl::GetLineCount() {
1099 return SendMsg(2154, 0, 0);
1100}
9ce192d4 1101
4370573a 1102// Sets the size in pixels of the left margin.
65ec6247
RD
1103void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
1104 SendMsg(2155, 0, pixelWidth);
4370573a 1105}
9ce192d4 1106
4370573a
RD
1107// Returns the size in pixels of the left margin.
1108int wxStyledTextCtrl::GetMarginLeft() {
1109 return SendMsg(2156, 0, 0);
9ce192d4
RD
1110}
1111
4370573a 1112// Sets the size in pixels of the right margin.
65ec6247
RD
1113void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
1114 SendMsg(2157, 0, pixelWidth);
4370573a 1115}
9ce192d4 1116
4370573a
RD
1117// Returns the size in pixels of the right margin.
1118int wxStyledTextCtrl::GetMarginRight() {
1119 return SendMsg(2158, 0, 0);
9ce192d4
RD
1120}
1121
4370573a
RD
1122// Is the document different from when it was last saved?
1123bool wxStyledTextCtrl::GetModify() {
1124 return SendMsg(2159, 0, 0) != 0;
1125}
9ce192d4 1126
4370573a
RD
1127// Select a range of text.
1128void wxStyledTextCtrl::SetSelection(int start, int end) {
1129 SendMsg(2160, start, end);
9ce192d4
RD
1130}
1131
4370573a
RD
1132// Retrieve the selected text.
1133wxString wxStyledTextCtrl::GetSelectedText() {
9e730a78
RD
1134 int start;
1135 int end;
9ce192d4 1136
9e730a78
RD
1137 GetSelection(&start, &end);
1138 int len = end - start;
1139 if (!len) return wxEmptyString;
9ce192d4 1140
3d7a4fe8 1141 wxMemoryBuffer mbuf(len+2);
9e730a78
RD
1142 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1143 SendMsg(2161, 0, (long)buf);
1144 mbuf.UngetWriteBuf(len);
1145 mbuf.AppendByte(0);
1146 return stc2wx(buf);
4370573a 1147}
9ce192d4 1148
4370573a
RD
1149// Retrieve a range of text.
1150wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
9e730a78
RD
1151 if (endPos < startPos) {
1152 int temp = startPos;
1153 startPos = endPos;
1154 endPos = temp;
1155 }
1156 int len = endPos - startPos;
1157 if (!len) return wxEmptyString;
1158 wxMemoryBuffer mbuf(len+1);
1159 char* buf = (char*)mbuf.GetWriteBuf(len);
1160 TextRange tr;
1161 tr.lpstrText = buf;
1162 tr.chrg.cpMin = startPos;
1163 tr.chrg.cpMax = endPos;
1164 SendMsg(2162, 0, (long)&tr);
1165 mbuf.UngetWriteBuf(len);
1166 mbuf.AppendByte(0);
1167 return stc2wx(buf);
9ce192d4
RD
1168}
1169
4370573a
RD
1170// Draw the selection in normal style or with selection highlighted.
1171void wxStyledTextCtrl::HideSelection(bool normal) {
1172 SendMsg(2163, normal, 0);
1173}
9ce192d4 1174
4370573a
RD
1175// Retrieve the line containing a position.
1176int wxStyledTextCtrl::LineFromPosition(int pos) {
1177 return SendMsg(2166, pos, 0);
9ce192d4
RD
1178}
1179
4370573a
RD
1180// Retrieve the position at the start of a line.
1181int wxStyledTextCtrl::PositionFromLine(int line) {
1182 return SendMsg(2167, line, 0);
1183}
9ce192d4 1184
4370573a
RD
1185// Scroll horizontally and vertically.
1186void wxStyledTextCtrl::LineScroll(int columns, int lines) {
1187 SendMsg(2168, columns, lines);
9ce192d4
RD
1188}
1189
4370573a
RD
1190// Ensure the caret is visible.
1191void wxStyledTextCtrl::EnsureCaretVisible() {
1192 SendMsg(2169, 0, 0);
1193}
9ce192d4 1194
4370573a
RD
1195// Replace the selected text with the argument text.
1196void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
0c5b83b0 1197 SendMsg(2170, 0, (long)(const char*)wx2stc(text));
9ce192d4
RD
1198}
1199
4370573a
RD
1200// Set to read only or read write.
1201void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1202 SendMsg(2171, readOnly, 0);
1203}
9ce192d4 1204
4370573a
RD
1205// Will a paste succeed?
1206bool wxStyledTextCtrl::CanPaste() {
1207 return SendMsg(2173, 0, 0) != 0;
9ce192d4
RD
1208}
1209
a834585d 1210// Are there any undoable actions in the undo history?
4370573a
RD
1211bool wxStyledTextCtrl::CanUndo() {
1212 return SendMsg(2174, 0, 0) != 0;
1213}
9ce192d4 1214
4370573a
RD
1215// Delete the undo history.
1216void wxStyledTextCtrl::EmptyUndoBuffer() {
1217 SendMsg(2175, 0, 0);
9ce192d4
RD
1218}
1219
4370573a
RD
1220// Undo one action in the undo history.
1221void wxStyledTextCtrl::Undo() {
1222 SendMsg(2176, 0, 0);
1223}
9ce192d4 1224
4370573a
RD
1225// Cut the selection to the clipboard.
1226void wxStyledTextCtrl::Cut() {
1227 SendMsg(2177, 0, 0);
f6bcfd97
BP
1228}
1229
4370573a
RD
1230// Copy the selection to the clipboard.
1231void wxStyledTextCtrl::Copy() {
1232 SendMsg(2178, 0, 0);
1233}
f6bcfd97 1234
4370573a
RD
1235// Paste the contents of the clipboard into the document replacing the selection.
1236void wxStyledTextCtrl::Paste() {
1237 SendMsg(2179, 0, 0);
f6bcfd97
BP
1238}
1239
4370573a
RD
1240// Clear the selection.
1241void wxStyledTextCtrl::Clear() {
1242 SendMsg(2180, 0, 0);
1243}
f6bcfd97 1244
4370573a
RD
1245// Replace the contents of the document with the argument text.
1246void wxStyledTextCtrl::SetText(const wxString& text) {
0c5b83b0 1247 SendMsg(2181, 0, (long)(const char*)wx2stc(text));
f6bcfd97
BP
1248}
1249
4370573a
RD
1250// Retrieve all the text in the document.
1251wxString wxStyledTextCtrl::GetText() {
9e730a78
RD
1252 int len = GetTextLength();
1253 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1254 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1255 SendMsg(2182, len+1, (long)buf);
1256 mbuf.UngetWriteBuf(len);
1257 mbuf.AppendByte(0);
1258 return stc2wx(buf);
4370573a 1259}
9ce192d4 1260
4370573a
RD
1261// Retrieve the number of characters in the document.
1262int wxStyledTextCtrl::GetTextLength() {
1263 return SendMsg(2183, 0, 0);
9ce192d4
RD
1264}
1265
a834585d 1266// Set to overtype (true) or insert mode.
4370573a
RD
1267void wxStyledTextCtrl::SetOvertype(bool overtype) {
1268 SendMsg(2186, overtype, 0);
1269}
9ce192d4 1270
4370573a
RD
1271// Returns true if overtype mode is active otherwise false is returned.
1272bool wxStyledTextCtrl::GetOvertype() {
1273 return SendMsg(2187, 0, 0) != 0;
9ce192d4
RD
1274}
1275
a834585d 1276// Set the width of the insert mode caret.
65ec6247
RD
1277void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
1278 SendMsg(2188, pixelWidth, 0);
1279}
1280
a834585d 1281// Returns the width of the insert mode caret.
65ec6247
RD
1282int wxStyledTextCtrl::GetCaretWidth() {
1283 return SendMsg(2189, 0, 0);
1284}
1285
1286// Sets the position that starts the target which is used for updating the
1287// document without affecting the scroll position.
1288void wxStyledTextCtrl::SetTargetStart(int pos) {
1289 SendMsg(2190, pos, 0);
1290}
1291
1292// Get the position that starts the target.
1293int wxStyledTextCtrl::GetTargetStart() {
1294 return SendMsg(2191, 0, 0);
1295}
1296
1297// Sets the position that ends the target which is used for updating the
1298// document without affecting the scroll position.
1299void wxStyledTextCtrl::SetTargetEnd(int pos) {
1300 SendMsg(2192, pos, 0);
1301}
1302
1303// Get the position that ends the target.
1304int wxStyledTextCtrl::GetTargetEnd() {
1305 return SendMsg(2193, 0, 0);
1306}
1307
1308// Replace the target text with the argument text.
8e54aaed 1309// Text is counted so it can contain NULs.
65ec6247
RD
1310// Returns the length of the replacement text.
1311
9e730a78
RD
1312 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1313 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1314 return SendMsg(2194, strlen(buf), (long)(const char*)buf);
65ec6247
RD
1315}
1316
1317// Replace the target text with the argument text after \d processing.
8e54aaed 1318// Text is counted so it can contain NULs.
65ec6247
RD
1319// Looks for \d where d is between 1 and 9 and replaces these with the strings
1320// matched in the last search operation which were surrounded by \( and \).
1321// Returns the length of the replacement text including any change
1322// caused by processing the \d patterns.
1323
9e730a78
RD
1324 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1325 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1326 return SendMsg(2195, strlen(buf), (long)(const char*)buf);
65ec6247
RD
1327}
1328
1329// Search for a counted string in the target and set the target to the found
8e54aaed 1330// range. Text is counted so it can contain NULs.
65ec6247
RD
1331// Returns length of range or -1 for failure in which case target is not moved.
1332
9e730a78
RD
1333 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1334 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1335 return SendMsg(2197, strlen(buf), (long)(const char*)buf);
65ec6247
RD
1336}
1337
a834585d 1338// Set the search flags used by SearchInTarget.
65ec6247
RD
1339void wxStyledTextCtrl::SetSearchFlags(int flags) {
1340 SendMsg(2198, flags, 0);
1341}
1342
a834585d 1343// Get the search flags used by SearchInTarget.
65ec6247
RD
1344int wxStyledTextCtrl::GetSearchFlags() {
1345 return SendMsg(2199, 0, 0);
1346}
1347
4370573a
RD
1348// Show a call tip containing a definition near position pos.
1349void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
0c5b83b0 1350 SendMsg(2200, pos, (long)(const char*)wx2stc(definition));
4370573a 1351}
9ce192d4 1352
4370573a
RD
1353// Remove the call tip from the screen.
1354void wxStyledTextCtrl::CallTipCancel() {
1355 SendMsg(2201, 0, 0);
9ce192d4
RD
1356}
1357
4370573a
RD
1358// Is there an active call tip?
1359bool wxStyledTextCtrl::CallTipActive() {
1360 return SendMsg(2202, 0, 0) != 0;
1361}
9ce192d4 1362
4370573a 1363// Retrieve the position where the caret was before displaying the call tip.
9ce192d4 1364int wxStyledTextCtrl::CallTipPosAtStart() {
4370573a 1365 return SendMsg(2203, 0, 0);
9ce192d4
RD
1366}
1367
4370573a 1368// Highlight a segment of the definition.
9ce192d4 1369void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
4370573a 1370 SendMsg(2204, start, end);
9ce192d4
RD
1371}
1372
4370573a
RD
1373// Set the background colour for the call tip.
1374void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1375 SendMsg(2205, wxColourAsLong(back), 0);
1376}
9ce192d4 1377
9e730a78
RD
1378// Set the foreground colour for the call tip.
1379void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore) {
1380 SendMsg(2206, wxColourAsLong(fore), 0);
1381}
1382
1383// Set the foreground colour for the highlighted part of the call tip.
1384void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) {
1385 SendMsg(2207, wxColourAsLong(fore), 0);
1386}
1387
4370573a
RD
1388// Find the display line of a document line taking hidden lines into account.
1389int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1390 return SendMsg(2220, line, 0);
9ce192d4
RD
1391}
1392
4370573a
RD
1393// Find the document line of a display line taking hidden lines into account.
1394int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1395 return SendMsg(2221, lineDisplay, 0);
1396}
9ce192d4 1397
4370573a
RD
1398// Set the fold level of a line.
1399// This encodes an integer level along with flags indicating whether the
1400// line is a header and whether it is effectively white space.
1401void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1402 SendMsg(2222, line, level);
1403}
9ce192d4 1404
4370573a
RD
1405// Retrieve the fold level of a line.
1406int wxStyledTextCtrl::GetFoldLevel(int line) {
1407 return SendMsg(2223, line, 0);
1408}
d134f170 1409
4370573a
RD
1410// Find the last child line of a header line.
1411int wxStyledTextCtrl::GetLastChild(int line, int level) {
1412 return SendMsg(2224, line, level);
9ce192d4
RD
1413}
1414
4370573a
RD
1415// Find the parent line of a child line.
1416int wxStyledTextCtrl::GetFoldParent(int line) {
1417 return SendMsg(2225, line, 0);
1418}
9ce192d4 1419
4370573a
RD
1420// Make a range of lines visible.
1421void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1422 SendMsg(2226, lineStart, lineEnd);
9ce192d4
RD
1423}
1424
4370573a
RD
1425// Make a range of lines invisible.
1426void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1427 SendMsg(2227, lineStart, lineEnd);
1428}
9ce192d4 1429
4370573a
RD
1430// Is a line visible?
1431bool wxStyledTextCtrl::GetLineVisible(int line) {
1432 return SendMsg(2228, line, 0) != 0;
9ce192d4
RD
1433}
1434
4370573a
RD
1435// Show the children of a header line.
1436void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1437 SendMsg(2229, line, expanded);
1438}
9ce192d4 1439
4370573a
RD
1440// Is a header line expanded?
1441bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1442 return SendMsg(2230, line, 0) != 0;
9ce192d4
RD
1443}
1444
4370573a
RD
1445// Switch a header line between expanded and contracted.
1446void wxStyledTextCtrl::ToggleFold(int line) {
1447 SendMsg(2231, line, 0);
1448}
9ce192d4 1449
4370573a
RD
1450// Ensure a particular line is visible by expanding any header line hiding it.
1451void wxStyledTextCtrl::EnsureVisible(int line) {
1452 SendMsg(2232, line, 0);
1453}
9ce192d4 1454
9e730a78 1455// Set some style options for folding.
4370573a
RD
1456void wxStyledTextCtrl::SetFoldFlags(int flags) {
1457 SendMsg(2233, flags, 0);
9ce192d4
RD
1458}
1459
65ec6247
RD
1460// Ensure a particular line is visible by expanding any header line hiding it.
1461// Use the currently set visibility policy to determine which range to display.
1462void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
1463 SendMsg(2234, line, 0);
1464}
1465
a834585d 1466// Sets whether a tab pressed when caret is within indentation indents.
65ec6247
RD
1467void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
1468 SendMsg(2260, tabIndents, 0);
1469}
1470
1471// Does a tab pressed when caret is within indentation indent?
1472bool wxStyledTextCtrl::GetTabIndents() {
1473 return SendMsg(2261, 0, 0) != 0;
1474}
1475
a834585d 1476// Sets whether a backspace pressed when caret is within indentation unindents.
65ec6247
RD
1477void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
1478 SendMsg(2262, bsUnIndents, 0);
1479}
1480
1481// Does a backspace pressed when caret is within indentation unindent?
1482bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1483 return SendMsg(2263, 0, 0) != 0;
1484}
1485
a834585d 1486// Sets the time the mouse must sit still to generate a mouse dwell event.
65ec6247
RD
1487void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
1488 SendMsg(2264, periodMilliseconds, 0);
1489}
1490
a834585d 1491// Retrieve the time the mouse must sit still to generate a mouse dwell event.
65ec6247
RD
1492int wxStyledTextCtrl::GetMouseDwellTime() {
1493 return SendMsg(2265, 0, 0);
1494}
1495
a834585d 1496// Get position of start of word.
1a2fb4cd
RD
1497int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
1498 return SendMsg(2266, pos, onlyWordCharacters);
1499}
1500
a834585d 1501// Get position of end of word.
1a2fb4cd
RD
1502int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
1503 return SendMsg(2267, pos, onlyWordCharacters);
1504}
1505
a834585d 1506// Sets whether text is word wrapped.
1a2fb4cd
RD
1507void wxStyledTextCtrl::SetWrapMode(int mode) {
1508 SendMsg(2268, mode, 0);
1509}
1510
a834585d 1511// Retrieve whether text is word wrapped.
1a2fb4cd
RD
1512int wxStyledTextCtrl::GetWrapMode() {
1513 return SendMsg(2269, 0, 0);
1514}
1515
a834585d 1516// Sets the degree of caching of layout information.
1a2fb4cd
RD
1517void wxStyledTextCtrl::SetLayoutCache(int mode) {
1518 SendMsg(2272, mode, 0);
1519}
1520
a834585d 1521// Retrieve the degree of caching of layout information.
1a2fb4cd
RD
1522int wxStyledTextCtrl::GetLayoutCache() {
1523 return SendMsg(2273, 0, 0);
1524}
1525
a834585d
RD
1526// Sets the document width assumed for scrolling.
1527void wxStyledTextCtrl::SetScrollWidth(int pixelWidth) {
1528 SendMsg(2274, pixelWidth, 0);
1529}
1530
1531// Retrieve the document width assumed for scrolling.
1532int wxStyledTextCtrl::GetScrollWidth() {
1533 return SendMsg(2275, 0, 0);
1534}
1535
1536// Measure the pixel width of some text in a particular style.
8e54aaed 1537// NUL terminated text argument.
a834585d
RD
1538// Does not handle tab or control characters.
1539int wxStyledTextCtrl::TextWidth(int style, const wxString& text) {
1540 return SendMsg(2276, style, (long)(const char*)wx2stc(text));
1541}
1542
1543// Sets the scroll range so that maximum scroll position has
1544// the last line at the bottom of the view (default).
1545// Setting this to false allows scrolling one page below the last line.
1546void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine) {
1547 SendMsg(2277, endAtLastLine, 0);
1548}
1549
1550// Retrieve whether the maximum scroll position has the last
1551// line at the bottom of the view.
1552int wxStyledTextCtrl::GetEndAtLastLine() {
1553 return SendMsg(2278, 0, 0);
1554}
1555
1556// Retrieve the height of a particular line of text in pixels.
1557int wxStyledTextCtrl::TextHeight(int line) {
1558 return SendMsg(2279, line, 0);
1559}
1560
9e730a78
RD
1561// Show or hide the vertical scroll bar.
1562void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show) {
1563 SendMsg(2280, show, 0);
1564}
1565
1566// Is the vertical scroll bar visible?
1567bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1568 return SendMsg(2281, 0, 0) != 0;
1569}
1570
1571// Append a string to the end of the document without changing the selection.
1572void wxStyledTextCtrl::AppendText(int length, const wxString& text) {
1573 SendMsg(2282, length, (long)(const char*)wx2stc(text));
1574}
1575
1576// Is drawing done in two phases with backgrounds drawn before foregrounds?
1577bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1578 return SendMsg(2283, 0, 0) != 0;
1579}
1580
1581// In twoPhaseDraw mode, drawing is performed in two phases, first the background
1582// and then the foreground. This avoids chopping off characters that overlap the next run.
1583void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) {
1584 SendMsg(2284, twoPhase, 0);
1585}
1586
1587// Make the target range start and end be the same as the selection range start and end.
1588void wxStyledTextCtrl::TargetFromSelection() {
1589 SendMsg(2287, 0, 0);
1590}
1591
1592// Join the lines in the target.
1593void wxStyledTextCtrl::LinesJoin() {
1594 SendMsg(2288, 0, 0);
1595}
1596
1597// Split the lines in the target into lines that are less wide than pixelWidth
1598// where possible.
1599void wxStyledTextCtrl::LinesSplit(int pixelWidth) {
1600 SendMsg(2289, pixelWidth, 0);
1601}
1602
1603// Set the colours used as a chequerboard pattern in the fold margin
1604void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) {
1605 SendMsg(2290, useSetting, wxColourAsLong(back));
1606}
1607void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) {
1608 SendMsg(2291, useSetting, wxColourAsLong(fore));
1609}
1610
c26dba42
RD
1611// Move caret down one line.
1612void wxStyledTextCtrl::LineDown() {
1613 SendMsg(2300, 0, 0);
1614}
1615
1616// Move caret down one line extending selection to new caret position.
1617void wxStyledTextCtrl::LineDownExtend() {
1618 SendMsg(2301, 0, 0);
1619}
1620
1621// Move caret up one line.
1622void wxStyledTextCtrl::LineUp() {
1623 SendMsg(2302, 0, 0);
1624}
1625
1626// Move caret up one line extending selection to new caret position.
1627void wxStyledTextCtrl::LineUpExtend() {
1628 SendMsg(2303, 0, 0);
1629}
1630
1631// Move caret left one character.
1632void wxStyledTextCtrl::CharLeft() {
1633 SendMsg(2304, 0, 0);
1634}
1635
1636// Move caret left one character extending selection to new caret position.
1637void wxStyledTextCtrl::CharLeftExtend() {
1638 SendMsg(2305, 0, 0);
1639}
1640
1641// Move caret right one character.
1642void wxStyledTextCtrl::CharRight() {
1643 SendMsg(2306, 0, 0);
1644}
1645
1646// Move caret right one character extending selection to new caret position.
1647void wxStyledTextCtrl::CharRightExtend() {
1648 SendMsg(2307, 0, 0);
1649}
1650
1651// Move caret left one word.
1652void wxStyledTextCtrl::WordLeft() {
1653 SendMsg(2308, 0, 0);
1654}
1655
1656// Move caret left one word extending selection to new caret position.
1657void wxStyledTextCtrl::WordLeftExtend() {
1658 SendMsg(2309, 0, 0);
1659}
1660
1661// Move caret right one word.
1662void wxStyledTextCtrl::WordRight() {
1663 SendMsg(2310, 0, 0);
1664}
1665
1666// Move caret right one word extending selection to new caret position.
1667void wxStyledTextCtrl::WordRightExtend() {
1668 SendMsg(2311, 0, 0);
1669}
1670
1671// Move caret to first position on line.
1672void wxStyledTextCtrl::Home() {
1673 SendMsg(2312, 0, 0);
1674}
1675
1676// Move caret to first position on line extending selection to new caret position.
1677void wxStyledTextCtrl::HomeExtend() {
1678 SendMsg(2313, 0, 0);
1679}
1680
1681// Move caret to last position on line.
1682void wxStyledTextCtrl::LineEnd() {
1683 SendMsg(2314, 0, 0);
1684}
1685
1686// Move caret to last position on line extending selection to new caret position.
1687void wxStyledTextCtrl::LineEndExtend() {
1688 SendMsg(2315, 0, 0);
1689}
1690
1691// Move caret to first position in document.
1692void wxStyledTextCtrl::DocumentStart() {
1693 SendMsg(2316, 0, 0);
1694}
1695
1696// Move caret to first position in document extending selection to new caret position.
1697void wxStyledTextCtrl::DocumentStartExtend() {
1698 SendMsg(2317, 0, 0);
1699}
1700
1701// Move caret to last position in document.
1702void wxStyledTextCtrl::DocumentEnd() {
1703 SendMsg(2318, 0, 0);
1704}
1705
1706// Move caret to last position in document extending selection to new caret position.
1707void wxStyledTextCtrl::DocumentEndExtend() {
1708 SendMsg(2319, 0, 0);
1709}
1710
1711// Move caret one page up.
1712void wxStyledTextCtrl::PageUp() {
1713 SendMsg(2320, 0, 0);
1714}
1715
1716// Move caret one page up extending selection to new caret position.
1717void wxStyledTextCtrl::PageUpExtend() {
1718 SendMsg(2321, 0, 0);
1719}
1720
1721// Move caret one page down.
1722void wxStyledTextCtrl::PageDown() {
1723 SendMsg(2322, 0, 0);
1724}
1725
1726// Move caret one page down extending selection to new caret position.
1727void wxStyledTextCtrl::PageDownExtend() {
1728 SendMsg(2323, 0, 0);
1729}
1730
1731// Switch from insert to overtype mode or the reverse.
1732void wxStyledTextCtrl::EditToggleOvertype() {
1733 SendMsg(2324, 0, 0);
1734}
1735
1736// Cancel any modes such as call tip or auto-completion list display.
1737void wxStyledTextCtrl::Cancel() {
1738 SendMsg(2325, 0, 0);
1739}
1740
1741// Delete the selection or if no selection, the character before the caret.
1742void wxStyledTextCtrl::DeleteBack() {
1743 SendMsg(2326, 0, 0);
1744}
1745
1746// If selection is empty or all on one line replace the selection with a tab character.
1747// If more than one line selected, indent the lines.
1748void wxStyledTextCtrl::Tab() {
1749 SendMsg(2327, 0, 0);
1750}
1751
1752// Dedent the selected lines.
1753void wxStyledTextCtrl::BackTab() {
1754 SendMsg(2328, 0, 0);
1755}
1756
1757// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1758void wxStyledTextCtrl::NewLine() {
1759 SendMsg(2329, 0, 0);
1760}
1761
1762// Insert a Form Feed character.
1763void wxStyledTextCtrl::FormFeed() {
1764 SendMsg(2330, 0, 0);
1765}
1766
1767// Move caret to before first visible character on line.
1768// If already there move to first character on line.
1769void wxStyledTextCtrl::VCHome() {
1770 SendMsg(2331, 0, 0);
1771}
1772
1773// Like VCHome but extending selection to new caret position.
1774void wxStyledTextCtrl::VCHomeExtend() {
1775 SendMsg(2332, 0, 0);
1776}
1777
1778// Magnify the displayed text by increasing the sizes by 1 point.
1779void wxStyledTextCtrl::ZoomIn() {
1780 SendMsg(2333, 0, 0);
1781}
1782
1783// Make the displayed text smaller by decreasing the sizes by 1 point.
1784void wxStyledTextCtrl::ZoomOut() {
1785 SendMsg(2334, 0, 0);
1786}
1787
1788// Delete the word to the left of the caret.
1789void wxStyledTextCtrl::DelWordLeft() {
1790 SendMsg(2335, 0, 0);
1791}
1792
1793// Delete the word to the right of the caret.
1794void wxStyledTextCtrl::DelWordRight() {
1795 SendMsg(2336, 0, 0);
1796}
1797
1798// Cut the line containing the caret.
1799void wxStyledTextCtrl::LineCut() {
1800 SendMsg(2337, 0, 0);
1801}
1802
1803// Delete the line containing the caret.
1804void wxStyledTextCtrl::LineDelete() {
1805 SendMsg(2338, 0, 0);
1806}
1807
1808// Switch the current line with the previous.
1809void wxStyledTextCtrl::LineTranspose() {
1810 SendMsg(2339, 0, 0);
1811}
1812
9e730a78
RD
1813// Duplicate the current line.
1814void wxStyledTextCtrl::LineDuplicate() {
1815 SendMsg(2404, 0, 0);
1816}
1817
c26dba42
RD
1818// Transform the selection to lower case.
1819void wxStyledTextCtrl::LowerCase() {
1820 SendMsg(2340, 0, 0);
1821}
1822
1823// Transform the selection to upper case.
1824void wxStyledTextCtrl::UpperCase() {
1825 SendMsg(2341, 0, 0);
1826}
1827
1828// Scroll the document down, keeping the caret visible.
1829void wxStyledTextCtrl::LineScrollDown() {
1830 SendMsg(2342, 0, 0);
1831}
1832
1833// Scroll the document up, keeping the caret visible.
1834void wxStyledTextCtrl::LineScrollUp() {
1835 SendMsg(2343, 0, 0);
1836}
1837
1838// Delete the selection or if no selection, the character before the caret.
1839// Will not delete the character before at the start of a line.
1840void wxStyledTextCtrl::DeleteBackNotLine() {
1841 SendMsg(2344, 0, 0);
1842}
1843
f114b858
RD
1844// Move caret to first position on display line.
1845void wxStyledTextCtrl::HomeDisplay() {
1846 SendMsg(2345, 0, 0);
1847}
1848
2b5f62a0 1849// Move caret to first position on display line extending selection to
f114b858
RD
1850// new caret position.
1851void wxStyledTextCtrl::HomeDisplayExtend() {
1852 SendMsg(2346, 0, 0);
1853}
1854
1855// Move caret to last position on display line.
1856void wxStyledTextCtrl::LineEndDisplay() {
1857 SendMsg(2347, 0, 0);
1858}
1859
2b5f62a0 1860// Move caret to last position on display line extending selection to new
f114b858
RD
1861// caret position.
1862void wxStyledTextCtrl::LineEndDisplayExtend() {
1863 SendMsg(2348, 0, 0);
1864}
1865
c26dba42
RD
1866// These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1867// except they behave differently when word-wrap is enabled:
1868// They go first to the start / end of the display line, like (Home|LineEnd)Display
1869// The difference is that, the cursor is already at the point, it goes on to the start
1870// or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1871void wxStyledTextCtrl::HomeWrap() {
1872 SendMsg(2349, 0, 0);
1873}
1874void wxStyledTextCtrl::HomeWrapExtend() {
1875 SendMsg(2450, 0, 0);
1876}
1877void wxStyledTextCtrl::LineEndWrap() {
1878 SendMsg(2451, 0, 0);
1879}
1880void wxStyledTextCtrl::LineEndWrapExtend() {
1881 SendMsg(2452, 0, 0);
1882}
1883void wxStyledTextCtrl::VCHomeWrap() {
1884 SendMsg(2453, 0, 0);
1885}
1886void wxStyledTextCtrl::VCHomeWrapExtend() {
1887 SendMsg(2454, 0, 0);
1888}
1889
e14d10b0
RD
1890// Copy the line containing the caret.
1891void wxStyledTextCtrl::LineCopy() {
1892 SendMsg(2455, 0, 0);
1893}
1894
a834585d 1895// Move the caret inside current view if it's not there already.
65ec6247
RD
1896void wxStyledTextCtrl::MoveCaretInsideView() {
1897 SendMsg(2401, 0, 0);
1898}
1899
a834585d 1900// How many characters are on a line, not including end of line characters?
4370573a
RD
1901int wxStyledTextCtrl::LineLength(int line) {
1902 return SendMsg(2350, line, 0);
1903}
9ce192d4 1904
4370573a
RD
1905// Highlight the characters at two positions.
1906void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
1907 SendMsg(2351, pos1, pos2);
1908}
9ce192d4 1909
4370573a
RD
1910// Highlight the character at a position indicating there is no matching brace.
1911void wxStyledTextCtrl::BraceBadLight(int pos) {
1912 SendMsg(2352, pos, 0);
9ce192d4
RD
1913}
1914
4370573a
RD
1915// Find the position of a matching brace or INVALID_POSITION if no match.
1916int wxStyledTextCtrl::BraceMatch(int pos) {
1917 return SendMsg(2353, pos, 0);
1918}
9ce192d4 1919
a834585d 1920// Are the end of line characters visible?
4370573a
RD
1921bool wxStyledTextCtrl::GetViewEOL() {
1922 return SendMsg(2355, 0, 0) != 0;
9ce192d4
RD
1923}
1924
a834585d 1925// Make the end of line characters visible or invisible.
4370573a
RD
1926void wxStyledTextCtrl::SetViewEOL(bool visible) {
1927 SendMsg(2356, visible, 0);
1928}
9ce192d4 1929
4370573a
RD
1930// Retrieve a pointer to the document object.
1931void* wxStyledTextCtrl::GetDocPointer() {
9e730a78 1932 return (void*)SendMsg(2357);
4370573a 1933}
67003d1a 1934
4370573a
RD
1935// Change the document object used.
1936void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
9e730a78 1937 SendMsg(2358, 0, (long)docPointer);
67003d1a
RD
1938}
1939
4370573a
RD
1940// Set which document modification events are sent to the container.
1941void wxStyledTextCtrl::SetModEventMask(int mask) {
1942 SendMsg(2359, mask, 0);
1943}
67003d1a 1944
4370573a
RD
1945// Retrieve the column number which text should be kept within.
1946int wxStyledTextCtrl::GetEdgeColumn() {
1947 return SendMsg(2360, 0, 0);
67003d1a
RD
1948}
1949
4370573a
RD
1950// Set the column number of the edge.
1951// If text goes past the edge then it is highlighted.
1952void wxStyledTextCtrl::SetEdgeColumn(int column) {
1953 SendMsg(2361, column, 0);
1954}
67003d1a 1955
4370573a
RD
1956// Retrieve the edge highlight mode.
1957int wxStyledTextCtrl::GetEdgeMode() {
1958 return SendMsg(2362, 0, 0);
67003d1a
RD
1959}
1960
4370573a
RD
1961// The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1962// goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1963void wxStyledTextCtrl::SetEdgeMode(int mode) {
1964 SendMsg(2363, mode, 0);
1965}
67003d1a 1966
4370573a
RD
1967// Retrieve the colour used in edge indication.
1968wxColour wxStyledTextCtrl::GetEdgeColour() {
1969 long c = SendMsg(2364, 0, 0);
1970 return wxColourFromLong(c);
67003d1a
RD
1971}
1972
4370573a
RD
1973// Change the colour used in edge indication.
1974void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
1975 SendMsg(2365, wxColourAsLong(edgeColour), 0);
1976}
67003d1a 1977
4370573a
RD
1978// Sets the current caret position to be the search anchor.
1979void wxStyledTextCtrl::SearchAnchor() {
1980 SendMsg(2366, 0, 0);
67003d1a
RD
1981}
1982
4370573a 1983// Find some text starting at the search anchor.
65ec6247 1984// Does not ensure the selection is visible.
4370573a 1985int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
0c5b83b0 1986 return SendMsg(2367, flags, (long)(const char*)wx2stc(text));
4370573a 1987}
67003d1a 1988
4370573a 1989// Find some text starting at the search anchor and moving backwards.
65ec6247 1990// Does not ensure the selection is visible.
4370573a 1991int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
0c5b83b0 1992 return SendMsg(2368, flags, (long)(const char*)wx2stc(text));
67003d1a
RD
1993}
1994
4370573a
RD
1995// Retrieves the number of lines completely visible.
1996int wxStyledTextCtrl::LinesOnScreen() {
1997 return SendMsg(2370, 0, 0);
67003d1a
RD
1998}
1999
4370573a
RD
2000// Set whether a pop up menu is displayed automatically when the user presses
2001// the wrong mouse button.
2002void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
2003 SendMsg(2371, allowPopUp, 0);
2004}
67003d1a 2005
a834585d 2006// Is the selection rectangular? The alternative is the more common stream selection.
4370573a
RD
2007bool wxStyledTextCtrl::SelectionIsRectangle() {
2008 return SendMsg(2372, 0, 0) != 0;
67003d1a
RD
2009}
2010
4370573a
RD
2011// Set the zoom level. This number of points is added to the size of all fonts.
2012// It may be positive to magnify or negative to reduce.
2013void wxStyledTextCtrl::SetZoom(int zoom) {
2014 SendMsg(2373, zoom, 0);
2015}
67003d1a 2016
4370573a
RD
2017// Retrieve the zoom level.
2018int wxStyledTextCtrl::GetZoom() {
2019 return SendMsg(2374, 0, 0);
67003d1a
RD
2020}
2021
4370573a
RD
2022// Create a new document object.
2023// Starts with reference count of 1 and not selected into editor.
2024void* wxStyledTextCtrl::CreateDocument() {
9e730a78 2025 return (void*)SendMsg(2375);
4370573a 2026}
67003d1a 2027
4370573a
RD
2028// Extend life of document.
2029void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
9e730a78 2030 SendMsg(2376, 0, (long)docPointer);
67003d1a
RD
2031}
2032
4370573a
RD
2033// Release a reference to the document, deleting document if it fades to black.
2034void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
9e730a78 2035 SendMsg(2377, 0, (long)docPointer);
4370573a 2036}
67003d1a 2037
4370573a
RD
2038// Get which document modification events are sent to the container.
2039int wxStyledTextCtrl::GetModEventMask() {
2040 return SendMsg(2378, 0, 0);
67003d1a
RD
2041}
2042
a834585d 2043// Change internal focus flag.
8de28db9 2044void wxStyledTextCtrl::SetSTCFocus(bool focus) {
65ec6247
RD
2045 SendMsg(2380, focus, 0);
2046}
2047
a834585d 2048// Get internal focus flag.
8de28db9 2049bool wxStyledTextCtrl::GetSTCFocus() {
65ec6247
RD
2050 return SendMsg(2381, 0, 0) != 0;
2051}
2052
a834585d 2053// Change error status - 0 = OK.
65ec6247
RD
2054void wxStyledTextCtrl::SetStatus(int statusCode) {
2055 SendMsg(2382, statusCode, 0);
2056}
2057
a834585d 2058// Get error status.
65ec6247
RD
2059int wxStyledTextCtrl::GetStatus() {
2060 return SendMsg(2383, 0, 0);
2061}
2062
a834585d 2063// Set whether the mouse is captured when its button is pressed.
65ec6247
RD
2064void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
2065 SendMsg(2384, captures, 0);
2066}
2067
a834585d 2068// Get whether mouse gets captured.
65ec6247
RD
2069bool wxStyledTextCtrl::GetMouseDownCaptures() {
2070 return SendMsg(2385, 0, 0) != 0;
2071}
2072
a834585d 2073// Sets the cursor to one of the SC_CURSOR* values.
88a8b04e 2074void wxStyledTextCtrl::SetSTCCursor(int cursorType) {
65ec6247
RD
2075 SendMsg(2386, cursorType, 0);
2076}
2077
a834585d 2078// Get cursor type.
88a8b04e 2079int wxStyledTextCtrl::GetSTCCursor() {
65ec6247
RD
2080 return SendMsg(2387, 0, 0);
2081}
2082
1a2fb4cd 2083// Change the way control characters are displayed:
a834585d 2084// If symbol is < 32, keep the drawn way, else, use the given character.
1a2fb4cd
RD
2085void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
2086 SendMsg(2388, symbol, 0);
2087}
2088
a834585d 2089// Get the way control characters are displayed.
1a2fb4cd
RD
2090int wxStyledTextCtrl::GetControlCharSymbol() {
2091 return SendMsg(2389, 0, 0);
2092}
2093
a834585d 2094// Move to the previous change in capitalisation.
65ec6247
RD
2095void wxStyledTextCtrl::WordPartLeft() {
2096 SendMsg(2390, 0, 0);
2097}
2098
a834585d
RD
2099// Move to the previous change in capitalisation extending selection
2100// to new caret position.
65ec6247
RD
2101void wxStyledTextCtrl::WordPartLeftExtend() {
2102 SendMsg(2391, 0, 0);
2103}
2104
a834585d 2105// Move to the change next in capitalisation.
65ec6247
RD
2106void wxStyledTextCtrl::WordPartRight() {
2107 SendMsg(2392, 0, 0);
2108}
2109
a834585d
RD
2110// Move to the next change in capitalisation extending selection
2111// to new caret position.
65ec6247
RD
2112void wxStyledTextCtrl::WordPartRightExtend() {
2113 SendMsg(2393, 0, 0);
2114}
2115
a834585d
RD
2116// Set the way the display area is determined when a particular line
2117// is to be moved to by Find, FindNext, GotoLine, etc.
65ec6247
RD
2118void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
2119 SendMsg(2394, visiblePolicy, visibleSlop);
2120}
2121
a834585d 2122// Delete back from the current position to the start of the line.
65ec6247
RD
2123void wxStyledTextCtrl::DelLineLeft() {
2124 SendMsg(2395, 0, 0);
2125}
2126
a834585d 2127// Delete forwards from the current position to the end of the line.
65ec6247
RD
2128void wxStyledTextCtrl::DelLineRight() {
2129 SendMsg(2396, 0, 0);
2130}
2131
a834585d 2132// Get and Set the xOffset (ie, horizonal scroll position).
1a2fb4cd
RD
2133void wxStyledTextCtrl::SetXOffset(int newOffset) {
2134 SendMsg(2397, newOffset, 0);
2135}
2136int wxStyledTextCtrl::GetXOffset() {
2137 return SendMsg(2398, 0, 0);
2138}
2139
8e54aaed 2140// Set the last x chosen value to be the caret x position.
9e730a78
RD
2141void wxStyledTextCtrl::ChooseCaretX() {
2142 SendMsg(2399, 0, 0);
2143}
2144
a834585d
RD
2145// Set the way the caret is kept visible when going sideway.
2146// The exclusion zone is given in pixels.
2147void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) {
2148 SendMsg(2402, caretPolicy, caretSlop);
2149}
2150
2151// Set the way the line the caret is on is kept visible.
2152// The exclusion zone is given in lines.
2153void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) {
2154 SendMsg(2403, caretPolicy, caretSlop);
2155}
2156
9e730a78
RD
2157// Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2158void wxStyledTextCtrl::SetPrintWrapMode(int mode) {
2159 SendMsg(2406, mode, 0);
2160}
2161
8e54aaed 2162// Is printing line wrapped?
9e730a78
RD
2163int wxStyledTextCtrl::GetPrintWrapMode() {
2164 return SendMsg(2407, 0, 0);
2165}
2166
2167// Set a fore colour for active hotspots.
2168void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) {
2169 SendMsg(2410, useSetting, wxColourAsLong(fore));
2170}
2171
2172// Set a back colour for active hotspots.
2173void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) {
2174 SendMsg(2411, useSetting, wxColourAsLong(back));
2175}
2176
2177// Enable / Disable underlining active hotspots.
2178void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) {
2179 SendMsg(2412, underline, 0);
2180}
2181
8e54aaed
RD
2182// Limit hotspots to single line so hotspots on two lines don't merge.
2183void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) {
2184 SendMsg(2421, singleLine, 0);
2185}
2186
c26dba42
RD
2187// Move caret between paragraphs (delimited by empty lines).
2188void wxStyledTextCtrl::ParaDown() {
2189 SendMsg(2413, 0, 0);
2190}
2191void wxStyledTextCtrl::ParaDownExtend() {
2192 SendMsg(2414, 0, 0);
2193}
2194void wxStyledTextCtrl::ParaUp() {
2195 SendMsg(2415, 0, 0);
2196}
2197void wxStyledTextCtrl::ParaUpExtend() {
2198 SendMsg(2416, 0, 0);
2199}
2200
e14d10b0
RD
2201// Given a valid document position, return the previous position taking code
2202// page into account. Returns 0 if passed 0.
2203int wxStyledTextCtrl::PositionBefore(int pos) {
2204 return SendMsg(2417, pos, 0);
2205}
2206
2207// Given a valid document position, return the next position taking code
2208// page into account. Maximum value returned is the last position in the document.
2209int wxStyledTextCtrl::PositionAfter(int pos) {
2210 return SendMsg(2418, pos, 0);
2211}
2212
2213// Copy a range of text to the clipboard. Positions are clipped into the document.
2214void wxStyledTextCtrl::CopyRange(int start, int end) {
2215 SendMsg(2419, start, end);
2216}
2217
2218// Copy argument text to the clipboard.
2219void wxStyledTextCtrl::CopyText(int length, const wxString& text) {
2220 SendMsg(2420, length, (long)(const char*)wx2stc(text));
2221}
2222
8e54aaed
RD
2223// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2224// by lines (SC_SEL_LINES).
2225void wxStyledTextCtrl::SetSelectionMode(int mode) {
2226 SendMsg(2422, mode, 0);
2227}
2228
2229// Get the mode of the current selection.
2230int wxStyledTextCtrl::GetSelectionMode() {
2231 return SendMsg(2423, 0, 0);
2232}
2233
2234// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2235int wxStyledTextCtrl::GetLineSelStartPosition(int line) {
2236 return SendMsg(2424, line, 0);
2237}
2238
2239// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2240int wxStyledTextCtrl::GetLineSelEndPosition(int line) {
2241 return SendMsg(2425, line, 0);
2242}
2243
c26dba42
RD
2244// Move caret down one line, extending rectangular selection to new caret position.
2245void wxStyledTextCtrl::LineDownRectExtend() {
2246 SendMsg(2426, 0, 0);
2247}
2248
2249// Move caret up one line, extending rectangular selection to new caret position.
2250void wxStyledTextCtrl::LineUpRectExtend() {
2251 SendMsg(2427, 0, 0);
2252}
2253
2254// Move caret left one character, extending rectangular selection to new caret position.
2255void wxStyledTextCtrl::CharLeftRectExtend() {
2256 SendMsg(2428, 0, 0);
2257}
2258
2259// Move caret right one character, extending rectangular selection to new caret position.
2260void wxStyledTextCtrl::CharRightRectExtend() {
2261 SendMsg(2429, 0, 0);
2262}
2263
2264// Move caret to first position on line, extending rectangular selection to new caret position.
2265void wxStyledTextCtrl::HomeRectExtend() {
2266 SendMsg(2430, 0, 0);
2267}
2268
2269// Move caret to before first visible character on line.
2270// If already there move to first character on line.
2271// In either case, extend rectangular selection to new caret position.
2272void wxStyledTextCtrl::VCHomeRectExtend() {
2273 SendMsg(2431, 0, 0);
2274}
2275
2276// Move caret to last position on line, extending rectangular selection to new caret position.
2277void wxStyledTextCtrl::LineEndRectExtend() {
2278 SendMsg(2432, 0, 0);
2279}
2280
2281// Move caret one page up, extending rectangular selection to new caret position.
2282void wxStyledTextCtrl::PageUpRectExtend() {
2283 SendMsg(2433, 0, 0);
2284}
2285
2286// Move caret one page down, extending rectangular selection to new caret position.
2287void wxStyledTextCtrl::PageDownRectExtend() {
2288 SendMsg(2434, 0, 0);
2289}
2290
2291// Move caret to top of page, or one page up if already at top of page.
2292void wxStyledTextCtrl::StutteredPageUp() {
2293 SendMsg(2435, 0, 0);
2294}
2295
2296// Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2297void wxStyledTextCtrl::StutteredPageUpExtend() {
2298 SendMsg(2436, 0, 0);
2299}
2300
2301// Move caret to bottom of page, or one page down if already at bottom of page.
2302void wxStyledTextCtrl::StutteredPageDown() {
2303 SendMsg(2437, 0, 0);
2304}
2305
2306// Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2307void wxStyledTextCtrl::StutteredPageDownExtend() {
2308 SendMsg(2438, 0, 0);
2309}
2310
2311// Move caret left one word, position cursor at end of word.
2312void wxStyledTextCtrl::WordLeftEnd() {
2313 SendMsg(2439, 0, 0);
2314}
2315
2316// Move caret left one word, position cursor at end of word, extending selection to new caret position.
2317void wxStyledTextCtrl::WordLeftEndExtend() {
2318 SendMsg(2440, 0, 0);
2319}
2320
2321// Move caret right one word, position cursor at end of word.
2322void wxStyledTextCtrl::WordRightEnd() {
2323 SendMsg(2441, 0, 0);
2324}
2325
2326// Move caret right one word, position cursor at end of word, extending selection to new caret position.
2327void wxStyledTextCtrl::WordRightEndExtend() {
2328 SendMsg(2442, 0, 0);
2329}
2330
8e54aaed
RD
2331// Set the set of characters making up whitespace for when moving or selecting by word.
2332// Should be called after SetWordChars.
2333void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) {
2334 SendMsg(2443, 0, (long)(const char*)wx2stc(characters));
2335}
2336
2337// Reset the set of characters for whitespace and word characters to the defaults.
2338void wxStyledTextCtrl::SetCharsDefault() {
2339 SendMsg(2444, 0, 0);
2340}
2341
2342// Get currently selected item position in the auto-completion list
2343int wxStyledTextCtrl::AutoCompGetCurrent() {
2344 return SendMsg(2445, 0, 0);
2345}
2346
4370573a
RD
2347// Start notifying the container of all key presses and commands.
2348void wxStyledTextCtrl::StartRecord() {
2349 SendMsg(3001, 0, 0);
2350}
67003d1a 2351
4370573a
RD
2352// Stop notifying the container of all key presses and commands.
2353void wxStyledTextCtrl::StopRecord() {
2354 SendMsg(3002, 0, 0);
67003d1a
RD
2355}
2356
4370573a
RD
2357// Set the lexing language of the document.
2358void wxStyledTextCtrl::SetLexer(int lexer) {
2359 SendMsg(4001, lexer, 0);
2360}
67003d1a 2361
4370573a
RD
2362// Retrieve the lexing language of the document.
2363int wxStyledTextCtrl::GetLexer() {
2364 return SendMsg(4002, 0, 0);
67003d1a
RD
2365}
2366
4370573a
RD
2367// Colourise a segment of the document using the current lexing language.
2368void wxStyledTextCtrl::Colourise(int start, int end) {
2369 SendMsg(4003, start, end);
2370}
67003d1a 2371
4370573a
RD
2372// Set up a value that may be used by a lexer for some optional feature.
2373void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
0c5b83b0 2374 SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value));
f6bcfd97
BP
2375}
2376
4370573a
RD
2377// Set up the key words used by the lexer.
2378void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
0c5b83b0 2379 SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords));
4370573a 2380}
f6bcfd97 2381
65ec6247
RD
2382// Set the lexing language of the document based on string name.
2383void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
0c5b83b0 2384 SendMsg(4006, 0, (long)(const char*)wx2stc(language));
65ec6247
RD
2385}
2386
4370573a 2387// END of generated section
f6bcfd97 2388//----------------------------------------------------------------------
f6bcfd97
BP
2389
2390
4370573a
RD
2391// Returns the line number of the line with the caret.
2392int wxStyledTextCtrl::GetCurrentLine() {
2393 int line = LineFromPosition(GetCurrentPos());
2394 return line;
f6bcfd97
BP
2395}
2396
2397
4370573a
RD
2398// Extract style settings from a spec-string which is composed of one or
2399// more of the following comma separated elements:
2400//
2401// bold turns on bold
2402// italic turns on italics
2403// fore:#RRGGBB sets the foreground colour
2404// back:#RRGGBB sets the background colour
2405// face:[facename] sets the font face name to use
2406// size:[num] sets the font size in points
2407// eol turns on eol filling
2408// underline turns on underlining
2409//
2410void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
2411
451c5cc7 2412 wxStringTokenizer tkz(spec, wxT(","));
4370573a
RD
2413 while (tkz.HasMoreTokens()) {
2414 wxString token = tkz.GetNextToken();
f6bcfd97 2415
4370573a
RD
2416 wxString option = token.BeforeFirst(':');
2417 wxString val = token.AfterFirst(':');
f6bcfd97 2418
451c5cc7 2419 if (option == wxT("bold"))
4370573a 2420 StyleSetBold(styleNum, true);
f6bcfd97 2421
451c5cc7 2422 else if (option == wxT("italic"))
4370573a 2423 StyleSetItalic(styleNum, true);
9ce192d4 2424
451c5cc7 2425 else if (option == wxT("underline"))
4370573a 2426 StyleSetUnderline(styleNum, true);
9ce192d4 2427
451c5cc7 2428 else if (option == wxT("eol"))
4370573a 2429 StyleSetEOLFilled(styleNum, true);
9ce192d4 2430
451c5cc7 2431 else if (option == wxT("size")) {
4370573a
RD
2432 long points;
2433 if (val.ToLong(&points))
2434 StyleSetSize(styleNum, points);
2435 }
9ce192d4 2436
451c5cc7 2437 else if (option == wxT("face"))
4370573a 2438 StyleSetFaceName(styleNum, val);
9ce192d4 2439
451c5cc7 2440 else if (option == wxT("fore"))
4370573a 2441 StyleSetForeground(styleNum, wxColourFromSpec(val));
9ce192d4 2442
451c5cc7 2443 else if (option == wxT("back"))
4370573a
RD
2444 StyleSetBackground(styleNum, wxColourFromSpec(val));
2445 }
9ce192d4
RD
2446}
2447
2448
4370573a
RD
2449// Set style size, face, bold, italic, and underline attributes from
2450// a wxFont's attributes.
2451void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
7475e814
RD
2452#ifdef __WXGTK__
2453 // Ensure that the native font is initialized
2454 int x, y;
2455 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
2456#endif
4370573a
RD
2457 int size = font.GetPointSize();
2458 wxString faceName = font.GetFaceName();
2459 bool bold = font.GetWeight() == wxBOLD;
2460 bool italic = font.GetStyle() != wxNORMAL;
2461 bool under = font.GetUnderlined();
9ce192d4 2462
4370573a
RD
2463 // TODO: add encoding/charset mapping
2464 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
9ce192d4
RD
2465}
2466
4370573a
RD
2467// Set all font style attributes at once.
2468void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
2469 const wxString& faceName,
2470 bool bold, bool italic,
2471 bool underline) {
2472 StyleSetSize(styleNum, size);
2473 StyleSetFaceName(styleNum, faceName);
2474 StyleSetBold(styleNum, bold);
2475 StyleSetItalic(styleNum, italic);
2476 StyleSetUnderline(styleNum, underline);
9ce192d4 2477
4370573a 2478 // TODO: add encoding/charset mapping
9ce192d4
RD
2479}
2480
2481
4370573a
RD
2482// Perform one of the operations defined by the wxSTC_CMD_* constants.
2483void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
2484 SendMsg(cmd);
9ce192d4
RD
2485}
2486
2487
4370573a
RD
2488// Set the left and right margin in the edit area, measured in pixels.
2489void wxStyledTextCtrl::SetMargins(int left, int right) {
2490 SetMarginLeft(left);
2491 SetMarginRight(right);
9ce192d4
RD
2492}
2493
2494
4370573a
RD
2495// Retrieve the start and end positions of the current selection.
2496void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
2497 if (startPos != NULL)
2498 *startPos = SendMsg(SCI_GETSELECTIONSTART);
2499 if (endPos != NULL)
2500 *endPos = SendMsg(SCI_GETSELECTIONEND);
9ce192d4
RD
2501}
2502
2503
4370573a
RD
2504// Retrieve the point in the window where a position is displayed.
2505wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
2506 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
2507 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
2508 return wxPoint(x, y);
f6bcfd97
BP
2509}
2510
f97d84a6
RD
2511// Scroll enough to make the given line visible
2512void wxStyledTextCtrl::ScrollToLine(int line) {
2513 m_swx->DoScrollToLine(line);
2514}
2515
2516
2517// Scroll enough to make the given column visible
2518void wxStyledTextCtrl::ScrollToColumn(int column) {
2519 m_swx->DoScrollToColumn(column);
2520}
2521
f6bcfd97 2522
51566b0b
RD
2523bool wxStyledTextCtrl::SaveFile(const wxString& filename)
2524{
2525 wxFile file(filename, wxFile::write);
2526
2527 if (!file.IsOpened())
2528 return FALSE;
2529
88a8b04e 2530 bool success = file.Write(GetText(), *wxConvCurrent);
51566b0b 2531
4a65f2c8 2532 if (success)
51566b0b 2533 SetSavePoint();
4a65f2c8 2534
51566b0b
RD
2535 return success;
2536}
2537
2538bool wxStyledTextCtrl::LoadFile(const wxString& filename)
2539{
041973c5 2540 bool success = false;
51566b0b
RD
2541 wxFile file(filename, wxFile::read);
2542
041973c5 2543 if (file.IsOpened())
51566b0b 2544 {
041973c5
RD
2545 wxString contents;
2546 off_t len = file.Length();
041973c5
RD
2547 if (len > 0)
2548 {
1e545382 2549#if wxUSE_UNICODE
1c26fbe0 2550 wxMemoryBuffer buffer(len+1);
8e5ec9cc 2551 success = (file.Read(buffer.GetData(), len) == len);
9efe0302
RD
2552 if (success) {
2553 ((char*)buffer.GetData())[len] = 0;
2554 contents = wxString(buffer, *wxConvCurrent, len);
2555 }
88a8b04e 2556#else
8e5ec9cc
MB
2557 wxString buffer;
2558 success = (file.Read(wxStringBuffer(buffer, len), len) == len);
88a8b04e
RD
2559 contents = buffer;
2560#endif
041973c5
RD
2561 }
2562 else
2563 success = true; // empty file is ok
2564
2565 if (success)
2566 {
2567 SetText(contents);
2568 EmptyUndoBuffer();
2569 SetSavePoint();
2570 }
51566b0b
RD
2571 }
2572
2573 return success;
2574}
2575
d25f5fbb 2576
2fcce896 2577#if wxUSE_DRAG_AND_DROP
4a65f2c8
RD
2578wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
2579 return m_swx->DoDragOver(x, y, def);
2580}
2581
2582
2583bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
2584 return m_swx->DoDropText(x, y, data);
2585}
2fcce896 2586#endif
4a65f2c8
RD
2587
2588
d1558f3d
RD
2589void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
2590 m_swx->SetUseAntiAliasing(useAA);
2591}
2592
2593bool wxStyledTextCtrl::GetUseAntiAliasing() {
2594 return m_swx->GetUseAntiAliasing();
2595}
2596
9ce192d4
RD
2597//----------------------------------------------------------------------
2598// Event handlers
2599
88a8b04e 2600void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
9ce192d4 2601 wxPaintDC dc(this);
9e730a78 2602 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
9ce192d4
RD
2603}
2604
2605void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
2606 if (evt.GetOrientation() == wxHORIZONTAL)
2607 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
2608 else
2609 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
2610}
2611
5fa4613c
RD
2612void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
2613 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
2614 if (sb) {
2615 if (sb->IsVertical())
2616 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
2617 else
2618 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
2619 }
2620}
2621
88a8b04e 2622void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
39c0acb6
RD
2623 if (m_swx) {
2624 wxSize sz = GetClientSize();
2625 m_swx->DoSize(sz.x, sz.y);
2626 }
9ce192d4
RD
2627}
2628
2629void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
cb1871ca 2630 SetFocus();
9ce192d4 2631 wxPoint pt = evt.GetPosition();
2b5f62a0 2632 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
9ce192d4
RD
2633 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
2634}
2635
2636void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
2637 wxPoint pt = evt.GetPosition();
2b5f62a0 2638 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
9ce192d4
RD
2639}
2640
2641void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
2642 wxPoint pt = evt.GetPosition();
2b5f62a0 2643 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
9ce192d4
RD
2644 evt.ControlDown());
2645}
2646
2647
ddf2da08
RD
2648void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
2649 wxPoint pt = evt.GetPosition();
2650 m_swx->DoContextMenu(Point(pt.x, pt.y));
2651}
2652
2653
2b5f62a0
VZ
2654void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
2655 wxPoint pt = evt.GetPosition();
2656 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
2657}
2658
65ec6247 2659void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
9ce192d4 2660 wxPoint pt = evt.GetPosition();
65ec6247 2661 ScreenToClient(&pt.x, &pt.y);
25484746
RD
2662 /*
2663 Show context menu at event point if it's within the window,
2664 or at caret location if not
2665 */
2666 wxHitTest ht = this->HitTest(pt);
2667 if (ht != wxHT_WINDOW_INSIDE) {
2668 pt = this->PointFromPosition(this->GetCurrentPos());
2669 }
9ce192d4
RD
2670 m_swx->DoContextMenu(Point(pt.x, pt.y));
2671}
2672
37d62433
RD
2673
2674void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
2675 m_swx->DoMouseWheel(evt.GetWheelRotation(),
2676 evt.GetWheelDelta(),
65ec6247 2677 evt.GetLinesPerAction(),
9b9337da
RD
2678 evt.ControlDown(),
2679 evt.IsPageScroll());
37d62433
RD
2680}
2681
2682
9ce192d4 2683void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
f3c2c221
RD
2684 // On (some?) non-US keyboards the AltGr key is required to enter some
2685 // common characters. It comes to us as both Alt and Ctrl down so we need
2686 // to let the char through in that case, otherwise if only ctrl or only
2687 // alt let's skip it.
2688 bool ctrl = evt.ControlDown();
2689 bool alt = evt.AltDown();
00c64037 2690 bool skip = ((ctrl || alt) && ! (ctrl && alt));
f3c2c221 2691
2b5f62a0
VZ
2692 int key = evt.GetKeyCode();
2693
0f9479da
RD
2694// printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
2695// key, m_lastKeyDownConsumed, ctrl, alt, skip);
10ef30eb 2696
25484746 2697 if ( (key <= WXK_START || key > WXK_COMMAND) &&
2b5f62a0 2698 !m_lastKeyDownConsumed && !skip) {
d25f5fbb 2699 m_swx->DoAddChar(key);
f3c2c221 2700 return;
d25f5fbb 2701 }
f3c2c221 2702 evt.Skip();
f6bcfd97
BP
2703}
2704
d6582821 2705
f6bcfd97 2706void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
10ef30eb 2707 int key = evt.GetKeyCode();
f3c2c221 2708 bool shift = evt.ShiftDown(),
10ef30eb 2709 ctrl = evt.ControlDown(),
88a8b04e
RD
2710 alt = evt.AltDown(),
2711 meta = evt.MetaDown();
f3c2c221 2712
88a8b04e 2713 int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, meta, &m_lastKeyDownConsumed);
f3c2c221 2714
0f9479da
RD
2715// printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
2716// key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
f3c2c221 2717
d6582821 2718 if (!processed && !m_lastKeyDownConsumed)
9ce192d4
RD
2719 evt.Skip();
2720}
2721
d6582821 2722
b6bfd8e8 2723void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
9ce192d4 2724 m_swx->DoLoseFocus();
b6bfd8e8 2725 evt.Skip();
9ce192d4
RD
2726}
2727
d6582821 2728
b6bfd8e8 2729void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
9ce192d4 2730 m_swx->DoGainFocus();
b6bfd8e8 2731 evt.Skip();
9ce192d4
RD
2732}
2733
d6582821 2734
88a8b04e 2735void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
9ce192d4
RD
2736 m_swx->DoSysColourChange();
2737}
2738
d6582821 2739
88a8b04e 2740void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
9ce192d4
RD
2741 // do nothing to help avoid flashing
2742}
2743
2744
2745
2746void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
2747 m_swx->DoCommand(evt.GetId());
2748}
2749
2750
88a8b04e 2751void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
f6bcfd97
BP
2752 m_swx->DoOnListBox();
2753}
2754
2755
8e54aaed
RD
2756void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
2757 m_swx->DoOnIdle(evt);
2758}
2759
2760
9ce192d4
RD
2761//----------------------------------------------------------------------
2762// Turn notifications from Scintilla into events
2763
f6bcfd97 2764
9ce192d4
RD
2765void wxStyledTextCtrl::NotifyChange() {
2766 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
a29a241f 2767 evt.SetEventObject(this);
9ce192d4
RD
2768 GetEventHandler()->ProcessEvent(evt);
2769}
2770
2b5f62a0
VZ
2771
2772static void SetEventText(wxStyledTextEvent& evt, const char* text,
2773 size_t length) {
2774 if(!text) return;
2775
2776 // The unicode conversion MUST have a null byte to terminate the
2777 // string so move it into a buffer first and give it one.
2778 wxMemoryBuffer buf(length+1);
2779 buf.AppendData((void*)text, length);
2780 buf.AppendByte(0);
2781 evt.SetText(stc2wx(buf));
2782}
2783
2784
9ce192d4
RD
2785void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
2786 SCNotification& scn = *_scn;
65ec6247
RD
2787 wxStyledTextEvent evt(0, GetId());
2788
a29a241f 2789 evt.SetEventObject(this);
65ec6247
RD
2790 evt.SetPosition(scn.position);
2791 evt.SetKey(scn.ch);
2792 evt.SetModifiers(scn.modifiers);
2793
9ce192d4
RD
2794 switch (scn.nmhdr.code) {
2795 case SCN_STYLENEEDED:
65ec6247 2796 evt.SetEventType(wxEVT_STC_STYLENEEDED);
9ce192d4 2797 break;
65ec6247 2798
9ce192d4 2799 case SCN_CHARADDED:
65ec6247 2800 evt.SetEventType(wxEVT_STC_CHARADDED);
9ce192d4 2801 break;
65ec6247 2802
9ce192d4 2803 case SCN_SAVEPOINTREACHED:
65ec6247 2804 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
9ce192d4 2805 break;
65ec6247 2806
9ce192d4 2807 case SCN_SAVEPOINTLEFT:
65ec6247 2808 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
9ce192d4 2809 break;
65ec6247 2810
9ce192d4 2811 case SCN_MODIFYATTEMPTRO:
65ec6247 2812 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
9ce192d4 2813 break;
65ec6247
RD
2814
2815 case SCN_KEY:
2816 evt.SetEventType(wxEVT_STC_KEY);
2817 break;
2818
9ce192d4 2819 case SCN_DOUBLECLICK:
65ec6247 2820 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
9ce192d4 2821 break;
65ec6247
RD
2822
2823 case SCN_UPDATEUI:
2824 evt.SetEventType(wxEVT_STC_UPDATEUI);
9ce192d4 2825 break;
65ec6247
RD
2826
2827 case SCN_MODIFIED:
2828 evt.SetEventType(wxEVT_STC_MODIFIED);
2829 evt.SetModificationType(scn.modificationType);
2b5f62a0 2830 SetEventText(evt, scn.text, scn.length);
65ec6247
RD
2831 evt.SetLength(scn.length);
2832 evt.SetLinesAdded(scn.linesAdded);
2833 evt.SetLine(scn.line);
2834 evt.SetFoldLevelNow(scn.foldLevelNow);
2835 evt.SetFoldLevelPrev(scn.foldLevelPrev);
9ce192d4 2836 break;
65ec6247 2837
9ce192d4 2838 case SCN_MACRORECORD:
65ec6247
RD
2839 evt.SetEventType(wxEVT_STC_MACRORECORD);
2840 evt.SetMessage(scn.message);
2841 evt.SetWParam(scn.wParam);
2842 evt.SetLParam(scn.lParam);
9ce192d4 2843 break;
65ec6247 2844
9ce192d4 2845 case SCN_MARGINCLICK:
65ec6247
RD
2846 evt.SetEventType(wxEVT_STC_MARGINCLICK);
2847 evt.SetMargin(scn.margin);
9ce192d4 2848 break;
65ec6247 2849
9ce192d4 2850 case SCN_NEEDSHOWN:
65ec6247
RD
2851 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
2852 evt.SetLength(scn.length);
9ce192d4 2853 break;
65ec6247 2854
65ec6247
RD
2855 case SCN_PAINTED:
2856 evt.SetEventType(wxEVT_STC_PAINTED);
2857 break;
2858
2859 case SCN_USERLISTSELECTION:
2860 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
2861 evt.SetListType(scn.listType);
2b5f62a0 2862 SetEventText(evt, scn.text, strlen(scn.text));
65ec6247
RD
2863 break;
2864
2865 case SCN_URIDROPPED:
2866 evt.SetEventType(wxEVT_STC_URIDROPPED);
2b5f62a0 2867 SetEventText(evt, scn.text, strlen(scn.text));
65ec6247
RD
2868 break;
2869
2870 case SCN_DWELLSTART:
2871 evt.SetEventType(wxEVT_STC_DWELLSTART);
2872 evt.SetX(scn.x);
2873 evt.SetY(scn.y);
2874 break;
2875
2876 case SCN_DWELLEND:
2877 evt.SetEventType(wxEVT_STC_DWELLEND);
2878 evt.SetX(scn.x);
2879 evt.SetY(scn.y);
2880 break;
2881
a834585d
RD
2882 case SCN_ZOOM:
2883 evt.SetEventType(wxEVT_STC_ZOOM);
2884 break;
2885
9e730a78
RD
2886 case SCN_HOTSPOTCLICK:
2887 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
2888 break;
2889
2890 case SCN_HOTSPOTDOUBLECLICK:
2891 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
2892 break;
2893
2894 case SCN_CALLTIPCLICK:
2895 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
2896 break;
2897
65ec6247
RD
2898 default:
2899 return;
9ce192d4 2900 }
65ec6247
RD
2901
2902 GetEventHandler()->ProcessEvent(evt);
9ce192d4
RD
2903}
2904
2905
9ce192d4
RD
2906//----------------------------------------------------------------------
2907//----------------------------------------------------------------------
2908//----------------------------------------------------------------------
2909
2910wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
2911 : wxCommandEvent(commandType, id)
2912{
2913 m_position = 0;
2914 m_key = 0;
2915 m_modifiers = 0;
2916 m_modificationType = 0;
2917 m_length = 0;
2918 m_linesAdded = 0;
2919 m_line = 0;
2920 m_foldLevelNow = 0;
2921 m_foldLevelPrev = 0;
2922 m_margin = 0;
2923 m_message = 0;
2924 m_wParam = 0;
2925 m_lParam = 0;
65ec6247
RD
2926 m_listType = 0;
2927 m_x = 0;
2928 m_y = 0;
a29a241f 2929 m_dragAllowMove = FALSE;
92bbd64f 2930#if wxUSE_DRAG_AND_DROP
a29a241f 2931 m_dragResult = wxDragNone;
92bbd64f 2932#endif
9ce192d4
RD
2933}
2934
2935bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
2936bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
2937bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
2938
5fa4613c 2939
41286fd1
JS
2940wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
2941 wxCommandEvent(event)
2942{
2943 m_position = event.m_position;
2944 m_key = event.m_key;
2945 m_modifiers = event.m_modifiers;
2946 m_modificationType = event.m_modificationType;
2947 m_text = event.m_text;
2948 m_length = event.m_length;
2949 m_linesAdded = event.m_linesAdded;
2950 m_line = event.m_line;
2951 m_foldLevelNow = event.m_foldLevelNow;
2952 m_foldLevelPrev = event.m_foldLevelPrev;
2953
2954 m_margin = event.m_margin;
2955
2956 m_message = event.m_message;
2957 m_wParam = event.m_wParam;
2958 m_lParam = event.m_lParam;
2959
2960 m_listType = event.m_listType;
2961 m_x = event.m_x;
2962 m_y = event.m_y;
9ce192d4 2963
41286fd1
JS
2964 m_dragText = event.m_dragText;
2965 m_dragAllowMove =event.m_dragAllowMove;
92bbd64f 2966#if wxUSE_DRAG_AND_DROP
41286fd1 2967 m_dragResult = event.m_dragResult;
92bbd64f 2968#endif
9ce192d4
RD
2969}
2970
2971//----------------------------------------------------------------------
2972//----------------------------------------------------------------------
2973
a29a241f
RD
2974
2975
2976
5fa4613c
RD
2977
2978
2979
2980
2981