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