Updated wxSTC's copy of Scintilla to version 1.61
[wxWidgets.git] / src / stc / stc.cpp
1 ////////////////////////////////////////////////////////////////////////////
2 // Name: stc.cpp
3 // Purpose: A wxWidgets 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/wx.h>
24 #include <wx/tokenzr.h>
25 #include <wx/mstream.h>
26 #include <wx/image.h>
27 #include <wx/file.h>
28
29
30 //----------------------------------------------------------------------
31
32 const wxChar* wxSTCNameStr = wxT("stcwindow");
33
34 #ifdef MAKELONG
35 #undef MAKELONG
36 #endif
37
38 #define MAKELONG(a, b) ((a) | ((b) << 16))
39
40
41 static long wxColourAsLong(const wxColour& co) {
42 return (((long)co.Blue() << 16) |
43 ((long)co.Green() << 8) |
44 ((long)co.Red()));
45 }
46
47 static wxColour wxColourFromLong(long c) {
48 wxColour clr;
49 clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff);
50 return clr;
51 }
52
53
54 static wxColour wxColourFromSpec(const wxString& spec) {
55 // spec should be "#RRGGBB"
56 long red, green, blue;
57 red = green = blue = 0;
58 spec.Mid(1,2).ToLong(&red, 16);
59 spec.Mid(3,2).ToLong(&green, 16);
60 spec.Mid(5,2).ToLong(&blue, 16);
61 return wxColour(red, green, blue);
62 }
63
64 //----------------------------------------------------------------------
65
66 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE )
67 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED )
68 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED )
69 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED )
70 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT )
71 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT )
72 DEFINE_EVENT_TYPE( wxEVT_STC_KEY )
73 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK )
74 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI )
75 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED )
76 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD )
77 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK )
78 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN )
79 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED )
80 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION )
81 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED )
82 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART )
83 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND )
84 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG )
85 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER )
86 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP )
87 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM )
88 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK )
89 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK )
90 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK )
91
92
93
94 BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
95 EVT_PAINT (wxStyledTextCtrl::OnPaint)
96 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
97 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
98 EVT_SIZE (wxStyledTextCtrl::OnSize)
99 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
100 // Let Scintilla see the double click as a second click
101 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
102 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
103 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
104 #if defined(__WXGTK__) || defined(__WXMAC__)
105 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
106 #else
107 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
108 #endif
109 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
110 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
111 EVT_CHAR (wxStyledTextCtrl::OnChar)
112 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
113 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
114 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
115 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
116 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
117 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
118 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox)
119 END_EVENT_TABLE()
120
121
122 IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
123 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
124
125 #ifdef LINK_LEXERS
126 // forces the linking of the lexer modules
127 int Scintilla_LinkLexers();
128 #endif
129
130 //----------------------------------------------------------------------
131 // Constructor and Destructor
132
133 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
134 wxWindowID id,
135 const wxPoint& pos,
136 const wxSize& size,
137 long style,
138 const wxString& name)
139 {
140 m_swx = NULL;
141 Create(parent, id, pos, size, style, name);
142 }
143
144
145 void wxStyledTextCtrl::Create(wxWindow *parent,
146 wxWindowID id,
147 const wxPoint& pos,
148 const wxSize& size,
149 long style,
150 const wxString& name)
151 {
152 #ifdef __WXMAC__
153 style |= wxVSCROLL | wxHSCROLL;
154 #endif
155 wxControl::Create(parent, id, pos, size,
156 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
157 wxDefaultValidator, name);
158
159 #ifdef LINK_LEXERS
160 Scintilla_LinkLexers();
161 #endif
162 m_swx = new ScintillaWX(this);
163 m_stopWatch.Start();
164 m_lastKeyDownConsumed = FALSE;
165 m_vScrollBar = NULL;
166 m_hScrollBar = NULL;
167 #if wxUSE_UNICODE
168 // Put Scintilla into unicode (UTF-8) mode
169 SetCodePage(wxSTC_CP_UTF8);
170 #endif
171
172 SetBestFittingSize(size);
173 }
174
175
176 wxStyledTextCtrl::~wxStyledTextCtrl() {
177 delete m_swx;
178 }
179
180
181 //----------------------------------------------------------------------
182
183 long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) {
184
185 return m_swx->WndProc(msg, wp, lp);
186 }
187
188
189
190 //----------------------------------------------------------------------
191 // BEGIN generated section. The following code is automatically generated
192 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
193 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
194
195
196 // Add text to the document at current position.
197 void wxStyledTextCtrl::AddText(const wxString& text) {
198 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
199 SendMsg(2001, strlen(buf), (long)(const char*)buf);
200 }
201
202 // Add array of cells to document.
203 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
204 SendMsg(2002, data.GetDataLen(), (long)data.GetData());
205 }
206
207 // Insert string at a position.
208 void wxStyledTextCtrl::InsertText(int pos, const wxString& text) {
209 SendMsg(2003, pos, (long)(const char*)wx2stc(text));
210 }
211
212 // Delete all text in the document.
213 void wxStyledTextCtrl::ClearAll() {
214 SendMsg(2004, 0, 0);
215 }
216
217 // Set all style bytes to 0, remove all folding information.
218 void wxStyledTextCtrl::ClearDocumentStyle() {
219 SendMsg(2005, 0, 0);
220 }
221
222 // Returns the number of characters in the document.
223 int wxStyledTextCtrl::GetLength() {
224 return SendMsg(2006, 0, 0);
225 }
226
227 // Returns the character byte at the position.
228 int wxStyledTextCtrl::GetCharAt(int pos) {
229 return (unsigned char)SendMsg(2007, pos, 0);
230 }
231
232 // Returns the position of the caret.
233 int wxStyledTextCtrl::GetCurrentPos() {
234 return SendMsg(2008, 0, 0);
235 }
236
237 // Returns the position of the opposite end of the selection to the caret.
238 int wxStyledTextCtrl::GetAnchor() {
239 return SendMsg(2009, 0, 0);
240 }
241
242 // Returns the style byte at the position.
243 int wxStyledTextCtrl::GetStyleAt(int pos) {
244 return (unsigned char)SendMsg(2010, pos, 0);
245 }
246
247 // Redoes the next action on the undo history.
248 void wxStyledTextCtrl::Redo() {
249 SendMsg(2011, 0, 0);
250 }
251
252 // Choose between collecting actions into the undo
253 // history and discarding them.
254 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) {
255 SendMsg(2012, collectUndo, 0);
256 }
257
258 // Select all the text in the document.
259 void wxStyledTextCtrl::SelectAll() {
260 SendMsg(2013, 0, 0);
261 }
262
263 // Remember the current position in the undo history as the position
264 // at which the document was saved.
265 void wxStyledTextCtrl::SetSavePoint() {
266 SendMsg(2014, 0, 0);
267 }
268
269 // Retrieve a buffer of cells.
270 wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
271 wxMemoryBuffer buf;
272 if (endPos < startPos) {
273 int temp = startPos;
274 startPos = endPos;
275 endPos = temp;
276 }
277 int len = endPos - startPos;
278 if (!len) return buf;
279 TextRange tr;
280 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
281 tr.chrg.cpMin = startPos;
282 tr.chrg.cpMax = endPos;
283 len = SendMsg(2015, 0, (long)&tr);
284 buf.UngetWriteBuf(len);
285 return buf;
286 }
287
288 // Are there any redoable actions in the undo history?
289 bool wxStyledTextCtrl::CanRedo() {
290 return SendMsg(2016, 0, 0) != 0;
291 }
292
293 // Retrieve the line number at which a particular marker is located.
294 int wxStyledTextCtrl::MarkerLineFromHandle(int handle) {
295 return SendMsg(2017, handle, 0);
296 }
297
298 // Delete a marker.
299 void wxStyledTextCtrl::MarkerDeleteHandle(int handle) {
300 SendMsg(2018, handle, 0);
301 }
302
303 // Is undo history being collected?
304 bool wxStyledTextCtrl::GetUndoCollection() {
305 return SendMsg(2019, 0, 0) != 0;
306 }
307
308 // Are white space characters currently visible?
309 // Returns one of SCWS_* constants.
310 int wxStyledTextCtrl::GetViewWhiteSpace() {
311 return SendMsg(2020, 0, 0);
312 }
313
314 // Make white space characters invisible, always visible or visible outside indentation.
315 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) {
316 SendMsg(2021, viewWS, 0);
317 }
318
319 // Find the position from a point within the window.
320 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) {
321 return SendMsg(2022, pt.x, pt.y);
322 }
323
324 // Find the position from a point within the window but return
325 // INVALID_POSITION if not close to text.
326 int wxStyledTextCtrl::PositionFromPointClose(int x, int y) {
327 return SendMsg(2023, x, y);
328 }
329
330 // Set caret to start of a line and ensure it is visible.
331 void wxStyledTextCtrl::GotoLine(int line) {
332 SendMsg(2024, line, 0);
333 }
334
335 // Set caret to a position and ensure it is visible.
336 void wxStyledTextCtrl::GotoPos(int pos) {
337 SendMsg(2025, pos, 0);
338 }
339
340 // Set the selection anchor to a position. The anchor is the opposite
341 // end of the selection from the caret.
342 void wxStyledTextCtrl::SetAnchor(int posAnchor) {
343 SendMsg(2026, posAnchor, 0);
344 }
345
346 // Retrieve the text of the line containing the caret.
347 // Returns the index of the caret on the line.
348 wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
349 int len = LineLength(GetCurrentLine());
350 if (!len) {
351 if (linePos) *linePos = 0;
352 return wxEmptyString;
353 }
354
355 wxMemoryBuffer mbuf(len+1);
356 char* buf = (char*)mbuf.GetWriteBuf(len+1);
357
358 int pos = SendMsg(2027, len+1, (long)buf);
359 mbuf.UngetWriteBuf(len);
360 mbuf.AppendByte(0);
361 if (linePos) *linePos = pos;
362 return stc2wx(buf);
363 }
364
365 // Retrieve the position of the last correctly styled character.
366 int wxStyledTextCtrl::GetEndStyled() {
367 return SendMsg(2028, 0, 0);
368 }
369
370 // Convert all line endings in the document to one mode.
371 void wxStyledTextCtrl::ConvertEOLs(int eolMode) {
372 SendMsg(2029, eolMode, 0);
373 }
374
375 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
376 int wxStyledTextCtrl::GetEOLMode() {
377 return SendMsg(2030, 0, 0);
378 }
379
380 // Set the current end of line mode.
381 void wxStyledTextCtrl::SetEOLMode(int eolMode) {
382 SendMsg(2031, eolMode, 0);
383 }
384
385 // Set the current styling position to pos and the styling mask to mask.
386 // The styling mask can be used to protect some bits in each styling byte from modification.
387 void wxStyledTextCtrl::StartStyling(int pos, int mask) {
388 SendMsg(2032, pos, mask);
389 }
390
391 // Change style from current styling position for length characters to a style
392 // and move the current styling position to after this newly styled segment.
393 void wxStyledTextCtrl::SetStyling(int length, int style) {
394 SendMsg(2033, length, style);
395 }
396
397 // Is drawing done first into a buffer or direct to the screen?
398 bool wxStyledTextCtrl::GetBufferedDraw() {
399 return SendMsg(2034, 0, 0) != 0;
400 }
401
402 // If drawing is buffered then each line of text is drawn into a bitmap buffer
403 // before drawing it to the screen to avoid flicker.
404 void wxStyledTextCtrl::SetBufferedDraw(bool buffered) {
405 SendMsg(2035, buffered, 0);
406 }
407
408 // Change the visible size of a tab to be a multiple of the width of a space character.
409 void wxStyledTextCtrl::SetTabWidth(int tabWidth) {
410 SendMsg(2036, tabWidth, 0);
411 }
412
413 // Retrieve the visible size of a tab.
414 int wxStyledTextCtrl::GetTabWidth() {
415 return SendMsg(2121, 0, 0);
416 }
417
418 // Set the code page used to interpret the bytes of the document as characters.
419 void wxStyledTextCtrl::SetCodePage(int codePage) {
420 #if wxUSE_UNICODE
421 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
422 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
423 #else
424 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
425 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
426 #endif
427 SendMsg(2037, codePage);
428 }
429
430 // Set the symbol used for a particular marker number,
431 // and optionally the fore and background colours.
432 void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
433 const wxColour& foreground,
434 const wxColour& background) {
435
436 SendMsg(2040, markerNumber, markerSymbol);
437 if (foreground.Ok())
438 MarkerSetForeground(markerNumber, foreground);
439 if (background.Ok())
440 MarkerSetBackground(markerNumber, background);
441 }
442
443 // Set the foreground colour used for a particular marker number.
444 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) {
445 SendMsg(2041, markerNumber, wxColourAsLong(fore));
446 }
447
448 // Set the background colour used for a particular marker number.
449 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) {
450 SendMsg(2042, markerNumber, wxColourAsLong(back));
451 }
452
453 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
454 int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) {
455 return SendMsg(2043, line, markerNumber);
456 }
457
458 // Delete a marker from a line.
459 void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) {
460 SendMsg(2044, line, markerNumber);
461 }
462
463 // Delete all markers with a particular number from all lines.
464 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) {
465 SendMsg(2045, markerNumber, 0);
466 }
467
468 // Get a bit mask of all the markers set on a line.
469 int wxStyledTextCtrl::MarkerGet(int line) {
470 return SendMsg(2046, line, 0);
471 }
472
473 // Find the next line after lineStart that includes a marker in mask.
474 int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) {
475 return SendMsg(2047, lineStart, markerMask);
476 }
477
478 // Find the previous line before lineStart that includes a marker in mask.
479 int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) {
480 return SendMsg(2048, lineStart, markerMask);
481 }
482
483 // Define a marker from a bitmap
484 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
485 // convert bmp to a xpm in a string
486 wxMemoryOutputStream strm;
487 wxImage img = bmp.ConvertToImage();
488 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
489 size_t len = strm.GetSize();
490 char* buff = new char[len+1];
491 strm.CopyTo(buff, len);
492 buff[len] = 0;
493 SendMsg(2049, markerNumber, (long)buff);
494 delete [] buff;
495
496 }
497
498 // Set a margin to be either numeric or symbolic.
499 void wxStyledTextCtrl::SetMarginType(int margin, int marginType) {
500 SendMsg(2240, margin, marginType);
501 }
502
503 // Retrieve the type of a margin.
504 int wxStyledTextCtrl::GetMarginType(int margin) {
505 return SendMsg(2241, margin, 0);
506 }
507
508 // Set the width of a margin to a width expressed in pixels.
509 void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) {
510 SendMsg(2242, margin, pixelWidth);
511 }
512
513 // Retrieve the width of a margin in pixels.
514 int wxStyledTextCtrl::GetMarginWidth(int margin) {
515 return SendMsg(2243, margin, 0);
516 }
517
518 // Set a mask that determines which markers are displayed in a margin.
519 void wxStyledTextCtrl::SetMarginMask(int margin, int mask) {
520 SendMsg(2244, margin, mask);
521 }
522
523 // Retrieve the marker mask of a margin.
524 int wxStyledTextCtrl::GetMarginMask(int margin) {
525 return SendMsg(2245, margin, 0);
526 }
527
528 // Make a margin sensitive or insensitive to mouse clicks.
529 void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) {
530 SendMsg(2246, margin, sensitive);
531 }
532
533 // Retrieve the mouse click sensitivity of a margin.
534 bool wxStyledTextCtrl::GetMarginSensitive(int margin) {
535 return SendMsg(2247, margin, 0) != 0;
536 }
537
538 // Clear all the styles and make equivalent to the global default style.
539 void wxStyledTextCtrl::StyleClearAll() {
540 SendMsg(2050, 0, 0);
541 }
542
543 // Set the foreground colour of a style.
544 void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) {
545 SendMsg(2051, style, wxColourAsLong(fore));
546 }
547
548 // Set the background colour of a style.
549 void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) {
550 SendMsg(2052, style, wxColourAsLong(back));
551 }
552
553 // Set a style to be bold or not.
554 void wxStyledTextCtrl::StyleSetBold(int style, bool bold) {
555 SendMsg(2053, style, bold);
556 }
557
558 // Set a style to be italic or not.
559 void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) {
560 SendMsg(2054, style, italic);
561 }
562
563 // Set the size of characters of a style.
564 void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) {
565 SendMsg(2055, style, sizePoints);
566 }
567
568 // Set the font of a style.
569 void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) {
570 SendMsg(2056, style, (long)(const char*)wx2stc(fontName));
571 }
572
573 // Set a style to have its end of line filled or not.
574 void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) {
575 SendMsg(2057, style, filled);
576 }
577
578 // Reset the default style to its state at startup
579 void wxStyledTextCtrl::StyleResetDefault() {
580 SendMsg(2058, 0, 0);
581 }
582
583 // Set a style to be underlined or not.
584 void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) {
585 SendMsg(2059, style, underline);
586 }
587
588 // Set a style to be mixed case, or to force upper or lower case.
589 void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) {
590 SendMsg(2060, style, caseForce);
591 }
592
593 // Set the character set of the font in a style.
594 void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) {
595 SendMsg(2066, style, characterSet);
596 }
597
598 // Set a style to be a hotspot or not.
599 void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) {
600 SendMsg(2409, style, hotspot);
601 }
602
603 // Set the foreground colour of the selection and whether to use this setting.
604 void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) {
605 SendMsg(2067, useSetting, wxColourAsLong(fore));
606 }
607
608 // Set the background colour of the selection and whether to use this setting.
609 void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) {
610 SendMsg(2068, useSetting, wxColourAsLong(back));
611 }
612
613 // Set the foreground colour of the caret.
614 void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) {
615 SendMsg(2069, wxColourAsLong(fore), 0);
616 }
617
618 // When key+modifier combination km is pressed perform msg.
619 void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
620 SendMsg(2070, MAKELONG(key, modifiers), cmd);
621 }
622
623 // When key+modifier combination km is pressed do nothing.
624 void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
625 SendMsg(2071, MAKELONG(key, modifiers));
626 }
627
628 // Drop all key mappings.
629 void wxStyledTextCtrl::CmdKeyClearAll() {
630 SendMsg(2072, 0, 0);
631 }
632
633 // Set the styles for a segment of the document.
634 void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
635 SendMsg(2073, length, (long)styleBytes);
636 }
637
638 // Set a style to be visible or not.
639 void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) {
640 SendMsg(2074, style, visible);
641 }
642
643 // Get the time in milliseconds that the caret is on and off.
644 int wxStyledTextCtrl::GetCaretPeriod() {
645 return SendMsg(2075, 0, 0);
646 }
647
648 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
649 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) {
650 SendMsg(2076, periodMilliseconds, 0);
651 }
652
653 // Set the set of characters making up words for when moving or selecting by word.
654 // First sets deaults like SetCharsDefault.
655 void wxStyledTextCtrl::SetWordChars(const wxString& characters) {
656 SendMsg(2077, 0, (long)(const char*)wx2stc(characters));
657 }
658
659 // Start a sequence of actions that is undone and redone as a unit.
660 // May be nested.
661 void wxStyledTextCtrl::BeginUndoAction() {
662 SendMsg(2078, 0, 0);
663 }
664
665 // End a sequence of actions that is undone and redone as a unit.
666 void wxStyledTextCtrl::EndUndoAction() {
667 SendMsg(2079, 0, 0);
668 }
669
670 // Set an indicator to plain, squiggle or TT.
671 void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) {
672 SendMsg(2080, indic, style);
673 }
674
675 // Retrieve the style of an indicator.
676 int wxStyledTextCtrl::IndicatorGetStyle(int indic) {
677 return SendMsg(2081, indic, 0);
678 }
679
680 // Set the foreground colour of an indicator.
681 void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) {
682 SendMsg(2082, indic, wxColourAsLong(fore));
683 }
684
685 // Retrieve the foreground colour of an indicator.
686 wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) {
687 long c = SendMsg(2083, indic, 0);
688 return wxColourFromLong(c);
689 }
690
691 // Set the foreground colour of all whitespace and whether to use this setting.
692 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) {
693 SendMsg(2084, useSetting, wxColourAsLong(fore));
694 }
695
696 // Set the background colour of all whitespace and whether to use this setting.
697 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) {
698 SendMsg(2085, useSetting, wxColourAsLong(back));
699 }
700
701 // Divide each styling byte into lexical class bits (default: 5) and indicator
702 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
703 // is used to expand the possible states.
704 void wxStyledTextCtrl::SetStyleBits(int bits) {
705 SendMsg(2090, bits, 0);
706 }
707
708 // Retrieve number of bits in style bytes used to hold the lexical state.
709 int wxStyledTextCtrl::GetStyleBits() {
710 return SendMsg(2091, 0, 0);
711 }
712
713 // Used to hold extra styling information for each line.
714 void wxStyledTextCtrl::SetLineState(int line, int state) {
715 SendMsg(2092, line, state);
716 }
717
718 // Retrieve the extra styling information for a line.
719 int wxStyledTextCtrl::GetLineState(int line) {
720 return SendMsg(2093, line, 0);
721 }
722
723 // Retrieve the last line number that has line state.
724 int wxStyledTextCtrl::GetMaxLineState() {
725 return SendMsg(2094, 0, 0);
726 }
727
728 // Is the background of the line containing the caret in a different colour?
729 bool wxStyledTextCtrl::GetCaretLineVisible() {
730 return SendMsg(2095, 0, 0) != 0;
731 }
732
733 // Display the background of the line containing the caret in a different colour.
734 void wxStyledTextCtrl::SetCaretLineVisible(bool show) {
735 SendMsg(2096, show, 0);
736 }
737
738 // Get the colour of the background of the line containing the caret.
739 wxColour wxStyledTextCtrl::GetCaretLineBack() {
740 long c = SendMsg(2097, 0, 0);
741 return wxColourFromLong(c);
742 }
743
744 // Set the colour of the background of the line containing the caret.
745 void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) {
746 SendMsg(2098, wxColourAsLong(back), 0);
747 }
748
749 // Set a style to be changeable or not (read only).
750 // Experimental feature, currently buggy.
751 void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) {
752 SendMsg(2099, style, changeable);
753 }
754
755 // Display a auto-completion list.
756 // The lenEntered parameter indicates how many characters before
757 // the caret should be used to provide context.
758 void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) {
759 SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList));
760 }
761
762 // Remove the auto-completion list from the screen.
763 void wxStyledTextCtrl::AutoCompCancel() {
764 SendMsg(2101, 0, 0);
765 }
766
767 // Is there an auto-completion list visible?
768 bool wxStyledTextCtrl::AutoCompActive() {
769 return SendMsg(2102, 0, 0) != 0;
770 }
771
772 // Retrieve the position of the caret when the auto-completion list was displayed.
773 int wxStyledTextCtrl::AutoCompPosStart() {
774 return SendMsg(2103, 0, 0);
775 }
776
777 // User has selected an item so remove the list and insert the selection.
778 void wxStyledTextCtrl::AutoCompComplete() {
779 SendMsg(2104, 0, 0);
780 }
781
782 // Define a set of character that when typed cancel the auto-completion list.
783 void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) {
784 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet));
785 }
786
787 // Change the separator character in the string setting up an auto-completion list.
788 // Default is space but can be changed if items contain space.
789 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) {
790 SendMsg(2106, separatorCharacter, 0);
791 }
792
793 // Retrieve the auto-completion list separator character.
794 int wxStyledTextCtrl::AutoCompGetSeparator() {
795 return SendMsg(2107, 0, 0);
796 }
797
798 // Select the item in the auto-completion list that starts with a string.
799 void wxStyledTextCtrl::AutoCompSelect(const wxString& text) {
800 SendMsg(2108, 0, (long)(const char*)wx2stc(text));
801 }
802
803 // Should the auto-completion list be cancelled if the user backspaces to a
804 // position before where the box was created.
805 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) {
806 SendMsg(2110, cancel, 0);
807 }
808
809 // Retrieve whether auto-completion cancelled by backspacing before start.
810 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
811 return SendMsg(2111, 0, 0) != 0;
812 }
813
814 // Define a set of characters that when typed will cause the autocompletion to
815 // choose the selected item.
816 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) {
817 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet));
818 }
819
820 // Should a single item auto-completion list automatically choose the item.
821 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) {
822 SendMsg(2113, chooseSingle, 0);
823 }
824
825 // Retrieve whether a single item auto-completion list automatically choose the item.
826 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
827 return SendMsg(2114, 0, 0) != 0;
828 }
829
830 // Set whether case is significant when performing auto-completion searches.
831 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) {
832 SendMsg(2115, ignoreCase, 0);
833 }
834
835 // Retrieve state of ignore case flag.
836 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
837 return SendMsg(2116, 0, 0) != 0;
838 }
839
840 // Display a list of strings and send notification when user chooses one.
841 void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) {
842 SendMsg(2117, listType, (long)(const char*)wx2stc(itemList));
843 }
844
845 // Set whether or not autocompletion is hidden automatically when nothing matches.
846 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) {
847 SendMsg(2118, autoHide, 0);
848 }
849
850 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
851 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
852 return SendMsg(2119, 0, 0) != 0;
853 }
854
855 // Set whether or not autocompletion deletes any word characters
856 // after the inserted text upon completion.
857 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) {
858 SendMsg(2270, dropRestOfWord, 0);
859 }
860
861 // Retrieve whether or not autocompletion deletes any word characters
862 // after the inserted text upon completion.
863 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
864 return SendMsg(2271, 0, 0) != 0;
865 }
866
867 // Register an image for use in autocompletion lists.
868 void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
869 // convert bmp to a xpm in a string
870 wxMemoryOutputStream strm;
871 wxImage img = bmp.ConvertToImage();
872 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
873 size_t len = strm.GetSize();
874 char* buff = new char[len+1];
875 strm.CopyTo(buff, len);
876 buff[len] = 0;
877 SendMsg(2405, type, (long)buff);
878 delete [] buff;
879
880 }
881
882 // Clear all the registered images.
883 void wxStyledTextCtrl::ClearRegisteredImages() {
884 SendMsg(2408, 0, 0);
885 }
886
887 // Retrieve the auto-completion list type-separator character.
888 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
889 return SendMsg(2285, 0, 0);
890 }
891
892 // Change the type-separator character in the string setting up an auto-completion list.
893 // Default is '?' but can be changed if items contain '?'.
894 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) {
895 SendMsg(2286, separatorCharacter, 0);
896 }
897
898 // Set the number of spaces used for one level of indentation.
899 void wxStyledTextCtrl::SetIndent(int indentSize) {
900 SendMsg(2122, indentSize, 0);
901 }
902
903 // Retrieve indentation size.
904 int wxStyledTextCtrl::GetIndent() {
905 return SendMsg(2123, 0, 0);
906 }
907
908 // Indentation will only use space characters if useTabs is false, otherwise
909 // it will use a combination of tabs and spaces.
910 void wxStyledTextCtrl::SetUseTabs(bool useTabs) {
911 SendMsg(2124, useTabs, 0);
912 }
913
914 // Retrieve whether tabs will be used in indentation.
915 bool wxStyledTextCtrl::GetUseTabs() {
916 return SendMsg(2125, 0, 0) != 0;
917 }
918
919 // Change the indentation of a line to a number of columns.
920 void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) {
921 SendMsg(2126, line, indentSize);
922 }
923
924 // Retrieve the number of columns that a line is indented.
925 int wxStyledTextCtrl::GetLineIndentation(int line) {
926 return SendMsg(2127, line, 0);
927 }
928
929 // Retrieve the position before the first non indentation character on a line.
930 int wxStyledTextCtrl::GetLineIndentPosition(int line) {
931 return SendMsg(2128, line, 0);
932 }
933
934 // Retrieve the column number of a position, taking tab width into account.
935 int wxStyledTextCtrl::GetColumn(int pos) {
936 return SendMsg(2129, pos, 0);
937 }
938
939 // Show or hide the horizontal scroll bar.
940 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) {
941 SendMsg(2130, show, 0);
942 }
943
944 // Is the horizontal scroll bar visible?
945 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
946 return SendMsg(2131, 0, 0) != 0;
947 }
948
949 // Show or hide indentation guides.
950 void wxStyledTextCtrl::SetIndentationGuides(bool show) {
951 SendMsg(2132, show, 0);
952 }
953
954 // Are the indentation guides visible?
955 bool wxStyledTextCtrl::GetIndentationGuides() {
956 return SendMsg(2133, 0, 0) != 0;
957 }
958
959 // Set the highlighted indentation guide column.
960 // 0 = no highlighted guide.
961 void wxStyledTextCtrl::SetHighlightGuide(int column) {
962 SendMsg(2134, column, 0);
963 }
964
965 // Get the highlighted indentation guide column.
966 int wxStyledTextCtrl::GetHighlightGuide() {
967 return SendMsg(2135, 0, 0);
968 }
969
970 // Get the position after the last visible characters on a line.
971 int wxStyledTextCtrl::GetLineEndPosition(int line) {
972 return SendMsg(2136, line, 0);
973 }
974
975 // Get the code page used to interpret the bytes of the document as characters.
976 int wxStyledTextCtrl::GetCodePage() {
977 return SendMsg(2137, 0, 0);
978 }
979
980 // Get the foreground colour of the caret.
981 wxColour wxStyledTextCtrl::GetCaretForeground() {
982 long c = SendMsg(2138, 0, 0);
983 return wxColourFromLong(c);
984 }
985
986 // In read-only mode?
987 bool wxStyledTextCtrl::GetReadOnly() {
988 return SendMsg(2140, 0, 0) != 0;
989 }
990
991 // Sets the position of the caret.
992 void wxStyledTextCtrl::SetCurrentPos(int pos) {
993 SendMsg(2141, pos, 0);
994 }
995
996 // Sets the position that starts the selection - this becomes the anchor.
997 void wxStyledTextCtrl::SetSelectionStart(int pos) {
998 SendMsg(2142, pos, 0);
999 }
1000
1001 // Returns the position at the start of the selection.
1002 int wxStyledTextCtrl::GetSelectionStart() {
1003 return SendMsg(2143, 0, 0);
1004 }
1005
1006 // Sets the position that ends the selection - this becomes the currentPosition.
1007 void wxStyledTextCtrl::SetSelectionEnd(int pos) {
1008 SendMsg(2144, pos, 0);
1009 }
1010
1011 // Returns the position at the end of the selection.
1012 int wxStyledTextCtrl::GetSelectionEnd() {
1013 return SendMsg(2145, 0, 0);
1014 }
1015
1016 // Sets the print magnification added to the point size of each style for printing.
1017 void wxStyledTextCtrl::SetPrintMagnification(int magnification) {
1018 SendMsg(2146, magnification, 0);
1019 }
1020
1021 // Returns the print magnification.
1022 int wxStyledTextCtrl::GetPrintMagnification() {
1023 return SendMsg(2147, 0, 0);
1024 }
1025
1026 // Modify colours when printing for clearer printed text.
1027 void wxStyledTextCtrl::SetPrintColourMode(int mode) {
1028 SendMsg(2148, mode, 0);
1029 }
1030
1031 // Returns the print colour mode.
1032 int wxStyledTextCtrl::GetPrintColourMode() {
1033 return SendMsg(2149, 0, 0);
1034 }
1035
1036 // Find some text in the document.
1037 int wxStyledTextCtrl::FindText(int minPos, int maxPos,
1038 const wxString& text,
1039 int flags) {
1040 TextToFind ft;
1041 ft.chrg.cpMin = minPos;
1042 ft.chrg.cpMax = maxPos;
1043 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1044 ft.lpstrText = (char*)(const char*)buf;
1045
1046 return SendMsg(2150, flags, (long)&ft);
1047 }
1048
1049 // On Windows, will draw the document into a display context such as a printer.
1050 int wxStyledTextCtrl::FormatRange(bool doDraw,
1051 int startPos,
1052 int endPos,
1053 wxDC* draw,
1054 wxDC* target,
1055 wxRect renderRect,
1056 wxRect pageRect) {
1057 RangeToFormat fr;
1058
1059 if (endPos < startPos) {
1060 int temp = startPos;
1061 startPos = endPos;
1062 endPos = temp;
1063 }
1064 fr.hdc = draw;
1065 fr.hdcTarget = target;
1066 fr.rc.top = renderRect.GetTop();
1067 fr.rc.left = renderRect.GetLeft();
1068 fr.rc.right = renderRect.GetRight();
1069 fr.rc.bottom = renderRect.GetBottom();
1070 fr.rcPage.top = pageRect.GetTop();
1071 fr.rcPage.left = pageRect.GetLeft();
1072 fr.rcPage.right = pageRect.GetRight();
1073 fr.rcPage.bottom = pageRect.GetBottom();
1074 fr.chrg.cpMin = startPos;
1075 fr.chrg.cpMax = endPos;
1076
1077 return SendMsg(2151, doDraw, (long)&fr);
1078 }
1079
1080 // Retrieve the display line at the top of the display.
1081 int wxStyledTextCtrl::GetFirstVisibleLine() {
1082 return SendMsg(2152, 0, 0);
1083 }
1084
1085 // Retrieve the contents of a line.
1086 wxString wxStyledTextCtrl::GetLine(int line) {
1087 int len = LineLength(line);
1088 if (!len) return wxEmptyString;
1089
1090 wxMemoryBuffer mbuf(len+1);
1091 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1092 SendMsg(2153, line, (long)buf);
1093 mbuf.UngetWriteBuf(len);
1094 mbuf.AppendByte(0);
1095 return stc2wx(buf);
1096 }
1097
1098 // Returns the number of lines in the document. There is always at least one.
1099 int wxStyledTextCtrl::GetLineCount() {
1100 return SendMsg(2154, 0, 0);
1101 }
1102
1103 // Sets the size in pixels of the left margin.
1104 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) {
1105 SendMsg(2155, 0, pixelWidth);
1106 }
1107
1108 // Returns the size in pixels of the left margin.
1109 int wxStyledTextCtrl::GetMarginLeft() {
1110 return SendMsg(2156, 0, 0);
1111 }
1112
1113 // Sets the size in pixels of the right margin.
1114 void wxStyledTextCtrl::SetMarginRight(int pixelWidth) {
1115 SendMsg(2157, 0, pixelWidth);
1116 }
1117
1118 // Returns the size in pixels of the right margin.
1119 int wxStyledTextCtrl::GetMarginRight() {
1120 return SendMsg(2158, 0, 0);
1121 }
1122
1123 // Is the document different from when it was last saved?
1124 bool wxStyledTextCtrl::GetModify() {
1125 return SendMsg(2159, 0, 0) != 0;
1126 }
1127
1128 // Select a range of text.
1129 void wxStyledTextCtrl::SetSelection(int start, int end) {
1130 SendMsg(2160, start, end);
1131 }
1132
1133 // Retrieve the selected text.
1134 wxString wxStyledTextCtrl::GetSelectedText() {
1135 int start;
1136 int end;
1137
1138 GetSelection(&start, &end);
1139 int len = end - start;
1140 if (!len) return wxEmptyString;
1141
1142 wxMemoryBuffer mbuf(len+2);
1143 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1144 SendMsg(2161, 0, (long)buf);
1145 mbuf.UngetWriteBuf(len);
1146 mbuf.AppendByte(0);
1147 return stc2wx(buf);
1148 }
1149
1150 // Retrieve a range of text.
1151 wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1152 if (endPos < startPos) {
1153 int temp = startPos;
1154 startPos = endPos;
1155 endPos = temp;
1156 }
1157 int len = endPos - startPos;
1158 if (!len) return wxEmptyString;
1159 wxMemoryBuffer mbuf(len+1);
1160 char* buf = (char*)mbuf.GetWriteBuf(len);
1161 TextRange tr;
1162 tr.lpstrText = buf;
1163 tr.chrg.cpMin = startPos;
1164 tr.chrg.cpMax = endPos;
1165 SendMsg(2162, 0, (long)&tr);
1166 mbuf.UngetWriteBuf(len);
1167 mbuf.AppendByte(0);
1168 return stc2wx(buf);
1169 }
1170
1171 // Draw the selection in normal style or with selection highlighted.
1172 void wxStyledTextCtrl::HideSelection(bool normal) {
1173 SendMsg(2163, normal, 0);
1174 }
1175
1176 // Retrieve the line containing a position.
1177 int wxStyledTextCtrl::LineFromPosition(int pos) {
1178 return SendMsg(2166, pos, 0);
1179 }
1180
1181 // Retrieve the position at the start of a line.
1182 int wxStyledTextCtrl::PositionFromLine(int line) {
1183 return SendMsg(2167, line, 0);
1184 }
1185
1186 // Scroll horizontally and vertically.
1187 void wxStyledTextCtrl::LineScroll(int columns, int lines) {
1188 SendMsg(2168, columns, lines);
1189 }
1190
1191 // Ensure the caret is visible.
1192 void wxStyledTextCtrl::EnsureCaretVisible() {
1193 SendMsg(2169, 0, 0);
1194 }
1195
1196 // Replace the selected text with the argument text.
1197 void wxStyledTextCtrl::ReplaceSelection(const wxString& text) {
1198 SendMsg(2170, 0, (long)(const char*)wx2stc(text));
1199 }
1200
1201 // Set to read only or read write.
1202 void wxStyledTextCtrl::SetReadOnly(bool readOnly) {
1203 SendMsg(2171, readOnly, 0);
1204 }
1205
1206 // Will a paste succeed?
1207 bool wxStyledTextCtrl::CanPaste() {
1208 return SendMsg(2173, 0, 0) != 0;
1209 }
1210
1211 // Are there any undoable actions in the undo history?
1212 bool wxStyledTextCtrl::CanUndo() {
1213 return SendMsg(2174, 0, 0) != 0;
1214 }
1215
1216 // Delete the undo history.
1217 void wxStyledTextCtrl::EmptyUndoBuffer() {
1218 SendMsg(2175, 0, 0);
1219 }
1220
1221 // Undo one action in the undo history.
1222 void wxStyledTextCtrl::Undo() {
1223 SendMsg(2176, 0, 0);
1224 }
1225
1226 // Cut the selection to the clipboard.
1227 void wxStyledTextCtrl::Cut() {
1228 SendMsg(2177, 0, 0);
1229 }
1230
1231 // Copy the selection to the clipboard.
1232 void wxStyledTextCtrl::Copy() {
1233 SendMsg(2178, 0, 0);
1234 }
1235
1236 // Paste the contents of the clipboard into the document replacing the selection.
1237 void wxStyledTextCtrl::Paste() {
1238 SendMsg(2179, 0, 0);
1239 }
1240
1241 // Clear the selection.
1242 void wxStyledTextCtrl::Clear() {
1243 SendMsg(2180, 0, 0);
1244 }
1245
1246 // Replace the contents of the document with the argument text.
1247 void wxStyledTextCtrl::SetText(const wxString& text) {
1248 SendMsg(2181, 0, (long)(const char*)wx2stc(text));
1249 }
1250
1251 // Retrieve all the text in the document.
1252 wxString wxStyledTextCtrl::GetText() {
1253 int len = GetTextLength();
1254 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1255 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1256 SendMsg(2182, len+1, (long)buf);
1257 mbuf.UngetWriteBuf(len);
1258 mbuf.AppendByte(0);
1259 return stc2wx(buf);
1260 }
1261
1262 // Retrieve the number of characters in the document.
1263 int wxStyledTextCtrl::GetTextLength() {
1264 return SendMsg(2183, 0, 0);
1265 }
1266
1267 // Set to overtype (true) or insert mode.
1268 void wxStyledTextCtrl::SetOvertype(bool overtype) {
1269 SendMsg(2186, overtype, 0);
1270 }
1271
1272 // Returns true if overtype mode is active otherwise false is returned.
1273 bool wxStyledTextCtrl::GetOvertype() {
1274 return SendMsg(2187, 0, 0) != 0;
1275 }
1276
1277 // Set the width of the insert mode caret.
1278 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) {
1279 SendMsg(2188, pixelWidth, 0);
1280 }
1281
1282 // Returns the width of the insert mode caret.
1283 int wxStyledTextCtrl::GetCaretWidth() {
1284 return SendMsg(2189, 0, 0);
1285 }
1286
1287 // Sets the position that starts the target which is used for updating the
1288 // document without affecting the scroll position.
1289 void wxStyledTextCtrl::SetTargetStart(int pos) {
1290 SendMsg(2190, pos, 0);
1291 }
1292
1293 // Get the position that starts the target.
1294 int wxStyledTextCtrl::GetTargetStart() {
1295 return SendMsg(2191, 0, 0);
1296 }
1297
1298 // Sets the position that ends the target which is used for updating the
1299 // document without affecting the scroll position.
1300 void wxStyledTextCtrl::SetTargetEnd(int pos) {
1301 SendMsg(2192, pos, 0);
1302 }
1303
1304 // Get the position that ends the target.
1305 int wxStyledTextCtrl::GetTargetEnd() {
1306 return SendMsg(2193, 0, 0);
1307 }
1308
1309 // Replace the target text with the argument text.
1310 // Text is counted so it can contain NULs.
1311 // Returns the length of the replacement text.
1312
1313 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1314 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1315 return SendMsg(2194, strlen(buf), (long)(const char*)buf);
1316 }
1317
1318 // Replace the target text with the argument text after \d processing.
1319 // Text is counted so it can contain NULs.
1320 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1321 // matched in the last search operation which were surrounded by \( and \).
1322 // Returns the length of the replacement text including any change
1323 // caused by processing the \d patterns.
1324
1325 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1326 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1327 return SendMsg(2195, strlen(buf), (long)(const char*)buf);
1328 }
1329
1330 // Search for a counted string in the target and set the target to the found
1331 // range. Text is counted so it can contain NULs.
1332 // Returns length of range or -1 for failure in which case target is not moved.
1333
1334 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1335 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1336 return SendMsg(2197, strlen(buf), (long)(const char*)buf);
1337 }
1338
1339 // Set the search flags used by SearchInTarget.
1340 void wxStyledTextCtrl::SetSearchFlags(int flags) {
1341 SendMsg(2198, flags, 0);
1342 }
1343
1344 // Get the search flags used by SearchInTarget.
1345 int wxStyledTextCtrl::GetSearchFlags() {
1346 return SendMsg(2199, 0, 0);
1347 }
1348
1349 // Show a call tip containing a definition near position pos.
1350 void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) {
1351 SendMsg(2200, pos, (long)(const char*)wx2stc(definition));
1352 }
1353
1354 // Remove the call tip from the screen.
1355 void wxStyledTextCtrl::CallTipCancel() {
1356 SendMsg(2201, 0, 0);
1357 }
1358
1359 // Is there an active call tip?
1360 bool wxStyledTextCtrl::CallTipActive() {
1361 return SendMsg(2202, 0, 0) != 0;
1362 }
1363
1364 // Retrieve the position where the caret was before displaying the call tip.
1365 int wxStyledTextCtrl::CallTipPosAtStart() {
1366 return SendMsg(2203, 0, 0);
1367 }
1368
1369 // Highlight a segment of the definition.
1370 void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) {
1371 SendMsg(2204, start, end);
1372 }
1373
1374 // Set the background colour for the call tip.
1375 void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) {
1376 SendMsg(2205, wxColourAsLong(back), 0);
1377 }
1378
1379 // Set the foreground colour for the call tip.
1380 void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore) {
1381 SendMsg(2206, wxColourAsLong(fore), 0);
1382 }
1383
1384 // Set the foreground colour for the highlighted part of the call tip.
1385 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) {
1386 SendMsg(2207, wxColourAsLong(fore), 0);
1387 }
1388
1389 // Find the display line of a document line taking hidden lines into account.
1390 int wxStyledTextCtrl::VisibleFromDocLine(int line) {
1391 return SendMsg(2220, line, 0);
1392 }
1393
1394 // Find the document line of a display line taking hidden lines into account.
1395 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) {
1396 return SendMsg(2221, lineDisplay, 0);
1397 }
1398
1399 // Set the fold level of a line.
1400 // This encodes an integer level along with flags indicating whether the
1401 // line is a header and whether it is effectively white space.
1402 void wxStyledTextCtrl::SetFoldLevel(int line, int level) {
1403 SendMsg(2222, line, level);
1404 }
1405
1406 // Retrieve the fold level of a line.
1407 int wxStyledTextCtrl::GetFoldLevel(int line) {
1408 return SendMsg(2223, line, 0);
1409 }
1410
1411 // Find the last child line of a header line.
1412 int wxStyledTextCtrl::GetLastChild(int line, int level) {
1413 return SendMsg(2224, line, level);
1414 }
1415
1416 // Find the parent line of a child line.
1417 int wxStyledTextCtrl::GetFoldParent(int line) {
1418 return SendMsg(2225, line, 0);
1419 }
1420
1421 // Make a range of lines visible.
1422 void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) {
1423 SendMsg(2226, lineStart, lineEnd);
1424 }
1425
1426 // Make a range of lines invisible.
1427 void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) {
1428 SendMsg(2227, lineStart, lineEnd);
1429 }
1430
1431 // Is a line visible?
1432 bool wxStyledTextCtrl::GetLineVisible(int line) {
1433 return SendMsg(2228, line, 0) != 0;
1434 }
1435
1436 // Show the children of a header line.
1437 void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) {
1438 SendMsg(2229, line, expanded);
1439 }
1440
1441 // Is a header line expanded?
1442 bool wxStyledTextCtrl::GetFoldExpanded(int line) {
1443 return SendMsg(2230, line, 0) != 0;
1444 }
1445
1446 // Switch a header line between expanded and contracted.
1447 void wxStyledTextCtrl::ToggleFold(int line) {
1448 SendMsg(2231, line, 0);
1449 }
1450
1451 // Ensure a particular line is visible by expanding any header line hiding it.
1452 void wxStyledTextCtrl::EnsureVisible(int line) {
1453 SendMsg(2232, line, 0);
1454 }
1455
1456 // Set some style options for folding.
1457 void wxStyledTextCtrl::SetFoldFlags(int flags) {
1458 SendMsg(2233, flags, 0);
1459 }
1460
1461 // Ensure a particular line is visible by expanding any header line hiding it.
1462 // Use the currently set visibility policy to determine which range to display.
1463 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) {
1464 SendMsg(2234, line, 0);
1465 }
1466
1467 // Sets whether a tab pressed when caret is within indentation indents.
1468 void wxStyledTextCtrl::SetTabIndents(bool tabIndents) {
1469 SendMsg(2260, tabIndents, 0);
1470 }
1471
1472 // Does a tab pressed when caret is within indentation indent?
1473 bool wxStyledTextCtrl::GetTabIndents() {
1474 return SendMsg(2261, 0, 0) != 0;
1475 }
1476
1477 // Sets whether a backspace pressed when caret is within indentation unindents.
1478 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) {
1479 SendMsg(2262, bsUnIndents, 0);
1480 }
1481
1482 // Does a backspace pressed when caret is within indentation unindent?
1483 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1484 return SendMsg(2263, 0, 0) != 0;
1485 }
1486
1487 // Sets the time the mouse must sit still to generate a mouse dwell event.
1488 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) {
1489 SendMsg(2264, periodMilliseconds, 0);
1490 }
1491
1492 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1493 int wxStyledTextCtrl::GetMouseDwellTime() {
1494 return SendMsg(2265, 0, 0);
1495 }
1496
1497 // Get position of start of word.
1498 int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) {
1499 return SendMsg(2266, pos, onlyWordCharacters);
1500 }
1501
1502 // Get position of end of word.
1503 int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) {
1504 return SendMsg(2267, pos, onlyWordCharacters);
1505 }
1506
1507 // Sets whether text is word wrapped.
1508 void wxStyledTextCtrl::SetWrapMode(int mode) {
1509 SendMsg(2268, mode, 0);
1510 }
1511
1512 // Retrieve whether text is word wrapped.
1513 int wxStyledTextCtrl::GetWrapMode() {
1514 return SendMsg(2269, 0, 0);
1515 }
1516
1517 // Set the display mode of visual flags for wrapped lines.
1518 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags) {
1519 SendMsg(2460, wrapVisualFlags, 0);
1520 }
1521
1522 // Retrive the display mode of visual flags for wrapped lines.
1523 int wxStyledTextCtrl::GetWrapVisualFlags() {
1524 return SendMsg(2461, 0, 0);
1525 }
1526
1527 // Set the location of visual flags for wrapped lines.
1528 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation) {
1529 SendMsg(2462, wrapVisualFlagsLocation, 0);
1530 }
1531
1532 // Retrive the location of visual flags for wrapped lines.
1533 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1534 return SendMsg(2463, 0, 0);
1535 }
1536
1537 // Set the start indent for wrapped lines.
1538 void wxStyledTextCtrl::SetWrapStartIndent(int indent) {
1539 SendMsg(2464, indent, 0);
1540 }
1541
1542 // Retrive the start indent for wrapped lines.
1543 int wxStyledTextCtrl::GetWrapStartIndent() {
1544 return SendMsg(2465, 0, 0);
1545 }
1546
1547 // Sets the degree of caching of layout information.
1548 void wxStyledTextCtrl::SetLayoutCache(int mode) {
1549 SendMsg(2272, mode, 0);
1550 }
1551
1552 // Retrieve the degree of caching of layout information.
1553 int wxStyledTextCtrl::GetLayoutCache() {
1554 return SendMsg(2273, 0, 0);
1555 }
1556
1557 // Sets the document width assumed for scrolling.
1558 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth) {
1559 SendMsg(2274, pixelWidth, 0);
1560 }
1561
1562 // Retrieve the document width assumed for scrolling.
1563 int wxStyledTextCtrl::GetScrollWidth() {
1564 return SendMsg(2275, 0, 0);
1565 }
1566
1567 // Measure the pixel width of some text in a particular style.
1568 // NUL terminated text argument.
1569 // Does not handle tab or control characters.
1570 int wxStyledTextCtrl::TextWidth(int style, const wxString& text) {
1571 return SendMsg(2276, style, (long)(const char*)wx2stc(text));
1572 }
1573
1574 // Sets the scroll range so that maximum scroll position has
1575 // the last line at the bottom of the view (default).
1576 // Setting this to false allows scrolling one page below the last line.
1577 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine) {
1578 SendMsg(2277, endAtLastLine, 0);
1579 }
1580
1581 // Retrieve whether the maximum scroll position has the last
1582 // line at the bottom of the view.
1583 int wxStyledTextCtrl::GetEndAtLastLine() {
1584 return SendMsg(2278, 0, 0);
1585 }
1586
1587 // Retrieve the height of a particular line of text in pixels.
1588 int wxStyledTextCtrl::TextHeight(int line) {
1589 return SendMsg(2279, line, 0);
1590 }
1591
1592 // Show or hide the vertical scroll bar.
1593 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show) {
1594 SendMsg(2280, show, 0);
1595 }
1596
1597 // Is the vertical scroll bar visible?
1598 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1599 return SendMsg(2281, 0, 0) != 0;
1600 }
1601
1602 // Append a string to the end of the document without changing the selection.
1603 void wxStyledTextCtrl::AppendText(int length, const wxString& text) {
1604 SendMsg(2282, length, (long)(const char*)wx2stc(text));
1605 }
1606
1607 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1608 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1609 return SendMsg(2283, 0, 0) != 0;
1610 }
1611
1612 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1613 // and then the foreground. This avoids chopping off characters that overlap the next run.
1614 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) {
1615 SendMsg(2284, twoPhase, 0);
1616 }
1617
1618 // Make the target range start and end be the same as the selection range start and end.
1619 void wxStyledTextCtrl::TargetFromSelection() {
1620 SendMsg(2287, 0, 0);
1621 }
1622
1623 // Join the lines in the target.
1624 void wxStyledTextCtrl::LinesJoin() {
1625 SendMsg(2288, 0, 0);
1626 }
1627
1628 // Split the lines in the target into lines that are less wide than pixelWidth
1629 // where possible.
1630 void wxStyledTextCtrl::LinesSplit(int pixelWidth) {
1631 SendMsg(2289, pixelWidth, 0);
1632 }
1633
1634 // Set the colours used as a chequerboard pattern in the fold margin
1635 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) {
1636 SendMsg(2290, useSetting, wxColourAsLong(back));
1637 }
1638 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) {
1639 SendMsg(2291, useSetting, wxColourAsLong(fore));
1640 }
1641
1642 // Move caret down one line.
1643 void wxStyledTextCtrl::LineDown() {
1644 SendMsg(2300, 0, 0);
1645 }
1646
1647 // Move caret down one line extending selection to new caret position.
1648 void wxStyledTextCtrl::LineDownExtend() {
1649 SendMsg(2301, 0, 0);
1650 }
1651
1652 // Move caret up one line.
1653 void wxStyledTextCtrl::LineUp() {
1654 SendMsg(2302, 0, 0);
1655 }
1656
1657 // Move caret up one line extending selection to new caret position.
1658 void wxStyledTextCtrl::LineUpExtend() {
1659 SendMsg(2303, 0, 0);
1660 }
1661
1662 // Move caret left one character.
1663 void wxStyledTextCtrl::CharLeft() {
1664 SendMsg(2304, 0, 0);
1665 }
1666
1667 // Move caret left one character extending selection to new caret position.
1668 void wxStyledTextCtrl::CharLeftExtend() {
1669 SendMsg(2305, 0, 0);
1670 }
1671
1672 // Move caret right one character.
1673 void wxStyledTextCtrl::CharRight() {
1674 SendMsg(2306, 0, 0);
1675 }
1676
1677 // Move caret right one character extending selection to new caret position.
1678 void wxStyledTextCtrl::CharRightExtend() {
1679 SendMsg(2307, 0, 0);
1680 }
1681
1682 // Move caret left one word.
1683 void wxStyledTextCtrl::WordLeft() {
1684 SendMsg(2308, 0, 0);
1685 }
1686
1687 // Move caret left one word extending selection to new caret position.
1688 void wxStyledTextCtrl::WordLeftExtend() {
1689 SendMsg(2309, 0, 0);
1690 }
1691
1692 // Move caret right one word.
1693 void wxStyledTextCtrl::WordRight() {
1694 SendMsg(2310, 0, 0);
1695 }
1696
1697 // Move caret right one word extending selection to new caret position.
1698 void wxStyledTextCtrl::WordRightExtend() {
1699 SendMsg(2311, 0, 0);
1700 }
1701
1702 // Move caret to first position on line.
1703 void wxStyledTextCtrl::Home() {
1704 SendMsg(2312, 0, 0);
1705 }
1706
1707 // Move caret to first position on line extending selection to new caret position.
1708 void wxStyledTextCtrl::HomeExtend() {
1709 SendMsg(2313, 0, 0);
1710 }
1711
1712 // Move caret to last position on line.
1713 void wxStyledTextCtrl::LineEnd() {
1714 SendMsg(2314, 0, 0);
1715 }
1716
1717 // Move caret to last position on line extending selection to new caret position.
1718 void wxStyledTextCtrl::LineEndExtend() {
1719 SendMsg(2315, 0, 0);
1720 }
1721
1722 // Move caret to first position in document.
1723 void wxStyledTextCtrl::DocumentStart() {
1724 SendMsg(2316, 0, 0);
1725 }
1726
1727 // Move caret to first position in document extending selection to new caret position.
1728 void wxStyledTextCtrl::DocumentStartExtend() {
1729 SendMsg(2317, 0, 0);
1730 }
1731
1732 // Move caret to last position in document.
1733 void wxStyledTextCtrl::DocumentEnd() {
1734 SendMsg(2318, 0, 0);
1735 }
1736
1737 // Move caret to last position in document extending selection to new caret position.
1738 void wxStyledTextCtrl::DocumentEndExtend() {
1739 SendMsg(2319, 0, 0);
1740 }
1741
1742 // Move caret one page up.
1743 void wxStyledTextCtrl::PageUp() {
1744 SendMsg(2320, 0, 0);
1745 }
1746
1747 // Move caret one page up extending selection to new caret position.
1748 void wxStyledTextCtrl::PageUpExtend() {
1749 SendMsg(2321, 0, 0);
1750 }
1751
1752 // Move caret one page down.
1753 void wxStyledTextCtrl::PageDown() {
1754 SendMsg(2322, 0, 0);
1755 }
1756
1757 // Move caret one page down extending selection to new caret position.
1758 void wxStyledTextCtrl::PageDownExtend() {
1759 SendMsg(2323, 0, 0);
1760 }
1761
1762 // Switch from insert to overtype mode or the reverse.
1763 void wxStyledTextCtrl::EditToggleOvertype() {
1764 SendMsg(2324, 0, 0);
1765 }
1766
1767 // Cancel any modes such as call tip or auto-completion list display.
1768 void wxStyledTextCtrl::Cancel() {
1769 SendMsg(2325, 0, 0);
1770 }
1771
1772 // Delete the selection or if no selection, the character before the caret.
1773 void wxStyledTextCtrl::DeleteBack() {
1774 SendMsg(2326, 0, 0);
1775 }
1776
1777 // If selection is empty or all on one line replace the selection with a tab character.
1778 // If more than one line selected, indent the lines.
1779 void wxStyledTextCtrl::Tab() {
1780 SendMsg(2327, 0, 0);
1781 }
1782
1783 // Dedent the selected lines.
1784 void wxStyledTextCtrl::BackTab() {
1785 SendMsg(2328, 0, 0);
1786 }
1787
1788 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1789 void wxStyledTextCtrl::NewLine() {
1790 SendMsg(2329, 0, 0);
1791 }
1792
1793 // Insert a Form Feed character.
1794 void wxStyledTextCtrl::FormFeed() {
1795 SendMsg(2330, 0, 0);
1796 }
1797
1798 // Move caret to before first visible character on line.
1799 // If already there move to first character on line.
1800 void wxStyledTextCtrl::VCHome() {
1801 SendMsg(2331, 0, 0);
1802 }
1803
1804 // Like VCHome but extending selection to new caret position.
1805 void wxStyledTextCtrl::VCHomeExtend() {
1806 SendMsg(2332, 0, 0);
1807 }
1808
1809 // Magnify the displayed text by increasing the sizes by 1 point.
1810 void wxStyledTextCtrl::ZoomIn() {
1811 SendMsg(2333, 0, 0);
1812 }
1813
1814 // Make the displayed text smaller by decreasing the sizes by 1 point.
1815 void wxStyledTextCtrl::ZoomOut() {
1816 SendMsg(2334, 0, 0);
1817 }
1818
1819 // Delete the word to the left of the caret.
1820 void wxStyledTextCtrl::DelWordLeft() {
1821 SendMsg(2335, 0, 0);
1822 }
1823
1824 // Delete the word to the right of the caret.
1825 void wxStyledTextCtrl::DelWordRight() {
1826 SendMsg(2336, 0, 0);
1827 }
1828
1829 // Cut the line containing the caret.
1830 void wxStyledTextCtrl::LineCut() {
1831 SendMsg(2337, 0, 0);
1832 }
1833
1834 // Delete the line containing the caret.
1835 void wxStyledTextCtrl::LineDelete() {
1836 SendMsg(2338, 0, 0);
1837 }
1838
1839 // Switch the current line with the previous.
1840 void wxStyledTextCtrl::LineTranspose() {
1841 SendMsg(2339, 0, 0);
1842 }
1843
1844 // Duplicate the current line.
1845 void wxStyledTextCtrl::LineDuplicate() {
1846 SendMsg(2404, 0, 0);
1847 }
1848
1849 // Transform the selection to lower case.
1850 void wxStyledTextCtrl::LowerCase() {
1851 SendMsg(2340, 0, 0);
1852 }
1853
1854 // Transform the selection to upper case.
1855 void wxStyledTextCtrl::UpperCase() {
1856 SendMsg(2341, 0, 0);
1857 }
1858
1859 // Scroll the document down, keeping the caret visible.
1860 void wxStyledTextCtrl::LineScrollDown() {
1861 SendMsg(2342, 0, 0);
1862 }
1863
1864 // Scroll the document up, keeping the caret visible.
1865 void wxStyledTextCtrl::LineScrollUp() {
1866 SendMsg(2343, 0, 0);
1867 }
1868
1869 // Delete the selection or if no selection, the character before the caret.
1870 // Will not delete the character before at the start of a line.
1871 void wxStyledTextCtrl::DeleteBackNotLine() {
1872 SendMsg(2344, 0, 0);
1873 }
1874
1875 // Move caret to first position on display line.
1876 void wxStyledTextCtrl::HomeDisplay() {
1877 SendMsg(2345, 0, 0);
1878 }
1879
1880 // Move caret to first position on display line extending selection to
1881 // new caret position.
1882 void wxStyledTextCtrl::HomeDisplayExtend() {
1883 SendMsg(2346, 0, 0);
1884 }
1885
1886 // Move caret to last position on display line.
1887 void wxStyledTextCtrl::LineEndDisplay() {
1888 SendMsg(2347, 0, 0);
1889 }
1890
1891 // Move caret to last position on display line extending selection to new
1892 // caret position.
1893 void wxStyledTextCtrl::LineEndDisplayExtend() {
1894 SendMsg(2348, 0, 0);
1895 }
1896
1897 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1898 // except they behave differently when word-wrap is enabled:
1899 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1900 // The difference is that, the cursor is already at the point, it goes on to the start
1901 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1902 void wxStyledTextCtrl::HomeWrap() {
1903 SendMsg(2349, 0, 0);
1904 }
1905 void wxStyledTextCtrl::HomeWrapExtend() {
1906 SendMsg(2450, 0, 0);
1907 }
1908 void wxStyledTextCtrl::LineEndWrap() {
1909 SendMsg(2451, 0, 0);
1910 }
1911 void wxStyledTextCtrl::LineEndWrapExtend() {
1912 SendMsg(2452, 0, 0);
1913 }
1914 void wxStyledTextCtrl::VCHomeWrap() {
1915 SendMsg(2453, 0, 0);
1916 }
1917 void wxStyledTextCtrl::VCHomeWrapExtend() {
1918 SendMsg(2454, 0, 0);
1919 }
1920
1921 // Copy the line containing the caret.
1922 void wxStyledTextCtrl::LineCopy() {
1923 SendMsg(2455, 0, 0);
1924 }
1925
1926 // Move the caret inside current view if it's not there already.
1927 void wxStyledTextCtrl::MoveCaretInsideView() {
1928 SendMsg(2401, 0, 0);
1929 }
1930
1931 // How many characters are on a line, not including end of line characters?
1932 int wxStyledTextCtrl::LineLength(int line) {
1933 return SendMsg(2350, line, 0);
1934 }
1935
1936 // Highlight the characters at two positions.
1937 void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) {
1938 SendMsg(2351, pos1, pos2);
1939 }
1940
1941 // Highlight the character at a position indicating there is no matching brace.
1942 void wxStyledTextCtrl::BraceBadLight(int pos) {
1943 SendMsg(2352, pos, 0);
1944 }
1945
1946 // Find the position of a matching brace or INVALID_POSITION if no match.
1947 int wxStyledTextCtrl::BraceMatch(int pos) {
1948 return SendMsg(2353, pos, 0);
1949 }
1950
1951 // Are the end of line characters visible?
1952 bool wxStyledTextCtrl::GetViewEOL() {
1953 return SendMsg(2355, 0, 0) != 0;
1954 }
1955
1956 // Make the end of line characters visible or invisible.
1957 void wxStyledTextCtrl::SetViewEOL(bool visible) {
1958 SendMsg(2356, visible, 0);
1959 }
1960
1961 // Retrieve a pointer to the document object.
1962 void* wxStyledTextCtrl::GetDocPointer() {
1963 return (void*)SendMsg(2357);
1964 }
1965
1966 // Change the document object used.
1967 void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
1968 SendMsg(2358, 0, (long)docPointer);
1969 }
1970
1971 // Set which document modification events are sent to the container.
1972 void wxStyledTextCtrl::SetModEventMask(int mask) {
1973 SendMsg(2359, mask, 0);
1974 }
1975
1976 // Retrieve the column number which text should be kept within.
1977 int wxStyledTextCtrl::GetEdgeColumn() {
1978 return SendMsg(2360, 0, 0);
1979 }
1980
1981 // Set the column number of the edge.
1982 // If text goes past the edge then it is highlighted.
1983 void wxStyledTextCtrl::SetEdgeColumn(int column) {
1984 SendMsg(2361, column, 0);
1985 }
1986
1987 // Retrieve the edge highlight mode.
1988 int wxStyledTextCtrl::GetEdgeMode() {
1989 return SendMsg(2362, 0, 0);
1990 }
1991
1992 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1993 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1994 void wxStyledTextCtrl::SetEdgeMode(int mode) {
1995 SendMsg(2363, mode, 0);
1996 }
1997
1998 // Retrieve the colour used in edge indication.
1999 wxColour wxStyledTextCtrl::GetEdgeColour() {
2000 long c = SendMsg(2364, 0, 0);
2001 return wxColourFromLong(c);
2002 }
2003
2004 // Change the colour used in edge indication.
2005 void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) {
2006 SendMsg(2365, wxColourAsLong(edgeColour), 0);
2007 }
2008
2009 // Sets the current caret position to be the search anchor.
2010 void wxStyledTextCtrl::SearchAnchor() {
2011 SendMsg(2366, 0, 0);
2012 }
2013
2014 // Find some text starting at the search anchor.
2015 // Does not ensure the selection is visible.
2016 int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) {
2017 return SendMsg(2367, flags, (long)(const char*)wx2stc(text));
2018 }
2019
2020 // Find some text starting at the search anchor and moving backwards.
2021 // Does not ensure the selection is visible.
2022 int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) {
2023 return SendMsg(2368, flags, (long)(const char*)wx2stc(text));
2024 }
2025
2026 // Retrieves the number of lines completely visible.
2027 int wxStyledTextCtrl::LinesOnScreen() {
2028 return SendMsg(2370, 0, 0);
2029 }
2030
2031 // Set whether a pop up menu is displayed automatically when the user presses
2032 // the wrong mouse button.
2033 void wxStyledTextCtrl::UsePopUp(bool allowPopUp) {
2034 SendMsg(2371, allowPopUp, 0);
2035 }
2036
2037 // Is the selection rectangular? The alternative is the more common stream selection.
2038 bool wxStyledTextCtrl::SelectionIsRectangle() {
2039 return SendMsg(2372, 0, 0) != 0;
2040 }
2041
2042 // Set the zoom level. This number of points is added to the size of all fonts.
2043 // It may be positive to magnify or negative to reduce.
2044 void wxStyledTextCtrl::SetZoom(int zoom) {
2045 SendMsg(2373, zoom, 0);
2046 }
2047
2048 // Retrieve the zoom level.
2049 int wxStyledTextCtrl::GetZoom() {
2050 return SendMsg(2374, 0, 0);
2051 }
2052
2053 // Create a new document object.
2054 // Starts with reference count of 1 and not selected into editor.
2055 void* wxStyledTextCtrl::CreateDocument() {
2056 return (void*)SendMsg(2375);
2057 }
2058
2059 // Extend life of document.
2060 void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
2061 SendMsg(2376, 0, (long)docPointer);
2062 }
2063
2064 // Release a reference to the document, deleting document if it fades to black.
2065 void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
2066 SendMsg(2377, 0, (long)docPointer);
2067 }
2068
2069 // Get which document modification events are sent to the container.
2070 int wxStyledTextCtrl::GetModEventMask() {
2071 return SendMsg(2378, 0, 0);
2072 }
2073
2074 // Change internal focus flag.
2075 void wxStyledTextCtrl::SetSTCFocus(bool focus) {
2076 SendMsg(2380, focus, 0);
2077 }
2078
2079 // Get internal focus flag.
2080 bool wxStyledTextCtrl::GetSTCFocus() {
2081 return SendMsg(2381, 0, 0) != 0;
2082 }
2083
2084 // Change error status - 0 = OK.
2085 void wxStyledTextCtrl::SetStatus(int statusCode) {
2086 SendMsg(2382, statusCode, 0);
2087 }
2088
2089 // Get error status.
2090 int wxStyledTextCtrl::GetStatus() {
2091 return SendMsg(2383, 0, 0);
2092 }
2093
2094 // Set whether the mouse is captured when its button is pressed.
2095 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) {
2096 SendMsg(2384, captures, 0);
2097 }
2098
2099 // Get whether mouse gets captured.
2100 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2101 return SendMsg(2385, 0, 0) != 0;
2102 }
2103
2104 // Sets the cursor to one of the SC_CURSOR* values.
2105 void wxStyledTextCtrl::SetSTCCursor(int cursorType) {
2106 SendMsg(2386, cursorType, 0);
2107 }
2108
2109 // Get cursor type.
2110 int wxStyledTextCtrl::GetSTCCursor() {
2111 return SendMsg(2387, 0, 0);
2112 }
2113
2114 // Change the way control characters are displayed:
2115 // If symbol is < 32, keep the drawn way, else, use the given character.
2116 void wxStyledTextCtrl::SetControlCharSymbol(int symbol) {
2117 SendMsg(2388, symbol, 0);
2118 }
2119
2120 // Get the way control characters are displayed.
2121 int wxStyledTextCtrl::GetControlCharSymbol() {
2122 return SendMsg(2389, 0, 0);
2123 }
2124
2125 // Move to the previous change in capitalisation.
2126 void wxStyledTextCtrl::WordPartLeft() {
2127 SendMsg(2390, 0, 0);
2128 }
2129
2130 // Move to the previous change in capitalisation extending selection
2131 // to new caret position.
2132 void wxStyledTextCtrl::WordPartLeftExtend() {
2133 SendMsg(2391, 0, 0);
2134 }
2135
2136 // Move to the change next in capitalisation.
2137 void wxStyledTextCtrl::WordPartRight() {
2138 SendMsg(2392, 0, 0);
2139 }
2140
2141 // Move to the next change in capitalisation extending selection
2142 // to new caret position.
2143 void wxStyledTextCtrl::WordPartRightExtend() {
2144 SendMsg(2393, 0, 0);
2145 }
2146
2147 // Set the way the display area is determined when a particular line
2148 // is to be moved to by Find, FindNext, GotoLine, etc.
2149 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) {
2150 SendMsg(2394, visiblePolicy, visibleSlop);
2151 }
2152
2153 // Delete back from the current position to the start of the line.
2154 void wxStyledTextCtrl::DelLineLeft() {
2155 SendMsg(2395, 0, 0);
2156 }
2157
2158 // Delete forwards from the current position to the end of the line.
2159 void wxStyledTextCtrl::DelLineRight() {
2160 SendMsg(2396, 0, 0);
2161 }
2162
2163 // Get and Set the xOffset (ie, horizonal scroll position).
2164 void wxStyledTextCtrl::SetXOffset(int newOffset) {
2165 SendMsg(2397, newOffset, 0);
2166 }
2167 int wxStyledTextCtrl::GetXOffset() {
2168 return SendMsg(2398, 0, 0);
2169 }
2170
2171 // Set the last x chosen value to be the caret x position.
2172 void wxStyledTextCtrl::ChooseCaretX() {
2173 SendMsg(2399, 0, 0);
2174 }
2175
2176 // Set the way the caret is kept visible when going sideway.
2177 // The exclusion zone is given in pixels.
2178 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) {
2179 SendMsg(2402, caretPolicy, caretSlop);
2180 }
2181
2182 // Set the way the line the caret is on is kept visible.
2183 // The exclusion zone is given in lines.
2184 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) {
2185 SendMsg(2403, caretPolicy, caretSlop);
2186 }
2187
2188 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2189 void wxStyledTextCtrl::SetPrintWrapMode(int mode) {
2190 SendMsg(2406, mode, 0);
2191 }
2192
2193 // Is printing line wrapped?
2194 int wxStyledTextCtrl::GetPrintWrapMode() {
2195 return SendMsg(2407, 0, 0);
2196 }
2197
2198 // Set a fore colour for active hotspots.
2199 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) {
2200 SendMsg(2410, useSetting, wxColourAsLong(fore));
2201 }
2202
2203 // Set a back colour for active hotspots.
2204 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) {
2205 SendMsg(2411, useSetting, wxColourAsLong(back));
2206 }
2207
2208 // Enable / Disable underlining active hotspots.
2209 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) {
2210 SendMsg(2412, underline, 0);
2211 }
2212
2213 // Limit hotspots to single line so hotspots on two lines don't merge.
2214 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine) {
2215 SendMsg(2421, singleLine, 0);
2216 }
2217
2218 // Move caret between paragraphs (delimited by empty lines).
2219 void wxStyledTextCtrl::ParaDown() {
2220 SendMsg(2413, 0, 0);
2221 }
2222 void wxStyledTextCtrl::ParaDownExtend() {
2223 SendMsg(2414, 0, 0);
2224 }
2225 void wxStyledTextCtrl::ParaUp() {
2226 SendMsg(2415, 0, 0);
2227 }
2228 void wxStyledTextCtrl::ParaUpExtend() {
2229 SendMsg(2416, 0, 0);
2230 }
2231
2232 // Given a valid document position, return the previous position taking code
2233 // page into account. Returns 0 if passed 0.
2234 int wxStyledTextCtrl::PositionBefore(int pos) {
2235 return SendMsg(2417, pos, 0);
2236 }
2237
2238 // Given a valid document position, return the next position taking code
2239 // page into account. Maximum value returned is the last position in the document.
2240 int wxStyledTextCtrl::PositionAfter(int pos) {
2241 return SendMsg(2418, pos, 0);
2242 }
2243
2244 // Copy a range of text to the clipboard. Positions are clipped into the document.
2245 void wxStyledTextCtrl::CopyRange(int start, int end) {
2246 SendMsg(2419, start, end);
2247 }
2248
2249 // Copy argument text to the clipboard.
2250 void wxStyledTextCtrl::CopyText(int length, const wxString& text) {
2251 SendMsg(2420, length, (long)(const char*)wx2stc(text));
2252 }
2253
2254 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2255 // by lines (SC_SEL_LINES).
2256 void wxStyledTextCtrl::SetSelectionMode(int mode) {
2257 SendMsg(2422, mode, 0);
2258 }
2259
2260 // Get the mode of the current selection.
2261 int wxStyledTextCtrl::GetSelectionMode() {
2262 return SendMsg(2423, 0, 0);
2263 }
2264
2265 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2266 int wxStyledTextCtrl::GetLineSelStartPosition(int line) {
2267 return SendMsg(2424, line, 0);
2268 }
2269
2270 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2271 int wxStyledTextCtrl::GetLineSelEndPosition(int line) {
2272 return SendMsg(2425, line, 0);
2273 }
2274
2275 // Move caret down one line, extending rectangular selection to new caret position.
2276 void wxStyledTextCtrl::LineDownRectExtend() {
2277 SendMsg(2426, 0, 0);
2278 }
2279
2280 // Move caret up one line, extending rectangular selection to new caret position.
2281 void wxStyledTextCtrl::LineUpRectExtend() {
2282 SendMsg(2427, 0, 0);
2283 }
2284
2285 // Move caret left one character, extending rectangular selection to new caret position.
2286 void wxStyledTextCtrl::CharLeftRectExtend() {
2287 SendMsg(2428, 0, 0);
2288 }
2289
2290 // Move caret right one character, extending rectangular selection to new caret position.
2291 void wxStyledTextCtrl::CharRightRectExtend() {
2292 SendMsg(2429, 0, 0);
2293 }
2294
2295 // Move caret to first position on line, extending rectangular selection to new caret position.
2296 void wxStyledTextCtrl::HomeRectExtend() {
2297 SendMsg(2430, 0, 0);
2298 }
2299
2300 // Move caret to before first visible character on line.
2301 // If already there move to first character on line.
2302 // In either case, extend rectangular selection to new caret position.
2303 void wxStyledTextCtrl::VCHomeRectExtend() {
2304 SendMsg(2431, 0, 0);
2305 }
2306
2307 // Move caret to last position on line, extending rectangular selection to new caret position.
2308 void wxStyledTextCtrl::LineEndRectExtend() {
2309 SendMsg(2432, 0, 0);
2310 }
2311
2312 // Move caret one page up, extending rectangular selection to new caret position.
2313 void wxStyledTextCtrl::PageUpRectExtend() {
2314 SendMsg(2433, 0, 0);
2315 }
2316
2317 // Move caret one page down, extending rectangular selection to new caret position.
2318 void wxStyledTextCtrl::PageDownRectExtend() {
2319 SendMsg(2434, 0, 0);
2320 }
2321
2322 // Move caret to top of page, or one page up if already at top of page.
2323 void wxStyledTextCtrl::StutteredPageUp() {
2324 SendMsg(2435, 0, 0);
2325 }
2326
2327 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2328 void wxStyledTextCtrl::StutteredPageUpExtend() {
2329 SendMsg(2436, 0, 0);
2330 }
2331
2332 // Move caret to bottom of page, or one page down if already at bottom of page.
2333 void wxStyledTextCtrl::StutteredPageDown() {
2334 SendMsg(2437, 0, 0);
2335 }
2336
2337 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2338 void wxStyledTextCtrl::StutteredPageDownExtend() {
2339 SendMsg(2438, 0, 0);
2340 }
2341
2342 // Move caret left one word, position cursor at end of word.
2343 void wxStyledTextCtrl::WordLeftEnd() {
2344 SendMsg(2439, 0, 0);
2345 }
2346
2347 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2348 void wxStyledTextCtrl::WordLeftEndExtend() {
2349 SendMsg(2440, 0, 0);
2350 }
2351
2352 // Move caret right one word, position cursor at end of word.
2353 void wxStyledTextCtrl::WordRightEnd() {
2354 SendMsg(2441, 0, 0);
2355 }
2356
2357 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2358 void wxStyledTextCtrl::WordRightEndExtend() {
2359 SendMsg(2442, 0, 0);
2360 }
2361
2362 // Set the set of characters making up whitespace for when moving or selecting by word.
2363 // Should be called after SetWordChars.
2364 void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters) {
2365 SendMsg(2443, 0, (long)(const char*)wx2stc(characters));
2366 }
2367
2368 // Reset the set of characters for whitespace and word characters to the defaults.
2369 void wxStyledTextCtrl::SetCharsDefault() {
2370 SendMsg(2444, 0, 0);
2371 }
2372
2373 // Get currently selected item position in the auto-completion list
2374 int wxStyledTextCtrl::AutoCompGetCurrent() {
2375 return SendMsg(2445, 0, 0);
2376 }
2377
2378 // Enlarge the document to a particular size of text bytes.
2379 void wxStyledTextCtrl::Allocate(int bytes) {
2380 SendMsg(2446, bytes, 0);
2381 }
2382
2383 // Start notifying the container of all key presses and commands.
2384 void wxStyledTextCtrl::StartRecord() {
2385 SendMsg(3001, 0, 0);
2386 }
2387
2388 // Stop notifying the container of all key presses and commands.
2389 void wxStyledTextCtrl::StopRecord() {
2390 SendMsg(3002, 0, 0);
2391 }
2392
2393 // Set the lexing language of the document.
2394 void wxStyledTextCtrl::SetLexer(int lexer) {
2395 SendMsg(4001, lexer, 0);
2396 }
2397
2398 // Retrieve the lexing language of the document.
2399 int wxStyledTextCtrl::GetLexer() {
2400 return SendMsg(4002, 0, 0);
2401 }
2402
2403 // Colourise a segment of the document using the current lexing language.
2404 void wxStyledTextCtrl::Colourise(int start, int end) {
2405 SendMsg(4003, start, end);
2406 }
2407
2408 // Set up a value that may be used by a lexer for some optional feature.
2409 void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) {
2410 SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value));
2411 }
2412
2413 // Set up the key words used by the lexer.
2414 void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) {
2415 SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords));
2416 }
2417
2418 // Set the lexing language of the document based on string name.
2419 void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) {
2420 SendMsg(4006, 0, (long)(const char*)wx2stc(language));
2421 }
2422
2423 // END of generated section
2424 //----------------------------------------------------------------------
2425
2426
2427 // Returns the line number of the line with the caret.
2428 int wxStyledTextCtrl::GetCurrentLine() {
2429 int line = LineFromPosition(GetCurrentPos());
2430 return line;
2431 }
2432
2433
2434 // Extract style settings from a spec-string which is composed of one or
2435 // more of the following comma separated elements:
2436 //
2437 // bold turns on bold
2438 // italic turns on italics
2439 // fore:#RRGGBB sets the foreground colour
2440 // back:#RRGGBB sets the background colour
2441 // face:[facename] sets the font face name to use
2442 // size:[num] sets the font size in points
2443 // eol turns on eol filling
2444 // underline turns on underlining
2445 //
2446 void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
2447
2448 wxStringTokenizer tkz(spec, wxT(","));
2449 while (tkz.HasMoreTokens()) {
2450 wxString token = tkz.GetNextToken();
2451
2452 wxString option = token.BeforeFirst(':');
2453 wxString val = token.AfterFirst(':');
2454
2455 if (option == wxT("bold"))
2456 StyleSetBold(styleNum, true);
2457
2458 else if (option == wxT("italic"))
2459 StyleSetItalic(styleNum, true);
2460
2461 else if (option == wxT("underline"))
2462 StyleSetUnderline(styleNum, true);
2463
2464 else if (option == wxT("eol"))
2465 StyleSetEOLFilled(styleNum, true);
2466
2467 else if (option == wxT("size")) {
2468 long points;
2469 if (val.ToLong(&points))
2470 StyleSetSize(styleNum, points);
2471 }
2472
2473 else if (option == wxT("face"))
2474 StyleSetFaceName(styleNum, val);
2475
2476 else if (option == wxT("fore"))
2477 StyleSetForeground(styleNum, wxColourFromSpec(val));
2478
2479 else if (option == wxT("back"))
2480 StyleSetBackground(styleNum, wxColourFromSpec(val));
2481 }
2482 }
2483
2484
2485 // Set style size, face, bold, italic, and underline attributes from
2486 // a wxFont's attributes.
2487 void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
2488 #ifdef __WXGTK__
2489 // Ensure that the native font is initialized
2490 int x, y;
2491 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
2492 #endif
2493 int size = font.GetPointSize();
2494 wxString faceName = font.GetFaceName();
2495 bool bold = font.GetWeight() == wxBOLD;
2496 bool italic = font.GetStyle() != wxNORMAL;
2497 bool under = font.GetUnderlined();
2498
2499 // TODO: add encoding/charset mapping
2500 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under);
2501 }
2502
2503 // Set all font style attributes at once.
2504 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
2505 const wxString& faceName,
2506 bool bold, bool italic,
2507 bool underline) {
2508 StyleSetSize(styleNum, size);
2509 StyleSetFaceName(styleNum, faceName);
2510 StyleSetBold(styleNum, bold);
2511 StyleSetItalic(styleNum, italic);
2512 StyleSetUnderline(styleNum, underline);
2513
2514 // TODO: add encoding/charset mapping
2515 }
2516
2517
2518 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2519 void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
2520 SendMsg(cmd);
2521 }
2522
2523
2524 // Set the left and right margin in the edit area, measured in pixels.
2525 void wxStyledTextCtrl::SetMargins(int left, int right) {
2526 SetMarginLeft(left);
2527 SetMarginRight(right);
2528 }
2529
2530
2531 // Retrieve the start and end positions of the current selection.
2532 void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) {
2533 if (startPos != NULL)
2534 *startPos = SendMsg(SCI_GETSELECTIONSTART);
2535 if (endPos != NULL)
2536 *endPos = SendMsg(SCI_GETSELECTIONEND);
2537 }
2538
2539
2540 // Retrieve the point in the window where a position is displayed.
2541 wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
2542 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
2543 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
2544 return wxPoint(x, y);
2545 }
2546
2547 // Scroll enough to make the given line visible
2548 void wxStyledTextCtrl::ScrollToLine(int line) {
2549 m_swx->DoScrollToLine(line);
2550 }
2551
2552
2553 // Scroll enough to make the given column visible
2554 void wxStyledTextCtrl::ScrollToColumn(int column) {
2555 m_swx->DoScrollToColumn(column);
2556 }
2557
2558
2559 bool wxStyledTextCtrl::SaveFile(const wxString& filename)
2560 {
2561 wxFile file(filename, wxFile::write);
2562
2563 if (!file.IsOpened())
2564 return FALSE;
2565
2566 bool success = file.Write(GetText(), *wxConvCurrent);
2567
2568 if (success)
2569 SetSavePoint();
2570
2571 return success;
2572 }
2573
2574 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
2575 {
2576 bool success = false;
2577 wxFile file(filename, wxFile::read);
2578
2579 if (file.IsOpened())
2580 {
2581 wxString contents;
2582 off_t len = file.Length();
2583 if (len > 0)
2584 {
2585 #if wxUSE_UNICODE
2586 wxMemoryBuffer buffer(len+1);
2587 success = (file.Read(buffer.GetData(), len) == len);
2588 if (success) {
2589 ((char*)buffer.GetData())[len] = 0;
2590 contents = wxString(buffer, *wxConvCurrent, len);
2591 }
2592 #else
2593 wxString buffer;
2594 success = (file.Read(wxStringBuffer(buffer, len), len) == len);
2595 contents = buffer;
2596 #endif
2597 }
2598 else
2599 success = true; // empty file is ok
2600
2601 if (success)
2602 {
2603 SetText(contents);
2604 EmptyUndoBuffer();
2605 SetSavePoint();
2606 }
2607 }
2608
2609 return success;
2610 }
2611
2612
2613 #if wxUSE_DRAG_AND_DROP
2614 wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
2615 return m_swx->DoDragOver(x, y, def);
2616 }
2617
2618
2619 bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
2620 return m_swx->DoDropText(x, y, data);
2621 }
2622 #endif
2623
2624
2625 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
2626 m_swx->SetUseAntiAliasing(useAA);
2627 }
2628
2629 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2630 return m_swx->GetUseAntiAliasing();
2631 }
2632
2633 //----------------------------------------------------------------------
2634 // Event handlers
2635
2636 void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
2637 wxPaintDC dc(this);
2638 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
2639 }
2640
2641 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
2642 if (evt.GetOrientation() == wxHORIZONTAL)
2643 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
2644 else
2645 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
2646 }
2647
2648 void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
2649 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
2650 if (sb) {
2651 if (sb->IsVertical())
2652 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
2653 else
2654 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
2655 }
2656 }
2657
2658 void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
2659 if (m_swx) {
2660 wxSize sz = GetClientSize();
2661 m_swx->DoSize(sz.x, sz.y);
2662 }
2663 }
2664
2665 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
2666 SetFocus();
2667 wxPoint pt = evt.GetPosition();
2668 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
2669 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
2670 }
2671
2672 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
2673 wxPoint pt = evt.GetPosition();
2674 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
2675 }
2676
2677 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
2678 wxPoint pt = evt.GetPosition();
2679 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
2680 evt.ControlDown());
2681 }
2682
2683
2684 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
2685 wxPoint pt = evt.GetPosition();
2686 m_swx->DoContextMenu(Point(pt.x, pt.y));
2687 }
2688
2689
2690 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
2691 wxPoint pt = evt.GetPosition();
2692 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
2693 }
2694
2695 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
2696 wxPoint pt = evt.GetPosition();
2697 ScreenToClient(&pt.x, &pt.y);
2698 /*
2699 Show context menu at event point if it's within the window,
2700 or at caret location if not
2701 */
2702 wxHitTest ht = this->HitTest(pt);
2703 if (ht != wxHT_WINDOW_INSIDE) {
2704 pt = this->PointFromPosition(this->GetCurrentPos());
2705 }
2706 m_swx->DoContextMenu(Point(pt.x, pt.y));
2707 }
2708
2709
2710 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) {
2711 m_swx->DoMouseWheel(evt.GetWheelRotation(),
2712 evt.GetWheelDelta(),
2713 evt.GetLinesPerAction(),
2714 evt.ControlDown(),
2715 evt.IsPageScroll());
2716 }
2717
2718
2719 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
2720 // On (some?) non-US keyboards the AltGr key is required to enter some
2721 // common characters. It comes to us as both Alt and Ctrl down so we need
2722 // to let the char through in that case, otherwise if only ctrl or only
2723 // alt let's skip it.
2724 bool ctrl = evt.ControlDown();
2725 bool alt = evt.AltDown();
2726 bool skip = ((ctrl || alt) && ! (ctrl && alt));
2727
2728 int key = evt.GetKeyCode();
2729
2730 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
2731 // key, m_lastKeyDownConsumed, ctrl, alt, skip);
2732
2733 if ( (key <= WXK_START || key > WXK_COMMAND) &&
2734 !m_lastKeyDownConsumed && !skip) {
2735 m_swx->DoAddChar(key);
2736 return;
2737 }
2738 evt.Skip();
2739 }
2740
2741
2742 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
2743 int key = evt.GetKeyCode();
2744 bool shift = evt.ShiftDown(),
2745 ctrl = evt.ControlDown(),
2746 alt = evt.AltDown(),
2747 meta = evt.MetaDown();
2748
2749 int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, meta, &m_lastKeyDownConsumed);
2750
2751 // printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
2752 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
2753
2754 if (!processed && !m_lastKeyDownConsumed)
2755 evt.Skip();
2756 }
2757
2758
2759 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
2760 m_swx->DoLoseFocus();
2761 evt.Skip();
2762 }
2763
2764
2765 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
2766 m_swx->DoGainFocus();
2767 evt.Skip();
2768 }
2769
2770
2771 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
2772 m_swx->DoSysColourChange();
2773 }
2774
2775
2776 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
2777 // do nothing to help avoid flashing
2778 }
2779
2780
2781
2782 void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
2783 m_swx->DoCommand(evt.GetId());
2784 }
2785
2786
2787 void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
2788 m_swx->DoOnListBox();
2789 }
2790
2791
2792 void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
2793 m_swx->DoOnIdle(evt);
2794 }
2795
2796
2797 wxSize wxStyledTextCtrl::DoGetBestSize() const
2798 {
2799 // What would be the best size for a wxSTC?
2800 // Just give a reasonable minimum until something else can be figured out.
2801 return wxSize(200,100);
2802 }
2803
2804
2805 //----------------------------------------------------------------------
2806 // Turn notifications from Scintilla into events
2807
2808
2809 void wxStyledTextCtrl::NotifyChange() {
2810 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
2811 evt.SetEventObject(this);
2812 GetEventHandler()->ProcessEvent(evt);
2813 }
2814
2815
2816 static void SetEventText(wxStyledTextEvent& evt, const char* text,
2817 size_t length) {
2818 if(!text) return;
2819
2820 // The unicode conversion MUST have a null byte to terminate the
2821 // string so move it into a buffer first and give it one.
2822 wxMemoryBuffer buf(length+1);
2823 buf.AppendData((void*)text, length);
2824 buf.AppendByte(0);
2825 evt.SetText(stc2wx(buf));
2826 }
2827
2828
2829 void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
2830 SCNotification& scn = *_scn;
2831 wxStyledTextEvent evt(0, GetId());
2832
2833 evt.SetEventObject(this);
2834 evt.SetPosition(scn.position);
2835 evt.SetKey(scn.ch);
2836 evt.SetModifiers(scn.modifiers);
2837
2838 switch (scn.nmhdr.code) {
2839 case SCN_STYLENEEDED:
2840 evt.SetEventType(wxEVT_STC_STYLENEEDED);
2841 break;
2842
2843 case SCN_CHARADDED:
2844 evt.SetEventType(wxEVT_STC_CHARADDED);
2845 break;
2846
2847 case SCN_SAVEPOINTREACHED:
2848 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
2849 break;
2850
2851 case SCN_SAVEPOINTLEFT:
2852 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
2853 break;
2854
2855 case SCN_MODIFYATTEMPTRO:
2856 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
2857 break;
2858
2859 case SCN_KEY:
2860 evt.SetEventType(wxEVT_STC_KEY);
2861 break;
2862
2863 case SCN_DOUBLECLICK:
2864 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
2865 break;
2866
2867 case SCN_UPDATEUI:
2868 evt.SetEventType(wxEVT_STC_UPDATEUI);
2869 break;
2870
2871 case SCN_MODIFIED:
2872 evt.SetEventType(wxEVT_STC_MODIFIED);
2873 evt.SetModificationType(scn.modificationType);
2874 SetEventText(evt, scn.text, scn.length);
2875 evt.SetLength(scn.length);
2876 evt.SetLinesAdded(scn.linesAdded);
2877 evt.SetLine(scn.line);
2878 evt.SetFoldLevelNow(scn.foldLevelNow);
2879 evt.SetFoldLevelPrev(scn.foldLevelPrev);
2880 break;
2881
2882 case SCN_MACRORECORD:
2883 evt.SetEventType(wxEVT_STC_MACRORECORD);
2884 evt.SetMessage(scn.message);
2885 evt.SetWParam(scn.wParam);
2886 evt.SetLParam(scn.lParam);
2887 break;
2888
2889 case SCN_MARGINCLICK:
2890 evt.SetEventType(wxEVT_STC_MARGINCLICK);
2891 evt.SetMargin(scn.margin);
2892 break;
2893
2894 case SCN_NEEDSHOWN:
2895 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
2896 evt.SetLength(scn.length);
2897 break;
2898
2899 case SCN_PAINTED:
2900 evt.SetEventType(wxEVT_STC_PAINTED);
2901 break;
2902
2903 case SCN_USERLISTSELECTION:
2904 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
2905 evt.SetListType(scn.listType);
2906 SetEventText(evt, scn.text, strlen(scn.text));
2907 break;
2908
2909 case SCN_URIDROPPED:
2910 evt.SetEventType(wxEVT_STC_URIDROPPED);
2911 SetEventText(evt, scn.text, strlen(scn.text));
2912 break;
2913
2914 case SCN_DWELLSTART:
2915 evt.SetEventType(wxEVT_STC_DWELLSTART);
2916 evt.SetX(scn.x);
2917 evt.SetY(scn.y);
2918 break;
2919
2920 case SCN_DWELLEND:
2921 evt.SetEventType(wxEVT_STC_DWELLEND);
2922 evt.SetX(scn.x);
2923 evt.SetY(scn.y);
2924 break;
2925
2926 case SCN_ZOOM:
2927 evt.SetEventType(wxEVT_STC_ZOOM);
2928 break;
2929
2930 case SCN_HOTSPOTCLICK:
2931 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
2932 break;
2933
2934 case SCN_HOTSPOTDOUBLECLICK:
2935 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
2936 break;
2937
2938 case SCN_CALLTIPCLICK:
2939 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
2940 break;
2941
2942 default:
2943 return;
2944 }
2945
2946 GetEventHandler()->ProcessEvent(evt);
2947 }
2948
2949
2950 //----------------------------------------------------------------------
2951 //----------------------------------------------------------------------
2952 //----------------------------------------------------------------------
2953
2954 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
2955 : wxCommandEvent(commandType, id)
2956 {
2957 m_position = 0;
2958 m_key = 0;
2959 m_modifiers = 0;
2960 m_modificationType = 0;
2961 m_length = 0;
2962 m_linesAdded = 0;
2963 m_line = 0;
2964 m_foldLevelNow = 0;
2965 m_foldLevelPrev = 0;
2966 m_margin = 0;
2967 m_message = 0;
2968 m_wParam = 0;
2969 m_lParam = 0;
2970 m_listType = 0;
2971 m_x = 0;
2972 m_y = 0;
2973 m_dragAllowMove = FALSE;
2974 #if wxUSE_DRAG_AND_DROP
2975 m_dragResult = wxDragNone;
2976 #endif
2977 }
2978
2979 bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
2980 bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
2981 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
2982
2983
2984 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
2985 wxCommandEvent(event)
2986 {
2987 m_position = event.m_position;
2988 m_key = event.m_key;
2989 m_modifiers = event.m_modifiers;
2990 m_modificationType = event.m_modificationType;
2991 m_text = event.m_text;
2992 m_length = event.m_length;
2993 m_linesAdded = event.m_linesAdded;
2994 m_line = event.m_line;
2995 m_foldLevelNow = event.m_foldLevelNow;
2996 m_foldLevelPrev = event.m_foldLevelPrev;
2997
2998 m_margin = event.m_margin;
2999
3000 m_message = event.m_message;
3001 m_wParam = event.m_wParam;
3002 m_lParam = event.m_lParam;
3003
3004 m_listType = event.m_listType;
3005 m_x = event.m_x;
3006 m_y = event.m_y;
3007
3008 m_dragText = event.m_dragText;
3009 m_dragAllowMove =event.m_dragAllowMove;
3010 #if wxUSE_DRAG_AND_DROP
3011 m_dragResult = event.m_dragResult;
3012 #endif
3013 }
3014
3015 //----------------------------------------------------------------------
3016 //----------------------------------------------------------------------
3017
3018
3019
3020
3021
3022
3023
3024
3025