1 ////////////////////////////////////////////////////////////////////////////
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.
12 // Created: 13-Jan-2000
14 // Copyright: (c) 2000 by Total Control Software
15 // Licence: wxWindows license
16 /////////////////////////////////////////////////////////////////////////////
20 #include "wx/stc/stc.h"
21 #include "ScintillaWX.h"
24 #include <wx/tokenzr.h>
25 #include <wx/mstream.h>
29 //----------------------------------------------------------------------
31 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
37 #define MAKELONG(a, b) ((a) | ((b) << 16))
40 static long wxColourAsLong(const wxColour
& co
) {
41 return (((long)co
.Blue() << 16) |
42 ((long)co
.Green() << 8) |
46 static wxColour
wxColourFromLong(long c
) {
48 clr
.Set(c
& 0xff, (c
>> 8) & 0xff, (c
>> 16) & 0xff);
53 static wxColour
wxColourFromSpec(const wxString
& spec
) {
54 // spec should be "#RRGGBB"
55 long red
, green
, blue
;
56 red
= green
= blue
= 0;
57 spec
.Mid(1,2).ToLong(&red
, 16);
58 spec
.Mid(3,2).ToLong(&green
, 16);
59 spec
.Mid(5,2).ToLong(&blue
, 16);
60 return wxColour(red
, green
, blue
);
63 //----------------------------------------------------------------------
65 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
66 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
67 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
68 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
69 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
70 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
71 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
72 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
73 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
74 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
75 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
76 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
77 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
78 DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED
)
79 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
80 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
81 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
82 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
83 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
84 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
85 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
94 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
95 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
96 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
97 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
98 EVT_SIZE (wxStyledTextCtrl::OnSize
)
99 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
100 // Let Scintilla see the double click as a second click
101 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
102 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
103 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
104 #if defined(__WXGTK__) || defined(__WXMAC__)
105 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
107 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
109 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
110 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
111 EVT_CHAR (wxStyledTextCtrl::OnChar
)
112 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
113 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
114 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
115 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
116 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
117 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
118 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox
)
122 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
123 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
126 // forces the linking of the lexer modules
127 int Scintilla_LinkLexers();
130 //----------------------------------------------------------------------
131 // Constructor and Destructor
133 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
138 const wxString
& name
) :
139 wxControl(parent
, id
, pos
, size
,
140 style
| wxVSCROLL
| wxHSCROLL
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
141 wxDefaultValidator
, name
)
144 Scintilla_LinkLexers();
146 m_swx
= new ScintillaWX(this);
148 m_lastKeyDownConsumed
= FALSE
;
152 // Put Scintilla into unicode (UTF-8) mode
153 SetCodePage(wxSTC_CP_UTF8
);
158 wxStyledTextCtrl::~wxStyledTextCtrl() {
163 //----------------------------------------------------------------------
165 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
167 return m_swx
->WndProc(msg
, wp
, lp
);
172 //----------------------------------------------------------------------
173 // BEGIN generated section. The following code is automatically generated
174 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
175 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
178 // Add text to the document.
179 void wxStyledTextCtrl::AddText(const wxString
& text
) {
180 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
181 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
184 // Add array of cells to document.
185 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
186 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
189 // Insert string at a position.
190 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
191 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
194 // Delete all text in the document.
195 void wxStyledTextCtrl::ClearAll() {
199 // Set all style bytes to 0, remove all folding information.
200 void wxStyledTextCtrl::ClearDocumentStyle() {
204 // The number of characters in the document.
205 int wxStyledTextCtrl::GetLength() {
206 return SendMsg(2006, 0, 0);
209 // Returns the character byte at the position.
210 int wxStyledTextCtrl::GetCharAt(int pos
) {
211 return (unsigned char)SendMsg(2007, pos
, 0);
214 // Returns the position of the caret.
215 int wxStyledTextCtrl::GetCurrentPos() {
216 return SendMsg(2008, 0, 0);
219 // Returns the position of the opposite end of the selection to the caret.
220 int wxStyledTextCtrl::GetAnchor() {
221 return SendMsg(2009, 0, 0);
224 // Returns the style byte at the position.
225 int wxStyledTextCtrl::GetStyleAt(int pos
) {
226 return (unsigned char)SendMsg(2010, pos
, 0);
229 // Redoes the next action on the undo history.
230 void wxStyledTextCtrl::Redo() {
234 // Choose between collecting actions into the undo
235 // history and discarding them.
236 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
237 SendMsg(2012, collectUndo
, 0);
240 // Select all the text in the document.
241 void wxStyledTextCtrl::SelectAll() {
245 // Remember the current position in the undo history as the position
246 // at which the document was saved.
247 void wxStyledTextCtrl::SetSavePoint() {
251 // Retrieve a buffer of cells.
252 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
254 if (endPos
< startPos
) {
259 int len
= endPos
- startPos
;
260 if (!len
) return buf
;
262 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
263 tr
.chrg
.cpMin
= startPos
;
264 tr
.chrg
.cpMax
= endPos
;
265 len
= SendMsg(2015, 0, (long)&tr
);
266 buf
.UngetWriteBuf(len
);
270 // Are there any redoable actions in the undo history?
271 bool wxStyledTextCtrl::CanRedo() {
272 return SendMsg(2016, 0, 0) != 0;
275 // Retrieve the line number at which a particular marker is located.
276 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
277 return SendMsg(2017, handle
, 0);
281 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
282 SendMsg(2018, handle
, 0);
285 // Is undo history being collected?
286 bool wxStyledTextCtrl::GetUndoCollection() {
287 return SendMsg(2019, 0, 0) != 0;
290 // Are white space characters currently visible?
291 // Returns one of SCWS_* constants.
292 int wxStyledTextCtrl::GetViewWhiteSpace() {
293 return SendMsg(2020, 0, 0);
296 // Make white space characters invisible, always visible or visible outside indentation.
297 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
298 SendMsg(2021, viewWS
, 0);
301 // Find the position from a point within the window.
302 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
303 return SendMsg(2022, pt
.x
, pt
.y
);
306 // Find the position from a point within the window but return
307 // INVALID_POSITION if not close to text.
308 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
309 return SendMsg(2023, x
, y
);
312 // Set caret to start of a line and ensure it is visible.
313 void wxStyledTextCtrl::GotoLine(int line
) {
314 SendMsg(2024, line
, 0);
317 // Set caret to a position and ensure it is visible.
318 void wxStyledTextCtrl::GotoPos(int pos
) {
319 SendMsg(2025, pos
, 0);
322 // Set the selection anchor to a position. The anchor is the opposite
323 // end of the selection from the caret.
324 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
325 SendMsg(2026, posAnchor
, 0);
328 // Retrieve the text of the line containing the caret.
329 // Returns the index of the caret on the line.
330 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
331 int len
= LineLength(GetCurrentLine());
333 if (linePos
) *linePos
= 0;
334 return wxEmptyString
;
337 wxMemoryBuffer
mbuf(len
+1);
338 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
340 int pos
= SendMsg(2027, len
+1, (long)buf
);
341 mbuf
.UngetWriteBuf(len
);
343 if (linePos
) *linePos
= pos
;
347 // Retrieve the position of the last correctly styled character.
348 int wxStyledTextCtrl::GetEndStyled() {
349 return SendMsg(2028, 0, 0);
352 // Convert all line endings in the document to one mode.
353 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
354 SendMsg(2029, eolMode
, 0);
357 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
358 int wxStyledTextCtrl::GetEOLMode() {
359 return SendMsg(2030, 0, 0);
362 // Set the current end of line mode.
363 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
364 SendMsg(2031, eolMode
, 0);
367 // Set the current styling position to pos and the styling mask to mask.
368 // The styling mask can be used to protect some bits in each styling byte from modification.
369 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
370 SendMsg(2032, pos
, mask
);
373 // Change style from current styling position for length characters to a style
374 // and move the current styling position to after this newly styled segment.
375 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
376 SendMsg(2033, length
, style
);
379 // Is drawing done first into a buffer or direct to the screen?
380 bool wxStyledTextCtrl::GetBufferedDraw() {
381 return SendMsg(2034, 0, 0) != 0;
384 // If drawing is buffered then each line of text is drawn into a bitmap buffer
385 // before drawing it to the screen to avoid flicker.
386 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
387 SendMsg(2035, buffered
, 0);
390 // Change the visible size of a tab to be a multiple of the width of a space character.
391 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
392 SendMsg(2036, tabWidth
, 0);
395 // Retrieve the visible size of a tab.
396 int wxStyledTextCtrl::GetTabWidth() {
397 return SendMsg(2121, 0, 0);
400 // Set the code page used to interpret the bytes of the document as characters.
401 void wxStyledTextCtrl::SetCodePage(int codePage
) {
403 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
404 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
406 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
407 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
409 SendMsg(2037, codePage
);
412 // Set the symbol used for a particular marker number,
413 // and optionally the fore and background colours.
414 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
415 const wxColour
& foreground
,
416 const wxColour
& background
) {
418 SendMsg(2040, markerNumber
, markerSymbol
);
420 MarkerSetForeground(markerNumber
, foreground
);
422 MarkerSetBackground(markerNumber
, background
);
425 // Set the foreground colour used for a particular marker number.
426 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
427 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
430 // Set the background colour used for a particular marker number.
431 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
432 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
435 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
436 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
437 return SendMsg(2043, line
, markerNumber
);
440 // Delete a marker from a line.
441 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
442 SendMsg(2044, line
, markerNumber
);
445 // Delete all markers with a particular number from all lines.
446 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
447 SendMsg(2045, markerNumber
, 0);
450 // Get a bit mask of all the markers set on a line.
451 int wxStyledTextCtrl::MarkerGet(int line
) {
452 return SendMsg(2046, line
, 0);
455 // Find the next line after lineStart that includes a marker in mask.
456 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
457 return SendMsg(2047, lineStart
, markerMask
);
460 // Find the previous line before lineStart that includes a marker in mask.
461 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
462 return SendMsg(2048, lineStart
, markerMask
);
465 // Define a marker from a bitmap
466 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
467 // convert bmp to a xpm in a string
468 wxMemoryOutputStream strm
;
469 wxImage img
= bmp
.ConvertToImage();
470 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
471 size_t len
= strm
.GetSize();
472 char* buff
= new char[len
+1];
473 strm
.CopyTo(buff
, len
);
475 SendMsg(2049, markerNumber
, (long)buff
);
480 // Set a margin to be either numeric or symbolic.
481 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
482 SendMsg(2240, margin
, marginType
);
485 // Retrieve the type of a margin.
486 int wxStyledTextCtrl::GetMarginType(int margin
) {
487 return SendMsg(2241, margin
, 0);
490 // Set the width of a margin to a width expressed in pixels.
491 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
492 SendMsg(2242, margin
, pixelWidth
);
495 // Retrieve the width of a margin in pixels.
496 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
497 return SendMsg(2243, margin
, 0);
500 // Set a mask that determines which markers are displayed in a margin.
501 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
502 SendMsg(2244, margin
, mask
);
505 // Retrieve the marker mask of a margin.
506 int wxStyledTextCtrl::GetMarginMask(int margin
) {
507 return SendMsg(2245, margin
, 0);
510 // Make a margin sensitive or insensitive to mouse clicks.
511 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
512 SendMsg(2246, margin
, sensitive
);
515 // Retrieve the mouse click sensitivity of a margin.
516 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
517 return SendMsg(2247, margin
, 0) != 0;
520 // Clear all the styles and make equivalent to the global default style.
521 void wxStyledTextCtrl::StyleClearAll() {
525 // Set the foreground colour of a style.
526 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
527 SendMsg(2051, style
, wxColourAsLong(fore
));
530 // Set the background colour of a style.
531 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
532 SendMsg(2052, style
, wxColourAsLong(back
));
535 // Set a style to be bold or not.
536 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
537 SendMsg(2053, style
, bold
);
540 // Set a style to be italic or not.
541 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
542 SendMsg(2054, style
, italic
);
545 // Set the size of characters of a style.
546 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
547 SendMsg(2055, style
, sizePoints
);
550 // Set the font of a style.
551 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
552 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
555 // Set a style to have its end of line filled or not.
556 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
557 SendMsg(2057, style
, filled
);
560 // Reset the default style to its state at startup
561 void wxStyledTextCtrl::StyleResetDefault() {
565 // Set a style to be underlined or not.
566 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
567 SendMsg(2059, style
, underline
);
570 // Set a style to be mixed case, or to force upper or lower case.
571 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
572 SendMsg(2060, style
, caseForce
);
575 // Set the character set of the font in a style.
576 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
) {
577 SendMsg(2066, style
, characterSet
);
580 // Set a style to be a hotspot or not.
581 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
582 SendMsg(2409, style
, hotspot
);
585 // Set the foreground colour of the selection and whether to use this setting.
586 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
587 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
590 // Set the background colour of the selection and whether to use this setting.
591 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
592 SendMsg(2068, useSetting
, wxColourAsLong(back
));
595 // Set the foreground colour of the caret.
596 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
597 SendMsg(2069, wxColourAsLong(fore
), 0);
600 // When key+modifier combination km is pressed perform msg.
601 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
602 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
605 // When key+modifier combination km do nothing.
606 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
607 SendMsg(2071, MAKELONG(key
, modifiers
));
610 // Drop all key mappings.
611 void wxStyledTextCtrl::CmdKeyClearAll() {
615 // Set the styles for a segment of the document.
616 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
617 SendMsg(2073, length
, (long)styleBytes
);
620 // Set a style to be visible or not.
621 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
622 SendMsg(2074, style
, visible
);
625 // Get the time in milliseconds that the caret is on and off.
626 int wxStyledTextCtrl::GetCaretPeriod() {
627 return SendMsg(2075, 0, 0);
630 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
631 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
632 SendMsg(2076, periodMilliseconds
, 0);
635 // Set the set of characters making up words for when moving or selecting by word.
636 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
637 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
640 // Start a sequence of actions that is undone and redone as a unit.
642 void wxStyledTextCtrl::BeginUndoAction() {
646 // End a sequence of actions that is undone and redone as a unit.
647 void wxStyledTextCtrl::EndUndoAction() {
651 // Set an indicator to plain, squiggle or TT.
652 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
653 SendMsg(2080, indic
, style
);
656 // Retrieve the style of an indicator.
657 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
658 return SendMsg(2081, indic
, 0);
661 // Set the foreground colour of an indicator.
662 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
663 SendMsg(2082, indic
, wxColourAsLong(fore
));
666 // Retrieve the foreground colour of an indicator.
667 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
668 long c
= SendMsg(2083, indic
, 0);
669 return wxColourFromLong(c
);
672 // Set the foreground colour of all whitespace and whether to use this setting.
673 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
674 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
677 // Set the background colour of all whitespace and whether to use this setting.
678 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
679 SendMsg(2085, useSetting
, wxColourAsLong(back
));
682 // Divide each styling byte into lexical class bits (default: 5) and indicator
683 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
684 // is used to expand the possible states.
685 void wxStyledTextCtrl::SetStyleBits(int bits
) {
686 SendMsg(2090, bits
, 0);
689 // Retrieve number of bits in style bytes used to hold the lexical state.
690 int wxStyledTextCtrl::GetStyleBits() {
691 return SendMsg(2091, 0, 0);
694 // Used to hold extra styling information for each line.
695 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
696 SendMsg(2092, line
, state
);
699 // Retrieve the extra styling information for a line.
700 int wxStyledTextCtrl::GetLineState(int line
) {
701 return SendMsg(2093, line
, 0);
704 // Retrieve the last line number that has line state.
705 int wxStyledTextCtrl::GetMaxLineState() {
706 return SendMsg(2094, 0, 0);
709 // Is the background of the line containing the caret in a different colour?
710 bool wxStyledTextCtrl::GetCaretLineVisible() {
711 return SendMsg(2095, 0, 0) != 0;
714 // Display the background of the line containing the caret in a different colour.
715 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
716 SendMsg(2096, show
, 0);
719 // Get the colour of the background of the line containing the caret.
720 wxColour
wxStyledTextCtrl::GetCaretLineBack() {
721 long c
= SendMsg(2097, 0, 0);
722 return wxColourFromLong(c
);
725 // Set the colour of the background of the line containing the caret.
726 void wxStyledTextCtrl::SetCaretLineBack(const wxColour
& back
) {
727 SendMsg(2098, wxColourAsLong(back
), 0);
730 // Set a style to be changeable or not (read only).
731 // Experimental feature, currently buggy.
732 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
733 SendMsg(2099, style
, changeable
);
736 // Display a auto-completion list.
737 // The lenEntered parameter indicates how many characters before
738 // the caret should be used to provide context.
739 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
740 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
743 // Remove the auto-completion list from the screen.
744 void wxStyledTextCtrl::AutoCompCancel() {
748 // Is there an auto-completion list visible?
749 bool wxStyledTextCtrl::AutoCompActive() {
750 return SendMsg(2102, 0, 0) != 0;
753 // Retrieve the position of the caret when the auto-completion list was displayed.
754 int wxStyledTextCtrl::AutoCompPosStart() {
755 return SendMsg(2103, 0, 0);
758 // User has selected an item so remove the list and insert the selection.
759 void wxStyledTextCtrl::AutoCompComplete() {
763 // Define a set of character that when typed cancel the auto-completion list.
764 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
765 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
768 // Change the separator character in the string setting up an auto-completion list.
769 // Default is space but can be changed if items contain space.
770 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
771 SendMsg(2106, separatorCharacter
, 0);
774 // Retrieve the auto-completion list separator character.
775 int wxStyledTextCtrl::AutoCompGetSeparator() {
776 return SendMsg(2107, 0, 0);
779 // Select the item in the auto-completion list that starts with a string.
780 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
781 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
784 // Should the auto-completion list be cancelled if the user backspaces to a
785 // position before where the box was created.
786 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
787 SendMsg(2110, cancel
, 0);
790 // Retrieve whether auto-completion cancelled by backspacing before start.
791 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
792 return SendMsg(2111, 0, 0) != 0;
795 // Define a set of characters that when typed will cause the autocompletion to
796 // choose the selected item.
797 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
798 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
801 // Should a single item auto-completion list automatically choose the item.
802 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
803 SendMsg(2113, chooseSingle
, 0);
806 // Retrieve whether a single item auto-completion list automatically choose the item.
807 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
808 return SendMsg(2114, 0, 0) != 0;
811 // Set whether case is significant when performing auto-completion searches.
812 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
813 SendMsg(2115, ignoreCase
, 0);
816 // Retrieve state of ignore case flag.
817 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
818 return SendMsg(2116, 0, 0) != 0;
821 // Display a list of strings and send notification when user chooses one.
822 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
823 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
826 // Set whether or not autocompletion is hidden automatically when nothing matches.
827 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
828 SendMsg(2118, autoHide
, 0);
831 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
832 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
833 return SendMsg(2119, 0, 0) != 0;
836 // Set whether or not autocompletion deletes any word characters
837 // after the inserted text upon completion.
838 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
839 SendMsg(2270, dropRestOfWord
, 0);
842 // Retrieve whether or not autocompletion deletes any word characters
843 // after the inserted text upon completion.
844 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
845 return SendMsg(2271, 0, 0) != 0;
848 // Register an image for use in autocompletion lists.
849 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
850 // convert bmp to a xpm in a string
851 wxMemoryOutputStream strm
;
852 wxImage img
= bmp
.ConvertToImage();
853 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
854 size_t len
= strm
.GetSize();
855 char* buff
= new char[len
+1];
856 strm
.CopyTo(buff
, len
);
858 SendMsg(2405, type
, (long)buff
);
863 // Clear all the registered images.
864 void wxStyledTextCtrl::ClearRegisteredImages() {
868 // Retrieve the auto-completion list type-separator character.
869 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
870 return SendMsg(2285, 0, 0);
873 // Change the type-separator character in the string setting up an auto-completion list.
874 // Default is '?' but can be changed if items contain '?'.
875 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
876 SendMsg(2286, separatorCharacter
, 0);
879 // Set the number of spaces used for one level of indentation.
880 void wxStyledTextCtrl::SetIndent(int indentSize
) {
881 SendMsg(2122, indentSize
, 0);
884 // Retrieve indentation size.
885 int wxStyledTextCtrl::GetIndent() {
886 return SendMsg(2123, 0, 0);
889 // Indentation will only use space characters if useTabs is false, otherwise
890 // it will use a combination of tabs and spaces.
891 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
892 SendMsg(2124, useTabs
, 0);
895 // Retrieve whether tabs will be used in indentation.
896 bool wxStyledTextCtrl::GetUseTabs() {
897 return SendMsg(2125, 0, 0) != 0;
900 // Change the indentation of a line to a number of columns.
901 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
902 SendMsg(2126, line
, indentSize
);
905 // Retrieve the number of columns that a line is indented.
906 int wxStyledTextCtrl::GetLineIndentation(int line
) {
907 return SendMsg(2127, line
, 0);
910 // Retrieve the position before the first non indentation character on a line.
911 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
912 return SendMsg(2128, line
, 0);
915 // Retrieve the column number of a position, taking tab width into account.
916 int wxStyledTextCtrl::GetColumn(int pos
) {
917 return SendMsg(2129, pos
, 0);
920 // Show or hide the horizontal scroll bar.
921 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
922 SendMsg(2130, show
, 0);
925 // Is the horizontal scroll bar visible?
926 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
927 return SendMsg(2131, 0, 0) != 0;
930 // Show or hide indentation guides.
931 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
932 SendMsg(2132, show
, 0);
935 // Are the indentation guides visible?
936 bool wxStyledTextCtrl::GetIndentationGuides() {
937 return SendMsg(2133, 0, 0) != 0;
940 // Set the highlighted indentation guide column.
941 // 0 = no highlighted guide.
942 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
943 SendMsg(2134, column
, 0);
946 // Get the highlighted indentation guide column.
947 int wxStyledTextCtrl::GetHighlightGuide() {
948 return SendMsg(2135, 0, 0);
951 // Get the position after the last visible characters on a line.
952 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
953 return SendMsg(2136, line
, 0);
956 // Get the code page used to interpret the bytes of the document as characters.
957 int wxStyledTextCtrl::GetCodePage() {
958 return SendMsg(2137, 0, 0);
961 // Get the foreground colour of the caret.
962 wxColour
wxStyledTextCtrl::GetCaretForeground() {
963 long c
= SendMsg(2138, 0, 0);
964 return wxColourFromLong(c
);
967 // In read-only mode?
968 bool wxStyledTextCtrl::GetReadOnly() {
969 return SendMsg(2140, 0, 0) != 0;
972 // Sets the position of the caret.
973 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
974 SendMsg(2141, pos
, 0);
977 // Sets the position that starts the selection - this becomes the anchor.
978 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
979 SendMsg(2142, pos
, 0);
982 // Returns the position at the start of the selection.
983 int wxStyledTextCtrl::GetSelectionStart() {
984 return SendMsg(2143, 0, 0);
987 // Sets the position that ends the selection - this becomes the currentPosition.
988 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
989 SendMsg(2144, pos
, 0);
992 // Returns the position at the end of the selection.
993 int wxStyledTextCtrl::GetSelectionEnd() {
994 return SendMsg(2145, 0, 0);
997 // Sets the print magnification added to the point size of each style for printing.
998 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
999 SendMsg(2146, magnification
, 0);
1002 // Returns the print magnification.
1003 int wxStyledTextCtrl::GetPrintMagnification() {
1004 return SendMsg(2147, 0, 0);
1007 // Modify colours when printing for clearer printed text.
1008 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1009 SendMsg(2148, mode
, 0);
1012 // Returns the print colour mode.
1013 int wxStyledTextCtrl::GetPrintColourMode() {
1014 return SendMsg(2149, 0, 0);
1017 // Find some text in the document.
1018 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1019 const wxString
& text
,
1022 ft
.chrg
.cpMin
= minPos
;
1023 ft
.chrg
.cpMax
= maxPos
;
1024 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1025 ft
.lpstrText
= (char*)(const char*)buf
;
1027 return SendMsg(2150, flags
, (long)&ft
);
1030 // On Windows, will draw the document into a display context such as a printer.
1031 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1035 wxDC
* target
, // Why does it use two? Can they be the same?
1040 if (endPos
< startPos
) {
1041 int temp
= startPos
;
1046 fr
.hdcTarget
= target
;
1047 fr
.rc
.top
= renderRect
.GetTop();
1048 fr
.rc
.left
= renderRect
.GetLeft();
1049 fr
.rc
.right
= renderRect
.GetRight();
1050 fr
.rc
.bottom
= renderRect
.GetBottom();
1051 fr
.rcPage
.top
= pageRect
.GetTop();
1052 fr
.rcPage
.left
= pageRect
.GetLeft();
1053 fr
.rcPage
.right
= pageRect
.GetRight();
1054 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1055 fr
.chrg
.cpMin
= startPos
;
1056 fr
.chrg
.cpMax
= endPos
;
1058 return SendMsg(2151, doDraw
, (long)&fr
);
1061 // Retrieve the display line at the top of the display.
1062 int wxStyledTextCtrl::GetFirstVisibleLine() {
1063 return SendMsg(2152, 0, 0);
1066 // Retrieve the contents of a line.
1067 wxString
wxStyledTextCtrl::GetLine(int line
) {
1068 int len
= LineLength(line
);
1069 if (!len
) return wxEmptyString
;
1071 wxMemoryBuffer
mbuf(len
+1);
1072 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1073 SendMsg(2153, line
, (long)buf
);
1074 mbuf
.UngetWriteBuf(len
);
1079 // Returns the number of lines in the document. There is always at least one.
1080 int wxStyledTextCtrl::GetLineCount() {
1081 return SendMsg(2154, 0, 0);
1084 // Sets the size in pixels of the left margin.
1085 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1086 SendMsg(2155, 0, pixelWidth
);
1089 // Returns the size in pixels of the left margin.
1090 int wxStyledTextCtrl::GetMarginLeft() {
1091 return SendMsg(2156, 0, 0);
1094 // Sets the size in pixels of the right margin.
1095 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1096 SendMsg(2157, 0, pixelWidth
);
1099 // Returns the size in pixels of the right margin.
1100 int wxStyledTextCtrl::GetMarginRight() {
1101 return SendMsg(2158, 0, 0);
1104 // Is the document different from when it was last saved?
1105 bool wxStyledTextCtrl::GetModify() {
1106 return SendMsg(2159, 0, 0) != 0;
1109 // Select a range of text.
1110 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1111 SendMsg(2160, start
, end
);
1114 // Retrieve the selected text.
1115 wxString
wxStyledTextCtrl::GetSelectedText() {
1119 GetSelection(&start
, &end
);
1120 int len
= end
- start
;
1121 if (!len
) return wxEmptyString
;
1123 wxMemoryBuffer
mbuf(len
+1);
1124 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1125 SendMsg(2161, 0, (long)buf
);
1126 mbuf
.UngetWriteBuf(len
);
1131 // Retrieve a range of text.
1132 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1133 if (endPos
< startPos
) {
1134 int temp
= startPos
;
1138 int len
= endPos
- startPos
;
1139 if (!len
) return wxEmptyString
;
1140 wxMemoryBuffer
mbuf(len
+1);
1141 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1144 tr
.chrg
.cpMin
= startPos
;
1145 tr
.chrg
.cpMax
= endPos
;
1146 SendMsg(2162, 0, (long)&tr
);
1147 mbuf
.UngetWriteBuf(len
);
1152 // Draw the selection in normal style or with selection highlighted.
1153 void wxStyledTextCtrl::HideSelection(bool normal
) {
1154 SendMsg(2163, normal
, 0);
1157 // Retrieve the line containing a position.
1158 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1159 return SendMsg(2166, pos
, 0);
1162 // Retrieve the position at the start of a line.
1163 int wxStyledTextCtrl::PositionFromLine(int line
) {
1164 return SendMsg(2167, line
, 0);
1167 // Scroll horizontally and vertically.
1168 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1169 SendMsg(2168, columns
, lines
);
1172 // Ensure the caret is visible.
1173 void wxStyledTextCtrl::EnsureCaretVisible() {
1174 SendMsg(2169, 0, 0);
1177 // Replace the selected text with the argument text.
1178 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1179 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1182 // Set to read only or read write.
1183 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1184 SendMsg(2171, readOnly
, 0);
1187 // Will a paste succeed?
1188 bool wxStyledTextCtrl::CanPaste() {
1189 return SendMsg(2173, 0, 0) != 0;
1192 // Are there any undoable actions in the undo history?
1193 bool wxStyledTextCtrl::CanUndo() {
1194 return SendMsg(2174, 0, 0) != 0;
1197 // Delete the undo history.
1198 void wxStyledTextCtrl::EmptyUndoBuffer() {
1199 SendMsg(2175, 0, 0);
1202 // Undo one action in the undo history.
1203 void wxStyledTextCtrl::Undo() {
1204 SendMsg(2176, 0, 0);
1207 // Cut the selection to the clipboard.
1208 void wxStyledTextCtrl::Cut() {
1209 SendMsg(2177, 0, 0);
1212 // Copy the selection to the clipboard.
1213 void wxStyledTextCtrl::Copy() {
1214 SendMsg(2178, 0, 0);
1217 // Paste the contents of the clipboard into the document replacing the selection.
1218 void wxStyledTextCtrl::Paste() {
1219 SendMsg(2179, 0, 0);
1222 // Clear the selection.
1223 void wxStyledTextCtrl::Clear() {
1224 SendMsg(2180, 0, 0);
1227 // Replace the contents of the document with the argument text.
1228 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1229 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1232 // Retrieve all the text in the document.
1233 wxString
wxStyledTextCtrl::GetText() {
1234 int len
= GetTextLength();
1235 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1236 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1237 SendMsg(2182, len
+1, (long)buf
);
1238 mbuf
.UngetWriteBuf(len
);
1243 // Retrieve the number of characters in the document.
1244 int wxStyledTextCtrl::GetTextLength() {
1245 return SendMsg(2183, 0, 0);
1248 // Set to overtype (true) or insert mode.
1249 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1250 SendMsg(2186, overtype
, 0);
1253 // Returns true if overtype mode is active otherwise false is returned.
1254 bool wxStyledTextCtrl::GetOvertype() {
1255 return SendMsg(2187, 0, 0) != 0;
1258 // Set the width of the insert mode caret.
1259 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1260 SendMsg(2188, pixelWidth
, 0);
1263 // Returns the width of the insert mode caret.
1264 int wxStyledTextCtrl::GetCaretWidth() {
1265 return SendMsg(2189, 0, 0);
1268 // Sets the position that starts the target which is used for updating the
1269 // document without affecting the scroll position.
1270 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1271 SendMsg(2190, pos
, 0);
1274 // Get the position that starts the target.
1275 int wxStyledTextCtrl::GetTargetStart() {
1276 return SendMsg(2191, 0, 0);
1279 // Sets the position that ends the target which is used for updating the
1280 // document without affecting the scroll position.
1281 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1282 SendMsg(2192, pos
, 0);
1285 // Get the position that ends the target.
1286 int wxStyledTextCtrl::GetTargetEnd() {
1287 return SendMsg(2193, 0, 0);
1290 // Replace the target text with the argument text.
1291 // Text is counted so it can contain nulls.
1292 // Returns the length of the replacement text.
1294 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1295 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1296 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1299 // Replace the target text with the argument text after \d processing.
1300 // Text is counted so it can contain nulls.
1301 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1302 // matched in the last search operation which were surrounded by \( and \).
1303 // Returns the length of the replacement text including any change
1304 // caused by processing the \d patterns.
1306 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1307 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1308 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1311 // Search for a counted string in the target and set the target to the found
1312 // range. Text is counted so it can contain nulls.
1313 // Returns length of range or -1 for failure in which case target is not moved.
1315 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1316 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1317 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1320 // Set the search flags used by SearchInTarget.
1321 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1322 SendMsg(2198, flags
, 0);
1325 // Get the search flags used by SearchInTarget.
1326 int wxStyledTextCtrl::GetSearchFlags() {
1327 return SendMsg(2199, 0, 0);
1330 // Show a call tip containing a definition near position pos.
1331 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1332 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1335 // Remove the call tip from the screen.
1336 void wxStyledTextCtrl::CallTipCancel() {
1337 SendMsg(2201, 0, 0);
1340 // Is there an active call tip?
1341 bool wxStyledTextCtrl::CallTipActive() {
1342 return SendMsg(2202, 0, 0) != 0;
1345 // Retrieve the position where the caret was before displaying the call tip.
1346 int wxStyledTextCtrl::CallTipPosAtStart() {
1347 return SendMsg(2203, 0, 0);
1350 // Highlight a segment of the definition.
1351 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1352 SendMsg(2204, start
, end
);
1355 // Set the background colour for the call tip.
1356 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1357 SendMsg(2205, wxColourAsLong(back
), 0);
1360 // Set the foreground colour for the call tip.
1361 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1362 SendMsg(2206, wxColourAsLong(fore
), 0);
1365 // Set the foreground colour for the highlighted part of the call tip.
1366 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1367 SendMsg(2207, wxColourAsLong(fore
), 0);
1370 // Find the display line of a document line taking hidden lines into account.
1371 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1372 return SendMsg(2220, line
, 0);
1375 // Find the document line of a display line taking hidden lines into account.
1376 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1377 return SendMsg(2221, lineDisplay
, 0);
1380 // Set the fold level of a line.
1381 // This encodes an integer level along with flags indicating whether the
1382 // line is a header and whether it is effectively white space.
1383 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1384 SendMsg(2222, line
, level
);
1387 // Retrieve the fold level of a line.
1388 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1389 return SendMsg(2223, line
, 0);
1392 // Find the last child line of a header line.
1393 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1394 return SendMsg(2224, line
, level
);
1397 // Find the parent line of a child line.
1398 int wxStyledTextCtrl::GetFoldParent(int line
) {
1399 return SendMsg(2225, line
, 0);
1402 // Make a range of lines visible.
1403 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1404 SendMsg(2226, lineStart
, lineEnd
);
1407 // Make a range of lines invisible.
1408 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1409 SendMsg(2227, lineStart
, lineEnd
);
1412 // Is a line visible?
1413 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1414 return SendMsg(2228, line
, 0) != 0;
1417 // Show the children of a header line.
1418 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1419 SendMsg(2229, line
, expanded
);
1422 // Is a header line expanded?
1423 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1424 return SendMsg(2230, line
, 0) != 0;
1427 // Switch a header line between expanded and contracted.
1428 void wxStyledTextCtrl::ToggleFold(int line
) {
1429 SendMsg(2231, line
, 0);
1432 // Ensure a particular line is visible by expanding any header line hiding it.
1433 void wxStyledTextCtrl::EnsureVisible(int line
) {
1434 SendMsg(2232, line
, 0);
1437 // Set some style options for folding.
1438 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1439 SendMsg(2233, flags
, 0);
1442 // Ensure a particular line is visible by expanding any header line hiding it.
1443 // Use the currently set visibility policy to determine which range to display.
1444 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1445 SendMsg(2234, line
, 0);
1448 // Sets whether a tab pressed when caret is within indentation indents.
1449 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1450 SendMsg(2260, tabIndents
, 0);
1453 // Does a tab pressed when caret is within indentation indent?
1454 bool wxStyledTextCtrl::GetTabIndents() {
1455 return SendMsg(2261, 0, 0) != 0;
1458 // Sets whether a backspace pressed when caret is within indentation unindents.
1459 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1460 SendMsg(2262, bsUnIndents
, 0);
1463 // Does a backspace pressed when caret is within indentation unindent?
1464 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1465 return SendMsg(2263, 0, 0) != 0;
1468 // Sets the time the mouse must sit still to generate a mouse dwell event.
1469 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1470 SendMsg(2264, periodMilliseconds
, 0);
1473 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1474 int wxStyledTextCtrl::GetMouseDwellTime() {
1475 return SendMsg(2265, 0, 0);
1478 // Get position of start of word.
1479 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1480 return SendMsg(2266, pos
, onlyWordCharacters
);
1483 // Get position of end of word.
1484 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1485 return SendMsg(2267, pos
, onlyWordCharacters
);
1488 // Sets whether text is word wrapped.
1489 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1490 SendMsg(2268, mode
, 0);
1493 // Retrieve whether text is word wrapped.
1494 int wxStyledTextCtrl::GetWrapMode() {
1495 return SendMsg(2269, 0, 0);
1498 // Sets the degree of caching of layout information.
1499 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1500 SendMsg(2272, mode
, 0);
1503 // Retrieve the degree of caching of layout information.
1504 int wxStyledTextCtrl::GetLayoutCache() {
1505 return SendMsg(2273, 0, 0);
1508 // Sets the document width assumed for scrolling.
1509 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1510 SendMsg(2274, pixelWidth
, 0);
1513 // Retrieve the document width assumed for scrolling.
1514 int wxStyledTextCtrl::GetScrollWidth() {
1515 return SendMsg(2275, 0, 0);
1518 // Measure the pixel width of some text in a particular style.
1519 // Nul terminated text argument.
1520 // Does not handle tab or control characters.
1521 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1522 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1525 // Sets the scroll range so that maximum scroll position has
1526 // the last line at the bottom of the view (default).
1527 // Setting this to false allows scrolling one page below the last line.
1528 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1529 SendMsg(2277, endAtLastLine
, 0);
1532 // Retrieve whether the maximum scroll position has the last
1533 // line at the bottom of the view.
1534 int wxStyledTextCtrl::GetEndAtLastLine() {
1535 return SendMsg(2278, 0, 0);
1538 // Retrieve the height of a particular line of text in pixels.
1539 int wxStyledTextCtrl::TextHeight(int line
) {
1540 return SendMsg(2279, line
, 0);
1543 // Show or hide the vertical scroll bar.
1544 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1545 SendMsg(2280, show
, 0);
1548 // Is the vertical scroll bar visible?
1549 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1550 return SendMsg(2281, 0, 0) != 0;
1553 // Append a string to the end of the document without changing the selection.
1554 void wxStyledTextCtrl::AppendText(int length
, const wxString
& text
) {
1555 SendMsg(2282, length
, (long)(const char*)wx2stc(text
));
1558 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1559 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1560 return SendMsg(2283, 0, 0) != 0;
1563 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1564 // and then the foreground. This avoids chopping off characters that overlap the next run.
1565 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1566 SendMsg(2284, twoPhase
, 0);
1569 // Make the target range start and end be the same as the selection range start and end.
1570 void wxStyledTextCtrl::TargetFromSelection() {
1571 SendMsg(2287, 0, 0);
1574 // Join the lines in the target.
1575 void wxStyledTextCtrl::LinesJoin() {
1576 SendMsg(2288, 0, 0);
1579 // Split the lines in the target into lines that are less wide than pixelWidth
1581 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1582 SendMsg(2289, pixelWidth
, 0);
1585 // Set the colours used as a chequerboard pattern in the fold margin
1586 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1587 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1589 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1590 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1593 // Duplicate the current line.
1594 void wxStyledTextCtrl::LineDuplicate() {
1595 SendMsg(2404, 0, 0);
1598 // Move caret to first position on display line.
1599 void wxStyledTextCtrl::HomeDisplay() {
1600 SendMsg(2345, 0, 0);
1603 // Move caret to first position on display line extending selection to
1604 // new caret position.
1605 void wxStyledTextCtrl::HomeDisplayExtend() {
1606 SendMsg(2346, 0, 0);
1609 // Move caret to last position on display line.
1610 void wxStyledTextCtrl::LineEndDisplay() {
1611 SendMsg(2347, 0, 0);
1614 // Move caret to last position on display line extending selection to new
1616 void wxStyledTextCtrl::LineEndDisplayExtend() {
1617 SendMsg(2348, 0, 0);
1620 // Move the caret inside current view if it's not there already.
1621 void wxStyledTextCtrl::MoveCaretInsideView() {
1622 SendMsg(2401, 0, 0);
1625 // How many characters are on a line, not including end of line characters?
1626 int wxStyledTextCtrl::LineLength(int line
) {
1627 return SendMsg(2350, line
, 0);
1630 // Highlight the characters at two positions.
1631 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1632 SendMsg(2351, pos1
, pos2
);
1635 // Highlight the character at a position indicating there is no matching brace.
1636 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1637 SendMsg(2352, pos
, 0);
1640 // Find the position of a matching brace or INVALID_POSITION if no match.
1641 int wxStyledTextCtrl::BraceMatch(int pos
) {
1642 return SendMsg(2353, pos
, 0);
1645 // Are the end of line characters visible?
1646 bool wxStyledTextCtrl::GetViewEOL() {
1647 return SendMsg(2355, 0, 0) != 0;
1650 // Make the end of line characters visible or invisible.
1651 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1652 SendMsg(2356, visible
, 0);
1655 // Retrieve a pointer to the document object.
1656 void* wxStyledTextCtrl::GetDocPointer() {
1657 return (void*)SendMsg(2357);
1660 // Change the document object used.
1661 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1662 SendMsg(2358, 0, (long)docPointer
);
1665 // Set which document modification events are sent to the container.
1666 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1667 SendMsg(2359, mask
, 0);
1670 // Retrieve the column number which text should be kept within.
1671 int wxStyledTextCtrl::GetEdgeColumn() {
1672 return SendMsg(2360, 0, 0);
1675 // Set the column number of the edge.
1676 // If text goes past the edge then it is highlighted.
1677 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1678 SendMsg(2361, column
, 0);
1681 // Retrieve the edge highlight mode.
1682 int wxStyledTextCtrl::GetEdgeMode() {
1683 return SendMsg(2362, 0, 0);
1686 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1687 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1688 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
1689 SendMsg(2363, mode
, 0);
1692 // Retrieve the colour used in edge indication.
1693 wxColour
wxStyledTextCtrl::GetEdgeColour() {
1694 long c
= SendMsg(2364, 0, 0);
1695 return wxColourFromLong(c
);
1698 // Change the colour used in edge indication.
1699 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
1700 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
1703 // Sets the current caret position to be the search anchor.
1704 void wxStyledTextCtrl::SearchAnchor() {
1705 SendMsg(2366, 0, 0);
1708 // Find some text starting at the search anchor.
1709 // Does not ensure the selection is visible.
1710 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
1711 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
1714 // Find some text starting at the search anchor and moving backwards.
1715 // Does not ensure the selection is visible.
1716 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
1717 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
1720 // Retrieves the number of lines completely visible.
1721 int wxStyledTextCtrl::LinesOnScreen() {
1722 return SendMsg(2370, 0, 0);
1725 // Set whether a pop up menu is displayed automatically when the user presses
1726 // the wrong mouse button.
1727 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
1728 SendMsg(2371, allowPopUp
, 0);
1731 // Is the selection rectangular? The alternative is the more common stream selection.
1732 bool wxStyledTextCtrl::SelectionIsRectangle() {
1733 return SendMsg(2372, 0, 0) != 0;
1736 // Set the zoom level. This number of points is added to the size of all fonts.
1737 // It may be positive to magnify or negative to reduce.
1738 void wxStyledTextCtrl::SetZoom(int zoom
) {
1739 SendMsg(2373, zoom
, 0);
1742 // Retrieve the zoom level.
1743 int wxStyledTextCtrl::GetZoom() {
1744 return SendMsg(2374, 0, 0);
1747 // Create a new document object.
1748 // Starts with reference count of 1 and not selected into editor.
1749 void* wxStyledTextCtrl::CreateDocument() {
1750 return (void*)SendMsg(2375);
1753 // Extend life of document.
1754 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
1755 SendMsg(2376, 0, (long)docPointer
);
1758 // Release a reference to the document, deleting document if it fades to black.
1759 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
1760 SendMsg(2377, 0, (long)docPointer
);
1763 // Get which document modification events are sent to the container.
1764 int wxStyledTextCtrl::GetModEventMask() {
1765 return SendMsg(2378, 0, 0);
1768 // Change internal focus flag.
1769 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
1770 SendMsg(2380, focus
, 0);
1773 // Get internal focus flag.
1774 bool wxStyledTextCtrl::GetSTCFocus() {
1775 return SendMsg(2381, 0, 0) != 0;
1778 // Change error status - 0 = OK.
1779 void wxStyledTextCtrl::SetStatus(int statusCode
) {
1780 SendMsg(2382, statusCode
, 0);
1783 // Get error status.
1784 int wxStyledTextCtrl::GetStatus() {
1785 return SendMsg(2383, 0, 0);
1788 // Set whether the mouse is captured when its button is pressed.
1789 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
1790 SendMsg(2384, captures
, 0);
1793 // Get whether mouse gets captured.
1794 bool wxStyledTextCtrl::GetMouseDownCaptures() {
1795 return SendMsg(2385, 0, 0) != 0;
1798 // Sets the cursor to one of the SC_CURSOR* values.
1799 void wxStyledTextCtrl::SetCursor(int cursorType
) {
1800 SendMsg(2386, cursorType
, 0);
1804 int wxStyledTextCtrl::GetCursor() {
1805 return SendMsg(2387, 0, 0);
1808 // Change the way control characters are displayed:
1809 // If symbol is < 32, keep the drawn way, else, use the given character.
1810 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
1811 SendMsg(2388, symbol
, 0);
1814 // Get the way control characters are displayed.
1815 int wxStyledTextCtrl::GetControlCharSymbol() {
1816 return SendMsg(2389, 0, 0);
1819 // Move to the previous change in capitalisation.
1820 void wxStyledTextCtrl::WordPartLeft() {
1821 SendMsg(2390, 0, 0);
1824 // Move to the previous change in capitalisation extending selection
1825 // to new caret position.
1826 void wxStyledTextCtrl::WordPartLeftExtend() {
1827 SendMsg(2391, 0, 0);
1830 // Move to the change next in capitalisation.
1831 void wxStyledTextCtrl::WordPartRight() {
1832 SendMsg(2392, 0, 0);
1835 // Move to the next change in capitalisation extending selection
1836 // to new caret position.
1837 void wxStyledTextCtrl::WordPartRightExtend() {
1838 SendMsg(2393, 0, 0);
1841 // Set the way the display area is determined when a particular line
1842 // is to be moved to by Find, FindNext, GotoLine, etc.
1843 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
1844 SendMsg(2394, visiblePolicy
, visibleSlop
);
1847 // Delete back from the current position to the start of the line.
1848 void wxStyledTextCtrl::DelLineLeft() {
1849 SendMsg(2395, 0, 0);
1852 // Delete forwards from the current position to the end of the line.
1853 void wxStyledTextCtrl::DelLineRight() {
1854 SendMsg(2396, 0, 0);
1857 // Get and Set the xOffset (ie, horizonal scroll position).
1858 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
1859 SendMsg(2397, newOffset
, 0);
1861 int wxStyledTextCtrl::GetXOffset() {
1862 return SendMsg(2398, 0, 0);
1865 // Set the last x chosen value to be the caret x position
1866 void wxStyledTextCtrl::ChooseCaretX() {
1867 SendMsg(2399, 0, 0);
1870 // Set the way the caret is kept visible when going sideway.
1871 // The exclusion zone is given in pixels.
1872 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
1873 SendMsg(2402, caretPolicy
, caretSlop
);
1876 // Set the way the line the caret is on is kept visible.
1877 // The exclusion zone is given in lines.
1878 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
1879 SendMsg(2403, caretPolicy
, caretSlop
);
1882 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
1883 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
1884 SendMsg(2406, mode
, 0);
1887 // Is printing line wrapped.
1888 int wxStyledTextCtrl::GetPrintWrapMode() {
1889 return SendMsg(2407, 0, 0);
1892 // Set a fore colour for active hotspots.
1893 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
1894 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
1897 // Set a back colour for active hotspots.
1898 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
1899 SendMsg(2411, useSetting
, wxColourAsLong(back
));
1902 // Enable / Disable underlining active hotspots.
1903 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
1904 SendMsg(2412, underline
, 0);
1907 // Start notifying the container of all key presses and commands.
1908 void wxStyledTextCtrl::StartRecord() {
1909 SendMsg(3001, 0, 0);
1912 // Stop notifying the container of all key presses and commands.
1913 void wxStyledTextCtrl::StopRecord() {
1914 SendMsg(3002, 0, 0);
1917 // Set the lexing language of the document.
1918 void wxStyledTextCtrl::SetLexer(int lexer
) {
1919 SendMsg(4001, lexer
, 0);
1922 // Retrieve the lexing language of the document.
1923 int wxStyledTextCtrl::GetLexer() {
1924 return SendMsg(4002, 0, 0);
1927 // Colourise a segment of the document using the current lexing language.
1928 void wxStyledTextCtrl::Colourise(int start
, int end
) {
1929 SendMsg(4003, start
, end
);
1932 // Set up a value that may be used by a lexer for some optional feature.
1933 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
1934 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
1937 // Set up the key words used by the lexer.
1938 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
1939 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
1942 // Set the lexing language of the document based on string name.
1943 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
1944 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
1947 // END of generated section
1948 //----------------------------------------------------------------------
1951 // Returns the line number of the line with the caret.
1952 int wxStyledTextCtrl::GetCurrentLine() {
1953 int line
= LineFromPosition(GetCurrentPos());
1958 // Extract style settings from a spec-string which is composed of one or
1959 // more of the following comma separated elements:
1961 // bold turns on bold
1962 // italic turns on italics
1963 // fore:#RRGGBB sets the foreground colour
1964 // back:#RRGGBB sets the background colour
1965 // face:[facename] sets the font face name to use
1966 // size:[num] sets the font size in points
1967 // eol turns on eol filling
1968 // underline turns on underlining
1970 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
1972 wxStringTokenizer
tkz(spec
, wxT(","));
1973 while (tkz
.HasMoreTokens()) {
1974 wxString token
= tkz
.GetNextToken();
1976 wxString option
= token
.BeforeFirst(':');
1977 wxString val
= token
.AfterFirst(':');
1979 if (option
== wxT("bold"))
1980 StyleSetBold(styleNum
, true);
1982 else if (option
== wxT("italic"))
1983 StyleSetItalic(styleNum
, true);
1985 else if (option
== wxT("underline"))
1986 StyleSetUnderline(styleNum
, true);
1988 else if (option
== wxT("eol"))
1989 StyleSetEOLFilled(styleNum
, true);
1991 else if (option
== wxT("size")) {
1993 if (val
.ToLong(&points
))
1994 StyleSetSize(styleNum
, points
);
1997 else if (option
== wxT("face"))
1998 StyleSetFaceName(styleNum
, val
);
2000 else if (option
== wxT("fore"))
2001 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2003 else if (option
== wxT("back"))
2004 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2009 // Set style size, face, bold, italic, and underline attributes from
2010 // a wxFont's attributes.
2011 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2012 int size
= font
.GetPointSize();
2013 wxString faceName
= font
.GetFaceName();
2014 bool bold
= font
.GetWeight() == wxBOLD
;
2015 bool italic
= font
.GetStyle() != wxNORMAL
;
2016 bool under
= font
.GetUnderlined();
2018 // TODO: add encoding/charset mapping
2019 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
2022 // Set all font style attributes at once.
2023 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2024 const wxString
& faceName
,
2025 bool bold
, bool italic
,
2027 StyleSetSize(styleNum
, size
);
2028 StyleSetFaceName(styleNum
, faceName
);
2029 StyleSetBold(styleNum
, bold
);
2030 StyleSetItalic(styleNum
, italic
);
2031 StyleSetUnderline(styleNum
, underline
);
2033 // TODO: add encoding/charset mapping
2037 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2038 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2043 // Set the left and right margin in the edit area, measured in pixels.
2044 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2045 SetMarginLeft(left
);
2046 SetMarginRight(right
);
2050 // Retrieve the start and end positions of the current selection.
2051 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2052 if (startPos
!= NULL
)
2053 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2055 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2059 // Retrieve the point in the window where a position is displayed.
2060 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2061 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2062 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2063 return wxPoint(x
, y
);
2066 // Scroll enough to make the given line visible
2067 void wxStyledTextCtrl::ScrollToLine(int line
) {
2068 m_swx
->DoScrollToLine(line
);
2072 // Scroll enough to make the given column visible
2073 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2074 m_swx
->DoScrollToColumn(column
);
2079 //----------------------------------------------------------------------
2082 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& evt
) {
2084 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
2087 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
2088 if (evt
.GetOrientation() == wxHORIZONTAL
)
2089 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2091 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2094 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
2095 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
2097 if (sb
->IsVertical())
2098 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2100 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2104 void wxStyledTextCtrl::OnSize(wxSizeEvent
& evt
) {
2105 wxSize sz
= GetClientSize();
2106 m_swx
->DoSize(sz
.x
, sz
.y
);
2109 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
2111 wxPoint pt
= evt
.GetPosition();
2112 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2113 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
2116 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
2117 wxPoint pt
= evt
.GetPosition();
2118 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
2121 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
2122 wxPoint pt
= evt
.GetPosition();
2123 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2128 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
2129 wxPoint pt
= evt
.GetPosition();
2130 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2134 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
2135 wxPoint pt
= evt
.GetPosition();
2136 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
2139 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
2140 wxPoint pt
= evt
.GetPosition();
2141 ScreenToClient(&pt
.x
, &pt
.y
);
2142 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2146 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
2147 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
2148 evt
.GetWheelDelta(),
2149 evt
.GetLinesPerAction(),
2151 evt
.IsPageScroll());
2155 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
2156 // On (some?) non-US keyboards the AltGr key is required to enter some
2157 // common characters. It comes to us as both Alt and Ctrl down so we need
2158 // to let the char through in that case, otherwise if only ctrl or only
2159 // alt let's skip it.
2160 bool ctrl
= evt
.ControlDown();
2161 bool alt
= evt
.AltDown();
2162 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
2164 int key
= evt
.GetKeyCode();
2166 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
2167 // key, m_lastKeyDownConsumed, ctrl, alt, skip);
2169 if ( (key
<= WXK_START
|| key
> WXK_NUMPAD_DIVIDE
) &&
2170 !m_lastKeyDownConsumed
&& !skip
) {
2171 m_swx
->DoAddChar(key
);
2178 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
2179 int key
= evt
.GetKeyCode();
2180 bool shift
= evt
.ShiftDown(),
2181 ctrl
= evt
.ControlDown(),
2182 alt
= evt
.AltDown();
2184 int processed
= m_swx
->DoKeyDown(key
, shift
, ctrl
, alt
, &m_lastKeyDownConsumed
);
2186 // printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
2187 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
2189 if (!processed
&& !m_lastKeyDownConsumed
)
2194 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
2195 m_swx
->DoLoseFocus();
2199 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
2200 m_swx
->DoGainFocus();
2204 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& evt
) {
2205 m_swx
->DoSysColourChange();
2209 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& evt
) {
2210 // do nothing to help avoid flashing
2215 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
2216 m_swx
->DoCommand(evt
.GetId());
2220 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& evt
) {
2221 m_swx
->DoOnListBox();
2225 //----------------------------------------------------------------------
2226 // Turn notifications from Scintilla into events
2229 void wxStyledTextCtrl::NotifyChange() {
2230 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
2231 evt
.SetEventObject(this);
2232 GetEventHandler()->ProcessEvent(evt
);
2236 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
2240 // The unicode conversion MUST have a null byte to terminate the
2241 // string so move it into a buffer first and give it one.
2242 wxMemoryBuffer
buf(length
+1);
2243 buf
.AppendData((void*)text
, length
);
2245 evt
.SetText(stc2wx(buf
));
2249 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
2250 SCNotification
& scn
= *_scn
;
2251 wxStyledTextEvent
evt(0, GetId());
2253 evt
.SetEventObject(this);
2254 evt
.SetPosition(scn
.position
);
2256 evt
.SetModifiers(scn
.modifiers
);
2258 switch (scn
.nmhdr
.code
) {
2259 case SCN_STYLENEEDED
:
2260 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
2264 evt
.SetEventType(wxEVT_STC_CHARADDED
);
2267 case SCN_SAVEPOINTREACHED
:
2268 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
2271 case SCN_SAVEPOINTLEFT
:
2272 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
2275 case SCN_MODIFYATTEMPTRO
:
2276 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
2280 evt
.SetEventType(wxEVT_STC_KEY
);
2283 case SCN_DOUBLECLICK
:
2284 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
2288 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
2292 evt
.SetEventType(wxEVT_STC_MODIFIED
);
2293 evt
.SetModificationType(scn
.modificationType
);
2294 SetEventText(evt
, scn
.text
, scn
.length
);
2295 evt
.SetLength(scn
.length
);
2296 evt
.SetLinesAdded(scn
.linesAdded
);
2297 evt
.SetLine(scn
.line
);
2298 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
2299 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
2302 case SCN_MACRORECORD
:
2303 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
2304 evt
.SetMessage(scn
.message
);
2305 evt
.SetWParam(scn
.wParam
);
2306 evt
.SetLParam(scn
.lParam
);
2309 case SCN_MARGINCLICK
:
2310 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
2311 evt
.SetMargin(scn
.margin
);
2315 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
2316 evt
.SetLength(scn
.length
);
2320 evt
.SetEventType(wxEVT_STC_PAINTED
);
2323 case SCN_USERLISTSELECTION
:
2324 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
2325 evt
.SetListType(scn
.listType
);
2326 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2329 case SCN_URIDROPPED
:
2330 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
2331 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2334 case SCN_DWELLSTART
:
2335 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
2341 evt
.SetEventType(wxEVT_STC_DWELLEND
);
2347 evt
.SetEventType(wxEVT_STC_ZOOM
);
2350 case SCN_HOTSPOTCLICK
:
2351 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
2354 case SCN_HOTSPOTDOUBLECLICK
:
2355 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
2358 case SCN_CALLTIPCLICK
:
2359 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
2366 GetEventHandler()->ProcessEvent(evt
);
2370 //----------------------------------------------------------------------
2371 //----------------------------------------------------------------------
2372 //----------------------------------------------------------------------
2374 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
2375 : wxCommandEvent(commandType
, id
)
2380 m_modificationType
= 0;
2385 m_foldLevelPrev
= 0;
2393 m_dragAllowMove
= FALSE
;
2394 #if wxUSE_DRAG_AND_DROP
2395 m_dragResult
= wxDragNone
;
2399 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
2400 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
2401 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
2404 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
2405 wxCommandEvent(event
)
2407 m_position
= event
.m_position
;
2408 m_key
= event
.m_key
;
2409 m_modifiers
= event
.m_modifiers
;
2410 m_modificationType
= event
.m_modificationType
;
2411 m_text
= event
.m_text
;
2412 m_length
= event
.m_length
;
2413 m_linesAdded
= event
.m_linesAdded
;
2414 m_line
= event
.m_line
;
2415 m_foldLevelNow
= event
.m_foldLevelNow
;
2416 m_foldLevelPrev
= event
.m_foldLevelPrev
;
2418 m_margin
= event
.m_margin
;
2420 m_message
= event
.m_message
;
2421 m_wParam
= event
.m_wParam
;
2422 m_lParam
= event
.m_lParam
;
2424 m_listType
= event
.m_listType
;
2428 m_dragText
= event
.m_dragText
;
2429 m_dragAllowMove
=event
.m_dragAllowMove
;
2430 #if wxUSE_DRAG_AND_DROP
2431 m_dragResult
= event
.m_dragResult
;
2435 //----------------------------------------------------------------------
2436 //----------------------------------------------------------------------