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