]> git.saurik.com Git - wxWidgets.git/blob - src/stc/stc.cpp
Add wxActivateEvent::GetActivationReason().
[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 // Copyright: (c) 2000 by Total Control Software
14 // Licence: wxWindows licence
15 /////////////////////////////////////////////////////////////////////////////
16
17 /*
18 IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from
19 src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be
20 lost after the next regeneration, edit stc.cpp.in and rerun the
21 gen_iface.py script instead!
22
23 Parts of this file generated by the script are found in between
24 the special "{{{" and "}}}" markers, the rest of it is copied
25 verbatim from src.h.in.
26 */
27
28 // For compilers that support precompilation, includes "wx.h".
29 #include "wx/wxprec.h"
30
31 #ifdef __BORLANDC__
32 #pragma hdrstop
33 #endif
34
35 #if wxUSE_STC
36
37 #include "wx/stc/stc.h"
38 #include "wx/stc/private.h"
39
40 #ifndef WX_PRECOMP
41 #include "wx/wx.h"
42 #endif // WX_PRECOMP
43
44 #include <ctype.h>
45
46 #include "wx/tokenzr.h"
47 #include "wx/mstream.h"
48 #include "wx/image.h"
49 #if wxUSE_FFILE
50 #include "wx/ffile.h"
51 #elif wxUSE_FILE
52 #include "wx/file.h"
53 #endif
54
55 #ifdef __WXGTK__
56 #include "wx/dcbuffer.h"
57 #endif
58
59 #include "ScintillaWX.h"
60
61 //----------------------------------------------------------------------
62
63 const char wxSTCNameStr[] = "stcwindow";
64
65 #ifdef MAKELONG
66 #undef MAKELONG
67 #endif
68
69 #define MAKELONG(a, b) ((a) | ((b) << 16))
70
71
72 static long wxColourAsLong(const wxColour& co) {
73 return (((long)co.Blue() << 16) |
74 ((long)co.Green() << 8) |
75 ((long)co.Red()));
76 }
77
78 static wxColour wxColourFromLong(long c) {
79 wxColour clr;
80 clr.Set((unsigned char)(c & 0xff),
81 (unsigned char)((c >> 8) & 0xff),
82 (unsigned char)((c >> 16) & 0xff));
83 return clr;
84 }
85
86
87 static wxColour wxColourFromSpec(const wxString& spec) {
88 // spec should be a colour name or "#RRGGBB"
89 if (spec.GetChar(0) == wxT('#')) {
90
91 long red, green, blue;
92 red = green = blue = 0;
93 spec.Mid(1,2).ToLong(&red, 16);
94 spec.Mid(3,2).ToLong(&green, 16);
95 spec.Mid(5,2).ToLong(&blue, 16);
96 return wxColour((unsigned char)red,
97 (unsigned char)green,
98 (unsigned char)blue);
99 }
100 else
101 return wxColour(spec);
102 }
103
104 //----------------------------------------------------------------------
105
106 wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent );
107 wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent );
108 wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent );
109 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent );
110 wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent );
111 wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent );
112 wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent );
113 wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent );
114 wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent );
115 wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent );
116 wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent );
117 wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent );
118 wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent );
119 wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent );
120 wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent );
121 wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent );
122 wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent );
123 wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent );
124 wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent );
125 wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent );
126 wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent );
127 wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent );
128 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent );
129 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent );
130 wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent );
131 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent );
132 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent );
133 wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent );
134 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent );
135 wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent );
136 wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent );
137
138
139
140 BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl)
141 EVT_PAINT (wxStyledTextCtrl::OnPaint)
142 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin)
143 EVT_SCROLL (wxStyledTextCtrl::OnScroll)
144 EVT_SIZE (wxStyledTextCtrl::OnSize)
145 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown)
146 // Let Scintilla see the double click as a second click
147 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown)
148 EVT_MOTION (wxStyledTextCtrl::OnMouseMove)
149 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp)
150 #if defined(__WXGTK__) || defined(__WXMAC__)
151 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp)
152 #else
153 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu)
154 #endif
155 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel)
156 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp)
157 EVT_CHAR (wxStyledTextCtrl::OnChar)
158 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown)
159 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus)
160 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus)
161 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged)
162 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground)
163 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu)
164 EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox)
165 END_EVENT_TABLE()
166
167
168 IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl)
169 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent)
170
171 #ifdef LINK_LEXERS
172 // forces the linking of the lexer modules
173 int Scintilla_LinkLexers();
174 #endif
175
176 //----------------------------------------------------------------------
177 // Constructor and Destructor
178
179 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent,
180 wxWindowID id,
181 const wxPoint& pos,
182 const wxSize& size,
183 long style,
184 const wxString& name)
185 {
186 m_swx = NULL;
187 Create(parent, id, pos, size, style, name);
188 }
189
190
191 bool wxStyledTextCtrl::Create(wxWindow *parent,
192 wxWindowID id,
193 const wxPoint& pos,
194 const wxSize& size,
195 long style,
196 const wxString& name)
197 {
198 style |= wxVSCROLL | wxHSCROLL;
199 if (!wxControl::Create(parent, id, pos, size,
200 style | wxWANTS_CHARS | wxCLIP_CHILDREN,
201 wxDefaultValidator, name))
202 return false;
203
204 #ifdef LINK_LEXERS
205 Scintilla_LinkLexers();
206 #endif
207 m_swx = new ScintillaWX(this);
208 m_stopWatch.Start();
209 m_lastKeyDownConsumed = false;
210 m_vScrollBar = NULL;
211 m_hScrollBar = NULL;
212 #if wxUSE_UNICODE
213 // Put Scintilla into unicode (UTF-8) mode
214 SetCodePage(wxSTC_CP_UTF8);
215 #endif
216
217 SetInitialSize(size);
218
219 // Reduces flicker on GTK+/X11
220 SetBackgroundStyle(wxBG_STYLE_PAINT);
221
222 // Make sure it can take the focus
223 SetCanFocus(true);
224
225 return true;
226 }
227
228
229 wxStyledTextCtrl::~wxStyledTextCtrl() {
230 delete m_swx;
231 }
232
233
234 //----------------------------------------------------------------------
235
236 wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const
237 {
238 return m_swx->WndProc(msg, wp, lp);
239 }
240
241 //----------------------------------------------------------------------
242
243 // Set the vertical scrollbar to use instead of the ont that's built-in.
244 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) {
245 m_vScrollBar = bar;
246 if (bar != NULL) {
247 // ensure that the built-in scrollbar is not visible
248 SetScrollbar(wxVERTICAL, 0, 0, 0);
249 }
250 }
251
252
253 // Set the horizontal scrollbar to use instead of the ont that's built-in.
254 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) {
255 m_hScrollBar = bar;
256 if (bar != NULL) {
257 // ensure that the built-in scrollbar is not visible
258 SetScrollbar(wxHORIZONTAL, 0, 0, 0);
259 }
260 }
261
262 //----------------------------------------------------------------------
263 // Generated methods implementation section {{{
264
265
266 // Add text to the document at current position.
267 void wxStyledTextCtrl::AddText(const wxString& text) {
268 const wxWX2MBbuf buf = wx2stc(text);
269 SendMsg(2001, wx2stclen(text, buf), (sptr_t)(const char*)buf);
270 }
271
272 // Add array of cells to document.
273 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) {
274 SendMsg(2002, data.GetDataLen(), (sptr_t)data.GetData());
275 }
276
277 // Insert string at a position.
278 void wxStyledTextCtrl::InsertText(int pos, const wxString& text)
279 {
280 SendMsg(2003, pos, (sptr_t)(const char*)wx2stc(text));
281 }
282
283 // Delete all text in the document.
284 void wxStyledTextCtrl::ClearAll()
285 {
286 SendMsg(2004, 0, 0);
287 }
288
289 // Delete a range of text in the document.
290 void wxStyledTextCtrl::DeleteRange(int pos, int deleteLength)
291 {
292 SendMsg(2645, pos, deleteLength);
293 }
294
295 // Set all style bytes to 0, remove all folding information.
296 void wxStyledTextCtrl::ClearDocumentStyle()
297 {
298 SendMsg(2005, 0, 0);
299 }
300
301 // Returns the number of bytes in the document.
302 int wxStyledTextCtrl::GetLength() const
303 {
304 return SendMsg(2006, 0, 0);
305 }
306
307 // Returns the character byte at the position.
308 int wxStyledTextCtrl::GetCharAt(int pos) const {
309 return (unsigned char)SendMsg(2007, pos, 0);
310 }
311
312 // Returns the position of the caret.
313 int wxStyledTextCtrl::GetCurrentPos() const
314 {
315 return SendMsg(2008, 0, 0);
316 }
317
318 // Returns the position of the opposite end of the selection to the caret.
319 int wxStyledTextCtrl::GetAnchor() const
320 {
321 return SendMsg(2009, 0, 0);
322 }
323
324 // Returns the style byte at the position.
325 int wxStyledTextCtrl::GetStyleAt(int pos) const {
326 return (unsigned char)SendMsg(2010, pos, 0);
327 }
328
329 // Redoes the next action on the undo history.
330 void wxStyledTextCtrl::Redo()
331 {
332 SendMsg(2011, 0, 0);
333 }
334
335 // Choose between collecting actions into the undo
336 // history and discarding them.
337 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo)
338 {
339 SendMsg(2012, collectUndo, 0);
340 }
341
342 // Select all the text in the document.
343 void wxStyledTextCtrl::SelectAll()
344 {
345 SendMsg(2013, 0, 0);
346 }
347
348 // Remember the current position in the undo history as the position
349 // at which the document was saved.
350 void wxStyledTextCtrl::SetSavePoint()
351 {
352 SendMsg(2014, 0, 0);
353 }
354
355 // Retrieve a buffer of cells.
356 wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) {
357 wxMemoryBuffer buf;
358 if (endPos < startPos) {
359 int temp = startPos;
360 startPos = endPos;
361 endPos = temp;
362 }
363 int len = endPos - startPos;
364 if (!len) return buf;
365 TextRange tr;
366 tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1);
367 tr.chrg.cpMin = startPos;
368 tr.chrg.cpMax = endPos;
369 len = SendMsg(2015, 0, (sptr_t)&tr);
370 buf.UngetWriteBuf(len);
371 return buf;
372 }
373
374 // Are there any redoable actions in the undo history?
375 bool wxStyledTextCtrl::CanRedo() const
376 {
377 return SendMsg(2016, 0, 0) != 0;
378 }
379
380 // Retrieve the line number at which a particular marker is located.
381 int wxStyledTextCtrl::MarkerLineFromHandle(int handle)
382 {
383 return SendMsg(2017, handle, 0);
384 }
385
386 // Delete a marker.
387 void wxStyledTextCtrl::MarkerDeleteHandle(int handle)
388 {
389 SendMsg(2018, handle, 0);
390 }
391
392 // Is undo history being collected?
393 bool wxStyledTextCtrl::GetUndoCollection() const
394 {
395 return SendMsg(2019, 0, 0) != 0;
396 }
397
398 // Are white space characters currently visible?
399 // Returns one of SCWS_* constants.
400 int wxStyledTextCtrl::GetViewWhiteSpace() const
401 {
402 return SendMsg(2020, 0, 0);
403 }
404
405 // Make white space characters invisible, always visible or visible outside indentation.
406 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS)
407 {
408 SendMsg(2021, viewWS, 0);
409 }
410
411 // Find the position from a point within the window.
412 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) const {
413 return SendMsg(2022, pt.x, pt.y);
414 }
415
416 // Find the position from a point within the window but return
417 // INVALID_POSITION if not close to text.
418 int wxStyledTextCtrl::PositionFromPointClose(int x, int y)
419 {
420 return SendMsg(2023, x, y);
421 }
422
423 // Set caret to start of a line and ensure it is visible.
424 void wxStyledTextCtrl::GotoLine(int line)
425 {
426 SendMsg(2024, line, 0);
427 }
428
429 // Set caret to a position and ensure it is visible.
430 void wxStyledTextCtrl::GotoPos(int pos)
431 {
432 SendMsg(2025, pos, 0);
433 }
434
435 // Set the selection anchor to a position. The anchor is the opposite
436 // end of the selection from the caret.
437 void wxStyledTextCtrl::SetAnchor(int posAnchor)
438 {
439 SendMsg(2026, posAnchor, 0);
440 }
441
442 // Retrieve the text of the line containing the caret.
443 // Returns the index of the caret on the line.
444 wxString wxStyledTextCtrl::GetCurLine(int* linePos) {
445 int len = LineLength(GetCurrentLine());
446 if (!len) {
447 if (linePos) *linePos = 0;
448 return wxEmptyString;
449 }
450
451 wxMemoryBuffer mbuf(len+1);
452 char* buf = (char*)mbuf.GetWriteBuf(len+1);
453
454 int pos = SendMsg(2027, len+1, (sptr_t)buf);
455 mbuf.UngetWriteBuf(len);
456 mbuf.AppendByte(0);
457 if (linePos) *linePos = pos;
458 return stc2wx(buf);
459 }
460
461 // Retrieve the position of the last correctly styled character.
462 int wxStyledTextCtrl::GetEndStyled() const
463 {
464 return SendMsg(2028, 0, 0);
465 }
466
467 // Convert all line endings in the document to one mode.
468 void wxStyledTextCtrl::ConvertEOLs(int eolMode)
469 {
470 SendMsg(2029, eolMode, 0);
471 }
472
473 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
474 int wxStyledTextCtrl::GetEOLMode() const
475 {
476 return SendMsg(2030, 0, 0);
477 }
478
479 // Set the current end of line mode.
480 void wxStyledTextCtrl::SetEOLMode(int eolMode)
481 {
482 SendMsg(2031, eolMode, 0);
483 }
484
485 // Set the current styling position to pos and the styling mask to mask.
486 // The styling mask can be used to protect some bits in each styling byte from modification.
487 void wxStyledTextCtrl::StartStyling(int pos, int mask)
488 {
489 SendMsg(2032, pos, mask);
490 }
491
492 // Change style from current styling position for length characters to a style
493 // and move the current styling position to after this newly styled segment.
494 void wxStyledTextCtrl::SetStyling(int length, int style)
495 {
496 SendMsg(2033, length, style);
497 }
498
499 // Is drawing done first into a buffer or direct to the screen?
500 bool wxStyledTextCtrl::GetBufferedDraw() const
501 {
502 return SendMsg(2034, 0, 0) != 0;
503 }
504
505 // If drawing is buffered then each line of text is drawn into a bitmap buffer
506 // before drawing it to the screen to avoid flicker.
507 void wxStyledTextCtrl::SetBufferedDraw(bool buffered)
508 {
509 SendMsg(2035, buffered, 0);
510 }
511
512 // Change the visible size of a tab to be a multiple of the width of a space character.
513 void wxStyledTextCtrl::SetTabWidth(int tabWidth)
514 {
515 SendMsg(2036, tabWidth, 0);
516 }
517
518 // Retrieve the visible size of a tab.
519 int wxStyledTextCtrl::GetTabWidth() const
520 {
521 return SendMsg(2121, 0, 0);
522 }
523
524 // Set the code page used to interpret the bytes of the document as characters.
525 void wxStyledTextCtrl::SetCodePage(int codePage) {
526 #if wxUSE_UNICODE
527 wxASSERT_MSG(codePage == wxSTC_CP_UTF8,
528 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
529 #else
530 wxASSERT_MSG(codePage != wxSTC_CP_UTF8,
531 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
532 #endif
533 SendMsg(2037, codePage);
534 }
535
536 // Set the symbol used for a particular marker number,
537 // and optionally the fore and background colours.
538 void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol,
539 const wxColour& foreground,
540 const wxColour& background) {
541
542 SendMsg(2040, markerNumber, markerSymbol);
543 if (foreground.IsOk())
544 MarkerSetForeground(markerNumber, foreground);
545 if (background.IsOk())
546 MarkerSetBackground(markerNumber, background);
547 }
548
549 // Set the foreground colour used for a particular marker number.
550 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore)
551 {
552 SendMsg(2041, markerNumber, wxColourAsLong(fore));
553 }
554
555 // Set the background colour used for a particular marker number.
556 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back)
557 {
558 SendMsg(2042, markerNumber, wxColourAsLong(back));
559 }
560
561 // Set the background colour used for a particular marker number when its folding block is selected.
562 void wxStyledTextCtrl::MarkerSetBackgroundSelected(int markerNumber, const wxColour& back)
563 {
564 SendMsg(2292, markerNumber, wxColourAsLong(back));
565 }
566
567 // Enable/disable highlight for current folding bloc (smallest one that contains the caret)
568 void wxStyledTextCtrl::MarkerEnableHighlight(bool enabled)
569 {
570 SendMsg(2293, enabled, 0);
571 }
572
573 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
574 int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber)
575 {
576 return SendMsg(2043, line, markerNumber);
577 }
578
579 // Delete a marker from a line.
580 void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber)
581 {
582 SendMsg(2044, line, markerNumber);
583 }
584
585 // Delete all markers with a particular number from all lines.
586 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber)
587 {
588 SendMsg(2045, markerNumber, 0);
589 }
590
591 // Get a bit mask of all the markers set on a line.
592 int wxStyledTextCtrl::MarkerGet(int line)
593 {
594 return SendMsg(2046, line, 0);
595 }
596
597 // Find the next line at or after lineStart that includes a marker in mask.
598 // Return -1 when no more lines.
599 int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask)
600 {
601 return SendMsg(2047, lineStart, markerMask);
602 }
603
604 // Find the previous line before lineStart that includes a marker in mask.
605 int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask)
606 {
607 return SendMsg(2048, lineStart, markerMask);
608 }
609
610 // Define a marker from a bitmap
611 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) {
612 // convert bmp to a xpm in a string
613 wxMemoryOutputStream strm;
614 wxImage img = bmp.ConvertToImage();
615 if (img.HasAlpha())
616 img.ConvertAlphaToMask();
617 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
618 size_t len = strm.GetSize();
619 char* buff = new char[len+1];
620 strm.CopyTo(buff, len);
621 buff[len] = 0;
622 SendMsg(2049, markerNumber, (sptr_t)buff);
623 delete [] buff;
624
625 }
626
627 // Add a set of markers to a line.
628 void wxStyledTextCtrl::MarkerAddSet(int line, int set)
629 {
630 SendMsg(2466, line, set);
631 }
632
633 // Set the alpha used for a marker that is drawn in the text area, not the margin.
634 void wxStyledTextCtrl::MarkerSetAlpha(int markerNumber, int alpha)
635 {
636 SendMsg(2476, markerNumber, alpha);
637 }
638
639 // Set a margin to be either numeric or symbolic.
640 void wxStyledTextCtrl::SetMarginType(int margin, int marginType)
641 {
642 SendMsg(2240, margin, marginType);
643 }
644
645 // Retrieve the type of a margin.
646 int wxStyledTextCtrl::GetMarginType(int margin) const
647 {
648 return SendMsg(2241, margin, 0);
649 }
650
651 // Set the width of a margin to a width expressed in pixels.
652 void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth)
653 {
654 SendMsg(2242, margin, pixelWidth);
655 }
656
657 // Retrieve the width of a margin in pixels.
658 int wxStyledTextCtrl::GetMarginWidth(int margin) const
659 {
660 return SendMsg(2243, margin, 0);
661 }
662
663 // Set a mask that determines which markers are displayed in a margin.
664 void wxStyledTextCtrl::SetMarginMask(int margin, int mask)
665 {
666 SendMsg(2244, margin, mask);
667 }
668
669 // Retrieve the marker mask of a margin.
670 int wxStyledTextCtrl::GetMarginMask(int margin) const
671 {
672 return SendMsg(2245, margin, 0);
673 }
674
675 // Make a margin sensitive or insensitive to mouse clicks.
676 void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive)
677 {
678 SendMsg(2246, margin, sensitive);
679 }
680
681 // Retrieve the mouse click sensitivity of a margin.
682 bool wxStyledTextCtrl::GetMarginSensitive(int margin) const
683 {
684 return SendMsg(2247, margin, 0) != 0;
685 }
686
687 // Set the cursor shown when the mouse is inside a margin.
688 void wxStyledTextCtrl::SetMarginCursor(int margin, int cursor)
689 {
690 SendMsg(2248, margin, cursor);
691 }
692
693 // Retrieve the cursor shown in a margin.
694 int wxStyledTextCtrl::GetMarginCursor(int margin) const
695 {
696 return SendMsg(2249, margin, 0);
697 }
698
699 // Clear all the styles and make equivalent to the global default style.
700 void wxStyledTextCtrl::StyleClearAll()
701 {
702 SendMsg(2050, 0, 0);
703 }
704
705 // Set the foreground colour of a style.
706 void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore)
707 {
708 SendMsg(2051, style, wxColourAsLong(fore));
709 }
710
711 // Set the background colour of a style.
712 void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back)
713 {
714 SendMsg(2052, style, wxColourAsLong(back));
715 }
716
717 // Set a style to be bold or not.
718 void wxStyledTextCtrl::StyleSetBold(int style, bool bold)
719 {
720 SendMsg(2053, style, bold);
721 }
722
723 // Set a style to be italic or not.
724 void wxStyledTextCtrl::StyleSetItalic(int style, bool italic)
725 {
726 SendMsg(2054, style, italic);
727 }
728
729 // Set the size of characters of a style.
730 void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints)
731 {
732 SendMsg(2055, style, sizePoints);
733 }
734
735 // Set the font of a style.
736 void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName)
737 {
738 SendMsg(2056, style, (sptr_t)(const char*)wx2stc(fontName));
739 }
740
741 // Set a style to have its end of line filled or not.
742 void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled)
743 {
744 SendMsg(2057, style, filled);
745 }
746
747 // Reset the default style to its state at startup
748 void wxStyledTextCtrl::StyleResetDefault()
749 {
750 SendMsg(2058, 0, 0);
751 }
752
753 // Set a style to be underlined or not.
754 void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline)
755 {
756 SendMsg(2059, style, underline);
757 }
758
759 // Get the foreground colour of a style.
760 wxColour wxStyledTextCtrl::StyleGetForeground(int style) const
761 {
762 long c = SendMsg(2481, style, 0);
763 return wxColourFromLong(c);
764 }
765
766 // Get the background colour of a style.
767 wxColour wxStyledTextCtrl::StyleGetBackground(int style) const
768 {
769 long c = SendMsg(2482, style, 0);
770 return wxColourFromLong(c);
771 }
772
773 // Get is a style bold or not.
774 bool wxStyledTextCtrl::StyleGetBold(int style) const
775 {
776 return SendMsg(2483, style, 0) != 0;
777 }
778
779 // Get is a style italic or not.
780 bool wxStyledTextCtrl::StyleGetItalic(int style) const
781 {
782 return SendMsg(2484, style, 0) != 0;
783 }
784
785 // Get the size of characters of a style.
786 int wxStyledTextCtrl::StyleGetSize(int style) const
787 {
788 return SendMsg(2485, style, 0);
789 }
790
791 // Get the font facename of a style
792 wxString wxStyledTextCtrl::StyleGetFaceName(int style) {
793 long msg = 2486;
794 long len = SendMsg(msg, style, 0);
795 wxMemoryBuffer mbuf(len+1);
796 char* buf = (char*)mbuf.GetWriteBuf(len+1);
797 SendMsg(msg, style, (sptr_t)buf);
798 mbuf.UngetWriteBuf(len);
799 mbuf.AppendByte(0);
800 return stc2wx(buf);
801 }
802
803 // Get is a style to have its end of line filled or not.
804 bool wxStyledTextCtrl::StyleGetEOLFilled(int style) const
805 {
806 return SendMsg(2487, style, 0) != 0;
807 }
808
809 // Get is a style underlined or not.
810 bool wxStyledTextCtrl::StyleGetUnderline(int style) const
811 {
812 return SendMsg(2488, style, 0) != 0;
813 }
814
815 // Get is a style mixed case, or to force upper or lower case.
816 int wxStyledTextCtrl::StyleGetCase(int style) const
817 {
818 return SendMsg(2489, style, 0);
819 }
820
821 // Get the character set of the font in a style.
822 int wxStyledTextCtrl::StyleGetCharacterSet(int style) const
823 {
824 return SendMsg(2490, style, 0);
825 }
826
827 // Get is a style visible or not.
828 bool wxStyledTextCtrl::StyleGetVisible(int style) const
829 {
830 return SendMsg(2491, style, 0) != 0;
831 }
832
833 // Get is a style changeable or not (read only).
834 // Experimental feature, currently buggy.
835 bool wxStyledTextCtrl::StyleGetChangeable(int style) const
836 {
837 return SendMsg(2492, style, 0) != 0;
838 }
839
840 // Get is a style a hotspot or not.
841 bool wxStyledTextCtrl::StyleGetHotSpot(int style) const
842 {
843 return SendMsg(2493, style, 0) != 0;
844 }
845
846 // Set a style to be mixed case, or to force upper or lower case.
847 void wxStyledTextCtrl::StyleSetCase(int style, int caseForce)
848 {
849 SendMsg(2060, style, caseForce);
850 }
851
852 // Set the size of characters of a style. Size is in points multiplied by 100.
853 void wxStyledTextCtrl::StyleSetSizeFractional(int style, int caseForce)
854 {
855 SendMsg(2061, style, caseForce);
856 }
857
858 // Get the size of characters of a style in points multiplied by 100
859 int wxStyledTextCtrl::StyleGetSizeFractional(int style) const
860 {
861 return SendMsg(2062, style, 0);
862 }
863
864 // Set the weight of characters of a style.
865 void wxStyledTextCtrl::StyleSetWeight(int style, int weight)
866 {
867 SendMsg(2063, style, weight);
868 }
869
870 // Get the weight of characters of a style.
871 int wxStyledTextCtrl::StyleGetWeight(int style) const
872 {
873 return SendMsg(2064, style, 0);
874 }
875
876 // Set a style to be a hotspot or not.
877 void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot)
878 {
879 SendMsg(2409, style, hotspot);
880 }
881
882 // Set the foreground colour of the main and additional selections and whether to use this setting.
883 void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore)
884 {
885 SendMsg(2067, useSetting, wxColourAsLong(fore));
886 }
887
888 // Set the background colour of the main and additional selections and whether to use this setting.
889 void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back)
890 {
891 SendMsg(2068, useSetting, wxColourAsLong(back));
892 }
893
894 // Get the alpha of the selection.
895 int wxStyledTextCtrl::GetSelAlpha() const
896 {
897 return SendMsg(2477, 0, 0);
898 }
899
900 // Set the alpha of the selection.
901 void wxStyledTextCtrl::SetSelAlpha(int alpha)
902 {
903 SendMsg(2478, alpha, 0);
904 }
905
906 // Is the selection end of line filled?
907 bool wxStyledTextCtrl::GetSelEOLFilled() const
908 {
909 return SendMsg(2479, 0, 0) != 0;
910 }
911
912 // Set the selection to have its end of line filled or not.
913 void wxStyledTextCtrl::SetSelEOLFilled(bool filled)
914 {
915 SendMsg(2480, filled, 0);
916 }
917
918 // Set the foreground colour of the caret.
919 void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore)
920 {
921 SendMsg(2069, wxColourAsLong(fore), 0);
922 }
923
924 // When key+modifier combination km is pressed perform msg.
925 void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) {
926 SendMsg(2070, MAKELONG(key, modifiers), cmd);
927 }
928
929 // When key+modifier combination km is pressed do nothing.
930 void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) {
931 SendMsg(2071, MAKELONG(key, modifiers));
932 }
933
934 // Drop all key mappings.
935 void wxStyledTextCtrl::CmdKeyClearAll()
936 {
937 SendMsg(2072, 0, 0);
938 }
939
940 // Set the styles for a segment of the document.
941 void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) {
942 SendMsg(2073, length, (sptr_t)styleBytes);
943 }
944
945 // Set a style to be visible or not.
946 void wxStyledTextCtrl::StyleSetVisible(int style, bool visible)
947 {
948 SendMsg(2074, style, visible);
949 }
950
951 // Get the time in milliseconds that the caret is on and off.
952 int wxStyledTextCtrl::GetCaretPeriod() const
953 {
954 return SendMsg(2075, 0, 0);
955 }
956
957 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
958 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds)
959 {
960 SendMsg(2076, periodMilliseconds, 0);
961 }
962
963 // Set the set of characters making up words for when moving or selecting by word.
964 // First sets defaults like SetCharsDefault.
965 void wxStyledTextCtrl::SetWordChars(const wxString& characters)
966 {
967 SendMsg(2077, 0, (sptr_t)(const char*)wx2stc(characters));
968 }
969
970 // Get the set of characters making up words for when moving or selecting by word.
971 wxString wxStyledTextCtrl::GetWordChars() const {
972 int msg = 2646;
973 int len = SendMsg(msg, 0, (sptr_t)NULL);
974 if (!len) return wxEmptyString;
975
976 wxMemoryBuffer mbuf(len+1);
977 char* buf = (char*)mbuf.GetWriteBuf(len+1);
978 SendMsg(msg, 0, (sptr_t)buf);
979 mbuf.UngetWriteBuf(len);
980 mbuf.AppendByte(0);
981 return stc2wx(buf);
982 }
983
984 // Start a sequence of actions that is undone and redone as a unit.
985 // May be nested.
986 void wxStyledTextCtrl::BeginUndoAction()
987 {
988 SendMsg(2078, 0, 0);
989 }
990
991 // End a sequence of actions that is undone and redone as a unit.
992 void wxStyledTextCtrl::EndUndoAction()
993 {
994 SendMsg(2079, 0, 0);
995 }
996
997 // Set an indicator to plain, squiggle or TT.
998 void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style)
999 {
1000 SendMsg(2080, indic, style);
1001 }
1002
1003 // Retrieve the style of an indicator.
1004 int wxStyledTextCtrl::IndicatorGetStyle(int indic) const
1005 {
1006 return SendMsg(2081, indic, 0);
1007 }
1008
1009 // Set the foreground colour of an indicator.
1010 void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore)
1011 {
1012 SendMsg(2082, indic, wxColourAsLong(fore));
1013 }
1014
1015 // Retrieve the foreground colour of an indicator.
1016 wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) const
1017 {
1018 long c = SendMsg(2083, indic, 0);
1019 return wxColourFromLong(c);
1020 }
1021
1022 // Set an indicator to draw under text or over(default).
1023 void wxStyledTextCtrl::IndicatorSetUnder(int indic, bool under)
1024 {
1025 SendMsg(2510, indic, under);
1026 }
1027
1028 // Retrieve whether indicator drawn under or over text.
1029 bool wxStyledTextCtrl::IndicatorGetUnder(int indic) const
1030 {
1031 return SendMsg(2511, indic, 0) != 0;
1032 }
1033
1034 // Set the foreground colour of all whitespace and whether to use this setting.
1035 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore)
1036 {
1037 SendMsg(2084, useSetting, wxColourAsLong(fore));
1038 }
1039
1040 // Set the background colour of all whitespace and whether to use this setting.
1041 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back)
1042 {
1043 SendMsg(2085, useSetting, wxColourAsLong(back));
1044 }
1045
1046 // Set the size of the dots used to mark space characters.
1047 void wxStyledTextCtrl::SetWhitespaceSize(int size)
1048 {
1049 SendMsg(2086, size, 0);
1050 }
1051
1052 // Get the size of the dots used to mark space characters.
1053 int wxStyledTextCtrl::GetWhitespaceSize() const
1054 {
1055 return SendMsg(2087, 0, 0);
1056 }
1057
1058 // Divide each styling byte into lexical class bits (default: 5) and indicator
1059 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
1060 // is used to expand the possible states.
1061 void wxStyledTextCtrl::SetStyleBits(int bits)
1062 {
1063 SendMsg(2090, bits, 0);
1064 }
1065
1066 // Retrieve number of bits in style bytes used to hold the lexical state.
1067 int wxStyledTextCtrl::GetStyleBits() const
1068 {
1069 return SendMsg(2091, 0, 0);
1070 }
1071
1072 // Used to hold extra styling information for each line.
1073 void wxStyledTextCtrl::SetLineState(int line, int state)
1074 {
1075 SendMsg(2092, line, state);
1076 }
1077
1078 // Retrieve the extra styling information for a line.
1079 int wxStyledTextCtrl::GetLineState(int line) const
1080 {
1081 return SendMsg(2093, line, 0);
1082 }
1083
1084 // Retrieve the last line number that has line state.
1085 int wxStyledTextCtrl::GetMaxLineState() const
1086 {
1087 return SendMsg(2094, 0, 0);
1088 }
1089
1090 // Is the background of the line containing the caret in a different colour?
1091 bool wxStyledTextCtrl::GetCaretLineVisible() const
1092 {
1093 return SendMsg(2095, 0, 0) != 0;
1094 }
1095
1096 // Display the background of the line containing the caret in a different colour.
1097 void wxStyledTextCtrl::SetCaretLineVisible(bool show)
1098 {
1099 SendMsg(2096, show, 0);
1100 }
1101
1102 // Get the colour of the background of the line containing the caret.
1103 wxColour wxStyledTextCtrl::GetCaretLineBackground() const
1104 {
1105 long c = SendMsg(2097, 0, 0);
1106 return wxColourFromLong(c);
1107 }
1108
1109 // Set the colour of the background of the line containing the caret.
1110 void wxStyledTextCtrl::SetCaretLineBackground(const wxColour& back)
1111 {
1112 SendMsg(2098, wxColourAsLong(back), 0);
1113 }
1114
1115 // Set a style to be changeable or not (read only).
1116 // Experimental feature, currently buggy.
1117 void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable)
1118 {
1119 SendMsg(2099, style, changeable);
1120 }
1121
1122 // Display a auto-completion list.
1123 // The lenEntered parameter indicates how many characters before
1124 // the caret should be used to provide context.
1125 void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList)
1126 {
1127 SendMsg(2100, lenEntered, (sptr_t)(const char*)wx2stc(itemList));
1128 }
1129
1130 // Remove the auto-completion list from the screen.
1131 void wxStyledTextCtrl::AutoCompCancel()
1132 {
1133 SendMsg(2101, 0, 0);
1134 }
1135
1136 // Is there an auto-completion list visible?
1137 bool wxStyledTextCtrl::AutoCompActive()
1138 {
1139 return SendMsg(2102, 0, 0) != 0;
1140 }
1141
1142 // Retrieve the position of the caret when the auto-completion list was displayed.
1143 int wxStyledTextCtrl::AutoCompPosStart()
1144 {
1145 return SendMsg(2103, 0, 0);
1146 }
1147
1148 // User has selected an item so remove the list and insert the selection.
1149 void wxStyledTextCtrl::AutoCompComplete()
1150 {
1151 SendMsg(2104, 0, 0);
1152 }
1153
1154 // Define a set of character that when typed cancel the auto-completion list.
1155 void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet)
1156 {
1157 SendMsg(2105, 0, (sptr_t)(const char*)wx2stc(characterSet));
1158 }
1159
1160 // Change the separator character in the string setting up an auto-completion list.
1161 // Default is space but can be changed if items contain space.
1162 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter)
1163 {
1164 SendMsg(2106, separatorCharacter, 0);
1165 }
1166
1167 // Retrieve the auto-completion list separator character.
1168 int wxStyledTextCtrl::AutoCompGetSeparator() const
1169 {
1170 return SendMsg(2107, 0, 0);
1171 }
1172
1173 // Select the item in the auto-completion list that starts with a string.
1174 void wxStyledTextCtrl::AutoCompSelect(const wxString& text)
1175 {
1176 SendMsg(2108, 0, (sptr_t)(const char*)wx2stc(text));
1177 }
1178
1179 // Should the auto-completion list be cancelled if the user backspaces to a
1180 // position before where the box was created.
1181 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel)
1182 {
1183 SendMsg(2110, cancel, 0);
1184 }
1185
1186 // Retrieve whether auto-completion cancelled by backspacing before start.
1187 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() const
1188 {
1189 return SendMsg(2111, 0, 0) != 0;
1190 }
1191
1192 // Define a set of characters that when typed will cause the autocompletion to
1193 // choose the selected item.
1194 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet)
1195 {
1196 SendMsg(2112, 0, (sptr_t)(const char*)wx2stc(characterSet));
1197 }
1198
1199 // Should a single item auto-completion list automatically choose the item.
1200 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle)
1201 {
1202 SendMsg(2113, chooseSingle, 0);
1203 }
1204
1205 // Retrieve whether a single item auto-completion list automatically choose the item.
1206 bool wxStyledTextCtrl::AutoCompGetChooseSingle() const
1207 {
1208 return SendMsg(2114, 0, 0) != 0;
1209 }
1210
1211 // Set whether case is significant when performing auto-completion searches.
1212 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase)
1213 {
1214 SendMsg(2115, ignoreCase, 0);
1215 }
1216
1217 // Retrieve state of ignore case flag.
1218 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() const
1219 {
1220 return SendMsg(2116, 0, 0) != 0;
1221 }
1222
1223 // Display a list of strings and send notification when user chooses one.
1224 void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList)
1225 {
1226 SendMsg(2117, listType, (sptr_t)(const char*)wx2stc(itemList));
1227 }
1228
1229 // Set whether or not autocompletion is hidden automatically when nothing matches.
1230 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide)
1231 {
1232 SendMsg(2118, autoHide, 0);
1233 }
1234
1235 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
1236 bool wxStyledTextCtrl::AutoCompGetAutoHide() const
1237 {
1238 return SendMsg(2119, 0, 0) != 0;
1239 }
1240
1241 // Set whether or not autocompletion deletes any word characters
1242 // after the inserted text upon completion.
1243 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord)
1244 {
1245 SendMsg(2270, dropRestOfWord, 0);
1246 }
1247
1248 // Retrieve whether or not autocompletion deletes any word characters
1249 // after the inserted text upon completion.
1250 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() const
1251 {
1252 return SendMsg(2271, 0, 0) != 0;
1253 }
1254
1255 // Register an image for use in autocompletion lists.
1256 void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
1257 // convert bmp to a xpm in a string
1258 wxMemoryOutputStream strm;
1259 wxImage img = bmp.ConvertToImage();
1260 if (img.HasAlpha())
1261 img.ConvertAlphaToMask();
1262 img.SaveFile(strm, wxBITMAP_TYPE_XPM);
1263 size_t len = strm.GetSize();
1264 char* buff = new char[len+1];
1265 strm.CopyTo(buff, len);
1266 buff[len] = 0;
1267 SendMsg(2405, type, (sptr_t)buff);
1268 delete [] buff;
1269
1270 }
1271
1272 // Clear all the registered images.
1273 void wxStyledTextCtrl::ClearRegisteredImages()
1274 {
1275 SendMsg(2408, 0, 0);
1276 }
1277
1278 // Retrieve the auto-completion list type-separator character.
1279 int wxStyledTextCtrl::AutoCompGetTypeSeparator() const
1280 {
1281 return SendMsg(2285, 0, 0);
1282 }
1283
1284 // Change the type-separator character in the string setting up an auto-completion list.
1285 // Default is '?' but can be changed if items contain '?'.
1286 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter)
1287 {
1288 SendMsg(2286, separatorCharacter, 0);
1289 }
1290
1291 // Set the maximum width, in characters, of auto-completion and user lists.
1292 // Set to 0 to autosize to fit longest item, which is the default.
1293 void wxStyledTextCtrl::AutoCompSetMaxWidth(int characterCount)
1294 {
1295 SendMsg(2208, characterCount, 0);
1296 }
1297
1298 // Get the maximum width, in characters, of auto-completion and user lists.
1299 int wxStyledTextCtrl::AutoCompGetMaxWidth() const
1300 {
1301 return SendMsg(2209, 0, 0);
1302 }
1303
1304 // Set the maximum height, in rows, of auto-completion and user lists.
1305 // The default is 5 rows.
1306 void wxStyledTextCtrl::AutoCompSetMaxHeight(int rowCount)
1307 {
1308 SendMsg(2210, rowCount, 0);
1309 }
1310
1311 // Set the maximum height, in rows, of auto-completion and user lists.
1312 int wxStyledTextCtrl::AutoCompGetMaxHeight() const
1313 {
1314 return SendMsg(2211, 0, 0);
1315 }
1316
1317 // Set the number of spaces used for one level of indentation.
1318 void wxStyledTextCtrl::SetIndent(int indentSize)
1319 {
1320 SendMsg(2122, indentSize, 0);
1321 }
1322
1323 // Retrieve indentation size.
1324 int wxStyledTextCtrl::GetIndent() const
1325 {
1326 return SendMsg(2123, 0, 0);
1327 }
1328
1329 // Indentation will only use space characters if useTabs is false, otherwise
1330 // it will use a combination of tabs and spaces.
1331 void wxStyledTextCtrl::SetUseTabs(bool useTabs)
1332 {
1333 SendMsg(2124, useTabs, 0);
1334 }
1335
1336 // Retrieve whether tabs will be used in indentation.
1337 bool wxStyledTextCtrl::GetUseTabs() const
1338 {
1339 return SendMsg(2125, 0, 0) != 0;
1340 }
1341
1342 // Change the indentation of a line to a number of columns.
1343 void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize)
1344 {
1345 SendMsg(2126, line, indentSize);
1346 }
1347
1348 // Retrieve the number of columns that a line is indented.
1349 int wxStyledTextCtrl::GetLineIndentation(int line) const
1350 {
1351 return SendMsg(2127, line, 0);
1352 }
1353
1354 // Retrieve the position before the first non indentation character on a line.
1355 int wxStyledTextCtrl::GetLineIndentPosition(int line) const
1356 {
1357 return SendMsg(2128, line, 0);
1358 }
1359
1360 // Retrieve the column number of a position, taking tab width into account.
1361 int wxStyledTextCtrl::GetColumn(int pos) const
1362 {
1363 return SendMsg(2129, pos, 0);
1364 }
1365
1366 // Count characters between two positions.
1367 int wxStyledTextCtrl::CountCharacters(int startPos, int endPos)
1368 {
1369 return SendMsg(2633, startPos, endPos);
1370 }
1371
1372 // Show or hide the horizontal scroll bar.
1373 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show)
1374 {
1375 SendMsg(2130, show, 0);
1376 }
1377
1378 // Is the horizontal scroll bar visible?
1379 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() const
1380 {
1381 return SendMsg(2131, 0, 0) != 0;
1382 }
1383
1384 // Show or hide indentation guides.
1385 void wxStyledTextCtrl::SetIndentationGuides(int indentView)
1386 {
1387 SendMsg(2132, indentView, 0);
1388 }
1389
1390 // Are the indentation guides visible?
1391 int wxStyledTextCtrl::GetIndentationGuides() const
1392 {
1393 return SendMsg(2133, 0, 0);
1394 }
1395
1396 // Set the highlighted indentation guide column.
1397 // 0 = no highlighted guide.
1398 void wxStyledTextCtrl::SetHighlightGuide(int column)
1399 {
1400 SendMsg(2134, column, 0);
1401 }
1402
1403 // Get the highlighted indentation guide column.
1404 int wxStyledTextCtrl::GetHighlightGuide() const
1405 {
1406 return SendMsg(2135, 0, 0);
1407 }
1408
1409 // Get the position after the last visible characters on a line.
1410 int wxStyledTextCtrl::GetLineEndPosition(int line) const
1411 {
1412 return SendMsg(2136, line, 0);
1413 }
1414
1415 // Get the code page used to interpret the bytes of the document as characters.
1416 int wxStyledTextCtrl::GetCodePage() const
1417 {
1418 return SendMsg(2137, 0, 0);
1419 }
1420
1421 // Get the foreground colour of the caret.
1422 wxColour wxStyledTextCtrl::GetCaretForeground() const
1423 {
1424 long c = SendMsg(2138, 0, 0);
1425 return wxColourFromLong(c);
1426 }
1427
1428 // In read-only mode?
1429 bool wxStyledTextCtrl::GetReadOnly() const
1430 {
1431 return SendMsg(2140, 0, 0) != 0;
1432 }
1433
1434 // Sets the position of the caret.
1435 void wxStyledTextCtrl::SetCurrentPos(int pos)
1436 {
1437 SendMsg(2141, pos, 0);
1438 }
1439
1440 // Sets the position that starts the selection - this becomes the anchor.
1441 void wxStyledTextCtrl::SetSelectionStart(int pos)
1442 {
1443 SendMsg(2142, pos, 0);
1444 }
1445
1446 // Returns the position at the start of the selection.
1447 int wxStyledTextCtrl::GetSelectionStart() const
1448 {
1449 return SendMsg(2143, 0, 0);
1450 }
1451
1452 // Sets the position that ends the selection - this becomes the currentPosition.
1453 void wxStyledTextCtrl::SetSelectionEnd(int pos)
1454 {
1455 SendMsg(2144, pos, 0);
1456 }
1457
1458 // Returns the position at the end of the selection.
1459 int wxStyledTextCtrl::GetSelectionEnd() const
1460 {
1461 return SendMsg(2145, 0, 0);
1462 }
1463
1464 // Set caret to a position, while removing any existing selection.
1465 void wxStyledTextCtrl::SetEmptySelection(int pos)
1466 {
1467 SendMsg(2556, pos, 0);
1468 }
1469
1470 // Sets the print magnification added to the point size of each style for printing.
1471 void wxStyledTextCtrl::SetPrintMagnification(int magnification)
1472 {
1473 SendMsg(2146, magnification, 0);
1474 }
1475
1476 // Returns the print magnification.
1477 int wxStyledTextCtrl::GetPrintMagnification() const
1478 {
1479 return SendMsg(2147, 0, 0);
1480 }
1481
1482 // Modify colours when printing for clearer printed text.
1483 void wxStyledTextCtrl::SetPrintColourMode(int mode)
1484 {
1485 SendMsg(2148, mode, 0);
1486 }
1487
1488 // Returns the print colour mode.
1489 int wxStyledTextCtrl::GetPrintColourMode() const
1490 {
1491 return SendMsg(2149, 0, 0);
1492 }
1493
1494 // Find some text in the document.
1495 int wxStyledTextCtrl::FindText(int minPos, int maxPos,
1496 const wxString& text,
1497 int flags) {
1498 TextToFind ft;
1499 ft.chrg.cpMin = minPos;
1500 ft.chrg.cpMax = maxPos;
1501 const wxWX2MBbuf buf = wx2stc(text);
1502 ft.lpstrText = (char*)(const char*)buf;
1503
1504 return SendMsg(2150, flags, (sptr_t)&ft);
1505 }
1506
1507 // On Windows, will draw the document into a display context such as a printer.
1508 int wxStyledTextCtrl::FormatRange(bool doDraw,
1509 int startPos,
1510 int endPos,
1511 wxDC* draw,
1512 wxDC* target,
1513 wxRect renderRect,
1514 wxRect pageRect) {
1515 RangeToFormat fr;
1516
1517 if (endPos < startPos) {
1518 int temp = startPos;
1519 startPos = endPos;
1520 endPos = temp;
1521 }
1522 fr.hdc = draw;
1523 fr.hdcTarget = target;
1524 fr.rc.top = renderRect.GetTop();
1525 fr.rc.left = renderRect.GetLeft();
1526 fr.rc.right = renderRect.GetRight();
1527 fr.rc.bottom = renderRect.GetBottom();
1528 fr.rcPage.top = pageRect.GetTop();
1529 fr.rcPage.left = pageRect.GetLeft();
1530 fr.rcPage.right = pageRect.GetRight();
1531 fr.rcPage.bottom = pageRect.GetBottom();
1532 fr.chrg.cpMin = startPos;
1533 fr.chrg.cpMax = endPos;
1534
1535 return SendMsg(2151, doDraw, (sptr_t)&fr);
1536 }
1537
1538 // Retrieve the display line at the top of the display.
1539 int wxStyledTextCtrl::GetFirstVisibleLine() const
1540 {
1541 return SendMsg(2152, 0, 0);
1542 }
1543
1544 // Retrieve the contents of a line.
1545 wxString wxStyledTextCtrl::GetLine(int line) const {
1546 int len = LineLength(line);
1547 if (!len) return wxEmptyString;
1548
1549 wxMemoryBuffer mbuf(len+1);
1550 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1551 SendMsg(2153, line, (sptr_t)buf);
1552 mbuf.UngetWriteBuf(len);
1553 mbuf.AppendByte(0);
1554 return stc2wx(buf);
1555 }
1556
1557 // Returns the number of lines in the document. There is always at least one.
1558 int wxStyledTextCtrl::GetLineCount() const
1559 {
1560 return SendMsg(2154, 0, 0);
1561 }
1562
1563 // Sets the size in pixels of the left margin.
1564 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth)
1565 {
1566 SendMsg(2155, 0, pixelWidth);
1567 }
1568
1569 // Returns the size in pixels of the left margin.
1570 int wxStyledTextCtrl::GetMarginLeft() const
1571 {
1572 return SendMsg(2156, 0, 0);
1573 }
1574
1575 // Sets the size in pixels of the right margin.
1576 void wxStyledTextCtrl::SetMarginRight(int pixelWidth)
1577 {
1578 SendMsg(2157, 0, pixelWidth);
1579 }
1580
1581 // Returns the size in pixels of the right margin.
1582 int wxStyledTextCtrl::GetMarginRight() const
1583 {
1584 return SendMsg(2158, 0, 0);
1585 }
1586
1587 // Is the document different from when it was last saved?
1588 bool wxStyledTextCtrl::GetModify() const
1589 {
1590 return SendMsg(2159, 0, 0) != 0;
1591 }
1592
1593 // Retrieve the selected text.
1594 wxString wxStyledTextCtrl::GetSelectedText() {
1595 const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
1596 if (!len) return wxEmptyString;
1597
1598 wxMemoryBuffer mbuf(len+2);
1599 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1600 SendMsg(2161, 0, (sptr_t)buf);
1601 mbuf.UngetWriteBuf(len);
1602 mbuf.AppendByte(0);
1603 return stc2wx(buf);
1604 }
1605
1606 // Retrieve a range of text.
1607 wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) {
1608 if (endPos < startPos) {
1609 int temp = startPos;
1610 startPos = endPos;
1611 endPos = temp;
1612 }
1613 int len = endPos - startPos;
1614 if (!len) return wxEmptyString;
1615 wxMemoryBuffer mbuf(len+1);
1616 char* buf = (char*)mbuf.GetWriteBuf(len);
1617 TextRange tr;
1618 tr.lpstrText = buf;
1619 tr.chrg.cpMin = startPos;
1620 tr.chrg.cpMax = endPos;
1621 SendMsg(2162, 0, (sptr_t)&tr);
1622 mbuf.UngetWriteBuf(len);
1623 mbuf.AppendByte(0);
1624 return stc2wx(buf);
1625 }
1626
1627 // Draw the selection in normal style or with selection highlighted.
1628 void wxStyledTextCtrl::HideSelection(bool normal)
1629 {
1630 SendMsg(2163, normal, 0);
1631 }
1632
1633 // Retrieve the line containing a position.
1634 int wxStyledTextCtrl::LineFromPosition(int pos) const
1635 {
1636 return SendMsg(2166, pos, 0);
1637 }
1638
1639 // Retrieve the position at the start of a line.
1640 int wxStyledTextCtrl::PositionFromLine(int line) const
1641 {
1642 return SendMsg(2167, line, 0);
1643 }
1644
1645 // Scroll horizontally and vertically.
1646 void wxStyledTextCtrl::LineScroll(int columns, int lines)
1647 {
1648 SendMsg(2168, columns, lines);
1649 }
1650
1651 // Ensure the caret is visible.
1652 void wxStyledTextCtrl::EnsureCaretVisible()
1653 {
1654 SendMsg(2169, 0, 0);
1655 }
1656
1657 // Replace the selected text with the argument text.
1658 void wxStyledTextCtrl::ReplaceSelection(const wxString& text)
1659 {
1660 SendMsg(2170, 0, (sptr_t)(const char*)wx2stc(text));
1661 }
1662
1663 // Set to read only or read write.
1664 void wxStyledTextCtrl::SetReadOnly(bool readOnly)
1665 {
1666 SendMsg(2171, readOnly, 0);
1667 }
1668
1669 // Will a paste succeed?
1670 bool wxStyledTextCtrl::CanPaste() const
1671 {
1672 return SendMsg(2173, 0, 0) != 0;
1673 }
1674
1675 // Are there any undoable actions in the undo history?
1676 bool wxStyledTextCtrl::CanUndo() const
1677 {
1678 return SendMsg(2174, 0, 0) != 0;
1679 }
1680
1681 // Delete the undo history.
1682 void wxStyledTextCtrl::EmptyUndoBuffer()
1683 {
1684 SendMsg(2175, 0, 0);
1685 }
1686
1687 // Undo one action in the undo history.
1688 void wxStyledTextCtrl::Undo()
1689 {
1690 SendMsg(2176, 0, 0);
1691 }
1692
1693 // Cut the selection to the clipboard.
1694 void wxStyledTextCtrl::Cut()
1695 {
1696 SendMsg(2177, 0, 0);
1697 }
1698
1699 // Copy the selection to the clipboard.
1700 void wxStyledTextCtrl::Copy()
1701 {
1702 SendMsg(2178, 0, 0);
1703 }
1704
1705 // Paste the contents of the clipboard into the document replacing the selection.
1706 void wxStyledTextCtrl::Paste()
1707 {
1708 SendMsg(2179, 0, 0);
1709 }
1710
1711 // Clear the selection.
1712 void wxStyledTextCtrl::Clear()
1713 {
1714 SendMsg(2180, 0, 0);
1715 }
1716
1717 // Replace the contents of the document with the argument text.
1718 void wxStyledTextCtrl::SetText(const wxString& text)
1719 {
1720 SendMsg(2181, 0, (sptr_t)(const char*)wx2stc(text));
1721 }
1722
1723 // Retrieve all the text in the document.
1724 wxString wxStyledTextCtrl::GetText() const {
1725 int len = GetTextLength();
1726 wxMemoryBuffer mbuf(len+1); // leave room for the null...
1727 char* buf = (char*)mbuf.GetWriteBuf(len+1);
1728 SendMsg(2182, len+1, (sptr_t)buf);
1729 mbuf.UngetWriteBuf(len);
1730 mbuf.AppendByte(0);
1731 return stc2wx(buf);
1732 }
1733
1734 // Retrieve the number of characters in the document.
1735 int wxStyledTextCtrl::GetTextLength() const
1736 {
1737 return SendMsg(2183, 0, 0);
1738 }
1739
1740 // Set to overtype (true) or insert mode.
1741 void wxStyledTextCtrl::SetOvertype(bool overtype)
1742 {
1743 SendMsg(2186, overtype, 0);
1744 }
1745
1746 // Returns true if overtype mode is active otherwise false is returned.
1747 bool wxStyledTextCtrl::GetOvertype() const
1748 {
1749 return SendMsg(2187, 0, 0) != 0;
1750 }
1751
1752 // Set the width of the insert mode caret.
1753 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth)
1754 {
1755 SendMsg(2188, pixelWidth, 0);
1756 }
1757
1758 // Returns the width of the insert mode caret.
1759 int wxStyledTextCtrl::GetCaretWidth() const
1760 {
1761 return SendMsg(2189, 0, 0);
1762 }
1763
1764 // Sets the position that starts the target which is used for updating the
1765 // document without affecting the scroll position.
1766 void wxStyledTextCtrl::SetTargetStart(int pos)
1767 {
1768 SendMsg(2190, pos, 0);
1769 }
1770
1771 // Get the position that starts the target.
1772 int wxStyledTextCtrl::GetTargetStart() const
1773 {
1774 return SendMsg(2191, 0, 0);
1775 }
1776
1777 // Sets the position that ends the target which is used for updating the
1778 // document without affecting the scroll position.
1779 void wxStyledTextCtrl::SetTargetEnd(int pos)
1780 {
1781 SendMsg(2192, pos, 0);
1782 }
1783
1784 // Get the position that ends the target.
1785 int wxStyledTextCtrl::GetTargetEnd() const
1786 {
1787 return SendMsg(2193, 0, 0);
1788 }
1789
1790 // Replace the target text with the argument text.
1791 // Text is counted so it can contain NULs.
1792 // Returns the length of the replacement text.
1793
1794 int wxStyledTextCtrl::ReplaceTarget(const wxString& text) {
1795 const wxWX2MBbuf buf = wx2stc(text);
1796 return SendMsg(2194, wx2stclen(text, buf), (sptr_t)(const char*)buf);
1797 }
1798
1799 // Replace the target text with the argument text after \\d processing.
1800 // Text is counted so it can contain NULs.
1801 // Looks for \\d where d is between 1 and 9 and replaces these with the strings
1802 // matched in the last search operation which were surrounded by \( and \).
1803 // Returns the length of the replacement text including any change
1804 // caused by processing the \\d patterns.
1805
1806 int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) {
1807 const wxWX2MBbuf buf = wx2stc(text);
1808 return SendMsg(2195, wx2stclen(text, buf), (sptr_t)(const char*)buf);
1809 }
1810
1811 // Search for a counted string in the target and set the target to the found
1812 // range. Text is counted so it can contain NULs.
1813 // Returns length of range or -1 for failure in which case target is not moved.
1814
1815 int wxStyledTextCtrl::SearchInTarget(const wxString& text) {
1816 const wxWX2MBbuf buf = wx2stc(text);
1817 return SendMsg(2197, wx2stclen(text, buf), (sptr_t)(const char*)buf);
1818 }
1819
1820 // Set the search flags used by SearchInTarget.
1821 void wxStyledTextCtrl::SetSearchFlags(int flags)
1822 {
1823 SendMsg(2198, flags, 0);
1824 }
1825
1826 // Get the search flags used by SearchInTarget.
1827 int wxStyledTextCtrl::GetSearchFlags() const
1828 {
1829 return SendMsg(2199, 0, 0);
1830 }
1831
1832 // Show a call tip containing a definition near position pos.
1833 void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition)
1834 {
1835 SendMsg(2200, pos, (sptr_t)(const char*)wx2stc(definition));
1836 }
1837
1838 // Remove the call tip from the screen.
1839 void wxStyledTextCtrl::CallTipCancel()
1840 {
1841 SendMsg(2201, 0, 0);
1842 }
1843
1844 // Is there an active call tip?
1845 bool wxStyledTextCtrl::CallTipActive()
1846 {
1847 return SendMsg(2202, 0, 0) != 0;
1848 }
1849
1850 // Retrieve the position where the caret was before displaying the call tip.
1851 int wxStyledTextCtrl::CallTipPosAtStart()
1852 {
1853 return SendMsg(2203, 0, 0);
1854 }
1855
1856 // Highlight a segment of the definition.
1857 void wxStyledTextCtrl::CallTipSetHighlight(int start, int end)
1858 {
1859 SendMsg(2204, start, end);
1860 }
1861
1862 // Set the background colour for the call tip.
1863 void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back)
1864 {
1865 SendMsg(2205, wxColourAsLong(back), 0);
1866 }
1867
1868 // Set the foreground colour for the call tip.
1869 void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore)
1870 {
1871 SendMsg(2206, wxColourAsLong(fore), 0);
1872 }
1873
1874 // Set the foreground colour for the highlighted part of the call tip.
1875 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore)
1876 {
1877 SendMsg(2207, wxColourAsLong(fore), 0);
1878 }
1879
1880 // Enable use of STYLE_CALLTIP and set call tip tab size in pixels.
1881 void wxStyledTextCtrl::CallTipUseStyle(int tabSize)
1882 {
1883 SendMsg(2212, tabSize, 0);
1884 }
1885
1886 // Set position of calltip, above or below text.
1887 void wxStyledTextCtrl::CallTipSetPosition(bool above)
1888 {
1889 SendMsg(2213, above, 0);
1890 }
1891
1892 // Find the display line of a document line taking hidden lines into account.
1893 int wxStyledTextCtrl::VisibleFromDocLine(int line)
1894 {
1895 return SendMsg(2220, line, 0);
1896 }
1897
1898 // Find the document line of a display line taking hidden lines into account.
1899 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay)
1900 {
1901 return SendMsg(2221, lineDisplay, 0);
1902 }
1903
1904 // The number of display lines needed to wrap a document line
1905 int wxStyledTextCtrl::WrapCount(int line)
1906 {
1907 return SendMsg(2235, line, 0);
1908 }
1909
1910 // Set the fold level of a line.
1911 // This encodes an integer level along with flags indicating whether the
1912 // line is a header and whether it is effectively white space.
1913 void wxStyledTextCtrl::SetFoldLevel(int line, int level)
1914 {
1915 SendMsg(2222, line, level);
1916 }
1917
1918 // Retrieve the fold level of a line.
1919 int wxStyledTextCtrl::GetFoldLevel(int line) const
1920 {
1921 return SendMsg(2223, line, 0);
1922 }
1923
1924 // Find the last child line of a header line.
1925 int wxStyledTextCtrl::GetLastChild(int line, int level) const
1926 {
1927 return SendMsg(2224, line, level);
1928 }
1929
1930 // Find the parent line of a child line.
1931 int wxStyledTextCtrl::GetFoldParent(int line) const
1932 {
1933 return SendMsg(2225, line, 0);
1934 }
1935
1936 // Make a range of lines visible.
1937 void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd)
1938 {
1939 SendMsg(2226, lineStart, lineEnd);
1940 }
1941
1942 // Make a range of lines invisible.
1943 void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd)
1944 {
1945 SendMsg(2227, lineStart, lineEnd);
1946 }
1947
1948 // Is a line visible?
1949 bool wxStyledTextCtrl::GetLineVisible(int line) const
1950 {
1951 return SendMsg(2228, line, 0) != 0;
1952 }
1953
1954 // Are all lines visible?
1955 bool wxStyledTextCtrl::GetAllLinesVisible() const
1956 {
1957 return SendMsg(2236, 0, 0) != 0;
1958 }
1959
1960 // Show the children of a header line.
1961 void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded)
1962 {
1963 SendMsg(2229, line, expanded);
1964 }
1965
1966 // Is a header line expanded?
1967 bool wxStyledTextCtrl::GetFoldExpanded(int line) const
1968 {
1969 return SendMsg(2230, line, 0) != 0;
1970 }
1971
1972 // Switch a header line between expanded and contracted.
1973 void wxStyledTextCtrl::ToggleFold(int line)
1974 {
1975 SendMsg(2231, line, 0);
1976 }
1977
1978 // Ensure a particular line is visible by expanding any header line hiding it.
1979 void wxStyledTextCtrl::EnsureVisible(int line)
1980 {
1981 SendMsg(2232, line, 0);
1982 }
1983
1984 // Set some style options for folding.
1985 void wxStyledTextCtrl::SetFoldFlags(int flags)
1986 {
1987 SendMsg(2233, flags, 0);
1988 }
1989
1990 // Ensure a particular line is visible by expanding any header line hiding it.
1991 // Use the currently set visibility policy to determine which range to display.
1992 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line)
1993 {
1994 SendMsg(2234, line, 0);
1995 }
1996
1997 // Sets whether a tab pressed when caret is within indentation indents.
1998 void wxStyledTextCtrl::SetTabIndents(bool tabIndents)
1999 {
2000 SendMsg(2260, tabIndents, 0);
2001 }
2002
2003 // Does a tab pressed when caret is within indentation indent?
2004 bool wxStyledTextCtrl::GetTabIndents() const
2005 {
2006 return SendMsg(2261, 0, 0) != 0;
2007 }
2008
2009 // Sets whether a backspace pressed when caret is within indentation unindents.
2010 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents)
2011 {
2012 SendMsg(2262, bsUnIndents, 0);
2013 }
2014
2015 // Does a backspace pressed when caret is within indentation unindent?
2016 bool wxStyledTextCtrl::GetBackSpaceUnIndents() const
2017 {
2018 return SendMsg(2263, 0, 0) != 0;
2019 }
2020
2021 // Sets the time the mouse must sit still to generate a mouse dwell event.
2022 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds)
2023 {
2024 SendMsg(2264, periodMilliseconds, 0);
2025 }
2026
2027 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
2028 int wxStyledTextCtrl::GetMouseDwellTime() const
2029 {
2030 return SendMsg(2265, 0, 0);
2031 }
2032
2033 // Get position of start of word.
2034 int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters)
2035 {
2036 return SendMsg(2266, pos, onlyWordCharacters);
2037 }
2038
2039 // Get position of end of word.
2040 int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters)
2041 {
2042 return SendMsg(2267, pos, onlyWordCharacters);
2043 }
2044
2045 // Sets whether text is word wrapped.
2046 void wxStyledTextCtrl::SetWrapMode(int mode)
2047 {
2048 SendMsg(2268, mode, 0);
2049 }
2050
2051 // Retrieve whether text is word wrapped.
2052 int wxStyledTextCtrl::GetWrapMode() const
2053 {
2054 return SendMsg(2269, 0, 0);
2055 }
2056
2057 // Set the display mode of visual flags for wrapped lines.
2058 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags)
2059 {
2060 SendMsg(2460, wrapVisualFlags, 0);
2061 }
2062
2063 // Retrive the display mode of visual flags for wrapped lines.
2064 int wxStyledTextCtrl::GetWrapVisualFlags() const
2065 {
2066 return SendMsg(2461, 0, 0);
2067 }
2068
2069 // Set the location of visual flags for wrapped lines.
2070 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation)
2071 {
2072 SendMsg(2462, wrapVisualFlagsLocation, 0);
2073 }
2074
2075 // Retrive the location of visual flags for wrapped lines.
2076 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() const
2077 {
2078 return SendMsg(2463, 0, 0);
2079 }
2080
2081 // Set the start indent for wrapped lines.
2082 void wxStyledTextCtrl::SetWrapStartIndent(int indent)
2083 {
2084 SendMsg(2464, indent, 0);
2085 }
2086
2087 // Retrive the start indent for wrapped lines.
2088 int wxStyledTextCtrl::GetWrapStartIndent() const
2089 {
2090 return SendMsg(2465, 0, 0);
2091 }
2092
2093 // Sets how wrapped sublines are placed. Default is fixed.
2094 void wxStyledTextCtrl::SetWrapIndentMode(int mode)
2095 {
2096 SendMsg(2472, mode, 0);
2097 }
2098
2099 // Retrieve how wrapped sublines are placed. Default is fixed.
2100 int wxStyledTextCtrl::GetWrapIndentMode() const
2101 {
2102 return SendMsg(2473, 0, 0);
2103 }
2104
2105 // Sets the degree of caching of layout information.
2106 void wxStyledTextCtrl::SetLayoutCache(int mode)
2107 {
2108 SendMsg(2272, mode, 0);
2109 }
2110
2111 // Retrieve the degree of caching of layout information.
2112 int wxStyledTextCtrl::GetLayoutCache() const
2113 {
2114 return SendMsg(2273, 0, 0);
2115 }
2116
2117 // Sets the document width assumed for scrolling.
2118 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth)
2119 {
2120 SendMsg(2274, pixelWidth, 0);
2121 }
2122
2123 // Retrieve the document width assumed for scrolling.
2124 int wxStyledTextCtrl::GetScrollWidth() const
2125 {
2126 return SendMsg(2275, 0, 0);
2127 }
2128
2129 // Sets whether the maximum width line displayed is used to set scroll width.
2130 void wxStyledTextCtrl::SetScrollWidthTracking(bool tracking)
2131 {
2132 SendMsg(2516, tracking, 0);
2133 }
2134
2135 // Retrieve whether the scroll width tracks wide lines.
2136 bool wxStyledTextCtrl::GetScrollWidthTracking() const
2137 {
2138 return SendMsg(2517, 0, 0) != 0;
2139 }
2140
2141 // Measure the pixel width of some text in a particular style.
2142 // NUL terminated text argument.
2143 // Does not handle tab or control characters.
2144 int wxStyledTextCtrl::TextWidth(int style, const wxString& text)
2145 {
2146 return SendMsg(2276, style, (sptr_t)(const char*)wx2stc(text));
2147 }
2148
2149 // Sets the scroll range so that maximum scroll position has
2150 // the last line at the bottom of the view (default).
2151 // Setting this to false allows scrolling one page below the last line.
2152 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine)
2153 {
2154 SendMsg(2277, endAtLastLine, 0);
2155 }
2156
2157 // Retrieve whether the maximum scroll position has the last
2158 // line at the bottom of the view.
2159 bool wxStyledTextCtrl::GetEndAtLastLine() const
2160 {
2161 return SendMsg(2278, 0, 0) != 0;
2162 }
2163
2164 // Retrieve the height of a particular line of text in pixels.
2165 int wxStyledTextCtrl::TextHeight(int line)
2166 {
2167 return SendMsg(2279, line, 0);
2168 }
2169
2170 // Show or hide the vertical scroll bar.
2171 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show)
2172 {
2173 SendMsg(2280, show, 0);
2174 }
2175
2176 // Is the vertical scroll bar visible?
2177 bool wxStyledTextCtrl::GetUseVerticalScrollBar() const
2178 {
2179 return SendMsg(2281, 0, 0) != 0;
2180 }
2181
2182 // Append a string to the end of the document without changing the selection.
2183 void wxStyledTextCtrl::AppendText(const wxString& text) {
2184 const wxWX2MBbuf buf = wx2stc(text);
2185 SendMsg(2282, wx2stclen(text, buf), (sptr_t)(const char*)buf);
2186 }
2187
2188 // Is drawing done in two phases with backgrounds drawn before foregrounds?
2189 bool wxStyledTextCtrl::GetTwoPhaseDraw() const
2190 {
2191 return SendMsg(2283, 0, 0) != 0;
2192 }
2193
2194 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
2195 // and then the foreground. This avoids chopping off characters that overlap the next run.
2196 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase)
2197 {
2198 SendMsg(2284, twoPhase, 0);
2199 }
2200
2201 // Scroll so that a display line is at the top of the display.
2202 void wxStyledTextCtrl::SetFirstVisibleLine(int lineDisplay)
2203 {
2204 SendMsg(2613, lineDisplay, 0);
2205 }
2206
2207 // Change the effect of pasting when there are multiple selections.
2208 void wxStyledTextCtrl::SetMultiPaste(int multiPaste)
2209 {
2210 SendMsg(2614, multiPaste, 0);
2211 }
2212
2213 // Retrieve the effect of pasting when there are multiple selections.
2214 int wxStyledTextCtrl::GetMultiPaste() const
2215 {
2216 return SendMsg(2615, 0, 0);
2217 }
2218
2219 // Retrieve the value of a tag from a regular expression search.
2220 wxString wxStyledTextCtrl::GetTag(int tagNumber) const {
2221 int msg = 2616;
2222 int len = SendMsg(msg, tagNumber, (sptr_t)NULL);
2223 if (!len) return wxEmptyString;
2224
2225 wxMemoryBuffer mbuf(len+1);
2226 char* buf = (char*)mbuf.GetWriteBuf(len+1);
2227 SendMsg(msg, tagNumber, (sptr_t)buf);
2228 mbuf.UngetWriteBuf(len);
2229 mbuf.AppendByte(0);
2230 return stc2wx(buf);
2231 }
2232
2233 // Make the target range start and end be the same as the selection range start and end.
2234 void wxStyledTextCtrl::TargetFromSelection()
2235 {
2236 SendMsg(2287, 0, 0);
2237 }
2238
2239 // Join the lines in the target.
2240 void wxStyledTextCtrl::LinesJoin()
2241 {
2242 SendMsg(2288, 0, 0);
2243 }
2244
2245 // Split the lines in the target into lines that are less wide than pixelWidth
2246 // where possible.
2247 void wxStyledTextCtrl::LinesSplit(int pixelWidth)
2248 {
2249 SendMsg(2289, pixelWidth, 0);
2250 }
2251
2252 // Set the colours used as a chequerboard pattern in the fold margin
2253 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back)
2254 {
2255 SendMsg(2290, useSetting, wxColourAsLong(back));
2256 }
2257 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore)
2258 {
2259 SendMsg(2291, useSetting, wxColourAsLong(fore));
2260 }
2261
2262 // Move caret down one line.
2263 void wxStyledTextCtrl::LineDown()
2264 {
2265 SendMsg(2300, 0, 0);
2266 }
2267
2268 // Move caret down one line extending selection to new caret position.
2269 void wxStyledTextCtrl::LineDownExtend()
2270 {
2271 SendMsg(2301, 0, 0);
2272 }
2273
2274 // Move caret up one line.
2275 void wxStyledTextCtrl::LineUp()
2276 {
2277 SendMsg(2302, 0, 0);
2278 }
2279
2280 // Move caret up one line extending selection to new caret position.
2281 void wxStyledTextCtrl::LineUpExtend()
2282 {
2283 SendMsg(2303, 0, 0);
2284 }
2285
2286 // Move caret left one character.
2287 void wxStyledTextCtrl::CharLeft()
2288 {
2289 SendMsg(2304, 0, 0);
2290 }
2291
2292 // Move caret left one character extending selection to new caret position.
2293 void wxStyledTextCtrl::CharLeftExtend()
2294 {
2295 SendMsg(2305, 0, 0);
2296 }
2297
2298 // Move caret right one character.
2299 void wxStyledTextCtrl::CharRight()
2300 {
2301 SendMsg(2306, 0, 0);
2302 }
2303
2304 // Move caret right one character extending selection to new caret position.
2305 void wxStyledTextCtrl::CharRightExtend()
2306 {
2307 SendMsg(2307, 0, 0);
2308 }
2309
2310 // Move caret left one word.
2311 void wxStyledTextCtrl::WordLeft()
2312 {
2313 SendMsg(2308, 0, 0);
2314 }
2315
2316 // Move caret left one word extending selection to new caret position.
2317 void wxStyledTextCtrl::WordLeftExtend()
2318 {
2319 SendMsg(2309, 0, 0);
2320 }
2321
2322 // Move caret right one word.
2323 void wxStyledTextCtrl::WordRight()
2324 {
2325 SendMsg(2310, 0, 0);
2326 }
2327
2328 // Move caret right one word extending selection to new caret position.
2329 void wxStyledTextCtrl::WordRightExtend()
2330 {
2331 SendMsg(2311, 0, 0);
2332 }
2333
2334 // Move caret to first position on line.
2335 void wxStyledTextCtrl::Home()
2336 {
2337 SendMsg(2312, 0, 0);
2338 }
2339
2340 // Move caret to first position on line extending selection to new caret position.
2341 void wxStyledTextCtrl::HomeExtend()
2342 {
2343 SendMsg(2313, 0, 0);
2344 }
2345
2346 // Move caret to last position on line.
2347 void wxStyledTextCtrl::LineEnd()
2348 {
2349 SendMsg(2314, 0, 0);
2350 }
2351
2352 // Move caret to last position on line extending selection to new caret position.
2353 void wxStyledTextCtrl::LineEndExtend()
2354 {
2355 SendMsg(2315, 0, 0);
2356 }
2357
2358 // Move caret to first position in document.
2359 void wxStyledTextCtrl::DocumentStart()
2360 {
2361 SendMsg(2316, 0, 0);
2362 }
2363
2364 // Move caret to first position in document extending selection to new caret position.
2365 void wxStyledTextCtrl::DocumentStartExtend()
2366 {
2367 SendMsg(2317, 0, 0);
2368 }
2369
2370 // Move caret to last position in document.
2371 void wxStyledTextCtrl::DocumentEnd()
2372 {
2373 SendMsg(2318, 0, 0);
2374 }
2375
2376 // Move caret to last position in document extending selection to new caret position.
2377 void wxStyledTextCtrl::DocumentEndExtend()
2378 {
2379 SendMsg(2319, 0, 0);
2380 }
2381
2382 // Move caret one page up.
2383 void wxStyledTextCtrl::PageUp()
2384 {
2385 SendMsg(2320, 0, 0);
2386 }
2387
2388 // Move caret one page up extending selection to new caret position.
2389 void wxStyledTextCtrl::PageUpExtend()
2390 {
2391 SendMsg(2321, 0, 0);
2392 }
2393
2394 // Move caret one page down.
2395 void wxStyledTextCtrl::PageDown()
2396 {
2397 SendMsg(2322, 0, 0);
2398 }
2399
2400 // Move caret one page down extending selection to new caret position.
2401 void wxStyledTextCtrl::PageDownExtend()
2402 {
2403 SendMsg(2323, 0, 0);
2404 }
2405
2406 // Switch from insert to overtype mode or the reverse.
2407 void wxStyledTextCtrl::EditToggleOvertype()
2408 {
2409 SendMsg(2324, 0, 0);
2410 }
2411
2412 // Cancel any modes such as call tip or auto-completion list display.
2413 void wxStyledTextCtrl::Cancel()
2414 {
2415 SendMsg(2325, 0, 0);
2416 }
2417
2418 // Delete the selection or if no selection, the character before the caret.
2419 void wxStyledTextCtrl::DeleteBack()
2420 {
2421 SendMsg(2326, 0, 0);
2422 }
2423
2424 // If selection is empty or all on one line replace the selection with a tab character.
2425 // If more than one line selected, indent the lines.
2426 void wxStyledTextCtrl::Tab()
2427 {
2428 SendMsg(2327, 0, 0);
2429 }
2430
2431 // Dedent the selected lines.
2432 void wxStyledTextCtrl::BackTab()
2433 {
2434 SendMsg(2328, 0, 0);
2435 }
2436
2437 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
2438 void wxStyledTextCtrl::NewLine()
2439 {
2440 SendMsg(2329, 0, 0);
2441 }
2442
2443 // Insert a Form Feed character.
2444 void wxStyledTextCtrl::FormFeed()
2445 {
2446 SendMsg(2330, 0, 0);
2447 }
2448
2449 // Move caret to before first visible character on line.
2450 // If already there move to first character on line.
2451 void wxStyledTextCtrl::VCHome()
2452 {
2453 SendMsg(2331, 0, 0);
2454 }
2455
2456 // Like VCHome but extending selection to new caret position.
2457 void wxStyledTextCtrl::VCHomeExtend()
2458 {
2459 SendMsg(2332, 0, 0);
2460 }
2461
2462 // Magnify the displayed text by increasing the sizes by 1 point.
2463 void wxStyledTextCtrl::ZoomIn()
2464 {
2465 SendMsg(2333, 0, 0);
2466 }
2467
2468 // Make the displayed text smaller by decreasing the sizes by 1 point.
2469 void wxStyledTextCtrl::ZoomOut()
2470 {
2471 SendMsg(2334, 0, 0);
2472 }
2473
2474 // Delete the word to the left of the caret.
2475 void wxStyledTextCtrl::DelWordLeft()
2476 {
2477 SendMsg(2335, 0, 0);
2478 }
2479
2480 // Delete the word to the right of the caret.
2481 void wxStyledTextCtrl::DelWordRight()
2482 {
2483 SendMsg(2336, 0, 0);
2484 }
2485
2486 // Delete the word to the right of the caret, but not the trailing non-word characters.
2487 void wxStyledTextCtrl::DelWordRightEnd()
2488 {
2489 SendMsg(2518, 0, 0);
2490 }
2491
2492 // Cut the line containing the caret.
2493 void wxStyledTextCtrl::LineCut()
2494 {
2495 SendMsg(2337, 0, 0);
2496 }
2497
2498 // Delete the line containing the caret.
2499 void wxStyledTextCtrl::LineDelete()
2500 {
2501 SendMsg(2338, 0, 0);
2502 }
2503
2504 // Switch the current line with the previous.
2505 void wxStyledTextCtrl::LineTranspose()
2506 {
2507 SendMsg(2339, 0, 0);
2508 }
2509
2510 // Duplicate the current line.
2511 void wxStyledTextCtrl::LineDuplicate()
2512 {
2513 SendMsg(2404, 0, 0);
2514 }
2515
2516 // Transform the selection to lower case.
2517 void wxStyledTextCtrl::LowerCase()
2518 {
2519 SendMsg(2340, 0, 0);
2520 }
2521
2522 // Transform the selection to upper case.
2523 void wxStyledTextCtrl::UpperCase()
2524 {
2525 SendMsg(2341, 0, 0);
2526 }
2527
2528 // Scroll the document down, keeping the caret visible.
2529 void wxStyledTextCtrl::LineScrollDown()
2530 {
2531 SendMsg(2342, 0, 0);
2532 }
2533
2534 // Scroll the document up, keeping the caret visible.
2535 void wxStyledTextCtrl::LineScrollUp()
2536 {
2537 SendMsg(2343, 0, 0);
2538 }
2539
2540 // Delete the selection or if no selection, the character before the caret.
2541 // Will not delete the character before at the start of a line.
2542 void wxStyledTextCtrl::DeleteBackNotLine()
2543 {
2544 SendMsg(2344, 0, 0);
2545 }
2546
2547 // Move caret to first position on display line.
2548 void wxStyledTextCtrl::HomeDisplay()
2549 {
2550 SendMsg(2345, 0, 0);
2551 }
2552
2553 // Move caret to first position on display line extending selection to
2554 // new caret position.
2555 void wxStyledTextCtrl::HomeDisplayExtend()
2556 {
2557 SendMsg(2346, 0, 0);
2558 }
2559
2560 // Move caret to last position on display line.
2561 void wxStyledTextCtrl::LineEndDisplay()
2562 {
2563 SendMsg(2347, 0, 0);
2564 }
2565
2566 // Move caret to last position on display line extending selection to new
2567 // caret position.
2568 void wxStyledTextCtrl::LineEndDisplayExtend()
2569 {
2570 SendMsg(2348, 0, 0);
2571 }
2572
2573 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
2574 // except they behave differently when word-wrap is enabled:
2575 // They go first to the start / end of the display line, like (Home|LineEnd)Display
2576 // The difference is that, the cursor is already at the point, it goes on to the start
2577 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
2578 void wxStyledTextCtrl::HomeWrap()
2579 {
2580 SendMsg(2349, 0, 0);
2581 }
2582 void wxStyledTextCtrl::HomeWrapExtend()
2583 {
2584 SendMsg(2450, 0, 0);
2585 }
2586 void wxStyledTextCtrl::LineEndWrap()
2587 {
2588 SendMsg(2451, 0, 0);
2589 }
2590 void wxStyledTextCtrl::LineEndWrapExtend()
2591 {
2592 SendMsg(2452, 0, 0);
2593 }
2594 void wxStyledTextCtrl::VCHomeWrap()
2595 {
2596 SendMsg(2453, 0, 0);
2597 }
2598 void wxStyledTextCtrl::VCHomeWrapExtend()
2599 {
2600 SendMsg(2454, 0, 0);
2601 }
2602
2603 // Copy the line containing the caret.
2604 void wxStyledTextCtrl::LineCopy()
2605 {
2606 SendMsg(2455, 0, 0);
2607 }
2608
2609 // Move the caret inside current view if it's not there already.
2610 void wxStyledTextCtrl::MoveCaretInsideView()
2611 {
2612 SendMsg(2401, 0, 0);
2613 }
2614
2615 // How many characters are on a line, including end of line characters?
2616 int wxStyledTextCtrl::LineLength(int line) const
2617 {
2618 return SendMsg(2350, line, 0);
2619 }
2620
2621 // Highlight the characters at two positions.
2622 void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2)
2623 {
2624 SendMsg(2351, pos1, pos2);
2625 }
2626
2627 // Use specified indicator to highlight matching braces instead of changing their style.
2628 void wxStyledTextCtrl::BraceHighlightIndicator(bool useBraceHighlightIndicator, int indicator)
2629 {
2630 SendMsg(2498, useBraceHighlightIndicator, indicator);
2631 }
2632
2633 // Highlight the character at a position indicating there is no matching brace.
2634 void wxStyledTextCtrl::BraceBadLight(int pos)
2635 {
2636 SendMsg(2352, pos, 0);
2637 }
2638
2639 // Use specified indicator to highlight non matching brace instead of changing its style.
2640 void wxStyledTextCtrl::BraceBadLightIndicator(bool useBraceBadLightIndicator, int indicator)
2641 {
2642 SendMsg(2499, useBraceBadLightIndicator, indicator);
2643 }
2644
2645 // Find the position of a matching brace or INVALID_POSITION if no match.
2646 int wxStyledTextCtrl::BraceMatch(int pos)
2647 {
2648 return SendMsg(2353, pos, 0);
2649 }
2650
2651 // Are the end of line characters visible?
2652 bool wxStyledTextCtrl::GetViewEOL() const
2653 {
2654 return SendMsg(2355, 0, 0) != 0;
2655 }
2656
2657 // Make the end of line characters visible or invisible.
2658 void wxStyledTextCtrl::SetViewEOL(bool visible)
2659 {
2660 SendMsg(2356, visible, 0);
2661 }
2662
2663 // Retrieve a pointer to the document object.
2664 void* wxStyledTextCtrl::GetDocPointer() {
2665 return (void*)SendMsg(2357);
2666 }
2667
2668 // Change the document object used.
2669 void wxStyledTextCtrl::SetDocPointer(void* docPointer) {
2670 SendMsg(2358, 0, (sptr_t)docPointer);
2671 }
2672
2673 // Set which document modification events are sent to the container.
2674 void wxStyledTextCtrl::SetModEventMask(int mask)
2675 {
2676 SendMsg(2359, mask, 0);
2677 }
2678
2679 // Retrieve the column number which text should be kept within.
2680 int wxStyledTextCtrl::GetEdgeColumn() const
2681 {
2682 return SendMsg(2360, 0, 0);
2683 }
2684
2685 // Set the column number of the edge.
2686 // If text goes past the edge then it is highlighted.
2687 void wxStyledTextCtrl::SetEdgeColumn(int column)
2688 {
2689 SendMsg(2361, column, 0);
2690 }
2691
2692 // Retrieve the edge highlight mode.
2693 int wxStyledTextCtrl::GetEdgeMode() const
2694 {
2695 return SendMsg(2362, 0, 0);
2696 }
2697
2698 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2699 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2700 void wxStyledTextCtrl::SetEdgeMode(int mode)
2701 {
2702 SendMsg(2363, mode, 0);
2703 }
2704
2705 // Retrieve the colour used in edge indication.
2706 wxColour wxStyledTextCtrl::GetEdgeColour() const
2707 {
2708 long c = SendMsg(2364, 0, 0);
2709 return wxColourFromLong(c);
2710 }
2711
2712 // Change the colour used in edge indication.
2713 void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour)
2714 {
2715 SendMsg(2365, wxColourAsLong(edgeColour), 0);
2716 }
2717
2718 // Sets the current caret position to be the search anchor.
2719 void wxStyledTextCtrl::SearchAnchor()
2720 {
2721 SendMsg(2366, 0, 0);
2722 }
2723
2724 // Find some text starting at the search anchor.
2725 // Does not ensure the selection is visible.
2726 int wxStyledTextCtrl::SearchNext(int flags, const wxString& text)
2727 {
2728 return SendMsg(2367, flags, (sptr_t)(const char*)wx2stc(text));
2729 }
2730
2731 // Find some text starting at the search anchor and moving backwards.
2732 // Does not ensure the selection is visible.
2733 int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text)
2734 {
2735 return SendMsg(2368, flags, (sptr_t)(const char*)wx2stc(text));
2736 }
2737
2738 // Retrieves the number of lines completely visible.
2739 int wxStyledTextCtrl::LinesOnScreen() const
2740 {
2741 return SendMsg(2370, 0, 0);
2742 }
2743
2744 // Set whether a pop up menu is displayed automatically when the user presses
2745 // the wrong mouse button.
2746 void wxStyledTextCtrl::UsePopUp(bool allowPopUp)
2747 {
2748 SendMsg(2371, allowPopUp, 0);
2749 }
2750
2751 // Is the selection rectangular? The alternative is the more common stream selection.
2752 bool wxStyledTextCtrl::SelectionIsRectangle() const
2753 {
2754 return SendMsg(2372, 0, 0) != 0;
2755 }
2756
2757 // Set the zoom level. This number of points is added to the size of all fonts.
2758 // It may be positive to magnify or negative to reduce.
2759 void wxStyledTextCtrl::SetZoom(int zoom)
2760 {
2761 SendMsg(2373, zoom, 0);
2762 }
2763
2764 // Retrieve the zoom level.
2765 int wxStyledTextCtrl::GetZoom() const
2766 {
2767 return SendMsg(2374, 0, 0);
2768 }
2769
2770 // Create a new document object.
2771 // Starts with reference count of 1 and not selected into editor.
2772 void* wxStyledTextCtrl::CreateDocument() {
2773 return (void*)SendMsg(2375);
2774 }
2775
2776 // Extend life of document.
2777 void wxStyledTextCtrl::AddRefDocument(void* docPointer) {
2778 SendMsg(2376, 0, (sptr_t)docPointer);
2779 }
2780
2781 // Release a reference to the document, deleting document if it fades to black.
2782 void wxStyledTextCtrl::ReleaseDocument(void* docPointer) {
2783 SendMsg(2377, 0, (sptr_t)docPointer);
2784 }
2785
2786 // Get which document modification events are sent to the container.
2787 int wxStyledTextCtrl::GetModEventMask() const
2788 {
2789 return SendMsg(2378, 0, 0);
2790 }
2791
2792 // Change internal focus flag.
2793 void wxStyledTextCtrl::SetSTCFocus(bool focus)
2794 {
2795 SendMsg(2380, focus, 0);
2796 }
2797
2798 // Get internal focus flag.
2799 bool wxStyledTextCtrl::GetSTCFocus() const
2800 {
2801 return SendMsg(2381, 0, 0) != 0;
2802 }
2803
2804 // Change error status - 0 = OK.
2805 void wxStyledTextCtrl::SetStatus(int statusCode)
2806 {
2807 SendMsg(2382, statusCode, 0);
2808 }
2809
2810 // Get error status.
2811 int wxStyledTextCtrl::GetStatus() const
2812 {
2813 return SendMsg(2383, 0, 0);
2814 }
2815
2816 // Set whether the mouse is captured when its button is pressed.
2817 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures)
2818 {
2819 SendMsg(2384, captures, 0);
2820 }
2821
2822 // Get whether mouse gets captured.
2823 bool wxStyledTextCtrl::GetMouseDownCaptures() const
2824 {
2825 return SendMsg(2385, 0, 0) != 0;
2826 }
2827
2828 // Sets the cursor to one of the SC_CURSOR* values.
2829 void wxStyledTextCtrl::SetSTCCursor(int cursorType)
2830 {
2831 SendMsg(2386, cursorType, 0);
2832 }
2833
2834 // Get cursor type.
2835 int wxStyledTextCtrl::GetSTCCursor() const
2836 {
2837 return SendMsg(2387, 0, 0);
2838 }
2839
2840 // Change the way control characters are displayed:
2841 // If symbol is < 32, keep the drawn way, else, use the given character.
2842 void wxStyledTextCtrl::SetControlCharSymbol(int symbol)
2843 {
2844 SendMsg(2388, symbol, 0);
2845 }
2846
2847 // Get the way control characters are displayed.
2848 int wxStyledTextCtrl::GetControlCharSymbol() const
2849 {
2850 return SendMsg(2389, 0, 0);
2851 }
2852
2853 // Move to the previous change in capitalisation.
2854 void wxStyledTextCtrl::WordPartLeft()
2855 {
2856 SendMsg(2390, 0, 0);
2857 }
2858
2859 // Move to the previous change in capitalisation extending selection
2860 // to new caret position.
2861 void wxStyledTextCtrl::WordPartLeftExtend()
2862 {
2863 SendMsg(2391, 0, 0);
2864 }
2865
2866 // Move to the change next in capitalisation.
2867 void wxStyledTextCtrl::WordPartRight()
2868 {
2869 SendMsg(2392, 0, 0);
2870 }
2871
2872 // Move to the next change in capitalisation extending selection
2873 // to new caret position.
2874 void wxStyledTextCtrl::WordPartRightExtend()
2875 {
2876 SendMsg(2393, 0, 0);
2877 }
2878
2879 // Set the way the display area is determined when a particular line
2880 // is to be moved to by Find, FindNext, GotoLine, etc.
2881 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop)
2882 {
2883 SendMsg(2394, visiblePolicy, visibleSlop);
2884 }
2885
2886 // Delete back from the current position to the start of the line.
2887 void wxStyledTextCtrl::DelLineLeft()
2888 {
2889 SendMsg(2395, 0, 0);
2890 }
2891
2892 // Delete forwards from the current position to the end of the line.
2893 void wxStyledTextCtrl::DelLineRight()
2894 {
2895 SendMsg(2396, 0, 0);
2896 }
2897
2898 // Get and Set the xOffset (ie, horizontal scroll position).
2899 void wxStyledTextCtrl::SetXOffset(int newOffset)
2900 {
2901 SendMsg(2397, newOffset, 0);
2902 }
2903 int wxStyledTextCtrl::GetXOffset() const
2904 {
2905 return SendMsg(2398, 0, 0);
2906 }
2907
2908 // Set the last x chosen value to be the caret x position.
2909 void wxStyledTextCtrl::ChooseCaretX()
2910 {
2911 SendMsg(2399, 0, 0);
2912 }
2913
2914 // Set the way the caret is kept visible when going sideways.
2915 // The exclusion zone is given in pixels.
2916 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop)
2917 {
2918 SendMsg(2402, caretPolicy, caretSlop);
2919 }
2920
2921 // Set the way the line the caret is on is kept visible.
2922 // The exclusion zone is given in lines.
2923 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop)
2924 {
2925 SendMsg(2403, caretPolicy, caretSlop);
2926 }
2927
2928 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2929 void wxStyledTextCtrl::SetPrintWrapMode(int mode)
2930 {
2931 SendMsg(2406, mode, 0);
2932 }
2933
2934 // Is printing line wrapped?
2935 int wxStyledTextCtrl::GetPrintWrapMode() const
2936 {
2937 return SendMsg(2407, 0, 0);
2938 }
2939
2940 // Set a fore colour for active hotspots.
2941 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore)
2942 {
2943 SendMsg(2410, useSetting, wxColourAsLong(fore));
2944 }
2945
2946 // Get the fore colour for active hotspots.
2947 wxColour wxStyledTextCtrl::GetHotspotActiveForeground() const
2948 {
2949 long c = SendMsg(2494, 0, 0);
2950 return wxColourFromLong(c);
2951 }
2952
2953 // Set a back colour for active hotspots.
2954 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back)
2955 {
2956 SendMsg(2411, useSetting, wxColourAsLong(back));
2957 }
2958
2959 // Get the back colour for active hotspots.
2960 wxColour wxStyledTextCtrl::GetHotspotActiveBackground() const
2961 {
2962 long c = SendMsg(2495, 0, 0);
2963 return wxColourFromLong(c);
2964 }
2965
2966 // Enable / Disable underlining active hotspots.
2967 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline)
2968 {
2969 SendMsg(2412, underline, 0);
2970 }
2971
2972 // Get whether underlining for active hotspots.
2973 bool wxStyledTextCtrl::GetHotspotActiveUnderline() const
2974 {
2975 return SendMsg(2496, 0, 0) != 0;
2976 }
2977
2978 // Limit hotspots to single line so hotspots on two lines don't merge.
2979 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine)
2980 {
2981 SendMsg(2421, singleLine, 0);
2982 }
2983
2984 // Get the HotspotSingleLine property
2985 bool wxStyledTextCtrl::GetHotspotSingleLine() const
2986 {
2987 return SendMsg(2497, 0, 0) != 0;
2988 }
2989
2990 // Move caret between paragraphs (delimited by empty lines).
2991 void wxStyledTextCtrl::ParaDown()
2992 {
2993 SendMsg(2413, 0, 0);
2994 }
2995 void wxStyledTextCtrl::ParaDownExtend()
2996 {
2997 SendMsg(2414, 0, 0);
2998 }
2999 void wxStyledTextCtrl::ParaUp()
3000 {
3001 SendMsg(2415, 0, 0);
3002 }
3003 void wxStyledTextCtrl::ParaUpExtend()
3004 {
3005 SendMsg(2416, 0, 0);
3006 }
3007
3008 // Given a valid document position, return the previous position taking code
3009 // page into account. Returns 0 if passed 0.
3010 int wxStyledTextCtrl::PositionBefore(int pos)
3011 {
3012 return SendMsg(2417, pos, 0);
3013 }
3014
3015 // Given a valid document position, return the next position taking code
3016 // page into account. Maximum value returned is the last position in the document.
3017 int wxStyledTextCtrl::PositionAfter(int pos)
3018 {
3019 return SendMsg(2418, pos, 0);
3020 }
3021
3022 // Copy a range of text to the clipboard. Positions are clipped into the document.
3023 void wxStyledTextCtrl::CopyRange(int start, int end)
3024 {
3025 SendMsg(2419, start, end);
3026 }
3027
3028 // Copy argument text to the clipboard.
3029 void wxStyledTextCtrl::CopyText(int length, const wxString& text)
3030 {
3031 SendMsg(2420, length, (sptr_t)(const char*)wx2stc(text));
3032 }
3033
3034 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE/SC_SEL_THIN) or
3035 // by lines (SC_SEL_LINES).
3036 void wxStyledTextCtrl::SetSelectionMode(int mode)
3037 {
3038 SendMsg(2422, mode, 0);
3039 }
3040
3041 // Get the mode of the current selection.
3042 int wxStyledTextCtrl::GetSelectionMode() const
3043 {
3044 return SendMsg(2423, 0, 0);
3045 }
3046
3047 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
3048 int wxStyledTextCtrl::GetLineSelStartPosition(int line)
3049 {
3050 return SendMsg(2424, line, 0);
3051 }
3052
3053 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
3054 int wxStyledTextCtrl::GetLineSelEndPosition(int line)
3055 {
3056 return SendMsg(2425, line, 0);
3057 }
3058
3059 // Move caret down one line, extending rectangular selection to new caret position.
3060 void wxStyledTextCtrl::LineDownRectExtend()
3061 {
3062 SendMsg(2426, 0, 0);
3063 }
3064
3065 // Move caret up one line, extending rectangular selection to new caret position.
3066 void wxStyledTextCtrl::LineUpRectExtend()
3067 {
3068 SendMsg(2427, 0, 0);
3069 }
3070
3071 // Move caret left one character, extending rectangular selection to new caret position.
3072 void wxStyledTextCtrl::CharLeftRectExtend()
3073 {
3074 SendMsg(2428, 0, 0);
3075 }
3076
3077 // Move caret right one character, extending rectangular selection to new caret position.
3078 void wxStyledTextCtrl::CharRightRectExtend()
3079 {
3080 SendMsg(2429, 0, 0);
3081 }
3082
3083 // Move caret to first position on line, extending rectangular selection to new caret position.
3084 void wxStyledTextCtrl::HomeRectExtend()
3085 {
3086 SendMsg(2430, 0, 0);
3087 }
3088
3089 // Move caret to before first visible character on line.
3090 // If already there move to first character on line.
3091 // In either case, extend rectangular selection to new caret position.
3092 void wxStyledTextCtrl::VCHomeRectExtend()
3093 {
3094 SendMsg(2431, 0, 0);
3095 }
3096
3097 // Move caret to last position on line, extending rectangular selection to new caret position.
3098 void wxStyledTextCtrl::LineEndRectExtend()
3099 {
3100 SendMsg(2432, 0, 0);
3101 }
3102
3103 // Move caret one page up, extending rectangular selection to new caret position.
3104 void wxStyledTextCtrl::PageUpRectExtend()
3105 {
3106 SendMsg(2433, 0, 0);
3107 }
3108
3109 // Move caret one page down, extending rectangular selection to new caret position.
3110 void wxStyledTextCtrl::PageDownRectExtend()
3111 {
3112 SendMsg(2434, 0, 0);
3113 }
3114
3115 // Move caret to top of page, or one page up if already at top of page.
3116 void wxStyledTextCtrl::StutteredPageUp()
3117 {
3118 SendMsg(2435, 0, 0);
3119 }
3120
3121 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
3122 void wxStyledTextCtrl::StutteredPageUpExtend()
3123 {
3124 SendMsg(2436, 0, 0);
3125 }
3126
3127 // Move caret to bottom of page, or one page down if already at bottom of page.
3128 void wxStyledTextCtrl::StutteredPageDown()
3129 {
3130 SendMsg(2437, 0, 0);
3131 }
3132
3133 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
3134 void wxStyledTextCtrl::StutteredPageDownExtend()
3135 {
3136 SendMsg(2438, 0, 0);
3137 }
3138
3139 // Move caret left one word, position cursor at end of word.
3140 void wxStyledTextCtrl::WordLeftEnd()
3141 {
3142 SendMsg(2439, 0, 0);
3143 }
3144
3145 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
3146 void wxStyledTextCtrl::WordLeftEndExtend()
3147 {
3148 SendMsg(2440, 0, 0);
3149 }
3150
3151 // Move caret right one word, position cursor at end of word.
3152 void wxStyledTextCtrl::WordRightEnd()
3153 {
3154 SendMsg(2441, 0, 0);
3155 }
3156
3157 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
3158 void wxStyledTextCtrl::WordRightEndExtend()
3159 {
3160 SendMsg(2442, 0, 0);
3161 }
3162
3163 // Set the set of characters making up whitespace for when moving or selecting by word.
3164 // Should be called after SetWordChars.
3165 void wxStyledTextCtrl::SetWhitespaceChars(const wxString& characters)
3166 {
3167 SendMsg(2443, 0, (sptr_t)(const char*)wx2stc(characters));
3168 }
3169
3170 // Get the set of characters making up whitespace for when moving or selecting by word.
3171 wxString wxStyledTextCtrl::GetWhitespaceChars() const {
3172 int msg = 2647;
3173 int len = SendMsg(msg, 0, (sptr_t)NULL);
3174 if (!len) return wxEmptyString;
3175
3176 wxMemoryBuffer mbuf(len+1);
3177 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3178 SendMsg(msg, 0, (sptr_t)buf);
3179 mbuf.UngetWriteBuf(len);
3180 mbuf.AppendByte(0);
3181 return stc2wx(buf);
3182 }
3183
3184 // Set the set of characters making up punctuation characters
3185 // Should be called after SetWordChars.
3186 void wxStyledTextCtrl::SetPunctuationChars(const wxString& characters)
3187 {
3188 SendMsg(2648, 0, (sptr_t)(const char*)wx2stc(characters));
3189 }
3190
3191 // Get the set of characters making up punctuation characters
3192 wxString wxStyledTextCtrl::GetPunctuationChars() const {
3193 int msg = 2649;
3194 int len = SendMsg(msg, 0, (sptr_t)NULL);
3195 if (!len) return wxEmptyString;
3196
3197 wxMemoryBuffer mbuf(len+1);
3198 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3199 SendMsg(msg, 0, (sptr_t)buf);
3200 mbuf.UngetWriteBuf(len);
3201 mbuf.AppendByte(0);
3202 return stc2wx(buf);
3203 }
3204
3205 // Reset the set of characters for whitespace and word characters to the defaults.
3206 void wxStyledTextCtrl::SetCharsDefault()
3207 {
3208 SendMsg(2444, 0, 0);
3209 }
3210
3211 // Get currently selected item position in the auto-completion list
3212 int wxStyledTextCtrl::AutoCompGetCurrent() const
3213 {
3214 return SendMsg(2445, 0, 0);
3215 }
3216
3217 // Set auto-completion case insensitive behaviour to either prefer case-sensitive matches or have no preference.
3218 void wxStyledTextCtrl::AutoCompSetCaseInsensitiveBehaviour(int behaviour)
3219 {
3220 SendMsg(2634, behaviour, 0);
3221 }
3222
3223 // Get auto-completion case insensitive behaviour.
3224 int wxStyledTextCtrl::AutoCompGetCaseInsensitiveBehaviour() const
3225 {
3226 return SendMsg(2635, 0, 0);
3227 }
3228
3229 // Enlarge the document to a particular size of text bytes.
3230 void wxStyledTextCtrl::Allocate(int bytes)
3231 {
3232 SendMsg(2446, bytes, 0);
3233 }
3234
3235 // Find the position of a column on a line taking into account tabs and
3236 // multi-byte characters. If beyond end of line, return line end position.
3237 int wxStyledTextCtrl::FindColumn(int line, int column)
3238 {
3239 return SendMsg(2456, line, column);
3240 }
3241
3242 // Can the caret preferred x position only be changed by explicit movement commands?
3243 int wxStyledTextCtrl::GetCaretSticky() const
3244 {
3245 return SendMsg(2457, 0, 0);
3246 }
3247
3248 // Stop the caret preferred x position changing when the user types.
3249 void wxStyledTextCtrl::SetCaretSticky(int useCaretStickyBehaviour)
3250 {
3251 SendMsg(2458, useCaretStickyBehaviour, 0);
3252 }
3253
3254 // Switch between sticky and non-sticky: meant to be bound to a key.
3255 void wxStyledTextCtrl::ToggleCaretSticky()
3256 {
3257 SendMsg(2459, 0, 0);
3258 }
3259
3260 // Enable/Disable convert-on-paste for line endings
3261 void wxStyledTextCtrl::SetPasteConvertEndings(bool convert)
3262 {
3263 SendMsg(2467, convert, 0);
3264 }
3265
3266 // Get convert-on-paste setting
3267 bool wxStyledTextCtrl::GetPasteConvertEndings() const
3268 {
3269 return SendMsg(2468, 0, 0) != 0;
3270 }
3271
3272 // Duplicate the selection. If selection empty duplicate the line containing the caret.
3273 void wxStyledTextCtrl::SelectionDuplicate()
3274 {
3275 SendMsg(2469, 0, 0);
3276 }
3277
3278 // Set background alpha of the caret line.
3279 void wxStyledTextCtrl::SetCaretLineBackAlpha(int alpha)
3280 {
3281 SendMsg(2470, alpha, 0);
3282 }
3283
3284 // Get the background alpha of the caret line.
3285 int wxStyledTextCtrl::GetCaretLineBackAlpha() const
3286 {
3287 return SendMsg(2471, 0, 0);
3288 }
3289
3290 // Set the style of the caret to be drawn.
3291 void wxStyledTextCtrl::SetCaretStyle(int caretStyle)
3292 {
3293 SendMsg(2512, caretStyle, 0);
3294 }
3295
3296 // Returns the current style of the caret.
3297 int wxStyledTextCtrl::GetCaretStyle() const
3298 {
3299 return SendMsg(2513, 0, 0);
3300 }
3301
3302 // Set the indicator used for IndicatorFillRange and IndicatorClearRange
3303 void wxStyledTextCtrl::SetIndicatorCurrent(int indicator)
3304 {
3305 SendMsg(2500, indicator, 0);
3306 }
3307
3308 // Get the current indicator
3309 int wxStyledTextCtrl::GetIndicatorCurrent() const
3310 {
3311 return SendMsg(2501, 0, 0);
3312 }
3313
3314 // Set the value used for IndicatorFillRange
3315 void wxStyledTextCtrl::SetIndicatorValue(int value)
3316 {
3317 SendMsg(2502, value, 0);
3318 }
3319
3320 // Get the current indicator value
3321 int wxStyledTextCtrl::GetIndicatorValue() const
3322 {
3323 return SendMsg(2503, 0, 0);
3324 }
3325
3326 // Turn a indicator on over a range.
3327 void wxStyledTextCtrl::IndicatorFillRange(int position, int fillLength)
3328 {
3329 SendMsg(2504, position, fillLength);
3330 }
3331
3332 // Turn a indicator off over a range.
3333 void wxStyledTextCtrl::IndicatorClearRange(int position, int clearLength)
3334 {
3335 SendMsg(2505, position, clearLength);
3336 }
3337
3338 // Are any indicators present at position?
3339 int wxStyledTextCtrl::IndicatorAllOnFor(int position)
3340 {
3341 return SendMsg(2506, position, 0);
3342 }
3343
3344 // What value does a particular indicator have at at a position?
3345 int wxStyledTextCtrl::IndicatorValueAt(int indicator, int position)
3346 {
3347 return SendMsg(2507, indicator, position);
3348 }
3349
3350 // Where does a particular indicator start?
3351 int wxStyledTextCtrl::IndicatorStart(int indicator, int position)
3352 {
3353 return SendMsg(2508, indicator, position);
3354 }
3355
3356 // Where does a particular indicator end?
3357 int wxStyledTextCtrl::IndicatorEnd(int indicator, int position)
3358 {
3359 return SendMsg(2509, indicator, position);
3360 }
3361
3362 // Set number of entries in position cache
3363 void wxStyledTextCtrl::SetPositionCacheSize(int size)
3364 {
3365 SendMsg(2514, size, 0);
3366 }
3367
3368 // How many entries are allocated to the position cache?
3369 int wxStyledTextCtrl::GetPositionCacheSize() const
3370 {
3371 return SendMsg(2515, 0, 0);
3372 }
3373
3374 // Copy the selection, if selection empty copy the line with the caret
3375 void wxStyledTextCtrl::CopyAllowLine()
3376 {
3377 SendMsg(2519, 0, 0);
3378 }
3379
3380 // Compact the document buffer and return a read-only pointer to the
3381 // characters in the document.
3382 const char* wxStyledTextCtrl::GetCharacterPointer() const {
3383 return (const char*)SendMsg(2520, 0, 0);
3384 }
3385
3386 // Return a read-only pointer to a range of characters in the document.
3387 // May move the gap so that the range is contiguous, but will only move up
3388 // to rangeLength bytes.
3389 const char* wxStyledTextCtrl::GetRangePointer(int position, int rangeLength) const {
3390 return (const char*)SendMsg(2643, position, rangeLength);
3391 }
3392
3393 // Return a position which, to avoid performance costs, should not be within
3394 // the range of a call to GetRangePointer.
3395 int wxStyledTextCtrl::GetGapPosition() const
3396 {
3397 return SendMsg(2644, 0, 0);
3398 }
3399
3400 // Always interpret keyboard input as Unicode
3401 void wxStyledTextCtrl::SetKeysUnicode(bool keysUnicode)
3402 {
3403 SendMsg(2521, keysUnicode, 0);
3404 }
3405
3406 // Are keys always interpreted as Unicode?
3407 bool wxStyledTextCtrl::GetKeysUnicode() const
3408 {
3409 return SendMsg(2522, 0, 0) != 0;
3410 }
3411
3412 // Set the alpha fill colour of the given indicator.
3413 void wxStyledTextCtrl::IndicatorSetAlpha(int indicator, int alpha)
3414 {
3415 SendMsg(2523, indicator, alpha);
3416 }
3417
3418 // Get the alpha fill colour of the given indicator.
3419 int wxStyledTextCtrl::IndicatorGetAlpha(int indicator) const
3420 {
3421 return SendMsg(2524, indicator, 0);
3422 }
3423
3424 // Set the alpha outline colour of the given indicator.
3425 void wxStyledTextCtrl::IndicatorSetOutlineAlpha(int indicator, int alpha)
3426 {
3427 SendMsg(2558, indicator, alpha);
3428 }
3429
3430 // Get the alpha outline colour of the given indicator.
3431 int wxStyledTextCtrl::IndicatorGetOutlineAlpha(int indicator) const
3432 {
3433 return SendMsg(2559, indicator, 0);
3434 }
3435
3436 // Set extra ascent for each line
3437 void wxStyledTextCtrl::SetExtraAscent(int extraAscent)
3438 {
3439 SendMsg(2525, extraAscent, 0);
3440 }
3441
3442 // Get extra ascent for each line
3443 int wxStyledTextCtrl::GetExtraAscent() const
3444 {
3445 return SendMsg(2526, 0, 0);
3446 }
3447
3448 // Set extra descent for each line
3449 void wxStyledTextCtrl::SetExtraDescent(int extraDescent)
3450 {
3451 SendMsg(2527, extraDescent, 0);
3452 }
3453
3454 // Get extra descent for each line
3455 int wxStyledTextCtrl::GetExtraDescent() const
3456 {
3457 return SendMsg(2528, 0, 0);
3458 }
3459
3460 // Which symbol was defined for markerNumber with MarkerDefine
3461 int wxStyledTextCtrl::GetMarkerSymbolDefined(int markerNumber)
3462 {
3463 return SendMsg(2529, markerNumber, 0);
3464 }
3465
3466 // Set the text in the text margin for a line
3467 void wxStyledTextCtrl::MarginSetText(int line, const wxString& text)
3468 {
3469 SendMsg(2530, line, (sptr_t)(const char*)wx2stc(text));
3470 }
3471
3472 // Get the text in the text margin for a line
3473 wxString wxStyledTextCtrl::MarginGetText(int line) const {
3474 long msg = 2531;
3475 long len = SendMsg(msg, line, 0);
3476
3477 wxMemoryBuffer mbuf(len+1);
3478 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3479 SendMsg(msg, line, (sptr_t)buf);
3480 mbuf.UngetWriteBuf(len);
3481 mbuf.AppendByte(0);
3482 return stc2wx(buf);
3483 }
3484
3485 // Set the style number for the text margin for a line
3486 void wxStyledTextCtrl::MarginSetStyle(int line, int style)
3487 {
3488 SendMsg(2532, line, style);
3489 }
3490
3491 // Get the style number for the text margin for a line
3492 int wxStyledTextCtrl::MarginGetStyle(int line) const
3493 {
3494 return SendMsg(2533, line, 0);
3495 }
3496
3497 // Set the style in the text margin for a line
3498 void wxStyledTextCtrl::MarginSetStyles(int line, const wxString& styles)
3499 {
3500 SendMsg(2534, line, (sptr_t)(const char*)wx2stc(styles));
3501 }
3502
3503 // Get the styles in the text margin for a line
3504 wxString wxStyledTextCtrl::MarginGetStyles(int line) const {
3505 long msg = 2535;
3506 long len = SendMsg(msg, line, 0);
3507
3508 wxMemoryBuffer mbuf(len+1);
3509 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3510 SendMsg(msg, line, (sptr_t)buf);
3511 mbuf.UngetWriteBuf(len);
3512 mbuf.AppendByte(0);
3513 return stc2wx(buf);
3514 }
3515
3516 // Clear the margin text on all lines
3517 void wxStyledTextCtrl::MarginTextClearAll()
3518 {
3519 SendMsg(2536, 0, 0);
3520 }
3521
3522 // Get the start of the range of style numbers used for margin text
3523 void wxStyledTextCtrl::MarginSetStyleOffset(int style)
3524 {
3525 SendMsg(2537, style, 0);
3526 }
3527
3528 // Get the start of the range of style numbers used for margin text
3529 int wxStyledTextCtrl::MarginGetStyleOffset() const
3530 {
3531 return SendMsg(2538, 0, 0);
3532 }
3533
3534 // Set the margin options.
3535 void wxStyledTextCtrl::SetMarginOptions(int marginOptions)
3536 {
3537 SendMsg(2539, marginOptions, 0);
3538 }
3539
3540 // Get the margin options.
3541 int wxStyledTextCtrl::GetMarginOptions() const
3542 {
3543 return SendMsg(2557, 0, 0);
3544 }
3545
3546 // Set the annotation text for a line
3547 void wxStyledTextCtrl::AnnotationSetText(int line, const wxString& text)
3548 {
3549 SendMsg(2540, line, (sptr_t)(const char*)wx2stc(text));
3550 }
3551
3552 // Get the annotation text for a line
3553 wxString wxStyledTextCtrl::AnnotationGetText(int line) const {
3554 long msg = 2541;
3555 long len = SendMsg(msg, line, 0);
3556
3557 wxMemoryBuffer mbuf(len+1);
3558 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3559 SendMsg(msg, line, (sptr_t)buf);
3560 mbuf.UngetWriteBuf(len);
3561 mbuf.AppendByte(0);
3562 return stc2wx(buf);
3563 }
3564
3565 // Set the style number for the annotations for a line
3566 void wxStyledTextCtrl::AnnotationSetStyle(int line, int style)
3567 {
3568 SendMsg(2542, line, style);
3569 }
3570
3571 // Get the style number for the annotations for a line
3572 int wxStyledTextCtrl::AnnotationGetStyle(int line) const
3573 {
3574 return SendMsg(2543, line, 0);
3575 }
3576
3577 // Set the annotation styles for a line
3578 void wxStyledTextCtrl::AnnotationSetStyles(int line, const wxString& styles)
3579 {
3580 SendMsg(2544, line, (sptr_t)(const char*)wx2stc(styles));
3581 }
3582
3583 // Get the annotation styles for a line
3584 wxString wxStyledTextCtrl::AnnotationGetStyles(int line) const {
3585 long msg = 2545;
3586 long len = SendMsg(msg, line, 0);
3587
3588 wxMemoryBuffer mbuf(len+1);
3589 char* buf = (char*)mbuf.GetWriteBuf(len+1);
3590 SendMsg(msg, line, (sptr_t)buf);
3591 mbuf.UngetWriteBuf(len);
3592 mbuf.AppendByte(0);
3593 return stc2wx(buf);
3594 }
3595
3596 // Get the number of annotation lines for a line
3597 int wxStyledTextCtrl::AnnotationGetLines(int line) const
3598 {
3599 return SendMsg(2546, line, 0);
3600 }
3601
3602 // Clear the annotations from all lines
3603 void wxStyledTextCtrl::AnnotationClearAll()
3604 {
3605 SendMsg(2547, 0, 0);
3606 }
3607
3608 // Set the visibility for the annotations for a view
3609 void wxStyledTextCtrl::AnnotationSetVisible(int visible)
3610 {
3611 SendMsg(2548, visible, 0);
3612 }
3613
3614 // Get the visibility for the annotations for a view
3615 int wxStyledTextCtrl::AnnotationGetVisible() const
3616 {
3617 return SendMsg(2549, 0, 0);
3618 }
3619
3620 // Get the start of the range of style numbers used for annotations
3621 void wxStyledTextCtrl::AnnotationSetStyleOffset(int style)
3622 {
3623 SendMsg(2550, style, 0);
3624 }
3625
3626 // Get the start of the range of style numbers used for annotations
3627 int wxStyledTextCtrl::AnnotationGetStyleOffset() const
3628 {
3629 return SendMsg(2551, 0, 0);
3630 }
3631
3632 // Add a container action to the undo stack
3633 void wxStyledTextCtrl::AddUndoAction(int token, int flags)
3634 {
3635 SendMsg(2560, token, flags);
3636 }
3637
3638 // Find the position of a character from a point within the window.
3639 int wxStyledTextCtrl::CharPositionFromPoint(int x, int y)
3640 {
3641 return SendMsg(2561, x, y);
3642 }
3643
3644 // Find the position of a character from a point within the window.
3645 // Return INVALID_POSITION if not close to text.
3646 int wxStyledTextCtrl::CharPositionFromPointClose(int x, int y)
3647 {
3648 return SendMsg(2562, x, y);
3649 }
3650
3651 // Set whether multiple selections can be made
3652 void wxStyledTextCtrl::SetMultipleSelection(bool multipleSelection)
3653 {
3654 SendMsg(2563, multipleSelection, 0);
3655 }
3656
3657 // Whether multiple selections can be made
3658 bool wxStyledTextCtrl::GetMultipleSelection() const
3659 {
3660 return SendMsg(2564, 0, 0) != 0;
3661 }
3662
3663 // Set whether typing can be performed into multiple selections
3664 void wxStyledTextCtrl::SetAdditionalSelectionTyping(bool additionalSelectionTyping)
3665 {
3666 SendMsg(2565, additionalSelectionTyping, 0);
3667 }
3668
3669 // Whether typing can be performed into multiple selections
3670 bool wxStyledTextCtrl::GetAdditionalSelectionTyping() const
3671 {
3672 return SendMsg(2566, 0, 0) != 0;
3673 }
3674
3675 // Set whether additional carets will blink
3676 void wxStyledTextCtrl::SetAdditionalCaretsBlink(bool additionalCaretsBlink)
3677 {
3678 SendMsg(2567, additionalCaretsBlink, 0);
3679 }
3680
3681 // Whether additional carets will blink
3682 bool wxStyledTextCtrl::GetAdditionalCaretsBlink() const
3683 {
3684 return SendMsg(2568, 0, 0) != 0;
3685 }
3686
3687 // Set whether additional carets are visible
3688 void wxStyledTextCtrl::SetAdditionalCaretsVisible(bool additionalCaretsBlink)
3689 {
3690 SendMsg(2608, additionalCaretsBlink, 0);
3691 }
3692
3693 // Whether additional carets are visible
3694 bool wxStyledTextCtrl::GetAdditionalCaretsVisible() const
3695 {
3696 return SendMsg(2609, 0, 0) != 0;
3697 }
3698
3699 // How many selections are there?
3700 int wxStyledTextCtrl::GetSelections() const
3701 {
3702 return SendMsg(2570, 0, 0);
3703 }
3704
3705 // Clear selections to a single empty stream selection
3706 void wxStyledTextCtrl::ClearSelections()
3707 {
3708 SendMsg(2571, 0, 0);
3709 }
3710
3711 // Add a selection
3712 int wxStyledTextCtrl::AddSelection(int caret, int anchor)
3713 {
3714 return SendMsg(2573, caret, anchor);
3715 }
3716
3717 // Set the main selection
3718 void wxStyledTextCtrl::SetMainSelection(int selection)
3719 {
3720 SendMsg(2574, selection, 0);
3721 }
3722
3723 // Which selection is the main selection
3724 int wxStyledTextCtrl::GetMainSelection() const
3725 {
3726 return SendMsg(2575, 0, 0);
3727 }
3728 void wxStyledTextCtrl::SetSelectionNCaret(int selection, int pos)
3729 {
3730 SendMsg(2576, selection, pos);
3731 }
3732 int wxStyledTextCtrl::GetSelectionNCaret(int selection) const
3733 {
3734 return SendMsg(2577, selection, 0);
3735 }
3736 void wxStyledTextCtrl::SetSelectionNAnchor(int selection, int posAnchor)
3737 {
3738 SendMsg(2578, selection, posAnchor);
3739 }
3740 int wxStyledTextCtrl::GetSelectionNAnchor(int selection) const
3741 {
3742 return SendMsg(2579, selection, 0);
3743 }
3744 void wxStyledTextCtrl::SetSelectionNCaretVirtualSpace(int selection, int space)
3745 {
3746 SendMsg(2580, selection, space);
3747 }
3748 int wxStyledTextCtrl::GetSelectionNCaretVirtualSpace(int selection) const
3749 {
3750 return SendMsg(2581, selection, 0);
3751 }
3752 void wxStyledTextCtrl::SetSelectionNAnchorVirtualSpace(int selection, int space)
3753 {
3754 SendMsg(2582, selection, space);
3755 }
3756 int wxStyledTextCtrl::GetSelectionNAnchorVirtualSpace(int selection) const
3757 {
3758 return SendMsg(2583, selection, 0);
3759 }
3760
3761 // Sets the position that starts the selection - this becomes the anchor.
3762 void wxStyledTextCtrl::SetSelectionNStart(int selection, int pos)
3763 {
3764 SendMsg(2584, selection, pos);
3765 }
3766
3767 // Returns the position at the start of the selection.
3768 int wxStyledTextCtrl::GetSelectionNStart(int selection) const
3769 {
3770 return SendMsg(2585, selection, 0);
3771 }
3772
3773 // Sets the position that ends the selection - this becomes the currentPosition.
3774 void wxStyledTextCtrl::SetSelectionNEnd(int selection, int pos)
3775 {
3776 SendMsg(2586, selection, pos);
3777 }
3778
3779 // Returns the position at the end of the selection.
3780 int wxStyledTextCtrl::GetSelectionNEnd(int selection) const
3781 {
3782 return SendMsg(2587, selection, 0);
3783 }
3784 void wxStyledTextCtrl::SetRectangularSelectionCaret(int pos)
3785 {
3786 SendMsg(2588, pos, 0);
3787 }
3788 int wxStyledTextCtrl::GetRectangularSelectionCaret() const
3789 {
3790 return SendMsg(2589, 0, 0);
3791 }
3792 void wxStyledTextCtrl::SetRectangularSelectionAnchor(int posAnchor)
3793 {
3794 SendMsg(2590, posAnchor, 0);
3795 }
3796 int wxStyledTextCtrl::GetRectangularSelectionAnchor() const
3797 {
3798 return SendMsg(2591, 0, 0);
3799 }
3800 void wxStyledTextCtrl::SetRectangularSelectionCaretVirtualSpace(int space)
3801 {
3802 SendMsg(2592, space, 0);
3803 }
3804 int wxStyledTextCtrl::GetRectangularSelectionCaretVirtualSpace() const
3805 {
3806 return SendMsg(2593, 0, 0);
3807 }
3808 void wxStyledTextCtrl::SetRectangularSelectionAnchorVirtualSpace(int space)
3809 {
3810 SendMsg(2594, space, 0);
3811 }
3812 int wxStyledTextCtrl::GetRectangularSelectionAnchorVirtualSpace() const
3813 {
3814 return SendMsg(2595, 0, 0);
3815 }
3816 void wxStyledTextCtrl::SetVirtualSpaceOptions(int virtualSpaceOptions)
3817 {
3818 SendMsg(2596, virtualSpaceOptions, 0);
3819 }
3820 int wxStyledTextCtrl::GetVirtualSpaceOptions() const
3821 {
3822 return SendMsg(2597, 0, 0);
3823 }
3824
3825 // On GTK+, allow selecting the modifier key to use for mouse-based
3826 // rectangular selection. Often the window manager requires Alt+Mouse Drag
3827 // for moving windows.
3828 // Valid values are SCMOD_CTRL(default), SCMOD_ALT, or SCMOD_SUPER.
3829 void wxStyledTextCtrl::SetRectangularSelectionModifier(int modifier)
3830 {
3831 SendMsg(2598, modifier, 0);
3832 }
3833
3834 // Get the modifier key used for rectangular selection.
3835 int wxStyledTextCtrl::GetRectangularSelectionModifier() const
3836 {
3837 return SendMsg(2599, 0, 0);
3838 }
3839
3840 // Set the foreground colour of additional selections.
3841 // Must have previously called SetSelFore with non-zero first argument for this to have an effect.
3842 void wxStyledTextCtrl::SetAdditionalSelForeground(const wxColour& fore)
3843 {
3844 SendMsg(2600, wxColourAsLong(fore), 0);
3845 }
3846
3847 // Set the background colour of additional selections.
3848 // Must have previously called SetSelBack with non-zero first argument for this to have an effect.
3849 void wxStyledTextCtrl::SetAdditionalSelBackground(const wxColour& back)
3850 {
3851 SendMsg(2601, wxColourAsLong(back), 0);
3852 }
3853
3854 // Set the alpha of the selection.
3855 void wxStyledTextCtrl::SetAdditionalSelAlpha(int alpha)
3856 {
3857 SendMsg(2602, alpha, 0);
3858 }
3859
3860 // Get the alpha of the selection.
3861 int wxStyledTextCtrl::GetAdditionalSelAlpha() const
3862 {
3863 return SendMsg(2603, 0, 0);
3864 }
3865
3866 // Set the foreground colour of additional carets.
3867 void wxStyledTextCtrl::SetAdditionalCaretForeground(const wxColour& fore)
3868 {
3869 SendMsg(2604, wxColourAsLong(fore), 0);
3870 }
3871
3872 // Get the foreground colour of additional carets.
3873 wxColour wxStyledTextCtrl::GetAdditionalCaretForeground() const
3874 {
3875 long c = SendMsg(2605, 0, 0);
3876 return wxColourFromLong(c);
3877 }
3878
3879 // Set the main selection to the next selection.
3880 void wxStyledTextCtrl::RotateSelection()
3881 {
3882 SendMsg(2606, 0, 0);
3883 }
3884
3885 // Swap that caret and anchor of the main selection.
3886 void wxStyledTextCtrl::SwapMainAnchorCaret()
3887 {
3888 SendMsg(2607, 0, 0);
3889 }
3890
3891 // Indicate that the internal state of a lexer has changed over a range and therefore
3892 // there may be a need to redraw.
3893 int wxStyledTextCtrl::ChangeLexerState(int start, int end)
3894 {
3895 return SendMsg(2617, start, end);
3896 }
3897
3898 // Find the next line at or after lineStart that is a contracted fold header line.
3899 // Return -1 when no more lines.
3900 int wxStyledTextCtrl::ContractedFoldNext(int lineStart)
3901 {
3902 return SendMsg(2618, lineStart, 0);
3903 }
3904
3905 // Centre current line in window.
3906 void wxStyledTextCtrl::VerticalCentreCaret()
3907 {
3908 SendMsg(2619, 0, 0);
3909 }
3910
3911 // Move the selected lines up one line, shifting the line above after the selection
3912 void wxStyledTextCtrl::MoveSelectedLinesUp()
3913 {
3914 SendMsg(2620, 0, 0);
3915 }
3916
3917 // Move the selected lines down one line, shifting the line below before the selection
3918 void wxStyledTextCtrl::MoveSelectedLinesDown()
3919 {
3920 SendMsg(2621, 0, 0);
3921 }
3922
3923 // Set the identifier reported as idFrom in notification messages.
3924 void wxStyledTextCtrl::SetIdentifier(int identifier)
3925 {
3926 SendMsg(2622, identifier, 0);
3927 }
3928
3929 // Get the identifier.
3930 int wxStyledTextCtrl::GetIdentifier() const
3931 {
3932 return SendMsg(2623, 0, 0);
3933 }
3934
3935 // Set the width for future RGBA image data.
3936 void wxStyledTextCtrl::RGBAImageSetWidth(int width)
3937 {
3938 SendMsg(2624, width, 0);
3939 }
3940
3941 // Set the height for future RGBA image data.
3942 void wxStyledTextCtrl::RGBAImageSetHeight(int height)
3943 {
3944 SendMsg(2625, height, 0);
3945 }
3946
3947 // Define a marker from RGBA data.
3948 // It has the width and height from RGBAImageSetWidth/Height
3949 void wxStyledTextCtrl::MarkerDefineRGBAImage(int markerNumber, const unsigned char* pixels) {
3950 SendMsg(2626, markerNumber, (sptr_t)pixels);
3951 }
3952
3953 // Register an RGBA image for use in autocompletion lists.
3954 // It has the width and height from RGBAImageSetWidth/Height
3955 void wxStyledTextCtrl::RegisterRGBAImage(int type, const unsigned char* pixels) {
3956 SendMsg(2627, type, (sptr_t)pixels);
3957 }
3958
3959 // Scroll to start of document.
3960 void wxStyledTextCtrl::ScrollToStart()
3961 {
3962 SendMsg(2628, 0, 0);
3963 }
3964
3965 // Scroll to end of document.
3966 void wxStyledTextCtrl::ScrollToEnd()
3967 {
3968 SendMsg(2629, 0, 0);
3969 }
3970
3971 // Set the technology used.
3972 void wxStyledTextCtrl::SetTechnology(int technology)
3973 {
3974 SendMsg(2630, technology, 0);
3975 }
3976
3977 // Get the tech.
3978 int wxStyledTextCtrl::GetTechnology() const
3979 {
3980 return SendMsg(2631, 0, 0);
3981 }
3982
3983 // Create an ILoader*.
3984 void* wxStyledTextCtrl::CreateLoader(int bytes) const {
3985 return (void*)(sptr_t)SendMsg(2632, bytes);
3986 }
3987
3988 // Start notifying the container of all key presses and commands.
3989 void wxStyledTextCtrl::StartRecord()
3990 {
3991 SendMsg(3001, 0, 0);
3992 }
3993
3994 // Stop notifying the container of all key presses and commands.
3995 void wxStyledTextCtrl::StopRecord()
3996 {
3997 SendMsg(3002, 0, 0);
3998 }
3999
4000 // Set the lexing language of the document.
4001 void wxStyledTextCtrl::SetLexer(int lexer)
4002 {
4003 SendMsg(4001, lexer, 0);
4004 }
4005
4006 // Retrieve the lexing language of the document.
4007 int wxStyledTextCtrl::GetLexer() const
4008 {
4009 return SendMsg(4002, 0, 0);
4010 }
4011
4012 // Colourise a segment of the document using the current lexing language.
4013 void wxStyledTextCtrl::Colourise(int start, int end)
4014 {
4015 SendMsg(4003, start, end);
4016 }
4017
4018 // Set up a value that may be used by a lexer for some optional feature.
4019 void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value)
4020 {
4021 SendMsg(4004, (sptr_t)(const char*)wx2stc(key), (sptr_t)(const char*)wx2stc(value));
4022 }
4023
4024 // Set up the key words used by the lexer.
4025 void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords)
4026 {
4027 SendMsg(4005, keywordSet, (sptr_t)(const char*)wx2stc(keyWords));
4028 }
4029
4030 // Set the lexing language of the document based on string name.
4031 void wxStyledTextCtrl::SetLexerLanguage(const wxString& language)
4032 {
4033 SendMsg(4006, 0, (sptr_t)(const char*)wx2stc(language));
4034 }
4035
4036 // Retrieve a 'property' value previously set with SetProperty.
4037 wxString wxStyledTextCtrl::GetProperty(const wxString& key) {
4038 int len = SendMsg(SCI_GETPROPERTY, (sptr_t)(const char*)wx2stc(key), 0);
4039 if (!len) return wxEmptyString;
4040
4041 wxMemoryBuffer mbuf(len+1);
4042 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4043 SendMsg(4008, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
4044 mbuf.UngetWriteBuf(len);
4045 mbuf.AppendByte(0);
4046 return stc2wx(buf);
4047 }
4048
4049 // Retrieve a 'property' value previously set with SetProperty,
4050 // with '$()' variable replacement on returned buffer.
4051 wxString wxStyledTextCtrl::GetPropertyExpanded(const wxString& key) {
4052 int len = SendMsg(SCI_GETPROPERTYEXPANDED, (uptr_t)(const char*)wx2stc(key), 0);
4053 if (!len) return wxEmptyString;
4054
4055 wxMemoryBuffer mbuf(len+1);
4056 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4057 SendMsg(4009, (uptr_t)(const char*)wx2stc(key), (sptr_t)buf);
4058 mbuf.UngetWriteBuf(len);
4059 mbuf.AppendByte(0);
4060 return stc2wx(buf);
4061 }
4062
4063 // Retrieve a 'property' value previously set with SetProperty,
4064 // interpreted as an int AFTER any '$()' variable replacement.
4065 int wxStyledTextCtrl::GetPropertyInt(const wxString& key) const
4066 {
4067 return SendMsg(4010, (sptr_t)(const char*)wx2stc(key), 0);
4068 }
4069
4070 // Retrieve the number of bits the current lexer needs for styling.
4071 int wxStyledTextCtrl::GetStyleBitsNeeded() const
4072 {
4073 return SendMsg(4011, 0, 0);
4074 }
4075
4076 // For private communication between an application and a known lexer.
4077 void* wxStyledTextCtrl::PrivateLexerCall(int operation, void* pointer) {
4078 return (void*)(sptr_t)SendMsg(4013, operation, (sptr_t)pointer);
4079 }
4080
4081 // Retrieve a '\n' separated list of properties understood by the current lexer.
4082 wxString wxStyledTextCtrl::PropertyNames() const {
4083 int msg = 4014;
4084 int len = SendMsg(msg, 0, (sptr_t)NULL);
4085 if (!len) return wxEmptyString;
4086
4087 wxMemoryBuffer mbuf(len+1);
4088 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4089 SendMsg(msg, 0, (sptr_t)buf);
4090 mbuf.UngetWriteBuf(len);
4091 mbuf.AppendByte(0);
4092 return stc2wx(buf);
4093 }
4094
4095 // Retrieve the type of a property.
4096 int wxStyledTextCtrl::PropertyType(const wxString& name)
4097 {
4098 return SendMsg(4015, (sptr_t)(const char*)wx2stc(name), 0);
4099 }
4100
4101 // Describe a property.
4102 wxString wxStyledTextCtrl::DescribeProperty(const wxString& name) const {
4103 int msg = 4016;
4104 int len = SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)NULL);
4105 if (!len) return wxEmptyString;
4106
4107 wxMemoryBuffer mbuf(len+1);
4108 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4109 SendMsg(msg, (sptr_t)(const char*)wx2stc(name), (sptr_t)buf);
4110 mbuf.UngetWriteBuf(len);
4111 mbuf.AppendByte(0);
4112 return stc2wx(buf);
4113 }
4114
4115 // Retrieve a '\n' separated list of descriptions of the keyword sets understood by the current lexer.
4116 wxString wxStyledTextCtrl::DescribeKeyWordSets() const {
4117 int msg = 4017;
4118 int len = SendMsg(msg, 0, (sptr_t)NULL);
4119 if (!len) return wxEmptyString;
4120
4121 wxMemoryBuffer mbuf(len+1);
4122 char* buf = (char*)mbuf.GetWriteBuf(len+1);
4123 SendMsg(msg, 0, (sptr_t)buf);
4124 mbuf.UngetWriteBuf(len);
4125 mbuf.AppendByte(0);
4126 return stc2wx(buf);
4127 }
4128
4129 //}}}
4130 //----------------------------------------------------------------------
4131
4132
4133 // Returns the line number of the line with the caret.
4134 int wxStyledTextCtrl::GetCurrentLine() {
4135 int line = LineFromPosition(GetCurrentPos());
4136 return line;
4137 }
4138
4139
4140 // Extract style settings from a spec-string which is composed of one or
4141 // more of the following comma separated elements:
4142 //
4143 // bold turns on bold
4144 // italic turns on italics
4145 // fore:[name or #RRGGBB] sets the foreground colour
4146 // back:[name or #RRGGBB] sets the background colour
4147 // face:[facename] sets the font face name to use
4148 // size:[num] sets the font size in points
4149 // eol turns on eol filling
4150 // underline turns on underlining
4151 //
4152 void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) {
4153
4154 wxStringTokenizer tkz(spec, wxT(","));
4155 while (tkz.HasMoreTokens()) {
4156 wxString token = tkz.GetNextToken();
4157
4158 wxString option = token.BeforeFirst(':');
4159 wxString val = token.AfterFirst(':');
4160
4161 if (option == wxT("bold"))
4162 StyleSetBold(styleNum, true);
4163
4164 else if (option == wxT("italic"))
4165 StyleSetItalic(styleNum, true);
4166
4167 else if (option == wxT("underline"))
4168 StyleSetUnderline(styleNum, true);
4169
4170 else if (option == wxT("eol"))
4171 StyleSetEOLFilled(styleNum, true);
4172
4173 else if (option == wxT("size")) {
4174 long points;
4175 if (val.ToLong(&points))
4176 StyleSetSize(styleNum, points);
4177 }
4178
4179 else if (option == wxT("face"))
4180 StyleSetFaceName(styleNum, val);
4181
4182 else if (option == wxT("fore"))
4183 StyleSetForeground(styleNum, wxColourFromSpec(val));
4184
4185 else if (option == wxT("back"))
4186 StyleSetBackground(styleNum, wxColourFromSpec(val));
4187 }
4188 }
4189
4190
4191 // Get the font of a style
4192 wxFont wxStyledTextCtrl::StyleGetFont(int style) {
4193 wxFont font;
4194 font.SetPointSize(StyleGetSize(style));
4195 font.SetFaceName(StyleGetFaceName(style));
4196 if( StyleGetBold(style) )
4197 font.SetWeight(wxFONTWEIGHT_BOLD);
4198 else
4199 font.SetWeight(wxFONTWEIGHT_NORMAL);
4200
4201 if( StyleGetItalic(style) )
4202 font.SetStyle(wxFONTSTYLE_ITALIC);
4203 else
4204 font.SetStyle(wxFONTSTYLE_NORMAL);
4205
4206 return font;
4207 }
4208
4209
4210 // Set style size, face, bold, italic, and underline attributes from
4211 // a wxFont's attributes.
4212 void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) {
4213 #ifdef __WXGTK__
4214 // Ensure that the native font is initialized
4215 int x, y;
4216 GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font);
4217 #endif
4218 int size = font.GetPointSize();
4219 wxString faceName = font.GetFaceName();
4220 bool bold = font.GetWeight() == wxBOLD;
4221 bool italic = font.GetStyle() != wxNORMAL;
4222 bool under = font.GetUnderlined();
4223 wxFontEncoding encoding = font.GetEncoding();
4224
4225 StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding);
4226 }
4227
4228 // Set all font style attributes at once.
4229 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size,
4230 const wxString& faceName,
4231 bool bold, bool italic,
4232 bool underline,
4233 wxFontEncoding encoding) {
4234 StyleSetSize(styleNum, size);
4235 StyleSetFaceName(styleNum, faceName);
4236 StyleSetBold(styleNum, bold);
4237 StyleSetItalic(styleNum, italic);
4238 StyleSetUnderline(styleNum, underline);
4239 StyleSetFontEncoding(styleNum, encoding);
4240 }
4241
4242
4243 // Set the character set of the font in a style. Converts the Scintilla
4244 // character set values to a wxFontEncoding.
4245 void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet)
4246 {
4247 wxFontEncoding encoding;
4248
4249 // Translate the Scintilla characterSet to a wxFontEncoding
4250 switch (characterSet) {
4251 default:
4252 case wxSTC_CHARSET_ANSI:
4253 case wxSTC_CHARSET_DEFAULT:
4254 encoding = wxFONTENCODING_DEFAULT;
4255 break;
4256
4257 case wxSTC_CHARSET_BALTIC:
4258 encoding = wxFONTENCODING_ISO8859_13;
4259 break;
4260
4261 case wxSTC_CHARSET_CHINESEBIG5:
4262 encoding = wxFONTENCODING_CP950;
4263 break;
4264
4265 case wxSTC_CHARSET_EASTEUROPE:
4266 encoding = wxFONTENCODING_ISO8859_2;
4267 break;
4268
4269 case wxSTC_CHARSET_GB2312:
4270 encoding = wxFONTENCODING_CP936;
4271 break;
4272
4273 case wxSTC_CHARSET_GREEK:
4274 encoding = wxFONTENCODING_ISO8859_7;
4275 break;
4276
4277 case wxSTC_CHARSET_HANGUL:
4278 encoding = wxFONTENCODING_CP949;
4279 break;
4280
4281 case wxSTC_CHARSET_MAC:
4282 encoding = wxFONTENCODING_DEFAULT;
4283 break;
4284
4285 case wxSTC_CHARSET_OEM:
4286 encoding = wxFONTENCODING_DEFAULT;
4287 break;
4288
4289 case wxSTC_CHARSET_RUSSIAN:
4290 encoding = wxFONTENCODING_KOI8;
4291 break;
4292
4293 case wxSTC_CHARSET_SHIFTJIS:
4294 encoding = wxFONTENCODING_CP932;
4295 break;
4296
4297 case wxSTC_CHARSET_SYMBOL:
4298 encoding = wxFONTENCODING_DEFAULT;
4299 break;
4300
4301 case wxSTC_CHARSET_TURKISH:
4302 encoding = wxFONTENCODING_ISO8859_9;
4303 break;
4304
4305 case wxSTC_CHARSET_JOHAB:
4306 encoding = wxFONTENCODING_DEFAULT;
4307 break;
4308
4309 case wxSTC_CHARSET_HEBREW:
4310 encoding = wxFONTENCODING_ISO8859_8;
4311 break;
4312
4313 case wxSTC_CHARSET_ARABIC:
4314 encoding = wxFONTENCODING_ISO8859_6;
4315 break;
4316
4317 case wxSTC_CHARSET_VIETNAMESE:
4318 encoding = wxFONTENCODING_DEFAULT;
4319 break;
4320
4321 case wxSTC_CHARSET_THAI:
4322 encoding = wxFONTENCODING_ISO8859_11;
4323 break;
4324
4325 case wxSTC_CHARSET_CYRILLIC:
4326 encoding = wxFONTENCODING_ISO8859_5;
4327 break;
4328
4329 case wxSTC_CHARSET_8859_15:
4330 encoding = wxFONTENCODING_ISO8859_15;;
4331 break;
4332 }
4333
4334 // We just have Scintilla track the wxFontEncoding for us. It gets used
4335 // in Font::Create in PlatWX.cpp. We add one to the value so that the
4336 // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when
4337 // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back
4338 // to wxFONENCODING_DEFAULT in Font::Create.
4339 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
4340 }
4341
4342
4343 // Set the font encoding to be used by a style.
4344 void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding)
4345 {
4346 SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1);
4347 }
4348
4349
4350 // Perform one of the operations defined by the wxSTC_CMD_* constants.
4351 void wxStyledTextCtrl::CmdKeyExecute(int cmd) {
4352 SendMsg(cmd);
4353 }
4354
4355
4356 // Set the left and right margin in the edit area, measured in pixels.
4357 void wxStyledTextCtrl::SetMargins(int left, int right) {
4358 SetMarginLeft(left);
4359 SetMarginRight(right);
4360 }
4361
4362
4363 // Retrieve the point in the window where a position is displayed.
4364 wxPoint wxStyledTextCtrl::PointFromPosition(int pos) {
4365 int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos);
4366 int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos);
4367 return wxPoint(x, y);
4368 }
4369
4370 // Scroll enough to make the given line visible
4371 void wxStyledTextCtrl::ScrollToLine(int line) {
4372 m_swx->DoScrollToLine(line);
4373 }
4374
4375
4376 // Scroll enough to make the given column visible
4377 void wxStyledTextCtrl::ScrollToColumn(int column) {
4378 m_swx->DoScrollToColumn(column);
4379 }
4380
4381
4382 void wxStyledTextCtrl::DoSetValue(const wxString& value, int flags)
4383 {
4384 if ( flags & SetValue_SelectionOnly )
4385 ReplaceSelection(value);
4386 else
4387 SetText(value);
4388
4389 // We don't send wxEVT_TEXT anyhow, so ignore the
4390 // SetValue_SendEvent bit of the flags
4391 }
4392
4393 bool
4394 wxStyledTextCtrl::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
4395 {
4396 #if wxUSE_FFILE || wxUSE_FILE
4397
4398 #if wxUSE_FFILE
4399 // Take care to use "b" to ensure that possibly non-native EOLs in the file
4400 // contents are not mangled when saving it.
4401 wxFFile file(filename, wxS("wb"));
4402 #elif wxUSE_FILE
4403 wxFile file(filename, wxFile::write);
4404 #endif
4405
4406 if ( file.IsOpened() && file.Write(GetValue(), *wxConvCurrent) )
4407 {
4408 SetSavePoint();
4409
4410 return true;
4411 }
4412
4413 #endif // !wxUSE_FFILE && !wxUSE_FILE
4414
4415 return false;
4416 }
4417
4418 bool
4419 wxStyledTextCtrl::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
4420 {
4421 #if wxUSE_FFILE || wxUSE_FILE
4422
4423 #if wxUSE_FFILE
4424 // As above, we want to read the real EOLs from the file, e.g. without
4425 // translating them to just LFs under Windows, so that the original CR LF
4426 // are preserved when it's written back.
4427 wxFFile file(filename, wxS("rb"));
4428 #else
4429 wxFile file(filename);
4430 #endif
4431
4432 if ( file.IsOpened() )
4433 {
4434 wxString text;
4435 if ( file.ReadAll(&text, wxConvAuto()) )
4436 {
4437 // Detect the EOL: we use just the first line because there is not
4438 // much we can do if the file uses inconsistent EOLs anyhow, we'd
4439 // need to ask the user about the one we should really use and we
4440 // don't currently provide a way to do it.
4441 //
4442 // We also only check for Unix and DOS EOLs but not classic Mac
4443 // CR-only one as it's obsolete by now.
4444 const wxString::size_type posLF = text.find('\n');
4445 if ( posLF != wxString::npos )
4446 {
4447 // Set EOL mode to ensure that the new lines inserted into the
4448 // text use the same EOLs as the existing ones.
4449 if ( posLF > 0 && text[posLF - 1] == '\r' )
4450 SetEOLMode(wxSTC_EOL_CRLF);
4451 else
4452 SetEOLMode(wxSTC_EOL_LF);
4453 }
4454 //else: Use the default EOL for the current platform.
4455
4456 SetValue(text);
4457 EmptyUndoBuffer();
4458 SetSavePoint();
4459
4460 return true;
4461 }
4462 }
4463 #endif // !wxUSE_FFILE && !wxUSE_FILE
4464
4465 return false;
4466 }
4467
4468 // If we don't derive from wxTextAreaBase, we need to implement these methods
4469 // ourselves, otherwise we already inherit them.
4470 #if !wxUSE_TEXTCTRL
4471
4472 bool wxStyledTextCtrl::SaveFile(const wxString& filename)
4473 {
4474 if ( filename.empty() )
4475 return false;
4476
4477 return DoSaveFile(filename, wxTEXT_TYPE_ANY);
4478 }
4479
4480 bool wxStyledTextCtrl::LoadFile(const wxString& filename)
4481 {
4482 if ( filename.empty() )
4483 return false;
4484
4485 return DoLoadFile(filename, wxTEXT_TYPE_ANY);
4486 }
4487
4488 #endif // !wxUSE_TEXTCTRL
4489
4490 #if wxUSE_DRAG_AND_DROP
4491 wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
4492 return m_swx->DoDragOver(x, y, def);
4493 }
4494
4495
4496 bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
4497 return m_swx->DoDropText(x, y, data);
4498 }
4499 #endif
4500
4501
4502 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
4503 m_swx->SetUseAntiAliasing(useAA);
4504 }
4505
4506 bool wxStyledTextCtrl::GetUseAntiAliasing() {
4507 return m_swx->GetUseAntiAliasing();
4508 }
4509
4510 void wxStyledTextCtrl::AnnotationClearLine(int line) {
4511 SendMsg(SCI_ANNOTATIONSETTEXT, line, (sptr_t)NULL);
4512 }
4513
4514
4515
4516
4517 void wxStyledTextCtrl::AddTextRaw(const char* text, int length)
4518 {
4519 if (length == -1)
4520 length = strlen(text);
4521 SendMsg(SCI_ADDTEXT, length, (sptr_t)text);
4522 }
4523
4524 void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
4525 {
4526 SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text);
4527 }
4528
4529 wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
4530 {
4531 int len = LineLength(GetCurrentLine());
4532 if (!len) {
4533 if (linePos) *linePos = 0;
4534 wxCharBuffer empty;
4535 return empty;
4536 }
4537
4538 wxCharBuffer buf(len);
4539 int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data());
4540 if (linePos) *linePos = pos;
4541 return buf;
4542 }
4543
4544 wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
4545 {
4546 int len = LineLength(line);
4547 if (!len) {
4548 wxCharBuffer empty;
4549 return empty;
4550 }
4551
4552 wxCharBuffer buf(len);
4553 SendMsg(SCI_GETLINE, line, (sptr_t)buf.data());
4554 return buf;
4555 }
4556
4557 wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
4558 {
4559 // Calculate the length needed first.
4560 const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0);
4561
4562 // And then really get the data.
4563 wxCharBuffer buf(len);
4564 SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data());
4565 return buf;
4566 }
4567
4568 wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
4569 {
4570 if (endPos < startPos) {
4571 int temp = startPos;
4572 startPos = endPos;
4573 endPos = temp;
4574 }
4575 int len = endPos - startPos;
4576 if (!len) {
4577 wxCharBuffer empty;
4578 return empty;
4579 }
4580
4581 wxCharBuffer buf(len);
4582 TextRange tr;
4583 tr.lpstrText = buf.data();
4584 tr.chrg.cpMin = startPos;
4585 tr.chrg.cpMax = endPos;
4586 SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr);
4587 return buf;
4588 }
4589
4590 void wxStyledTextCtrl::SetTextRaw(const char* text)
4591 {
4592 SendMsg(SCI_SETTEXT, 0, (sptr_t)text);
4593 }
4594
4595 wxCharBuffer wxStyledTextCtrl::GetTextRaw()
4596 {
4597 int len = GetTextLength();
4598 wxCharBuffer buf(len); // adds 1 for NUL automatically
4599 SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data());
4600 return buf;
4601 }
4602
4603 void wxStyledTextCtrl::AppendTextRaw(const char* text, int length)
4604 {
4605 if (length == -1)
4606 length = strlen(text);
4607 SendMsg(SCI_APPENDTEXT, length, (sptr_t)text);
4608 }
4609
4610
4611
4612
4613
4614 //----------------------------------------------------------------------
4615 // Event handlers
4616
4617 void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) {
4618 #ifdef __WXGTK__
4619 wxBufferedPaintDC dc(this);
4620 #else
4621 wxPaintDC dc(this);
4622 #endif
4623 m_swx->DoPaint(&dc, GetUpdateRegion().GetBox());
4624 }
4625
4626 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) {
4627 if (evt.GetOrientation() == wxHORIZONTAL)
4628 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4629 else
4630 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4631 }
4632
4633 void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) {
4634 wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar);
4635 if (sb) {
4636 if (sb->IsVertical())
4637 m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition());
4638 else
4639 m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition());
4640 }
4641 }
4642
4643 void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) {
4644 if (m_swx) {
4645 wxSize sz = GetClientSize();
4646 m_swx->DoSize(sz.x, sz.y);
4647 }
4648 }
4649
4650 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {
4651 SetFocus();
4652 wxPoint pt = evt.GetPosition();
4653 m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(),
4654 evt.ShiftDown(), evt.ControlDown(), evt.AltDown());
4655 }
4656
4657 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) {
4658 wxPoint pt = evt.GetPosition();
4659 m_swx->DoLeftButtonMove(Point(pt.x, pt.y));
4660 }
4661
4662 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) {
4663 wxPoint pt = evt.GetPosition();
4664 m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(),
4665 evt.ControlDown());
4666 }
4667
4668
4669 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) {
4670 wxPoint pt = evt.GetPosition();
4671 m_swx->DoContextMenu(Point(pt.x, pt.y));
4672 }
4673
4674
4675 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) {
4676 wxPoint pt = evt.GetPosition();
4677 m_swx->DoMiddleButtonUp(Point(pt.x, pt.y));
4678 }
4679
4680 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) {
4681 wxPoint pt = evt.GetPosition();
4682 ScreenToClient(&pt.x, &pt.y);
4683 /*
4684 Show context menu at event point if it's within the window,
4685 or at caret location if not
4686 */
4687 wxHitTest ht = this->HitTest(pt);
4688 if (ht != wxHT_WINDOW_INSIDE) {
4689 pt = this->PointFromPosition(this->GetCurrentPos());
4690 }
4691 m_swx->DoContextMenu(Point(pt.x, pt.y));
4692 }
4693
4694
4695 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt)
4696 {
4697 m_swx->DoMouseWheel(evt.GetWheelAxis(),
4698 evt.GetWheelRotation(),
4699 evt.GetWheelDelta(),
4700 evt.GetLinesPerAction(),
4701 evt.GetColumnsPerAction(),
4702 evt.ControlDown(),
4703 evt.IsPageScroll());
4704 }
4705
4706
4707 void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) {
4708 // On (some?) non-US PC keyboards the AltGr key is required to enter some
4709 // common characters. It comes to us as both Alt and Ctrl down so we need
4710 // to let the char through in that case, otherwise if only ctrl or only
4711 // alt let's skip it.
4712 bool ctrl = evt.ControlDown();
4713 #ifdef __WXMAC__
4714 // On the Mac the Alt key is just a modifier key (like Shift) so we need
4715 // to allow the char events to be processed when Alt is pressed.
4716 // TODO: Should we check MetaDown instead in this case?
4717 bool alt = false;
4718 #else
4719 bool alt = evt.AltDown();
4720 #endif
4721 bool skip = ((ctrl || alt) && ! (ctrl && alt));
4722
4723 #if wxUSE_UNICODE
4724 // apparently if we don't do this, Unicode keys pressed after non-char
4725 // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989)
4726 if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255)
4727 m_lastKeyDownConsumed = false;
4728 #endif
4729
4730 if (!m_lastKeyDownConsumed && !skip) {
4731 #if wxUSE_UNICODE
4732 int key = evt.GetUnicodeKey();
4733 bool keyOk = true;
4734
4735 // if the unicode key code is not really a unicode character (it may
4736 // be a function key or etc., the platforms appear to always give us a
4737 // small value in this case) then fallback to the ascii key code but
4738 // don't do anything for function keys or etc.
4739 if (key <= 127) {
4740 key = evt.GetKeyCode();
4741 keyOk = (key <= 127);
4742 }
4743 if (keyOk) {
4744 m_swx->DoAddChar(key);
4745 return;
4746 }
4747 #else
4748 int key = evt.GetKeyCode();
4749 if (key <= WXK_START || key > WXK_COMMAND) {
4750 m_swx->DoAddChar(key);
4751 return;
4752 }
4753 #endif
4754 }
4755
4756 evt.Skip();
4757 }
4758
4759
4760 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) {
4761 int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed);
4762 if (!processed && !m_lastKeyDownConsumed)
4763 evt.Skip();
4764 }
4765
4766
4767 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) {
4768 m_swx->DoLoseFocus();
4769 evt.Skip();
4770 }
4771
4772
4773 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) {
4774 m_swx->DoGainFocus();
4775 evt.Skip();
4776 }
4777
4778
4779 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) {
4780 m_swx->DoSysColourChange();
4781 }
4782
4783
4784 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) {
4785 // do nothing to help avoid flashing
4786 }
4787
4788
4789
4790 void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) {
4791 m_swx->DoCommand(evt.GetId());
4792 }
4793
4794
4795 void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) {
4796 m_swx->DoOnListBox();
4797 }
4798
4799
4800 void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) {
4801 m_swx->DoOnIdle(evt);
4802 }
4803
4804
4805 wxSize wxStyledTextCtrl::DoGetBestSize() const
4806 {
4807 // What would be the best size for a wxSTC?
4808 // Just give a reasonable minimum until something else can be figured out.
4809 return wxSize(200,100);
4810 }
4811
4812
4813 //----------------------------------------------------------------------
4814 // Turn notifications from Scintilla into events
4815
4816
4817 void wxStyledTextCtrl::NotifyChange() {
4818 wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId());
4819 evt.SetEventObject(this);
4820 GetEventHandler()->ProcessEvent(evt);
4821 }
4822
4823
4824 static void SetEventText(wxStyledTextEvent& evt, const char* text,
4825 size_t length) {
4826 if(!text) return;
4827
4828 evt.SetText(stc2wx(text, length));
4829 }
4830
4831
4832 void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) {
4833 SCNotification& scn = *_scn;
4834 wxStyledTextEvent evt(0, GetId());
4835
4836 evt.SetEventObject(this);
4837 evt.SetPosition(scn.position);
4838 evt.SetKey(scn.ch);
4839 evt.SetModifiers(scn.modifiers);
4840
4841 switch (scn.nmhdr.code) {
4842 case SCN_STYLENEEDED:
4843 evt.SetEventType(wxEVT_STC_STYLENEEDED);
4844 break;
4845
4846 case SCN_CHARADDED:
4847 evt.SetEventType(wxEVT_STC_CHARADDED);
4848 break;
4849
4850 case SCN_SAVEPOINTREACHED:
4851 evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED);
4852 break;
4853
4854 case SCN_SAVEPOINTLEFT:
4855 evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT);
4856 break;
4857
4858 case SCN_MODIFYATTEMPTRO:
4859 evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT);
4860 break;
4861
4862 case SCN_KEY:
4863 evt.SetEventType(wxEVT_STC_KEY);
4864 break;
4865
4866 case SCN_DOUBLECLICK:
4867 evt.SetEventType(wxEVT_STC_DOUBLECLICK);
4868 evt.SetLine(scn.line);
4869 break;
4870
4871 case SCN_UPDATEUI:
4872 evt.SetEventType(wxEVT_STC_UPDATEUI);
4873 evt.SetUpdated(scn.updated);
4874 break;
4875
4876 case SCN_MODIFIED:
4877 evt.SetEventType(wxEVT_STC_MODIFIED);
4878 evt.SetModificationType(scn.modificationType);
4879 SetEventText(evt, scn.text, scn.length);
4880 evt.SetLength(scn.length);
4881 evt.SetLinesAdded(scn.linesAdded);
4882 evt.SetLine(scn.line);
4883 evt.SetFoldLevelNow(scn.foldLevelNow);
4884 evt.SetFoldLevelPrev(scn.foldLevelPrev);
4885 evt.SetToken(scn.token);
4886 evt.SetAnnotationLinesAdded(scn.annotationLinesAdded);
4887 break;
4888
4889 case SCN_MACRORECORD:
4890 evt.SetEventType(wxEVT_STC_MACRORECORD);
4891 evt.SetMessage(scn.message);
4892 evt.SetWParam(scn.wParam);
4893 evt.SetLParam(scn.lParam);
4894 break;
4895
4896 case SCN_MARGINCLICK:
4897 evt.SetEventType(wxEVT_STC_MARGINCLICK);
4898 evt.SetMargin(scn.margin);
4899 break;
4900
4901 case SCN_NEEDSHOWN:
4902 evt.SetEventType(wxEVT_STC_NEEDSHOWN);
4903 evt.SetLength(scn.length);
4904 break;
4905
4906 case SCN_PAINTED:
4907 evt.SetEventType(wxEVT_STC_PAINTED);
4908 break;
4909
4910 case SCN_AUTOCSELECTION:
4911 evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION);
4912 evt.SetListType(scn.listType);
4913 SetEventText(evt, scn.text, strlen(scn.text));
4914 evt.SetPosition(scn.lParam);
4915 break;
4916
4917 case SCN_USERLISTSELECTION:
4918 evt.SetEventType(wxEVT_STC_USERLISTSELECTION);
4919 evt.SetListType(scn.listType);
4920 SetEventText(evt, scn.text, strlen(scn.text));
4921 evt.SetPosition(scn.lParam);
4922 break;
4923
4924 case SCN_URIDROPPED:
4925 evt.SetEventType(wxEVT_STC_URIDROPPED);
4926 SetEventText(evt, scn.text, strlen(scn.text));
4927 break;
4928
4929 case SCN_DWELLSTART:
4930 evt.SetEventType(wxEVT_STC_DWELLSTART);
4931 evt.SetX(scn.x);
4932 evt.SetY(scn.y);
4933 break;
4934
4935 case SCN_DWELLEND:
4936 evt.SetEventType(wxEVT_STC_DWELLEND);
4937 evt.SetX(scn.x);
4938 evt.SetY(scn.y);
4939 break;
4940
4941 case SCN_ZOOM:
4942 evt.SetEventType(wxEVT_STC_ZOOM);
4943 break;
4944
4945 case SCN_HOTSPOTCLICK:
4946 evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK);
4947 break;
4948
4949 case SCN_HOTSPOTDOUBLECLICK:
4950 evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK);
4951 break;
4952
4953 case SCN_CALLTIPCLICK:
4954 evt.SetEventType(wxEVT_STC_CALLTIP_CLICK);
4955 break;
4956
4957 case SCN_INDICATORCLICK:
4958 evt.SetEventType(wxEVT_STC_INDICATOR_CLICK);
4959 break;
4960
4961 case SCN_INDICATORRELEASE:
4962 evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE);
4963 break;
4964
4965 case SCN_AUTOCCANCELLED:
4966 evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED);
4967 break;
4968
4969 case SCN_AUTOCCHARDELETED:
4970 evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED);
4971 break;
4972
4973 case SCN_HOTSPOTRELEASECLICK:
4974 evt.SetEventType(wxEVT_STC_HOTSPOT_RELEASE_CLICK);
4975 break;
4976
4977 default:
4978 return;
4979 }
4980
4981 GetEventHandler()->ProcessEvent(evt);
4982 }
4983
4984
4985 //----------------------------------------------------------------------
4986 //----------------------------------------------------------------------
4987 //----------------------------------------------------------------------
4988
4989 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id)
4990 : wxCommandEvent(commandType, id)
4991 {
4992 m_position = 0;
4993 m_key = 0;
4994 m_modifiers = 0;
4995 m_modificationType = 0;
4996 m_length = 0;
4997 m_linesAdded = 0;
4998 m_line = 0;
4999 m_foldLevelNow = 0;
5000 m_foldLevelPrev = 0;
5001 m_margin = 0;
5002 m_message = 0;
5003 m_wParam = 0;
5004 m_lParam = 0;
5005 m_listType = 0;
5006 m_x = 0;
5007 m_y = 0;
5008 m_token = 0;
5009 m_annotationLinesAdded = 0;
5010 m_updated = 0;
5011
5012 #if wxUSE_DRAG_AND_DROP
5013 m_dragFlags = wxDrag_CopyOnly;
5014 m_dragResult = wxDragNone;
5015 #endif
5016 }
5017
5018 bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; }
5019 bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; }
5020 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; }
5021
5022
5023 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event):
5024 wxCommandEvent(event)
5025 {
5026 m_position = event.m_position;
5027 m_key = event.m_key;
5028 m_modifiers = event.m_modifiers;
5029 m_modificationType = event.m_modificationType;
5030 m_text = event.m_text;
5031 m_length = event.m_length;
5032 m_linesAdded = event.m_linesAdded;
5033 m_line = event.m_line;
5034 m_foldLevelNow = event.m_foldLevelNow;
5035 m_foldLevelPrev = event.m_foldLevelPrev;
5036
5037 m_margin = event.m_margin;
5038
5039 m_message = event.m_message;
5040 m_wParam = event.m_wParam;
5041 m_lParam = event.m_lParam;
5042
5043 m_listType = event.m_listType;
5044 m_x = event.m_x;
5045 m_y = event.m_y;
5046
5047 m_token = event.m_token;
5048 m_annotationLinesAdded = event.m_annotationLinesAdded;
5049 m_updated = event.m_updated;
5050
5051 #if wxUSE_DRAG_AND_DROP
5052 m_dragText = event.m_dragText;
5053 m_dragFlags = event.m_dragFlags;
5054 m_dragResult = event.m_dragResult;
5055 #endif
5056 }
5057
5058 //----------------------------------------------------------------------
5059 //----------------------------------------------------------------------
5060
5061 /*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo()
5062 {
5063 return wxVersionInfo("Scintilla", 3, 21, 0, "Scintilla 3.21");
5064 }
5065
5066 #endif // wxUSE_STC