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