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