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