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