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