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