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