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