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