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