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