]> git.saurik.com Git - wxWidgets.git/blame - src/stc/stc.cpp
#9675: wxDataViewModel::Reset() and scrollbar problem (wxMac)
[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
a5c2ccf2
VZ
18/*
19 IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from
20 src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be
21 lost after the next regeneration, edit stc.cpp.in and rerun the
22 gen_iface.py script instead!
23
24 Parts of this file generated by the script are found in between
25 the special "{{{" and "}}}" markers, the rest of it is copied
26 verbatim from src.h.in.
27 */
28
54429bb3
RD
29// For compilers that support precompilation, includes "wx.h".
30#include "wx/wxprec.h"
31
32#ifdef __BORLANDC__
33 #pragma hdrstop
34#endif
35
29825f5f
PC
36#if wxUSE_STC
37
38#include "wx/stc/stc.h"
ea88e9bc 39#include "wx/stc/private.h"
54429bb3
RD
40
41#ifndef WX_PRECOMP
29825f5f 42 #include "wx/wx.h"
54429bb3
RD
43#endif // WX_PRECOMP
44
f6bcfd97
BP
45#include <ctype.h>
46
d6655166
WS
47#include "wx/tokenzr.h"
48#include "wx/mstream.h"
49#include "wx/image.h"
50#include "wx/file.h"
9ce192d4 51
f9ee2e27 52#include "ScintillaWX.h"
f6bcfd97 53
9ce192d4
RD
54//----------------------------------------------------------------------
55
10ef30eb 56const wxChar* wxSTCNameStr = wxT("stcwindow");
9ce192d4 57
451c5cc7
RD
58#ifdef MAKELONG
59#undef MAKELONG
60#endif
61
62#define MAKELONG(a, b) ((a) | ((b) << 16))
63
64
65static long wxColourAsLong(const wxColour& co) {
66 return (((long)co.Blue() << 16) |
67 ((long)co.Green() << 8) |
68 ((long)co.Red()));
69}
70
71static wxColour wxColourFromLong(long c) {
72 wxColour clr;
c8b75e94
WS
73 clr.Set((unsigned char)(c & 0xff),
74 (unsigned char)((c >> 8) & 0xff),
75 (unsigned char)((c >> 16) & 0xff));
451c5cc7
RD
76 return clr;
77}
78
79
80static wxColour wxColourFromSpec(const wxString& spec) {
5ee1d760
RD
81 // spec should be a colour name or "#RRGGBB"
82 if (spec.GetChar(0) == wxT('#')) {
7e126a07 83
5ee1d760
RD
84 long red, green, blue;
85 red = green = blue = 0;
86 spec.Mid(1,2).ToLong(&red, 16);
87 spec.Mid(3,2).ToLong(&green, 16);
88 spec.Mid(5,2).ToLong(&blue, 16);
c8b75e94
WS
89 return wxColour((unsigned char)red,
90 (unsigned char)green,
91 (unsigned char)blue);
5ee1d760
RD
92 }
93 else
94 return wxColour(spec);
451c5cc7
RD
95}
96
97//----------------------------------------------------------------------
98
d25f5fbb
RD
99DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
100DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
101DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
d25f5fbb
RD
102DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
103DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
104DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
65ec6247 105DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
d25f5fbb 106DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
65ec6247 107DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
d25f5fbb 108DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
d25f5fbb
RD
109DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
110DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
111DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
65ec6247
RD
112DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
113DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
114DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
115DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
116DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
a29a241f
RD
117DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
118DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
119DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
a834585d 120DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM )
9e730a78
RD
121DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
122DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
123DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
7e0c58e9
RD
124DEFINE_EVENT_TYPE( wxEVT_STC_AUTOCOMP_SELECTION )
125DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_CLICK )
126DEFINE_EVENT_TYPE( wxEVT_STC_INDICATOR_RELEASE )
9e730a78 127
d25f5fbb
RD
128
129
9ce192d4
RD
130BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
131 EVT_PAINT (wxStyledTextCtrl::OnPaint)
132 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
5fa4613c 133 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
9ce192d4
RD
134 EVT_SIZE (wxStyledTextCtrl::OnSize)
135 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
4ceb1196
RD
136 // Let Scintilla see the double click as a second click
137 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
9ce192d4
RD
138 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
139 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
451c5cc7 140#if defined(__WXGTK__) || defined(__WXMAC__)
ddf2da08
RD
141 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
142#else
65ec6247 143 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
ddf2da08 144#endif
37d62433 145 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
2b5f62a0 146 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
9ce192d4 147 EVT_CHAR (wxStyledTextCtrl::OnChar)
f6bcfd97 148 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
9ce192d4
RD
149 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
150 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
151 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
152 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
dd4aa550 153 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
7e126a07 154 EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
9ce192d4
RD
155END_EVENT_TABLE()
156
f6bcfd97
BP
157
158IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
159IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
160
40716a51 161#ifdef LINK_LEXERS
1a2fb4cd 162// forces the linking of the lexer modules
a834585d 163int Scintilla_LinkLexers();
40716a51 164#endif
1a2fb4cd 165
9ce192d4
RD
166//----------------------------------------------------------------------
167// Constructor and Destructor
168
169wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
170 wxWindowID id,
171 const wxPoint& pos,
172 const wxSize& size,
173 long style,
39c0acb6
RD
174 const wxString& name)
175{
176 m_swx = NULL;
177 Create(parent, id, pos, size, style, name);
178}
179
180
a48cb415
RD
181bool wxStyledTextCtrl::Create(wxWindow *parent,
182 wxWindowID id,
183 const wxPoint& pos,
184 const wxSize& size,
185 long style,
186 const wxString& name)
9ce192d4 187{
2659dad3 188 style |= wxVSCROLL | wxHSCROLL;
a48cb415
RD
189 if (!wxControl::Create(parent, id, pos, size,
190 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
191 wxDefaultValidator, name))
192 return false;
39c0acb6 193
40716a51 194#ifdef LINK_LEXERS
a834585d 195 Scintilla_LinkLexers();
40716a51 196#endif
9ce192d4 197 m_swx = new ScintillaWX(this);
9ce192d4 198 m_stopWatch.Start();
7e126a07 199 m_lastKeyDownConsumed = false;
60957703 200 m_lastWheelTimestamp = 0;
5fa4613c
RD
201 m_vScrollBar = NULL;
202 m_hScrollBar = NULL;
10ef30eb
RD
203#if wxUSE_UNICODE
204 // Put Scintilla into unicode (UTF-8) mode
205 SetCodePage(wxSTC_CP_UTF8);
206#endif
8ae4f086 207
170acdc9 208 SetInitialSize(size);
f9ee2e27 209
be108f96
JS
210 // Reduces flicker on GTK+/X11
211 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
439cce14
RD
212
213 // Make sure it can take the focus
214 SetCanFocus(true);
215
a48cb415 216 return true;
9ce192d4
RD
217}
218
219
220wxStyledTextCtrl::~wxStyledTextCtrl() {
221 delete m_swx;
9ce192d4
RD
222}
223
224
225//----------------------------------------------------------------------
226
fafd43c5 227wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const
8e0945da 228{
9ce192d4
RD
229 return m_swx->WndProc(msg, wp, lp);
230}
231
ccfc3219
RD
232//----------------------------------------------------------------------
233
234// Set the vertical scrollbar to use instead of the ont that's built-in.
235void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
236 m_vScrollBar = bar;
237 if (bar != NULL) {
238 // ensure that the built-in scrollbar is not visible
239 SetScrollbar(wxVERTICAL, 0, 0, 0);
240 }
241}
9ce192d4 242
9ce192d4 243
ccfc3219
RD
244// Set the horizontal scrollbar to use instead of the ont that's built-in.
245void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
246 m_hScrollBar = bar;
247 if (bar != NULL) {
248 // ensure that the built-in scrollbar is not visible
249 SetScrollbar(wxHORIZONTAL, 0, 0, 0);
250 }
251}
252
4370573a 253//----------------------------------------------------------------------
a5c2ccf2 254// Generated methods implementation section {{{
9ce192d4
RD
255
256
591d01be 257// Add text to the document at current position.
9ce192d4 258void wxStyledTextCtrl::AddText(const wxString& text) {
0c5b83b0 259 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
b796ba39 260 SendMsg(2001, strlen(buf), (sptr_t)(const char*)buf);
9ce192d4
RD
261}
262
a834585d 263// Add array of cells to document.
10ef30eb 264void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
b796ba39 265 SendMsg(2002, data.GetDataLen(), (sptr_t)data.GetData());
9ce192d4
RD
266}
267
a834585d 268// Insert string at a position.
8e0945da
VZ
269void wxStyledTextCtrl::InsertText(int pos, const wxString& text)
270{
b796ba39 271 SendMsg(2003, pos, (sptr_t)(const char*)wx2stc(text));
9ce192d4
RD
272}
273
a834585d 274// Delete all text in the document.
8e0945da
VZ
275void wxStyledTextCtrl::ClearAll()
276{
4370573a 277 SendMsg(2004, 0, 0);
9ce192d4
RD
278}
279
a834585d 280// Set all style bytes to 0, remove all folding information.
8e0945da
VZ
281void wxStyledTextCtrl::ClearDocumentStyle()
282{
4370573a 283 SendMsg(2005, 0, 0);
9ce192d4
RD
284}
285
591d01be 286// Returns the number of characters in the document.
8e0945da
VZ
287int wxStyledTextCtrl::GetLength() const
288{
4370573a 289 return SendMsg(2006, 0, 0);
9ce192d4
RD
290}
291
a834585d 292// Returns the character byte at the position.
8e0945da 293int wxStyledTextCtrl::GetCharAt(int pos) const {
9e730a78 294 return (unsigned char)SendMsg(2007, pos, 0);
9ce192d4
RD
295}
296
a834585d 297// Returns the position of the caret.
8e0945da
VZ
298int wxStyledTextCtrl::GetCurrentPos() const
299{
4370573a 300 return SendMsg(2008, 0, 0);
9ce192d4
RD
301}
302
a834585d 303// Returns the position of the opposite end of the selection to the caret.
8e0945da
VZ
304int wxStyledTextCtrl::GetAnchor() const
305{
4370573a 306 return SendMsg(2009, 0, 0);
9ce192d4
RD
307}
308
a834585d 309// Returns the style byte at the position.
8e0945da 310int wxStyledTextCtrl::GetStyleAt(int pos) const {
9e730a78 311 return (unsigned char)SendMsg(2010, pos, 0);
9ce192d4
RD
312}
313
a834585d 314// Redoes the next action on the undo history.
8e0945da
VZ
315void wxStyledTextCtrl::Redo()
316{
4370573a 317 SendMsg(2011, 0, 0);
9ce192d4
RD
318}
319
4370573a
RD
320// Choose between collecting actions into the undo
321// history and discarding them.
8e0945da
VZ
322void wxStyledTextCtrl::SetUndoCollection(bool collectUndo)
323{
4370573a 324 SendMsg(2012, collectUndo, 0);
9ce192d4
RD
325}
326
4370573a 327// Select all the text in the document.
8e0945da
VZ
328void wxStyledTextCtrl::SelectAll()
329{
4370573a 330 SendMsg(2013, 0, 0);
9ce192d4
RD
331}
332
4370573a
RD
333// Remember the current position in the undo history as the position
334// at which the document was saved.
8e0945da
VZ
335void wxStyledTextCtrl::SetSavePoint()
336{
4370573a 337 SendMsg(2014, 0, 0);
9ce192d4
RD
338}
339
4370573a 340// Retrieve a buffer of cells.
10ef30eb 341wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
9e730a78
RD
342 wxMemoryBuffer buf;
343 if (endPos < startPos) {
344 int temp = startPos;
345 startPos = endPos;
346 endPos = temp;
347 }
348 int len = endPos - startPos;
349 if (!len) return buf;
350 TextRange tr;
351 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
352 tr.chrg.cpMin = startPos;
353 tr.chrg.cpMax = endPos;
b796ba39 354 len = SendMsg(2015, 0, (sptr_t)&tr);
9e730a78
RD
355 buf.UngetWriteBuf(len);
356 return buf;
9ce192d4
RD
357}
358
a834585d 359// Are there any redoable actions in the undo history?
93578927 360bool wxStyledTextCtrl::CanRedo() const
8e0945da 361{
4370573a 362 return SendMsg(2016, 0, 0) != 0;
9ce192d4
RD
363}
364
a834585d 365// Retrieve the line number at which a particular marker is located.
8e0945da
VZ
366int wxStyledTextCtrl::MarkerLineFromHandle(int handle)
367{
4370573a 368 return SendMsg(2017, handle, 0);
9ce192d4
RD
369}
370
4370573a 371// Delete a marker.
8e0945da
VZ
372void wxStyledTextCtrl::MarkerDeleteHandle(int handle)
373{
4370573a 374 SendMsg(2018, handle, 0);
9ce192d4
RD
375}
376
4370573a 377// Is undo history being collected?
8e0945da
VZ
378bool wxStyledTextCtrl::GetUndoCollection() const
379{
4370573a 380 return SendMsg(2019, 0, 0) != 0;
9ce192d4
RD
381}
382
4370573a
RD
383// Are white space characters currently visible?
384// Returns one of SCWS_* constants.
8e0945da
VZ
385int wxStyledTextCtrl::GetViewWhiteSpace() const
386{
4370573a 387 return SendMsg(2020, 0, 0);
9ce192d4
RD
388}
389
4370573a 390// Make white space characters invisible, always visible or visible outside indentation.
8e0945da
VZ
391void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS)
392{
4370573a 393 SendMsg(2021, viewWS, 0);
9ce192d4
RD
394}
395
4370573a 396// Find the position from a point within the window.
2bfca191 397int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const {
9e730a78 398 return SendMsg(2022, pt.x, pt.y);
9ce192d4
RD
399}
400
65ec6247
RD
401// Find the position from a point within the window but return
402// INVALID_POSITION if not close to text.
8e0945da
VZ
403int wxStyledTextCtrl::PositionFromPointClose(int x, int y)
404{
65ec6247
RD
405 return SendMsg(2023, x, y);
406}
407
4370573a 408// Set caret to start of a line and ensure it is visible.
8e0945da
VZ
409void wxStyledTextCtrl::GotoLine(int line)
410{
4370573a 411 SendMsg(2024, line, 0);
9ce192d4
RD
412}
413
4370573a 414// Set caret to a position and ensure it is visible.
8e0945da
VZ
415void wxStyledTextCtrl::GotoPos(int pos)
416{
4370573a 417 SendMsg(2025, pos, 0);
9ce192d4
RD
418}
419
4370573a
RD
420// Set the selection anchor to a position. The anchor is the opposite
421// end of the selection from the caret.
8e0945da
VZ
422void wxStyledTextCtrl::SetAnchor(int posAnchor)
423{
4370573a 424 SendMsg(2026, posAnchor, 0);
9ce192d4
RD
425}
426
4370573a
RD
427// Retrieve the text of the line containing the caret.
428// Returns the index of the caret on the line.
429wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
9e730a78
RD
430 int len = LineLength(GetCurrentLine());
431 if (!len) {
432 if (linePos) *linePos = 0;
433 return wxEmptyString;
434 }
10ef30eb 435
9e730a78
RD
436 wxMemoryBuffer mbuf(len+1);
437 char* buf = (char*)mbuf.GetWriteBuf(len+1);
8de28db9 438
b796ba39 439 int pos = SendMsg(2027, len+1, (sptr_t)buf);
9e730a78
RD
440 mbuf.UngetWriteBuf(len);
441 mbuf.AppendByte(0);
442 if (linePos) *linePos = pos;
443 return stc2wx(buf);
9ce192d4
RD
444}
445
4370573a 446// Retrieve the position of the last correctly styled character.
8e0945da
VZ
447int wxStyledTextCtrl::GetEndStyled() const
448{
4370573a 449 return SendMsg(2028, 0, 0);
9ce192d4
RD
450}
451
65ec6247 452// Convert all line endings in the document to one mode.
8e0945da
VZ
453void wxStyledTextCtrl::ConvertEOLs(int eolMode)
454{
65ec6247 455 SendMsg(2029, eolMode, 0);
9ce192d4
RD
456}
457
4370573a 458// Retrieve the current end of line mode - one of CRLF, CR, or LF.
8e0945da
VZ
459int wxStyledTextCtrl::GetEOLMode() const
460{
4370573a 461 return SendMsg(2030, 0, 0);
9ce192d4
RD
462}
463
4370573a 464// Set the current end of line mode.
8e0945da
VZ
465void wxStyledTextCtrl::SetEOLMode(int eolMode)
466{
4370573a 467 SendMsg(2031, eolMode, 0);
9ce192d4
RD
468}
469
4370573a 470// Set the current styling position to pos and the styling mask to mask.
a834585d 471// The styling mask can be used to protect some bits in each styling byte from modification.
8e0945da
VZ
472void wxStyledTextCtrl::StartStyling(int pos, int mask)
473{
4370573a 474 SendMsg(2032, pos, mask);
9ce192d4
RD
475}
476
4370573a
RD
477// Change style from current styling position for length characters to a style
478// and move the current styling position to after this newly styled segment.
8e0945da
VZ
479void wxStyledTextCtrl::SetStyling(int length, int style)
480{
4370573a 481 SendMsg(2033, length, style);
f6bcfd97
BP
482}
483
a834585d 484// Is drawing done first into a buffer or direct to the screen?
8e0945da
VZ
485bool wxStyledTextCtrl::GetBufferedDraw() const
486{
4370573a 487 return SendMsg(2034, 0, 0) != 0;
f6bcfd97
BP
488}
489
4370573a
RD
490// If drawing is buffered then each line of text is drawn into a bitmap buffer
491// before drawing it to the screen to avoid flicker.
8e0945da
VZ
492void wxStyledTextCtrl::SetBufferedDraw(bool buffered)
493{
4370573a 494 SendMsg(2035, buffered, 0);
f6bcfd97
BP
495}
496
a834585d 497// Change the visible size of a tab to be a multiple of the width of a space character.
8e0945da
VZ
498void wxStyledTextCtrl::SetTabWidth(int tabWidth)
499{
4370573a 500 SendMsg(2036, tabWidth, 0);
f6bcfd97
BP
501}
502
4370573a 503// Retrieve the visible size of a tab.
8e0945da
VZ
504int wxStyledTextCtrl::GetTabWidth() const
505{
4370573a 506 return SendMsg(2121, 0, 0);
9ce192d4
RD
507}
508
4370573a 509// Set the code page used to interpret the bytes of the document as characters.
4370573a 510void wxStyledTextCtrl::SetCodePage(int codePage) {
10ef30eb
RD
511#if wxUSE_UNICODE
512 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
513 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
514#else
515 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
516 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
517#endif
9e730a78 518 SendMsg(2037, codePage);
9ce192d4
RD
519}
520
4370573a 521// Set the symbol used for a particular marker number,
1a2fb4cd 522// and optionally the fore and background colours.
4370573a 523void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
9e730a78
RD
524 const wxColour& foreground,
525 const wxColour& background) {
9ce192d4 526
9e730a78
RD
527 SendMsg(2040, markerNumber, markerSymbol);
528 if (foreground.Ok())
529 MarkerSetForeground(markerNumber, foreground);
530 if (background.Ok())
531 MarkerSetBackground(markerNumber, background);
9ce192d4
RD
532}
533
4370573a 534// Set the foreground colour used for a particular marker number.
8e0945da
VZ
535void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore)
536{
4370573a 537 SendMsg(2041, markerNumber, wxColourAsLong(fore));
9ce192d4
RD
538}
539
4370573a 540// Set the background colour used for a particular marker number.
8e0945da
VZ
541void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back)
542{
4370573a 543 SendMsg(2042, markerNumber, wxColourAsLong(back));
9ce192d4
RD
544}
545
1a2fb4cd 546// Add a marker to a line, returning an ID which can be used to find or delete the marker.
8e0945da
VZ
547int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber)
548{
1a2fb4cd 549 return SendMsg(2043, line, markerNumber);
9ce192d4
RD
550}
551
a834585d 552// Delete a marker from a line.
8e0945da
VZ
553void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber)
554{
4370573a 555 SendMsg(2044, line, markerNumber);
9ce192d4
RD
556}
557
a834585d 558// Delete all markers with a particular number from all lines.
8e0945da
VZ
559void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber)
560{
4370573a 561 SendMsg(2045, markerNumber, 0);
9ce192d4
RD
562}
563
4370573a 564// Get a bit mask of all the markers set on a line.
8e0945da
VZ
565int wxStyledTextCtrl::MarkerGet(int line)
566{
4370573a 567 return SendMsg(2046, line, 0);
9ce192d4
RD
568}
569
4370573a 570// Find the next line after lineStart that includes a marker in mask.
8e0945da
VZ
571int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask)
572{
4370573a 573 return SendMsg(2047, lineStart, markerMask);
9ce192d4
RD
574}
575
4370573a 576// Find the previous line before lineStart that includes a marker in mask.
8e0945da
VZ
577int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask)
578{
4370573a 579 return SendMsg(2048, lineStart, markerMask);
9ce192d4
RD
580}
581
9e730a78
RD
582// Define a marker from a bitmap
583void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
584 // convert bmp to a xpm in a string
585 wxMemoryOutputStream strm;
586 wxImage img = bmp.ConvertToImage();
e45b3f17
RD
587 if (img.HasAlpha())
588 img.ConvertAlphaToMask();
9e730a78
RD
589 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
590 size_t len = strm.GetSize();
591 char* buff = new char[len+1];
592 strm.CopyTo(buff, len);
593 buff[len] = 0;
b796ba39 594 SendMsg(2049, markerNumber, (sptr_t)buff);
9e730a78 595 delete [] buff;
a5b274d7 596
9e730a78
RD
597}
598
1e9bafca 599// Add a set of markers to a line.
8e0945da
VZ
600void wxStyledTextCtrl::MarkerAddSet(int line, int set)
601{
1e9bafca
RD
602 SendMsg(2466, line, set);
603}
604
b8193d80 605// Set the alpha used for a marker that is drawn in the text area, not the margin.
8e0945da
VZ
606void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha)
607{
b8193d80
RD
608 SendMsg(2476, markerNumber, alpha);
609}
610
4370573a 611// Set a margin to be either numeric or symbolic.
8e0945da
VZ
612void wxStyledTextCtrl::SetMarginType(int margin, int marginType)
613{
4370573a 614 SendMsg(2240, margin, marginType);
9ce192d4
RD
615}
616
4370573a 617// Retrieve the type of a margin.
8e0945da
VZ
618int wxStyledTextCtrl::GetMarginType(int margin) const
619{
4370573a 620 return SendMsg(2241, margin, 0);
9ce192d4
RD
621}
622
4370573a 623// Set the width of a margin to a width expressed in pixels.
8e0945da
VZ
624void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth)
625{
4370573a 626 SendMsg(2242, margin, pixelWidth);
9ce192d4
RD
627}
628
4370573a 629// Retrieve the width of a margin in pixels.
8e0945da
VZ
630int wxStyledTextCtrl::GetMarginWidth(int margin) const
631{
4370573a 632 return SendMsg(2243, margin, 0);
f6bcfd97
BP
633}
634
4370573a 635// Set a mask that determines which markers are displayed in a margin.
8e0945da
VZ
636void wxStyledTextCtrl::SetMarginMask(int margin, int mask)
637{
4370573a 638 SendMsg(2244, margin, mask);
f6bcfd97
BP
639}
640
4370573a 641// Retrieve the marker mask of a margin.
8e0945da
VZ
642int wxStyledTextCtrl::GetMarginMask(int margin) const
643{
4370573a 644 return SendMsg(2245, margin, 0);
9ce192d4
RD
645}
646
4370573a 647// Make a margin sensitive or insensitive to mouse clicks.
8e0945da
VZ
648void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive)
649{
4370573a 650 SendMsg(2246, margin, sensitive);
9ce192d4
RD
651}
652
4370573a 653// Retrieve the mouse click sensitivity of a margin.
8e0945da
VZ
654bool wxStyledTextCtrl::GetMarginSensitive(int margin) const
655{
4370573a 656 return SendMsg(2247, margin, 0) != 0;
9ce192d4
RD
657}
658
4370573a 659// Clear all the styles and make equivalent to the global default style.
8e0945da
VZ
660void wxStyledTextCtrl::StyleClearAll()
661{
4370573a 662 SendMsg(2050, 0, 0);
9ce192d4
RD
663}
664
4370573a 665// Set the foreground colour of a style.
8e0945da
VZ
666void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore)
667{
4370573a 668 SendMsg(2051, style, wxColourAsLong(fore));
9ce192d4
RD
669}
670
4370573a 671// Set the background colour of a style.
8e0945da
VZ
672void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back)
673{
4370573a 674 SendMsg(2052, style, wxColourAsLong(back));
9ce192d4
RD
675}
676
4370573a 677// Set a style to be bold or not.
8e0945da
VZ
678void wxStyledTextCtrl::StyleSetBold(int style, bool bold)
679{
4370573a 680 SendMsg(2053, style, bold);
9ce192d4
RD
681}
682
4370573a 683// Set a style to be italic or not.
8e0945da
VZ
684void wxStyledTextCtrl::StyleSetItalic(int style, bool italic)
685{
4370573a 686 SendMsg(2054, style, italic);
9ce192d4
RD
687}
688
4370573a 689// Set the size of characters of a style.
8e0945da
VZ
690void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints)
691{
4370573a 692 SendMsg(2055, style, sizePoints);
9ce192d4
RD
693}
694
4370573a 695// Set the font of a style.
8e0945da
VZ
696void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName)
697{
b796ba39 698 SendMsg(2056, style, (sptr_t)(const char*)wx2stc(fontName));
9ce192d4
RD
699}
700
4370573a 701// Set a style to have its end of line filled or not.
8e0945da
VZ
702void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled)
703{
4370573a 704 SendMsg(2057, style, filled);
9ce192d4
RD
705}
706
4370573a 707// Reset the default style to its state at startup
8e0945da
VZ
708void wxStyledTextCtrl::StyleResetDefault()
709{
4370573a 710 SendMsg(2058, 0, 0);
9ce192d4
RD
711}
712
4370573a 713// Set a style to be underlined or not.
8e0945da
VZ
714void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline)
715{
4370573a 716 SendMsg(2059, style, underline);
9ce192d4
RD
717}
718
7e0c58e9 719// Get the foreground colour of a style.
8e0945da
VZ
720wxColour wxStyledTextCtrl::StyleGetForeground(int style) const
721{
7e0c58e9
RD
722 long c = SendMsg(2481, style, 0);
723 return wxColourFromLong(c);
724}
725
726// Get the background colour of a style.
8e0945da
VZ
727wxColour wxStyledTextCtrl::StyleGetBackground(int style) const
728{
7e0c58e9
RD
729 long c = SendMsg(2482, style, 0);
730 return wxColourFromLong(c);
731}
732
733// Get is a style bold or not.
8e0945da
VZ
734bool wxStyledTextCtrl::StyleGetBold(int style) const
735{
7e0c58e9
RD
736 return SendMsg(2483, style, 0) != 0;
737}
738
739// Get is a style italic or not.
8e0945da
VZ
740bool wxStyledTextCtrl::StyleGetItalic(int style) const
741{
7e0c58e9
RD
742 return SendMsg(2484, style, 0) != 0;
743}
744
745// Get the size of characters of a style.
8e0945da
VZ
746int wxStyledTextCtrl::StyleGetSize(int style) const
747{
7e0c58e9
RD
748 return SendMsg(2485, style, 0);
749}
750
751// Get the font facename of a style
752wxString wxStyledTextCtrl::StyleGetFaceName(int style) {
753 long msg = 2486;
754 long len = SendMsg(msg, style, 0);
755 wxMemoryBuffer mbuf(len+1);
756 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 757 SendMsg(msg, style, (sptr_t)buf);
7e0c58e9
RD
758 mbuf.UngetWriteBuf(len);
759 mbuf.AppendByte(0);
760 return stc2wx(buf);
761}
762
763// Get is a style to have its end of line filled or not.
8e0945da
VZ
764bool wxStyledTextCtrl::StyleGetEOLFilled(int style) const
765{
7e0c58e9
RD
766 return SendMsg(2487, style, 0) != 0;
767}
768
769// Get is a style underlined or not.
8e0945da
VZ
770bool wxStyledTextCtrl::StyleGetUnderline(int style) const
771{
7e0c58e9
RD
772 return SendMsg(2488, style, 0) != 0;
773}
774
775// Get is a style mixed case, or to force upper or lower case.
8e0945da
VZ
776int wxStyledTextCtrl::StyleGetCase(int style) const
777{
7e0c58e9
RD
778 return SendMsg(2489, style, 0);
779}
780
781// Get the character set of the font in a style.
8e0945da
VZ
782int wxStyledTextCtrl::StyleGetCharacterSet(int style) const
783{
7e0c58e9
RD
784 return SendMsg(2490, style, 0);
785}
786
787// Get is a style visible or not.
8e0945da
VZ
788bool wxStyledTextCtrl::StyleGetVisible(int style) const
789{
7e0c58e9
RD
790 return SendMsg(2491, style, 0) != 0;
791}
792
793// Get is a style changeable or not (read only).
794// Experimental feature, currently buggy.
8e0945da
VZ
795bool wxStyledTextCtrl::StyleGetChangeable(int style) const
796{
7e0c58e9
RD
797 return SendMsg(2492, style, 0) != 0;
798}
799
800// Get is a style a hotspot or not.
8e0945da
VZ
801bool wxStyledTextCtrl::StyleGetHotSpot(int style) const
802{
7e0c58e9
RD
803 return SendMsg(2493, style, 0) != 0;
804}
805
65ec6247 806// Set a style to be mixed case, or to force upper or lower case.
8e0945da
VZ
807void wxStyledTextCtrl::StyleSetCase(int style, int caseForce)
808{
65ec6247
RD
809 SendMsg(2060, style, caseForce);
810}
811
9e730a78 812// Set a style to be a hotspot or not.
8e0945da
VZ
813void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot)
814{
9e730a78
RD
815 SendMsg(2409, style, hotspot);
816}
817
4370573a 818// Set the foreground colour of the selection and whether to use this setting.
8e0945da
VZ
819void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore)
820{
4370573a 821 SendMsg(2067, useSetting, wxColourAsLong(fore));
9ce192d4
RD
822}
823
4370573a 824// Set the background colour of the selection and whether to use this setting.
8e0945da
VZ
825void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back)
826{
4370573a 827 SendMsg(2068, useSetting, wxColourAsLong(back));
9ce192d4
RD
828}
829
b8193d80 830// Get the alpha of the selection.
8e0945da
VZ
831int wxStyledTextCtrl::GetSelAlpha() const
832{
b8193d80
RD
833 return SendMsg(2477, 0, 0);
834}
835
836// Set the alpha of the selection.
8e0945da
VZ
837void wxStyledTextCtrl::SetSelAlpha(int alpha)
838{
b8193d80
RD
839 SendMsg(2478, alpha, 0);
840}
841
7e0c58e9 842// Is the selection end of line filled?
8e0945da
VZ
843bool wxStyledTextCtrl::GetSelEOLFilled() const
844{
7e0c58e9
RD
845 return SendMsg(2479, 0, 0) != 0;
846}
847
848// Set the selection to have its end of line filled or not.
8e0945da
VZ
849void wxStyledTextCtrl::SetSelEOLFilled(bool filled)
850{
7e0c58e9
RD
851 SendMsg(2480, filled, 0);
852}
853
4370573a 854// Set the foreground colour of the caret.
8e0945da
VZ
855void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore)
856{
4370573a 857 SendMsg(2069, wxColourAsLong(fore), 0);
9ce192d4
RD
858}
859
4370573a
RD
860// When key+modifier combination km is pressed perform msg.
861void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
9e730a78 862 SendMsg(2070, MAKELONG(key, modifiers), cmd);
9ce192d4
RD
863}
864
8e54aaed 865// When key+modifier combination km is pressed do nothing.
4370573a 866void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
9e730a78 867 SendMsg(2071, MAKELONG(key, modifiers));
9ce192d4
RD
868}
869
4370573a 870// Drop all key mappings.
8e0945da
VZ
871void wxStyledTextCtrl::CmdKeyClearAll()
872{
4370573a
RD
873 SendMsg(2072, 0, 0);
874}
9ce192d4 875
4370573a
RD
876// Set the styles for a segment of the document.
877void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
b796ba39 878 SendMsg(2073, length, (sptr_t)styleBytes);
9ce192d4
RD
879}
880
4370573a 881// Set a style to be visible or not.
8e0945da
VZ
882void wxStyledTextCtrl::StyleSetVisible(int style, bool visible)
883{
4370573a
RD
884 SendMsg(2074, style, visible);
885}
9ce192d4 886
4370573a 887// Get the time in milliseconds that the caret is on and off.
8e0945da
VZ
888int wxStyledTextCtrl::GetCaretPeriod() const
889{
4370573a 890 return SendMsg(2075, 0, 0);
9ce192d4
RD
891}
892
4370573a 893// Get the time in milliseconds that the caret is on and off. 0 = steady on.
8e0945da
VZ
894void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds)
895{
4370573a
RD
896 SendMsg(2076, periodMilliseconds, 0);
897}
9ce192d4 898
a834585d 899// Set the set of characters making up words for when moving or selecting by word.
8e54aaed 900// First sets deaults like SetCharsDefault.
8e0945da
VZ
901void wxStyledTextCtrl::SetWordChars(const wxString& characters)
902{
b796ba39 903 SendMsg(2077, 0, (sptr_t)(const char*)wx2stc(characters));
9ce192d4
RD
904}
905
4370573a
RD
906// Start a sequence of actions that is undone and redone as a unit.
907// May be nested.
8e0945da
VZ
908void wxStyledTextCtrl::BeginUndoAction()
909{
4370573a
RD
910 SendMsg(2078, 0, 0);
911}
9ce192d4 912
4370573a 913// End a sequence of actions that is undone and redone as a unit.
8e0945da
VZ
914void wxStyledTextCtrl::EndUndoAction()
915{
4370573a
RD
916 SendMsg(2079, 0, 0);
917}
9ce192d4 918
4370573a 919// Set an indicator to plain, squiggle or TT.
8e0945da
VZ
920void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style)
921{
4370573a
RD
922 SendMsg(2080, indic, style);
923}
9ce192d4 924
4370573a 925// Retrieve the style of an indicator.
8e0945da
VZ
926int wxStyledTextCtrl::IndicatorGetStyle(int indic) const
927{
4370573a
RD
928 return SendMsg(2081, indic, 0);
929}
9ce192d4 930
4370573a 931// Set the foreground colour of an indicator.
8e0945da
VZ
932void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore)
933{
4370573a 934 SendMsg(2082, indic, wxColourAsLong(fore));
9ce192d4
RD
935}
936
4370573a 937// Retrieve the foreground colour of an indicator.
8e0945da
VZ
938wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) const
939{
4370573a
RD
940 long c = SendMsg(2083, indic, 0);
941 return wxColourFromLong(c);
942}
9ce192d4 943
7e0c58e9 944// Set an indicator to draw under text or over(default).
8e0945da
VZ
945void wxStyledTextCtrl::IndicatorSetUnder(int indic, bool under)
946{
7e0c58e9
RD
947 SendMsg(2510, indic, under);
948}
949
950// Retrieve whether indicator drawn under or over text.
8e0945da
VZ
951bool wxStyledTextCtrl::IndicatorGetUnder(int indic) const
952{
7e0c58e9
RD
953 return SendMsg(2511, indic, 0) != 0;
954}
955
f114b858 956// Set the foreground colour of all whitespace and whether to use this setting.
8e0945da
VZ
957void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore)
958{
f114b858
RD
959 SendMsg(2084, useSetting, wxColourAsLong(fore));
960}
961
962// Set the background colour of all whitespace and whether to use this setting.
8e0945da
VZ
963void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back)
964{
f114b858
RD
965 SendMsg(2085, useSetting, wxColourAsLong(back));
966}
967
a834585d
RD
968// Divide each styling byte into lexical class bits (default: 5) and indicator
969// bits (default: 3). If a lexer requires more than 32 lexical states, then this
4370573a 970// is used to expand the possible states.
8e0945da
VZ
971void wxStyledTextCtrl::SetStyleBits(int bits)
972{
4370573a 973 SendMsg(2090, bits, 0);
9ce192d4
RD
974}
975
4370573a 976// Retrieve number of bits in style bytes used to hold the lexical state.
8e0945da
VZ
977int wxStyledTextCtrl::GetStyleBits() const
978{
4370573a
RD
979 return SendMsg(2091, 0, 0);
980}
9ce192d4 981
4370573a 982// Used to hold extra styling information for each line.
8e0945da
VZ
983void wxStyledTextCtrl::SetLineState(int line, int state)
984{
4370573a 985 SendMsg(2092, line, state);
f6bcfd97
BP
986}
987
4370573a 988// Retrieve the extra styling information for a line.
8e0945da
VZ
989int wxStyledTextCtrl::GetLineState(int line) const
990{
4370573a
RD
991 return SendMsg(2093, line, 0);
992}
f6bcfd97 993
4370573a 994// Retrieve the last line number that has line state.
8e0945da
VZ
995int wxStyledTextCtrl::GetMaxLineState() const
996{
4370573a 997 return SendMsg(2094, 0, 0);
f6bcfd97
BP
998}
999
65ec6247 1000// Is the background of the line containing the caret in a different colour?
8e0945da
VZ
1001bool wxStyledTextCtrl::GetCaretLineVisible() const
1002{
65ec6247
RD
1003 return SendMsg(2095, 0, 0) != 0;
1004}
1005
a834585d 1006// Display the background of the line containing the caret in a different colour.
8e0945da
VZ
1007void wxStyledTextCtrl::SetCaretLineVisible(bool show)
1008{
65ec6247
RD
1009 SendMsg(2096, show, 0);
1010}
1011
1012// Get the colour of the background of the line containing the caret.
8e0945da
VZ
1013wxColour wxStyledTextCtrl::GetCaretLineBackground() const
1014{
65ec6247
RD
1015 long c = SendMsg(2097, 0, 0);
1016 return wxColourFromLong(c);
1017}
1018
1019// Set the colour of the background of the line containing the caret.
8e0945da
VZ
1020void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back)
1021{
65ec6247
RD
1022 SendMsg(2098, wxColourAsLong(back), 0);
1023}
1024
1a2fb4cd
RD
1025// Set a style to be changeable or not (read only).
1026// Experimental feature, currently buggy.
8e0945da
VZ
1027void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable)
1028{
1a2fb4cd
RD
1029 SendMsg(2099, style, changeable);
1030}
1031
4370573a
RD
1032// Display a auto-completion list.
1033// The lenEntered parameter indicates how many characters before
1034// the caret should be used to provide context.
8e0945da
VZ
1035void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList)
1036{
b796ba39 1037 SendMsg(2100, lenEntered, (sptr_t)(const char*)wx2stc(itemList));
4370573a 1038}
f6bcfd97 1039
4370573a 1040// Remove the auto-completion list from the screen.
8e0945da
VZ
1041void wxStyledTextCtrl::AutoCompCancel()
1042{
4370573a 1043 SendMsg(2101, 0, 0);
f6bcfd97
BP
1044}
1045
4370573a 1046// Is there an auto-completion list visible?
8e0945da
VZ
1047bool wxStyledTextCtrl::AutoCompActive()
1048{
4370573a
RD
1049 return SendMsg(2102, 0, 0) != 0;
1050}
f6bcfd97 1051
a834585d 1052// Retrieve the position of the caret when the auto-completion list was displayed.
8e0945da
VZ
1053int wxStyledTextCtrl::AutoCompPosStart()
1054{
4370573a 1055 return SendMsg(2103, 0, 0);
f6bcfd97
BP
1056}
1057
4370573a 1058// User has selected an item so remove the list and insert the selection.
8e0945da
VZ
1059void wxStyledTextCtrl::AutoCompComplete()
1060{
4370573a
RD
1061 SendMsg(2104, 0, 0);
1062}
f6bcfd97 1063
4370573a 1064// Define a set of character that when typed cancel the auto-completion list.
8e0945da
VZ
1065void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet)
1066{
b796ba39 1067 SendMsg(2105, 0, (sptr_t)(const char*)wx2stc(characterSet));
f6bcfd97
BP
1068}
1069
a834585d
RD
1070// Change the separator character in the string setting up an auto-completion list.
1071// Default is space but can be changed if items contain space.
8e0945da
VZ
1072void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter)
1073{
4370573a
RD
1074 SendMsg(2106, separatorCharacter, 0);
1075}
f6bcfd97 1076
4370573a 1077// Retrieve the auto-completion list separator character.
8e0945da
VZ
1078int wxStyledTextCtrl::AutoCompGetSeparator() const
1079{
4370573a 1080 return SendMsg(2107, 0, 0);
9ce192d4
RD
1081}
1082
4370573a 1083// Select the item in the auto-completion list that starts with a string.
8e0945da
VZ
1084void wxStyledTextCtrl::AutoCompSelect(const wxString& text)
1085{
b796ba39 1086 SendMsg(2108, 0, (sptr_t)(const char*)wx2stc(text));
4370573a 1087}
9ce192d4 1088
4370573a
RD
1089// Should the auto-completion list be cancelled if the user backspaces to a
1090// position before where the box was created.
8e0945da
VZ
1091void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel)
1092{
4370573a 1093 SendMsg(2110, cancel, 0);
f6bcfd97
BP
1094}
1095
4370573a 1096// Retrieve whether auto-completion cancelled by backspacing before start.
8e0945da
VZ
1097bool wxStyledTextCtrl::AutoCompGetCancelAtStart() const
1098{
4370573a
RD
1099 return SendMsg(2111, 0, 0) != 0;
1100}
f6bcfd97 1101
1a2fb4cd
RD
1102// Define a set of characters that when typed will cause the autocompletion to
1103// choose the selected item.
8e0945da
VZ
1104void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet)
1105{
b796ba39 1106 SendMsg(2112, 0, (sptr_t)(const char*)wx2stc(characterSet));
4370573a 1107}
9ce192d4 1108
4370573a 1109// Should a single item auto-completion list automatically choose the item.
8e0945da
VZ
1110void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle)
1111{
4370573a
RD
1112 SendMsg(2113, chooseSingle, 0);
1113}
9ce192d4 1114
4370573a 1115// Retrieve whether a single item auto-completion list automatically choose the item.
8e0945da
VZ
1116bool wxStyledTextCtrl::AutoCompGetChooseSingle() const
1117{
4370573a 1118 return SendMsg(2114, 0, 0) != 0;
9ce192d4
RD
1119}
1120
4370573a 1121// Set whether case is significant when performing auto-completion searches.
8e0945da
VZ
1122void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase)
1123{
4370573a
RD
1124 SendMsg(2115, ignoreCase, 0);
1125}
9ce192d4 1126
4370573a 1127// Retrieve state of ignore case flag.
8e0945da
VZ
1128bool wxStyledTextCtrl::AutoCompGetIgnoreCase() const
1129{
4370573a 1130 return SendMsg(2116, 0, 0) != 0;
9ce192d4
RD
1131}
1132
65ec6247 1133// Display a list of strings and send notification when user chooses one.
8e0945da
VZ
1134void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList)
1135{
b796ba39 1136 SendMsg(2117, listType, (sptr_t)(const char*)wx2stc(itemList));
65ec6247
RD
1137}
1138
a834585d 1139// Set whether or not autocompletion is hidden automatically when nothing matches.
8e0945da
VZ
1140void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide)
1141{
65ec6247
RD
1142 SendMsg(2118, autoHide, 0);
1143}
1144
a834585d 1145// Retrieve whether or not autocompletion is hidden automatically when nothing matches.
8e0945da
VZ
1146bool wxStyledTextCtrl::AutoCompGetAutoHide() const
1147{
65ec6247
RD
1148 return SendMsg(2119, 0, 0) != 0;
1149}
1150
a834585d
RD
1151// Set whether or not autocompletion deletes any word characters
1152// after the inserted text upon completion.
8e0945da
VZ
1153void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord)
1154{
1a2fb4cd
RD
1155 SendMsg(2270, dropRestOfWord, 0);
1156}
1157
a834585d
RD
1158// Retrieve whether or not autocompletion deletes any word characters
1159// after the inserted text upon completion.
8e0945da
VZ
1160bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() const
1161{
1a2fb4cd
RD
1162 return SendMsg(2271, 0, 0) != 0;
1163}
1164
9e730a78
RD
1165// Register an image for use in autocompletion lists.
1166void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
1167 // convert bmp to a xpm in a string
1168 wxMemoryOutputStream strm;
1169 wxImage img = bmp.ConvertToImage();
e45b3f17
RD
1170 if (img.HasAlpha())
1171 img.ConvertAlphaToMask();
9e730a78
RD
1172 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
1173 size_t len = strm.GetSize();
1174 char* buff = new char[len+1];
1175 strm.CopyTo(buff, len);
1176 buff[len] = 0;
b796ba39 1177 SendMsg(2405, type, (sptr_t)buff);
9e730a78 1178 delete [] buff;
a5b274d7 1179
9e730a78
RD
1180}
1181
1182// Clear all the registered images.
8e0945da
VZ
1183void wxStyledTextCtrl::ClearRegisteredImages()
1184{
9e730a78
RD
1185 SendMsg(2408, 0, 0);
1186}
1187
1188// Retrieve the auto-completion list type-separator character.
8e0945da
VZ
1189int wxStyledTextCtrl::AutoCompGetTypeSeparator() const
1190{
9e730a78
RD
1191 return SendMsg(2285, 0, 0);
1192}
1193
1194// Change the type-separator character in the string setting up an auto-completion list.
1195// Default is '?' but can be changed if items contain '?'.
8e0945da
VZ
1196void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter)
1197{
9e730a78
RD
1198 SendMsg(2286, separatorCharacter, 0);
1199}
1200
1e9bafca
RD
1201// Set the maximum width, in characters, of auto-completion and user lists.
1202// Set to 0 to autosize to fit longest item, which is the default.
8e0945da
VZ
1203void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount)
1204{
1e9bafca
RD
1205 SendMsg(2208, characterCount, 0);
1206}
1207
1208// Get the maximum width, in characters, of auto-completion and user lists.
8e0945da
VZ
1209int wxStyledTextCtrl::AutoCompGetMaxWidth() const
1210{
1e9bafca
RD
1211 return SendMsg(2209, 0, 0);
1212}
1213
1214// Set the maximum height, in rows, of auto-completion and user lists.
1215// The default is 5 rows.
8e0945da
VZ
1216void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount)
1217{
1e9bafca
RD
1218 SendMsg(2210, rowCount, 0);
1219}
1220
1221// Set the maximum height, in rows, of auto-completion and user lists.
8e0945da
VZ
1222int wxStyledTextCtrl::AutoCompGetMaxHeight() const
1223{
1e9bafca
RD
1224 return SendMsg(2211, 0, 0);
1225}
1226
4370573a 1227// Set the number of spaces used for one level of indentation.
8e0945da
VZ
1228void wxStyledTextCtrl::SetIndent(int indentSize)
1229{
4370573a
RD
1230 SendMsg(2122, indentSize, 0);
1231}
9ce192d4 1232
4370573a 1233// Retrieve indentation size.
8e0945da
VZ
1234int wxStyledTextCtrl::GetIndent() const
1235{
4370573a 1236 return SendMsg(2123, 0, 0);
9ce192d4
RD
1237}
1238
4370573a
RD
1239// Indentation will only use space characters if useTabs is false, otherwise
1240// it will use a combination of tabs and spaces.
8e0945da
VZ
1241void wxStyledTextCtrl::SetUseTabs(bool useTabs)
1242{
4370573a
RD
1243 SendMsg(2124, useTabs, 0);
1244}
9ce192d4 1245
4370573a 1246// Retrieve whether tabs will be used in indentation.
8e0945da
VZ
1247bool wxStyledTextCtrl::GetUseTabs() const
1248{
4370573a
RD
1249 return SendMsg(2125, 0, 0) != 0;
1250}
9ce192d4 1251
4370573a 1252// Change the indentation of a line to a number of columns.
8e0945da
VZ
1253void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize)
1254{
4370573a
RD
1255 SendMsg(2126, line, indentSize);
1256}
9ce192d4 1257
4370573a 1258// Retrieve the number of columns that a line is indented.
8e0945da
VZ
1259int wxStyledTextCtrl::GetLineIndentation(int line) const
1260{
4370573a 1261 return SendMsg(2127, line, 0);
9ce192d4
RD
1262}
1263
4370573a 1264// Retrieve the position before the first non indentation character on a line.
8e0945da
VZ
1265int wxStyledTextCtrl::GetLineIndentPosition(int line) const
1266{
4370573a
RD
1267 return SendMsg(2128, line, 0);
1268}
9ce192d4 1269
4370573a 1270// Retrieve the column number of a position, taking tab width into account.
8e0945da
VZ
1271int wxStyledTextCtrl::GetColumn(int pos) const
1272{
4370573a 1273 return SendMsg(2129, pos, 0);
9ce192d4
RD
1274}
1275
4370573a 1276// Show or hide the horizontal scroll bar.
8e0945da
VZ
1277void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show)
1278{
4370573a
RD
1279 SendMsg(2130, show, 0);
1280}
9ce192d4 1281
4370573a 1282// Is the horizontal scroll bar visible?
8e0945da
VZ
1283bool wxStyledTextCtrl::GetUseHorizontalScrollBar() const
1284{
4370573a 1285 return SendMsg(2131, 0, 0) != 0;
9ce192d4
RD
1286}
1287
4370573a 1288// Show or hide indentation guides.
8e0945da
VZ
1289void wxStyledTextCtrl::SetIndentationGuides(int indentView)
1290{
7e0c58e9 1291 SendMsg(2132, indentView, 0);
4370573a 1292}
9ce192d4 1293
4370573a 1294// Are the indentation guides visible?
8e0945da
VZ
1295int wxStyledTextCtrl::GetIndentationGuides() const
1296{
7e0c58e9 1297 return SendMsg(2133, 0, 0);
9ce192d4
RD
1298}
1299
4370573a
RD
1300// Set the highlighted indentation guide column.
1301// 0 = no highlighted guide.
8e0945da
VZ
1302void wxStyledTextCtrl::SetHighlightGuide(int column)
1303{
4370573a
RD
1304 SendMsg(2134, column, 0);
1305}
9ce192d4 1306
4370573a 1307// Get the highlighted indentation guide column.
8e0945da
VZ
1308int wxStyledTextCtrl::GetHighlightGuide() const
1309{
4370573a 1310 return SendMsg(2135, 0, 0);
9ce192d4
RD
1311}
1312
4370573a 1313// Get the position after the last visible characters on a line.
8e0945da
VZ
1314int wxStyledTextCtrl::GetLineEndPosition(int line) const
1315{
4370573a
RD
1316 return SendMsg(2136, line, 0);
1317}
9ce192d4 1318
4370573a 1319// Get the code page used to interpret the bytes of the document as characters.
8e0945da
VZ
1320int wxStyledTextCtrl::GetCodePage() const
1321{
4370573a 1322 return SendMsg(2137, 0, 0);
9ce192d4
RD
1323}
1324
4370573a 1325// Get the foreground colour of the caret.
8e0945da
VZ
1326wxColour wxStyledTextCtrl::GetCaretForeground() const
1327{
4370573a
RD
1328 long c = SendMsg(2138, 0, 0);
1329 return wxColourFromLong(c);
1330}
9ce192d4 1331
4370573a 1332// In read-only mode?
8e0945da
VZ
1333bool wxStyledTextCtrl::GetReadOnly() const
1334{
4370573a 1335 return SendMsg(2140, 0, 0) != 0;
9ce192d4
RD
1336}
1337
4370573a 1338// Sets the position of the caret.
8e0945da
VZ
1339void wxStyledTextCtrl::SetCurrentPos(int pos)
1340{
4370573a
RD
1341 SendMsg(2141, pos, 0);
1342}
9ce192d4 1343
4370573a 1344// Sets the position that starts the selection - this becomes the anchor.
8e0945da
VZ
1345void wxStyledTextCtrl::SetSelectionStart(int pos)
1346{
4370573a 1347 SendMsg(2142, pos, 0);
9ce192d4
RD
1348}
1349
4370573a 1350// Returns the position at the start of the selection.
8e0945da
VZ
1351int wxStyledTextCtrl::GetSelectionStart() const
1352{
4370573a
RD
1353 return SendMsg(2143, 0, 0);
1354}
9ce192d4 1355
4370573a 1356// Sets the position that ends the selection - this becomes the currentPosition.
8e0945da
VZ
1357void wxStyledTextCtrl::SetSelectionEnd(int pos)
1358{
4370573a 1359 SendMsg(2144, pos, 0);
9ce192d4
RD
1360}
1361
4370573a 1362// Returns the position at the end of the selection.
8e0945da
VZ
1363int wxStyledTextCtrl::GetSelectionEnd() const
1364{
4370573a
RD
1365 return SendMsg(2145, 0, 0);
1366}
9ce192d4 1367
4370573a 1368// Sets the print magnification added to the point size of each style for printing.
8e0945da
VZ
1369void wxStyledTextCtrl::SetPrintMagnification(int magnification)
1370{
4370573a 1371 SendMsg(2146, magnification, 0);
9ce192d4
RD
1372}
1373
4370573a 1374// Returns the print magnification.
8e0945da
VZ
1375int wxStyledTextCtrl::GetPrintMagnification() const
1376{
4370573a
RD
1377 return SendMsg(2147, 0, 0);
1378}
9ce192d4 1379
4370573a 1380// Modify colours when printing for clearer printed text.
8e0945da
VZ
1381void wxStyledTextCtrl::SetPrintColourMode(int mode)
1382{
4370573a 1383 SendMsg(2148, mode, 0);
9ce192d4
RD
1384}
1385
4370573a 1386// Returns the print colour mode.
8e0945da
VZ
1387int wxStyledTextCtrl::GetPrintColourMode() const
1388{
4370573a
RD
1389 return SendMsg(2149, 0, 0);
1390}
9ce192d4 1391
4370573a
RD
1392// Find some text in the document.
1393int wxStyledTextCtrl::FindText(int minPos, int maxPos,
9e730a78
RD
1394 const wxString& text,
1395 int flags) {
1396 TextToFind ft;
1397 ft.chrg.cpMin = minPos;
1398 ft.chrg.cpMax = maxPos;
1399 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1400 ft.lpstrText = (char*)(const char*)buf;
4370573a 1401
b796ba39 1402 return SendMsg(2150, flags, (sptr_t)&ft);
4370573a
RD
1403}
1404
a834585d 1405// On Windows, will draw the document into a display context such as a printer.
a5b274d7
WS
1406 int wxStyledTextCtrl::FormatRange(bool doDraw,
1407 int startPos,
1408 int endPos,
1409 wxDC* draw,
a5c2ccf2 1410 wxDC* target,
a5b274d7
WS
1411 wxRect renderRect,
1412 wxRect pageRect) {
1413 RangeToFormat fr;
1414
1415 if (endPos < startPos) {
1416 int temp = startPos;
1417 startPos = endPos;
1418 endPos = temp;
1419 }
1420 fr.hdc = draw;
1421 fr.hdcTarget = target;
1422 fr.rc.top = renderRect.GetTop();
1423 fr.rc.left = renderRect.GetLeft();
1424 fr.rc.right = renderRect.GetRight();
1425 fr.rc.bottom = renderRect.GetBottom();
1426 fr.rcPage.top = pageRect.GetTop();
1427 fr.rcPage.left = pageRect.GetLeft();
1428 fr.rcPage.right = pageRect.GetRight();
1429 fr.rcPage.bottom = pageRect.GetBottom();
1430 fr.chrg.cpMin = startPos;
1431 fr.chrg.cpMax = endPos;
1432
b796ba39 1433 return SendMsg(2151, doDraw, (sptr_t)&fr);
9e730a78
RD
1434}
1435
1436// Retrieve the display line at the top of the display.
8e0945da
VZ
1437int wxStyledTextCtrl::GetFirstVisibleLine() const
1438{
4370573a 1439 return SendMsg(2152, 0, 0);
9ce192d4
RD
1440}
1441
4370573a 1442// Retrieve the contents of a line.
2bfca191 1443wxString wxStyledTextCtrl::GetLine(int line) const {
9e730a78
RD
1444 int len = LineLength(line);
1445 if (!len) return wxEmptyString;
9ce192d4 1446
9e730a78
RD
1447 wxMemoryBuffer mbuf(len+1);
1448 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 1449 SendMsg(2153, line, (sptr_t)buf);
9e730a78
RD
1450 mbuf.UngetWriteBuf(len);
1451 mbuf.AppendByte(0);
1452 return stc2wx(buf);
4370573a
RD
1453}
1454
1455// Returns the number of lines in the document. There is always at least one.
8e0945da
VZ
1456int wxStyledTextCtrl::GetLineCount() const
1457{
4370573a
RD
1458 return SendMsg(2154, 0, 0);
1459}
9ce192d4 1460
4370573a 1461// Sets the size in pixels of the left margin.
8e0945da
VZ
1462void wxStyledTextCtrl::SetMarginLeft(int pixelWidth)
1463{
65ec6247 1464 SendMsg(2155, 0, pixelWidth);
4370573a 1465}
9ce192d4 1466
4370573a 1467// Returns the size in pixels of the left margin.
8e0945da
VZ
1468int wxStyledTextCtrl::GetMarginLeft() const
1469{
4370573a 1470 return SendMsg(2156, 0, 0);
9ce192d4
RD
1471}
1472
4370573a 1473// Sets the size in pixels of the right margin.
8e0945da
VZ
1474void wxStyledTextCtrl::SetMarginRight(int pixelWidth)
1475{
65ec6247 1476 SendMsg(2157, 0, pixelWidth);
4370573a 1477}
9ce192d4 1478
4370573a 1479// Returns the size in pixels of the right margin.
8e0945da
VZ
1480int wxStyledTextCtrl::GetMarginRight() const
1481{
4370573a 1482 return SendMsg(2158, 0, 0);
9ce192d4
RD
1483}
1484
4370573a 1485// Is the document different from when it was last saved?
8e0945da
VZ
1486bool wxStyledTextCtrl::GetModify() const
1487{
4370573a
RD
1488 return SendMsg(2159, 0, 0) != 0;
1489}
9ce192d4 1490
4370573a 1491// Select a range of text.
8e0945da
VZ
1492void wxStyledTextCtrl::SetSelection(int start, int end)
1493{
4370573a 1494 SendMsg(2160, start, end);
9ce192d4
RD
1495}
1496
4370573a
RD
1497// Retrieve the selected text.
1498wxString wxStyledTextCtrl::GetSelectedText() {
9e730a78
RD
1499 int start;
1500 int end;
9ce192d4 1501
9e730a78
RD
1502 GetSelection(&start, &end);
1503 int len = end - start;
1504 if (!len) return wxEmptyString;
9ce192d4 1505
3d7a4fe8 1506 wxMemoryBuffer mbuf(len+2);
9e730a78 1507 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 1508 SendMsg(2161, 0, (sptr_t)buf);
9e730a78
RD
1509 mbuf.UngetWriteBuf(len);
1510 mbuf.AppendByte(0);
1511 return stc2wx(buf);
4370573a 1512}
9ce192d4 1513
4370573a
RD
1514// Retrieve a range of text.
1515wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
9e730a78
RD
1516 if (endPos < startPos) {
1517 int temp = startPos;
1518 startPos = endPos;
1519 endPos = temp;
1520 }
1521 int len = endPos - startPos;
1522 if (!len) return wxEmptyString;
1523 wxMemoryBuffer mbuf(len+1);
1524 char* buf = (char*)mbuf.GetWriteBuf(len);
1525 TextRange tr;
1526 tr.lpstrText = buf;
1527 tr.chrg.cpMin = startPos;
1528 tr.chrg.cpMax = endPos;
b796ba39 1529 SendMsg(2162, 0, (sptr_t)&tr);
9e730a78
RD
1530 mbuf.UngetWriteBuf(len);
1531 mbuf.AppendByte(0);
1532 return stc2wx(buf);
9ce192d4
RD
1533}
1534
4370573a 1535// Draw the selection in normal style or with selection highlighted.
8e0945da
VZ
1536void wxStyledTextCtrl::HideSelection(bool normal)
1537{
4370573a
RD
1538 SendMsg(2163, normal, 0);
1539}
9ce192d4 1540
4370573a 1541// Retrieve the line containing a position.
2bfca191 1542int wxStyledTextCtrl::LineFromPosition(int pos) const
8e0945da 1543{
4370573a 1544 return SendMsg(2166, pos, 0);
9ce192d4
RD
1545}
1546
4370573a 1547// Retrieve the position at the start of a line.
2bfca191 1548int wxStyledTextCtrl::PositionFromLine(int line) const
8e0945da 1549{
4370573a
RD
1550 return SendMsg(2167, line, 0);
1551}
9ce192d4 1552
4370573a 1553// Scroll horizontally and vertically.
8e0945da
VZ
1554void wxStyledTextCtrl::LineScroll(int columns, int lines)
1555{
4370573a 1556 SendMsg(2168, columns, lines);
9ce192d4
RD
1557}
1558
4370573a 1559// Ensure the caret is visible.
8e0945da
VZ
1560void wxStyledTextCtrl::EnsureCaretVisible()
1561{
4370573a
RD
1562 SendMsg(2169, 0, 0);
1563}
9ce192d4 1564
4370573a 1565// Replace the selected text with the argument text.
8e0945da
VZ
1566void wxStyledTextCtrl::ReplaceSelection(const wxString& text)
1567{
b796ba39 1568 SendMsg(2170, 0, (sptr_t)(const char*)wx2stc(text));
9ce192d4
RD
1569}
1570
4370573a 1571// Set to read only or read write.
8e0945da
VZ
1572void wxStyledTextCtrl::SetReadOnly(bool readOnly)
1573{
4370573a
RD
1574 SendMsg(2171, readOnly, 0);
1575}
9ce192d4 1576
4370573a 1577// Will a paste succeed?
8e0945da
VZ
1578bool wxStyledTextCtrl::CanPaste()
1579{
4370573a 1580 return SendMsg(2173, 0, 0) != 0;
9ce192d4
RD
1581}
1582
a834585d 1583// Are there any undoable actions in the undo history?
93578927 1584bool wxStyledTextCtrl::CanUndo() const
8e0945da 1585{
4370573a
RD
1586 return SendMsg(2174, 0, 0) != 0;
1587}
9ce192d4 1588
4370573a 1589// Delete the undo history.
8e0945da
VZ
1590void wxStyledTextCtrl::EmptyUndoBuffer()
1591{
4370573a 1592 SendMsg(2175, 0, 0);
9ce192d4
RD
1593}
1594
4370573a 1595// Undo one action in the undo history.
8e0945da
VZ
1596void wxStyledTextCtrl::Undo()
1597{
4370573a
RD
1598 SendMsg(2176, 0, 0);
1599}
9ce192d4 1600
4370573a 1601// Cut the selection to the clipboard.
8e0945da
VZ
1602void wxStyledTextCtrl::Cut()
1603{
4370573a 1604 SendMsg(2177, 0, 0);
f6bcfd97
BP
1605}
1606
4370573a 1607// Copy the selection to the clipboard.
8e0945da
VZ
1608void wxStyledTextCtrl::Copy()
1609{
4370573a
RD
1610 SendMsg(2178, 0, 0);
1611}
f6bcfd97 1612
4370573a 1613// Paste the contents of the clipboard into the document replacing the selection.
8e0945da
VZ
1614void wxStyledTextCtrl::Paste()
1615{
4370573a 1616 SendMsg(2179, 0, 0);
f6bcfd97
BP
1617}
1618
4370573a 1619// Clear the selection.
8e0945da
VZ
1620void wxStyledTextCtrl::Clear()
1621{
4370573a
RD
1622 SendMsg(2180, 0, 0);
1623}
f6bcfd97 1624
4370573a 1625// Replace the contents of the document with the argument text.
8e0945da
VZ
1626void wxStyledTextCtrl::SetText(const wxString& text)
1627{
b796ba39 1628 SendMsg(2181, 0, (sptr_t)(const char*)wx2stc(text));
f6bcfd97
BP
1629}
1630
4370573a 1631// Retrieve all the text in the document.
93578927 1632wxString wxStyledTextCtrl::GetText() const {
9e730a78
RD
1633 int len = GetTextLength();
1634 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1635 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 1636 SendMsg(2182, len+1, (sptr_t)buf);
9e730a78
RD
1637 mbuf.UngetWriteBuf(len);
1638 mbuf.AppendByte(0);
1639 return stc2wx(buf);
4370573a 1640}
9ce192d4 1641
4370573a 1642// Retrieve the number of characters in the document.
8e0945da
VZ
1643int wxStyledTextCtrl::GetTextLength() const
1644{
4370573a 1645 return SendMsg(2183, 0, 0);
9ce192d4
RD
1646}
1647
a834585d 1648// Set to overtype (true) or insert mode.
8e0945da
VZ
1649void wxStyledTextCtrl::SetOvertype(bool overtype)
1650{
4370573a
RD
1651 SendMsg(2186, overtype, 0);
1652}
9ce192d4 1653
4370573a 1654// Returns true if overtype mode is active otherwise false is returned.
8e0945da
VZ
1655bool wxStyledTextCtrl::GetOvertype() const
1656{
4370573a 1657 return SendMsg(2187, 0, 0) != 0;
9ce192d4
RD
1658}
1659
a834585d 1660// Set the width of the insert mode caret.
8e0945da
VZ
1661void wxStyledTextCtrl::SetCaretWidth(int pixelWidth)
1662{
65ec6247
RD
1663 SendMsg(2188, pixelWidth, 0);
1664}
1665
a834585d 1666// Returns the width of the insert mode caret.
8e0945da
VZ
1667int wxStyledTextCtrl::GetCaretWidth() const
1668{
65ec6247
RD
1669 return SendMsg(2189, 0, 0);
1670}
1671
1672// Sets the position that starts the target which is used for updating the
1673// document without affecting the scroll position.
8e0945da
VZ
1674void wxStyledTextCtrl::SetTargetStart(int pos)
1675{
65ec6247
RD
1676 SendMsg(2190, pos, 0);
1677}
1678
1679// Get the position that starts the target.
8e0945da
VZ
1680int wxStyledTextCtrl::GetTargetStart() const
1681{
65ec6247
RD
1682 return SendMsg(2191, 0, 0);
1683}
1684
1685// Sets the position that ends the target which is used for updating the
1686// document without affecting the scroll position.
8e0945da
VZ
1687void wxStyledTextCtrl::SetTargetEnd(int pos)
1688{
65ec6247
RD
1689 SendMsg(2192, pos, 0);
1690}
1691
1692// Get the position that ends the target.
8e0945da
VZ
1693int wxStyledTextCtrl::GetTargetEnd() const
1694{
65ec6247
RD
1695 return SendMsg(2193, 0, 0);
1696}
1697
1698// Replace the target text with the argument text.
8e54aaed 1699// Text is counted so it can contain NULs.
65ec6247
RD
1700// Returns the length of the replacement text.
1701
9e730a78
RD
1702 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1703 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
b796ba39 1704 return SendMsg(2194, strlen(buf), (sptr_t)(const char*)buf);
65ec6247
RD
1705}
1706
1707// Replace the target text with the argument text after \d processing.
8e54aaed 1708// Text is counted so it can contain NULs.
65ec6247
RD
1709// Looks for \d where d is between 1 and 9 and replaces these with the strings
1710// matched in the last search operation which were surrounded by \( and \).
1711// Returns the length of the replacement text including any change
1712// caused by processing the \d patterns.
1713
9e730a78
RD
1714 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1715 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
b796ba39 1716 return SendMsg(2195, strlen(buf), (sptr_t)(const char*)buf);
65ec6247
RD
1717}
1718
1719// Search for a counted string in the target and set the target to the found
8e54aaed 1720// range. Text is counted so it can contain NULs.
65ec6247
RD
1721// Returns length of range or -1 for failure in which case target is not moved.
1722
9e730a78
RD
1723 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1724 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
b796ba39 1725 return SendMsg(2197, strlen(buf), (sptr_t)(const char*)buf);
65ec6247
RD
1726}
1727
a834585d 1728// Set the search flags used by SearchInTarget.
8e0945da
VZ
1729void wxStyledTextCtrl::SetSearchFlags(int flags)
1730{
65ec6247
RD
1731 SendMsg(2198, flags, 0);
1732}
1733
a834585d 1734// Get the search flags used by SearchInTarget.
8e0945da
VZ
1735int wxStyledTextCtrl::GetSearchFlags() const
1736{
65ec6247
RD
1737 return SendMsg(2199, 0, 0);
1738}
1739
4370573a 1740// Show a call tip containing a definition near position pos.
8e0945da
VZ
1741void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition)
1742{
b796ba39 1743 SendMsg(2200, pos, (sptr_t)(const char*)wx2stc(definition));
4370573a 1744}
9ce192d4 1745
4370573a 1746// Remove the call tip from the screen.
8e0945da
VZ
1747void wxStyledTextCtrl::CallTipCancel()
1748{
4370573a 1749 SendMsg(2201, 0, 0);
9ce192d4
RD
1750}
1751
4370573a 1752// Is there an active call tip?
8e0945da
VZ
1753bool wxStyledTextCtrl::CallTipActive()
1754{
4370573a
RD
1755 return SendMsg(2202, 0, 0) != 0;
1756}
9ce192d4 1757
4370573a 1758// Retrieve the position where the caret was before displaying the call tip.
8e0945da
VZ
1759int wxStyledTextCtrl::CallTipPosAtStart()
1760{
4370573a 1761 return SendMsg(2203, 0, 0);
9ce192d4
RD
1762}
1763
4370573a 1764// Highlight a segment of the definition.
8e0945da
VZ
1765void wxStyledTextCtrl::CallTipSetHighlight(int start, int end)
1766{
4370573a 1767 SendMsg(2204, start, end);
9ce192d4
RD
1768}
1769
4370573a 1770// Set the background colour for the call tip.
8e0945da
VZ
1771void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back)
1772{
4370573a
RD
1773 SendMsg(2205, wxColourAsLong(back), 0);
1774}
9ce192d4 1775
9e730a78 1776// Set the foreground colour for the call tip.
8e0945da
VZ
1777void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore)
1778{
9e730a78
RD
1779 SendMsg(2206, wxColourAsLong(fore), 0);
1780}
1781
1782// Set the foreground colour for the highlighted part of the call tip.
8e0945da
VZ
1783void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore)
1784{
9e730a78
RD
1785 SendMsg(2207, wxColourAsLong(fore), 0);
1786}
1787
b8193d80 1788// Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
8e0945da
VZ
1789void wxStyledTextCtrl::CallTipUseStyle(int tabSize)
1790{
b8193d80
RD
1791 SendMsg(2212, tabSize, 0);
1792}
1793
4370573a 1794// Find the display line of a document line taking hidden lines into account.
8e0945da
VZ
1795int wxStyledTextCtrl::VisibleFromDocLine(int line)
1796{
4370573a 1797 return SendMsg(2220, line, 0);
9ce192d4
RD
1798}
1799
4370573a 1800// Find the document line of a display line taking hidden lines into account.
8e0945da
VZ
1801int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay)
1802{
4370573a
RD
1803 return SendMsg(2221, lineDisplay, 0);
1804}
9ce192d4 1805
1e9bafca 1806// The number of display lines needed to wrap a document line
8e0945da
VZ
1807int wxStyledTextCtrl::WrapCount(int line)
1808{
1e9bafca
RD
1809 return SendMsg(2235, line, 0);
1810}
1811
4370573a
RD
1812// Set the fold level of a line.
1813// This encodes an integer level along with flags indicating whether the
1814// line is a header and whether it is effectively white space.
8e0945da
VZ
1815void wxStyledTextCtrl::SetFoldLevel(int line, int level)
1816{
4370573a
RD
1817 SendMsg(2222, line, level);
1818}
9ce192d4 1819
4370573a 1820// Retrieve the fold level of a line.
8e0945da
VZ
1821int wxStyledTextCtrl::GetFoldLevel(int line) const
1822{
4370573a
RD
1823 return SendMsg(2223, line, 0);
1824}
d134f170 1825
4370573a 1826// Find the last child line of a header line.
8e0945da
VZ
1827int wxStyledTextCtrl::GetLastChild(int line, int level) const
1828{
4370573a 1829 return SendMsg(2224, line, level);
9ce192d4
RD
1830}
1831
4370573a 1832// Find the parent line of a child line.
8e0945da
VZ
1833int wxStyledTextCtrl::GetFoldParent(int line) const
1834{
4370573a
RD
1835 return SendMsg(2225, line, 0);
1836}
9ce192d4 1837
4370573a 1838// Make a range of lines visible.
8e0945da
VZ
1839void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd)
1840{
4370573a 1841 SendMsg(2226, lineStart, lineEnd);
9ce192d4
RD
1842}
1843
4370573a 1844// Make a range of lines invisible.
8e0945da
VZ
1845void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd)
1846{
4370573a
RD
1847 SendMsg(2227, lineStart, lineEnd);
1848}
9ce192d4 1849
4370573a 1850// Is a line visible?
8e0945da
VZ
1851bool wxStyledTextCtrl::GetLineVisible(int line) const
1852{
4370573a 1853 return SendMsg(2228, line, 0) != 0;
9ce192d4
RD
1854}
1855
4370573a 1856// Show the children of a header line.
8e0945da
VZ
1857void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded)
1858{
4370573a
RD
1859 SendMsg(2229, line, expanded);
1860}
9ce192d4 1861
4370573a 1862// Is a header line expanded?
8e0945da
VZ
1863bool wxStyledTextCtrl::GetFoldExpanded(int line) const
1864{
4370573a 1865 return SendMsg(2230, line, 0) != 0;
9ce192d4
RD
1866}
1867
4370573a 1868// Switch a header line between expanded and contracted.
8e0945da
VZ
1869void wxStyledTextCtrl::ToggleFold(int line)
1870{
4370573a
RD
1871 SendMsg(2231, line, 0);
1872}
9ce192d4 1873
4370573a 1874// Ensure a particular line is visible by expanding any header line hiding it.
8e0945da
VZ
1875void wxStyledTextCtrl::EnsureVisible(int line)
1876{
4370573a
RD
1877 SendMsg(2232, line, 0);
1878}
9ce192d4 1879
9e730a78 1880// Set some style options for folding.
8e0945da
VZ
1881void wxStyledTextCtrl::SetFoldFlags(int flags)
1882{
4370573a 1883 SendMsg(2233, flags, 0);
9ce192d4
RD
1884}
1885
65ec6247
RD
1886// Ensure a particular line is visible by expanding any header line hiding it.
1887// Use the currently set visibility policy to determine which range to display.
8e0945da
VZ
1888void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line)
1889{
65ec6247
RD
1890 SendMsg(2234, line, 0);
1891}
1892
a834585d 1893// Sets whether a tab pressed when caret is within indentation indents.
8e0945da
VZ
1894void wxStyledTextCtrl::SetTabIndents(bool tabIndents)
1895{
65ec6247
RD
1896 SendMsg(2260, tabIndents, 0);
1897}
1898
1899// Does a tab pressed when caret is within indentation indent?
8e0945da
VZ
1900bool wxStyledTextCtrl::GetTabIndents() const
1901{
65ec6247
RD
1902 return SendMsg(2261, 0, 0) != 0;
1903}
1904
a834585d 1905// Sets whether a backspace pressed when caret is within indentation unindents.
8e0945da
VZ
1906void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents)
1907{
65ec6247
RD
1908 SendMsg(2262, bsUnIndents, 0);
1909}
1910
1911// Does a backspace pressed when caret is within indentation unindent?
8e0945da
VZ
1912bool wxStyledTextCtrl::GetBackSpaceUnIndents() const
1913{
65ec6247
RD
1914 return SendMsg(2263, 0, 0) != 0;
1915}
1916
a834585d 1917// Sets the time the mouse must sit still to generate a mouse dwell event.
8e0945da
VZ
1918void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds)
1919{
65ec6247
RD
1920 SendMsg(2264, periodMilliseconds, 0);
1921}
1922
a834585d 1923// Retrieve the time the mouse must sit still to generate a mouse dwell event.
8e0945da
VZ
1924int wxStyledTextCtrl::GetMouseDwellTime() const
1925{
65ec6247
RD
1926 return SendMsg(2265, 0, 0);
1927}
1928
a834585d 1929// Get position of start of word.
8e0945da
VZ
1930int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters)
1931{
1a2fb4cd
RD
1932 return SendMsg(2266, pos, onlyWordCharacters);
1933}
1934
a834585d 1935// Get position of end of word.
8e0945da
VZ
1936int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters)
1937{
1a2fb4cd
RD
1938 return SendMsg(2267, pos, onlyWordCharacters);
1939}
1940
a834585d 1941// Sets whether text is word wrapped.
8e0945da
VZ
1942void wxStyledTextCtrl::SetWrapMode(int mode)
1943{
1a2fb4cd
RD
1944 SendMsg(2268, mode, 0);
1945}
1946
a834585d 1947// Retrieve whether text is word wrapped.
8e0945da
VZ
1948int wxStyledTextCtrl::GetWrapMode() const
1949{
1a2fb4cd
RD
1950 return SendMsg(2269, 0, 0);
1951}
1952
591d01be 1953// Set the display mode of visual flags for wrapped lines.
8e0945da
VZ
1954void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags)
1955{
591d01be
RD
1956 SendMsg(2460, wrapVisualFlags, 0);
1957}
1958
1959// Retrive the display mode of visual flags for wrapped lines.
8e0945da
VZ
1960int wxStyledTextCtrl::GetWrapVisualFlags() const
1961{
591d01be
RD
1962 return SendMsg(2461, 0, 0);
1963}
1964
1965// Set the location of visual flags for wrapped lines.
8e0945da
VZ
1966void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation)
1967{
591d01be
RD
1968 SendMsg(2462, wrapVisualFlagsLocation, 0);
1969}
1970
1971// Retrive the location of visual flags for wrapped lines.
8e0945da
VZ
1972int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const
1973{
591d01be
RD
1974 return SendMsg(2463, 0, 0);
1975}
1976
1977// Set the start indent for wrapped lines.
8e0945da
VZ
1978void wxStyledTextCtrl::SetWrapStartIndent(int indent)
1979{
591d01be
RD
1980 SendMsg(2464, indent, 0);
1981}
1982
1983// Retrive the start indent for wrapped lines.
8e0945da
VZ
1984int wxStyledTextCtrl::GetWrapStartIndent() const
1985{
591d01be
RD
1986 return SendMsg(2465, 0, 0);
1987}
1988
a834585d 1989// Sets the degree of caching of layout information.
8e0945da
VZ
1990void wxStyledTextCtrl::SetLayoutCache(int mode)
1991{
1a2fb4cd
RD
1992 SendMsg(2272, mode, 0);
1993}
1994
a834585d 1995// Retrieve the degree of caching of layout information.
8e0945da
VZ
1996int wxStyledTextCtrl::GetLayoutCache() const
1997{
1a2fb4cd
RD
1998 return SendMsg(2273, 0, 0);
1999}
2000
a834585d 2001// Sets the document width assumed for scrolling.
8e0945da
VZ
2002void wxStyledTextCtrl::SetScrollWidth(int pixelWidth)
2003{
a834585d
RD
2004 SendMsg(2274, pixelWidth, 0);
2005}
2006
2007// Retrieve the document width assumed for scrolling.
8e0945da
VZ
2008int wxStyledTextCtrl::GetScrollWidth() const
2009{
a834585d
RD
2010 return SendMsg(2275, 0, 0);
2011}
2012
7e0c58e9 2013// Sets whether the maximum width line displayed is used to set scroll width.
8e0945da
VZ
2014void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking)
2015{
7e0c58e9
RD
2016 SendMsg(2516, tracking, 0);
2017}
2018
2019// Retrieve whether the scroll width tracks wide lines.
8e0945da
VZ
2020bool wxStyledTextCtrl::GetScrollWidthTracking() const
2021{
7e0c58e9
RD
2022 return SendMsg(2517, 0, 0) != 0;
2023}
2024
a834585d 2025// Measure the pixel width of some text in a particular style.
8e54aaed 2026// NUL terminated text argument.
a834585d 2027// Does not handle tab or control characters.
8e0945da
VZ
2028int wxStyledTextCtrl::TextWidth(int style, const wxString& text)
2029{
b796ba39 2030 return SendMsg(2276, style, (sptr_t)(const char*)wx2stc(text));
a834585d
RD
2031}
2032
2033// Sets the scroll range so that maximum scroll position has
2034// the last line at the bottom of the view (default).
2035// Setting this to false allows scrolling one page below the last line.
8e0945da
VZ
2036void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine)
2037{
a834585d
RD
2038 SendMsg(2277, endAtLastLine, 0);
2039}
2040
2041// Retrieve whether the maximum scroll position has the last
2042// line at the bottom of the view.
8e0945da
VZ
2043bool wxStyledTextCtrl::GetEndAtLastLine() const
2044{
1e9bafca 2045 return SendMsg(2278, 0, 0) != 0;
a834585d
RD
2046}
2047
2048// Retrieve the height of a particular line of text in pixels.
8e0945da
VZ
2049int wxStyledTextCtrl::TextHeight(int line)
2050{
a834585d
RD
2051 return SendMsg(2279, line, 0);
2052}
2053
9e730a78 2054// Show or hide the vertical scroll bar.
8e0945da
VZ
2055void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show)
2056{
9e730a78
RD
2057 SendMsg(2280, show, 0);
2058}
2059
2060// Is the vertical scroll bar visible?
8e0945da
VZ
2061bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
2062{
9e730a78
RD
2063 return SendMsg(2281, 0, 0) != 0;
2064}
2065
2066// Append a string to the end of the document without changing the selection.
41a499cd
RD
2067void wxStyledTextCtrl::AppendText(const wxString& text) {
2068 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
b796ba39 2069 SendMsg(2282, strlen(buf), (sptr_t)(const char*)buf);
9e730a78
RD
2070}
2071
2072// Is drawing done in two phases with backgrounds drawn before foregrounds?
8e0945da
VZ
2073bool wxStyledTextCtrl::GetTwoPhaseDraw() const
2074{
9e730a78
RD
2075 return SendMsg(2283, 0, 0) != 0;
2076}
2077
2078// In twoPhaseDraw mode, drawing is performed in two phases, first the background
2079// and then the foreground. This avoids chopping off characters that overlap the next run.
8e0945da
VZ
2080void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase)
2081{
9e730a78
RD
2082 SendMsg(2284, twoPhase, 0);
2083}
2084
2085// Make the target range start and end be the same as the selection range start and end.
8e0945da
VZ
2086void wxStyledTextCtrl::TargetFromSelection()
2087{
9e730a78
RD
2088 SendMsg(2287, 0, 0);
2089}
2090
2091// Join the lines in the target.
8e0945da
VZ
2092void wxStyledTextCtrl::LinesJoin()
2093{
9e730a78
RD
2094 SendMsg(2288, 0, 0);
2095}
2096
2097// Split the lines in the target into lines that are less wide than pixelWidth
2098// where possible.
8e0945da
VZ
2099void wxStyledTextCtrl::LinesSplit(int pixelWidth)
2100{
9e730a78
RD
2101 SendMsg(2289, pixelWidth, 0);
2102}
2103
2104// Set the colours used as a chequerboard pattern in the fold margin
8e0945da
VZ
2105void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back)
2106{
9e730a78
RD
2107 SendMsg(2290, useSetting, wxColourAsLong(back));
2108}
8e0945da
VZ
2109void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore)
2110{
9e730a78
RD
2111 SendMsg(2291, useSetting, wxColourAsLong(fore));
2112}
2113
c26dba42 2114// Move caret down one line.
8e0945da
VZ
2115void wxStyledTextCtrl::LineDown()
2116{
c26dba42
RD
2117 SendMsg(2300, 0, 0);
2118}
2119
2120// Move caret down one line extending selection to new caret position.
8e0945da
VZ
2121void wxStyledTextCtrl::LineDownExtend()
2122{
c26dba42
RD
2123 SendMsg(2301, 0, 0);
2124}
2125
2126// Move caret up one line.
8e0945da
VZ
2127void wxStyledTextCtrl::LineUp()
2128{
c26dba42
RD
2129 SendMsg(2302, 0, 0);
2130}
2131
2132// Move caret up one line extending selection to new caret position.
8e0945da
VZ
2133void wxStyledTextCtrl::LineUpExtend()
2134{
c26dba42
RD
2135 SendMsg(2303, 0, 0);
2136}
2137
2138// Move caret left one character.
8e0945da
VZ
2139void wxStyledTextCtrl::CharLeft()
2140{
c26dba42
RD
2141 SendMsg(2304, 0, 0);
2142}
2143
2144// Move caret left one character extending selection to new caret position.
8e0945da
VZ
2145void wxStyledTextCtrl::CharLeftExtend()
2146{
c26dba42
RD
2147 SendMsg(2305, 0, 0);
2148}
2149
2150// Move caret right one character.
8e0945da
VZ
2151void wxStyledTextCtrl::CharRight()
2152{
c26dba42
RD
2153 SendMsg(2306, 0, 0);
2154}
2155
2156// Move caret right one character extending selection to new caret position.
8e0945da
VZ
2157void wxStyledTextCtrl::CharRightExtend()
2158{
c26dba42
RD
2159 SendMsg(2307, 0, 0);
2160}
2161
2162// Move caret left one word.
8e0945da
VZ
2163void wxStyledTextCtrl::WordLeft()
2164{
c26dba42
RD
2165 SendMsg(2308, 0, 0);
2166}
2167
2168// Move caret left one word extending selection to new caret position.
8e0945da
VZ
2169void wxStyledTextCtrl::WordLeftExtend()
2170{
c26dba42
RD
2171 SendMsg(2309, 0, 0);
2172}
2173
2174// Move caret right one word.
8e0945da
VZ
2175void wxStyledTextCtrl::WordRight()
2176{
c26dba42
RD
2177 SendMsg(2310, 0, 0);
2178}
2179
2180// Move caret right one word extending selection to new caret position.
8e0945da
VZ
2181void wxStyledTextCtrl::WordRightExtend()
2182{
c26dba42
RD
2183 SendMsg(2311, 0, 0);
2184}
2185
2186// Move caret to first position on line.
8e0945da
VZ
2187void wxStyledTextCtrl::Home()
2188{
c26dba42
RD
2189 SendMsg(2312, 0, 0);
2190}
2191
2192// Move caret to first position on line extending selection to new caret position.
8e0945da
VZ
2193void wxStyledTextCtrl::HomeExtend()
2194{
c26dba42
RD
2195 SendMsg(2313, 0, 0);
2196}
2197
2198// Move caret to last position on line.
8e0945da
VZ
2199void wxStyledTextCtrl::LineEnd()
2200{
c26dba42
RD
2201 SendMsg(2314, 0, 0);
2202}
2203
2204// Move caret to last position on line extending selection to new caret position.
8e0945da
VZ
2205void wxStyledTextCtrl::LineEndExtend()
2206{
c26dba42
RD
2207 SendMsg(2315, 0, 0);
2208}
2209
2210// Move caret to first position in document.
8e0945da
VZ
2211void wxStyledTextCtrl::DocumentStart()
2212{
c26dba42
RD
2213 SendMsg(2316, 0, 0);
2214}
2215
2216// Move caret to first position in document extending selection to new caret position.
8e0945da
VZ
2217void wxStyledTextCtrl::DocumentStartExtend()
2218{
c26dba42
RD
2219 SendMsg(2317, 0, 0);
2220}
2221
2222// Move caret to last position in document.
8e0945da
VZ
2223void wxStyledTextCtrl::DocumentEnd()
2224{
c26dba42
RD
2225 SendMsg(2318, 0, 0);
2226}
2227
2228// Move caret to last position in document extending selection to new caret position.
8e0945da
VZ
2229void wxStyledTextCtrl::DocumentEndExtend()
2230{
c26dba42
RD
2231 SendMsg(2319, 0, 0);
2232}
2233
2234// Move caret one page up.
8e0945da
VZ
2235void wxStyledTextCtrl::PageUp()
2236{
c26dba42
RD
2237 SendMsg(2320, 0, 0);
2238}
2239
2240// Move caret one page up extending selection to new caret position.
8e0945da
VZ
2241void wxStyledTextCtrl::PageUpExtend()
2242{
c26dba42
RD
2243 SendMsg(2321, 0, 0);
2244}
2245
2246// Move caret one page down.
8e0945da
VZ
2247void wxStyledTextCtrl::PageDown()
2248{
c26dba42
RD
2249 SendMsg(2322, 0, 0);
2250}
2251
2252// Move caret one page down extending selection to new caret position.
8e0945da
VZ
2253void wxStyledTextCtrl::PageDownExtend()
2254{
c26dba42
RD
2255 SendMsg(2323, 0, 0);
2256}
2257
2258// Switch from insert to overtype mode or the reverse.
8e0945da
VZ
2259void wxStyledTextCtrl::EditToggleOvertype()
2260{
c26dba42
RD
2261 SendMsg(2324, 0, 0);
2262}
2263
2264// Cancel any modes such as call tip or auto-completion list display.
8e0945da
VZ
2265void wxStyledTextCtrl::Cancel()
2266{
c26dba42
RD
2267 SendMsg(2325, 0, 0);
2268}
2269
2270// Delete the selection or if no selection, the character before the caret.
8e0945da
VZ
2271void wxStyledTextCtrl::DeleteBack()
2272{
c26dba42
RD
2273 SendMsg(2326, 0, 0);
2274}
2275
2276// If selection is empty or all on one line replace the selection with a tab character.
2277// If more than one line selected, indent the lines.
8e0945da
VZ
2278void wxStyledTextCtrl::Tab()
2279{
c26dba42
RD
2280 SendMsg(2327, 0, 0);
2281}
2282
2283// Dedent the selected lines.
8e0945da
VZ
2284void wxStyledTextCtrl::BackTab()
2285{
c26dba42
RD
2286 SendMsg(2328, 0, 0);
2287}
2288
2289// Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
8e0945da
VZ
2290void wxStyledTextCtrl::NewLine()
2291{
c26dba42
RD
2292 SendMsg(2329, 0, 0);
2293}
2294
2295// Insert a Form Feed character.
8e0945da
VZ
2296void wxStyledTextCtrl::FormFeed()
2297{
c26dba42
RD
2298 SendMsg(2330, 0, 0);
2299}
2300
2301// Move caret to before first visible character on line.
2302// If already there move to first character on line.
8e0945da
VZ
2303void wxStyledTextCtrl::VCHome()
2304{
c26dba42
RD
2305 SendMsg(2331, 0, 0);
2306}
2307
2308// Like VCHome but extending selection to new caret position.
8e0945da
VZ
2309void wxStyledTextCtrl::VCHomeExtend()
2310{
c26dba42
RD
2311 SendMsg(2332, 0, 0);
2312}
2313
2314// Magnify the displayed text by increasing the sizes by 1 point.
8e0945da
VZ
2315void wxStyledTextCtrl::ZoomIn()
2316{
c26dba42
RD
2317 SendMsg(2333, 0, 0);
2318}
2319
2320// Make the displayed text smaller by decreasing the sizes by 1 point.
8e0945da
VZ
2321void wxStyledTextCtrl::ZoomOut()
2322{
c26dba42
RD
2323 SendMsg(2334, 0, 0);
2324}
2325
2326// Delete the word to the left of the caret.
8e0945da
VZ
2327void wxStyledTextCtrl::DelWordLeft()
2328{
c26dba42
RD
2329 SendMsg(2335, 0, 0);
2330}
2331
2332// Delete the word to the right of the caret.
8e0945da
VZ
2333void wxStyledTextCtrl::DelWordRight()
2334{
c26dba42
RD
2335 SendMsg(2336, 0, 0);
2336}
2337
7e0c58e9 2338// Delete the word to the right of the caret, but not the trailing non-word characters.
8e0945da
VZ
2339void wxStyledTextCtrl::DelWordRightEnd()
2340{
7e0c58e9
RD
2341 SendMsg(2518, 0, 0);
2342}
2343
c26dba42 2344// Cut the line containing the caret.
8e0945da
VZ
2345void wxStyledTextCtrl::LineCut()
2346{
c26dba42
RD
2347 SendMsg(2337, 0, 0);
2348}
2349
2350// Delete the line containing the caret.
8e0945da
VZ
2351void wxStyledTextCtrl::LineDelete()
2352{
c26dba42
RD
2353 SendMsg(2338, 0, 0);
2354}
2355
2356// Switch the current line with the previous.
8e0945da
VZ
2357void wxStyledTextCtrl::LineTranspose()
2358{
c26dba42
RD
2359 SendMsg(2339, 0, 0);
2360}
2361
9e730a78 2362// Duplicate the current line.
8e0945da
VZ
2363void wxStyledTextCtrl::LineDuplicate()
2364{
9e730a78
RD
2365 SendMsg(2404, 0, 0);
2366}
2367
c26dba42 2368// Transform the selection to lower case.
8e0945da
VZ
2369void wxStyledTextCtrl::LowerCase()
2370{
c26dba42
RD
2371 SendMsg(2340, 0, 0);
2372}
2373
2374// Transform the selection to upper case.
8e0945da
VZ
2375void wxStyledTextCtrl::UpperCase()
2376{
c26dba42
RD
2377 SendMsg(2341, 0, 0);
2378}
2379
2380// Scroll the document down, keeping the caret visible.
8e0945da
VZ
2381void wxStyledTextCtrl::LineScrollDown()
2382{
c26dba42
RD
2383 SendMsg(2342, 0, 0);
2384}
2385
2386// Scroll the document up, keeping the caret visible.
8e0945da
VZ
2387void wxStyledTextCtrl::LineScrollUp()
2388{
c26dba42
RD
2389 SendMsg(2343, 0, 0);
2390}
2391
2392// Delete the selection or if no selection, the character before the caret.
2393// Will not delete the character before at the start of a line.
8e0945da
VZ
2394void wxStyledTextCtrl::DeleteBackNotLine()
2395{
c26dba42
RD
2396 SendMsg(2344, 0, 0);
2397}
2398
f114b858 2399// Move caret to first position on display line.
8e0945da
VZ
2400void wxStyledTextCtrl::HomeDisplay()
2401{
f114b858
RD
2402 SendMsg(2345, 0, 0);
2403}
2404
2b5f62a0 2405// Move caret to first position on display line extending selection to
f114b858 2406// new caret position.
8e0945da
VZ
2407void wxStyledTextCtrl::HomeDisplayExtend()
2408{
f114b858
RD
2409 SendMsg(2346, 0, 0);
2410}
2411
2412// Move caret to last position on display line.
8e0945da
VZ
2413void wxStyledTextCtrl::LineEndDisplay()
2414{
f114b858
RD
2415 SendMsg(2347, 0, 0);
2416}
2417
2b5f62a0 2418// Move caret to last position on display line extending selection to new
f114b858 2419// caret position.
8e0945da
VZ
2420void wxStyledTextCtrl::LineEndDisplayExtend()
2421{
f114b858
RD
2422 SendMsg(2348, 0, 0);
2423}
2424
c26dba42
RD
2425// These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
2426// except they behave differently when word-wrap is enabled:
2427// They go first to the start / end of the display line, like (Home|LineEnd)Display
2428// The difference is that, the cursor is already at the point, it goes on to the start
2429// or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
8e0945da
VZ
2430void wxStyledTextCtrl::HomeWrap()
2431{
c26dba42
RD
2432 SendMsg(2349, 0, 0);
2433}
8e0945da
VZ
2434void wxStyledTextCtrl::HomeWrapExtend()
2435{
c26dba42
RD
2436 SendMsg(2450, 0, 0);
2437}
8e0945da
VZ
2438void wxStyledTextCtrl::LineEndWrap()
2439{
c26dba42
RD
2440 SendMsg(2451, 0, 0);
2441}
8e0945da
VZ
2442void wxStyledTextCtrl::LineEndWrapExtend()
2443{
c26dba42
RD
2444 SendMsg(2452, 0, 0);
2445}
8e0945da
VZ
2446void wxStyledTextCtrl::VCHomeWrap()
2447{
c26dba42
RD
2448 SendMsg(2453, 0, 0);
2449}
8e0945da
VZ
2450void wxStyledTextCtrl::VCHomeWrapExtend()
2451{
c26dba42
RD
2452 SendMsg(2454, 0, 0);
2453}
2454
e14d10b0 2455// Copy the line containing the caret.
8e0945da
VZ
2456void wxStyledTextCtrl::LineCopy()
2457{
e14d10b0
RD
2458 SendMsg(2455, 0, 0);
2459}
2460
a834585d 2461// Move the caret inside current view if it's not there already.
8e0945da
VZ
2462void wxStyledTextCtrl::MoveCaretInsideView()
2463{
65ec6247
RD
2464 SendMsg(2401, 0, 0);
2465}
2466
a834585d 2467// How many characters are on a line, not including end of line characters?
2bfca191 2468int wxStyledTextCtrl::LineLength(int line) const
8e0945da 2469{
4370573a
RD
2470 return SendMsg(2350, line, 0);
2471}
9ce192d4 2472
4370573a 2473// Highlight the characters at two positions.
8e0945da
VZ
2474void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2)
2475{
4370573a
RD
2476 SendMsg(2351, pos1, pos2);
2477}
9ce192d4 2478
4370573a 2479// Highlight the character at a position indicating there is no matching brace.
8e0945da
VZ
2480void wxStyledTextCtrl::BraceBadLight(int pos)
2481{
4370573a 2482 SendMsg(2352, pos, 0);
9ce192d4
RD
2483}
2484
4370573a 2485// Find the position of a matching brace or INVALID_POSITION if no match.
8e0945da
VZ
2486int wxStyledTextCtrl::BraceMatch(int pos)
2487{
4370573a
RD
2488 return SendMsg(2353, pos, 0);
2489}
9ce192d4 2490
a834585d 2491// Are the end of line characters visible?
8e0945da
VZ
2492bool wxStyledTextCtrl::GetViewEOL() const
2493{
4370573a 2494 return SendMsg(2355, 0, 0) != 0;
9ce192d4
RD
2495}
2496
a834585d 2497// Make the end of line characters visible or invisible.
8e0945da
VZ
2498void wxStyledTextCtrl::SetViewEOL(bool visible)
2499{
4370573a
RD
2500 SendMsg(2356, visible, 0);
2501}
9ce192d4 2502
4370573a
RD
2503// Retrieve a pointer to the document object.
2504void* wxStyledTextCtrl::GetDocPointer() {
9e730a78 2505 return (void*)SendMsg(2357);
4370573a 2506}
67003d1a 2507
4370573a
RD
2508// Change the document object used.
2509void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
b796ba39 2510 SendMsg(2358, 0, (sptr_t)docPointer);
67003d1a
RD
2511}
2512
4370573a 2513// Set which document modification events are sent to the container.
8e0945da
VZ
2514void wxStyledTextCtrl::SetModEventMask(int mask)
2515{
4370573a
RD
2516 SendMsg(2359, mask, 0);
2517}
67003d1a 2518
4370573a 2519// Retrieve the column number which text should be kept within.
8e0945da
VZ
2520int wxStyledTextCtrl::GetEdgeColumn() const
2521{
4370573a 2522 return SendMsg(2360, 0, 0);
67003d1a
RD
2523}
2524
4370573a
RD
2525// Set the column number of the edge.
2526// If text goes past the edge then it is highlighted.
8e0945da
VZ
2527void wxStyledTextCtrl::SetEdgeColumn(int column)
2528{
4370573a
RD
2529 SendMsg(2361, column, 0);
2530}
67003d1a 2531
4370573a 2532// Retrieve the edge highlight mode.
8e0945da
VZ
2533int wxStyledTextCtrl::GetEdgeMode() const
2534{
4370573a 2535 return SendMsg(2362, 0, 0);
67003d1a
RD
2536}
2537
4370573a
RD
2538// The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2539// goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
8e0945da
VZ
2540void wxStyledTextCtrl::SetEdgeMode(int mode)
2541{
4370573a
RD
2542 SendMsg(2363, mode, 0);
2543}
67003d1a 2544
4370573a 2545// Retrieve the colour used in edge indication.
8e0945da
VZ
2546wxColour wxStyledTextCtrl::GetEdgeColour() const
2547{
4370573a
RD
2548 long c = SendMsg(2364, 0, 0);
2549 return wxColourFromLong(c);
67003d1a
RD
2550}
2551
4370573a 2552// Change the colour used in edge indication.
8e0945da
VZ
2553void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour)
2554{
4370573a
RD
2555 SendMsg(2365, wxColourAsLong(edgeColour), 0);
2556}
67003d1a 2557
4370573a 2558// Sets the current caret position to be the search anchor.
8e0945da
VZ
2559void wxStyledTextCtrl::SearchAnchor()
2560{
4370573a 2561 SendMsg(2366, 0, 0);
67003d1a
RD
2562}
2563
4370573a 2564// Find some text starting at the search anchor.
65ec6247 2565// Does not ensure the selection is visible.
8e0945da
VZ
2566int wxStyledTextCtrl::SearchNext(int flags, const wxString& text)
2567{
b796ba39 2568 return SendMsg(2367, flags, (sptr_t)(const char*)wx2stc(text));
4370573a 2569}
67003d1a 2570
4370573a 2571// Find some text starting at the search anchor and moving backwards.
65ec6247 2572// Does not ensure the selection is visible.
8e0945da
VZ
2573int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text)
2574{
b796ba39 2575 return SendMsg(2368, flags, (sptr_t)(const char*)wx2stc(text));
67003d1a
RD
2576}
2577
4370573a 2578// Retrieves the number of lines completely visible.
8e0945da
VZ
2579int wxStyledTextCtrl::LinesOnScreen() const
2580{
4370573a 2581 return SendMsg(2370, 0, 0);
67003d1a
RD
2582}
2583
4370573a
RD
2584// Set whether a pop up menu is displayed automatically when the user presses
2585// the wrong mouse button.
8e0945da
VZ
2586void wxStyledTextCtrl::UsePopUp(bool allowPopUp)
2587{
4370573a
RD
2588 SendMsg(2371, allowPopUp, 0);
2589}
67003d1a 2590
a834585d 2591// Is the selection rectangular? The alternative is the more common stream selection.
8e0945da
VZ
2592bool wxStyledTextCtrl::SelectionIsRectangle() const
2593{
4370573a 2594 return SendMsg(2372, 0, 0) != 0;
67003d1a
RD
2595}
2596
4370573a
RD
2597// Set the zoom level. This number of points is added to the size of all fonts.
2598// It may be positive to magnify or negative to reduce.
8e0945da
VZ
2599void wxStyledTextCtrl::SetZoom(int zoom)
2600{
4370573a
RD
2601 SendMsg(2373, zoom, 0);
2602}
67003d1a 2603
4370573a 2604// Retrieve the zoom level.
8e0945da
VZ
2605int wxStyledTextCtrl::GetZoom() const
2606{
4370573a 2607 return SendMsg(2374, 0, 0);
67003d1a
RD
2608}
2609
4370573a
RD
2610// Create a new document object.
2611// Starts with reference count of 1 and not selected into editor.
2612void* wxStyledTextCtrl::CreateDocument() {
9e730a78 2613 return (void*)SendMsg(2375);
4370573a 2614}
67003d1a 2615
4370573a
RD
2616// Extend life of document.
2617void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
b796ba39 2618 SendMsg(2376, 0, (sptr_t)docPointer);
67003d1a
RD
2619}
2620
4370573a
RD
2621// Release a reference to the document, deleting document if it fades to black.
2622void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
b796ba39 2623 SendMsg(2377, 0, (sptr_t)docPointer);
4370573a 2624}
67003d1a 2625
4370573a 2626// Get which document modification events are sent to the container.
8e0945da
VZ
2627int wxStyledTextCtrl::GetModEventMask() const
2628{
4370573a 2629 return SendMsg(2378, 0, 0);
67003d1a
RD
2630}
2631
a834585d 2632// Change internal focus flag.
8e0945da
VZ
2633void wxStyledTextCtrl::SetSTCFocus(bool focus)
2634{
65ec6247
RD
2635 SendMsg(2380, focus, 0);
2636}
2637
a834585d 2638// Get internal focus flag.
8e0945da
VZ
2639bool wxStyledTextCtrl::GetSTCFocus() const
2640{
65ec6247
RD
2641 return SendMsg(2381, 0, 0) != 0;
2642}
2643
a834585d 2644// Change error status - 0 = OK.
8e0945da
VZ
2645void wxStyledTextCtrl::SetStatus(int statusCode)
2646{
65ec6247
RD
2647 SendMsg(2382, statusCode, 0);
2648}
2649
a834585d 2650// Get error status.
8e0945da
VZ
2651int wxStyledTextCtrl::GetStatus() const
2652{
65ec6247
RD
2653 return SendMsg(2383, 0, 0);
2654}
2655
a834585d 2656// Set whether the mouse is captured when its button is pressed.
8e0945da
VZ
2657void wxStyledTextCtrl::SetMouseDownCaptures(bool captures)
2658{
65ec6247
RD
2659 SendMsg(2384, captures, 0);
2660}
2661
a834585d 2662// Get whether mouse gets captured.
8e0945da
VZ
2663bool wxStyledTextCtrl::GetMouseDownCaptures() const
2664{
65ec6247
RD
2665 return SendMsg(2385, 0, 0) != 0;
2666}
2667
a834585d 2668// Sets the cursor to one of the SC_CURSOR* values.
8e0945da
VZ
2669void wxStyledTextCtrl::SetSTCCursor(int cursorType)
2670{
65ec6247
RD
2671 SendMsg(2386, cursorType, 0);
2672}
2673
a834585d 2674// Get cursor type.
8e0945da
VZ
2675int wxStyledTextCtrl::GetSTCCursor() const
2676{
65ec6247
RD
2677 return SendMsg(2387, 0, 0);
2678}
2679
1a2fb4cd 2680// Change the way control characters are displayed:
a834585d 2681// If symbol is < 32, keep the drawn way, else, use the given character.
8e0945da
VZ
2682void wxStyledTextCtrl::SetControlCharSymbol(int symbol)
2683{
1a2fb4cd
RD
2684 SendMsg(2388, symbol, 0);
2685}
2686
a834585d 2687// Get the way control characters are displayed.
8e0945da
VZ
2688int wxStyledTextCtrl::GetControlCharSymbol() const
2689{
1a2fb4cd
RD
2690 return SendMsg(2389, 0, 0);
2691}
2692
a834585d 2693// Move to the previous change in capitalisation.
8e0945da
VZ
2694void wxStyledTextCtrl::WordPartLeft()
2695{
65ec6247
RD
2696 SendMsg(2390, 0, 0);
2697}
2698
a834585d
RD
2699// Move to the previous change in capitalisation extending selection
2700// to new caret position.
8e0945da
VZ
2701void wxStyledTextCtrl::WordPartLeftExtend()
2702{
65ec6247
RD
2703 SendMsg(2391, 0, 0);
2704}
2705
a834585d 2706// Move to the change next in capitalisation.
8e0945da
VZ
2707void wxStyledTextCtrl::WordPartRight()
2708{
65ec6247
RD
2709 SendMsg(2392, 0, 0);
2710}
2711
a834585d
RD
2712// Move to the next change in capitalisation extending selection
2713// to new caret position.
8e0945da
VZ
2714void wxStyledTextCtrl::WordPartRightExtend()
2715{
65ec6247
RD
2716 SendMsg(2393, 0, 0);
2717}
2718
a834585d
RD
2719// Set the way the display area is determined when a particular line
2720// is to be moved to by Find, FindNext, GotoLine, etc.
8e0945da
VZ
2721void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop)
2722{
65ec6247
RD
2723 SendMsg(2394, visiblePolicy, visibleSlop);
2724}
2725
a834585d 2726// Delete back from the current position to the start of the line.
8e0945da
VZ
2727void wxStyledTextCtrl::DelLineLeft()
2728{
65ec6247
RD
2729 SendMsg(2395, 0, 0);
2730}
2731
a834585d 2732// Delete forwards from the current position to the end of the line.
8e0945da
VZ
2733void wxStyledTextCtrl::DelLineRight()
2734{
65ec6247
RD
2735 SendMsg(2396, 0, 0);
2736}
2737
a834585d 2738// Get and Set the xOffset (ie, horizonal scroll position).
8e0945da
VZ
2739void wxStyledTextCtrl::SetXOffset(int newOffset)
2740{
1a2fb4cd
RD
2741 SendMsg(2397, newOffset, 0);
2742}
8e0945da
VZ
2743int wxStyledTextCtrl::GetXOffset() const
2744{
1a2fb4cd
RD
2745 return SendMsg(2398, 0, 0);
2746}
2747
8e54aaed 2748// Set the last x chosen value to be the caret x position.
8e0945da
VZ
2749void wxStyledTextCtrl::ChooseCaretX()
2750{
9e730a78
RD
2751 SendMsg(2399, 0, 0);
2752}
2753
a834585d
RD
2754// Set the way the caret is kept visible when going sideway.
2755// The exclusion zone is given in pixels.
8e0945da
VZ
2756void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop)
2757{
a834585d
RD
2758 SendMsg(2402, caretPolicy, caretSlop);
2759}
2760
2761// Set the way the line the caret is on is kept visible.
2762// The exclusion zone is given in lines.
8e0945da
VZ
2763void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop)
2764{
a834585d
RD
2765 SendMsg(2403, caretPolicy, caretSlop);
2766}
2767
9e730a78 2768// Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
8e0945da
VZ
2769void wxStyledTextCtrl::SetPrintWrapMode(int mode)
2770{
9e730a78
RD
2771 SendMsg(2406, mode, 0);
2772}
2773
8e54aaed 2774// Is printing line wrapped?
8e0945da
VZ
2775int wxStyledTextCtrl::GetPrintWrapMode() const
2776{
9e730a78
RD
2777 return SendMsg(2407, 0, 0);
2778}
2779
2780// Set a fore colour for active hotspots.
8e0945da
VZ
2781void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore)
2782{
9e730a78
RD
2783 SendMsg(2410, useSetting, wxColourAsLong(fore));
2784}
2785
7e0c58e9 2786// Get the fore colour for active hotspots.
8e0945da
VZ
2787wxColour wxStyledTextCtrl::GetHotspotActiveForeground() const
2788{
7e0c58e9
RD
2789 long c = SendMsg(2494, 0, 0);
2790 return wxColourFromLong(c);
2791}
2792
9e730a78 2793// Set a back colour for active hotspots.
8e0945da
VZ
2794void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back)
2795{
9e730a78
RD
2796 SendMsg(2411, useSetting, wxColourAsLong(back));
2797}
2798
7e0c58e9 2799// Get the back colour for active hotspots.
8e0945da
VZ
2800wxColour wxStyledTextCtrl::GetHotspotActiveBackground() const
2801{
7e0c58e9
RD
2802 long c = SendMsg(2495, 0, 0);
2803 return wxColourFromLong(c);
2804}
2805
9e730a78 2806// Enable / Disable underlining active hotspots.
8e0945da
VZ
2807void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline)
2808{
9e730a78
RD
2809 SendMsg(2412, underline, 0);
2810}
2811
7e0c58e9 2812// Get whether underlining for active hotspots.
8e0945da
VZ
2813bool wxStyledTextCtrl::GetHotspotActiveUnderline() const
2814{
7e0c58e9
RD
2815 return SendMsg(2496, 0, 0) != 0;
2816}
2817
8e54aaed 2818// Limit hotspots to single line so hotspots on two lines don't merge.
8e0945da
VZ
2819void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine)
2820{
8e54aaed
RD
2821 SendMsg(2421, singleLine, 0);
2822}
2823
7e0c58e9 2824// Get the HotspotSingleLine property
8e0945da
VZ
2825bool wxStyledTextCtrl::GetHotspotSingleLine() const
2826{
7e0c58e9
RD
2827 return SendMsg(2497, 0, 0) != 0;
2828}
2829
c26dba42 2830// Move caret between paragraphs (delimited by empty lines).
8e0945da
VZ
2831void wxStyledTextCtrl::ParaDown()
2832{
c26dba42
RD
2833 SendMsg(2413, 0, 0);
2834}
8e0945da
VZ
2835void wxStyledTextCtrl::ParaDownExtend()
2836{
c26dba42
RD
2837 SendMsg(2414, 0, 0);
2838}
8e0945da
VZ
2839void wxStyledTextCtrl::ParaUp()
2840{
c26dba42
RD
2841 SendMsg(2415, 0, 0);
2842}
8e0945da
VZ
2843void wxStyledTextCtrl::ParaUpExtend()
2844{
c26dba42
RD
2845 SendMsg(2416, 0, 0);
2846}
2847
e14d10b0
RD
2848// Given a valid document position, return the previous position taking code
2849// page into account. Returns 0 if passed 0.
8e0945da
VZ
2850int wxStyledTextCtrl::PositionBefore(int pos)
2851{
e14d10b0
RD
2852 return SendMsg(2417, pos, 0);
2853}
2854
2855// Given a valid document position, return the next position taking code
2856// page into account. Maximum value returned is the last position in the document.
8e0945da
VZ
2857int wxStyledTextCtrl::PositionAfter(int pos)
2858{
e14d10b0
RD
2859 return SendMsg(2418, pos, 0);
2860}
2861
2862// Copy a range of text to the clipboard. Positions are clipped into the document.
8e0945da
VZ
2863void wxStyledTextCtrl::CopyRange(int start, int end)
2864{
e14d10b0
RD
2865 SendMsg(2419, start, end);
2866}
2867
2868// Copy argument text to the clipboard.
8e0945da
VZ
2869void wxStyledTextCtrl::CopyText(int length, const wxString& text)
2870{
b796ba39 2871 SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text));
e14d10b0
RD
2872}
2873
8e54aaed
RD
2874// Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2875// by lines (SC_SEL_LINES).
8e0945da
VZ
2876void wxStyledTextCtrl::SetSelectionMode(int mode)
2877{
8e54aaed
RD
2878 SendMsg(2422, mode, 0);
2879}
2880
2881// Get the mode of the current selection.
8e0945da
VZ
2882int wxStyledTextCtrl::GetSelectionMode() const
2883{
8e54aaed
RD
2884 return SendMsg(2423, 0, 0);
2885}
2886
2887// Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
8e0945da
VZ
2888int wxStyledTextCtrl::GetLineSelStartPosition(int line)
2889{
8e54aaed
RD
2890 return SendMsg(2424, line, 0);
2891}
2892
2893// Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
8e0945da
VZ
2894int wxStyledTextCtrl::GetLineSelEndPosition(int line)
2895{
8e54aaed
RD
2896 return SendMsg(2425, line, 0);
2897}
2898
c26dba42 2899// Move caret down one line, extending rectangular selection to new caret position.
8e0945da
VZ
2900void wxStyledTextCtrl::LineDownRectExtend()
2901{
c26dba42
RD
2902 SendMsg(2426, 0, 0);
2903}
2904
2905// Move caret up one line, extending rectangular selection to new caret position.
8e0945da
VZ
2906void wxStyledTextCtrl::LineUpRectExtend()
2907{
c26dba42
RD
2908 SendMsg(2427, 0, 0);
2909}
2910
2911// Move caret left one character, extending rectangular selection to new caret position.
8e0945da
VZ
2912void wxStyledTextCtrl::CharLeftRectExtend()
2913{
c26dba42
RD
2914 SendMsg(2428, 0, 0);
2915}
2916
2917// Move caret right one character, extending rectangular selection to new caret position.
8e0945da
VZ
2918void wxStyledTextCtrl::CharRightRectExtend()
2919{
c26dba42
RD
2920 SendMsg(2429, 0, 0);
2921}
2922
2923// Move caret to first position on line, extending rectangular selection to new caret position.
8e0945da
VZ
2924void wxStyledTextCtrl::HomeRectExtend()
2925{
c26dba42
RD
2926 SendMsg(2430, 0, 0);
2927}
2928
2929// Move caret to before first visible character on line.
2930// If already there move to first character on line.
2931// In either case, extend rectangular selection to new caret position.
8e0945da
VZ
2932void wxStyledTextCtrl::VCHomeRectExtend()
2933{
c26dba42
RD
2934 SendMsg(2431, 0, 0);
2935}
2936
2937// Move caret to last position on line, extending rectangular selection to new caret position.
8e0945da
VZ
2938void wxStyledTextCtrl::LineEndRectExtend()
2939{
c26dba42
RD
2940 SendMsg(2432, 0, 0);
2941}
2942
2943// Move caret one page up, extending rectangular selection to new caret position.
8e0945da
VZ
2944void wxStyledTextCtrl::PageUpRectExtend()
2945{
c26dba42
RD
2946 SendMsg(2433, 0, 0);
2947}
2948
2949// Move caret one page down, extending rectangular selection to new caret position.
8e0945da
VZ
2950void wxStyledTextCtrl::PageDownRectExtend()
2951{
c26dba42
RD
2952 SendMsg(2434, 0, 0);
2953}
2954
2955// Move caret to top of page, or one page up if already at top of page.
8e0945da
VZ
2956void wxStyledTextCtrl::StutteredPageUp()
2957{
c26dba42
RD
2958 SendMsg(2435, 0, 0);
2959}
2960
2961// Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
8e0945da
VZ
2962void wxStyledTextCtrl::StutteredPageUpExtend()
2963{
c26dba42
RD
2964 SendMsg(2436, 0, 0);
2965}
2966
2967// Move caret to bottom of page, or one page down if already at bottom of page.
8e0945da
VZ
2968void wxStyledTextCtrl::StutteredPageDown()
2969{
c26dba42
RD
2970 SendMsg(2437, 0, 0);
2971}
2972
2973// Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
8e0945da
VZ
2974void wxStyledTextCtrl::StutteredPageDownExtend()
2975{
c26dba42
RD
2976 SendMsg(2438, 0, 0);
2977}
2978
2979// Move caret left one word, position cursor at end of word.
8e0945da
VZ
2980void wxStyledTextCtrl::WordLeftEnd()
2981{
c26dba42
RD
2982 SendMsg(2439, 0, 0);
2983}
2984
2985// Move caret left one word, position cursor at end of word, extending selection to new caret position.
8e0945da
VZ
2986void wxStyledTextCtrl::WordLeftEndExtend()
2987{
c26dba42
RD
2988 SendMsg(2440, 0, 0);
2989}
2990
2991// Move caret right one word, position cursor at end of word.
8e0945da
VZ
2992void wxStyledTextCtrl::WordRightEnd()
2993{
c26dba42
RD
2994 SendMsg(2441, 0, 0);
2995}
2996
2997// Move caret right one word, position cursor at end of word, extending selection to new caret position.
8e0945da
VZ
2998void wxStyledTextCtrl::WordRightEndExtend()
2999{
c26dba42
RD
3000 SendMsg(2442, 0, 0);
3001}
3002
8e54aaed
RD
3003// Set the set of characters making up whitespace for when moving or selecting by word.
3004// Should be called after SetWordChars.
8e0945da
VZ
3005void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters)
3006{
b796ba39 3007 SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters));
8e54aaed
RD
3008}
3009
3010// Reset the set of characters for whitespace and word characters to the defaults.
8e0945da
VZ
3011void wxStyledTextCtrl::SetCharsDefault()
3012{
8e54aaed
RD
3013 SendMsg(2444, 0, 0);
3014}
3015
3016// Get currently selected item position in the auto-completion list
8e0945da
VZ
3017int wxStyledTextCtrl::AutoCompGetCurrent()
3018{
8e54aaed
RD
3019 return SendMsg(2445, 0, 0);
3020}
3021
591d01be 3022// Enlarge the document to a particular size of text bytes.
8e0945da
VZ
3023void wxStyledTextCtrl::Allocate(int bytes)
3024{
591d01be
RD
3025 SendMsg(2446, bytes, 0);
3026}
3027
1e9bafca 3028// Find the position of a column on a line taking into account tabs and
a33203cb 3029// multi-byte characters. If beyond end of line, return line end position.
8e0945da
VZ
3030int wxStyledTextCtrl::FindColumn(int line, int column)
3031{
a33203cb
RD
3032 return SendMsg(2456, line, column);
3033}
3034
1e9bafca 3035// Can the caret preferred x position only be changed by explicit movement commands?
8e0945da
VZ
3036bool wxStyledTextCtrl::GetCaretSticky() const
3037{
1e9bafca
RD
3038 return SendMsg(2457, 0, 0) != 0;
3039}
3040
3041// Stop the caret preferred x position changing when the user types.
8e0945da
VZ
3042void wxStyledTextCtrl::SetCaretSticky(bool useCaretStickyBehaviour)
3043{
1e9bafca
RD
3044 SendMsg(2458, useCaretStickyBehaviour, 0);
3045}
3046
3047// Switch between sticky and non-sticky: meant to be bound to a key.
8e0945da
VZ
3048void wxStyledTextCtrl::ToggleCaretSticky()
3049{
1e9bafca
RD
3050 SendMsg(2459, 0, 0);
3051}
3052
3053// Enable/Disable convert-on-paste for line endings
8e0945da
VZ
3054void wxStyledTextCtrl::SetPasteConvertEndings(bool convert)
3055{
1e9bafca
RD
3056 SendMsg(2467, convert, 0);
3057}
3058
3059// Get convert-on-paste setting
8e0945da
VZ
3060bool wxStyledTextCtrl::GetPasteConvertEndings() const
3061{
1e9bafca
RD
3062 return SendMsg(2468, 0, 0) != 0;
3063}
3064
3065// Duplicate the selection. If selection empty duplicate the line containing the caret.
8e0945da
VZ
3066void wxStyledTextCtrl::SelectionDuplicate()
3067{
1e9bafca
RD
3068 SendMsg(2469, 0, 0);
3069}
3070
b8193d80 3071// Set background alpha of the caret line.
8e0945da
VZ
3072void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha)
3073{
b8193d80
RD
3074 SendMsg(2470, alpha, 0);
3075}
3076
3077// Get the background alpha of the caret line.
8e0945da
VZ
3078int wxStyledTextCtrl::GetCaretLineBackAlpha() const
3079{
b8193d80
RD
3080 return SendMsg(2471, 0, 0);
3081}
3082
7e0c58e9 3083// Set the style of the caret to be drawn.
8e0945da
VZ
3084void wxStyledTextCtrl::SetCaretStyle(int caretStyle)
3085{
7e0c58e9
RD
3086 SendMsg(2512, caretStyle, 0);
3087}
3088
3089// Returns the current style of the caret.
8e0945da
VZ
3090int wxStyledTextCtrl::GetCaretStyle() const
3091{
7e0c58e9
RD
3092 return SendMsg(2513, 0, 0);
3093}
3094
3095// Set the indicator used for IndicatorFillRange and IndicatorClearRange
8e0945da
VZ
3096void wxStyledTextCtrl::SetIndicatorCurrent(int indicator)
3097{
7e0c58e9
RD
3098 SendMsg(2500, indicator, 0);
3099}
3100
3101// Get the current indicator
8e0945da
VZ
3102int wxStyledTextCtrl::GetIndicatorCurrent() const
3103{
7e0c58e9
RD
3104 return SendMsg(2501, 0, 0);
3105}
3106
3107// Set the value used for IndicatorFillRange
8e0945da
VZ
3108void wxStyledTextCtrl::SetIndicatorValue(int value)
3109{
7e0c58e9
RD
3110 SendMsg(2502, value, 0);
3111}
3112
3113// Get the current indicator vaue
8e0945da
VZ
3114int wxStyledTextCtrl::GetIndicatorValue() const
3115{
7e0c58e9
RD
3116 return SendMsg(2503, 0, 0);
3117}
3118
3119// Turn a indicator on over a range.
8e0945da
VZ
3120void wxStyledTextCtrl::IndicatorFillRange(int position, int fillLength)
3121{
7e0c58e9
RD
3122 SendMsg(2504, position, fillLength);
3123}
3124
3125// Turn a indicator off over a range.
8e0945da
VZ
3126void wxStyledTextCtrl::IndicatorClearRange(int position, int clearLength)
3127{
7e0c58e9
RD
3128 SendMsg(2505, position, clearLength);
3129}
3130
3131// Are any indicators present at position?
8e0945da
VZ
3132int wxStyledTextCtrl::IndicatorAllOnFor(int position)
3133{
7e0c58e9
RD
3134 return SendMsg(2506, position, 0);
3135}
3136
3137// What value does a particular indicator have at at a position?
8e0945da
VZ
3138int wxStyledTextCtrl::IndicatorValueAt(int indicator, int position)
3139{
7e0c58e9
RD
3140 return SendMsg(2507, indicator, position);
3141}
3142
3143// Where does a particular indicator start?
8e0945da
VZ
3144int wxStyledTextCtrl::IndicatorStart(int indicator, int position)
3145{
7e0c58e9
RD
3146 return SendMsg(2508, indicator, position);
3147}
3148
3149// Where does a particular indicator end?
8e0945da
VZ
3150int wxStyledTextCtrl::IndicatorEnd(int indicator, int position)
3151{
7e0c58e9
RD
3152 return SendMsg(2509, indicator, position);
3153}
3154
3155// Set number of entries in position cache
8e0945da
VZ
3156void wxStyledTextCtrl::SetPositionCacheSize(int size)
3157{
7e0c58e9
RD
3158 SendMsg(2514, size, 0);
3159}
3160
3161// How many entries are allocated to the position cache?
8e0945da
VZ
3162int wxStyledTextCtrl::GetPositionCacheSize() const
3163{
7e0c58e9
RD
3164 return SendMsg(2515, 0, 0);
3165}
3166
4370573a 3167// Start notifying the container of all key presses and commands.
8e0945da
VZ
3168void wxStyledTextCtrl::StartRecord()
3169{
4370573a
RD
3170 SendMsg(3001, 0, 0);
3171}
67003d1a 3172
4370573a 3173// Stop notifying the container of all key presses and commands.
8e0945da
VZ
3174void wxStyledTextCtrl::StopRecord()
3175{
4370573a 3176 SendMsg(3002, 0, 0);
67003d1a
RD
3177}
3178
4370573a 3179// Set the lexing language of the document.
8e0945da
VZ
3180void wxStyledTextCtrl::SetLexer(int lexer)
3181{
4370573a
RD
3182 SendMsg(4001, lexer, 0);
3183}
67003d1a 3184
4370573a 3185// Retrieve the lexing language of the document.
8e0945da
VZ
3186int wxStyledTextCtrl::GetLexer() const
3187{
4370573a 3188 return SendMsg(4002, 0, 0);
67003d1a
RD
3189}
3190
4370573a 3191// Colourise a segment of the document using the current lexing language.
8e0945da
VZ
3192void wxStyledTextCtrl::Colourise(int start, int end)
3193{
4370573a
RD
3194 SendMsg(4003, start, end);
3195}
67003d1a 3196
4370573a 3197// Set up a value that may be used by a lexer for some optional feature.
8e0945da
VZ
3198void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
3199{
b796ba39 3200 SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
f6bcfd97
BP
3201}
3202
4370573a 3203// Set up the key words used by the lexer.
8e0945da
VZ
3204void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords)
3205{
b796ba39 3206 SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords));
4370573a 3207}
f6bcfd97 3208
65ec6247 3209// Set the lexing language of the document based on string name.
8e0945da
VZ
3210void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
3211{
b796ba39 3212 SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language));
65ec6247
RD
3213}
3214
1e9bafca
RD
3215// Retrieve a 'property' value previously set with SetProperty.
3216wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
b796ba39 3217 int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0);
1e9bafca
RD
3218 if (!len) return wxEmptyString;
3219
3220 wxMemoryBuffer mbuf(len+1);
3221 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 3222 SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
1e9bafca
RD
3223 mbuf.UngetWriteBuf(len);
3224 mbuf.AppendByte(0);
3225 return stc2wx(buf);
3226}
3227
3228// Retrieve a 'property' value previously set with SetProperty,
3229// with '$()' variable replacement on returned buffer.
3230wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
b796ba39 3231 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0);
1e9bafca
RD
3232 if (!len) return wxEmptyString;
3233
3234 wxMemoryBuffer mbuf(len+1);
3235 char* buf = (char*)mbuf.GetWriteBuf(len+1);
b796ba39 3236 SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
1e9bafca
RD
3237 mbuf.UngetWriteBuf(len);
3238 mbuf.AppendByte(0);
3239 return stc2wx(buf);
3240}
3241
3242// Retrieve a 'property' value previously set with SetProperty,
3243// interpreted as an int AFTER any '$()' variable replacement.
8e0945da
VZ
3244int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const
3245{
b796ba39 3246 return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0);
1e9bafca
RD
3247}
3248
3249// Retrieve the number of bits the current lexer needs for styling.
8e0945da
VZ
3250int wxStyledTextCtrl::GetStyleBitsNeeded() const
3251{
1e9bafca
RD
3252 return SendMsg(4011, 0, 0);
3253}
3254
a5c2ccf2 3255//}}}
f6bcfd97 3256//----------------------------------------------------------------------
f6bcfd97
BP
3257
3258
4370573a
RD
3259// Returns the line number of the line with the caret.
3260int wxStyledTextCtrl::GetCurrentLine() {
3261 int line = LineFromPosition(GetCurrentPos());
3262 return line;
f6bcfd97
BP
3263}
3264
3265
4370573a
RD
3266// Extract style settings from a spec-string which is composed of one or
3267// more of the following comma separated elements:
3268//
3269// bold turns on bold
3270// italic turns on italics
5ee1d760
RD
3271// fore:[name or #RRGGBB] sets the foreground colour
3272// back:[name or #RRGGBB] sets the background colour
4370573a
RD
3273// face:[facename] sets the font face name to use
3274// size:[num] sets the font size in points
3275// eol turns on eol filling
3276// underline turns on underlining
3277//
3278void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
3279
451c5cc7 3280 wxStringTokenizer tkz(spec, wxT(","));
4370573a
RD
3281 while (tkz.HasMoreTokens()) {
3282 wxString token = tkz.GetNextToken();
f6bcfd97 3283
4370573a
RD
3284 wxString option = token.BeforeFirst(':');
3285 wxString val = token.AfterFirst(':');
f6bcfd97 3286
451c5cc7 3287 if (option == wxT("bold"))
4370573a 3288 StyleSetBold(styleNum, true);
f6bcfd97 3289
451c5cc7 3290 else if (option == wxT("italic"))
4370573a 3291 StyleSetItalic(styleNum, true);
9ce192d4 3292
451c5cc7 3293 else if (option == wxT("underline"))
4370573a 3294 StyleSetUnderline(styleNum, true);
9ce192d4 3295
451c5cc7 3296 else if (option == wxT("eol"))
4370573a 3297 StyleSetEOLFilled(styleNum, true);
9ce192d4 3298
451c5cc7 3299 else if (option == wxT("size")) {
4370573a
RD
3300 long points;
3301 if (val.ToLong(&points))
3302 StyleSetSize(styleNum, points);
3303 }
9ce192d4 3304
451c5cc7 3305 else if (option == wxT("face"))
4370573a 3306 StyleSetFaceName(styleNum, val);
9ce192d4 3307
451c5cc7 3308 else if (option == wxT("fore"))
4370573a 3309 StyleSetForeground(styleNum, wxColourFromSpec(val));
9ce192d4 3310
451c5cc7 3311 else if (option == wxT("back"))
4370573a
RD
3312 StyleSetBackground(styleNum, wxColourFromSpec(val));
3313 }
9ce192d4
RD
3314}
3315
3316
7e0c58e9
RD
3317// Get the font of a style
3318wxFont wxStyledTextCtrl::StyleGetFont(int style) {
3319 wxFont font;
3320 font.SetPointSize(StyleGetSize(style));
3321 font.SetFaceName(StyleGetFaceName(style));
3322 if( StyleGetBold(style) )
3323 font.SetWeight(wxFONTWEIGHT_BOLD);
3324 else
3325 font.SetWeight(wxFONTWEIGHT_NORMAL);
3326
3327 if( StyleGetItalic(style) )
3328 font.SetStyle(wxFONTSTYLE_ITALIC);
3329 else
3330 font.SetStyle(wxFONTSTYLE_NORMAL);
3331
3332 return font;
3333}
3334
3335
4370573a
RD
3336// Set style size, face, bold, italic, and underline attributes from
3337// a wxFont's attributes.
3338void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
7475e814
RD
3339#ifdef __WXGTK__
3340 // Ensure that the native font is initialized
3341 int x, y;
3342 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
3343#endif
af0531a5
RD
3344 int size = font.GetPointSize();
3345 wxString faceName = font.GetFaceName();
3346 bool bold = font.GetWeight() == wxBOLD;
3347 bool italic = font.GetStyle() != wxNORMAL;
3348 bool under = font.GetUnderlined();
c5bd09bf 3349 wxFontEncoding encoding = font.GetEncoding();
7e0c58e9 3350
af0531a5 3351 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
9ce192d4
RD
3352}
3353
4370573a
RD
3354// Set all font style attributes at once.
3355void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
3356 const wxString& faceName,
3357 bool bold, bool italic,
3727c043
RD
3358 bool underline,
3359 wxFontEncoding encoding) {
4370573a
RD
3360 StyleSetSize(styleNum, size);
3361 StyleSetFaceName(styleNum, faceName);
3362 StyleSetBold(styleNum, bold);
3363 StyleSetItalic(styleNum, italic);
3364 StyleSetUnderline(styleNum, underline);
3727c043
RD
3365 StyleSetFontEncoding(styleNum, encoding);
3366}
9ce192d4 3367
3727c043
RD
3368
3369// Set the character set of the font in a style. Converts the Scintilla
3370// character set values to a wxFontEncoding.
3371void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
3372{
3373 wxFontEncoding encoding;
3374
3375 // Translate the Scintilla characterSet to a wxFontEncoding
3376 switch (characterSet) {
3377 default:
3378 case wxSTC_CHARSET_ANSI:
3379 case wxSTC_CHARSET_DEFAULT:
3380 encoding = wxFONTENCODING_DEFAULT;
3381 break;
3382
3383 case wxSTC_CHARSET_BALTIC:
3384 encoding = wxFONTENCODING_ISO8859_13;
3385 break;
3386
3387 case wxSTC_CHARSET_CHINESEBIG5:
3388 encoding = wxFONTENCODING_CP950;
3389 break;
3390
3391 case wxSTC_CHARSET_EASTEUROPE:
3392 encoding = wxFONTENCODING_ISO8859_2;
3393 break;
3394
3395 case wxSTC_CHARSET_GB2312:
3396 encoding = wxFONTENCODING_CP936;
3397 break;
3398
3399 case wxSTC_CHARSET_GREEK:
3400 encoding = wxFONTENCODING_ISO8859_7;
3401 break;
3402
3403 case wxSTC_CHARSET_HANGUL:
3404 encoding = wxFONTENCODING_CP949;
3405 break;
3406
3407 case wxSTC_CHARSET_MAC:
3408 encoding = wxFONTENCODING_DEFAULT;
3409 break;
3410
3411 case wxSTC_CHARSET_OEM:
3412 encoding = wxFONTENCODING_DEFAULT;
3413 break;
3414
3415 case wxSTC_CHARSET_RUSSIAN:
3416 encoding = wxFONTENCODING_KOI8;
3417 break;
3418
3419 case wxSTC_CHARSET_SHIFTJIS:
3420 encoding = wxFONTENCODING_CP932;
3421 break;
3422
3423 case wxSTC_CHARSET_SYMBOL:
3424 encoding = wxFONTENCODING_DEFAULT;
3425 break;
3426
3427 case wxSTC_CHARSET_TURKISH:
3428 encoding = wxFONTENCODING_ISO8859_9;
3429 break;
3430
3431 case wxSTC_CHARSET_JOHAB:
3432 encoding = wxFONTENCODING_DEFAULT;
3433 break;
3434
3435 case wxSTC_CHARSET_HEBREW:
3436 encoding = wxFONTENCODING_ISO8859_8;
3437 break;
3438
3439 case wxSTC_CHARSET_ARABIC:
3440 encoding = wxFONTENCODING_ISO8859_6;
3441 break;
3442
3443 case wxSTC_CHARSET_VIETNAMESE:
3444 encoding = wxFONTENCODING_DEFAULT;
3445 break;
3446
3447 case wxSTC_CHARSET_THAI:
3448 encoding = wxFONTENCODING_ISO8859_11;
3449 break;
1e9bafca
RD
3450
3451 case wxSTC_CHARSET_CYRILLIC:
3452 encoding = wxFONTENCODING_ISO8859_5;
3453 break;
7e0c58e9 3454
1e9bafca
RD
3455 case wxSTC_CHARSET_8859_15:
3456 encoding = wxFONTENCODING_ISO8859_15;;
3457 break;
3727c043
RD
3458 }
3459
3460 // We just have Scintilla track the wxFontEncoding for us. It gets used
3461 // in Font::Create in PlatWX.cpp. We add one to the value so that the
3462 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
3463 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
3464 // to wxFONENCODING_DEFAULT in Font::Create.
3465 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
3466}
3467
3468
3469// Set the font encoding to be used by a style.
3470void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
3471{
3472 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
9ce192d4
RD
3473}
3474
3475
4370573a
RD
3476// Perform one of the operations defined by the wxSTC_CMD_* constants.
3477void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
3478 SendMsg(cmd);
9ce192d4
RD
3479}
3480
3481
4370573a
RD
3482// Set the left and right margin in the edit area, measured in pixels.
3483void wxStyledTextCtrl::SetMargins(int left, int right) {
3484 SetMarginLeft(left);
3485 SetMarginRight(right);
9ce192d4
RD
3486}
3487
3488
4370573a
RD
3489// Retrieve the start and end positions of the current selection.
3490void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
3491 if (startPos != NULL)
3492 *startPos = SendMsg(SCI_GETSELECTIONSTART);
3493 if (endPos != NULL)
3494 *endPos = SendMsg(SCI_GETSELECTIONEND);
9ce192d4
RD
3495}
3496
3497
4370573a
RD
3498// Retrieve the point in the window where a position is displayed.
3499wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
3500 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
3501 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
3502 return wxPoint(x, y);
f6bcfd97
BP
3503}
3504
f97d84a6
RD
3505// Scroll enough to make the given line visible
3506void wxStyledTextCtrl::ScrollToLine(int line) {
3507 m_swx->DoScrollToLine(line);
3508}
3509
3510
3511// Scroll enough to make the given column visible
3512void wxStyledTextCtrl::ScrollToColumn(int column) {
3513 m_swx->DoScrollToColumn(column);
3514}
3515
f6bcfd97 3516
2bfca191
VZ
3517#if wxUSE_TEXTCTRL
3518bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
3519#else
51566b0b 3520bool wxStyledTextCtrl::SaveFile(const wxString& filename)
2bfca191 3521#endif
51566b0b
RD
3522{
3523 wxFile file(filename, wxFile::write);
3524
3525 if (!file.IsOpened())
7e126a07 3526 return false;
51566b0b 3527
88a8b04e 3528 bool success = file.Write(GetText(), *wxConvCurrent);
51566b0b 3529
4a65f2c8 3530 if (success)
51566b0b 3531 SetSavePoint();
4a65f2c8 3532
51566b0b
RD
3533 return success;
3534}
3535
2bfca191
VZ
3536#if wxUSE_TEXTCTRL
3537bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
3538#else
51566b0b 3539bool wxStyledTextCtrl::LoadFile(const wxString& filename)
2bfca191 3540#endif
51566b0b 3541{
041973c5 3542 bool success = false;
51566b0b
RD
3543 wxFile file(filename, wxFile::read);
3544
041973c5 3545 if (file.IsOpened())
51566b0b 3546 {
041973c5 3547 wxString contents;
c8b75e94
WS
3548 // get the file size (assume it is not huge file...)
3549 ssize_t len = (ssize_t)file.Length();
3550
041973c5
RD
3551 if (len > 0)
3552 {
1e545382 3553#if wxUSE_UNICODE
1c26fbe0 3554 wxMemoryBuffer buffer(len+1);
8e5ec9cc 3555 success = (file.Read(buffer.GetData(), len) == len);
ccfc3219 3556 if (success) {
9efe0302
RD
3557 ((char*)buffer.GetData())[len] = 0;
3558 contents = wxString(buffer, *wxConvCurrent, len);
3559 }
88a8b04e 3560#else
8e5ec9cc
MB
3561 wxString buffer;
3562 success = (file.Read(wxStringBuffer(buffer, len), len) == len);
88a8b04e
RD
3563 contents = buffer;
3564#endif
041973c5
RD
3565 }
3566 else
c8b75e94
WS
3567 {
3568 if (len == 0)
3569 success = true; // empty file is ok
3570 else
3571 success = false; // len == wxInvalidOffset
3572 }
041973c5
RD
3573
3574 if (success)
3575 {
3576 SetText(contents);
3577 EmptyUndoBuffer();
3578 SetSavePoint();
3579 }
51566b0b
RD
3580 }
3581
3582 return success;
3583}
3584
d25f5fbb 3585
2fcce896 3586#if wxUSE_DRAG_AND_DROP
7e126a07
WS
3587wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
3588 return m_swx->DoDragOver(x, y, def);
3589}
4a65f2c8
RD
3590
3591
7e126a07 3592bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
4a65f2c8
RD
3593 return m_swx->DoDropText(x, y, data);
3594}
2fcce896 3595#endif
4a65f2c8
RD
3596
3597
d1558f3d
RD
3598void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
3599 m_swx->SetUseAntiAliasing(useAA);
3600}
3601
3602bool wxStyledTextCtrl::GetUseAntiAliasing() {
3603 return m_swx->GetUseAntiAliasing();
3604}
3605
41a499cd
RD
3606
3607
3608
3609
3610void wxStyledTextCtrl::AddTextRaw(const char* text)
3611{
b796ba39 3612 SendMsg(SCI_ADDTEXT, strlen(text), (sptr_t)text);
41a499cd
RD
3613}
3614
3615void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
3616{
b796ba39 3617 SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text);
41a499cd
RD
3618}
3619
3620wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
3621{
3622 int len = LineLength(GetCurrentLine());
3623 if (!len) {
3624 if (linePos) *linePos = 0;
3625 wxCharBuffer empty;
3626 return empty;
3627 }
3628
3629 wxCharBuffer buf(len);
b796ba39 3630 int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data());
41a499cd
RD
3631 if (linePos) *linePos = pos;
3632 return buf;
3633}
3634
3635wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
3636{
3637 int len = LineLength(line);
3638 if (!len) {
3639 wxCharBuffer empty;
3640 return empty;
3641 }
3642
3643 wxCharBuffer buf(len);
b796ba39 3644 SendMsg(SCI_GETLINE, line, (sptr_t)buf.data());
41a499cd
RD
3645 return buf;
3646}
3647
3648wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
3649{
3650 int start;
3651 int end;
3652
3653 GetSelection(&start, &end);
3654 int len = end - start;
3655 if (!len) {
3656 wxCharBuffer empty;
3657 return empty;
7e0c58e9 3658 }
41a499cd
RD
3659
3660 wxCharBuffer buf(len);
b796ba39 3661 SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
41a499cd
RD
3662 return buf;
3663}
3664
3665wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
3666{
3667 if (endPos < startPos) {
3668 int temp = startPos;
3669 startPos = endPos;
3670 endPos = temp;
3671 }
3672 int len = endPos - startPos;
3673 if (!len) {
3674 wxCharBuffer empty;
3675 return empty;
7e0c58e9 3676 }
41a499cd
RD
3677
3678 wxCharBuffer buf(len);
3679 TextRange tr;
3680 tr.lpstrText = buf.data();
3681 tr.chrg.cpMin = startPos;
3682 tr.chrg.cpMax = endPos;
b796ba39 3683 SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
41a499cd
RD
3684 return buf;
3685}
3686
3687void wxStyledTextCtrl::SetTextRaw(const char* text)
3688{
b796ba39 3689 SendMsg(SCI_SETTEXT, 0, (sptr_t)text);
41a499cd
RD
3690}
3691
3692wxCharBuffer wxStyledTextCtrl::GetTextRaw()
3693{
949750de
VZ
3694 int len = GetTextLength();
3695 wxCharBuffer buf(len); // adds 1 for NUL automatically
b796ba39 3696 SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data());
41a499cd
RD
3697 return buf;
3698}
3699
3700void wxStyledTextCtrl::AppendTextRaw(const char* text)
3701{
b796ba39 3702 SendMsg(SCI_APPENDTEXT, strlen(text), (sptr_t)text);
41a499cd
RD
3703}
3704
3705
3706
3707
3708
9ce192d4
RD
3709//----------------------------------------------------------------------
3710// Event handlers
3711
88a8b04e 3712void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
9ce192d4 3713 wxPaintDC dc(this);
9e730a78 3714 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
9ce192d4
RD
3715}
3716
3717void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
3718 if (evt.GetOrientation() == wxHORIZONTAL)
3719 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
3720 else
3721 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
3722}
3723
5fa4613c
RD
3724void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
3725 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
3726 if (sb) {
3727 if (sb->IsVertical())
3728 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
3729 else
3730 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
3731 }
3732}
3733
88a8b04e 3734void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
39c0acb6
RD
3735 if (m_swx) {
3736 wxSize sz = GetClientSize();
3737 m_swx->DoSize(sz.x, sz.y);
3738 }
9ce192d4
RD
3739}
3740
3741void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
cb1871ca 3742 SetFocus();
9ce192d4 3743 wxPoint pt = evt.GetPosition();
2b5f62a0 3744 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
9ce192d4
RD
3745 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
3746}
3747
3748void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
3749 wxPoint pt = evt.GetPosition();
2b5f62a0 3750 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
9ce192d4
RD
3751}
3752
3753void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
3754 wxPoint pt = evt.GetPosition();
2b5f62a0 3755 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
9ce192d4
RD
3756 evt.ControlDown());
3757}
3758
3759
ddf2da08
RD
3760void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
3761 wxPoint pt = evt.GetPosition();
3762 m_swx->DoContextMenu(Point(pt.x, pt.y));
3763}
3764
3765
2b5f62a0
VZ
3766void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
3767 wxPoint pt = evt.GetPosition();
3768 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
3769}
3770
65ec6247 3771void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
9ce192d4 3772 wxPoint pt = evt.GetPosition();
65ec6247 3773 ScreenToClient(&pt.x, &pt.y);
25484746
RD
3774 /*
3775 Show context menu at event point if it's within the window,
3776 or at caret location if not
3777 */
3778 wxHitTest ht = this->HitTest(pt);
3779 if (ht != wxHT_WINDOW_INSIDE) {
3780 pt = this->PointFromPosition(this->GetCurrentPos());
3781 }
9ce192d4
RD
3782 m_swx->DoContextMenu(Point(pt.x, pt.y));
3783}
3784
37d62433 3785
60957703
VZ
3786void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
3787{
3788 // prevent having an event queue with wheel events that cannot be processed
3789 // reasonably fast (see ticket #9057)
3790 if ( m_lastWheelTimestamp <= evt.GetTimestamp() )
3791 {
3792 m_lastWheelTimestamp = m_stopWatch.Time();
3793 m_swx->DoMouseWheel(evt.GetWheelRotation(),
3794 evt.GetWheelDelta(),
3795 evt.GetLinesPerAction(),
3796 evt.ControlDown(),
3797 evt.IsPageScroll());
3798 m_lastWheelTimestamp = m_stopWatch.Time() - m_lastWheelTimestamp;
3799 m_lastWheelTimestamp += evt.GetTimestamp();
3800 }
37d62433
RD
3801}
3802
3803
9ce192d4 3804void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
5fd656d5 3805 // On (some?) non-US PC keyboards the AltGr key is required to enter some
f3c2c221
RD
3806 // common characters. It comes to us as both Alt and Ctrl down so we need
3807 // to let the char through in that case, otherwise if only ctrl or only
3808 // alt let's skip it.
3809 bool ctrl = evt.ControlDown();
28e0c28e
RD
3810#ifdef __WXMAC__
3811 // On the Mac the Alt key is just a modifier key (like Shift) so we need
3812 // to allow the char events to be processed when Alt is pressed.
3813 // TODO: Should we check MetaDown instead in this case?
3814 bool alt = false;
3815#else
f3c2c221 3816 bool alt = evt.AltDown();
28e0c28e 3817#endif
00c64037 3818 bool skip = ((ctrl || alt) && ! (ctrl && alt));
f3c2c221 3819
a0421c77
RD
3820#if wxUSE_UNICODE
3821 // apparently if we don't do this, Unicode keys pressed after non-char
3822 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
3823 if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255)
3824 m_lastKeyDownConsumed = false;
3825#endif
3826
5fd656d5
RD
3827 if (!m_lastKeyDownConsumed && !skip) {
3828#if wxUSE_UNICODE
3829 int key = evt.GetUnicodeKey();
3830 bool keyOk = true;
3831
3832 // if the unicode key code is not really a unicode character (it may
3833 // be a function key or etc., the platforms appear to always give us a
3834 // small value in this case) then fallback to the ascii key code but
3835 // don't do anything for function keys or etc.
1b14227e 3836 if (key <= 127) {
5fd656d5 3837 key = evt.GetKeyCode();
1b14227e 3838 keyOk = (key <= 127);
5fd656d5
RD
3839 }
3840 if (keyOk) {
3841 m_swx->DoAddChar(key);
3842 return;
3843 }
3844#else
3845 int key = evt.GetKeyCode();
3846 if (key <= WXK_START || key > WXK_COMMAND) {
3847 m_swx->DoAddChar(key);
3848 return;
3849 }
3850#endif
d25f5fbb 3851 }
7e0c58e9 3852
f3c2c221 3853 evt.Skip();
f6bcfd97
BP
3854}
3855
d6582821 3856
f6bcfd97 3857void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
5fd656d5 3858 int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
d6582821 3859 if (!processed && !m_lastKeyDownConsumed)
9ce192d4
RD
3860 evt.Skip();
3861}
3862
d6582821 3863
b6bfd8e8 3864void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
ec830416 3865 m_swx->DoLoseFocus();
b6bfd8e8 3866 evt.Skip();
9ce192d4
RD
3867}
3868
d6582821 3869
b6bfd8e8 3870void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
9ce192d4 3871 m_swx->DoGainFocus();
b6bfd8e8 3872 evt.Skip();
9ce192d4
RD
3873}
3874
d6582821 3875
88a8b04e 3876void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
9ce192d4
RD
3877 m_swx->DoSysColourChange();
3878}
3879
d6582821 3880
88a8b04e 3881void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
9ce192d4
RD
3882 // do nothing to help avoid flashing
3883}
3884
3885
3886
3887void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
3888 m_swx->DoCommand(evt.GetId());
3889}
3890
3891
88a8b04e 3892void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
f6bcfd97
BP
3893 m_swx->DoOnListBox();
3894}
3895
3896
8e54aaed
RD
3897void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
3898 m_swx->DoOnIdle(evt);
3899}
3900
3901
8ae4f086
RD
3902wxSize wxStyledTextCtrl::DoGetBestSize() const
3903{
3904 // What would be the best size for a wxSTC?
3905 // Just give a reasonable minimum until something else can be figured out.
3906 return wxSize(200,100);
3907}
3908
3909
9ce192d4
RD
3910//----------------------------------------------------------------------
3911// Turn notifications from Scintilla into events
3912
f6bcfd97 3913
9ce192d4
RD
3914void wxStyledTextCtrl::NotifyChange() {
3915 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
a29a241f 3916 evt.SetEventObject(this);
9ce192d4
RD
3917 GetEventHandler()->ProcessEvent(evt);
3918}
3919
2b5f62a0
VZ
3920
3921static void SetEventText(wxStyledTextEvent& evt, const char* text,
3922 size_t length) {
3923 if(!text) return;
3924
1c930beb 3925 evt.SetText(stc2wx(text, length));
2b5f62a0
VZ
3926}
3927
3928
9ce192d4
RD
3929void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
3930 SCNotification& scn = *_scn;
65ec6247
RD
3931 wxStyledTextEvent evt(0, GetId());
3932
a29a241f 3933 evt.SetEventObject(this);
65ec6247
RD
3934 evt.SetPosition(scn.position);
3935 evt.SetKey(scn.ch);
3936 evt.SetModifiers(scn.modifiers);
3937
9ce192d4
RD
3938 switch (scn.nmhdr.code) {
3939 case SCN_STYLENEEDED:
65ec6247 3940 evt.SetEventType(wxEVT_STC_STYLENEEDED);
9ce192d4 3941 break;
65ec6247 3942
9ce192d4 3943 case SCN_CHARADDED:
65ec6247 3944 evt.SetEventType(wxEVT_STC_CHARADDED);
9ce192d4 3945 break;
65ec6247 3946
9ce192d4 3947 case SCN_SAVEPOINTREACHED:
65ec6247 3948 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
9ce192d4 3949 break;
65ec6247 3950
9ce192d4 3951 case SCN_SAVEPOINTLEFT:
65ec6247 3952 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
9ce192d4 3953 break;
65ec6247 3954
9ce192d4 3955 case SCN_MODIFYATTEMPTRO:
65ec6247 3956 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
9ce192d4 3957 break;
65ec6247
RD
3958
3959 case SCN_KEY:
3960 evt.SetEventType(wxEVT_STC_KEY);
3961 break;
3962
9ce192d4 3963 case SCN_DOUBLECLICK:
65ec6247 3964 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
9ce192d4 3965 break;
65ec6247
RD
3966
3967 case SCN_UPDATEUI:
3968 evt.SetEventType(wxEVT_STC_UPDATEUI);
9ce192d4 3969 break;
65ec6247
RD
3970
3971 case SCN_MODIFIED:
3972 evt.SetEventType(wxEVT_STC_MODIFIED);
3973 evt.SetModificationType(scn.modificationType);
2b5f62a0 3974 SetEventText(evt, scn.text, scn.length);
65ec6247
RD
3975 evt.SetLength(scn.length);
3976 evt.SetLinesAdded(scn.linesAdded);
3977 evt.SetLine(scn.line);
3978 evt.SetFoldLevelNow(scn.foldLevelNow);
3979 evt.SetFoldLevelPrev(scn.foldLevelPrev);
9ce192d4 3980 break;
65ec6247 3981
9ce192d4 3982 case SCN_MACRORECORD:
65ec6247
RD
3983 evt.SetEventType(wxEVT_STC_MACRORECORD);
3984 evt.SetMessage(scn.message);
3985 evt.SetWParam(scn.wParam);
3986 evt.SetLParam(scn.lParam);
9ce192d4 3987 break;
65ec6247 3988
9ce192d4 3989 case SCN_MARGINCLICK:
65ec6247
RD
3990 evt.SetEventType(wxEVT_STC_MARGINCLICK);
3991 evt.SetMargin(scn.margin);
9ce192d4 3992 break;
65ec6247 3993
9ce192d4 3994 case SCN_NEEDSHOWN:
65ec6247
RD
3995 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
3996 evt.SetLength(scn.length);
9ce192d4 3997 break;
65ec6247 3998
65ec6247
RD
3999 case SCN_PAINTED:
4000 evt.SetEventType(wxEVT_STC_PAINTED);
4001 break;
4002
0daf5e6b
RD
4003 case SCN_AUTOCSELECTION:
4004 evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION);
4005 evt.SetListType(scn.listType);
4006 SetEventText(evt, scn.text, strlen(scn.text));
4007 evt.SetPosition(scn.lParam);
4008 break;
7e0c58e9 4009
65ec6247
RD
4010 case SCN_USERLISTSELECTION:
4011 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
4012 evt.SetListType(scn.listType);
2b5f62a0 4013 SetEventText(evt, scn.text, strlen(scn.text));
0daf5e6b 4014 evt.SetPosition(scn.lParam);
65ec6247
RD
4015 break;
4016
4017 case SCN_URIDROPPED:
4018 evt.SetEventType(wxEVT_STC_URIDROPPED);
2b5f62a0 4019 SetEventText(evt, scn.text, strlen(scn.text));
65ec6247
RD
4020 break;
4021
4022 case SCN_DWELLSTART:
4023 evt.SetEventType(wxEVT_STC_DWELLSTART);
4024 evt.SetX(scn.x);
4025 evt.SetY(scn.y);
4026 break;
4027
4028 case SCN_DWELLEND:
4029 evt.SetEventType(wxEVT_STC_DWELLEND);
4030 evt.SetX(scn.x);
4031 evt.SetY(scn.y);
4032 break;
4033
a834585d
RD
4034 case SCN_ZOOM:
4035 evt.SetEventType(wxEVT_STC_ZOOM);
4036 break;
4037
9e730a78
RD
4038 case SCN_HOTSPOTCLICK:
4039 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
4040 break;
4041
4042 case SCN_HOTSPOTDOUBLECLICK:
4043 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
4044 break;
4045
4046 case SCN_CALLTIPCLICK:
4047 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
4048 break;
7e0c58e9
RD
4049
4050 case SCN_INDICATORCLICK:
4051 evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
4052 break;
4053
4054 case SCN_INDICATORRELEASE:
4055 evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
4056 break;
4057
65ec6247
RD
4058 default:
4059 return;
9ce192d4 4060 }
65ec6247
RD
4061
4062 GetEventHandler()->ProcessEvent(evt);
9ce192d4
RD
4063}
4064
4065
9ce192d4
RD
4066//----------------------------------------------------------------------
4067//----------------------------------------------------------------------
4068//----------------------------------------------------------------------
4069
4070wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
4071 : wxCommandEvent(commandType, id)
4072{
4073 m_position = 0;
4074 m_key = 0;
4075 m_modifiers = 0;
4076 m_modificationType = 0;
4077 m_length = 0;
4078 m_linesAdded = 0;
4079 m_line = 0;
4080 m_foldLevelNow = 0;
4081 m_foldLevelPrev = 0;
4082 m_margin = 0;
4083 m_message = 0;
4084 m_wParam = 0;
4085 m_lParam = 0;
65ec6247
RD
4086 m_listType = 0;
4087 m_x = 0;
4088 m_y = 0;
7e126a07 4089 m_dragAllowMove = false;
92bbd64f 4090#if wxUSE_DRAG_AND_DROP
a29a241f 4091 m_dragResult = wxDragNone;
92bbd64f 4092#endif
9ce192d4
RD
4093}
4094
4095bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
4096bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
4097bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
4098
5fa4613c 4099
41286fd1
JS
4100wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
4101 wxCommandEvent(event)
4102{
4103 m_position = event.m_position;
4104 m_key = event.m_key;
4105 m_modifiers = event.m_modifiers;
4106 m_modificationType = event.m_modificationType;
4107 m_text = event.m_text;
4108 m_length = event.m_length;
4109 m_linesAdded = event.m_linesAdded;
4110 m_line = event.m_line;
4111 m_foldLevelNow = event.m_foldLevelNow;
4112 m_foldLevelPrev = event.m_foldLevelPrev;
4113
4114 m_margin = event.m_margin;
4115
4116 m_message = event.m_message;
4117 m_wParam = event.m_wParam;
4118 m_lParam = event.m_lParam;
4119
4120 m_listType = event.m_listType;
4121 m_x = event.m_x;
4122 m_y = event.m_y;
9ce192d4 4123
41286fd1
JS
4124 m_dragText = event.m_dragText;
4125 m_dragAllowMove =event.m_dragAllowMove;
92bbd64f 4126#if wxUSE_DRAG_AND_DROP
41286fd1 4127 m_dragResult = event.m_dragResult;
92bbd64f 4128#endif
9ce192d4
RD
4129}
4130
4131//----------------------------------------------------------------------
4132//----------------------------------------------------------------------
4133
29825f5f 4134#endif // wxUSE_STC