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