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