]> git.saurik.com Git - wxWidgets.git/blame - src/stc/stc.cpp
Committing in .
[wxWidgets.git] / src / stc / stc.cpp
CommitLineData
9ce192d4
RD
1////////////////////////////////////////////////////////////////////////////
2// Name: stc.cpp
3// Purpose: A wxWindows implementation of Scintilla. This class is the
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
23#include <wx/tokenzr.h>
24
f6bcfd97
BP
25// The following code forces a reference to all of the Scintilla lexers.
26// If we don't do something like this, then the linker tends to "optimize"
27// them away. (eric@sourcegear.com)
28
4370573a 29int wxForceScintillaLexers(void)
f6bcfd97 30{
65ec6247
RD
31 extern LexerModule lmAda;
32 extern LexerModule lmAVE;
33 extern LexerModule lmConf;
f6bcfd97 34 extern LexerModule lmCPP;
65ec6247 35 extern LexerModule lmEiffel;
f6bcfd97 36 extern LexerModule lmHTML;
65ec6247
RD
37 extern LexerModule lmLISP;
38 extern LexerModule lmLua;
39 extern LexerModule lmBatch; // In LexOthers.cxx
40 extern LexerModule lmPascal;
f6bcfd97
BP
41 extern LexerModule lmPerl;
42 extern LexerModule lmPython;
65ec6247 43 extern LexerModule lmRuby;
f6bcfd97
BP
44 extern LexerModule lmSQL;
45 extern LexerModule lmVB;
46
65ec6247
RD
47 if ( &lmAda
48 && &lmAVE
49 && &lmConf
50 && &lmCPP
51 && &lmEiffel
52 && &lmHTML
53 && &lmLISP
54 && &lmLua
55 && &lmBatch
56 && &lmPascal
57 && &lmPerl
58 && &lmPython
59 && &lmRuby
60 && &lmSQL
61 && &lmVB )
f6bcfd97
BP
62 {
63 return 1;
64 }
4370573a
RD
65 else
66 {
67 return 0;
68 }
f6bcfd97
BP
69}
70
9ce192d4
RD
71//----------------------------------------------------------------------
72
73const wxChar* wxSTCNameStr = "stcwindow";
74
d25f5fbb
RD
75DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
76DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
77DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
d25f5fbb
RD
78DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
79DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
80DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
65ec6247 81DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
d25f5fbb 82DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
65ec6247 83DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
d25f5fbb 84DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
d25f5fbb
RD
85DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
86DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
87DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
88DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED )
65ec6247
RD
89DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
90DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
91DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
92DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
93DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
94
95
d25f5fbb
RD
96
97
9ce192d4
RD
98BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
99 EVT_PAINT (wxStyledTextCtrl::OnPaint)
100 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
101 EVT_SIZE (wxStyledTextCtrl::OnSize)
102 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
4ceb1196
RD
103#ifdef __WXMSW__
104 // Let Scintilla see the double click as a second click
105 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
106#endif
9ce192d4
RD
107 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
108 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
65ec6247 109 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
37d62433 110 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
9ce192d4 111 EVT_CHAR (wxStyledTextCtrl::OnChar)
f6bcfd97 112 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
9ce192d4
RD
113 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
114 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
115 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
116 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
117 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu)
f6bcfd97 118 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
9ce192d4
RD
119END_EVENT_TABLE()
120
f6bcfd97
BP
121
122IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
123IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
124
9ce192d4
RD
125//----------------------------------------------------------------------
126// Constructor and Destructor
127
128wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
129 wxWindowID id,
130 const wxPoint& pos,
131 const wxSize& size,
132 long style,
133 const wxString& name) :
134 wxControl(parent, id, pos, size,
f97d84a6 135 style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN,
9ce192d4
RD
136 wxDefaultValidator, name)
137{
138 m_swx = new ScintillaWX(this);
9ce192d4 139 m_stopWatch.Start();
9ce192d4
RD
140}
141
142
143wxStyledTextCtrl::~wxStyledTextCtrl() {
144 delete m_swx;
9ce192d4
RD
145}
146
147
148//----------------------------------------------------------------------
149
f6bcfd97 150long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
9ce192d4
RD
151
152 return m_swx->WndProc(msg, wp, lp);
153}
154
155
f97d84a6
RD
156#ifdef MAKELONG
157#undef MAKELONG
158#endif
159
4370573a 160#define MAKELONG(a, b) ((a) | ((b) << 16))
9ce192d4
RD
161
162
4370573a
RD
163static long wxColourAsLong(const wxColour& co) {
164 return (((long)co.Blue() << 16) |
165 ((long)co.Green() << 8) |
166 ((long)co.Red()));
9ce192d4
RD
167}
168
4370573a
RD
169static wxColour wxColourFromLong(long c) {
170 wxColour clr;
171 clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
172 return clr;
9ce192d4
RD
173}
174
175
4370573a
RD
176static wxColour wxColourFromSpec(const wxString& spec) {
177 // spec should be #RRGGBB
178 char* junk;
179 int red = strtol(spec.Mid(1,2), &junk, 16);
180 int green = strtol(spec.Mid(3,2), &junk, 16);
181 int blue = strtol(spec.Mid(5,2), &junk, 16);
182 return wxColour(red, green, blue);
9ce192d4
RD
183}
184
185
4370573a
RD
186//----------------------------------------------------------------------
187// BEGIN generated section. The following code is automatically generated
188// by gen_iface.py from the contents of Scintilla.iface. Do not edit
189// this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
9ce192d4
RD
190
191
4370573a 192// Add text to the document
9ce192d4 193void wxStyledTextCtrl::AddText(const wxString& text) {
4370573a 194 SendMsg(2001, text.Len(), (long)text.c_str());
9ce192d4
RD
195}
196
4370573a 197// Add array of cells to document
9ce192d4 198void wxStyledTextCtrl::AddStyledText(const wxString& text) {
4370573a 199 SendMsg(2002, text.Len(), (long)text.c_str());
9ce192d4
RD
200}
201
4370573a 202// Insert string at a position
9ce192d4 203void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
4370573a 204 SendMsg(2003, pos, (long)text.c_str());
9ce192d4
RD
205}
206
4370573a 207// Delete all text in the document
9ce192d4 208void wxStyledTextCtrl::ClearAll() {
4370573a 209 SendMsg(2004, 0, 0);
9ce192d4
RD
210}
211
4370573a
RD
212// Set all style bytes to 0, remove all folding information
213void wxStyledTextCtrl::ClearDocumentStyle() {
214 SendMsg(2005, 0, 0);
9ce192d4
RD
215}
216
4370573a
RD
217// The number of characters in the document
218int wxStyledTextCtrl::GetLength() {
219 return SendMsg(2006, 0, 0);
9ce192d4
RD
220}
221
4370573a
RD
222// Returns the character byte at the position
223int wxStyledTextCtrl::GetCharAt(int pos) {
224 return SendMsg(2007, pos, 0);
9ce192d4
RD
225}
226
4370573a
RD
227// Returns the position of the caret
228int wxStyledTextCtrl::GetCurrentPos() {
229 return SendMsg(2008, 0, 0);
9ce192d4
RD
230}
231
4370573a
RD
232// Returns the position of the opposite end of the selection to the caret
233int wxStyledTextCtrl::GetAnchor() {
234 return SendMsg(2009, 0, 0);
9ce192d4
RD
235}
236
4370573a
RD
237// Returns the style byte at the position
238int wxStyledTextCtrl::GetStyleAt(int pos) {
239 return SendMsg(2010, pos, 0);
9ce192d4
RD
240}
241
4370573a 242// Redoes the next action on the undo history
9ce192d4 243void wxStyledTextCtrl::Redo() {
4370573a 244 SendMsg(2011, 0, 0);
9ce192d4
RD
245}
246
4370573a
RD
247// Choose between collecting actions into the undo
248// history and discarding them.
249void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
250 SendMsg(2012, collectUndo, 0);
9ce192d4
RD
251}
252
4370573a
RD
253// Select all the text in the document.
254void wxStyledTextCtrl::SelectAll() {
255 SendMsg(2013, 0, 0);
9ce192d4
RD
256}
257
4370573a
RD
258// Remember the current position in the undo history as the position
259// at which the document was saved.
260void wxStyledTextCtrl::SetSavePoint() {
261 SendMsg(2014, 0, 0);
9ce192d4
RD
262}
263
4370573a
RD
264// Retrieve a buffer of cells.
265wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
266 wxString text;
267 int len = endPos - startPos;
abb69c6c 268 if (!len) return "";
4370573a 269 TextRange tr;
abb69c6c 270 tr.lpstrText = text.GetWriteBuf(len*2);
4370573a
RD
271 tr.chrg.cpMin = startPos;
272 tr.chrg.cpMax = endPos;
273 SendMsg(2015, 0, (long)&tr);
274 text.UngetWriteBuf(len*2);
275 return text;
9ce192d4
RD
276}
277
4370573a
RD
278// Are there any redoable actions in the undo history.
279bool wxStyledTextCtrl::CanRedo() {
280 return SendMsg(2016, 0, 0) != 0;
9ce192d4
RD
281}
282
4370573a
RD
283// Retrieve the line number at which a particular marker is located
284int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
285 return SendMsg(2017, handle, 0);
9ce192d4
RD
286}
287
4370573a
RD
288// Delete a marker.
289void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
290 SendMsg(2018, handle, 0);
9ce192d4
RD
291}
292
4370573a
RD
293// Is undo history being collected?
294bool wxStyledTextCtrl::GetUndoCollection() {
295 return SendMsg(2019, 0, 0) != 0;
9ce192d4
RD
296}
297
4370573a
RD
298// Are white space characters currently visible?
299// Returns one of SCWS_* constants.
300int wxStyledTextCtrl::GetViewWhiteSpace() {
301 return SendMsg(2020, 0, 0);
9ce192d4
RD
302}
303
4370573a
RD
304// Make white space characters invisible, always visible or visible outside indentation.
305void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
306 SendMsg(2021, viewWS, 0);
9ce192d4
RD
307}
308
4370573a 309// Find the position from a point within the window.
9ce192d4 310int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
4370573a 311 return SendMsg(2022, pt.x, pt.y);
9ce192d4
RD
312}
313
65ec6247
RD
314// Find the position from a point within the window but return
315// INVALID_POSITION if not close to text.
316int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
317 return SendMsg(2023, x, y);
318}
319
4370573a
RD
320// Set caret to start of a line and ensure it is visible.
321void wxStyledTextCtrl::GotoLine(int line) {
322 SendMsg(2024, line, 0);
9ce192d4
RD
323}
324
4370573a 325// Set caret to a position and ensure it is visible.
9ce192d4 326void wxStyledTextCtrl::GotoPos(int pos) {
4370573a 327 SendMsg(2025, pos, 0);
9ce192d4
RD
328}
329
4370573a
RD
330// Set the selection anchor to a position. The anchor is the opposite
331// end of the selection from the caret.
332void wxStyledTextCtrl::SetAnchor(int posAnchor) {
333 SendMsg(2026, posAnchor, 0);
9ce192d4
RD
334}
335
4370573a
RD
336// Retrieve the text of the line containing the caret.
337// Returns the index of the caret on the line.
338wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
339 wxString text;
340 int len = LineLength(GetCurrentLine());
abb69c6c 341 if (!len) return "";
afc2b641 342 char* buf = text.GetWriteBuf(len);
9ce192d4 343
4370573a 344 int pos = SendMsg(2027, len, (long)buf);
abb69c6c 345 text.UngetWriteBuf(len);
4370573a 346 if (linePos) *linePos = pos;
9ce192d4 347
4370573a 348 return text;
9ce192d4
RD
349}
350
4370573a
RD
351// Retrieve the position of the last correctly styled character.
352int wxStyledTextCtrl::GetEndStyled() {
353 return SendMsg(2028, 0, 0);
9ce192d4
RD
354}
355
65ec6247
RD
356// Convert all line endings in the document to one mode.
357void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
358 SendMsg(2029, eolMode, 0);
9ce192d4
RD
359}
360
4370573a
RD
361// Retrieve the current end of line mode - one of CRLF, CR, or LF.
362int wxStyledTextCtrl::GetEOLMode() {
363 return SendMsg(2030, 0, 0);
9ce192d4
RD
364}
365
4370573a
RD
366// Set the current end of line mode.
367void wxStyledTextCtrl::SetEOLMode(int eolMode) {
368 SendMsg(2031, eolMode, 0);
9ce192d4
RD
369}
370
4370573a
RD
371// Set the current styling position to pos and the styling mask to mask.
372// The styling mask can be used to protect some bits in each styling byte from
373// modification.
374void wxStyledTextCtrl::StartStyling(int pos, int mask) {
375 SendMsg(2032, pos, mask);
9ce192d4
RD
376}
377
4370573a
RD
378// Change style from current styling position for length characters to a style
379// and move the current styling position to after this newly styled segment.
380void wxStyledTextCtrl::SetStyling(int length, int style) {
381 SendMsg(2033, length, style);
f6bcfd97
BP
382}
383
4370573a
RD
384// Is drawing done first into a buffer or direct to the screen.
385bool wxStyledTextCtrl::GetBufferedDraw() {
386 return SendMsg(2034, 0, 0) != 0;
f6bcfd97
BP
387}
388
4370573a
RD
389// If drawing is buffered then each line of text is drawn into a bitmap buffer
390// before drawing it to the screen to avoid flicker.
391void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
392 SendMsg(2035, buffered, 0);
f6bcfd97
BP
393}
394
4370573a
RD
395// Change the visible size of a tab to be a multiple of the width of a space
396// character.
397void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
398 SendMsg(2036, tabWidth, 0);
f6bcfd97
BP
399}
400
4370573a
RD
401// Retrieve the visible size of a tab.
402int wxStyledTextCtrl::GetTabWidth() {
403 return SendMsg(2121, 0, 0);
9ce192d4
RD
404}
405
4370573a
RD
406// Set the code page used to interpret the bytes of the document as characters.
407// The SC_CP_UTF8 value can be used to enter Unicode mode.
408void wxStyledTextCtrl::SetCodePage(int codePage) {
409 SendMsg(2037, codePage, 0);
9ce192d4
RD
410}
411
4370573a
RD
412// Set the symbol used for a particular marker number,
413// and optionally the for and background colours.
414void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
415 const wxColour& foreground,
416 const wxColour& background) {
9ce192d4 417
4370573a
RD
418 SendMsg(2040, markerNumber, markerSymbol);
419 if (foreground.Ok())
420 MarkerSetForeground(markerNumber, foreground);
421 if (background.Ok())
422 MarkerSetBackground(markerNumber, background);
9ce192d4
RD
423}
424
4370573a
RD
425// Set the foreground colour used for a particular marker number.
426void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
427 SendMsg(2041, markerNumber, wxColourAsLong(fore));
9ce192d4
RD
428}
429
4370573a
RD
430// Set the background colour used for a particular marker number.
431void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
432 SendMsg(2042, markerNumber, wxColourAsLong(back));
9ce192d4
RD
433}
434
4370573a
RD
435// Add a marker to a line.
436void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
437 SendMsg(2043, line, markerNumber);
9ce192d4
RD
438}
439
4370573a
RD
440// Delete a marker from a line
441void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
442 SendMsg(2044, line, markerNumber);
9ce192d4
RD
443}
444
4370573a
RD
445// Delete all markers with a particular number from all lines
446void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
447 SendMsg(2045, markerNumber, 0);
9ce192d4
RD
448}
449
4370573a
RD
450// Get a bit mask of all the markers set on a line.
451int wxStyledTextCtrl::MarkerGet(int line) {
452 return SendMsg(2046, line, 0);
9ce192d4
RD
453}
454
4370573a
RD
455// Find the next line after lineStart that includes a marker in mask.
456int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
457 return SendMsg(2047, lineStart, markerMask);
9ce192d4
RD
458}
459
4370573a
RD
460// Find the previous line before lineStart that includes a marker in mask.
461int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
462 return SendMsg(2048, lineStart, markerMask);
9ce192d4
RD
463}
464
4370573a
RD
465// Set a margin to be either numeric or symbolic.
466void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
467 SendMsg(2240, margin, marginType);
9ce192d4
RD
468}
469
4370573a
RD
470// Retrieve the type of a margin.
471int wxStyledTextCtrl::GetMarginType(int margin) {
472 return SendMsg(2241, margin, 0);
9ce192d4
RD
473}
474
4370573a
RD
475// Set the width of a margin to a width expressed in pixels.
476void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
477 SendMsg(2242, margin, pixelWidth);
9ce192d4
RD
478}
479
4370573a
RD
480// Retrieve the width of a margin in pixels.
481int wxStyledTextCtrl::GetMarginWidth(int margin) {
482 return SendMsg(2243, margin, 0);
f6bcfd97
BP
483}
484
4370573a
RD
485// Set a mask that determines which markers are displayed in a margin.
486void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
487 SendMsg(2244, margin, mask);
f6bcfd97
BP
488}
489
4370573a
RD
490// Retrieve the marker mask of a margin.
491int wxStyledTextCtrl::GetMarginMask(int margin) {
492 return SendMsg(2245, margin, 0);
9ce192d4
RD
493}
494
4370573a
RD
495// Make a margin sensitive or insensitive to mouse clicks.
496void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
497 SendMsg(2246, margin, sensitive);
9ce192d4
RD
498}
499
4370573a
RD
500// Retrieve the mouse click sensitivity of a margin.
501bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
502 return SendMsg(2247, margin, 0) != 0;
9ce192d4
RD
503}
504
4370573a 505// Clear all the styles and make equivalent to the global default style.
9ce192d4 506void wxStyledTextCtrl::StyleClearAll() {
4370573a 507 SendMsg(2050, 0, 0);
9ce192d4
RD
508}
509
4370573a
RD
510// Set the foreground colour of a style.
511void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
512 SendMsg(2051, style, wxColourAsLong(fore));
9ce192d4
RD
513}
514
4370573a
RD
515// Set the background colour of a style.
516void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
517 SendMsg(2052, style, wxColourAsLong(back));
9ce192d4
RD
518}
519
4370573a
RD
520// Set a style to be bold or not.
521void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
522 SendMsg(2053, style, bold);
9ce192d4
RD
523}
524
4370573a
RD
525// Set a style to be italic or not.
526void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
527 SendMsg(2054, style, italic);
9ce192d4
RD
528}
529
4370573a
RD
530// Set the size of characters of a style.
531void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
532 SendMsg(2055, style, sizePoints);
9ce192d4
RD
533}
534
4370573a
RD
535// Set the font of a style.
536void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
537 SendMsg(2056, style, (long)fontName.c_str());
9ce192d4
RD
538}
539
4370573a
RD
540// Set a style to have its end of line filled or not.
541void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
542 SendMsg(2057, style, filled);
9ce192d4
RD
543}
544
4370573a
RD
545// Reset the default style to its state at startup
546void wxStyledTextCtrl::StyleResetDefault() {
547 SendMsg(2058, 0, 0);
9ce192d4
RD
548}
549
4370573a
RD
550// Set a style to be underlined or not.
551void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
552 SendMsg(2059, style, underline);
9ce192d4
RD
553}
554
65ec6247
RD
555// Set a style to be mixed case, or to force upper or lower case.
556void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
557 SendMsg(2060, style, caseForce);
558}
559
4370573a
RD
560// Set the foreground colour of the selection and whether to use this setting.
561void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
562 SendMsg(2067, useSetting, wxColourAsLong(fore));
9ce192d4
RD
563}
564
4370573a
RD
565// Set the background colour of the selection and whether to use this setting.
566void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
567 SendMsg(2068, useSetting, wxColourAsLong(back));
9ce192d4
RD
568}
569
4370573a
RD
570// Set the foreground colour of the caret.
571void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
572 SendMsg(2069, wxColourAsLong(fore), 0);
9ce192d4
RD
573}
574
4370573a
RD
575// When key+modifier combination km is pressed perform msg.
576void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
577 SendMsg(2070, MAKELONG(key, modifiers), cmd);
9ce192d4
RD
578}
579
4370573a
RD
580// When key+modifier combination km do nothing.
581void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
582 SendMsg(2071, MAKELONG(key, modifiers));
9ce192d4
RD
583}
584
4370573a
RD
585// Drop all key mappings.
586void wxStyledTextCtrl::CmdKeyClearAll() {
587 SendMsg(2072, 0, 0);
588}
9ce192d4 589
4370573a
RD
590// Set the styles for a segment of the document.
591void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
592 SendMsg(2073, length, (long)styleBytes);
9ce192d4
RD
593}
594
4370573a
RD
595// Set a style to be visible or not.
596void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
597 SendMsg(2074, style, visible);
598}
9ce192d4 599
4370573a 600// Get the time in milliseconds that the caret is on and off.
9ce192d4 601int wxStyledTextCtrl::GetCaretPeriod() {
4370573a 602 return SendMsg(2075, 0, 0);
9ce192d4
RD
603}
604
4370573a
RD
605// Get the time in milliseconds that the caret is on and off. 0 = steady on.
606void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
607 SendMsg(2076, periodMilliseconds, 0);
608}
9ce192d4 609
4370573a
RD
610// Set the set of characters making up words for when moving or selecting
611// by word.
612void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
613 SendMsg(2077, 0, (long)characters.c_str());
9ce192d4
RD
614}
615
4370573a
RD
616// Start a sequence of actions that is undone and redone as a unit.
617// May be nested.
618void wxStyledTextCtrl::BeginUndoAction() {
619 SendMsg(2078, 0, 0);
620}
9ce192d4 621
4370573a
RD
622// End a sequence of actions that is undone and redone as a unit.
623void wxStyledTextCtrl::EndUndoAction() {
624 SendMsg(2079, 0, 0);
625}
9ce192d4 626
4370573a
RD
627// Set an indicator to plain, squiggle or TT.
628void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
629 SendMsg(2080, indic, style);
630}
9ce192d4 631
4370573a
RD
632// Retrieve the style of an indicator.
633int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
634 return SendMsg(2081, indic, 0);
635}
9ce192d4 636
4370573a
RD
637// Set the foreground colour of an indicator.
638void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
639 SendMsg(2082, indic, wxColourAsLong(fore));
9ce192d4
RD
640}
641
4370573a
RD
642// Retrieve the foreground colour of an indicator.
643wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
644 long c = SendMsg(2083, indic, 0);
645 return wxColourFromLong(c);
646}
9ce192d4 647
4370573a
RD
648// Divide each styling byte into lexical class bits (default:5) and indicator
649// bits (default:3). If a lexer requires more than 32 lexical states, then this
650// is used to expand the possible states.
651void wxStyledTextCtrl::SetStyleBits(int bits) {
652 SendMsg(2090, bits, 0);
9ce192d4
RD
653}
654
4370573a
RD
655// Retrieve number of bits in style bytes used to hold the lexical state.
656int wxStyledTextCtrl::GetStyleBits() {
657 return SendMsg(2091, 0, 0);
658}
9ce192d4 659
4370573a
RD
660// Used to hold extra styling information for each line.
661void wxStyledTextCtrl::SetLineState(int line, int state) {
662 SendMsg(2092, line, state);
f6bcfd97
BP
663}
664
4370573a
RD
665// Retrieve the extra styling information for a line.
666int wxStyledTextCtrl::GetLineState(int line) {
667 return SendMsg(2093, line, 0);
668}
f6bcfd97 669
4370573a
RD
670// Retrieve the last line number that has line state.
671int wxStyledTextCtrl::GetMaxLineState() {
672 return SendMsg(2094, 0, 0);
f6bcfd97
BP
673}
674
65ec6247
RD
675// Is the background of the line containing the caret in a different colour?
676bool wxStyledTextCtrl::GetCaretLineVisible() {
677 return SendMsg(2095, 0, 0) != 0;
678}
679
680// Display the background of the line containing the caret in a different colour.
681void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
682 SendMsg(2096, show, 0);
683}
684
685// Get the colour of the background of the line containing the caret.
686wxColour wxStyledTextCtrl::GetCaretLineBack() {
687 long c = SendMsg(2097, 0, 0);
688 return wxColourFromLong(c);
689}
690
691// Set the colour of the background of the line containing the caret.
692void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
693 SendMsg(2098, wxColourAsLong(back), 0);
694}
695
4370573a
RD
696// Display a auto-completion list.
697// The lenEntered parameter indicates how many characters before
698// the caret should be used to provide context.
699void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
700 SendMsg(2100, lenEntered, (long)itemList.c_str());
701}
f6bcfd97 702
4370573a
RD
703// Remove the auto-completion list from the screen.
704void wxStyledTextCtrl::AutoCompCancel() {
705 SendMsg(2101, 0, 0);
f6bcfd97
BP
706}
707
4370573a
RD
708// Is there an auto-completion list visible?
709bool wxStyledTextCtrl::AutoCompActive() {
710 return SendMsg(2102, 0, 0) != 0;
711}
f6bcfd97 712
4370573a
RD
713// Retrieve the position of the caret when the auto-completion list was
714// displayed.
715int wxStyledTextCtrl::AutoCompPosStart() {
716 return SendMsg(2103, 0, 0);
f6bcfd97
BP
717}
718
4370573a
RD
719// User has selected an item so remove the list and insert the selection.
720void wxStyledTextCtrl::AutoCompComplete() {
721 SendMsg(2104, 0, 0);
722}
f6bcfd97 723
4370573a
RD
724// Define a set of character that when typed cancel the auto-completion list.
725void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
726 SendMsg(2105, 0, (long)characterSet.c_str());
f6bcfd97
BP
727}
728
4370573a
RD
729// Change the separator character in the string setting up an auto-completion
730// list. Default is space but can be changed if items contain space.
731void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
732 SendMsg(2106, separatorCharacter, 0);
733}
f6bcfd97 734
4370573a
RD
735// Retrieve the auto-completion list separator character.
736int wxStyledTextCtrl::AutoCompGetSeparator() {
737 return SendMsg(2107, 0, 0);
9ce192d4
RD
738}
739
4370573a
RD
740// Select the item in the auto-completion list that starts with a string.
741void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
742 SendMsg(2108, 0, (long)text.c_str());
743}
9ce192d4 744
4370573a
RD
745// Should the auto-completion list be cancelled if the user backspaces to a
746// position before where the box was created.
747void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
748 SendMsg(2110, cancel, 0);
f6bcfd97
BP
749}
750
4370573a
RD
751// Retrieve whether auto-completion cancelled by backspacing before start.
752bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
753 return SendMsg(2111, 0, 0) != 0;
754}
f6bcfd97 755
4370573a
RD
756// Define a set of character that when typed fills up the selected word.
757void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
758 SendMsg(2112, 0, (long)characterSet.c_str());
759}
9ce192d4 760
4370573a
RD
761// Should a single item auto-completion list automatically choose the item.
762void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
763 SendMsg(2113, chooseSingle, 0);
764}
9ce192d4 765
4370573a
RD
766// Retrieve whether a single item auto-completion list automatically choose the item.
767bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
768 return SendMsg(2114, 0, 0) != 0;
9ce192d4
RD
769}
770
4370573a
RD
771// Set whether case is significant when performing auto-completion searches.
772void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
773 SendMsg(2115, ignoreCase, 0);
774}
9ce192d4 775
4370573a
RD
776// Retrieve state of ignore case flag.
777bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
778 return SendMsg(2116, 0, 0) != 0;
9ce192d4
RD
779}
780
65ec6247
RD
781// Display a list of strings and send notification when user chooses one.
782void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
783 SendMsg(2117, listType, (long)itemList.c_str());
784}
785
786// Set whether or not autocompletion is hidden automatically when nothing matches
787void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
788 SendMsg(2118, autoHide, 0);
789}
790
791// Retrieve whether or not autocompletion is hidden automatically when nothing matches
792bool wxStyledTextCtrl::AutoCompGetAutoHide() {
793 return SendMsg(2119, 0, 0) != 0;
794}
795
4370573a
RD
796// Set the number of spaces used for one level of indentation.
797void wxStyledTextCtrl::SetIndent(int indentSize) {
798 SendMsg(2122, indentSize, 0);
799}
9ce192d4 800
4370573a
RD
801// Retrieve indentation size.
802int wxStyledTextCtrl::GetIndent() {
803 return SendMsg(2123, 0, 0);
9ce192d4
RD
804}
805
4370573a
RD
806// Indentation will only use space characters if useTabs is false, otherwise
807// it will use a combination of tabs and spaces.
808void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
809 SendMsg(2124, useTabs, 0);
810}
9ce192d4 811
4370573a
RD
812// Retrieve whether tabs will be used in indentation.
813bool wxStyledTextCtrl::GetUseTabs() {
814 return SendMsg(2125, 0, 0) != 0;
815}
9ce192d4 816
4370573a
RD
817// Change the indentation of a line to a number of columns.
818void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
819 SendMsg(2126, line, indentSize);
820}
9ce192d4 821
4370573a
RD
822// Retrieve the number of columns that a line is indented.
823int wxStyledTextCtrl::GetLineIndentation(int line) {
824 return SendMsg(2127, line, 0);
9ce192d4
RD
825}
826
4370573a
RD
827// Retrieve the position before the first non indentation character on a line.
828int wxStyledTextCtrl::GetLineIndentPosition(int line) {
829 return SendMsg(2128, line, 0);
830}
9ce192d4 831
4370573a
RD
832// Retrieve the column number of a position, taking tab width into account.
833int wxStyledTextCtrl::GetColumn(int pos) {
834 return SendMsg(2129, pos, 0);
9ce192d4
RD
835}
836
4370573a
RD
837// Show or hide the horizontal scroll bar.
838void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
839 SendMsg(2130, show, 0);
840}
9ce192d4 841
4370573a
RD
842// Is the horizontal scroll bar visible?
843bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
844 return SendMsg(2131, 0, 0) != 0;
9ce192d4
RD
845}
846
4370573a
RD
847// Show or hide indentation guides.
848void wxStyledTextCtrl::SetIndentationGuides(bool show) {
849 SendMsg(2132, show, 0);
850}
9ce192d4 851
4370573a
RD
852// Are the indentation guides visible?
853bool wxStyledTextCtrl::GetIndentationGuides() {
854 return SendMsg(2133, 0, 0) != 0;
9ce192d4
RD
855}
856
4370573a
RD
857// Set the highlighted indentation guide column.
858// 0 = no highlighted guide.
859void wxStyledTextCtrl::SetHighlightGuide(int column) {
860 SendMsg(2134, column, 0);
861}
9ce192d4 862
4370573a
RD
863// Get the highlighted indentation guide column.
864int wxStyledTextCtrl::GetHighlightGuide() {
865 return SendMsg(2135, 0, 0);
9ce192d4
RD
866}
867
4370573a
RD
868// Get the position after the last visible characters on a line.
869int wxStyledTextCtrl::GetLineEndPosition(int line) {
870 return SendMsg(2136, line, 0);
871}
9ce192d4 872
4370573a
RD
873// Get the code page used to interpret the bytes of the document as characters.
874int wxStyledTextCtrl::GetCodePage() {
875 return SendMsg(2137, 0, 0);
9ce192d4
RD
876}
877
4370573a
RD
878// Get the foreground colour of the caret.
879wxColour wxStyledTextCtrl::GetCaretForeground() {
880 long c = SendMsg(2138, 0, 0);
881 return wxColourFromLong(c);
882}
9ce192d4 883
4370573a
RD
884// In read-only mode?
885bool wxStyledTextCtrl::GetReadOnly() {
886 return SendMsg(2140, 0, 0) != 0;
9ce192d4
RD
887}
888
4370573a
RD
889// Sets the position of the caret.
890void wxStyledTextCtrl::SetCurrentPos(int pos) {
891 SendMsg(2141, pos, 0);
892}
9ce192d4 893
4370573a
RD
894// Sets the position that starts the selection - this becomes the anchor.
895void wxStyledTextCtrl::SetSelectionStart(int pos) {
896 SendMsg(2142, pos, 0);
9ce192d4
RD
897}
898
4370573a
RD
899// Returns the position at the start of the selection.
900int wxStyledTextCtrl::GetSelectionStart() {
901 return SendMsg(2143, 0, 0);
902}
9ce192d4 903
4370573a
RD
904// Sets the position that ends the selection - this becomes the currentPosition.
905void wxStyledTextCtrl::SetSelectionEnd(int pos) {
906 SendMsg(2144, pos, 0);
9ce192d4
RD
907}
908
4370573a
RD
909// Returns the position at the end of the selection.
910int wxStyledTextCtrl::GetSelectionEnd() {
911 return SendMsg(2145, 0, 0);
912}
9ce192d4 913
4370573a
RD
914// Sets the print magnification added to the point size of each style for printing.
915void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
916 SendMsg(2146, magnification, 0);
9ce192d4
RD
917}
918
4370573a
RD
919// Returns the print magnification.
920int wxStyledTextCtrl::GetPrintMagnification() {
921 return SendMsg(2147, 0, 0);
922}
9ce192d4 923
4370573a
RD
924// Modify colours when printing for clearer printed text.
925void wxStyledTextCtrl::SetPrintColourMode(int mode) {
926 SendMsg(2148, mode, 0);
9ce192d4
RD
927}
928
4370573a
RD
929// Returns the print colour mode.
930int wxStyledTextCtrl::GetPrintColourMode() {
931 return SendMsg(2149, 0, 0);
932}
9ce192d4 933
4370573a
RD
934// Find some text in the document.
935int wxStyledTextCtrl::FindText(int minPos, int maxPos,
936 const wxString& text,
937 bool caseSensitive, bool wholeWord) {
938 TextToFind ft;
939 int flags = 0;
940
941 flags |= caseSensitive ? SCFIND_MATCHCASE : 0;
942 flags |= wholeWord ? SCFIND_WHOLEWORD : 0;
943 ft.chrg.cpMin = minPos;
944 ft.chrg.cpMax = maxPos;
945 ft.lpstrText = (char*)text.c_str();
946
947 return SendMsg(2150, flags, (long)&ft);
948}
949
950// On Windows will draw the document into a display context such as a printer.
951 int wxStyledTextCtrl::FormatRange(bool doDraw,
952 int startPos,
953 int endPos,
954 wxDC* draw,
955 wxDC* target, // Why does it use two? Can they be the same?
956 wxRect renderRect,
957 wxRect pageRect) {
958 RangeToFormat fr;
959
960 fr.hdc = draw;
961 fr.hdcTarget = target;
962 fr.rc.top = renderRect.GetTop();
963 fr.rc.left = renderRect.GetLeft();
964 fr.rc.right = renderRect.GetRight();
965 fr.rc.bottom = renderRect.GetBottom();
966 fr.rcPage.top = pageRect.GetTop();
967 fr.rcPage.left = pageRect.GetLeft();
968 fr.rcPage.right = pageRect.GetRight();
969 fr.rcPage.bottom = pageRect.GetBottom();
970 fr.chrg.cpMin = startPos;
971 fr.chrg.cpMax = endPos;
972
973 return SendMsg(2151, doDraw, (long)&fr);
974}
975
976// Retrieve the line at the top of the display.
977int wxStyledTextCtrl::GetFirstVisibleLine() {
978 return SendMsg(2152, 0, 0);
9ce192d4
RD
979}
980
4370573a
RD
981// Retrieve the contents of a line.
982wxString wxStyledTextCtrl::GetLine(int line) {
983 wxString text;
984 int len = LineLength(line);
abb69c6c 985 if (!len) return "";
afc2b641 986 char* buf = text.GetWriteBuf(len);
9ce192d4 987
4370573a 988 int pos = SendMsg(2153, line, (long)buf);
abb69c6c 989 text.UngetWriteBuf(len);
9ce192d4 990
4370573a
RD
991 return text;
992}
993
994// Returns the number of lines in the document. There is always at least one.
995int wxStyledTextCtrl::GetLineCount() {
996 return SendMsg(2154, 0, 0);
997}
9ce192d4 998
4370573a 999// Sets the size in pixels of the left margin.
65ec6247
RD
1000void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
1001 SendMsg(2155, 0, pixelWidth);
4370573a 1002}
9ce192d4 1003
4370573a
RD
1004// Returns the size in pixels of the left margin.
1005int wxStyledTextCtrl::GetMarginLeft() {
1006 return SendMsg(2156, 0, 0);
9ce192d4
RD
1007}
1008
4370573a 1009// Sets the size in pixels of the right margin.
65ec6247
RD
1010void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
1011 SendMsg(2157, 0, pixelWidth);
4370573a 1012}
9ce192d4 1013
4370573a
RD
1014// Returns the size in pixels of the right margin.
1015int wxStyledTextCtrl::GetMarginRight() {
1016 return SendMsg(2158, 0, 0);
9ce192d4
RD
1017}
1018
4370573a
RD
1019// Is the document different from when it was last saved?
1020bool wxStyledTextCtrl::GetModify() {
1021 return SendMsg(2159, 0, 0) != 0;
1022}
9ce192d4 1023
4370573a
RD
1024// Select a range of text.
1025void wxStyledTextCtrl::SetSelection(int start, int end) {
1026 SendMsg(2160, start, end);
9ce192d4
RD
1027}
1028
4370573a
RD
1029// Retrieve the selected text.
1030wxString wxStyledTextCtrl::GetSelectedText() {
1031 wxString text;
1032 int start;
1033 int end;
9ce192d4 1034
4370573a
RD
1035 GetSelection(&start, &end);
1036 int len = end - start;
abb69c6c
RD
1037 if (!len) return "";
1038 char* buff = text.GetWriteBuf(len);
9ce192d4 1039
4370573a 1040 SendMsg(2161, 0, (long)buff);
abb69c6c 1041 text.UngetWriteBuf(len);
4370573a
RD
1042 return text;
1043}
9ce192d4 1044
4370573a
RD
1045// Retrieve a range of text.
1046wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1047 wxString text;
1048 int len = endPos - startPos;
abb69c6c
RD
1049 if (!len) return "";
1050 char* buff = text.GetWriteBuf(len);
4370573a
RD
1051 TextRange tr;
1052 tr.lpstrText = buff;
1053 tr.chrg.cpMin = startPos;
1054 tr.chrg.cpMax = endPos;
9ce192d4 1055
4370573a 1056 SendMsg(2162, 0, (long)&tr);
abb69c6c 1057 text.UngetWriteBuf(len);
4370573a 1058 return text;
9ce192d4
RD
1059}
1060
4370573a
RD
1061// Draw the selection in normal style or with selection highlighted.
1062void wxStyledTextCtrl::HideSelection(bool normal) {
1063 SendMsg(2163, normal, 0);
1064}
9ce192d4 1065
4370573a
RD
1066// Retrieve the line containing a position.
1067int wxStyledTextCtrl::LineFromPosition(int pos) {
1068 return SendMsg(2166, pos, 0);
9ce192d4
RD
1069}
1070
4370573a
RD
1071// Retrieve the position at the start of a line.
1072int wxStyledTextCtrl::PositionFromLine(int line) {
1073 return SendMsg(2167, line, 0);
1074}
9ce192d4 1075
4370573a
RD
1076// Scroll horizontally and vertically.
1077void wxStyledTextCtrl::LineScroll(int columns, int lines) {
1078 SendMsg(2168, columns, lines);
9ce192d4
RD
1079}
1080
4370573a
RD
1081// Ensure the caret is visible.
1082void wxStyledTextCtrl::EnsureCaretVisible() {
1083 SendMsg(2169, 0, 0);
1084}
9ce192d4 1085
4370573a
RD
1086// Replace the selected text with the argument text.
1087void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
1088 SendMsg(2170, 0, (long)text.c_str());
9ce192d4
RD
1089}
1090
4370573a
RD
1091// Set to read only or read write.
1092void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1093 SendMsg(2171, readOnly, 0);
1094}
9ce192d4 1095
4370573a
RD
1096// Will a paste succeed?
1097bool wxStyledTextCtrl::CanPaste() {
1098 return SendMsg(2173, 0, 0) != 0;
9ce192d4
RD
1099}
1100
4370573a
RD
1101// Are there any undoable actions in the undo history.
1102bool wxStyledTextCtrl::CanUndo() {
1103 return SendMsg(2174, 0, 0) != 0;
1104}
9ce192d4 1105
4370573a
RD
1106// Delete the undo history.
1107void wxStyledTextCtrl::EmptyUndoBuffer() {
1108 SendMsg(2175, 0, 0);
9ce192d4
RD
1109}
1110
4370573a
RD
1111// Undo one action in the undo history.
1112void wxStyledTextCtrl::Undo() {
1113 SendMsg(2176, 0, 0);
1114}
9ce192d4 1115
4370573a
RD
1116// Cut the selection to the clipboard.
1117void wxStyledTextCtrl::Cut() {
1118 SendMsg(2177, 0, 0);
f6bcfd97
BP
1119}
1120
4370573a
RD
1121// Copy the selection to the clipboard.
1122void wxStyledTextCtrl::Copy() {
1123 SendMsg(2178, 0, 0);
1124}
f6bcfd97 1125
4370573a
RD
1126// Paste the contents of the clipboard into the document replacing the selection.
1127void wxStyledTextCtrl::Paste() {
1128 SendMsg(2179, 0, 0);
f6bcfd97
BP
1129}
1130
4370573a
RD
1131// Clear the selection.
1132void wxStyledTextCtrl::Clear() {
1133 SendMsg(2180, 0, 0);
1134}
f6bcfd97 1135
4370573a
RD
1136// Replace the contents of the document with the argument text.
1137void wxStyledTextCtrl::SetText(const wxString& text) {
1138 SendMsg(2181, 0, (long)text.c_str());
f6bcfd97
BP
1139}
1140
4370573a
RD
1141// Retrieve all the text in the document.
1142wxString wxStyledTextCtrl::GetText() {
1143 wxString text;
0c7dcb7f 1144 int len = GetTextLength()+1;
abb69c6c 1145 char* buff = text.GetWriteBuf(len);
f6bcfd97 1146
4370573a 1147 SendMsg(2182, len, (long)buff);
abb69c6c 1148 text.UngetWriteBuf(len-1);
4370573a
RD
1149 return text;
1150}
9ce192d4 1151
4370573a
RD
1152// Retrieve the number of characters in the document.
1153int wxStyledTextCtrl::GetTextLength() {
1154 return SendMsg(2183, 0, 0);
9ce192d4
RD
1155}
1156
4370573a
RD
1157// Set to overtype (true) or insert mode
1158void wxStyledTextCtrl::SetOvertype(bool overtype) {
1159 SendMsg(2186, overtype, 0);
1160}
9ce192d4 1161
4370573a
RD
1162// Returns true if overtype mode is active otherwise false is returned.
1163bool wxStyledTextCtrl::GetOvertype() {
1164 return SendMsg(2187, 0, 0) != 0;
9ce192d4
RD
1165}
1166
65ec6247
RD
1167// Set the width of the insert mode caret
1168void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
1169 SendMsg(2188, pixelWidth, 0);
1170}
1171
1172// Returns the width of the insert mode caret
1173int wxStyledTextCtrl::GetCaretWidth() {
1174 return SendMsg(2189, 0, 0);
1175}
1176
1177// Sets the position that starts the target which is used for updating the
1178// document without affecting the scroll position.
1179void wxStyledTextCtrl::SetTargetStart(int pos) {
1180 SendMsg(2190, pos, 0);
1181}
1182
1183// Get the position that starts the target.
1184int wxStyledTextCtrl::GetTargetStart() {
1185 return SendMsg(2191, 0, 0);
1186}
1187
1188// Sets the position that ends the target which is used for updating the
1189// document without affecting the scroll position.
1190void wxStyledTextCtrl::SetTargetEnd(int pos) {
1191 SendMsg(2192, pos, 0);
1192}
1193
1194// Get the position that ends the target.
1195int wxStyledTextCtrl::GetTargetEnd() {
1196 return SendMsg(2193, 0, 0);
1197}
1198
1199// Replace the target text with the argument text.
1200// Returns the length of the replacement text.
1201
1202 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1203 return SendMsg(2194, text.Len(), (long)text.c_str());
1204
1205}
1206
1207// Replace the target text with the argument text after \d processing.
1208// Looks for \d where d is between 1 and 9 and replaces these with the strings
1209// matched in the last search operation which were surrounded by \( and \).
1210// Returns the length of the replacement text including any change
1211// caused by processing the \d patterns.
1212
1213 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1214 return SendMsg(2195, text.Len(), (long)text.c_str());
1215
1216}
1217
1218// Search for a counted string in the target and set the target to the found
1219// range.
1220// Returns length of range or -1 for failure in which case target is not moved.
1221
1222 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1223 return SendMsg(2197, text.Len(), (long)text.c_str());
1224
1225}
1226
1227// Set the search flags used by SearchInTarget
1228void wxStyledTextCtrl::SetSearchFlags(int flags) {
1229 SendMsg(2198, flags, 0);
1230}
1231
1232// Get the search flags used by SearchInTarget
1233int wxStyledTextCtrl::GetSearchFlags() {
1234 return SendMsg(2199, 0, 0);
1235}
1236
4370573a
RD
1237// Show a call tip containing a definition near position pos.
1238void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
1239 SendMsg(2200, pos, (long)definition.c_str());
1240}
9ce192d4 1241
4370573a
RD
1242// Remove the call tip from the screen.
1243void wxStyledTextCtrl::CallTipCancel() {
1244 SendMsg(2201, 0, 0);
9ce192d4
RD
1245}
1246
4370573a
RD
1247// Is there an active call tip?
1248bool wxStyledTextCtrl::CallTipActive() {
1249 return SendMsg(2202, 0, 0) != 0;
1250}
9ce192d4 1251
4370573a 1252// Retrieve the position where the caret was before displaying the call tip.
9ce192d4 1253int wxStyledTextCtrl::CallTipPosAtStart() {
4370573a 1254 return SendMsg(2203, 0, 0);
9ce192d4
RD
1255}
1256
4370573a 1257// Highlight a segment of the definition.
9ce192d4 1258void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
4370573a 1259 SendMsg(2204, start, end);
9ce192d4
RD
1260}
1261
4370573a
RD
1262// Set the background colour for the call tip.
1263void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1264 SendMsg(2205, wxColourAsLong(back), 0);
1265}
9ce192d4 1266
4370573a
RD
1267// Find the display line of a document line taking hidden lines into account.
1268int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1269 return SendMsg(2220, line, 0);
9ce192d4
RD
1270}
1271
4370573a
RD
1272// Find the document line of a display line taking hidden lines into account.
1273int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1274 return SendMsg(2221, lineDisplay, 0);
1275}
9ce192d4 1276
4370573a
RD
1277// Set the fold level of a line.
1278// This encodes an integer level along with flags indicating whether the
1279// line is a header and whether it is effectively white space.
1280void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1281 SendMsg(2222, line, level);
1282}
9ce192d4 1283
4370573a
RD
1284// Retrieve the fold level of a line.
1285int wxStyledTextCtrl::GetFoldLevel(int line) {
1286 return SendMsg(2223, line, 0);
1287}
d134f170 1288
4370573a
RD
1289// Find the last child line of a header line.
1290int wxStyledTextCtrl::GetLastChild(int line, int level) {
1291 return SendMsg(2224, line, level);
9ce192d4
RD
1292}
1293
4370573a
RD
1294// Find the parent line of a child line.
1295int wxStyledTextCtrl::GetFoldParent(int line) {
1296 return SendMsg(2225, line, 0);
1297}
9ce192d4 1298
4370573a
RD
1299// Make a range of lines visible.
1300void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1301 SendMsg(2226, lineStart, lineEnd);
9ce192d4
RD
1302}
1303
4370573a
RD
1304// Make a range of lines invisible.
1305void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1306 SendMsg(2227, lineStart, lineEnd);
1307}
9ce192d4 1308
4370573a
RD
1309// Is a line visible?
1310bool wxStyledTextCtrl::GetLineVisible(int line) {
1311 return SendMsg(2228, line, 0) != 0;
9ce192d4
RD
1312}
1313
4370573a
RD
1314// Show the children of a header line.
1315void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1316 SendMsg(2229, line, expanded);
1317}
9ce192d4 1318
4370573a
RD
1319// Is a header line expanded?
1320bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1321 return SendMsg(2230, line, 0) != 0;
9ce192d4
RD
1322}
1323
4370573a
RD
1324// Switch a header line between expanded and contracted.
1325void wxStyledTextCtrl::ToggleFold(int line) {
1326 SendMsg(2231, line, 0);
1327}
9ce192d4 1328
4370573a
RD
1329// Ensure a particular line is visible by expanding any header line hiding it.
1330void wxStyledTextCtrl::EnsureVisible(int line) {
1331 SendMsg(2232, line, 0);
1332}
9ce192d4 1333
4370573a
RD
1334// Set some debugging options for folding
1335void wxStyledTextCtrl::SetFoldFlags(int flags) {
1336 SendMsg(2233, flags, 0);
9ce192d4
RD
1337}
1338
65ec6247
RD
1339// Ensure a particular line is visible by expanding any header line hiding it.
1340// Use the currently set visibility policy to determine which range to display.
1341void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
1342 SendMsg(2234, line, 0);
1343}
1344
1345// Sets whether a tab pressed when caret is within indentation indents
1346void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
1347 SendMsg(2260, tabIndents, 0);
1348}
1349
1350// Does a tab pressed when caret is within indentation indent?
1351bool wxStyledTextCtrl::GetTabIndents() {
1352 return SendMsg(2261, 0, 0) != 0;
1353}
1354
1355// Sets whether a backspace pressed when caret is within indentation unindents
1356void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
1357 SendMsg(2262, bsUnIndents, 0);
1358}
1359
1360// Does a backspace pressed when caret is within indentation unindent?
1361bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1362 return SendMsg(2263, 0, 0) != 0;
1363}
1364
1365// Sets the time the mouse must sit still to generate a mouse dwell event
1366void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
1367 SendMsg(2264, periodMilliseconds, 0);
1368}
1369
1370// Retrieve the time the mouse must sit still to generate a mouse dwell event
1371int wxStyledTextCtrl::GetMouseDwellTime() {
1372 return SendMsg(2265, 0, 0);
1373}
1374
1375// Move the caret inside current view if it's not there already
1376void wxStyledTextCtrl::MoveCaretInsideView() {
1377 SendMsg(2401, 0, 0);
1378}
1379
4370573a
RD
1380// How many characters are on a line, not including end of line characters.
1381int wxStyledTextCtrl::LineLength(int line) {
1382 return SendMsg(2350, line, 0);
1383}
9ce192d4 1384
4370573a
RD
1385// Highlight the characters at two positions.
1386void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
1387 SendMsg(2351, pos1, pos2);
1388}
9ce192d4 1389
4370573a
RD
1390// Highlight the character at a position indicating there is no matching brace.
1391void wxStyledTextCtrl::BraceBadLight(int pos) {
1392 SendMsg(2352, pos, 0);
9ce192d4
RD
1393}
1394
4370573a
RD
1395// Find the position of a matching brace or INVALID_POSITION if no match.
1396int wxStyledTextCtrl::BraceMatch(int pos) {
1397 return SendMsg(2353, pos, 0);
1398}
9ce192d4 1399
4370573a
RD
1400// Are the end of line characters visible.
1401bool wxStyledTextCtrl::GetViewEOL() {
1402 return SendMsg(2355, 0, 0) != 0;
9ce192d4
RD
1403}
1404
4370573a
RD
1405// Make the end of line characters visible or invisible
1406void wxStyledTextCtrl::SetViewEOL(bool visible) {
1407 SendMsg(2356, visible, 0);
1408}
9ce192d4 1409
4370573a
RD
1410// Retrieve a pointer to the document object.
1411void* wxStyledTextCtrl::GetDocPointer() {
1412 return (void*)SendMsg(2357);
1413}
67003d1a 1414
4370573a
RD
1415// Change the document object used.
1416void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
65ec6247 1417 SendMsg(2358, 0, (long)docPointer);
67003d1a
RD
1418}
1419
4370573a
RD
1420// Set which document modification events are sent to the container.
1421void wxStyledTextCtrl::SetModEventMask(int mask) {
1422 SendMsg(2359, mask, 0);
1423}
67003d1a 1424
4370573a
RD
1425// Retrieve the column number which text should be kept within.
1426int wxStyledTextCtrl::GetEdgeColumn() {
1427 return SendMsg(2360, 0, 0);
67003d1a
RD
1428}
1429
4370573a
RD
1430// Set the column number of the edge.
1431// If text goes past the edge then it is highlighted.
1432void wxStyledTextCtrl::SetEdgeColumn(int column) {
1433 SendMsg(2361, column, 0);
1434}
67003d1a 1435
4370573a
RD
1436// Retrieve the edge highlight mode.
1437int wxStyledTextCtrl::GetEdgeMode() {
1438 return SendMsg(2362, 0, 0);
67003d1a
RD
1439}
1440
4370573a
RD
1441// The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1442// goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1443void wxStyledTextCtrl::SetEdgeMode(int mode) {
1444 SendMsg(2363, mode, 0);
1445}
67003d1a 1446
4370573a
RD
1447// Retrieve the colour used in edge indication.
1448wxColour wxStyledTextCtrl::GetEdgeColour() {
1449 long c = SendMsg(2364, 0, 0);
1450 return wxColourFromLong(c);
67003d1a
RD
1451}
1452
4370573a
RD
1453// Change the colour used in edge indication.
1454void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
1455 SendMsg(2365, wxColourAsLong(edgeColour), 0);
1456}
67003d1a 1457
4370573a
RD
1458// Sets the current caret position to be the search anchor.
1459void wxStyledTextCtrl::SearchAnchor() {
1460 SendMsg(2366, 0, 0);
67003d1a
RD
1461}
1462
4370573a 1463// Find some text starting at the search anchor.
65ec6247 1464// Does not ensure the selection is visible.
4370573a
RD
1465int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
1466 return SendMsg(2367, flags, (long)text.c_str());
1467}
67003d1a 1468
4370573a 1469// Find some text starting at the search anchor and moving backwards.
65ec6247 1470// Does not ensure the selection is visible.
4370573a
RD
1471int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
1472 return SendMsg(2368, flags, (long)text.c_str());
67003d1a
RD
1473}
1474
4370573a
RD
1475// Set the way the line the caret is on is kept visible.
1476void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy, int caretSlop) {
1477 SendMsg(2369, caretPolicy, caretSlop);
1478}
67003d1a 1479
4370573a
RD
1480// Retrieves the number of lines completely visible.
1481int wxStyledTextCtrl::LinesOnScreen() {
1482 return SendMsg(2370, 0, 0);
67003d1a
RD
1483}
1484
4370573a
RD
1485// Set whether a pop up menu is displayed automatically when the user presses
1486// the wrong mouse button.
1487void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
1488 SendMsg(2371, allowPopUp, 0);
1489}
67003d1a 1490
4370573a
RD
1491// Is the selection a rectangular. The alternative is the more common stream selection.
1492bool wxStyledTextCtrl::SelectionIsRectangle() {
1493 return SendMsg(2372, 0, 0) != 0;
67003d1a
RD
1494}
1495
4370573a
RD
1496// Set the zoom level. This number of points is added to the size of all fonts.
1497// It may be positive to magnify or negative to reduce.
1498void wxStyledTextCtrl::SetZoom(int zoom) {
1499 SendMsg(2373, zoom, 0);
1500}
67003d1a 1501
4370573a
RD
1502// Retrieve the zoom level.
1503int wxStyledTextCtrl::GetZoom() {
1504 return SendMsg(2374, 0, 0);
67003d1a
RD
1505}
1506
4370573a
RD
1507// Create a new document object.
1508// Starts with reference count of 1 and not selected into editor.
1509void* wxStyledTextCtrl::CreateDocument() {
1510 return (void*)SendMsg(2375);
1511}
67003d1a 1512
4370573a
RD
1513// Extend life of document.
1514void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
1515 SendMsg(2376, (long)docPointer);
67003d1a
RD
1516}
1517
4370573a
RD
1518// Release a reference to the document, deleting document if it fades to black.
1519void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
1520 SendMsg(2377, (long)docPointer);
1521}
67003d1a 1522
4370573a
RD
1523// Get which document modification events are sent to the container.
1524int wxStyledTextCtrl::GetModEventMask() {
1525 return SendMsg(2378, 0, 0);
67003d1a
RD
1526}
1527
65ec6247
RD
1528// Change internal focus flag
1529void wxStyledTextCtrl::SetFocus(bool focus) {
1530 SendMsg(2380, focus, 0);
1531}
1532
1533// Get internal focus flag
1534bool wxStyledTextCtrl::GetFocus() {
1535 return SendMsg(2381, 0, 0) != 0;
1536}
1537
1538// Change error status - 0 = OK
1539void wxStyledTextCtrl::SetStatus(int statusCode) {
1540 SendMsg(2382, statusCode, 0);
1541}
1542
1543// Get error status
1544int wxStyledTextCtrl::GetStatus() {
1545 return SendMsg(2383, 0, 0);
1546}
1547
1548// Set whether the mouse is captured when its button is pressed
1549void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
1550 SendMsg(2384, captures, 0);
1551}
1552
1553// Get whether mouse gets captured
1554bool wxStyledTextCtrl::GetMouseDownCaptures() {
1555 return SendMsg(2385, 0, 0) != 0;
1556}
1557
1558// Sets the cursor to one of the SC_CURSOR* values
1559void wxStyledTextCtrl::SetCursor(int cursorType) {
1560 SendMsg(2386, cursorType, 0);
1561}
1562
1563// Get cursor type
1564int wxStyledTextCtrl::GetCursor() {
1565 return SendMsg(2387, 0, 0);
1566}
1567
1568// Move to the previous change in capitalistion
1569void wxStyledTextCtrl::WordPartLeft() {
1570 SendMsg(2390, 0, 0);
1571}
1572
1573// Move to the previous change in capitalistion extending selection to new caret position.
1574void wxStyledTextCtrl::WordPartLeftExtend() {
1575 SendMsg(2391, 0, 0);
1576}
1577
1578// Move to the change next in capitalistion
1579void wxStyledTextCtrl::WordPartRight() {
1580 SendMsg(2392, 0, 0);
1581}
1582
1583// Move to the next change in capitalistion extending selection to new caret position.
1584void wxStyledTextCtrl::WordPartRightExtend() {
1585 SendMsg(2393, 0, 0);
1586}
1587
1588// Set the way the display area is determined when a particular line is to be moved to.
1589void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
1590 SendMsg(2394, visiblePolicy, visibleSlop);
1591}
1592
1593// Delete back from the current position to the start of the line
1594void wxStyledTextCtrl::DelLineLeft() {
1595 SendMsg(2395, 0, 0);
1596}
1597
1598// Delete forwards from the current position to the end of the line
1599void wxStyledTextCtrl::DelLineRight() {
1600 SendMsg(2396, 0, 0);
1601}
1602
4370573a
RD
1603// Start notifying the container of all key presses and commands.
1604void wxStyledTextCtrl::StartRecord() {
1605 SendMsg(3001, 0, 0);
1606}
67003d1a 1607
4370573a
RD
1608// Stop notifying the container of all key presses and commands.
1609void wxStyledTextCtrl::StopRecord() {
1610 SendMsg(3002, 0, 0);
67003d1a
RD
1611}
1612
4370573a
RD
1613// Set the lexing language of the document.
1614void wxStyledTextCtrl::SetLexer(int lexer) {
1615 SendMsg(4001, lexer, 0);
1616}
67003d1a 1617
4370573a
RD
1618// Retrieve the lexing language of the document.
1619int wxStyledTextCtrl::GetLexer() {
1620 return SendMsg(4002, 0, 0);
67003d1a
RD
1621}
1622
4370573a
RD
1623// Colourise a segment of the document using the current lexing language.
1624void wxStyledTextCtrl::Colourise(int start, int end) {
1625 SendMsg(4003, start, end);
1626}
67003d1a 1627
4370573a
RD
1628// Set up a value that may be used by a lexer for some optional feature.
1629void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
1630 SendMsg(4004, (long)key.c_str(), (long)value.c_str());
f6bcfd97
BP
1631}
1632
4370573a
RD
1633// Set up the key words used by the lexer.
1634void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
1635 SendMsg(4005, keywordSet, (long)keyWords.c_str());
1636}
f6bcfd97 1637
65ec6247
RD
1638// Set the lexing language of the document based on string name.
1639void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
1640 SendMsg(4006, 0, (long)language.c_str());
1641}
1642
4370573a 1643// END of generated section
f6bcfd97 1644//----------------------------------------------------------------------
f6bcfd97
BP
1645
1646
4370573a
RD
1647// Returns the line number of the line with the caret.
1648int wxStyledTextCtrl::GetCurrentLine() {
1649 int line = LineFromPosition(GetCurrentPos());
1650 return line;
f6bcfd97
BP
1651}
1652
1653
4370573a
RD
1654// Extract style settings from a spec-string which is composed of one or
1655// more of the following comma separated elements:
1656//
1657// bold turns on bold
1658// italic turns on italics
1659// fore:#RRGGBB sets the foreground colour
1660// back:#RRGGBB sets the background colour
1661// face:[facename] sets the font face name to use
1662// size:[num] sets the font size in points
1663// eol turns on eol filling
1664// underline turns on underlining
1665//
1666void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
1667
1668 wxStringTokenizer tkz(spec, ",");
1669 while (tkz.HasMoreTokens()) {
1670 wxString token = tkz.GetNextToken();
f6bcfd97 1671
4370573a
RD
1672 wxString option = token.BeforeFirst(':');
1673 wxString val = token.AfterFirst(':');
f6bcfd97 1674
4370573a
RD
1675 if (option == "bold")
1676 StyleSetBold(styleNum, true);
f6bcfd97 1677
4370573a
RD
1678 else if (option == "italic")
1679 StyleSetItalic(styleNum, true);
9ce192d4 1680
4370573a
RD
1681 else if (option == "underline")
1682 StyleSetUnderline(styleNum, true);
9ce192d4 1683
4370573a
RD
1684 else if (option == "eol")
1685 StyleSetEOLFilled(styleNum, true);
9ce192d4 1686
4370573a
RD
1687 else if (option == "size") {
1688 long points;
1689 if (val.ToLong(&points))
1690 StyleSetSize(styleNum, points);
1691 }
9ce192d4 1692
4370573a
RD
1693 else if (option == "face")
1694 StyleSetFaceName(styleNum, val);
9ce192d4 1695
4370573a
RD
1696 else if (option == "fore")
1697 StyleSetForeground(styleNum, wxColourFromSpec(val));
9ce192d4 1698
4370573a
RD
1699 else if (option == "back")
1700 StyleSetBackground(styleNum, wxColourFromSpec(val));
1701 }
9ce192d4
RD
1702}
1703
1704
4370573a
RD
1705// Set style size, face, bold, italic, and underline attributes from
1706// a wxFont's attributes.
1707void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
1708 int size = font.GetPointSize();
1709 wxString faceName = font.GetFaceName();
1710 bool bold = font.GetWeight() == wxBOLD;
1711 bool italic = font.GetStyle() != wxNORMAL;
1712 bool under = font.GetUnderlined();
9ce192d4 1713
4370573a
RD
1714 // TODO: add encoding/charset mapping
1715 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
9ce192d4
RD
1716}
1717
4370573a
RD
1718// Set all font style attributes at once.
1719void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
1720 const wxString& faceName,
1721 bool bold, bool italic,
1722 bool underline) {
1723 StyleSetSize(styleNum, size);
1724 StyleSetFaceName(styleNum, faceName);
1725 StyleSetBold(styleNum, bold);
1726 StyleSetItalic(styleNum, italic);
1727 StyleSetUnderline(styleNum, underline);
9ce192d4 1728
4370573a 1729 // TODO: add encoding/charset mapping
9ce192d4
RD
1730}
1731
1732
4370573a
RD
1733// Perform one of the operations defined by the wxSTC_CMD_* constants.
1734void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
1735 SendMsg(cmd);
9ce192d4
RD
1736}
1737
1738
4370573a
RD
1739// Set the left and right margin in the edit area, measured in pixels.
1740void wxStyledTextCtrl::SetMargins(int left, int right) {
1741 SetMarginLeft(left);
1742 SetMarginRight(right);
9ce192d4
RD
1743}
1744
1745
4370573a
RD
1746// Retrieve the start and end positions of the current selection.
1747void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
1748 if (startPos != NULL)
1749 *startPos = SendMsg(SCI_GETSELECTIONSTART);
1750 if (endPos != NULL)
1751 *endPos = SendMsg(SCI_GETSELECTIONEND);
9ce192d4
RD
1752}
1753
1754
4370573a
RD
1755// Retrieve the point in the window where a position is displayed.
1756wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
1757 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
1758 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
1759 return wxPoint(x, y);
f6bcfd97
BP
1760}
1761
f97d84a6
RD
1762// Scroll enough to make the given line visible
1763void wxStyledTextCtrl::ScrollToLine(int line) {
1764 m_swx->DoScrollToLine(line);
1765}
1766
1767
1768// Scroll enough to make the given column visible
1769void wxStyledTextCtrl::ScrollToColumn(int column) {
1770 m_swx->DoScrollToColumn(column);
1771}
1772
f6bcfd97 1773
d25f5fbb 1774
9ce192d4
RD
1775//----------------------------------------------------------------------
1776// Event handlers
1777
1778void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) {
1779 wxPaintDC dc(this);
1780 wxRegion region = GetUpdateRegion();
1781
1782 m_swx->DoPaint(&dc, region.GetBox());
1783}
1784
1785void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
1786 if (evt.GetOrientation() == wxHORIZONTAL)
1787 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
1788 else
1789 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
1790}
1791
1792void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) {
1793 wxSize sz = GetClientSize();
1794 m_swx->DoSize(sz.x, sz.y);
1795}
1796
1797void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
1798 wxPoint pt = evt.GetPosition();
1799 m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
1800 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
1801}
1802
1803void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
1804 wxPoint pt = evt.GetPosition();
1805 m_swx->DoButtonMove(Point(pt.x, pt.y));
1806}
1807
1808void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
1809 wxPoint pt = evt.GetPosition();
1810 m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
1811 evt.ControlDown());
1812}
1813
1814
65ec6247 1815void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
9ce192d4 1816 wxPoint pt = evt.GetPosition();
65ec6247 1817 ScreenToClient(&pt.x, &pt.y);
9ce192d4
RD
1818 m_swx->DoContextMenu(Point(pt.x, pt.y));
1819}
1820
37d62433
RD
1821
1822void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
1823 m_swx->DoMouseWheel(evt.GetWheelRotation(),
1824 evt.GetWheelDelta(),
65ec6247
RD
1825 evt.GetLinesPerAction(),
1826 evt.ControlDown());
37d62433
RD
1827}
1828
1829
9ce192d4 1830void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
9ce192d4 1831 long key = evt.KeyCode();
d25f5fbb
RD
1832 if ((key > WXK_ESCAPE) &&
1833 (key != WXK_DELETE) && (key < 255) &&
1834 !evt.ControlDown() && !evt.AltDown()) {
1835
1836 m_swx->DoAddChar(key);
1837 }
1838 else {
1839 evt.Skip();
9ce192d4 1840 }
f6bcfd97
BP
1841}
1842
1843void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
1844 long key = evt.KeyCode();
65ec6247
RD
1845 //key = toupper(key); //**** ????
1846 bool consumed = FALSE;
1847 int processed = m_swx->DoKeyDown(key,
1848 evt.ShiftDown(),
1849 evt.ControlDown(),
1850 evt.AltDown(),
1851 &consumed);
1852 if (!processed && !consumed)
9ce192d4
RD
1853 evt.Skip();
1854}
1855
1856void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
1857 m_swx->DoLoseFocus();
1858}
1859
1860void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
1861 m_swx->DoGainFocus();
1862}
1863
1864void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) {
1865 m_swx->DoSysColourChange();
1866}
1867
1868void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) {
1869 // do nothing to help avoid flashing
1870}
1871
1872
1873
1874void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
1875 m_swx->DoCommand(evt.GetId());
1876}
1877
1878
f6bcfd97
BP
1879void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) {
1880 m_swx->DoOnListBox();
1881}
1882
1883
9ce192d4
RD
1884//----------------------------------------------------------------------
1885// Turn notifications from Scintilla into events
1886
f6bcfd97 1887
9ce192d4
RD
1888void wxStyledTextCtrl::NotifyChange() {
1889 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
1890 GetEventHandler()->ProcessEvent(evt);
1891}
1892
1893void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
1894 SCNotification& scn = *_scn;
65ec6247
RD
1895 wxStyledTextEvent evt(0, GetId());
1896
1897 evt.SetPosition(scn.position);
1898 evt.SetKey(scn.ch);
1899 evt.SetModifiers(scn.modifiers);
1900
9ce192d4
RD
1901 switch (scn.nmhdr.code) {
1902 case SCN_STYLENEEDED:
65ec6247 1903 evt.SetEventType(wxEVT_STC_STYLENEEDED);
9ce192d4 1904 break;
65ec6247 1905
9ce192d4 1906 case SCN_CHARADDED:
65ec6247 1907 evt.SetEventType(wxEVT_STC_CHARADDED);
9ce192d4 1908 break;
65ec6247 1909
9ce192d4 1910 case SCN_SAVEPOINTREACHED:
65ec6247 1911 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
9ce192d4 1912 break;
65ec6247 1913
9ce192d4 1914 case SCN_SAVEPOINTLEFT:
65ec6247 1915 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
9ce192d4 1916 break;
65ec6247 1917
9ce192d4 1918 case SCN_MODIFYATTEMPTRO:
65ec6247 1919 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
9ce192d4 1920 break;
65ec6247
RD
1921
1922 case SCN_KEY:
1923 evt.SetEventType(wxEVT_STC_KEY);
1924 break;
1925
9ce192d4 1926 case SCN_DOUBLECLICK:
65ec6247 1927 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
9ce192d4 1928 break;
65ec6247
RD
1929
1930 case SCN_UPDATEUI:
1931 evt.SetEventType(wxEVT_STC_UPDATEUI);
9ce192d4 1932 break;
65ec6247
RD
1933
1934 case SCN_MODIFIED:
1935 evt.SetEventType(wxEVT_STC_MODIFIED);
1936 evt.SetModificationType(scn.modificationType);
1937 if (scn.text)
1938 evt.SetText(wxString(scn.text, scn.length));
1939 evt.SetLength(scn.length);
1940 evt.SetLinesAdded(scn.linesAdded);
1941 evt.SetLine(scn.line);
1942 evt.SetFoldLevelNow(scn.foldLevelNow);
1943 evt.SetFoldLevelPrev(scn.foldLevelPrev);
9ce192d4 1944 break;
65ec6247 1945
9ce192d4 1946 case SCN_MACRORECORD:
65ec6247
RD
1947 evt.SetEventType(wxEVT_STC_MACRORECORD);
1948 evt.SetMessage(scn.message);
1949 evt.SetWParam(scn.wParam);
1950 evt.SetLParam(scn.lParam);
9ce192d4 1951 break;
65ec6247 1952
9ce192d4 1953 case SCN_MARGINCLICK:
65ec6247
RD
1954 evt.SetEventType(wxEVT_STC_MARGINCLICK);
1955 evt.SetMargin(scn.margin);
9ce192d4 1956 break;
65ec6247 1957
9ce192d4 1958 case SCN_NEEDSHOWN:
65ec6247
RD
1959 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
1960 evt.SetLength(scn.length);
9ce192d4 1961 break;
65ec6247 1962
4370573a 1963 case SCN_POSCHANGED:
65ec6247 1964 evt.SetEventType(wxEVT_STC_POSCHANGED);
4370573a 1965 break;
9ce192d4 1966
65ec6247
RD
1967 case SCN_PAINTED:
1968 evt.SetEventType(wxEVT_STC_PAINTED);
1969 break;
1970
1971 case SCN_USERLISTSELECTION:
1972 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
1973 evt.SetListType(scn.listType);
1974 evt.SetText(scn.text);
1975 break;
1976
1977 case SCN_URIDROPPED:
1978 evt.SetEventType(wxEVT_STC_URIDROPPED);
1979 evt.SetText(scn.text);
1980 break;
1981
1982 case SCN_DWELLSTART:
1983 evt.SetEventType(wxEVT_STC_DWELLSTART);
1984 evt.SetX(scn.x);
1985 evt.SetY(scn.y);
1986 break;
1987
1988 case SCN_DWELLEND:
1989 evt.SetEventType(wxEVT_STC_DWELLEND);
1990 evt.SetX(scn.x);
1991 evt.SetY(scn.y);
1992 break;
1993
1994 default:
1995 return;
9ce192d4 1996 }
65ec6247
RD
1997
1998 GetEventHandler()->ProcessEvent(evt);
9ce192d4
RD
1999}
2000
2001
2002
2003//----------------------------------------------------------------------
2004//----------------------------------------------------------------------
2005//----------------------------------------------------------------------
2006
2007wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
2008 : wxCommandEvent(commandType, id)
2009{
2010 m_position = 0;
2011 m_key = 0;
2012 m_modifiers = 0;
2013 m_modificationType = 0;
2014 m_length = 0;
2015 m_linesAdded = 0;
2016 m_line = 0;
2017 m_foldLevelNow = 0;
2018 m_foldLevelPrev = 0;
2019 m_margin = 0;
2020 m_message = 0;
2021 m_wParam = 0;
2022 m_lParam = 0;
65ec6247
RD
2023 m_listType = 0;
2024 m_x = 0;
2025 m_y = 0;
9ce192d4
RD
2026}
2027
2028bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
2029bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
2030bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
2031
2032void wxStyledTextEvent::CopyObject(wxObject& obj) const {
2033 wxCommandEvent::CopyObject(obj);
2034
2035 wxStyledTextEvent* o = (wxStyledTextEvent*)&obj;
2036 o->m_position = m_position;
2037 o->m_key = m_key;
2038 o->m_modifiers = m_modifiers;
2039 o->m_modificationType = m_modificationType;
2040 o->m_text = m_text;
2041 o->m_length = m_length;
2042 o->m_linesAdded = m_linesAdded;
2043 o->m_line = m_line;
2044 o->m_foldLevelNow = m_foldLevelNow;
2045 o->m_foldLevelPrev = m_foldLevelPrev;
2046
2047 o->m_margin = m_margin;
2048
2049 o->m_message = m_message;
2050 o->m_wParam = m_wParam;
2051 o->m_lParam = m_lParam;
2052
65ec6247
RD
2053 o->m_listType = m_listType;
2054 o->m_x = m_x;
2055 o->m_y = m_y;
9ce192d4
RD
2056
2057}
2058
2059//----------------------------------------------------------------------
2060//----------------------------------------------------------------------
2061