1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: A wxWidgets implementation of Scintilla. This class is the
4 // one meant to be used directly by wx applications. It does not
5 // derive directly from the Scintilla classes, but instead
6 // delegates most things to the real Scintilla class.
7 // This allows the use of Scintilla without polluting the
8 // namespace with all the classes and identifiers from Scintilla.
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>
30 //----------------------------------------------------------------------
32 const wxChar
* wxSTCNameStr
= wxT("stcwindow");
38 #define MAKELONG(a, b) ((a) | ((b) << 16))
41 static long wxColourAsLong(const wxColour
& co
) {
42 return (((long)co
.Blue() << 16) |
43 ((long)co
.Green() << 8) |
47 static wxColour
wxColourFromLong(long c
) {
49 clr
.Set(c
& 0xff, (c
>> 8) & 0xff, (c
>> 16) & 0xff);
54 static wxColour
wxColourFromSpec(const wxString
& spec
) {
55 // spec should be a colour name or "#RRGGBB"
56 if (spec
.GetChar(0) == wxT('#')) {
58 long red
, green
, blue
;
59 red
= green
= blue
= 0;
60 spec
.Mid(1,2).ToLong(&red
, 16);
61 spec
.Mid(3,2).ToLong(&green
, 16);
62 spec
.Mid(5,2).ToLong(&blue
, 16);
63 return wxColour(red
, green
, blue
);
66 return wxColour(spec
);
69 //----------------------------------------------------------------------
71 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
72 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
73 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
74 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
75 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
76 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
77 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
78 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
79 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
80 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
81 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
82 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
83 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
84 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
85 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
99 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
100 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
101 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
102 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
103 EVT_SIZE (wxStyledTextCtrl::OnSize
)
104 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
105 // Let Scintilla see the double click as a second click
106 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
107 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
108 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
109 #if defined(__WXGTK__) || defined(__WXMAC__)
110 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
112 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
114 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
115 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
116 EVT_CHAR (wxStyledTextCtrl::OnChar
)
117 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
118 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
119 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
120 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
121 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
122 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
123 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
127 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
128 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
131 // forces the linking of the lexer modules
132 int Scintilla_LinkLexers();
135 //----------------------------------------------------------------------
136 // Constructor and Destructor
138 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
143 const wxString
& name
)
146 Create(parent
, id
, pos
, size
, style
, name
);
150 void wxStyledTextCtrl::Create(wxWindow
*parent
,
155 const wxString
& name
)
158 style
|= wxVSCROLL
| wxHSCROLL
;
160 wxControl::Create(parent
, id
, pos
, size
,
161 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
162 wxDefaultValidator
, name
);
165 Scintilla_LinkLexers();
167 m_swx
= new ScintillaWX(this);
169 m_lastKeyDownConsumed
= false;
173 // Put Scintilla into unicode (UTF-8) mode
174 SetCodePage(wxSTC_CP_UTF8
);
177 SetBestFittingSize(size
);
181 wxStyledTextCtrl::~wxStyledTextCtrl() {
186 //----------------------------------------------------------------------
188 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
190 return m_swx
->WndProc(msg
, wp
, lp
);
193 //----------------------------------------------------------------------
195 // Set the vertical scrollbar to use instead of the ont that's built-in.
196 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
199 // ensure that the built-in scrollbar is not visible
200 SetScrollbar(wxVERTICAL
, 0, 0, 0);
205 // Set the horizontal scrollbar to use instead of the ont that's built-in.
206 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
209 // ensure that the built-in scrollbar is not visible
210 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
214 //----------------------------------------------------------------------
215 // BEGIN generated section. The following code is automatically generated
216 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
217 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
220 // Add text to the document at current position.
221 void wxStyledTextCtrl::AddText(const wxString
& text
) {
222 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
223 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
226 // Add array of cells to document.
227 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
228 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
231 // Insert string at a position.
232 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
233 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
236 // Delete all text in the document.
237 void wxStyledTextCtrl::ClearAll() {
241 // Set all style bytes to 0, remove all folding information.
242 void wxStyledTextCtrl::ClearDocumentStyle() {
246 // Returns the number of characters in the document.
247 int wxStyledTextCtrl::GetLength() {
248 return SendMsg(2006, 0, 0);
251 // Returns the character byte at the position.
252 int wxStyledTextCtrl::GetCharAt(int pos
) {
253 return (unsigned char)SendMsg(2007, pos
, 0);
256 // Returns the position of the caret.
257 int wxStyledTextCtrl::GetCurrentPos() {
258 return SendMsg(2008, 0, 0);
261 // Returns the position of the opposite end of the selection to the caret.
262 int wxStyledTextCtrl::GetAnchor() {
263 return SendMsg(2009, 0, 0);
266 // Returns the style byte at the position.
267 int wxStyledTextCtrl::GetStyleAt(int pos
) {
268 return (unsigned char)SendMsg(2010, pos
, 0);
271 // Redoes the next action on the undo history.
272 void wxStyledTextCtrl::Redo() {
276 // Choose between collecting actions into the undo
277 // history and discarding them.
278 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
279 SendMsg(2012, collectUndo
, 0);
282 // Select all the text in the document.
283 void wxStyledTextCtrl::SelectAll() {
287 // Remember the current position in the undo history as the position
288 // at which the document was saved.
289 void wxStyledTextCtrl::SetSavePoint() {
293 // Retrieve a buffer of cells.
294 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
296 if (endPos
< startPos
) {
301 int len
= endPos
- startPos
;
302 if (!len
) return buf
;
304 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
305 tr
.chrg
.cpMin
= startPos
;
306 tr
.chrg
.cpMax
= endPos
;
307 len
= SendMsg(2015, 0, (long)&tr
);
308 buf
.UngetWriteBuf(len
);
312 // Are there any redoable actions in the undo history?
313 bool wxStyledTextCtrl::CanRedo() {
314 return SendMsg(2016, 0, 0) != 0;
317 // Retrieve the line number at which a particular marker is located.
318 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
319 return SendMsg(2017, handle
, 0);
323 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
324 SendMsg(2018, handle
, 0);
327 // Is undo history being collected?
328 bool wxStyledTextCtrl::GetUndoCollection() {
329 return SendMsg(2019, 0, 0) != 0;
332 // Are white space characters currently visible?
333 // Returns one of SCWS_* constants.
334 int wxStyledTextCtrl::GetViewWhiteSpace() {
335 return SendMsg(2020, 0, 0);
338 // Make white space characters invisible, always visible or visible outside indentation.
339 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
340 SendMsg(2021, viewWS
, 0);
343 // Find the position from a point within the window.
344 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
345 return SendMsg(2022, pt
.x
, pt
.y
);
348 // Find the position from a point within the window but return
349 // INVALID_POSITION if not close to text.
350 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
351 return SendMsg(2023, x
, y
);
354 // Set caret to start of a line and ensure it is visible.
355 void wxStyledTextCtrl::GotoLine(int line
) {
356 SendMsg(2024, line
, 0);
359 // Set caret to a position and ensure it is visible.
360 void wxStyledTextCtrl::GotoPos(int pos
) {
361 SendMsg(2025, pos
, 0);
364 // Set the selection anchor to a position. The anchor is the opposite
365 // end of the selection from the caret.
366 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
367 SendMsg(2026, posAnchor
, 0);
370 // Retrieve the text of the line containing the caret.
371 // Returns the index of the caret on the line.
372 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
373 int len
= LineLength(GetCurrentLine());
375 if (linePos
) *linePos
= 0;
376 return wxEmptyString
;
379 wxMemoryBuffer
mbuf(len
+1);
380 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
382 int pos
= SendMsg(2027, len
+1, (long)buf
);
383 mbuf
.UngetWriteBuf(len
);
385 if (linePos
) *linePos
= pos
;
389 // Retrieve the position of the last correctly styled character.
390 int wxStyledTextCtrl::GetEndStyled() {
391 return SendMsg(2028, 0, 0);
394 // Convert all line endings in the document to one mode.
395 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
396 SendMsg(2029, eolMode
, 0);
399 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
400 int wxStyledTextCtrl::GetEOLMode() {
401 return SendMsg(2030, 0, 0);
404 // Set the current end of line mode.
405 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
406 SendMsg(2031, eolMode
, 0);
409 // Set the current styling position to pos and the styling mask to mask.
410 // The styling mask can be used to protect some bits in each styling byte from modification.
411 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
412 SendMsg(2032, pos
, mask
);
415 // Change style from current styling position for length characters to a style
416 // and move the current styling position to after this newly styled segment.
417 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
418 SendMsg(2033, length
, style
);
421 // Is drawing done first into a buffer or direct to the screen?
422 bool wxStyledTextCtrl::GetBufferedDraw() {
423 return SendMsg(2034, 0, 0) != 0;
426 // If drawing is buffered then each line of text is drawn into a bitmap buffer
427 // before drawing it to the screen to avoid flicker.
428 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
429 SendMsg(2035, buffered
, 0);
432 // Change the visible size of a tab to be a multiple of the width of a space character.
433 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
434 SendMsg(2036, tabWidth
, 0);
437 // Retrieve the visible size of a tab.
438 int wxStyledTextCtrl::GetTabWidth() {
439 return SendMsg(2121, 0, 0);
442 // Set the code page used to interpret the bytes of the document as characters.
443 void wxStyledTextCtrl::SetCodePage(int codePage
) {
445 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
446 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
448 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
449 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
451 SendMsg(2037, codePage
);
454 // Set the symbol used for a particular marker number,
455 // and optionally the fore and background colours.
456 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
457 const wxColour
& foreground
,
458 const wxColour
& background
) {
460 SendMsg(2040, markerNumber
, markerSymbol
);
462 MarkerSetForeground(markerNumber
, foreground
);
464 MarkerSetBackground(markerNumber
, background
);
467 // Set the foreground colour used for a particular marker number.
468 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
469 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
472 // Set the background colour used for a particular marker number.
473 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
474 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
477 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
478 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
479 return SendMsg(2043, line
, markerNumber
);
482 // Delete a marker from a line.
483 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
484 SendMsg(2044, line
, markerNumber
);
487 // Delete all markers with a particular number from all lines.
488 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
489 SendMsg(2045, markerNumber
, 0);
492 // Get a bit mask of all the markers set on a line.
493 int wxStyledTextCtrl::MarkerGet(int line
) {
494 return SendMsg(2046, line
, 0);
497 // Find the next line after lineStart that includes a marker in mask.
498 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
499 return SendMsg(2047, lineStart
, markerMask
);
502 // Find the previous line before lineStart that includes a marker in mask.
503 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
504 return SendMsg(2048, lineStart
, markerMask
);
507 // Define a marker from a bitmap
508 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
509 // convert bmp to a xpm in a string
510 wxMemoryOutputStream strm
;
511 wxImage img
= bmp
.ConvertToImage();
512 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
513 size_t len
= strm
.GetSize();
514 char* buff
= new char[len
+1];
515 strm
.CopyTo(buff
, len
);
517 SendMsg(2049, markerNumber
, (long)buff
);
522 // Set a margin to be either numeric or symbolic.
523 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
524 SendMsg(2240, margin
, marginType
);
527 // Retrieve the type of a margin.
528 int wxStyledTextCtrl::GetMarginType(int margin
) {
529 return SendMsg(2241, margin
, 0);
532 // Set the width of a margin to a width expressed in pixels.
533 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
534 SendMsg(2242, margin
, pixelWidth
);
537 // Retrieve the width of a margin in pixels.
538 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
539 return SendMsg(2243, margin
, 0);
542 // Set a mask that determines which markers are displayed in a margin.
543 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
544 SendMsg(2244, margin
, mask
);
547 // Retrieve the marker mask of a margin.
548 int wxStyledTextCtrl::GetMarginMask(int margin
) {
549 return SendMsg(2245, margin
, 0);
552 // Make a margin sensitive or insensitive to mouse clicks.
553 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
554 SendMsg(2246, margin
, sensitive
);
557 // Retrieve the mouse click sensitivity of a margin.
558 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
559 return SendMsg(2247, margin
, 0) != 0;
562 // Clear all the styles and make equivalent to the global default style.
563 void wxStyledTextCtrl::StyleClearAll() {
567 // Set the foreground colour of a style.
568 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
569 SendMsg(2051, style
, wxColourAsLong(fore
));
572 // Set the background colour of a style.
573 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
574 SendMsg(2052, style
, wxColourAsLong(back
));
577 // Set a style to be bold or not.
578 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
579 SendMsg(2053, style
, bold
);
582 // Set a style to be italic or not.
583 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
584 SendMsg(2054, style
, italic
);
587 // Set the size of characters of a style.
588 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
589 SendMsg(2055, style
, sizePoints
);
592 // Set the font of a style.
593 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
594 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
597 // Set a style to have its end of line filled or not.
598 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
599 SendMsg(2057, style
, filled
);
602 // Reset the default style to its state at startup
603 void wxStyledTextCtrl::StyleResetDefault() {
607 // Set a style to be underlined or not.
608 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
609 SendMsg(2059, style
, underline
);
612 // Set a style to be mixed case, or to force upper or lower case.
613 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
614 SendMsg(2060, style
, caseForce
);
617 // Set the character set of the font in a style.
618 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
) {
619 SendMsg(2066, style
, characterSet
);
622 // Set a style to be a hotspot or not.
623 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
624 SendMsg(2409, style
, hotspot
);
627 // Set the foreground colour of the selection and whether to use this setting.
628 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
629 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
632 // Set the background colour of the selection and whether to use this setting.
633 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
634 SendMsg(2068, useSetting
, wxColourAsLong(back
));
637 // Set the foreground colour of the caret.
638 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
639 SendMsg(2069, wxColourAsLong(fore
), 0);
642 // When key+modifier combination km is pressed perform msg.
643 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
644 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
647 // When key+modifier combination km is pressed do nothing.
648 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
649 SendMsg(2071, MAKELONG(key
, modifiers
));
652 // Drop all key mappings.
653 void wxStyledTextCtrl::CmdKeyClearAll() {
657 // Set the styles for a segment of the document.
658 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
659 SendMsg(2073, length
, (long)styleBytes
);
662 // Set a style to be visible or not.
663 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
664 SendMsg(2074, style
, visible
);
667 // Get the time in milliseconds that the caret is on and off.
668 int wxStyledTextCtrl::GetCaretPeriod() {
669 return SendMsg(2075, 0, 0);
672 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
673 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
674 SendMsg(2076, periodMilliseconds
, 0);
677 // Set the set of characters making up words for when moving or selecting by word.
678 // First sets deaults like SetCharsDefault.
679 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
680 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
683 // Start a sequence of actions that is undone and redone as a unit.
685 void wxStyledTextCtrl::BeginUndoAction() {
689 // End a sequence of actions that is undone and redone as a unit.
690 void wxStyledTextCtrl::EndUndoAction() {
694 // Set an indicator to plain, squiggle or TT.
695 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
696 SendMsg(2080, indic
, style
);
699 // Retrieve the style of an indicator.
700 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
701 return SendMsg(2081, indic
, 0);
704 // Set the foreground colour of an indicator.
705 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
706 SendMsg(2082, indic
, wxColourAsLong(fore
));
709 // Retrieve the foreground colour of an indicator.
710 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
711 long c
= SendMsg(2083, indic
, 0);
712 return wxColourFromLong(c
);
715 // Set the foreground colour of all whitespace and whether to use this setting.
716 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
717 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
720 // Set the background colour of all whitespace and whether to use this setting.
721 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
722 SendMsg(2085, useSetting
, wxColourAsLong(back
));
725 // Divide each styling byte into lexical class bits (default: 5) and indicator
726 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
727 // is used to expand the possible states.
728 void wxStyledTextCtrl::SetStyleBits(int bits
) {
729 SendMsg(2090, bits
, 0);
732 // Retrieve number of bits in style bytes used to hold the lexical state.
733 int wxStyledTextCtrl::GetStyleBits() {
734 return SendMsg(2091, 0, 0);
737 // Used to hold extra styling information for each line.
738 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
739 SendMsg(2092, line
, state
);
742 // Retrieve the extra styling information for a line.
743 int wxStyledTextCtrl::GetLineState(int line
) {
744 return SendMsg(2093, line
, 0);
747 // Retrieve the last line number that has line state.
748 int wxStyledTextCtrl::GetMaxLineState() {
749 return SendMsg(2094, 0, 0);
752 // Is the background of the line containing the caret in a different colour?
753 bool wxStyledTextCtrl::GetCaretLineVisible() {
754 return SendMsg(2095, 0, 0) != 0;
757 // Display the background of the line containing the caret in a different colour.
758 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
759 SendMsg(2096, show
, 0);
762 // Get the colour of the background of the line containing the caret.
763 wxColour
wxStyledTextCtrl::GetCaretLineBack() {
764 long c
= SendMsg(2097, 0, 0);
765 return wxColourFromLong(c
);
768 // Set the colour of the background of the line containing the caret.
769 void wxStyledTextCtrl::SetCaretLineBack(const wxColour
& back
) {
770 SendMsg(2098, wxColourAsLong(back
), 0);
773 // Set a style to be changeable or not (read only).
774 // Experimental feature, currently buggy.
775 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
776 SendMsg(2099, style
, changeable
);
779 // Display a auto-completion list.
780 // The lenEntered parameter indicates how many characters before
781 // the caret should be used to provide context.
782 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
783 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
786 // Remove the auto-completion list from the screen.
787 void wxStyledTextCtrl::AutoCompCancel() {
791 // Is there an auto-completion list visible?
792 bool wxStyledTextCtrl::AutoCompActive() {
793 return SendMsg(2102, 0, 0) != 0;
796 // Retrieve the position of the caret when the auto-completion list was displayed.
797 int wxStyledTextCtrl::AutoCompPosStart() {
798 return SendMsg(2103, 0, 0);
801 // User has selected an item so remove the list and insert the selection.
802 void wxStyledTextCtrl::AutoCompComplete() {
806 // Define a set of character that when typed cancel the auto-completion list.
807 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
808 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
811 // Change the separator character in the string setting up an auto-completion list.
812 // Default is space but can be changed if items contain space.
813 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
814 SendMsg(2106, separatorCharacter
, 0);
817 // Retrieve the auto-completion list separator character.
818 int wxStyledTextCtrl::AutoCompGetSeparator() {
819 return SendMsg(2107, 0, 0);
822 // Select the item in the auto-completion list that starts with a string.
823 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
824 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
827 // Should the auto-completion list be cancelled if the user backspaces to a
828 // position before where the box was created.
829 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
830 SendMsg(2110, cancel
, 0);
833 // Retrieve whether auto-completion cancelled by backspacing before start.
834 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
835 return SendMsg(2111, 0, 0) != 0;
838 // Define a set of characters that when typed will cause the autocompletion to
839 // choose the selected item.
840 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
841 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
844 // Should a single item auto-completion list automatically choose the item.
845 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
846 SendMsg(2113, chooseSingle
, 0);
849 // Retrieve whether a single item auto-completion list automatically choose the item.
850 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
851 return SendMsg(2114, 0, 0) != 0;
854 // Set whether case is significant when performing auto-completion searches.
855 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
856 SendMsg(2115, ignoreCase
, 0);
859 // Retrieve state of ignore case flag.
860 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
861 return SendMsg(2116, 0, 0) != 0;
864 // Display a list of strings and send notification when user chooses one.
865 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
866 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
869 // Set whether or not autocompletion is hidden automatically when nothing matches.
870 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
871 SendMsg(2118, autoHide
, 0);
874 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
875 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
876 return SendMsg(2119, 0, 0) != 0;
879 // Set whether or not autocompletion deletes any word characters
880 // after the inserted text upon completion.
881 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
882 SendMsg(2270, dropRestOfWord
, 0);
885 // Retrieve whether or not autocompletion deletes any word characters
886 // after the inserted text upon completion.
887 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
888 return SendMsg(2271, 0, 0) != 0;
891 // Register an image for use in autocompletion lists.
892 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
893 // convert bmp to a xpm in a string
894 wxMemoryOutputStream strm
;
895 wxImage img
= bmp
.ConvertToImage();
896 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
897 size_t len
= strm
.GetSize();
898 char* buff
= new char[len
+1];
899 strm
.CopyTo(buff
, len
);
901 SendMsg(2405, type
, (long)buff
);
906 // Clear all the registered images.
907 void wxStyledTextCtrl::ClearRegisteredImages() {
911 // Retrieve the auto-completion list type-separator character.
912 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
913 return SendMsg(2285, 0, 0);
916 // Change the type-separator character in the string setting up an auto-completion list.
917 // Default is '?' but can be changed if items contain '?'.
918 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
919 SendMsg(2286, separatorCharacter
, 0);
922 // Set the number of spaces used for one level of indentation.
923 void wxStyledTextCtrl::SetIndent(int indentSize
) {
924 SendMsg(2122, indentSize
, 0);
927 // Retrieve indentation size.
928 int wxStyledTextCtrl::GetIndent() {
929 return SendMsg(2123, 0, 0);
932 // Indentation will only use space characters if useTabs is false, otherwise
933 // it will use a combination of tabs and spaces.
934 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
935 SendMsg(2124, useTabs
, 0);
938 // Retrieve whether tabs will be used in indentation.
939 bool wxStyledTextCtrl::GetUseTabs() {
940 return SendMsg(2125, 0, 0) != 0;
943 // Change the indentation of a line to a number of columns.
944 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
945 SendMsg(2126, line
, indentSize
);
948 // Retrieve the number of columns that a line is indented.
949 int wxStyledTextCtrl::GetLineIndentation(int line
) {
950 return SendMsg(2127, line
, 0);
953 // Retrieve the position before the first non indentation character on a line.
954 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
955 return SendMsg(2128, line
, 0);
958 // Retrieve the column number of a position, taking tab width into account.
959 int wxStyledTextCtrl::GetColumn(int pos
) {
960 return SendMsg(2129, pos
, 0);
963 // Show or hide the horizontal scroll bar.
964 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
965 SendMsg(2130, show
, 0);
968 // Is the horizontal scroll bar visible?
969 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
970 return SendMsg(2131, 0, 0) != 0;
973 // Show or hide indentation guides.
974 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
975 SendMsg(2132, show
, 0);
978 // Are the indentation guides visible?
979 bool wxStyledTextCtrl::GetIndentationGuides() {
980 return SendMsg(2133, 0, 0) != 0;
983 // Set the highlighted indentation guide column.
984 // 0 = no highlighted guide.
985 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
986 SendMsg(2134, column
, 0);
989 // Get the highlighted indentation guide column.
990 int wxStyledTextCtrl::GetHighlightGuide() {
991 return SendMsg(2135, 0, 0);
994 // Get the position after the last visible characters on a line.
995 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
996 return SendMsg(2136, line
, 0);
999 // Get the code page used to interpret the bytes of the document as characters.
1000 int wxStyledTextCtrl::GetCodePage() {
1001 return SendMsg(2137, 0, 0);
1004 // Get the foreground colour of the caret.
1005 wxColour
wxStyledTextCtrl::GetCaretForeground() {
1006 long c
= SendMsg(2138, 0, 0);
1007 return wxColourFromLong(c
);
1010 // In read-only mode?
1011 bool wxStyledTextCtrl::GetReadOnly() {
1012 return SendMsg(2140, 0, 0) != 0;
1015 // Sets the position of the caret.
1016 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
1017 SendMsg(2141, pos
, 0);
1020 // Sets the position that starts the selection - this becomes the anchor.
1021 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1022 SendMsg(2142, pos
, 0);
1025 // Returns the position at the start of the selection.
1026 int wxStyledTextCtrl::GetSelectionStart() {
1027 return SendMsg(2143, 0, 0);
1030 // Sets the position that ends the selection - this becomes the currentPosition.
1031 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1032 SendMsg(2144, pos
, 0);
1035 // Returns the position at the end of the selection.
1036 int wxStyledTextCtrl::GetSelectionEnd() {
1037 return SendMsg(2145, 0, 0);
1040 // Sets the print magnification added to the point size of each style for printing.
1041 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1042 SendMsg(2146, magnification
, 0);
1045 // Returns the print magnification.
1046 int wxStyledTextCtrl::GetPrintMagnification() {
1047 return SendMsg(2147, 0, 0);
1050 // Modify colours when printing for clearer printed text.
1051 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1052 SendMsg(2148, mode
, 0);
1055 // Returns the print colour mode.
1056 int wxStyledTextCtrl::GetPrintColourMode() {
1057 return SendMsg(2149, 0, 0);
1060 // Find some text in the document.
1061 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1062 const wxString
& text
,
1065 ft
.chrg
.cpMin
= minPos
;
1066 ft
.chrg
.cpMax
= maxPos
;
1067 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1068 ft
.lpstrText
= (char*)(const char*)buf
;
1070 return SendMsg(2150, flags
, (long)&ft
);
1073 // On Windows, will draw the document into a display context such as a printer.
1074 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1083 if (endPos
< startPos
) {
1084 int temp
= startPos
;
1089 fr
.hdcTarget
= target
;
1090 fr
.rc
.top
= renderRect
.GetTop();
1091 fr
.rc
.left
= renderRect
.GetLeft();
1092 fr
.rc
.right
= renderRect
.GetRight();
1093 fr
.rc
.bottom
= renderRect
.GetBottom();
1094 fr
.rcPage
.top
= pageRect
.GetTop();
1095 fr
.rcPage
.left
= pageRect
.GetLeft();
1096 fr
.rcPage
.right
= pageRect
.GetRight();
1097 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1098 fr
.chrg
.cpMin
= startPos
;
1099 fr
.chrg
.cpMax
= endPos
;
1101 return SendMsg(2151, doDraw
, (long)&fr
);
1104 // Retrieve the display line at the top of the display.
1105 int wxStyledTextCtrl::GetFirstVisibleLine() {
1106 return SendMsg(2152, 0, 0);
1109 // Retrieve the contents of a line.
1110 wxString
wxStyledTextCtrl::GetLine(int line
) {
1111 int len
= LineLength(line
);
1112 if (!len
) return wxEmptyString
;
1114 wxMemoryBuffer
mbuf(len
+1);
1115 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1116 SendMsg(2153, line
, (long)buf
);
1117 mbuf
.UngetWriteBuf(len
);
1122 // Returns the number of lines in the document. There is always at least one.
1123 int wxStyledTextCtrl::GetLineCount() {
1124 return SendMsg(2154, 0, 0);
1127 // Sets the size in pixels of the left margin.
1128 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1129 SendMsg(2155, 0, pixelWidth
);
1132 // Returns the size in pixels of the left margin.
1133 int wxStyledTextCtrl::GetMarginLeft() {
1134 return SendMsg(2156, 0, 0);
1137 // Sets the size in pixels of the right margin.
1138 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1139 SendMsg(2157, 0, pixelWidth
);
1142 // Returns the size in pixels of the right margin.
1143 int wxStyledTextCtrl::GetMarginRight() {
1144 return SendMsg(2158, 0, 0);
1147 // Is the document different from when it was last saved?
1148 bool wxStyledTextCtrl::GetModify() {
1149 return SendMsg(2159, 0, 0) != 0;
1152 // Select a range of text.
1153 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1154 SendMsg(2160, start
, end
);
1157 // Retrieve the selected text.
1158 wxString
wxStyledTextCtrl::GetSelectedText() {
1162 GetSelection(&start
, &end
);
1163 int len
= end
- start
;
1164 if (!len
) return wxEmptyString
;
1166 wxMemoryBuffer
mbuf(len
+2);
1167 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1168 SendMsg(2161, 0, (long)buf
);
1169 mbuf
.UngetWriteBuf(len
);
1174 // Retrieve a range of text.
1175 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1176 if (endPos
< startPos
) {
1177 int temp
= startPos
;
1181 int len
= endPos
- startPos
;
1182 if (!len
) return wxEmptyString
;
1183 wxMemoryBuffer
mbuf(len
+1);
1184 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1187 tr
.chrg
.cpMin
= startPos
;
1188 tr
.chrg
.cpMax
= endPos
;
1189 SendMsg(2162, 0, (long)&tr
);
1190 mbuf
.UngetWriteBuf(len
);
1195 // Draw the selection in normal style or with selection highlighted.
1196 void wxStyledTextCtrl::HideSelection(bool normal
) {
1197 SendMsg(2163, normal
, 0);
1200 // Retrieve the line containing a position.
1201 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1202 return SendMsg(2166, pos
, 0);
1205 // Retrieve the position at the start of a line.
1206 int wxStyledTextCtrl::PositionFromLine(int line
) {
1207 return SendMsg(2167, line
, 0);
1210 // Scroll horizontally and vertically.
1211 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1212 SendMsg(2168, columns
, lines
);
1215 // Ensure the caret is visible.
1216 void wxStyledTextCtrl::EnsureCaretVisible() {
1217 SendMsg(2169, 0, 0);
1220 // Replace the selected text with the argument text.
1221 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1222 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1225 // Set to read only or read write.
1226 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1227 SendMsg(2171, readOnly
, 0);
1230 // Will a paste succeed?
1231 bool wxStyledTextCtrl::CanPaste() {
1232 return SendMsg(2173, 0, 0) != 0;
1235 // Are there any undoable actions in the undo history?
1236 bool wxStyledTextCtrl::CanUndo() {
1237 return SendMsg(2174, 0, 0) != 0;
1240 // Delete the undo history.
1241 void wxStyledTextCtrl::EmptyUndoBuffer() {
1242 SendMsg(2175, 0, 0);
1245 // Undo one action in the undo history.
1246 void wxStyledTextCtrl::Undo() {
1247 SendMsg(2176, 0, 0);
1250 // Cut the selection to the clipboard.
1251 void wxStyledTextCtrl::Cut() {
1252 SendMsg(2177, 0, 0);
1255 // Copy the selection to the clipboard.
1256 void wxStyledTextCtrl::Copy() {
1257 SendMsg(2178, 0, 0);
1260 // Paste the contents of the clipboard into the document replacing the selection.
1261 void wxStyledTextCtrl::Paste() {
1262 SendMsg(2179, 0, 0);
1265 // Clear the selection.
1266 void wxStyledTextCtrl::Clear() {
1267 SendMsg(2180, 0, 0);
1270 // Replace the contents of the document with the argument text.
1271 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1272 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1275 // Retrieve all the text in the document.
1276 wxString
wxStyledTextCtrl::GetText() {
1277 int len
= GetTextLength();
1278 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1279 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1280 SendMsg(2182, len
+1, (long)buf
);
1281 mbuf
.UngetWriteBuf(len
);
1286 // Retrieve the number of characters in the document.
1287 int wxStyledTextCtrl::GetTextLength() {
1288 return SendMsg(2183, 0, 0);
1291 // Set to overtype (true) or insert mode.
1292 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1293 SendMsg(2186, overtype
, 0);
1296 // Returns true if overtype mode is active otherwise false is returned.
1297 bool wxStyledTextCtrl::GetOvertype() {
1298 return SendMsg(2187, 0, 0) != 0;
1301 // Set the width of the insert mode caret.
1302 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1303 SendMsg(2188, pixelWidth
, 0);
1306 // Returns the width of the insert mode caret.
1307 int wxStyledTextCtrl::GetCaretWidth() {
1308 return SendMsg(2189, 0, 0);
1311 // Sets the position that starts the target which is used for updating the
1312 // document without affecting the scroll position.
1313 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1314 SendMsg(2190, pos
, 0);
1317 // Get the position that starts the target.
1318 int wxStyledTextCtrl::GetTargetStart() {
1319 return SendMsg(2191, 0, 0);
1322 // Sets the position that ends the target which is used for updating the
1323 // document without affecting the scroll position.
1324 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1325 SendMsg(2192, pos
, 0);
1328 // Get the position that ends the target.
1329 int wxStyledTextCtrl::GetTargetEnd() {
1330 return SendMsg(2193, 0, 0);
1333 // Replace the target text with the argument text.
1334 // Text is counted so it can contain NULs.
1335 // Returns the length of the replacement text.
1337 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1338 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1339 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1342 // Replace the target text with the argument text after \d processing.
1343 // Text is counted so it can contain NULs.
1344 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1345 // matched in the last search operation which were surrounded by \( and \).
1346 // Returns the length of the replacement text including any change
1347 // caused by processing the \d patterns.
1349 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1350 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1351 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1354 // Search for a counted string in the target and set the target to the found
1355 // range. Text is counted so it can contain NULs.
1356 // Returns length of range or -1 for failure in which case target is not moved.
1358 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1359 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1360 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1363 // Set the search flags used by SearchInTarget.
1364 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1365 SendMsg(2198, flags
, 0);
1368 // Get the search flags used by SearchInTarget.
1369 int wxStyledTextCtrl::GetSearchFlags() {
1370 return SendMsg(2199, 0, 0);
1373 // Show a call tip containing a definition near position pos.
1374 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1375 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1378 // Remove the call tip from the screen.
1379 void wxStyledTextCtrl::CallTipCancel() {
1380 SendMsg(2201, 0, 0);
1383 // Is there an active call tip?
1384 bool wxStyledTextCtrl::CallTipActive() {
1385 return SendMsg(2202, 0, 0) != 0;
1388 // Retrieve the position where the caret was before displaying the call tip.
1389 int wxStyledTextCtrl::CallTipPosAtStart() {
1390 return SendMsg(2203, 0, 0);
1393 // Highlight a segment of the definition.
1394 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1395 SendMsg(2204, start
, end
);
1398 // Set the background colour for the call tip.
1399 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1400 SendMsg(2205, wxColourAsLong(back
), 0);
1403 // Set the foreground colour for the call tip.
1404 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1405 SendMsg(2206, wxColourAsLong(fore
), 0);
1408 // Set the foreground colour for the highlighted part of the call tip.
1409 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1410 SendMsg(2207, wxColourAsLong(fore
), 0);
1413 // Find the display line of a document line taking hidden lines into account.
1414 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1415 return SendMsg(2220, line
, 0);
1418 // Find the document line of a display line taking hidden lines into account.
1419 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1420 return SendMsg(2221, lineDisplay
, 0);
1423 // Set the fold level of a line.
1424 // This encodes an integer level along with flags indicating whether the
1425 // line is a header and whether it is effectively white space.
1426 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1427 SendMsg(2222, line
, level
);
1430 // Retrieve the fold level of a line.
1431 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1432 return SendMsg(2223, line
, 0);
1435 // Find the last child line of a header line.
1436 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1437 return SendMsg(2224, line
, level
);
1440 // Find the parent line of a child line.
1441 int wxStyledTextCtrl::GetFoldParent(int line
) {
1442 return SendMsg(2225, line
, 0);
1445 // Make a range of lines visible.
1446 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1447 SendMsg(2226, lineStart
, lineEnd
);
1450 // Make a range of lines invisible.
1451 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1452 SendMsg(2227, lineStart
, lineEnd
);
1455 // Is a line visible?
1456 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1457 return SendMsg(2228, line
, 0) != 0;
1460 // Show the children of a header line.
1461 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1462 SendMsg(2229, line
, expanded
);
1465 // Is a header line expanded?
1466 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1467 return SendMsg(2230, line
, 0) != 0;
1470 // Switch a header line between expanded and contracted.
1471 void wxStyledTextCtrl::ToggleFold(int line
) {
1472 SendMsg(2231, line
, 0);
1475 // Ensure a particular line is visible by expanding any header line hiding it.
1476 void wxStyledTextCtrl::EnsureVisible(int line
) {
1477 SendMsg(2232, line
, 0);
1480 // Set some style options for folding.
1481 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1482 SendMsg(2233, flags
, 0);
1485 // Ensure a particular line is visible by expanding any header line hiding it.
1486 // Use the currently set visibility policy to determine which range to display.
1487 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1488 SendMsg(2234, line
, 0);
1491 // Sets whether a tab pressed when caret is within indentation indents.
1492 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1493 SendMsg(2260, tabIndents
, 0);
1496 // Does a tab pressed when caret is within indentation indent?
1497 bool wxStyledTextCtrl::GetTabIndents() {
1498 return SendMsg(2261, 0, 0) != 0;
1501 // Sets whether a backspace pressed when caret is within indentation unindents.
1502 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1503 SendMsg(2262, bsUnIndents
, 0);
1506 // Does a backspace pressed when caret is within indentation unindent?
1507 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1508 return SendMsg(2263, 0, 0) != 0;
1511 // Sets the time the mouse must sit still to generate a mouse dwell event.
1512 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1513 SendMsg(2264, periodMilliseconds
, 0);
1516 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1517 int wxStyledTextCtrl::GetMouseDwellTime() {
1518 return SendMsg(2265, 0, 0);
1521 // Get position of start of word.
1522 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1523 return SendMsg(2266, pos
, onlyWordCharacters
);
1526 // Get position of end of word.
1527 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1528 return SendMsg(2267, pos
, onlyWordCharacters
);
1531 // Sets whether text is word wrapped.
1532 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1533 SendMsg(2268, mode
, 0);
1536 // Retrieve whether text is word wrapped.
1537 int wxStyledTextCtrl::GetWrapMode() {
1538 return SendMsg(2269, 0, 0);
1541 // Set the display mode of visual flags for wrapped lines.
1542 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1543 SendMsg(2460, wrapVisualFlags
, 0);
1546 // Retrive the display mode of visual flags for wrapped lines.
1547 int wxStyledTextCtrl::GetWrapVisualFlags() {
1548 return SendMsg(2461, 0, 0);
1551 // Set the location of visual flags for wrapped lines.
1552 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1553 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1556 // Retrive the location of visual flags for wrapped lines.
1557 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1558 return SendMsg(2463, 0, 0);
1561 // Set the start indent for wrapped lines.
1562 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1563 SendMsg(2464, indent
, 0);
1566 // Retrive the start indent for wrapped lines.
1567 int wxStyledTextCtrl::GetWrapStartIndent() {
1568 return SendMsg(2465, 0, 0);
1571 // Sets the degree of caching of layout information.
1572 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1573 SendMsg(2272, mode
, 0);
1576 // Retrieve the degree of caching of layout information.
1577 int wxStyledTextCtrl::GetLayoutCache() {
1578 return SendMsg(2273, 0, 0);
1581 // Sets the document width assumed for scrolling.
1582 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1583 SendMsg(2274, pixelWidth
, 0);
1586 // Retrieve the document width assumed for scrolling.
1587 int wxStyledTextCtrl::GetScrollWidth() {
1588 return SendMsg(2275, 0, 0);
1591 // Measure the pixel width of some text in a particular style.
1592 // NUL terminated text argument.
1593 // Does not handle tab or control characters.
1594 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1595 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1598 // Sets the scroll range so that maximum scroll position has
1599 // the last line at the bottom of the view (default).
1600 // Setting this to false allows scrolling one page below the last line.
1601 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1602 SendMsg(2277, endAtLastLine
, 0);
1605 // Retrieve whether the maximum scroll position has the last
1606 // line at the bottom of the view.
1607 int wxStyledTextCtrl::GetEndAtLastLine() {
1608 return SendMsg(2278, 0, 0);
1611 // Retrieve the height of a particular line of text in pixels.
1612 int wxStyledTextCtrl::TextHeight(int line
) {
1613 return SendMsg(2279, line
, 0);
1616 // Show or hide the vertical scroll bar.
1617 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1618 SendMsg(2280, show
, 0);
1621 // Is the vertical scroll bar visible?
1622 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1623 return SendMsg(2281, 0, 0) != 0;
1626 // Append a string to the end of the document without changing the selection.
1627 void wxStyledTextCtrl::AppendText(int length
, const wxString
& text
) {
1628 SendMsg(2282, length
, (long)(const char*)wx2stc(text
));
1631 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1632 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1633 return SendMsg(2283, 0, 0) != 0;
1636 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1637 // and then the foreground. This avoids chopping off characters that overlap the next run.
1638 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1639 SendMsg(2284, twoPhase
, 0);
1642 // Make the target range start and end be the same as the selection range start and end.
1643 void wxStyledTextCtrl::TargetFromSelection() {
1644 SendMsg(2287, 0, 0);
1647 // Join the lines in the target.
1648 void wxStyledTextCtrl::LinesJoin() {
1649 SendMsg(2288, 0, 0);
1652 // Split the lines in the target into lines that are less wide than pixelWidth
1654 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1655 SendMsg(2289, pixelWidth
, 0);
1658 // Set the colours used as a chequerboard pattern in the fold margin
1659 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1660 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1662 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1663 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1666 // Move caret down one line.
1667 void wxStyledTextCtrl::LineDown() {
1668 SendMsg(2300, 0, 0);
1671 // Move caret down one line extending selection to new caret position.
1672 void wxStyledTextCtrl::LineDownExtend() {
1673 SendMsg(2301, 0, 0);
1676 // Move caret up one line.
1677 void wxStyledTextCtrl::LineUp() {
1678 SendMsg(2302, 0, 0);
1681 // Move caret up one line extending selection to new caret position.
1682 void wxStyledTextCtrl::LineUpExtend() {
1683 SendMsg(2303, 0, 0);
1686 // Move caret left one character.
1687 void wxStyledTextCtrl::CharLeft() {
1688 SendMsg(2304, 0, 0);
1691 // Move caret left one character extending selection to new caret position.
1692 void wxStyledTextCtrl::CharLeftExtend() {
1693 SendMsg(2305, 0, 0);
1696 // Move caret right one character.
1697 void wxStyledTextCtrl::CharRight() {
1698 SendMsg(2306, 0, 0);
1701 // Move caret right one character extending selection to new caret position.
1702 void wxStyledTextCtrl::CharRightExtend() {
1703 SendMsg(2307, 0, 0);
1706 // Move caret left one word.
1707 void wxStyledTextCtrl::WordLeft() {
1708 SendMsg(2308, 0, 0);
1711 // Move caret left one word extending selection to new caret position.
1712 void wxStyledTextCtrl::WordLeftExtend() {
1713 SendMsg(2309, 0, 0);
1716 // Move caret right one word.
1717 void wxStyledTextCtrl::WordRight() {
1718 SendMsg(2310, 0, 0);
1721 // Move caret right one word extending selection to new caret position.
1722 void wxStyledTextCtrl::WordRightExtend() {
1723 SendMsg(2311, 0, 0);
1726 // Move caret to first position on line.
1727 void wxStyledTextCtrl::Home() {
1728 SendMsg(2312, 0, 0);
1731 // Move caret to first position on line extending selection to new caret position.
1732 void wxStyledTextCtrl::HomeExtend() {
1733 SendMsg(2313, 0, 0);
1736 // Move caret to last position on line.
1737 void wxStyledTextCtrl::LineEnd() {
1738 SendMsg(2314, 0, 0);
1741 // Move caret to last position on line extending selection to new caret position.
1742 void wxStyledTextCtrl::LineEndExtend() {
1743 SendMsg(2315, 0, 0);
1746 // Move caret to first position in document.
1747 void wxStyledTextCtrl::DocumentStart() {
1748 SendMsg(2316, 0, 0);
1751 // Move caret to first position in document extending selection to new caret position.
1752 void wxStyledTextCtrl::DocumentStartExtend() {
1753 SendMsg(2317, 0, 0);
1756 // Move caret to last position in document.
1757 void wxStyledTextCtrl::DocumentEnd() {
1758 SendMsg(2318, 0, 0);
1761 // Move caret to last position in document extending selection to new caret position.
1762 void wxStyledTextCtrl::DocumentEndExtend() {
1763 SendMsg(2319, 0, 0);
1766 // Move caret one page up.
1767 void wxStyledTextCtrl::PageUp() {
1768 SendMsg(2320, 0, 0);
1771 // Move caret one page up extending selection to new caret position.
1772 void wxStyledTextCtrl::PageUpExtend() {
1773 SendMsg(2321, 0, 0);
1776 // Move caret one page down.
1777 void wxStyledTextCtrl::PageDown() {
1778 SendMsg(2322, 0, 0);
1781 // Move caret one page down extending selection to new caret position.
1782 void wxStyledTextCtrl::PageDownExtend() {
1783 SendMsg(2323, 0, 0);
1786 // Switch from insert to overtype mode or the reverse.
1787 void wxStyledTextCtrl::EditToggleOvertype() {
1788 SendMsg(2324, 0, 0);
1791 // Cancel any modes such as call tip or auto-completion list display.
1792 void wxStyledTextCtrl::Cancel() {
1793 SendMsg(2325, 0, 0);
1796 // Delete the selection or if no selection, the character before the caret.
1797 void wxStyledTextCtrl::DeleteBack() {
1798 SendMsg(2326, 0, 0);
1801 // If selection is empty or all on one line replace the selection with a tab character.
1802 // If more than one line selected, indent the lines.
1803 void wxStyledTextCtrl::Tab() {
1804 SendMsg(2327, 0, 0);
1807 // Dedent the selected lines.
1808 void wxStyledTextCtrl::BackTab() {
1809 SendMsg(2328, 0, 0);
1812 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1813 void wxStyledTextCtrl::NewLine() {
1814 SendMsg(2329, 0, 0);
1817 // Insert a Form Feed character.
1818 void wxStyledTextCtrl::FormFeed() {
1819 SendMsg(2330, 0, 0);
1822 // Move caret to before first visible character on line.
1823 // If already there move to first character on line.
1824 void wxStyledTextCtrl::VCHome() {
1825 SendMsg(2331, 0, 0);
1828 // Like VCHome but extending selection to new caret position.
1829 void wxStyledTextCtrl::VCHomeExtend() {
1830 SendMsg(2332, 0, 0);
1833 // Magnify the displayed text by increasing the sizes by 1 point.
1834 void wxStyledTextCtrl::ZoomIn() {
1835 SendMsg(2333, 0, 0);
1838 // Make the displayed text smaller by decreasing the sizes by 1 point.
1839 void wxStyledTextCtrl::ZoomOut() {
1840 SendMsg(2334, 0, 0);
1843 // Delete the word to the left of the caret.
1844 void wxStyledTextCtrl::DelWordLeft() {
1845 SendMsg(2335, 0, 0);
1848 // Delete the word to the right of the caret.
1849 void wxStyledTextCtrl::DelWordRight() {
1850 SendMsg(2336, 0, 0);
1853 // Cut the line containing the caret.
1854 void wxStyledTextCtrl::LineCut() {
1855 SendMsg(2337, 0, 0);
1858 // Delete the line containing the caret.
1859 void wxStyledTextCtrl::LineDelete() {
1860 SendMsg(2338, 0, 0);
1863 // Switch the current line with the previous.
1864 void wxStyledTextCtrl::LineTranspose() {
1865 SendMsg(2339, 0, 0);
1868 // Duplicate the current line.
1869 void wxStyledTextCtrl::LineDuplicate() {
1870 SendMsg(2404, 0, 0);
1873 // Transform the selection to lower case.
1874 void wxStyledTextCtrl::LowerCase() {
1875 SendMsg(2340, 0, 0);
1878 // Transform the selection to upper case.
1879 void wxStyledTextCtrl::UpperCase() {
1880 SendMsg(2341, 0, 0);
1883 // Scroll the document down, keeping the caret visible.
1884 void wxStyledTextCtrl::LineScrollDown() {
1885 SendMsg(2342, 0, 0);
1888 // Scroll the document up, keeping the caret visible.
1889 void wxStyledTextCtrl::LineScrollUp() {
1890 SendMsg(2343, 0, 0);
1893 // Delete the selection or if no selection, the character before the caret.
1894 // Will not delete the character before at the start of a line.
1895 void wxStyledTextCtrl::DeleteBackNotLine() {
1896 SendMsg(2344, 0, 0);
1899 // Move caret to first position on display line.
1900 void wxStyledTextCtrl::HomeDisplay() {
1901 SendMsg(2345, 0, 0);
1904 // Move caret to first position on display line extending selection to
1905 // new caret position.
1906 void wxStyledTextCtrl::HomeDisplayExtend() {
1907 SendMsg(2346, 0, 0);
1910 // Move caret to last position on display line.
1911 void wxStyledTextCtrl::LineEndDisplay() {
1912 SendMsg(2347, 0, 0);
1915 // Move caret to last position on display line extending selection to new
1917 void wxStyledTextCtrl::LineEndDisplayExtend() {
1918 SendMsg(2348, 0, 0);
1921 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1922 // except they behave differently when word-wrap is enabled:
1923 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1924 // The difference is that, the cursor is already at the point, it goes on to the start
1925 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1926 void wxStyledTextCtrl::HomeWrap() {
1927 SendMsg(2349, 0, 0);
1929 void wxStyledTextCtrl::HomeWrapExtend() {
1930 SendMsg(2450, 0, 0);
1932 void wxStyledTextCtrl::LineEndWrap() {
1933 SendMsg(2451, 0, 0);
1935 void wxStyledTextCtrl::LineEndWrapExtend() {
1936 SendMsg(2452, 0, 0);
1938 void wxStyledTextCtrl::VCHomeWrap() {
1939 SendMsg(2453, 0, 0);
1941 void wxStyledTextCtrl::VCHomeWrapExtend() {
1942 SendMsg(2454, 0, 0);
1945 // Copy the line containing the caret.
1946 void wxStyledTextCtrl::LineCopy() {
1947 SendMsg(2455, 0, 0);
1950 // Move the caret inside current view if it's not there already.
1951 void wxStyledTextCtrl::MoveCaretInsideView() {
1952 SendMsg(2401, 0, 0);
1955 // How many characters are on a line, not including end of line characters?
1956 int wxStyledTextCtrl::LineLength(int line
) {
1957 return SendMsg(2350, line
, 0);
1960 // Highlight the characters at two positions.
1961 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1962 SendMsg(2351, pos1
, pos2
);
1965 // Highlight the character at a position indicating there is no matching brace.
1966 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1967 SendMsg(2352, pos
, 0);
1970 // Find the position of a matching brace or INVALID_POSITION if no match.
1971 int wxStyledTextCtrl::BraceMatch(int pos
) {
1972 return SendMsg(2353, pos
, 0);
1975 // Are the end of line characters visible?
1976 bool wxStyledTextCtrl::GetViewEOL() {
1977 return SendMsg(2355, 0, 0) != 0;
1980 // Make the end of line characters visible or invisible.
1981 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1982 SendMsg(2356, visible
, 0);
1985 // Retrieve a pointer to the document object.
1986 void* wxStyledTextCtrl::GetDocPointer() {
1987 return (void*)SendMsg(2357);
1990 // Change the document object used.
1991 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1992 SendMsg(2358, 0, (long)docPointer
);
1995 // Set which document modification events are sent to the container.
1996 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1997 SendMsg(2359, mask
, 0);
2000 // Retrieve the column number which text should be kept within.
2001 int wxStyledTextCtrl::GetEdgeColumn() {
2002 return SendMsg(2360, 0, 0);
2005 // Set the column number of the edge.
2006 // If text goes past the edge then it is highlighted.
2007 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
2008 SendMsg(2361, column
, 0);
2011 // Retrieve the edge highlight mode.
2012 int wxStyledTextCtrl::GetEdgeMode() {
2013 return SendMsg(2362, 0, 0);
2016 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2017 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2018 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2019 SendMsg(2363, mode
, 0);
2022 // Retrieve the colour used in edge indication.
2023 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2024 long c
= SendMsg(2364, 0, 0);
2025 return wxColourFromLong(c
);
2028 // Change the colour used in edge indication.
2029 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2030 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2033 // Sets the current caret position to be the search anchor.
2034 void wxStyledTextCtrl::SearchAnchor() {
2035 SendMsg(2366, 0, 0);
2038 // Find some text starting at the search anchor.
2039 // Does not ensure the selection is visible.
2040 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2041 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2044 // Find some text starting at the search anchor and moving backwards.
2045 // Does not ensure the selection is visible.
2046 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2047 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2050 // Retrieves the number of lines completely visible.
2051 int wxStyledTextCtrl::LinesOnScreen() {
2052 return SendMsg(2370, 0, 0);
2055 // Set whether a pop up menu is displayed automatically when the user presses
2056 // the wrong mouse button.
2057 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2058 SendMsg(2371, allowPopUp
, 0);
2061 // Is the selection rectangular? The alternative is the more common stream selection.
2062 bool wxStyledTextCtrl::SelectionIsRectangle() {
2063 return SendMsg(2372, 0, 0) != 0;
2066 // Set the zoom level. This number of points is added to the size of all fonts.
2067 // It may be positive to magnify or negative to reduce.
2068 void wxStyledTextCtrl::SetZoom(int zoom
) {
2069 SendMsg(2373, zoom
, 0);
2072 // Retrieve the zoom level.
2073 int wxStyledTextCtrl::GetZoom() {
2074 return SendMsg(2374, 0, 0);
2077 // Create a new document object.
2078 // Starts with reference count of 1 and not selected into editor.
2079 void* wxStyledTextCtrl::CreateDocument() {
2080 return (void*)SendMsg(2375);
2083 // Extend life of document.
2084 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2085 SendMsg(2376, 0, (long)docPointer
);
2088 // Release a reference to the document, deleting document if it fades to black.
2089 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2090 SendMsg(2377, 0, (long)docPointer
);
2093 // Get which document modification events are sent to the container.
2094 int wxStyledTextCtrl::GetModEventMask() {
2095 return SendMsg(2378, 0, 0);
2098 // Change internal focus flag.
2099 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2100 SendMsg(2380, focus
, 0);
2103 // Get internal focus flag.
2104 bool wxStyledTextCtrl::GetSTCFocus() {
2105 return SendMsg(2381, 0, 0) != 0;
2108 // Change error status - 0 = OK.
2109 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2110 SendMsg(2382, statusCode
, 0);
2113 // Get error status.
2114 int wxStyledTextCtrl::GetStatus() {
2115 return SendMsg(2383, 0, 0);
2118 // Set whether the mouse is captured when its button is pressed.
2119 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2120 SendMsg(2384, captures
, 0);
2123 // Get whether mouse gets captured.
2124 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2125 return SendMsg(2385, 0, 0) != 0;
2128 // Sets the cursor to one of the SC_CURSOR* values.
2129 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2130 SendMsg(2386, cursorType
, 0);
2134 int wxStyledTextCtrl::GetSTCCursor() {
2135 return SendMsg(2387, 0, 0);
2138 // Change the way control characters are displayed:
2139 // If symbol is < 32, keep the drawn way, else, use the given character.
2140 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2141 SendMsg(2388, symbol
, 0);
2144 // Get the way control characters are displayed.
2145 int wxStyledTextCtrl::GetControlCharSymbol() {
2146 return SendMsg(2389, 0, 0);
2149 // Move to the previous change in capitalisation.
2150 void wxStyledTextCtrl::WordPartLeft() {
2151 SendMsg(2390, 0, 0);
2154 // Move to the previous change in capitalisation extending selection
2155 // to new caret position.
2156 void wxStyledTextCtrl::WordPartLeftExtend() {
2157 SendMsg(2391, 0, 0);
2160 // Move to the change next in capitalisation.
2161 void wxStyledTextCtrl::WordPartRight() {
2162 SendMsg(2392, 0, 0);
2165 // Move to the next change in capitalisation extending selection
2166 // to new caret position.
2167 void wxStyledTextCtrl::WordPartRightExtend() {
2168 SendMsg(2393, 0, 0);
2171 // Set the way the display area is determined when a particular line
2172 // is to be moved to by Find, FindNext, GotoLine, etc.
2173 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2174 SendMsg(2394, visiblePolicy
, visibleSlop
);
2177 // Delete back from the current position to the start of the line.
2178 void wxStyledTextCtrl::DelLineLeft() {
2179 SendMsg(2395, 0, 0);
2182 // Delete forwards from the current position to the end of the line.
2183 void wxStyledTextCtrl::DelLineRight() {
2184 SendMsg(2396, 0, 0);
2187 // Get and Set the xOffset (ie, horizonal scroll position).
2188 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2189 SendMsg(2397, newOffset
, 0);
2191 int wxStyledTextCtrl::GetXOffset() {
2192 return SendMsg(2398, 0, 0);
2195 // Set the last x chosen value to be the caret x position.
2196 void wxStyledTextCtrl::ChooseCaretX() {
2197 SendMsg(2399, 0, 0);
2200 // Set the way the caret is kept visible when going sideway.
2201 // The exclusion zone is given in pixels.
2202 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2203 SendMsg(2402, caretPolicy
, caretSlop
);
2206 // Set the way the line the caret is on is kept visible.
2207 // The exclusion zone is given in lines.
2208 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2209 SendMsg(2403, caretPolicy
, caretSlop
);
2212 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2213 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2214 SendMsg(2406, mode
, 0);
2217 // Is printing line wrapped?
2218 int wxStyledTextCtrl::GetPrintWrapMode() {
2219 return SendMsg(2407, 0, 0);
2222 // Set a fore colour for active hotspots.
2223 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2224 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2227 // Set a back colour for active hotspots.
2228 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2229 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2232 // Enable / Disable underlining active hotspots.
2233 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2234 SendMsg(2412, underline
, 0);
2237 // Limit hotspots to single line so hotspots on two lines don't merge.
2238 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2239 SendMsg(2421, singleLine
, 0);
2242 // Move caret between paragraphs (delimited by empty lines).
2243 void wxStyledTextCtrl::ParaDown() {
2244 SendMsg(2413, 0, 0);
2246 void wxStyledTextCtrl::ParaDownExtend() {
2247 SendMsg(2414, 0, 0);
2249 void wxStyledTextCtrl::ParaUp() {
2250 SendMsg(2415, 0, 0);
2252 void wxStyledTextCtrl::ParaUpExtend() {
2253 SendMsg(2416, 0, 0);
2256 // Given a valid document position, return the previous position taking code
2257 // page into account. Returns 0 if passed 0.
2258 int wxStyledTextCtrl::PositionBefore(int pos
) {
2259 return SendMsg(2417, pos
, 0);
2262 // Given a valid document position, return the next position taking code
2263 // page into account. Maximum value returned is the last position in the document.
2264 int wxStyledTextCtrl::PositionAfter(int pos
) {
2265 return SendMsg(2418, pos
, 0);
2268 // Copy a range of text to the clipboard. Positions are clipped into the document.
2269 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2270 SendMsg(2419, start
, end
);
2273 // Copy argument text to the clipboard.
2274 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2275 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2278 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2279 // by lines (SC_SEL_LINES).
2280 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2281 SendMsg(2422, mode
, 0);
2284 // Get the mode of the current selection.
2285 int wxStyledTextCtrl::GetSelectionMode() {
2286 return SendMsg(2423, 0, 0);
2289 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2290 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2291 return SendMsg(2424, line
, 0);
2294 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2295 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2296 return SendMsg(2425, line
, 0);
2299 // Move caret down one line, extending rectangular selection to new caret position.
2300 void wxStyledTextCtrl::LineDownRectExtend() {
2301 SendMsg(2426, 0, 0);
2304 // Move caret up one line, extending rectangular selection to new caret position.
2305 void wxStyledTextCtrl::LineUpRectExtend() {
2306 SendMsg(2427, 0, 0);
2309 // Move caret left one character, extending rectangular selection to new caret position.
2310 void wxStyledTextCtrl::CharLeftRectExtend() {
2311 SendMsg(2428, 0, 0);
2314 // Move caret right one character, extending rectangular selection to new caret position.
2315 void wxStyledTextCtrl::CharRightRectExtend() {
2316 SendMsg(2429, 0, 0);
2319 // Move caret to first position on line, extending rectangular selection to new caret position.
2320 void wxStyledTextCtrl::HomeRectExtend() {
2321 SendMsg(2430, 0, 0);
2324 // Move caret to before first visible character on line.
2325 // If already there move to first character on line.
2326 // In either case, extend rectangular selection to new caret position.
2327 void wxStyledTextCtrl::VCHomeRectExtend() {
2328 SendMsg(2431, 0, 0);
2331 // Move caret to last position on line, extending rectangular selection to new caret position.
2332 void wxStyledTextCtrl::LineEndRectExtend() {
2333 SendMsg(2432, 0, 0);
2336 // Move caret one page up, extending rectangular selection to new caret position.
2337 void wxStyledTextCtrl::PageUpRectExtend() {
2338 SendMsg(2433, 0, 0);
2341 // Move caret one page down, extending rectangular selection to new caret position.
2342 void wxStyledTextCtrl::PageDownRectExtend() {
2343 SendMsg(2434, 0, 0);
2346 // Move caret to top of page, or one page up if already at top of page.
2347 void wxStyledTextCtrl::StutteredPageUp() {
2348 SendMsg(2435, 0, 0);
2351 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2352 void wxStyledTextCtrl::StutteredPageUpExtend() {
2353 SendMsg(2436, 0, 0);
2356 // Move caret to bottom of page, or one page down if already at bottom of page.
2357 void wxStyledTextCtrl::StutteredPageDown() {
2358 SendMsg(2437, 0, 0);
2361 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2362 void wxStyledTextCtrl::StutteredPageDownExtend() {
2363 SendMsg(2438, 0, 0);
2366 // Move caret left one word, position cursor at end of word.
2367 void wxStyledTextCtrl::WordLeftEnd() {
2368 SendMsg(2439, 0, 0);
2371 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2372 void wxStyledTextCtrl::WordLeftEndExtend() {
2373 SendMsg(2440, 0, 0);
2376 // Move caret right one word, position cursor at end of word.
2377 void wxStyledTextCtrl::WordRightEnd() {
2378 SendMsg(2441, 0, 0);
2381 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2382 void wxStyledTextCtrl::WordRightEndExtend() {
2383 SendMsg(2442, 0, 0);
2386 // Set the set of characters making up whitespace for when moving or selecting by word.
2387 // Should be called after SetWordChars.
2388 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2389 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2392 // Reset the set of characters for whitespace and word characters to the defaults.
2393 void wxStyledTextCtrl::SetCharsDefault() {
2394 SendMsg(2444, 0, 0);
2397 // Get currently selected item position in the auto-completion list
2398 int wxStyledTextCtrl::AutoCompGetCurrent() {
2399 return SendMsg(2445, 0, 0);
2402 // Enlarge the document to a particular size of text bytes.
2403 void wxStyledTextCtrl::Allocate(int bytes
) {
2404 SendMsg(2446, bytes
, 0);
2407 // Start notifying the container of all key presses and commands.
2408 void wxStyledTextCtrl::StartRecord() {
2409 SendMsg(3001, 0, 0);
2412 // Stop notifying the container of all key presses and commands.
2413 void wxStyledTextCtrl::StopRecord() {
2414 SendMsg(3002, 0, 0);
2417 // Set the lexing language of the document.
2418 void wxStyledTextCtrl::SetLexer(int lexer
) {
2419 SendMsg(4001, lexer
, 0);
2422 // Retrieve the lexing language of the document.
2423 int wxStyledTextCtrl::GetLexer() {
2424 return SendMsg(4002, 0, 0);
2427 // Colourise a segment of the document using the current lexing language.
2428 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2429 SendMsg(4003, start
, end
);
2432 // Set up a value that may be used by a lexer for some optional feature.
2433 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2434 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2437 // Set up the key words used by the lexer.
2438 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2439 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2442 // Set the lexing language of the document based on string name.
2443 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2444 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2447 // END of generated section
2448 //----------------------------------------------------------------------
2451 // Returns the line number of the line with the caret.
2452 int wxStyledTextCtrl::GetCurrentLine() {
2453 int line
= LineFromPosition(GetCurrentPos());
2458 // Extract style settings from a spec-string which is composed of one or
2459 // more of the following comma separated elements:
2461 // bold turns on bold
2462 // italic turns on italics
2463 // fore:[name or #RRGGBB] sets the foreground colour
2464 // back:[name or #RRGGBB] sets the background colour
2465 // face:[facename] sets the font face name to use
2466 // size:[num] sets the font size in points
2467 // eol turns on eol filling
2468 // underline turns on underlining
2470 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2472 wxStringTokenizer
tkz(spec
, wxT(","));
2473 while (tkz
.HasMoreTokens()) {
2474 wxString token
= tkz
.GetNextToken();
2476 wxString option
= token
.BeforeFirst(':');
2477 wxString val
= token
.AfterFirst(':');
2479 if (option
== wxT("bold"))
2480 StyleSetBold(styleNum
, true);
2482 else if (option
== wxT("italic"))
2483 StyleSetItalic(styleNum
, true);
2485 else if (option
== wxT("underline"))
2486 StyleSetUnderline(styleNum
, true);
2488 else if (option
== wxT("eol"))
2489 StyleSetEOLFilled(styleNum
, true);
2491 else if (option
== wxT("size")) {
2493 if (val
.ToLong(&points
))
2494 StyleSetSize(styleNum
, points
);
2497 else if (option
== wxT("face"))
2498 StyleSetFaceName(styleNum
, val
);
2500 else if (option
== wxT("fore"))
2501 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2503 else if (option
== wxT("back"))
2504 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2509 // Set style size, face, bold, italic, and underline attributes from
2510 // a wxFont's attributes.
2511 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2513 // Ensure that the native font is initialized
2515 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2517 int size
= font
.GetPointSize();
2518 wxString faceName
= font
.GetFaceName();
2519 bool bold
= font
.GetWeight() == wxBOLD
;
2520 bool italic
= font
.GetStyle() != wxNORMAL
;
2521 bool under
= font
.GetUnderlined();
2523 // TODO: add encoding/charset mapping
2524 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
2527 // Set all font style attributes at once.
2528 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2529 const wxString
& faceName
,
2530 bool bold
, bool italic
,
2532 StyleSetSize(styleNum
, size
);
2533 StyleSetFaceName(styleNum
, faceName
);
2534 StyleSetBold(styleNum
, bold
);
2535 StyleSetItalic(styleNum
, italic
);
2536 StyleSetUnderline(styleNum
, underline
);
2538 // TODO: add encoding/charset mapping
2542 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2543 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2548 // Set the left and right margin in the edit area, measured in pixels.
2549 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2550 SetMarginLeft(left
);
2551 SetMarginRight(right
);
2555 // Retrieve the start and end positions of the current selection.
2556 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2557 if (startPos
!= NULL
)
2558 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2560 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2564 // Retrieve the point in the window where a position is displayed.
2565 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2566 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2567 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2568 return wxPoint(x
, y
);
2571 // Scroll enough to make the given line visible
2572 void wxStyledTextCtrl::ScrollToLine(int line
) {
2573 m_swx
->DoScrollToLine(line
);
2577 // Scroll enough to make the given column visible
2578 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2579 m_swx
->DoScrollToColumn(column
);
2583 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2585 wxFile
file(filename
, wxFile::write
);
2587 if (!file
.IsOpened())
2590 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2598 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2600 bool success
= false;
2601 wxFile
file(filename
, wxFile::read
);
2603 if (file
.IsOpened())
2606 size_t len
= (size_t)file
.Length();
2610 wxMemoryBuffer
buffer(len
+1);
2611 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2613 ((char*)buffer
.GetData())[len
] = 0;
2614 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2618 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2623 success
= true; // empty file is ok
2637 #if wxUSE_DRAG_AND_DROP
2638 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2639 return m_swx
->DoDragOver(x
, y
, def
);
2643 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2644 return m_swx
->DoDropText(x
, y
, data
);
2649 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2650 m_swx
->SetUseAntiAliasing(useAA
);
2653 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2654 return m_swx
->GetUseAntiAliasing();
2657 //----------------------------------------------------------------------
2660 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
2662 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
2665 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
2666 if (evt
.GetOrientation() == wxHORIZONTAL
)
2667 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2669 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2672 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
2673 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
2675 if (sb
->IsVertical())
2676 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2678 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2682 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
2684 wxSize sz
= GetClientSize();
2685 m_swx
->DoSize(sz
.x
, sz
.y
);
2689 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
2691 wxPoint pt
= evt
.GetPosition();
2692 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2693 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
2696 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
2697 wxPoint pt
= evt
.GetPosition();
2698 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
2701 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
2702 wxPoint pt
= evt
.GetPosition();
2703 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2708 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
2709 wxPoint pt
= evt
.GetPosition();
2710 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2714 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
2715 wxPoint pt
= evt
.GetPosition();
2716 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
2719 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
2720 wxPoint pt
= evt
.GetPosition();
2721 ScreenToClient(&pt
.x
, &pt
.y
);
2723 Show context menu at event point if it's within the window,
2724 or at caret location if not
2726 wxHitTest ht
= this->HitTest(pt
);
2727 if (ht
!= wxHT_WINDOW_INSIDE
) {
2728 pt
= this->PointFromPosition(this->GetCurrentPos());
2730 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2734 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
2735 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
2736 evt
.GetWheelDelta(),
2737 evt
.GetLinesPerAction(),
2739 evt
.IsPageScroll());
2743 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
2744 // On (some?) non-US keyboards the AltGr key is required to enter some
2745 // common characters. It comes to us as both Alt and Ctrl down so we need
2746 // to let the char through in that case, otherwise if only ctrl or only
2747 // alt let's skip it.
2748 bool ctrl
= evt
.ControlDown();
2750 // On the Mac the Alt key is just a modifier key (like Shift) so we need
2751 // to allow the char events to be processed when Alt is pressed.
2752 // TODO: Should we check MetaDown instead in this case?
2755 bool alt
= evt
.AltDown();
2757 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
2759 int key
= evt
.GetKeyCode();
2761 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
2762 // key, m_lastKeyDownConsumed, ctrl, alt, skip);
2764 if ( (key
<= WXK_START
|| key
> WXK_COMMAND
) &&
2765 !m_lastKeyDownConsumed
&& !skip
) {
2766 m_swx
->DoAddChar(key
);
2773 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
2774 int key
= evt
.GetKeyCode();
2775 bool shift
= evt
.ShiftDown(),
2776 ctrl
= evt
.ControlDown(),
2777 alt
= evt
.AltDown(),
2778 meta
= evt
.MetaDown();
2780 int processed
= m_swx
->DoKeyDown(key
, shift
, ctrl
, alt
, meta
, &m_lastKeyDownConsumed
);
2782 // printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
2783 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
2785 if (!processed
&& !m_lastKeyDownConsumed
)
2790 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
2791 m_swx
->DoLoseFocus();
2796 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
2797 m_swx
->DoGainFocus();
2802 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
2803 m_swx
->DoSysColourChange();
2807 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
2808 // do nothing to help avoid flashing
2813 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
2814 m_swx
->DoCommand(evt
.GetId());
2818 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
2819 m_swx
->DoOnListBox();
2823 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
2824 m_swx
->DoOnIdle(evt
);
2828 wxSize
wxStyledTextCtrl::DoGetBestSize() const
2830 // What would be the best size for a wxSTC?
2831 // Just give a reasonable minimum until something else can be figured out.
2832 return wxSize(200,100);
2836 //----------------------------------------------------------------------
2837 // Turn notifications from Scintilla into events
2840 void wxStyledTextCtrl::NotifyChange() {
2841 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
2842 evt
.SetEventObject(this);
2843 GetEventHandler()->ProcessEvent(evt
);
2847 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
2851 // The unicode conversion MUST have a null byte to terminate the
2852 // string so move it into a buffer first and give it one.
2853 wxMemoryBuffer
buf(length
+1);
2854 buf
.AppendData((void*)text
, length
);
2856 evt
.SetText(stc2wx(buf
));
2860 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
2861 SCNotification
& scn
= *_scn
;
2862 wxStyledTextEvent
evt(0, GetId());
2864 evt
.SetEventObject(this);
2865 evt
.SetPosition(scn
.position
);
2867 evt
.SetModifiers(scn
.modifiers
);
2869 switch (scn
.nmhdr
.code
) {
2870 case SCN_STYLENEEDED
:
2871 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
2875 evt
.SetEventType(wxEVT_STC_CHARADDED
);
2878 case SCN_SAVEPOINTREACHED
:
2879 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
2882 case SCN_SAVEPOINTLEFT
:
2883 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
2886 case SCN_MODIFYATTEMPTRO
:
2887 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
2891 evt
.SetEventType(wxEVT_STC_KEY
);
2894 case SCN_DOUBLECLICK
:
2895 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
2899 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
2903 evt
.SetEventType(wxEVT_STC_MODIFIED
);
2904 evt
.SetModificationType(scn
.modificationType
);
2905 SetEventText(evt
, scn
.text
, scn
.length
);
2906 evt
.SetLength(scn
.length
);
2907 evt
.SetLinesAdded(scn
.linesAdded
);
2908 evt
.SetLine(scn
.line
);
2909 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
2910 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
2913 case SCN_MACRORECORD
:
2914 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
2915 evt
.SetMessage(scn
.message
);
2916 evt
.SetWParam(scn
.wParam
);
2917 evt
.SetLParam(scn
.lParam
);
2920 case SCN_MARGINCLICK
:
2921 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
2922 evt
.SetMargin(scn
.margin
);
2926 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
2927 evt
.SetLength(scn
.length
);
2931 evt
.SetEventType(wxEVT_STC_PAINTED
);
2934 case SCN_USERLISTSELECTION
:
2935 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
2936 evt
.SetListType(scn
.listType
);
2937 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2940 case SCN_URIDROPPED
:
2941 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
2942 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2945 case SCN_DWELLSTART
:
2946 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
2952 evt
.SetEventType(wxEVT_STC_DWELLEND
);
2958 evt
.SetEventType(wxEVT_STC_ZOOM
);
2961 case SCN_HOTSPOTCLICK
:
2962 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
2965 case SCN_HOTSPOTDOUBLECLICK
:
2966 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
2969 case SCN_CALLTIPCLICK
:
2970 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
2977 GetEventHandler()->ProcessEvent(evt
);
2981 //----------------------------------------------------------------------
2982 //----------------------------------------------------------------------
2983 //----------------------------------------------------------------------
2985 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
2986 : wxCommandEvent(commandType
, id
)
2991 m_modificationType
= 0;
2996 m_foldLevelPrev
= 0;
3004 m_dragAllowMove
= false;
3005 #if wxUSE_DRAG_AND_DROP
3006 m_dragResult
= wxDragNone
;
3010 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
3011 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
3012 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
3015 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
3016 wxCommandEvent(event
)
3018 m_position
= event
.m_position
;
3019 m_key
= event
.m_key
;
3020 m_modifiers
= event
.m_modifiers
;
3021 m_modificationType
= event
.m_modificationType
;
3022 m_text
= event
.m_text
;
3023 m_length
= event
.m_length
;
3024 m_linesAdded
= event
.m_linesAdded
;
3025 m_line
= event
.m_line
;
3026 m_foldLevelNow
= event
.m_foldLevelNow
;
3027 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3029 m_margin
= event
.m_margin
;
3031 m_message
= event
.m_message
;
3032 m_wParam
= event
.m_wParam
;
3033 m_lParam
= event
.m_lParam
;
3035 m_listType
= event
.m_listType
;
3039 m_dragText
= event
.m_dragText
;
3040 m_dragAllowMove
=event
.m_dragAllowMove
;
3041 #if wxUSE_DRAG_AND_DROP
3042 m_dragResult
= event
.m_dragResult
;
3046 //----------------------------------------------------------------------
3047 //----------------------------------------------------------------------