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