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