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