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