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