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