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((unsigned char)(c
& 0xff),
50 (unsigned char)((c
>> 8) & 0xff),
51 (unsigned char)((c
>> 16) & 0xff));
56 static wxColour
wxColourFromSpec(const wxString
& spec
) {
57 // spec should be a colour name or "#RRGGBB"
58 if (spec
.GetChar(0) == wxT('#')) {
60 long red
, green
, blue
;
61 red
= green
= blue
= 0;
62 spec
.Mid(1,2).ToLong(&red
, 16);
63 spec
.Mid(3,2).ToLong(&green
, 16);
64 spec
.Mid(5,2).ToLong(&blue
, 16);
65 return wxColour((unsigned char)red
,
70 return wxColour(spec
);
73 //----------------------------------------------------------------------
75 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
76 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
77 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
78 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED
)
79 DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT
)
80 DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT
)
81 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
82 DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK
)
83 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
84 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
85 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
86 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
87 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
88 DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED
)
89 DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION
)
90 DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED
)
91 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART
)
92 DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND
)
93 DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG
)
94 DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER
)
95 DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP
)
96 DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM
)
97 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK
)
98 DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK
)
99 DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK
)
103 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
104 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
105 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
106 EVT_SCROLL (wxStyledTextCtrl::OnScroll
)
107 EVT_SIZE (wxStyledTextCtrl::OnSize
)
108 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
109 // Let Scintilla see the double click as a second click
110 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
111 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
112 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
113 #if defined(__WXGTK__) || defined(__WXMAC__)
114 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
116 EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu
)
118 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
119 EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp
)
120 EVT_CHAR (wxStyledTextCtrl::OnChar
)
121 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
122 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
123 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
124 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
125 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
126 EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu
)
127 EVT_LISTBOX_DCLICK (wxID_ANY
, wxStyledTextCtrl::OnListBox
)
131 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
132 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
135 // forces the linking of the lexer modules
136 int Scintilla_LinkLexers();
139 //----------------------------------------------------------------------
140 // Constructor and Destructor
142 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
147 const wxString
& name
)
150 Create(parent
, id
, pos
, size
, style
, name
);
154 void wxStyledTextCtrl::Create(wxWindow
*parent
,
159 const wxString
& name
)
162 style
|= wxVSCROLL
| wxHSCROLL
;
164 wxControl::Create(parent
, id
, pos
, size
,
165 style
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
166 wxDefaultValidator
, name
);
169 Scintilla_LinkLexers();
171 m_swx
= new ScintillaWX(this);
173 m_lastKeyDownConsumed
= false;
177 // Put Scintilla into unicode (UTF-8) mode
178 SetCodePage(wxSTC_CP_UTF8
);
181 // Reduces flicker on GTK+/X11
182 SetBackgroundStyle(wxBG_STYLE_CUSTOM
);
183 SetBestFittingSize(size
);
187 wxStyledTextCtrl::~wxStyledTextCtrl() {
192 //----------------------------------------------------------------------
194 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
196 return m_swx
->WndProc(msg
, wp
, lp
);
199 //----------------------------------------------------------------------
201 // Set the vertical scrollbar to use instead of the ont that's built-in.
202 void wxStyledTextCtrl::SetVScrollBar(wxScrollBar
* bar
) {
205 // ensure that the built-in scrollbar is not visible
206 SetScrollbar(wxVERTICAL
, 0, 0, 0);
211 // Set the horizontal scrollbar to use instead of the ont that's built-in.
212 void wxStyledTextCtrl::SetHScrollBar(wxScrollBar
* bar
) {
215 // ensure that the built-in scrollbar is not visible
216 SetScrollbar(wxHORIZONTAL
, 0, 0, 0);
220 //----------------------------------------------------------------------
221 // BEGIN generated section. The following code is automatically generated
222 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
223 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
226 // Add text to the document at current position.
227 void wxStyledTextCtrl::AddText(const wxString
& text
) {
228 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
229 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
232 // Add array of cells to document.
233 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
234 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
237 // Insert string at a position.
238 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
239 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
242 // Delete all text in the document.
243 void wxStyledTextCtrl::ClearAll() {
247 // Set all style bytes to 0, remove all folding information.
248 void wxStyledTextCtrl::ClearDocumentStyle() {
252 // Returns the number of characters in the document.
253 int wxStyledTextCtrl::GetLength() {
254 return SendMsg(2006, 0, 0);
257 // Returns the character byte at the position.
258 int wxStyledTextCtrl::GetCharAt(int pos
) {
259 return (unsigned char)SendMsg(2007, pos
, 0);
262 // Returns the position of the caret.
263 int wxStyledTextCtrl::GetCurrentPos() {
264 return SendMsg(2008, 0, 0);
267 // Returns the position of the opposite end of the selection to the caret.
268 int wxStyledTextCtrl::GetAnchor() {
269 return SendMsg(2009, 0, 0);
272 // Returns the style byte at the position.
273 int wxStyledTextCtrl::GetStyleAt(int pos
) {
274 return (unsigned char)SendMsg(2010, pos
, 0);
277 // Redoes the next action on the undo history.
278 void wxStyledTextCtrl::Redo() {
282 // Choose between collecting actions into the undo
283 // history and discarding them.
284 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
285 SendMsg(2012, collectUndo
, 0);
288 // Select all the text in the document.
289 void wxStyledTextCtrl::SelectAll() {
293 // Remember the current position in the undo history as the position
294 // at which the document was saved.
295 void wxStyledTextCtrl::SetSavePoint() {
299 // Retrieve a buffer of cells.
300 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
302 if (endPos
< startPos
) {
307 int len
= endPos
- startPos
;
308 if (!len
) return buf
;
310 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
311 tr
.chrg
.cpMin
= startPos
;
312 tr
.chrg
.cpMax
= endPos
;
313 len
= SendMsg(2015, 0, (long)&tr
);
314 buf
.UngetWriteBuf(len
);
318 // Are there any redoable actions in the undo history?
319 bool wxStyledTextCtrl::CanRedo() {
320 return SendMsg(2016, 0, 0) != 0;
323 // Retrieve the line number at which a particular marker is located.
324 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
325 return SendMsg(2017, handle
, 0);
329 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
330 SendMsg(2018, handle
, 0);
333 // Is undo history being collected?
334 bool wxStyledTextCtrl::GetUndoCollection() {
335 return SendMsg(2019, 0, 0) != 0;
338 // Are white space characters currently visible?
339 // Returns one of SCWS_* constants.
340 int wxStyledTextCtrl::GetViewWhiteSpace() {
341 return SendMsg(2020, 0, 0);
344 // Make white space characters invisible, always visible or visible outside indentation.
345 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
346 SendMsg(2021, viewWS
, 0);
349 // Find the position from a point within the window.
350 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
351 return SendMsg(2022, pt
.x
, pt
.y
);
354 // Find the position from a point within the window but return
355 // INVALID_POSITION if not close to text.
356 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
357 return SendMsg(2023, x
, y
);
360 // Set caret to start of a line and ensure it is visible.
361 void wxStyledTextCtrl::GotoLine(int line
) {
362 SendMsg(2024, line
, 0);
365 // Set caret to a position and ensure it is visible.
366 void wxStyledTextCtrl::GotoPos(int pos
) {
367 SendMsg(2025, pos
, 0);
370 // Set the selection anchor to a position. The anchor is the opposite
371 // end of the selection from the caret.
372 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
373 SendMsg(2026, posAnchor
, 0);
376 // Retrieve the text of the line containing the caret.
377 // Returns the index of the caret on the line.
378 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
379 int len
= LineLength(GetCurrentLine());
381 if (linePos
) *linePos
= 0;
382 return wxEmptyString
;
385 wxMemoryBuffer
mbuf(len
+1);
386 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
388 int pos
= SendMsg(2027, len
+1, (long)buf
);
389 mbuf
.UngetWriteBuf(len
);
391 if (linePos
) *linePos
= pos
;
395 // Retrieve the position of the last correctly styled character.
396 int wxStyledTextCtrl::GetEndStyled() {
397 return SendMsg(2028, 0, 0);
400 // Convert all line endings in the document to one mode.
401 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
402 SendMsg(2029, eolMode
, 0);
405 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
406 int wxStyledTextCtrl::GetEOLMode() {
407 return SendMsg(2030, 0, 0);
410 // Set the current end of line mode.
411 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
412 SendMsg(2031, eolMode
, 0);
415 // Set the current styling position to pos and the styling mask to mask.
416 // The styling mask can be used to protect some bits in each styling byte from modification.
417 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
418 SendMsg(2032, pos
, mask
);
421 // Change style from current styling position for length characters to a style
422 // and move the current styling position to after this newly styled segment.
423 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
424 SendMsg(2033, length
, style
);
427 // Is drawing done first into a buffer or direct to the screen?
428 bool wxStyledTextCtrl::GetBufferedDraw() {
429 return SendMsg(2034, 0, 0) != 0;
432 // If drawing is buffered then each line of text is drawn into a bitmap buffer
433 // before drawing it to the screen to avoid flicker.
434 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
435 SendMsg(2035, buffered
, 0);
438 // Change the visible size of a tab to be a multiple of the width of a space character.
439 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
440 SendMsg(2036, tabWidth
, 0);
443 // Retrieve the visible size of a tab.
444 int wxStyledTextCtrl::GetTabWidth() {
445 return SendMsg(2121, 0, 0);
448 // Set the code page used to interpret the bytes of the document as characters.
449 void wxStyledTextCtrl::SetCodePage(int codePage
) {
451 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
452 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
454 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
455 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
457 SendMsg(2037, codePage
);
460 // Set the symbol used for a particular marker number,
461 // and optionally the fore and background colours.
462 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
463 const wxColour
& foreground
,
464 const wxColour
& background
) {
466 SendMsg(2040, markerNumber
, markerSymbol
);
468 MarkerSetForeground(markerNumber
, foreground
);
470 MarkerSetBackground(markerNumber
, background
);
473 // Set the foreground colour used for a particular marker number.
474 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
475 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
478 // Set the background colour used for a particular marker number.
479 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
480 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
483 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
484 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
485 return SendMsg(2043, line
, markerNumber
);
488 // Delete a marker from a line.
489 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
490 SendMsg(2044, line
, markerNumber
);
493 // Delete all markers with a particular number from all lines.
494 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
495 SendMsg(2045, markerNumber
, 0);
498 // Get a bit mask of all the markers set on a line.
499 int wxStyledTextCtrl::MarkerGet(int line
) {
500 return SendMsg(2046, line
, 0);
503 // Find the next line after lineStart that includes a marker in mask.
504 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
505 return SendMsg(2047, lineStart
, markerMask
);
508 // Find the previous line before lineStart that includes a marker in mask.
509 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
510 return SendMsg(2048, lineStart
, markerMask
);
513 // Define a marker from a bitmap
514 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
515 // convert bmp to a xpm in a string
516 wxMemoryOutputStream strm
;
517 wxImage img
= bmp
.ConvertToImage();
518 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
519 size_t len
= strm
.GetSize();
520 char* buff
= new char[len
+1];
521 strm
.CopyTo(buff
, len
);
523 SendMsg(2049, markerNumber
, (long)buff
);
528 // Set a margin to be either numeric or symbolic.
529 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
530 SendMsg(2240, margin
, marginType
);
533 // Retrieve the type of a margin.
534 int wxStyledTextCtrl::GetMarginType(int margin
) {
535 return SendMsg(2241, margin
, 0);
538 // Set the width of a margin to a width expressed in pixels.
539 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
540 SendMsg(2242, margin
, pixelWidth
);
543 // Retrieve the width of a margin in pixels.
544 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
545 return SendMsg(2243, margin
, 0);
548 // Set a mask that determines which markers are displayed in a margin.
549 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
550 SendMsg(2244, margin
, mask
);
553 // Retrieve the marker mask of a margin.
554 int wxStyledTextCtrl::GetMarginMask(int margin
) {
555 return SendMsg(2245, margin
, 0);
558 // Make a margin sensitive or insensitive to mouse clicks.
559 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
560 SendMsg(2246, margin
, sensitive
);
563 // Retrieve the mouse click sensitivity of a margin.
564 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
565 return SendMsg(2247, margin
, 0) != 0;
568 // Clear all the styles and make equivalent to the global default style.
569 void wxStyledTextCtrl::StyleClearAll() {
573 // Set the foreground colour of a style.
574 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
575 SendMsg(2051, style
, wxColourAsLong(fore
));
578 // Set the background colour of a style.
579 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
580 SendMsg(2052, style
, wxColourAsLong(back
));
583 // Set a style to be bold or not.
584 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
585 SendMsg(2053, style
, bold
);
588 // Set a style to be italic or not.
589 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
590 SendMsg(2054, style
, italic
);
593 // Set the size of characters of a style.
594 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
595 SendMsg(2055, style
, sizePoints
);
598 // Set the font of a style.
599 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
600 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
603 // Set a style to have its end of line filled or not.
604 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
605 SendMsg(2057, style
, filled
);
608 // Reset the default style to its state at startup
609 void wxStyledTextCtrl::StyleResetDefault() {
613 // Set a style to be underlined or not.
614 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
615 SendMsg(2059, style
, underline
);
618 // Set a style to be mixed case, or to force upper or lower case.
619 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
620 SendMsg(2060, style
, caseForce
);
623 // Set the character set of the font in a style.
624 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
) {
625 SendMsg(2066, style
, characterSet
);
628 // Set a style to be a hotspot or not.
629 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
630 SendMsg(2409, style
, hotspot
);
633 // Set the foreground colour of the selection and whether to use this setting.
634 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
635 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
638 // Set the background colour of the selection and whether to use this setting.
639 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
640 SendMsg(2068, useSetting
, wxColourAsLong(back
));
643 // Set the foreground colour of the caret.
644 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
645 SendMsg(2069, wxColourAsLong(fore
), 0);
648 // When key+modifier combination km is pressed perform msg.
649 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
650 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
653 // When key+modifier combination km is pressed do nothing.
654 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
655 SendMsg(2071, MAKELONG(key
, modifiers
));
658 // Drop all key mappings.
659 void wxStyledTextCtrl::CmdKeyClearAll() {
663 // Set the styles for a segment of the document.
664 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
665 SendMsg(2073, length
, (long)styleBytes
);
668 // Set a style to be visible or not.
669 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
670 SendMsg(2074, style
, visible
);
673 // Get the time in milliseconds that the caret is on and off.
674 int wxStyledTextCtrl::GetCaretPeriod() {
675 return SendMsg(2075, 0, 0);
678 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
679 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
680 SendMsg(2076, periodMilliseconds
, 0);
683 // Set the set of characters making up words for when moving or selecting by word.
684 // First sets deaults like SetCharsDefault.
685 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
686 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
689 // Start a sequence of actions that is undone and redone as a unit.
691 void wxStyledTextCtrl::BeginUndoAction() {
695 // End a sequence of actions that is undone and redone as a unit.
696 void wxStyledTextCtrl::EndUndoAction() {
700 // Set an indicator to plain, squiggle or TT.
701 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
702 SendMsg(2080, indic
, style
);
705 // Retrieve the style of an indicator.
706 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
707 return SendMsg(2081, indic
, 0);
710 // Set the foreground colour of an indicator.
711 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
712 SendMsg(2082, indic
, wxColourAsLong(fore
));
715 // Retrieve the foreground colour of an indicator.
716 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
717 long c
= SendMsg(2083, indic
, 0);
718 return wxColourFromLong(c
);
721 // Set the foreground colour of all whitespace and whether to use this setting.
722 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
723 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
726 // Set the background colour of all whitespace and whether to use this setting.
727 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
728 SendMsg(2085, useSetting
, wxColourAsLong(back
));
731 // Divide each styling byte into lexical class bits (default: 5) and indicator
732 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
733 // is used to expand the possible states.
734 void wxStyledTextCtrl::SetStyleBits(int bits
) {
735 SendMsg(2090, bits
, 0);
738 // Retrieve number of bits in style bytes used to hold the lexical state.
739 int wxStyledTextCtrl::GetStyleBits() {
740 return SendMsg(2091, 0, 0);
743 // Used to hold extra styling information for each line.
744 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
745 SendMsg(2092, line
, state
);
748 // Retrieve the extra styling information for a line.
749 int wxStyledTextCtrl::GetLineState(int line
) {
750 return SendMsg(2093, line
, 0);
753 // Retrieve the last line number that has line state.
754 int wxStyledTextCtrl::GetMaxLineState() {
755 return SendMsg(2094, 0, 0);
758 // Is the background of the line containing the caret in a different colour?
759 bool wxStyledTextCtrl::GetCaretLineVisible() {
760 return SendMsg(2095, 0, 0) != 0;
763 // Display the background of the line containing the caret in a different colour.
764 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
765 SendMsg(2096, show
, 0);
768 // Get the colour of the background of the line containing the caret.
769 wxColour
wxStyledTextCtrl::GetCaretLineBack() {
770 long c
= SendMsg(2097, 0, 0);
771 return wxColourFromLong(c
);
774 // Set the colour of the background of the line containing the caret.
775 void wxStyledTextCtrl::SetCaretLineBack(const wxColour
& back
) {
776 SendMsg(2098, wxColourAsLong(back
), 0);
779 // Set a style to be changeable or not (read only).
780 // Experimental feature, currently buggy.
781 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
782 SendMsg(2099, style
, changeable
);
785 // Display a auto-completion list.
786 // The lenEntered parameter indicates how many characters before
787 // the caret should be used to provide context.
788 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
789 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
792 // Remove the auto-completion list from the screen.
793 void wxStyledTextCtrl::AutoCompCancel() {
797 // Is there an auto-completion list visible?
798 bool wxStyledTextCtrl::AutoCompActive() {
799 return SendMsg(2102, 0, 0) != 0;
802 // Retrieve the position of the caret when the auto-completion list was displayed.
803 int wxStyledTextCtrl::AutoCompPosStart() {
804 return SendMsg(2103, 0, 0);
807 // User has selected an item so remove the list and insert the selection.
808 void wxStyledTextCtrl::AutoCompComplete() {
812 // Define a set of character that when typed cancel the auto-completion list.
813 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
814 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
817 // Change the separator character in the string setting up an auto-completion list.
818 // Default is space but can be changed if items contain space.
819 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
820 SendMsg(2106, separatorCharacter
, 0);
823 // Retrieve the auto-completion list separator character.
824 int wxStyledTextCtrl::AutoCompGetSeparator() {
825 return SendMsg(2107, 0, 0);
828 // Select the item in the auto-completion list that starts with a string.
829 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
830 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
833 // Should the auto-completion list be cancelled if the user backspaces to a
834 // position before where the box was created.
835 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
836 SendMsg(2110, cancel
, 0);
839 // Retrieve whether auto-completion cancelled by backspacing before start.
840 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
841 return SendMsg(2111, 0, 0) != 0;
844 // Define a set of characters that when typed will cause the autocompletion to
845 // choose the selected item.
846 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
847 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
850 // Should a single item auto-completion list automatically choose the item.
851 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
852 SendMsg(2113, chooseSingle
, 0);
855 // Retrieve whether a single item auto-completion list automatically choose the item.
856 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
857 return SendMsg(2114, 0, 0) != 0;
860 // Set whether case is significant when performing auto-completion searches.
861 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
862 SendMsg(2115, ignoreCase
, 0);
865 // Retrieve state of ignore case flag.
866 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
867 return SendMsg(2116, 0, 0) != 0;
870 // Display a list of strings and send notification when user chooses one.
871 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
872 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
875 // Set whether or not autocompletion is hidden automatically when nothing matches.
876 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
877 SendMsg(2118, autoHide
, 0);
880 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
881 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
882 return SendMsg(2119, 0, 0) != 0;
885 // Set whether or not autocompletion deletes any word characters
886 // after the inserted text upon completion.
887 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
888 SendMsg(2270, dropRestOfWord
, 0);
891 // Retrieve whether or not autocompletion deletes any word characters
892 // after the inserted text upon completion.
893 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
894 return SendMsg(2271, 0, 0) != 0;
897 // Register an image for use in autocompletion lists.
898 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
899 // convert bmp to a xpm in a string
900 wxMemoryOutputStream strm
;
901 wxImage img
= bmp
.ConvertToImage();
902 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
903 size_t len
= strm
.GetSize();
904 char* buff
= new char[len
+1];
905 strm
.CopyTo(buff
, len
);
907 SendMsg(2405, type
, (long)buff
);
912 // Clear all the registered images.
913 void wxStyledTextCtrl::ClearRegisteredImages() {
917 // Retrieve the auto-completion list type-separator character.
918 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
919 return SendMsg(2285, 0, 0);
922 // Change the type-separator character in the string setting up an auto-completion list.
923 // Default is '?' but can be changed if items contain '?'.
924 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
925 SendMsg(2286, separatorCharacter
, 0);
928 // Set the number of spaces used for one level of indentation.
929 void wxStyledTextCtrl::SetIndent(int indentSize
) {
930 SendMsg(2122, indentSize
, 0);
933 // Retrieve indentation size.
934 int wxStyledTextCtrl::GetIndent() {
935 return SendMsg(2123, 0, 0);
938 // Indentation will only use space characters if useTabs is false, otherwise
939 // it will use a combination of tabs and spaces.
940 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
941 SendMsg(2124, useTabs
, 0);
944 // Retrieve whether tabs will be used in indentation.
945 bool wxStyledTextCtrl::GetUseTabs() {
946 return SendMsg(2125, 0, 0) != 0;
949 // Change the indentation of a line to a number of columns.
950 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
951 SendMsg(2126, line
, indentSize
);
954 // Retrieve the number of columns that a line is indented.
955 int wxStyledTextCtrl::GetLineIndentation(int line
) {
956 return SendMsg(2127, line
, 0);
959 // Retrieve the position before the first non indentation character on a line.
960 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
961 return SendMsg(2128, line
, 0);
964 // Retrieve the column number of a position, taking tab width into account.
965 int wxStyledTextCtrl::GetColumn(int pos
) {
966 return SendMsg(2129, pos
, 0);
969 // Show or hide the horizontal scroll bar.
970 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
971 SendMsg(2130, show
, 0);
974 // Is the horizontal scroll bar visible?
975 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
976 return SendMsg(2131, 0, 0) != 0;
979 // Show or hide indentation guides.
980 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
981 SendMsg(2132, show
, 0);
984 // Are the indentation guides visible?
985 bool wxStyledTextCtrl::GetIndentationGuides() {
986 return SendMsg(2133, 0, 0) != 0;
989 // Set the highlighted indentation guide column.
990 // 0 = no highlighted guide.
991 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
992 SendMsg(2134, column
, 0);
995 // Get the highlighted indentation guide column.
996 int wxStyledTextCtrl::GetHighlightGuide() {
997 return SendMsg(2135, 0, 0);
1000 // Get the position after the last visible characters on a line.
1001 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
1002 return SendMsg(2136, line
, 0);
1005 // Get the code page used to interpret the bytes of the document as characters.
1006 int wxStyledTextCtrl::GetCodePage() {
1007 return SendMsg(2137, 0, 0);
1010 // Get the foreground colour of the caret.
1011 wxColour
wxStyledTextCtrl::GetCaretForeground() {
1012 long c
= SendMsg(2138, 0, 0);
1013 return wxColourFromLong(c
);
1016 // In read-only mode?
1017 bool wxStyledTextCtrl::GetReadOnly() {
1018 return SendMsg(2140, 0, 0) != 0;
1021 // Sets the position of the caret.
1022 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
1023 SendMsg(2141, pos
, 0);
1026 // Sets the position that starts the selection - this becomes the anchor.
1027 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1028 SendMsg(2142, pos
, 0);
1031 // Returns the position at the start of the selection.
1032 int wxStyledTextCtrl::GetSelectionStart() {
1033 return SendMsg(2143, 0, 0);
1036 // Sets the position that ends the selection - this becomes the currentPosition.
1037 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1038 SendMsg(2144, pos
, 0);
1041 // Returns the position at the end of the selection.
1042 int wxStyledTextCtrl::GetSelectionEnd() {
1043 return SendMsg(2145, 0, 0);
1046 // Sets the print magnification added to the point size of each style for printing.
1047 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1048 SendMsg(2146, magnification
, 0);
1051 // Returns the print magnification.
1052 int wxStyledTextCtrl::GetPrintMagnification() {
1053 return SendMsg(2147, 0, 0);
1056 // Modify colours when printing for clearer printed text.
1057 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1058 SendMsg(2148, mode
, 0);
1061 // Returns the print colour mode.
1062 int wxStyledTextCtrl::GetPrintColourMode() {
1063 return SendMsg(2149, 0, 0);
1066 // Find some text in the document.
1067 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1068 const wxString
& text
,
1071 ft
.chrg
.cpMin
= minPos
;
1072 ft
.chrg
.cpMax
= maxPos
;
1073 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1074 ft
.lpstrText
= (char*)(const char*)buf
;
1076 return SendMsg(2150, flags
, (long)&ft
);
1079 // On Windows, will draw the document into a display context such as a printer.
1080 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1089 if (endPos
< startPos
) {
1090 int temp
= startPos
;
1095 fr
.hdcTarget
= target
;
1096 fr
.rc
.top
= renderRect
.GetTop();
1097 fr
.rc
.left
= renderRect
.GetLeft();
1098 fr
.rc
.right
= renderRect
.GetRight();
1099 fr
.rc
.bottom
= renderRect
.GetBottom();
1100 fr
.rcPage
.top
= pageRect
.GetTop();
1101 fr
.rcPage
.left
= pageRect
.GetLeft();
1102 fr
.rcPage
.right
= pageRect
.GetRight();
1103 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1104 fr
.chrg
.cpMin
= startPos
;
1105 fr
.chrg
.cpMax
= endPos
;
1107 return SendMsg(2151, doDraw
, (long)&fr
);
1110 // Retrieve the display line at the top of the display.
1111 int wxStyledTextCtrl::GetFirstVisibleLine() {
1112 return SendMsg(2152, 0, 0);
1115 // Retrieve the contents of a line.
1116 wxString
wxStyledTextCtrl::GetLine(int line
) {
1117 int len
= LineLength(line
);
1118 if (!len
) return wxEmptyString
;
1120 wxMemoryBuffer
mbuf(len
+1);
1121 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1122 SendMsg(2153, line
, (long)buf
);
1123 mbuf
.UngetWriteBuf(len
);
1128 // Returns the number of lines in the document. There is always at least one.
1129 int wxStyledTextCtrl::GetLineCount() {
1130 return SendMsg(2154, 0, 0);
1133 // Sets the size in pixels of the left margin.
1134 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1135 SendMsg(2155, 0, pixelWidth
);
1138 // Returns the size in pixels of the left margin.
1139 int wxStyledTextCtrl::GetMarginLeft() {
1140 return SendMsg(2156, 0, 0);
1143 // Sets the size in pixels of the right margin.
1144 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1145 SendMsg(2157, 0, pixelWidth
);
1148 // Returns the size in pixels of the right margin.
1149 int wxStyledTextCtrl::GetMarginRight() {
1150 return SendMsg(2158, 0, 0);
1153 // Is the document different from when it was last saved?
1154 bool wxStyledTextCtrl::GetModify() {
1155 return SendMsg(2159, 0, 0) != 0;
1158 // Select a range of text.
1159 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1160 SendMsg(2160, start
, end
);
1163 // Retrieve the selected text.
1164 wxString
wxStyledTextCtrl::GetSelectedText() {
1168 GetSelection(&start
, &end
);
1169 int len
= end
- start
;
1170 if (!len
) return wxEmptyString
;
1172 wxMemoryBuffer
mbuf(len
+2);
1173 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1174 SendMsg(2161, 0, (long)buf
);
1175 mbuf
.UngetWriteBuf(len
);
1180 // Retrieve a range of text.
1181 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1182 if (endPos
< startPos
) {
1183 int temp
= startPos
;
1187 int len
= endPos
- startPos
;
1188 if (!len
) return wxEmptyString
;
1189 wxMemoryBuffer
mbuf(len
+1);
1190 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1193 tr
.chrg
.cpMin
= startPos
;
1194 tr
.chrg
.cpMax
= endPos
;
1195 SendMsg(2162, 0, (long)&tr
);
1196 mbuf
.UngetWriteBuf(len
);
1201 // Draw the selection in normal style or with selection highlighted.
1202 void wxStyledTextCtrl::HideSelection(bool normal
) {
1203 SendMsg(2163, normal
, 0);
1206 // Retrieve the line containing a position.
1207 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1208 return SendMsg(2166, pos
, 0);
1211 // Retrieve the position at the start of a line.
1212 int wxStyledTextCtrl::PositionFromLine(int line
) {
1213 return SendMsg(2167, line
, 0);
1216 // Scroll horizontally and vertically.
1217 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1218 SendMsg(2168, columns
, lines
);
1221 // Ensure the caret is visible.
1222 void wxStyledTextCtrl::EnsureCaretVisible() {
1223 SendMsg(2169, 0, 0);
1226 // Replace the selected text with the argument text.
1227 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1228 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1231 // Set to read only or read write.
1232 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1233 SendMsg(2171, readOnly
, 0);
1236 // Will a paste succeed?
1237 bool wxStyledTextCtrl::CanPaste() {
1238 return SendMsg(2173, 0, 0) != 0;
1241 // Are there any undoable actions in the undo history?
1242 bool wxStyledTextCtrl::CanUndo() {
1243 return SendMsg(2174, 0, 0) != 0;
1246 // Delete the undo history.
1247 void wxStyledTextCtrl::EmptyUndoBuffer() {
1248 SendMsg(2175, 0, 0);
1251 // Undo one action in the undo history.
1252 void wxStyledTextCtrl::Undo() {
1253 SendMsg(2176, 0, 0);
1256 // Cut the selection to the clipboard.
1257 void wxStyledTextCtrl::Cut() {
1258 SendMsg(2177, 0, 0);
1261 // Copy the selection to the clipboard.
1262 void wxStyledTextCtrl::Copy() {
1263 SendMsg(2178, 0, 0);
1266 // Paste the contents of the clipboard into the document replacing the selection.
1267 void wxStyledTextCtrl::Paste() {
1268 SendMsg(2179, 0, 0);
1271 // Clear the selection.
1272 void wxStyledTextCtrl::Clear() {
1273 SendMsg(2180, 0, 0);
1276 // Replace the contents of the document with the argument text.
1277 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1278 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1281 // Retrieve all the text in the document.
1282 wxString
wxStyledTextCtrl::GetText() {
1283 int len
= GetTextLength();
1284 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1285 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1286 SendMsg(2182, len
+1, (long)buf
);
1287 mbuf
.UngetWriteBuf(len
);
1292 // Retrieve the number of characters in the document.
1293 int wxStyledTextCtrl::GetTextLength() {
1294 return SendMsg(2183, 0, 0);
1297 // Set to overtype (true) or insert mode.
1298 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1299 SendMsg(2186, overtype
, 0);
1302 // Returns true if overtype mode is active otherwise false is returned.
1303 bool wxStyledTextCtrl::GetOvertype() {
1304 return SendMsg(2187, 0, 0) != 0;
1307 // Set the width of the insert mode caret.
1308 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1309 SendMsg(2188, pixelWidth
, 0);
1312 // Returns the width of the insert mode caret.
1313 int wxStyledTextCtrl::GetCaretWidth() {
1314 return SendMsg(2189, 0, 0);
1317 // Sets the position that starts the target which is used for updating the
1318 // document without affecting the scroll position.
1319 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1320 SendMsg(2190, pos
, 0);
1323 // Get the position that starts the target.
1324 int wxStyledTextCtrl::GetTargetStart() {
1325 return SendMsg(2191, 0, 0);
1328 // Sets the position that ends the target which is used for updating the
1329 // document without affecting the scroll position.
1330 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1331 SendMsg(2192, pos
, 0);
1334 // Get the position that ends the target.
1335 int wxStyledTextCtrl::GetTargetEnd() {
1336 return SendMsg(2193, 0, 0);
1339 // Replace the target text with the argument text.
1340 // Text is counted so it can contain NULs.
1341 // Returns the length of the replacement text.
1343 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1344 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1345 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1348 // Replace the target text with the argument text after \d processing.
1349 // Text is counted so it can contain NULs.
1350 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1351 // matched in the last search operation which were surrounded by \( and \).
1352 // Returns the length of the replacement text including any change
1353 // caused by processing the \d patterns.
1355 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1356 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1357 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1360 // Search for a counted string in the target and set the target to the found
1361 // range. Text is counted so it can contain NULs.
1362 // Returns length of range or -1 for failure in which case target is not moved.
1364 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1365 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1366 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1369 // Set the search flags used by SearchInTarget.
1370 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1371 SendMsg(2198, flags
, 0);
1374 // Get the search flags used by SearchInTarget.
1375 int wxStyledTextCtrl::GetSearchFlags() {
1376 return SendMsg(2199, 0, 0);
1379 // Show a call tip containing a definition near position pos.
1380 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1381 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1384 // Remove the call tip from the screen.
1385 void wxStyledTextCtrl::CallTipCancel() {
1386 SendMsg(2201, 0, 0);
1389 // Is there an active call tip?
1390 bool wxStyledTextCtrl::CallTipActive() {
1391 return SendMsg(2202, 0, 0) != 0;
1394 // Retrieve the position where the caret was before displaying the call tip.
1395 int wxStyledTextCtrl::CallTipPosAtStart() {
1396 return SendMsg(2203, 0, 0);
1399 // Highlight a segment of the definition.
1400 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1401 SendMsg(2204, start
, end
);
1404 // Set the background colour for the call tip.
1405 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1406 SendMsg(2205, wxColourAsLong(back
), 0);
1409 // Set the foreground colour for the call tip.
1410 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1411 SendMsg(2206, wxColourAsLong(fore
), 0);
1414 // Set the foreground colour for the highlighted part of the call tip.
1415 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1416 SendMsg(2207, wxColourAsLong(fore
), 0);
1419 // Find the display line of a document line taking hidden lines into account.
1420 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1421 return SendMsg(2220, line
, 0);
1424 // Find the document line of a display line taking hidden lines into account.
1425 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1426 return SendMsg(2221, lineDisplay
, 0);
1429 // Set the fold level of a line.
1430 // This encodes an integer level along with flags indicating whether the
1431 // line is a header and whether it is effectively white space.
1432 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1433 SendMsg(2222, line
, level
);
1436 // Retrieve the fold level of a line.
1437 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1438 return SendMsg(2223, line
, 0);
1441 // Find the last child line of a header line.
1442 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1443 return SendMsg(2224, line
, level
);
1446 // Find the parent line of a child line.
1447 int wxStyledTextCtrl::GetFoldParent(int line
) {
1448 return SendMsg(2225, line
, 0);
1451 // Make a range of lines visible.
1452 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1453 SendMsg(2226, lineStart
, lineEnd
);
1456 // Make a range of lines invisible.
1457 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1458 SendMsg(2227, lineStart
, lineEnd
);
1461 // Is a line visible?
1462 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1463 return SendMsg(2228, line
, 0) != 0;
1466 // Show the children of a header line.
1467 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1468 SendMsg(2229, line
, expanded
);
1471 // Is a header line expanded?
1472 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1473 return SendMsg(2230, line
, 0) != 0;
1476 // Switch a header line between expanded and contracted.
1477 void wxStyledTextCtrl::ToggleFold(int line
) {
1478 SendMsg(2231, line
, 0);
1481 // Ensure a particular line is visible by expanding any header line hiding it.
1482 void wxStyledTextCtrl::EnsureVisible(int line
) {
1483 SendMsg(2232, line
, 0);
1486 // Set some style options for folding.
1487 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1488 SendMsg(2233, flags
, 0);
1491 // Ensure a particular line is visible by expanding any header line hiding it.
1492 // Use the currently set visibility policy to determine which range to display.
1493 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1494 SendMsg(2234, line
, 0);
1497 // Sets whether a tab pressed when caret is within indentation indents.
1498 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1499 SendMsg(2260, tabIndents
, 0);
1502 // Does a tab pressed when caret is within indentation indent?
1503 bool wxStyledTextCtrl::GetTabIndents() {
1504 return SendMsg(2261, 0, 0) != 0;
1507 // Sets whether a backspace pressed when caret is within indentation unindents.
1508 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1509 SendMsg(2262, bsUnIndents
, 0);
1512 // Does a backspace pressed when caret is within indentation unindent?
1513 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1514 return SendMsg(2263, 0, 0) != 0;
1517 // Sets the time the mouse must sit still to generate a mouse dwell event.
1518 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1519 SendMsg(2264, periodMilliseconds
, 0);
1522 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1523 int wxStyledTextCtrl::GetMouseDwellTime() {
1524 return SendMsg(2265, 0, 0);
1527 // Get position of start of word.
1528 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1529 return SendMsg(2266, pos
, onlyWordCharacters
);
1532 // Get position of end of word.
1533 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1534 return SendMsg(2267, pos
, onlyWordCharacters
);
1537 // Sets whether text is word wrapped.
1538 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1539 SendMsg(2268, mode
, 0);
1542 // Retrieve whether text is word wrapped.
1543 int wxStyledTextCtrl::GetWrapMode() {
1544 return SendMsg(2269, 0, 0);
1547 // Set the display mode of visual flags for wrapped lines.
1548 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1549 SendMsg(2460, wrapVisualFlags
, 0);
1552 // Retrive the display mode of visual flags for wrapped lines.
1553 int wxStyledTextCtrl::GetWrapVisualFlags() {
1554 return SendMsg(2461, 0, 0);
1557 // Set the location of visual flags for wrapped lines.
1558 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1559 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1562 // Retrive the location of visual flags for wrapped lines.
1563 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1564 return SendMsg(2463, 0, 0);
1567 // Set the start indent for wrapped lines.
1568 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1569 SendMsg(2464, indent
, 0);
1572 // Retrive the start indent for wrapped lines.
1573 int wxStyledTextCtrl::GetWrapStartIndent() {
1574 return SendMsg(2465, 0, 0);
1577 // Sets the degree of caching of layout information.
1578 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1579 SendMsg(2272, mode
, 0);
1582 // Retrieve the degree of caching of layout information.
1583 int wxStyledTextCtrl::GetLayoutCache() {
1584 return SendMsg(2273, 0, 0);
1587 // Sets the document width assumed for scrolling.
1588 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1589 SendMsg(2274, pixelWidth
, 0);
1592 // Retrieve the document width assumed for scrolling.
1593 int wxStyledTextCtrl::GetScrollWidth() {
1594 return SendMsg(2275, 0, 0);
1597 // Measure the pixel width of some text in a particular style.
1598 // NUL terminated text argument.
1599 // Does not handle tab or control characters.
1600 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1601 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1604 // Sets the scroll range so that maximum scroll position has
1605 // the last line at the bottom of the view (default).
1606 // Setting this to false allows scrolling one page below the last line.
1607 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1608 SendMsg(2277, endAtLastLine
, 0);
1611 // Retrieve whether the maximum scroll position has the last
1612 // line at the bottom of the view.
1613 int wxStyledTextCtrl::GetEndAtLastLine() {
1614 return SendMsg(2278, 0, 0);
1617 // Retrieve the height of a particular line of text in pixels.
1618 int wxStyledTextCtrl::TextHeight(int line
) {
1619 return SendMsg(2279, line
, 0);
1622 // Show or hide the vertical scroll bar.
1623 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1624 SendMsg(2280, show
, 0);
1627 // Is the vertical scroll bar visible?
1628 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1629 return SendMsg(2281, 0, 0) != 0;
1632 // Append a string to the end of the document without changing the selection.
1633 void wxStyledTextCtrl::AppendText(int length
, const wxString
& text
) {
1634 SendMsg(2282, length
, (long)(const char*)wx2stc(text
));
1637 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1638 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1639 return SendMsg(2283, 0, 0) != 0;
1642 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1643 // and then the foreground. This avoids chopping off characters that overlap the next run.
1644 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1645 SendMsg(2284, twoPhase
, 0);
1648 // Make the target range start and end be the same as the selection range start and end.
1649 void wxStyledTextCtrl::TargetFromSelection() {
1650 SendMsg(2287, 0, 0);
1653 // Join the lines in the target.
1654 void wxStyledTextCtrl::LinesJoin() {
1655 SendMsg(2288, 0, 0);
1658 // Split the lines in the target into lines that are less wide than pixelWidth
1660 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1661 SendMsg(2289, pixelWidth
, 0);
1664 // Set the colours used as a chequerboard pattern in the fold margin
1665 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1666 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1668 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1669 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1672 // Move caret down one line.
1673 void wxStyledTextCtrl::LineDown() {
1674 SendMsg(2300, 0, 0);
1677 // Move caret down one line extending selection to new caret position.
1678 void wxStyledTextCtrl::LineDownExtend() {
1679 SendMsg(2301, 0, 0);
1682 // Move caret up one line.
1683 void wxStyledTextCtrl::LineUp() {
1684 SendMsg(2302, 0, 0);
1687 // Move caret up one line extending selection to new caret position.
1688 void wxStyledTextCtrl::LineUpExtend() {
1689 SendMsg(2303, 0, 0);
1692 // Move caret left one character.
1693 void wxStyledTextCtrl::CharLeft() {
1694 SendMsg(2304, 0, 0);
1697 // Move caret left one character extending selection to new caret position.
1698 void wxStyledTextCtrl::CharLeftExtend() {
1699 SendMsg(2305, 0, 0);
1702 // Move caret right one character.
1703 void wxStyledTextCtrl::CharRight() {
1704 SendMsg(2306, 0, 0);
1707 // Move caret right one character extending selection to new caret position.
1708 void wxStyledTextCtrl::CharRightExtend() {
1709 SendMsg(2307, 0, 0);
1712 // Move caret left one word.
1713 void wxStyledTextCtrl::WordLeft() {
1714 SendMsg(2308, 0, 0);
1717 // Move caret left one word extending selection to new caret position.
1718 void wxStyledTextCtrl::WordLeftExtend() {
1719 SendMsg(2309, 0, 0);
1722 // Move caret right one word.
1723 void wxStyledTextCtrl::WordRight() {
1724 SendMsg(2310, 0, 0);
1727 // Move caret right one word extending selection to new caret position.
1728 void wxStyledTextCtrl::WordRightExtend() {
1729 SendMsg(2311, 0, 0);
1732 // Move caret to first position on line.
1733 void wxStyledTextCtrl::Home() {
1734 SendMsg(2312, 0, 0);
1737 // Move caret to first position on line extending selection to new caret position.
1738 void wxStyledTextCtrl::HomeExtend() {
1739 SendMsg(2313, 0, 0);
1742 // Move caret to last position on line.
1743 void wxStyledTextCtrl::LineEnd() {
1744 SendMsg(2314, 0, 0);
1747 // Move caret to last position on line extending selection to new caret position.
1748 void wxStyledTextCtrl::LineEndExtend() {
1749 SendMsg(2315, 0, 0);
1752 // Move caret to first position in document.
1753 void wxStyledTextCtrl::DocumentStart() {
1754 SendMsg(2316, 0, 0);
1757 // Move caret to first position in document extending selection to new caret position.
1758 void wxStyledTextCtrl::DocumentStartExtend() {
1759 SendMsg(2317, 0, 0);
1762 // Move caret to last position in document.
1763 void wxStyledTextCtrl::DocumentEnd() {
1764 SendMsg(2318, 0, 0);
1767 // Move caret to last position in document extending selection to new caret position.
1768 void wxStyledTextCtrl::DocumentEndExtend() {
1769 SendMsg(2319, 0, 0);
1772 // Move caret one page up.
1773 void wxStyledTextCtrl::PageUp() {
1774 SendMsg(2320, 0, 0);
1777 // Move caret one page up extending selection to new caret position.
1778 void wxStyledTextCtrl::PageUpExtend() {
1779 SendMsg(2321, 0, 0);
1782 // Move caret one page down.
1783 void wxStyledTextCtrl::PageDown() {
1784 SendMsg(2322, 0, 0);
1787 // Move caret one page down extending selection to new caret position.
1788 void wxStyledTextCtrl::PageDownExtend() {
1789 SendMsg(2323, 0, 0);
1792 // Switch from insert to overtype mode or the reverse.
1793 void wxStyledTextCtrl::EditToggleOvertype() {
1794 SendMsg(2324, 0, 0);
1797 // Cancel any modes such as call tip or auto-completion list display.
1798 void wxStyledTextCtrl::Cancel() {
1799 SendMsg(2325, 0, 0);
1802 // Delete the selection or if no selection, the character before the caret.
1803 void wxStyledTextCtrl::DeleteBack() {
1804 SendMsg(2326, 0, 0);
1807 // If selection is empty or all on one line replace the selection with a tab character.
1808 // If more than one line selected, indent the lines.
1809 void wxStyledTextCtrl::Tab() {
1810 SendMsg(2327, 0, 0);
1813 // Dedent the selected lines.
1814 void wxStyledTextCtrl::BackTab() {
1815 SendMsg(2328, 0, 0);
1818 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1819 void wxStyledTextCtrl::NewLine() {
1820 SendMsg(2329, 0, 0);
1823 // Insert a Form Feed character.
1824 void wxStyledTextCtrl::FormFeed() {
1825 SendMsg(2330, 0, 0);
1828 // Move caret to before first visible character on line.
1829 // If already there move to first character on line.
1830 void wxStyledTextCtrl::VCHome() {
1831 SendMsg(2331, 0, 0);
1834 // Like VCHome but extending selection to new caret position.
1835 void wxStyledTextCtrl::VCHomeExtend() {
1836 SendMsg(2332, 0, 0);
1839 // Magnify the displayed text by increasing the sizes by 1 point.
1840 void wxStyledTextCtrl::ZoomIn() {
1841 SendMsg(2333, 0, 0);
1844 // Make the displayed text smaller by decreasing the sizes by 1 point.
1845 void wxStyledTextCtrl::ZoomOut() {
1846 SendMsg(2334, 0, 0);
1849 // Delete the word to the left of the caret.
1850 void wxStyledTextCtrl::DelWordLeft() {
1851 SendMsg(2335, 0, 0);
1854 // Delete the word to the right of the caret.
1855 void wxStyledTextCtrl::DelWordRight() {
1856 SendMsg(2336, 0, 0);
1859 // Cut the line containing the caret.
1860 void wxStyledTextCtrl::LineCut() {
1861 SendMsg(2337, 0, 0);
1864 // Delete the line containing the caret.
1865 void wxStyledTextCtrl::LineDelete() {
1866 SendMsg(2338, 0, 0);
1869 // Switch the current line with the previous.
1870 void wxStyledTextCtrl::LineTranspose() {
1871 SendMsg(2339, 0, 0);
1874 // Duplicate the current line.
1875 void wxStyledTextCtrl::LineDuplicate() {
1876 SendMsg(2404, 0, 0);
1879 // Transform the selection to lower case.
1880 void wxStyledTextCtrl::LowerCase() {
1881 SendMsg(2340, 0, 0);
1884 // Transform the selection to upper case.
1885 void wxStyledTextCtrl::UpperCase() {
1886 SendMsg(2341, 0, 0);
1889 // Scroll the document down, keeping the caret visible.
1890 void wxStyledTextCtrl::LineScrollDown() {
1891 SendMsg(2342, 0, 0);
1894 // Scroll the document up, keeping the caret visible.
1895 void wxStyledTextCtrl::LineScrollUp() {
1896 SendMsg(2343, 0, 0);
1899 // Delete the selection or if no selection, the character before the caret.
1900 // Will not delete the character before at the start of a line.
1901 void wxStyledTextCtrl::DeleteBackNotLine() {
1902 SendMsg(2344, 0, 0);
1905 // Move caret to first position on display line.
1906 void wxStyledTextCtrl::HomeDisplay() {
1907 SendMsg(2345, 0, 0);
1910 // Move caret to first position on display line extending selection to
1911 // new caret position.
1912 void wxStyledTextCtrl::HomeDisplayExtend() {
1913 SendMsg(2346, 0, 0);
1916 // Move caret to last position on display line.
1917 void wxStyledTextCtrl::LineEndDisplay() {
1918 SendMsg(2347, 0, 0);
1921 // Move caret to last position on display line extending selection to new
1923 void wxStyledTextCtrl::LineEndDisplayExtend() {
1924 SendMsg(2348, 0, 0);
1927 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1928 // except they behave differently when word-wrap is enabled:
1929 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1930 // The difference is that, the cursor is already at the point, it goes on to the start
1931 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1932 void wxStyledTextCtrl::HomeWrap() {
1933 SendMsg(2349, 0, 0);
1935 void wxStyledTextCtrl::HomeWrapExtend() {
1936 SendMsg(2450, 0, 0);
1938 void wxStyledTextCtrl::LineEndWrap() {
1939 SendMsg(2451, 0, 0);
1941 void wxStyledTextCtrl::LineEndWrapExtend() {
1942 SendMsg(2452, 0, 0);
1944 void wxStyledTextCtrl::VCHomeWrap() {
1945 SendMsg(2453, 0, 0);
1947 void wxStyledTextCtrl::VCHomeWrapExtend() {
1948 SendMsg(2454, 0, 0);
1951 // Copy the line containing the caret.
1952 void wxStyledTextCtrl::LineCopy() {
1953 SendMsg(2455, 0, 0);
1956 // Move the caret inside current view if it's not there already.
1957 void wxStyledTextCtrl::MoveCaretInsideView() {
1958 SendMsg(2401, 0, 0);
1961 // How many characters are on a line, not including end of line characters?
1962 int wxStyledTextCtrl::LineLength(int line
) {
1963 return SendMsg(2350, line
, 0);
1966 // Highlight the characters at two positions.
1967 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1968 SendMsg(2351, pos1
, pos2
);
1971 // Highlight the character at a position indicating there is no matching brace.
1972 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1973 SendMsg(2352, pos
, 0);
1976 // Find the position of a matching brace or INVALID_POSITION if no match.
1977 int wxStyledTextCtrl::BraceMatch(int pos
) {
1978 return SendMsg(2353, pos
, 0);
1981 // Are the end of line characters visible?
1982 bool wxStyledTextCtrl::GetViewEOL() {
1983 return SendMsg(2355, 0, 0) != 0;
1986 // Make the end of line characters visible or invisible.
1987 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1988 SendMsg(2356, visible
, 0);
1991 // Retrieve a pointer to the document object.
1992 void* wxStyledTextCtrl::GetDocPointer() {
1993 return (void*)SendMsg(2357);
1996 // Change the document object used.
1997 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1998 SendMsg(2358, 0, (long)docPointer
);
2001 // Set which document modification events are sent to the container.
2002 void wxStyledTextCtrl::SetModEventMask(int mask
) {
2003 SendMsg(2359, mask
, 0);
2006 // Retrieve the column number which text should be kept within.
2007 int wxStyledTextCtrl::GetEdgeColumn() {
2008 return SendMsg(2360, 0, 0);
2011 // Set the column number of the edge.
2012 // If text goes past the edge then it is highlighted.
2013 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
2014 SendMsg(2361, column
, 0);
2017 // Retrieve the edge highlight mode.
2018 int wxStyledTextCtrl::GetEdgeMode() {
2019 return SendMsg(2362, 0, 0);
2022 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
2023 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
2024 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2025 SendMsg(2363, mode
, 0);
2028 // Retrieve the colour used in edge indication.
2029 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2030 long c
= SendMsg(2364, 0, 0);
2031 return wxColourFromLong(c
);
2034 // Change the colour used in edge indication.
2035 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2036 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2039 // Sets the current caret position to be the search anchor.
2040 void wxStyledTextCtrl::SearchAnchor() {
2041 SendMsg(2366, 0, 0);
2044 // Find some text starting at the search anchor.
2045 // Does not ensure the selection is visible.
2046 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2047 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2050 // Find some text starting at the search anchor and moving backwards.
2051 // Does not ensure the selection is visible.
2052 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2053 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2056 // Retrieves the number of lines completely visible.
2057 int wxStyledTextCtrl::LinesOnScreen() {
2058 return SendMsg(2370, 0, 0);
2061 // Set whether a pop up menu is displayed automatically when the user presses
2062 // the wrong mouse button.
2063 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2064 SendMsg(2371, allowPopUp
, 0);
2067 // Is the selection rectangular? The alternative is the more common stream selection.
2068 bool wxStyledTextCtrl::SelectionIsRectangle() {
2069 return SendMsg(2372, 0, 0) != 0;
2072 // Set the zoom level. This number of points is added to the size of all fonts.
2073 // It may be positive to magnify or negative to reduce.
2074 void wxStyledTextCtrl::SetZoom(int zoom
) {
2075 SendMsg(2373, zoom
, 0);
2078 // Retrieve the zoom level.
2079 int wxStyledTextCtrl::GetZoom() {
2080 return SendMsg(2374, 0, 0);
2083 // Create a new document object.
2084 // Starts with reference count of 1 and not selected into editor.
2085 void* wxStyledTextCtrl::CreateDocument() {
2086 return (void*)SendMsg(2375);
2089 // Extend life of document.
2090 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2091 SendMsg(2376, 0, (long)docPointer
);
2094 // Release a reference to the document, deleting document if it fades to black.
2095 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2096 SendMsg(2377, 0, (long)docPointer
);
2099 // Get which document modification events are sent to the container.
2100 int wxStyledTextCtrl::GetModEventMask() {
2101 return SendMsg(2378, 0, 0);
2104 // Change internal focus flag.
2105 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2106 SendMsg(2380, focus
, 0);
2109 // Get internal focus flag.
2110 bool wxStyledTextCtrl::GetSTCFocus() {
2111 return SendMsg(2381, 0, 0) != 0;
2114 // Change error status - 0 = OK.
2115 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2116 SendMsg(2382, statusCode
, 0);
2119 // Get error status.
2120 int wxStyledTextCtrl::GetStatus() {
2121 return SendMsg(2383, 0, 0);
2124 // Set whether the mouse is captured when its button is pressed.
2125 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2126 SendMsg(2384, captures
, 0);
2129 // Get whether mouse gets captured.
2130 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2131 return SendMsg(2385, 0, 0) != 0;
2134 // Sets the cursor to one of the SC_CURSOR* values.
2135 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2136 SendMsg(2386, cursorType
, 0);
2140 int wxStyledTextCtrl::GetSTCCursor() {
2141 return SendMsg(2387, 0, 0);
2144 // Change the way control characters are displayed:
2145 // If symbol is < 32, keep the drawn way, else, use the given character.
2146 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2147 SendMsg(2388, symbol
, 0);
2150 // Get the way control characters are displayed.
2151 int wxStyledTextCtrl::GetControlCharSymbol() {
2152 return SendMsg(2389, 0, 0);
2155 // Move to the previous change in capitalisation.
2156 void wxStyledTextCtrl::WordPartLeft() {
2157 SendMsg(2390, 0, 0);
2160 // Move to the previous change in capitalisation extending selection
2161 // to new caret position.
2162 void wxStyledTextCtrl::WordPartLeftExtend() {
2163 SendMsg(2391, 0, 0);
2166 // Move to the change next in capitalisation.
2167 void wxStyledTextCtrl::WordPartRight() {
2168 SendMsg(2392, 0, 0);
2171 // Move to the next change in capitalisation extending selection
2172 // to new caret position.
2173 void wxStyledTextCtrl::WordPartRightExtend() {
2174 SendMsg(2393, 0, 0);
2177 // Set the way the display area is determined when a particular line
2178 // is to be moved to by Find, FindNext, GotoLine, etc.
2179 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2180 SendMsg(2394, visiblePolicy
, visibleSlop
);
2183 // Delete back from the current position to the start of the line.
2184 void wxStyledTextCtrl::DelLineLeft() {
2185 SendMsg(2395, 0, 0);
2188 // Delete forwards from the current position to the end of the line.
2189 void wxStyledTextCtrl::DelLineRight() {
2190 SendMsg(2396, 0, 0);
2193 // Get and Set the xOffset (ie, horizonal scroll position).
2194 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2195 SendMsg(2397, newOffset
, 0);
2197 int wxStyledTextCtrl::GetXOffset() {
2198 return SendMsg(2398, 0, 0);
2201 // Set the last x chosen value to be the caret x position.
2202 void wxStyledTextCtrl::ChooseCaretX() {
2203 SendMsg(2399, 0, 0);
2206 // Set the way the caret is kept visible when going sideway.
2207 // The exclusion zone is given in pixels.
2208 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2209 SendMsg(2402, caretPolicy
, caretSlop
);
2212 // Set the way the line the caret is on is kept visible.
2213 // The exclusion zone is given in lines.
2214 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2215 SendMsg(2403, caretPolicy
, caretSlop
);
2218 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2219 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2220 SendMsg(2406, mode
, 0);
2223 // Is printing line wrapped?
2224 int wxStyledTextCtrl::GetPrintWrapMode() {
2225 return SendMsg(2407, 0, 0);
2228 // Set a fore colour for active hotspots.
2229 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2230 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2233 // Set a back colour for active hotspots.
2234 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2235 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2238 // Enable / Disable underlining active hotspots.
2239 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2240 SendMsg(2412, underline
, 0);
2243 // Limit hotspots to single line so hotspots on two lines don't merge.
2244 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2245 SendMsg(2421, singleLine
, 0);
2248 // Move caret between paragraphs (delimited by empty lines).
2249 void wxStyledTextCtrl::ParaDown() {
2250 SendMsg(2413, 0, 0);
2252 void wxStyledTextCtrl::ParaDownExtend() {
2253 SendMsg(2414, 0, 0);
2255 void wxStyledTextCtrl::ParaUp() {
2256 SendMsg(2415, 0, 0);
2258 void wxStyledTextCtrl::ParaUpExtend() {
2259 SendMsg(2416, 0, 0);
2262 // Given a valid document position, return the previous position taking code
2263 // page into account. Returns 0 if passed 0.
2264 int wxStyledTextCtrl::PositionBefore(int pos
) {
2265 return SendMsg(2417, pos
, 0);
2268 // Given a valid document position, return the next position taking code
2269 // page into account. Maximum value returned is the last position in the document.
2270 int wxStyledTextCtrl::PositionAfter(int pos
) {
2271 return SendMsg(2418, pos
, 0);
2274 // Copy a range of text to the clipboard. Positions are clipped into the document.
2275 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2276 SendMsg(2419, start
, end
);
2279 // Copy argument text to the clipboard.
2280 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2281 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2284 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2285 // by lines (SC_SEL_LINES).
2286 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2287 SendMsg(2422, mode
, 0);
2290 // Get the mode of the current selection.
2291 int wxStyledTextCtrl::GetSelectionMode() {
2292 return SendMsg(2423, 0, 0);
2295 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2296 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2297 return SendMsg(2424, line
, 0);
2300 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2301 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2302 return SendMsg(2425, line
, 0);
2305 // Move caret down one line, extending rectangular selection to new caret position.
2306 void wxStyledTextCtrl::LineDownRectExtend() {
2307 SendMsg(2426, 0, 0);
2310 // Move caret up one line, extending rectangular selection to new caret position.
2311 void wxStyledTextCtrl::LineUpRectExtend() {
2312 SendMsg(2427, 0, 0);
2315 // Move caret left one character, extending rectangular selection to new caret position.
2316 void wxStyledTextCtrl::CharLeftRectExtend() {
2317 SendMsg(2428, 0, 0);
2320 // Move caret right one character, extending rectangular selection to new caret position.
2321 void wxStyledTextCtrl::CharRightRectExtend() {
2322 SendMsg(2429, 0, 0);
2325 // Move caret to first position on line, extending rectangular selection to new caret position.
2326 void wxStyledTextCtrl::HomeRectExtend() {
2327 SendMsg(2430, 0, 0);
2330 // Move caret to before first visible character on line.
2331 // If already there move to first character on line.
2332 // In either case, extend rectangular selection to new caret position.
2333 void wxStyledTextCtrl::VCHomeRectExtend() {
2334 SendMsg(2431, 0, 0);
2337 // Move caret to last position on line, extending rectangular selection to new caret position.
2338 void wxStyledTextCtrl::LineEndRectExtend() {
2339 SendMsg(2432, 0, 0);
2342 // Move caret one page up, extending rectangular selection to new caret position.
2343 void wxStyledTextCtrl::PageUpRectExtend() {
2344 SendMsg(2433, 0, 0);
2347 // Move caret one page down, extending rectangular selection to new caret position.
2348 void wxStyledTextCtrl::PageDownRectExtend() {
2349 SendMsg(2434, 0, 0);
2352 // Move caret to top of page, or one page up if already at top of page.
2353 void wxStyledTextCtrl::StutteredPageUp() {
2354 SendMsg(2435, 0, 0);
2357 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2358 void wxStyledTextCtrl::StutteredPageUpExtend() {
2359 SendMsg(2436, 0, 0);
2362 // Move caret to bottom of page, or one page down if already at bottom of page.
2363 void wxStyledTextCtrl::StutteredPageDown() {
2364 SendMsg(2437, 0, 0);
2367 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2368 void wxStyledTextCtrl::StutteredPageDownExtend() {
2369 SendMsg(2438, 0, 0);
2372 // Move caret left one word, position cursor at end of word.
2373 void wxStyledTextCtrl::WordLeftEnd() {
2374 SendMsg(2439, 0, 0);
2377 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2378 void wxStyledTextCtrl::WordLeftEndExtend() {
2379 SendMsg(2440, 0, 0);
2382 // Move caret right one word, position cursor at end of word.
2383 void wxStyledTextCtrl::WordRightEnd() {
2384 SendMsg(2441, 0, 0);
2387 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2388 void wxStyledTextCtrl::WordRightEndExtend() {
2389 SendMsg(2442, 0, 0);
2392 // Set the set of characters making up whitespace for when moving or selecting by word.
2393 // Should be called after SetWordChars.
2394 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2395 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2398 // Reset the set of characters for whitespace and word characters to the defaults.
2399 void wxStyledTextCtrl::SetCharsDefault() {
2400 SendMsg(2444, 0, 0);
2403 // Get currently selected item position in the auto-completion list
2404 int wxStyledTextCtrl::AutoCompGetCurrent() {
2405 return SendMsg(2445, 0, 0);
2408 // Enlarge the document to a particular size of text bytes.
2409 void wxStyledTextCtrl::Allocate(int bytes
) {
2410 SendMsg(2446, bytes
, 0);
2413 // Find the position of a column on a line taking into account tabs and
2414 // multi-byte characters. If beyond end of line, return line end position.
2415 int wxStyledTextCtrl::FindColumn(int line
, int column
) {
2416 return SendMsg(2456, line
, column
);
2419 // Start notifying the container of all key presses and commands.
2420 void wxStyledTextCtrl::StartRecord() {
2421 SendMsg(3001, 0, 0);
2424 // Stop notifying the container of all key presses and commands.
2425 void wxStyledTextCtrl::StopRecord() {
2426 SendMsg(3002, 0, 0);
2429 // Set the lexing language of the document.
2430 void wxStyledTextCtrl::SetLexer(int lexer
) {
2431 SendMsg(4001, lexer
, 0);
2434 // Retrieve the lexing language of the document.
2435 int wxStyledTextCtrl::GetLexer() {
2436 return SendMsg(4002, 0, 0);
2439 // Colourise a segment of the document using the current lexing language.
2440 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2441 SendMsg(4003, start
, end
);
2444 // Set up a value that may be used by a lexer for some optional feature.
2445 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2446 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2449 // Set up the key words used by the lexer.
2450 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2451 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2454 // Set the lexing language of the document based on string name.
2455 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2456 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2459 // END of generated section
2460 //----------------------------------------------------------------------
2463 // Returns the line number of the line with the caret.
2464 int wxStyledTextCtrl::GetCurrentLine() {
2465 int line
= LineFromPosition(GetCurrentPos());
2470 // Extract style settings from a spec-string which is composed of one or
2471 // more of the following comma separated elements:
2473 // bold turns on bold
2474 // italic turns on italics
2475 // fore:[name or #RRGGBB] sets the foreground colour
2476 // back:[name or #RRGGBB] sets the background colour
2477 // face:[facename] sets the font face name to use
2478 // size:[num] sets the font size in points
2479 // eol turns on eol filling
2480 // underline turns on underlining
2482 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2484 wxStringTokenizer
tkz(spec
, wxT(","));
2485 while (tkz
.HasMoreTokens()) {
2486 wxString token
= tkz
.GetNextToken();
2488 wxString option
= token
.BeforeFirst(':');
2489 wxString val
= token
.AfterFirst(':');
2491 if (option
== wxT("bold"))
2492 StyleSetBold(styleNum
, true);
2494 else if (option
== wxT("italic"))
2495 StyleSetItalic(styleNum
, true);
2497 else if (option
== wxT("underline"))
2498 StyleSetUnderline(styleNum
, true);
2500 else if (option
== wxT("eol"))
2501 StyleSetEOLFilled(styleNum
, true);
2503 else if (option
== wxT("size")) {
2505 if (val
.ToLong(&points
))
2506 StyleSetSize(styleNum
, points
);
2509 else if (option
== wxT("face"))
2510 StyleSetFaceName(styleNum
, val
);
2512 else if (option
== wxT("fore"))
2513 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2515 else if (option
== wxT("back"))
2516 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2521 // Set style size, face, bold, italic, and underline attributes from
2522 // a wxFont's attributes.
2523 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2525 // Ensure that the native font is initialized
2527 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2529 int size
= font
.GetPointSize();
2530 wxString faceName
= font
.GetFaceName();
2531 bool bold
= font
.GetWeight() == wxBOLD
;
2532 bool italic
= font
.GetStyle() != wxNORMAL
;
2533 bool under
= font
.GetUnderlined();
2535 // TODO: add encoding/charset mapping
2536 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
2539 // Set all font style attributes at once.
2540 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2541 const wxString
& faceName
,
2542 bool bold
, bool italic
,
2544 StyleSetSize(styleNum
, size
);
2545 StyleSetFaceName(styleNum
, faceName
);
2546 StyleSetBold(styleNum
, bold
);
2547 StyleSetItalic(styleNum
, italic
);
2548 StyleSetUnderline(styleNum
, underline
);
2550 // TODO: add encoding/charset mapping
2554 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2555 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2560 // Set the left and right margin in the edit area, measured in pixels.
2561 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2562 SetMarginLeft(left
);
2563 SetMarginRight(right
);
2567 // Retrieve the start and end positions of the current selection.
2568 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2569 if (startPos
!= NULL
)
2570 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2572 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2576 // Retrieve the point in the window where a position is displayed.
2577 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2578 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2579 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2580 return wxPoint(x
, y
);
2583 // Scroll enough to make the given line visible
2584 void wxStyledTextCtrl::ScrollToLine(int line
) {
2585 m_swx
->DoScrollToLine(line
);
2589 // Scroll enough to make the given column visible
2590 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2591 m_swx
->DoScrollToColumn(column
);
2595 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2597 wxFile
file(filename
, wxFile::write
);
2599 if (!file
.IsOpened())
2602 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2610 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2612 bool success
= false;
2613 wxFile
file(filename
, wxFile::read
);
2615 if (file
.IsOpened())
2618 // get the file size (assume it is not huge file...)
2619 ssize_t len
= (ssize_t
)file
.Length();
2624 wxMemoryBuffer
buffer(len
+1);
2625 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2627 ((char*)buffer
.GetData())[len
] = 0;
2628 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2632 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2639 success
= true; // empty file is ok
2641 success
= false; // len == wxInvalidOffset
2656 #if wxUSE_DRAG_AND_DROP
2657 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2658 return m_swx
->DoDragOver(x
, y
, def
);
2662 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2663 return m_swx
->DoDropText(x
, y
, data
);
2668 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2669 m_swx
->SetUseAntiAliasing(useAA
);
2672 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2673 return m_swx
->GetUseAntiAliasing();
2676 //----------------------------------------------------------------------
2679 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
2681 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
2684 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
2685 if (evt
.GetOrientation() == wxHORIZONTAL
)
2686 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2688 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2691 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
2692 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
2694 if (sb
->IsVertical())
2695 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2697 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2701 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
2703 wxSize sz
= GetClientSize();
2704 m_swx
->DoSize(sz
.x
, sz
.y
);
2708 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
2710 wxPoint pt
= evt
.GetPosition();
2711 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2712 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
2715 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
2716 wxPoint pt
= evt
.GetPosition();
2717 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
2720 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
2721 wxPoint pt
= evt
.GetPosition();
2722 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2727 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
2728 wxPoint pt
= evt
.GetPosition();
2729 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2733 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
2734 wxPoint pt
= evt
.GetPosition();
2735 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
2738 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
2739 wxPoint pt
= evt
.GetPosition();
2740 ScreenToClient(&pt
.x
, &pt
.y
);
2742 Show context menu at event point if it's within the window,
2743 or at caret location if not
2745 wxHitTest ht
= this->HitTest(pt
);
2746 if (ht
!= wxHT_WINDOW_INSIDE
) {
2747 pt
= this->PointFromPosition(this->GetCurrentPos());
2749 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2753 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
2754 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
2755 evt
.GetWheelDelta(),
2756 evt
.GetLinesPerAction(),
2758 evt
.IsPageScroll());
2762 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
2763 // On (some?) non-US PC keyboards the AltGr key is required to enter some
2764 // common characters. It comes to us as both Alt and Ctrl down so we need
2765 // to let the char through in that case, otherwise if only ctrl or only
2766 // alt let's skip it.
2767 bool ctrl
= evt
.ControlDown();
2769 // On the Mac the Alt key is just a modifier key (like Shift) so we need
2770 // to allow the char events to be processed when Alt is pressed.
2771 // TODO: Should we check MetaDown instead in this case?
2774 bool alt
= evt
.AltDown();
2776 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
2778 if (!m_lastKeyDownConsumed
&& !skip
) {
2780 int key
= evt
.GetUnicodeKey();
2783 // if the unicode key code is not really a unicode character (it may
2784 // be a function key or etc., the platforms appear to always give us a
2785 // small value in this case) then fallback to the ascii key code but
2786 // don't do anything for function keys or etc.
2788 key
= evt
.GetKeyCode();
2789 keyOk
= (key
<= 127);
2792 m_swx
->DoAddChar(key
);
2796 int key
= evt
.GetKeyCode();
2797 if (key
<= WXK_START
|| key
> WXK_COMMAND
) {
2798 m_swx
->DoAddChar(key
);
2808 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
2809 int processed
= m_swx
->DoKeyDown(evt
, &m_lastKeyDownConsumed
);
2810 if (!processed
&& !m_lastKeyDownConsumed
)
2815 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
2816 m_swx
->DoLoseFocus();
2821 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
2822 m_swx
->DoGainFocus();
2827 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
2828 m_swx
->DoSysColourChange();
2832 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
2833 // do nothing to help avoid flashing
2838 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
2839 m_swx
->DoCommand(evt
.GetId());
2843 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
2844 m_swx
->DoOnListBox();
2848 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
2849 m_swx
->DoOnIdle(evt
);
2853 wxSize
wxStyledTextCtrl::DoGetBestSize() const
2855 // What would be the best size for a wxSTC?
2856 // Just give a reasonable minimum until something else can be figured out.
2857 return wxSize(200,100);
2861 //----------------------------------------------------------------------
2862 // Turn notifications from Scintilla into events
2865 void wxStyledTextCtrl::NotifyChange() {
2866 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
2867 evt
.SetEventObject(this);
2868 GetEventHandler()->ProcessEvent(evt
);
2872 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
2876 // The unicode conversion MUST have a null byte to terminate the
2877 // string so move it into a buffer first and give it one.
2878 wxMemoryBuffer
buf(length
+1);
2879 buf
.AppendData((void*)text
, length
);
2881 evt
.SetText(stc2wx(buf
));
2885 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
2886 SCNotification
& scn
= *_scn
;
2887 wxStyledTextEvent
evt(0, GetId());
2889 evt
.SetEventObject(this);
2890 evt
.SetPosition(scn
.position
);
2892 evt
.SetModifiers(scn
.modifiers
);
2894 switch (scn
.nmhdr
.code
) {
2895 case SCN_STYLENEEDED
:
2896 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
2900 evt
.SetEventType(wxEVT_STC_CHARADDED
);
2903 case SCN_SAVEPOINTREACHED
:
2904 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
2907 case SCN_SAVEPOINTLEFT
:
2908 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
2911 case SCN_MODIFYATTEMPTRO
:
2912 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
2916 evt
.SetEventType(wxEVT_STC_KEY
);
2919 case SCN_DOUBLECLICK
:
2920 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
2924 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
2928 evt
.SetEventType(wxEVT_STC_MODIFIED
);
2929 evt
.SetModificationType(scn
.modificationType
);
2930 SetEventText(evt
, scn
.text
, scn
.length
);
2931 evt
.SetLength(scn
.length
);
2932 evt
.SetLinesAdded(scn
.linesAdded
);
2933 evt
.SetLine(scn
.line
);
2934 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
2935 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
2938 case SCN_MACRORECORD
:
2939 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
2940 evt
.SetMessage(scn
.message
);
2941 evt
.SetWParam(scn
.wParam
);
2942 evt
.SetLParam(scn
.lParam
);
2945 case SCN_MARGINCLICK
:
2946 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
2947 evt
.SetMargin(scn
.margin
);
2951 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
2952 evt
.SetLength(scn
.length
);
2956 evt
.SetEventType(wxEVT_STC_PAINTED
);
2959 case SCN_USERLISTSELECTION
:
2960 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
2961 evt
.SetListType(scn
.listType
);
2962 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2965 case SCN_URIDROPPED
:
2966 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
2967 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2970 case SCN_DWELLSTART
:
2971 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
2977 evt
.SetEventType(wxEVT_STC_DWELLEND
);
2983 evt
.SetEventType(wxEVT_STC_ZOOM
);
2986 case SCN_HOTSPOTCLICK
:
2987 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
2990 case SCN_HOTSPOTDOUBLECLICK
:
2991 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
2994 case SCN_CALLTIPCLICK
:
2995 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
3002 GetEventHandler()->ProcessEvent(evt
);
3006 //----------------------------------------------------------------------
3007 //----------------------------------------------------------------------
3008 //----------------------------------------------------------------------
3010 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
3011 : wxCommandEvent(commandType
, id
)
3016 m_modificationType
= 0;
3021 m_foldLevelPrev
= 0;
3029 m_dragAllowMove
= false;
3030 #if wxUSE_DRAG_AND_DROP
3031 m_dragResult
= wxDragNone
;
3035 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
3036 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
3037 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
3040 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
3041 wxCommandEvent(event
)
3043 m_position
= event
.m_position
;
3044 m_key
= event
.m_key
;
3045 m_modifiers
= event
.m_modifiers
;
3046 m_modificationType
= event
.m_modificationType
;
3047 m_text
= event
.m_text
;
3048 m_length
= event
.m_length
;
3049 m_linesAdded
= event
.m_linesAdded
;
3050 m_line
= event
.m_line
;
3051 m_foldLevelNow
= event
.m_foldLevelNow
;
3052 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3054 m_margin
= event
.m_margin
;
3056 m_message
= event
.m_message
;
3057 m_wParam
= event
.m_wParam
;
3058 m_lParam
= event
.m_lParam
;
3060 m_listType
= event
.m_listType
;
3064 m_dragText
= event
.m_dragText
;
3065 m_dragAllowMove
=event
.m_dragAllowMove
;
3066 #if wxUSE_DRAG_AND_DROP
3067 m_dragResult
= event
.m_dragResult
;
3071 //----------------------------------------------------------------------
3072 //----------------------------------------------------------------------