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
);
195 //----------------------------------------------------------------------
196 // BEGIN generated section. The following code is automatically generated
197 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
198 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
201 // Add text to the document at current position.
202 void wxStyledTextCtrl::AddText(const wxString
& text
) {
203 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
204 SendMsg(2001, strlen(buf
), (long)(const char*)buf
);
207 // Add array of cells to document.
208 void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer
& data
) {
209 SendMsg(2002, data
.GetDataLen(), (long)data
.GetData());
212 // Insert string at a position.
213 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
214 SendMsg(2003, pos
, (long)(const char*)wx2stc(text
));
217 // Delete all text in the document.
218 void wxStyledTextCtrl::ClearAll() {
222 // Set all style bytes to 0, remove all folding information.
223 void wxStyledTextCtrl::ClearDocumentStyle() {
227 // Returns the number of characters in the document.
228 int wxStyledTextCtrl::GetLength() {
229 return SendMsg(2006, 0, 0);
232 // Returns the character byte at the position.
233 int wxStyledTextCtrl::GetCharAt(int pos
) {
234 return (unsigned char)SendMsg(2007, pos
, 0);
237 // Returns the position of the caret.
238 int wxStyledTextCtrl::GetCurrentPos() {
239 return SendMsg(2008, 0, 0);
242 // Returns the position of the opposite end of the selection to the caret.
243 int wxStyledTextCtrl::GetAnchor() {
244 return SendMsg(2009, 0, 0);
247 // Returns the style byte at the position.
248 int wxStyledTextCtrl::GetStyleAt(int pos
) {
249 return (unsigned char)SendMsg(2010, pos
, 0);
252 // Redoes the next action on the undo history.
253 void wxStyledTextCtrl::Redo() {
257 // Choose between collecting actions into the undo
258 // history and discarding them.
259 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
260 SendMsg(2012, collectUndo
, 0);
263 // Select all the text in the document.
264 void wxStyledTextCtrl::SelectAll() {
268 // Remember the current position in the undo history as the position
269 // at which the document was saved.
270 void wxStyledTextCtrl::SetSavePoint() {
274 // Retrieve a buffer of cells.
275 wxMemoryBuffer
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
277 if (endPos
< startPos
) {
282 int len
= endPos
- startPos
;
283 if (!len
) return buf
;
285 tr
.lpstrText
= (char*)buf
.GetWriteBuf(len
*2+1);
286 tr
.chrg
.cpMin
= startPos
;
287 tr
.chrg
.cpMax
= endPos
;
288 len
= SendMsg(2015, 0, (long)&tr
);
289 buf
.UngetWriteBuf(len
);
293 // Are there any redoable actions in the undo history?
294 bool wxStyledTextCtrl::CanRedo() {
295 return SendMsg(2016, 0, 0) != 0;
298 // Retrieve the line number at which a particular marker is located.
299 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
300 return SendMsg(2017, handle
, 0);
304 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
305 SendMsg(2018, handle
, 0);
308 // Is undo history being collected?
309 bool wxStyledTextCtrl::GetUndoCollection() {
310 return SendMsg(2019, 0, 0) != 0;
313 // Are white space characters currently visible?
314 // Returns one of SCWS_* constants.
315 int wxStyledTextCtrl::GetViewWhiteSpace() {
316 return SendMsg(2020, 0, 0);
319 // Make white space characters invisible, always visible or visible outside indentation.
320 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
321 SendMsg(2021, viewWS
, 0);
324 // Find the position from a point within the window.
325 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
326 return SendMsg(2022, pt
.x
, pt
.y
);
329 // Find the position from a point within the window but return
330 // INVALID_POSITION if not close to text.
331 int wxStyledTextCtrl::PositionFromPointClose(int x
, int y
) {
332 return SendMsg(2023, x
, y
);
335 // Set caret to start of a line and ensure it is visible.
336 void wxStyledTextCtrl::GotoLine(int line
) {
337 SendMsg(2024, line
, 0);
340 // Set caret to a position and ensure it is visible.
341 void wxStyledTextCtrl::GotoPos(int pos
) {
342 SendMsg(2025, pos
, 0);
345 // Set the selection anchor to a position. The anchor is the opposite
346 // end of the selection from the caret.
347 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
348 SendMsg(2026, posAnchor
, 0);
351 // Retrieve the text of the line containing the caret.
352 // Returns the index of the caret on the line.
353 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
354 int len
= LineLength(GetCurrentLine());
356 if (linePos
) *linePos
= 0;
357 return wxEmptyString
;
360 wxMemoryBuffer
mbuf(len
+1);
361 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
363 int pos
= SendMsg(2027, len
+1, (long)buf
);
364 mbuf
.UngetWriteBuf(len
);
366 if (linePos
) *linePos
= pos
;
370 // Retrieve the position of the last correctly styled character.
371 int wxStyledTextCtrl::GetEndStyled() {
372 return SendMsg(2028, 0, 0);
375 // Convert all line endings in the document to one mode.
376 void wxStyledTextCtrl::ConvertEOLs(int eolMode
) {
377 SendMsg(2029, eolMode
, 0);
380 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
381 int wxStyledTextCtrl::GetEOLMode() {
382 return SendMsg(2030, 0, 0);
385 // Set the current end of line mode.
386 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
387 SendMsg(2031, eolMode
, 0);
390 // Set the current styling position to pos and the styling mask to mask.
391 // The styling mask can be used to protect some bits in each styling byte from modification.
392 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
393 SendMsg(2032, pos
, mask
);
396 // Change style from current styling position for length characters to a style
397 // and move the current styling position to after this newly styled segment.
398 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
399 SendMsg(2033, length
, style
);
402 // Is drawing done first into a buffer or direct to the screen?
403 bool wxStyledTextCtrl::GetBufferedDraw() {
404 return SendMsg(2034, 0, 0) != 0;
407 // If drawing is buffered then each line of text is drawn into a bitmap buffer
408 // before drawing it to the screen to avoid flicker.
409 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
410 SendMsg(2035, buffered
, 0);
413 // Change the visible size of a tab to be a multiple of the width of a space character.
414 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
415 SendMsg(2036, tabWidth
, 0);
418 // Retrieve the visible size of a tab.
419 int wxStyledTextCtrl::GetTabWidth() {
420 return SendMsg(2121, 0, 0);
423 // Set the code page used to interpret the bytes of the document as characters.
424 void wxStyledTextCtrl::SetCodePage(int codePage
) {
426 wxASSERT_MSG(codePage
== wxSTC_CP_UTF8
,
427 wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on."));
429 wxASSERT_MSG(codePage
!= wxSTC_CP_UTF8
,
430 wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off."));
432 SendMsg(2037, codePage
);
435 // Set the symbol used for a particular marker number,
436 // and optionally the fore and background colours.
437 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
438 const wxColour
& foreground
,
439 const wxColour
& background
) {
441 SendMsg(2040, markerNumber
, markerSymbol
);
443 MarkerSetForeground(markerNumber
, foreground
);
445 MarkerSetBackground(markerNumber
, background
);
448 // Set the foreground colour used for a particular marker number.
449 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
450 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
453 // Set the background colour used for a particular marker number.
454 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
455 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
458 // Add a marker to a line, returning an ID which can be used to find or delete the marker.
459 int wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
460 return SendMsg(2043, line
, markerNumber
);
463 // Delete a marker from a line.
464 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
465 SendMsg(2044, line
, markerNumber
);
468 // Delete all markers with a particular number from all lines.
469 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
470 SendMsg(2045, markerNumber
, 0);
473 // Get a bit mask of all the markers set on a line.
474 int wxStyledTextCtrl::MarkerGet(int line
) {
475 return SendMsg(2046, line
, 0);
478 // Find the next line after lineStart that includes a marker in mask.
479 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
480 return SendMsg(2047, lineStart
, markerMask
);
483 // Find the previous line before lineStart that includes a marker in mask.
484 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
485 return SendMsg(2048, lineStart
, markerMask
);
488 // Define a marker from a bitmap
489 void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber
, const wxBitmap
& bmp
) {
490 // convert bmp to a xpm in a string
491 wxMemoryOutputStream strm
;
492 wxImage img
= bmp
.ConvertToImage();
493 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
494 size_t len
= strm
.GetSize();
495 char* buff
= new char[len
+1];
496 strm
.CopyTo(buff
, len
);
498 SendMsg(2049, markerNumber
, (long)buff
);
503 // Set a margin to be either numeric or symbolic.
504 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
505 SendMsg(2240, margin
, marginType
);
508 // Retrieve the type of a margin.
509 int wxStyledTextCtrl::GetMarginType(int margin
) {
510 return SendMsg(2241, margin
, 0);
513 // Set the width of a margin to a width expressed in pixels.
514 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
515 SendMsg(2242, margin
, pixelWidth
);
518 // Retrieve the width of a margin in pixels.
519 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
520 return SendMsg(2243, margin
, 0);
523 // Set a mask that determines which markers are displayed in a margin.
524 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
525 SendMsg(2244, margin
, mask
);
528 // Retrieve the marker mask of a margin.
529 int wxStyledTextCtrl::GetMarginMask(int margin
) {
530 return SendMsg(2245, margin
, 0);
533 // Make a margin sensitive or insensitive to mouse clicks.
534 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
535 SendMsg(2246, margin
, sensitive
);
538 // Retrieve the mouse click sensitivity of a margin.
539 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
540 return SendMsg(2247, margin
, 0) != 0;
543 // Clear all the styles and make equivalent to the global default style.
544 void wxStyledTextCtrl::StyleClearAll() {
548 // Set the foreground colour of a style.
549 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
550 SendMsg(2051, style
, wxColourAsLong(fore
));
553 // Set the background colour of a style.
554 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
555 SendMsg(2052, style
, wxColourAsLong(back
));
558 // Set a style to be bold or not.
559 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
560 SendMsg(2053, style
, bold
);
563 // Set a style to be italic or not.
564 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
565 SendMsg(2054, style
, italic
);
568 // Set the size of characters of a style.
569 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
570 SendMsg(2055, style
, sizePoints
);
573 // Set the font of a style.
574 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
575 SendMsg(2056, style
, (long)(const char*)wx2stc(fontName
));
578 // Set a style to have its end of line filled or not.
579 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
580 SendMsg(2057, style
, filled
);
583 // Reset the default style to its state at startup
584 void wxStyledTextCtrl::StyleResetDefault() {
588 // Set a style to be underlined or not.
589 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
590 SendMsg(2059, style
, underline
);
593 // Set a style to be mixed case, or to force upper or lower case.
594 void wxStyledTextCtrl::StyleSetCase(int style
, int caseForce
) {
595 SendMsg(2060, style
, caseForce
);
598 // Set the character set of the font in a style.
599 void wxStyledTextCtrl::StyleSetCharacterSet(int style
, int characterSet
) {
600 SendMsg(2066, style
, characterSet
);
603 // Set a style to be a hotspot or not.
604 void wxStyledTextCtrl::StyleSetHotSpot(int style
, bool hotspot
) {
605 SendMsg(2409, style
, hotspot
);
608 // Set the foreground colour of the selection and whether to use this setting.
609 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
610 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
613 // Set the background colour of the selection and whether to use this setting.
614 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
615 SendMsg(2068, useSetting
, wxColourAsLong(back
));
618 // Set the foreground colour of the caret.
619 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
620 SendMsg(2069, wxColourAsLong(fore
), 0);
623 // When key+modifier combination km is pressed perform msg.
624 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
625 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
628 // When key+modifier combination km is pressed do nothing.
629 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
630 SendMsg(2071, MAKELONG(key
, modifiers
));
633 // Drop all key mappings.
634 void wxStyledTextCtrl::CmdKeyClearAll() {
638 // Set the styles for a segment of the document.
639 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
640 SendMsg(2073, length
, (long)styleBytes
);
643 // Set a style to be visible or not.
644 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
645 SendMsg(2074, style
, visible
);
648 // Get the time in milliseconds that the caret is on and off.
649 int wxStyledTextCtrl::GetCaretPeriod() {
650 return SendMsg(2075, 0, 0);
653 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
654 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
655 SendMsg(2076, periodMilliseconds
, 0);
658 // Set the set of characters making up words for when moving or selecting by word.
659 // First sets deaults like SetCharsDefault.
660 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
661 SendMsg(2077, 0, (long)(const char*)wx2stc(characters
));
664 // Start a sequence of actions that is undone and redone as a unit.
666 void wxStyledTextCtrl::BeginUndoAction() {
670 // End a sequence of actions that is undone and redone as a unit.
671 void wxStyledTextCtrl::EndUndoAction() {
675 // Set an indicator to plain, squiggle or TT.
676 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
677 SendMsg(2080, indic
, style
);
680 // Retrieve the style of an indicator.
681 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
682 return SendMsg(2081, indic
, 0);
685 // Set the foreground colour of an indicator.
686 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
687 SendMsg(2082, indic
, wxColourAsLong(fore
));
690 // Retrieve the foreground colour of an indicator.
691 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
692 long c
= SendMsg(2083, indic
, 0);
693 return wxColourFromLong(c
);
696 // Set the foreground colour of all whitespace and whether to use this setting.
697 void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting
, const wxColour
& fore
) {
698 SendMsg(2084, useSetting
, wxColourAsLong(fore
));
701 // Set the background colour of all whitespace and whether to use this setting.
702 void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting
, const wxColour
& back
) {
703 SendMsg(2085, useSetting
, wxColourAsLong(back
));
706 // Divide each styling byte into lexical class bits (default: 5) and indicator
707 // bits (default: 3). If a lexer requires more than 32 lexical states, then this
708 // is used to expand the possible states.
709 void wxStyledTextCtrl::SetStyleBits(int bits
) {
710 SendMsg(2090, bits
, 0);
713 // Retrieve number of bits in style bytes used to hold the lexical state.
714 int wxStyledTextCtrl::GetStyleBits() {
715 return SendMsg(2091, 0, 0);
718 // Used to hold extra styling information for each line.
719 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
720 SendMsg(2092, line
, state
);
723 // Retrieve the extra styling information for a line.
724 int wxStyledTextCtrl::GetLineState(int line
) {
725 return SendMsg(2093, line
, 0);
728 // Retrieve the last line number that has line state.
729 int wxStyledTextCtrl::GetMaxLineState() {
730 return SendMsg(2094, 0, 0);
733 // Is the background of the line containing the caret in a different colour?
734 bool wxStyledTextCtrl::GetCaretLineVisible() {
735 return SendMsg(2095, 0, 0) != 0;
738 // Display the background of the line containing the caret in a different colour.
739 void wxStyledTextCtrl::SetCaretLineVisible(bool show
) {
740 SendMsg(2096, show
, 0);
743 // Get the colour of the background of the line containing the caret.
744 wxColour
wxStyledTextCtrl::GetCaretLineBack() {
745 long c
= SendMsg(2097, 0, 0);
746 return wxColourFromLong(c
);
749 // Set the colour of the background of the line containing the caret.
750 void wxStyledTextCtrl::SetCaretLineBack(const wxColour
& back
) {
751 SendMsg(2098, wxColourAsLong(back
), 0);
754 // Set a style to be changeable or not (read only).
755 // Experimental feature, currently buggy.
756 void wxStyledTextCtrl::StyleSetChangeable(int style
, bool changeable
) {
757 SendMsg(2099, style
, changeable
);
760 // Display a auto-completion list.
761 // The lenEntered parameter indicates how many characters before
762 // the caret should be used to provide context.
763 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
764 SendMsg(2100, lenEntered
, (long)(const char*)wx2stc(itemList
));
767 // Remove the auto-completion list from the screen.
768 void wxStyledTextCtrl::AutoCompCancel() {
772 // Is there an auto-completion list visible?
773 bool wxStyledTextCtrl::AutoCompActive() {
774 return SendMsg(2102, 0, 0) != 0;
777 // Retrieve the position of the caret when the auto-completion list was displayed.
778 int wxStyledTextCtrl::AutoCompPosStart() {
779 return SendMsg(2103, 0, 0);
782 // User has selected an item so remove the list and insert the selection.
783 void wxStyledTextCtrl::AutoCompComplete() {
787 // Define a set of character that when typed cancel the auto-completion list.
788 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
789 SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet
));
792 // Change the separator character in the string setting up an auto-completion list.
793 // Default is space but can be changed if items contain space.
794 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
795 SendMsg(2106, separatorCharacter
, 0);
798 // Retrieve the auto-completion list separator character.
799 int wxStyledTextCtrl::AutoCompGetSeparator() {
800 return SendMsg(2107, 0, 0);
803 // Select the item in the auto-completion list that starts with a string.
804 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
805 SendMsg(2108, 0, (long)(const char*)wx2stc(text
));
808 // Should the auto-completion list be cancelled if the user backspaces to a
809 // position before where the box was created.
810 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
811 SendMsg(2110, cancel
, 0);
814 // Retrieve whether auto-completion cancelled by backspacing before start.
815 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
816 return SendMsg(2111, 0, 0) != 0;
819 // Define a set of characters that when typed will cause the autocompletion to
820 // choose the selected item.
821 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
822 SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet
));
825 // Should a single item auto-completion list automatically choose the item.
826 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
827 SendMsg(2113, chooseSingle
, 0);
830 // Retrieve whether a single item auto-completion list automatically choose the item.
831 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
832 return SendMsg(2114, 0, 0) != 0;
835 // Set whether case is significant when performing auto-completion searches.
836 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
837 SendMsg(2115, ignoreCase
, 0);
840 // Retrieve state of ignore case flag.
841 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
842 return SendMsg(2116, 0, 0) != 0;
845 // Display a list of strings and send notification when user chooses one.
846 void wxStyledTextCtrl::UserListShow(int listType
, const wxString
& itemList
) {
847 SendMsg(2117, listType
, (long)(const char*)wx2stc(itemList
));
850 // Set whether or not autocompletion is hidden automatically when nothing matches.
851 void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide
) {
852 SendMsg(2118, autoHide
, 0);
855 // Retrieve whether or not autocompletion is hidden automatically when nothing matches.
856 bool wxStyledTextCtrl::AutoCompGetAutoHide() {
857 return SendMsg(2119, 0, 0) != 0;
860 // Set whether or not autocompletion deletes any word characters
861 // after the inserted text upon completion.
862 void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord
) {
863 SendMsg(2270, dropRestOfWord
, 0);
866 // Retrieve whether or not autocompletion deletes any word characters
867 // after the inserted text upon completion.
868 bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() {
869 return SendMsg(2271, 0, 0) != 0;
872 // Register an image for use in autocompletion lists.
873 void wxStyledTextCtrl::RegisterImage(int type
, const wxBitmap
& bmp
) {
874 // convert bmp to a xpm in a string
875 wxMemoryOutputStream strm
;
876 wxImage img
= bmp
.ConvertToImage();
877 img
.SaveFile(strm
, wxBITMAP_TYPE_XPM
);
878 size_t len
= strm
.GetSize();
879 char* buff
= new char[len
+1];
880 strm
.CopyTo(buff
, len
);
882 SendMsg(2405, type
, (long)buff
);
887 // Clear all the registered images.
888 void wxStyledTextCtrl::ClearRegisteredImages() {
892 // Retrieve the auto-completion list type-separator character.
893 int wxStyledTextCtrl::AutoCompGetTypeSeparator() {
894 return SendMsg(2285, 0, 0);
897 // Change the type-separator character in the string setting up an auto-completion list.
898 // Default is '?' but can be changed if items contain '?'.
899 void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter
) {
900 SendMsg(2286, separatorCharacter
, 0);
903 // Set the number of spaces used for one level of indentation.
904 void wxStyledTextCtrl::SetIndent(int indentSize
) {
905 SendMsg(2122, indentSize
, 0);
908 // Retrieve indentation size.
909 int wxStyledTextCtrl::GetIndent() {
910 return SendMsg(2123, 0, 0);
913 // Indentation will only use space characters if useTabs is false, otherwise
914 // it will use a combination of tabs and spaces.
915 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
916 SendMsg(2124, useTabs
, 0);
919 // Retrieve whether tabs will be used in indentation.
920 bool wxStyledTextCtrl::GetUseTabs() {
921 return SendMsg(2125, 0, 0) != 0;
924 // Change the indentation of a line to a number of columns.
925 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
926 SendMsg(2126, line
, indentSize
);
929 // Retrieve the number of columns that a line is indented.
930 int wxStyledTextCtrl::GetLineIndentation(int line
) {
931 return SendMsg(2127, line
, 0);
934 // Retrieve the position before the first non indentation character on a line.
935 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
936 return SendMsg(2128, line
, 0);
939 // Retrieve the column number of a position, taking tab width into account.
940 int wxStyledTextCtrl::GetColumn(int pos
) {
941 return SendMsg(2129, pos
, 0);
944 // Show or hide the horizontal scroll bar.
945 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
946 SendMsg(2130, show
, 0);
949 // Is the horizontal scroll bar visible?
950 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
951 return SendMsg(2131, 0, 0) != 0;
954 // Show or hide indentation guides.
955 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
956 SendMsg(2132, show
, 0);
959 // Are the indentation guides visible?
960 bool wxStyledTextCtrl::GetIndentationGuides() {
961 return SendMsg(2133, 0, 0) != 0;
964 // Set the highlighted indentation guide column.
965 // 0 = no highlighted guide.
966 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
967 SendMsg(2134, column
, 0);
970 // Get the highlighted indentation guide column.
971 int wxStyledTextCtrl::GetHighlightGuide() {
972 return SendMsg(2135, 0, 0);
975 // Get the position after the last visible characters on a line.
976 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
977 return SendMsg(2136, line
, 0);
980 // Get the code page used to interpret the bytes of the document as characters.
981 int wxStyledTextCtrl::GetCodePage() {
982 return SendMsg(2137, 0, 0);
985 // Get the foreground colour of the caret.
986 wxColour
wxStyledTextCtrl::GetCaretForeground() {
987 long c
= SendMsg(2138, 0, 0);
988 return wxColourFromLong(c
);
991 // In read-only mode?
992 bool wxStyledTextCtrl::GetReadOnly() {
993 return SendMsg(2140, 0, 0) != 0;
996 // Sets the position of the caret.
997 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
998 SendMsg(2141, pos
, 0);
1001 // Sets the position that starts the selection - this becomes the anchor.
1002 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
1003 SendMsg(2142, pos
, 0);
1006 // Returns the position at the start of the selection.
1007 int wxStyledTextCtrl::GetSelectionStart() {
1008 return SendMsg(2143, 0, 0);
1011 // Sets the position that ends the selection - this becomes the currentPosition.
1012 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
1013 SendMsg(2144, pos
, 0);
1016 // Returns the position at the end of the selection.
1017 int wxStyledTextCtrl::GetSelectionEnd() {
1018 return SendMsg(2145, 0, 0);
1021 // Sets the print magnification added to the point size of each style for printing.
1022 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
1023 SendMsg(2146, magnification
, 0);
1026 // Returns the print magnification.
1027 int wxStyledTextCtrl::GetPrintMagnification() {
1028 return SendMsg(2147, 0, 0);
1031 // Modify colours when printing for clearer printed text.
1032 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
1033 SendMsg(2148, mode
, 0);
1036 // Returns the print colour mode.
1037 int wxStyledTextCtrl::GetPrintColourMode() {
1038 return SendMsg(2149, 0, 0);
1041 // Find some text in the document.
1042 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
1043 const wxString
& text
,
1046 ft
.chrg
.cpMin
= minPos
;
1047 ft
.chrg
.cpMax
= maxPos
;
1048 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1049 ft
.lpstrText
= (char*)(const char*)buf
;
1051 return SendMsg(2150, flags
, (long)&ft
);
1054 // On Windows, will draw the document into a display context such as a printer.
1055 int wxStyledTextCtrl::FormatRange(bool doDraw
,
1064 if (endPos
< startPos
) {
1065 int temp
= startPos
;
1070 fr
.hdcTarget
= target
;
1071 fr
.rc
.top
= renderRect
.GetTop();
1072 fr
.rc
.left
= renderRect
.GetLeft();
1073 fr
.rc
.right
= renderRect
.GetRight();
1074 fr
.rc
.bottom
= renderRect
.GetBottom();
1075 fr
.rcPage
.top
= pageRect
.GetTop();
1076 fr
.rcPage
.left
= pageRect
.GetLeft();
1077 fr
.rcPage
.right
= pageRect
.GetRight();
1078 fr
.rcPage
.bottom
= pageRect
.GetBottom();
1079 fr
.chrg
.cpMin
= startPos
;
1080 fr
.chrg
.cpMax
= endPos
;
1082 return SendMsg(2151, doDraw
, (long)&fr
);
1085 // Retrieve the display line at the top of the display.
1086 int wxStyledTextCtrl::GetFirstVisibleLine() {
1087 return SendMsg(2152, 0, 0);
1090 // Retrieve the contents of a line.
1091 wxString
wxStyledTextCtrl::GetLine(int line
) {
1092 int len
= LineLength(line
);
1093 if (!len
) return wxEmptyString
;
1095 wxMemoryBuffer
mbuf(len
+1);
1096 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1097 SendMsg(2153, line
, (long)buf
);
1098 mbuf
.UngetWriteBuf(len
);
1103 // Returns the number of lines in the document. There is always at least one.
1104 int wxStyledTextCtrl::GetLineCount() {
1105 return SendMsg(2154, 0, 0);
1108 // Sets the size in pixels of the left margin.
1109 void wxStyledTextCtrl::SetMarginLeft(int pixelWidth
) {
1110 SendMsg(2155, 0, pixelWidth
);
1113 // Returns the size in pixels of the left margin.
1114 int wxStyledTextCtrl::GetMarginLeft() {
1115 return SendMsg(2156, 0, 0);
1118 // Sets the size in pixels of the right margin.
1119 void wxStyledTextCtrl::SetMarginRight(int pixelWidth
) {
1120 SendMsg(2157, 0, pixelWidth
);
1123 // Returns the size in pixels of the right margin.
1124 int wxStyledTextCtrl::GetMarginRight() {
1125 return SendMsg(2158, 0, 0);
1128 // Is the document different from when it was last saved?
1129 bool wxStyledTextCtrl::GetModify() {
1130 return SendMsg(2159, 0, 0) != 0;
1133 // Select a range of text.
1134 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
1135 SendMsg(2160, start
, end
);
1138 // Retrieve the selected text.
1139 wxString
wxStyledTextCtrl::GetSelectedText() {
1143 GetSelection(&start
, &end
);
1144 int len
= end
- start
;
1145 if (!len
) return wxEmptyString
;
1147 wxMemoryBuffer
mbuf(len
+2);
1148 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1149 SendMsg(2161, 0, (long)buf
);
1150 mbuf
.UngetWriteBuf(len
);
1155 // Retrieve a range of text.
1156 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
1157 if (endPos
< startPos
) {
1158 int temp
= startPos
;
1162 int len
= endPos
- startPos
;
1163 if (!len
) return wxEmptyString
;
1164 wxMemoryBuffer
mbuf(len
+1);
1165 char* buf
= (char*)mbuf
.GetWriteBuf(len
);
1168 tr
.chrg
.cpMin
= startPos
;
1169 tr
.chrg
.cpMax
= endPos
;
1170 SendMsg(2162, 0, (long)&tr
);
1171 mbuf
.UngetWriteBuf(len
);
1176 // Draw the selection in normal style or with selection highlighted.
1177 void wxStyledTextCtrl::HideSelection(bool normal
) {
1178 SendMsg(2163, normal
, 0);
1181 // Retrieve the line containing a position.
1182 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1183 return SendMsg(2166, pos
, 0);
1186 // Retrieve the position at the start of a line.
1187 int wxStyledTextCtrl::PositionFromLine(int line
) {
1188 return SendMsg(2167, line
, 0);
1191 // Scroll horizontally and vertically.
1192 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1193 SendMsg(2168, columns
, lines
);
1196 // Ensure the caret is visible.
1197 void wxStyledTextCtrl::EnsureCaretVisible() {
1198 SendMsg(2169, 0, 0);
1201 // Replace the selected text with the argument text.
1202 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1203 SendMsg(2170, 0, (long)(const char*)wx2stc(text
));
1206 // Set to read only or read write.
1207 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1208 SendMsg(2171, readOnly
, 0);
1211 // Will a paste succeed?
1212 bool wxStyledTextCtrl::CanPaste() {
1213 return SendMsg(2173, 0, 0) != 0;
1216 // Are there any undoable actions in the undo history?
1217 bool wxStyledTextCtrl::CanUndo() {
1218 return SendMsg(2174, 0, 0) != 0;
1221 // Delete the undo history.
1222 void wxStyledTextCtrl::EmptyUndoBuffer() {
1223 SendMsg(2175, 0, 0);
1226 // Undo one action in the undo history.
1227 void wxStyledTextCtrl::Undo() {
1228 SendMsg(2176, 0, 0);
1231 // Cut the selection to the clipboard.
1232 void wxStyledTextCtrl::Cut() {
1233 SendMsg(2177, 0, 0);
1236 // Copy the selection to the clipboard.
1237 void wxStyledTextCtrl::Copy() {
1238 SendMsg(2178, 0, 0);
1241 // Paste the contents of the clipboard into the document replacing the selection.
1242 void wxStyledTextCtrl::Paste() {
1243 SendMsg(2179, 0, 0);
1246 // Clear the selection.
1247 void wxStyledTextCtrl::Clear() {
1248 SendMsg(2180, 0, 0);
1251 // Replace the contents of the document with the argument text.
1252 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1253 SendMsg(2181, 0, (long)(const char*)wx2stc(text
));
1256 // Retrieve all the text in the document.
1257 wxString
wxStyledTextCtrl::GetText() {
1258 int len
= GetTextLength();
1259 wxMemoryBuffer
mbuf(len
+1); // leave room for the null...
1260 char* buf
= (char*)mbuf
.GetWriteBuf(len
+1);
1261 SendMsg(2182, len
+1, (long)buf
);
1262 mbuf
.UngetWriteBuf(len
);
1267 // Retrieve the number of characters in the document.
1268 int wxStyledTextCtrl::GetTextLength() {
1269 return SendMsg(2183, 0, 0);
1272 // Set to overtype (true) or insert mode.
1273 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1274 SendMsg(2186, overtype
, 0);
1277 // Returns true if overtype mode is active otherwise false is returned.
1278 bool wxStyledTextCtrl::GetOvertype() {
1279 return SendMsg(2187, 0, 0) != 0;
1282 // Set the width of the insert mode caret.
1283 void wxStyledTextCtrl::SetCaretWidth(int pixelWidth
) {
1284 SendMsg(2188, pixelWidth
, 0);
1287 // Returns the width of the insert mode caret.
1288 int wxStyledTextCtrl::GetCaretWidth() {
1289 return SendMsg(2189, 0, 0);
1292 // Sets the position that starts the target which is used for updating the
1293 // document without affecting the scroll position.
1294 void wxStyledTextCtrl::SetTargetStart(int pos
) {
1295 SendMsg(2190, pos
, 0);
1298 // Get the position that starts the target.
1299 int wxStyledTextCtrl::GetTargetStart() {
1300 return SendMsg(2191, 0, 0);
1303 // Sets the position that ends the target which is used for updating the
1304 // document without affecting the scroll position.
1305 void wxStyledTextCtrl::SetTargetEnd(int pos
) {
1306 SendMsg(2192, pos
, 0);
1309 // Get the position that ends the target.
1310 int wxStyledTextCtrl::GetTargetEnd() {
1311 return SendMsg(2193, 0, 0);
1314 // Replace the target text with the argument text.
1315 // Text is counted so it can contain NULs.
1316 // Returns the length of the replacement text.
1318 int wxStyledTextCtrl::ReplaceTarget(const wxString
& text
) {
1319 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1320 return SendMsg(2194, strlen(buf
), (long)(const char*)buf
);
1323 // Replace the target text with the argument text after \d processing.
1324 // Text is counted so it can contain NULs.
1325 // Looks for \d where d is between 1 and 9 and replaces these with the strings
1326 // matched in the last search operation which were surrounded by \( and \).
1327 // Returns the length of the replacement text including any change
1328 // caused by processing the \d patterns.
1330 int wxStyledTextCtrl::ReplaceTargetRE(const wxString
& text
) {
1331 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1332 return SendMsg(2195, strlen(buf
), (long)(const char*)buf
);
1335 // Search for a counted string in the target and set the target to the found
1336 // range. Text is counted so it can contain NULs.
1337 // Returns length of range or -1 for failure in which case target is not moved.
1339 int wxStyledTextCtrl::SearchInTarget(const wxString
& text
) {
1340 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
1341 return SendMsg(2197, strlen(buf
), (long)(const char*)buf
);
1344 // Set the search flags used by SearchInTarget.
1345 void wxStyledTextCtrl::SetSearchFlags(int flags
) {
1346 SendMsg(2198, flags
, 0);
1349 // Get the search flags used by SearchInTarget.
1350 int wxStyledTextCtrl::GetSearchFlags() {
1351 return SendMsg(2199, 0, 0);
1354 // Show a call tip containing a definition near position pos.
1355 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1356 SendMsg(2200, pos
, (long)(const char*)wx2stc(definition
));
1359 // Remove the call tip from the screen.
1360 void wxStyledTextCtrl::CallTipCancel() {
1361 SendMsg(2201, 0, 0);
1364 // Is there an active call tip?
1365 bool wxStyledTextCtrl::CallTipActive() {
1366 return SendMsg(2202, 0, 0) != 0;
1369 // Retrieve the position where the caret was before displaying the call tip.
1370 int wxStyledTextCtrl::CallTipPosAtStart() {
1371 return SendMsg(2203, 0, 0);
1374 // Highlight a segment of the definition.
1375 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1376 SendMsg(2204, start
, end
);
1379 // Set the background colour for the call tip.
1380 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1381 SendMsg(2205, wxColourAsLong(back
), 0);
1384 // Set the foreground colour for the call tip.
1385 void wxStyledTextCtrl::CallTipSetForeground(const wxColour
& fore
) {
1386 SendMsg(2206, wxColourAsLong(fore
), 0);
1389 // Set the foreground colour for the highlighted part of the call tip.
1390 void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour
& fore
) {
1391 SendMsg(2207, wxColourAsLong(fore
), 0);
1394 // Find the display line of a document line taking hidden lines into account.
1395 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1396 return SendMsg(2220, line
, 0);
1399 // Find the document line of a display line taking hidden lines into account.
1400 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1401 return SendMsg(2221, lineDisplay
, 0);
1404 // Set the fold level of a line.
1405 // This encodes an integer level along with flags indicating whether the
1406 // line is a header and whether it is effectively white space.
1407 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1408 SendMsg(2222, line
, level
);
1411 // Retrieve the fold level of a line.
1412 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1413 return SendMsg(2223, line
, 0);
1416 // Find the last child line of a header line.
1417 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1418 return SendMsg(2224, line
, level
);
1421 // Find the parent line of a child line.
1422 int wxStyledTextCtrl::GetFoldParent(int line
) {
1423 return SendMsg(2225, line
, 0);
1426 // Make a range of lines visible.
1427 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1428 SendMsg(2226, lineStart
, lineEnd
);
1431 // Make a range of lines invisible.
1432 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1433 SendMsg(2227, lineStart
, lineEnd
);
1436 // Is a line visible?
1437 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1438 return SendMsg(2228, line
, 0) != 0;
1441 // Show the children of a header line.
1442 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1443 SendMsg(2229, line
, expanded
);
1446 // Is a header line expanded?
1447 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1448 return SendMsg(2230, line
, 0) != 0;
1451 // Switch a header line between expanded and contracted.
1452 void wxStyledTextCtrl::ToggleFold(int line
) {
1453 SendMsg(2231, line
, 0);
1456 // Ensure a particular line is visible by expanding any header line hiding it.
1457 void wxStyledTextCtrl::EnsureVisible(int line
) {
1458 SendMsg(2232, line
, 0);
1461 // Set some style options for folding.
1462 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1463 SendMsg(2233, flags
, 0);
1466 // Ensure a particular line is visible by expanding any header line hiding it.
1467 // Use the currently set visibility policy to determine which range to display.
1468 void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line
) {
1469 SendMsg(2234, line
, 0);
1472 // Sets whether a tab pressed when caret is within indentation indents.
1473 void wxStyledTextCtrl::SetTabIndents(bool tabIndents
) {
1474 SendMsg(2260, tabIndents
, 0);
1477 // Does a tab pressed when caret is within indentation indent?
1478 bool wxStyledTextCtrl::GetTabIndents() {
1479 return SendMsg(2261, 0, 0) != 0;
1482 // Sets whether a backspace pressed when caret is within indentation unindents.
1483 void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents
) {
1484 SendMsg(2262, bsUnIndents
, 0);
1487 // Does a backspace pressed when caret is within indentation unindent?
1488 bool wxStyledTextCtrl::GetBackSpaceUnIndents() {
1489 return SendMsg(2263, 0, 0) != 0;
1492 // Sets the time the mouse must sit still to generate a mouse dwell event.
1493 void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds
) {
1494 SendMsg(2264, periodMilliseconds
, 0);
1497 // Retrieve the time the mouse must sit still to generate a mouse dwell event.
1498 int wxStyledTextCtrl::GetMouseDwellTime() {
1499 return SendMsg(2265, 0, 0);
1502 // Get position of start of word.
1503 int wxStyledTextCtrl::WordStartPosition(int pos
, bool onlyWordCharacters
) {
1504 return SendMsg(2266, pos
, onlyWordCharacters
);
1507 // Get position of end of word.
1508 int wxStyledTextCtrl::WordEndPosition(int pos
, bool onlyWordCharacters
) {
1509 return SendMsg(2267, pos
, onlyWordCharacters
);
1512 // Sets whether text is word wrapped.
1513 void wxStyledTextCtrl::SetWrapMode(int mode
) {
1514 SendMsg(2268, mode
, 0);
1517 // Retrieve whether text is word wrapped.
1518 int wxStyledTextCtrl::GetWrapMode() {
1519 return SendMsg(2269, 0, 0);
1522 // Set the display mode of visual flags for wrapped lines.
1523 void wxStyledTextCtrl::SetWrapVisualFlags(int wrapVisualFlags
) {
1524 SendMsg(2460, wrapVisualFlags
, 0);
1527 // Retrive the display mode of visual flags for wrapped lines.
1528 int wxStyledTextCtrl::GetWrapVisualFlags() {
1529 return SendMsg(2461, 0, 0);
1532 // Set the location of visual flags for wrapped lines.
1533 void wxStyledTextCtrl::SetWrapVisualFlagsLocation(int wrapVisualFlagsLocation
) {
1534 SendMsg(2462, wrapVisualFlagsLocation
, 0);
1537 // Retrive the location of visual flags for wrapped lines.
1538 int wxStyledTextCtrl::GetWrapVisualFlagsLocation() {
1539 return SendMsg(2463, 0, 0);
1542 // Set the start indent for wrapped lines.
1543 void wxStyledTextCtrl::SetWrapStartIndent(int indent
) {
1544 SendMsg(2464, indent
, 0);
1547 // Retrive the start indent for wrapped lines.
1548 int wxStyledTextCtrl::GetWrapStartIndent() {
1549 return SendMsg(2465, 0, 0);
1552 // Sets the degree of caching of layout information.
1553 void wxStyledTextCtrl::SetLayoutCache(int mode
) {
1554 SendMsg(2272, mode
, 0);
1557 // Retrieve the degree of caching of layout information.
1558 int wxStyledTextCtrl::GetLayoutCache() {
1559 return SendMsg(2273, 0, 0);
1562 // Sets the document width assumed for scrolling.
1563 void wxStyledTextCtrl::SetScrollWidth(int pixelWidth
) {
1564 SendMsg(2274, pixelWidth
, 0);
1567 // Retrieve the document width assumed for scrolling.
1568 int wxStyledTextCtrl::GetScrollWidth() {
1569 return SendMsg(2275, 0, 0);
1572 // Measure the pixel width of some text in a particular style.
1573 // NUL terminated text argument.
1574 // Does not handle tab or control characters.
1575 int wxStyledTextCtrl::TextWidth(int style
, const wxString
& text
) {
1576 return SendMsg(2276, style
, (long)(const char*)wx2stc(text
));
1579 // Sets the scroll range so that maximum scroll position has
1580 // the last line at the bottom of the view (default).
1581 // Setting this to false allows scrolling one page below the last line.
1582 void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine
) {
1583 SendMsg(2277, endAtLastLine
, 0);
1586 // Retrieve whether the maximum scroll position has the last
1587 // line at the bottom of the view.
1588 int wxStyledTextCtrl::GetEndAtLastLine() {
1589 return SendMsg(2278, 0, 0);
1592 // Retrieve the height of a particular line of text in pixels.
1593 int wxStyledTextCtrl::TextHeight(int line
) {
1594 return SendMsg(2279, line
, 0);
1597 // Show or hide the vertical scroll bar.
1598 void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show
) {
1599 SendMsg(2280, show
, 0);
1602 // Is the vertical scroll bar visible?
1603 bool wxStyledTextCtrl::GetUseVerticalScrollBar() {
1604 return SendMsg(2281, 0, 0) != 0;
1607 // Append a string to the end of the document without changing the selection.
1608 void wxStyledTextCtrl::AppendText(int length
, const wxString
& text
) {
1609 SendMsg(2282, length
, (long)(const char*)wx2stc(text
));
1612 // Is drawing done in two phases with backgrounds drawn before foregrounds?
1613 bool wxStyledTextCtrl::GetTwoPhaseDraw() {
1614 return SendMsg(2283, 0, 0) != 0;
1617 // In twoPhaseDraw mode, drawing is performed in two phases, first the background
1618 // and then the foreground. This avoids chopping off characters that overlap the next run.
1619 void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase
) {
1620 SendMsg(2284, twoPhase
, 0);
1623 // Make the target range start and end be the same as the selection range start and end.
1624 void wxStyledTextCtrl::TargetFromSelection() {
1625 SendMsg(2287, 0, 0);
1628 // Join the lines in the target.
1629 void wxStyledTextCtrl::LinesJoin() {
1630 SendMsg(2288, 0, 0);
1633 // Split the lines in the target into lines that are less wide than pixelWidth
1635 void wxStyledTextCtrl::LinesSplit(int pixelWidth
) {
1636 SendMsg(2289, pixelWidth
, 0);
1639 // Set the colours used as a chequerboard pattern in the fold margin
1640 void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting
, const wxColour
& back
) {
1641 SendMsg(2290, useSetting
, wxColourAsLong(back
));
1643 void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting
, const wxColour
& fore
) {
1644 SendMsg(2291, useSetting
, wxColourAsLong(fore
));
1647 // Move caret down one line.
1648 void wxStyledTextCtrl::LineDown() {
1649 SendMsg(2300, 0, 0);
1652 // Move caret down one line extending selection to new caret position.
1653 void wxStyledTextCtrl::LineDownExtend() {
1654 SendMsg(2301, 0, 0);
1657 // Move caret up one line.
1658 void wxStyledTextCtrl::LineUp() {
1659 SendMsg(2302, 0, 0);
1662 // Move caret up one line extending selection to new caret position.
1663 void wxStyledTextCtrl::LineUpExtend() {
1664 SendMsg(2303, 0, 0);
1667 // Move caret left one character.
1668 void wxStyledTextCtrl::CharLeft() {
1669 SendMsg(2304, 0, 0);
1672 // Move caret left one character extending selection to new caret position.
1673 void wxStyledTextCtrl::CharLeftExtend() {
1674 SendMsg(2305, 0, 0);
1677 // Move caret right one character.
1678 void wxStyledTextCtrl::CharRight() {
1679 SendMsg(2306, 0, 0);
1682 // Move caret right one character extending selection to new caret position.
1683 void wxStyledTextCtrl::CharRightExtend() {
1684 SendMsg(2307, 0, 0);
1687 // Move caret left one word.
1688 void wxStyledTextCtrl::WordLeft() {
1689 SendMsg(2308, 0, 0);
1692 // Move caret left one word extending selection to new caret position.
1693 void wxStyledTextCtrl::WordLeftExtend() {
1694 SendMsg(2309, 0, 0);
1697 // Move caret right one word.
1698 void wxStyledTextCtrl::WordRight() {
1699 SendMsg(2310, 0, 0);
1702 // Move caret right one word extending selection to new caret position.
1703 void wxStyledTextCtrl::WordRightExtend() {
1704 SendMsg(2311, 0, 0);
1707 // Move caret to first position on line.
1708 void wxStyledTextCtrl::Home() {
1709 SendMsg(2312, 0, 0);
1712 // Move caret to first position on line extending selection to new caret position.
1713 void wxStyledTextCtrl::HomeExtend() {
1714 SendMsg(2313, 0, 0);
1717 // Move caret to last position on line.
1718 void wxStyledTextCtrl::LineEnd() {
1719 SendMsg(2314, 0, 0);
1722 // Move caret to last position on line extending selection to new caret position.
1723 void wxStyledTextCtrl::LineEndExtend() {
1724 SendMsg(2315, 0, 0);
1727 // Move caret to first position in document.
1728 void wxStyledTextCtrl::DocumentStart() {
1729 SendMsg(2316, 0, 0);
1732 // Move caret to first position in document extending selection to new caret position.
1733 void wxStyledTextCtrl::DocumentStartExtend() {
1734 SendMsg(2317, 0, 0);
1737 // Move caret to last position in document.
1738 void wxStyledTextCtrl::DocumentEnd() {
1739 SendMsg(2318, 0, 0);
1742 // Move caret to last position in document extending selection to new caret position.
1743 void wxStyledTextCtrl::DocumentEndExtend() {
1744 SendMsg(2319, 0, 0);
1747 // Move caret one page up.
1748 void wxStyledTextCtrl::PageUp() {
1749 SendMsg(2320, 0, 0);
1752 // Move caret one page up extending selection to new caret position.
1753 void wxStyledTextCtrl::PageUpExtend() {
1754 SendMsg(2321, 0, 0);
1757 // Move caret one page down.
1758 void wxStyledTextCtrl::PageDown() {
1759 SendMsg(2322, 0, 0);
1762 // Move caret one page down extending selection to new caret position.
1763 void wxStyledTextCtrl::PageDownExtend() {
1764 SendMsg(2323, 0, 0);
1767 // Switch from insert to overtype mode or the reverse.
1768 void wxStyledTextCtrl::EditToggleOvertype() {
1769 SendMsg(2324, 0, 0);
1772 // Cancel any modes such as call tip or auto-completion list display.
1773 void wxStyledTextCtrl::Cancel() {
1774 SendMsg(2325, 0, 0);
1777 // Delete the selection or if no selection, the character before the caret.
1778 void wxStyledTextCtrl::DeleteBack() {
1779 SendMsg(2326, 0, 0);
1782 // If selection is empty or all on one line replace the selection with a tab character.
1783 // If more than one line selected, indent the lines.
1784 void wxStyledTextCtrl::Tab() {
1785 SendMsg(2327, 0, 0);
1788 // Dedent the selected lines.
1789 void wxStyledTextCtrl::BackTab() {
1790 SendMsg(2328, 0, 0);
1793 // Insert a new line, may use a CRLF, CR or LF depending on EOL mode.
1794 void wxStyledTextCtrl::NewLine() {
1795 SendMsg(2329, 0, 0);
1798 // Insert a Form Feed character.
1799 void wxStyledTextCtrl::FormFeed() {
1800 SendMsg(2330, 0, 0);
1803 // Move caret to before first visible character on line.
1804 // If already there move to first character on line.
1805 void wxStyledTextCtrl::VCHome() {
1806 SendMsg(2331, 0, 0);
1809 // Like VCHome but extending selection to new caret position.
1810 void wxStyledTextCtrl::VCHomeExtend() {
1811 SendMsg(2332, 0, 0);
1814 // Magnify the displayed text by increasing the sizes by 1 point.
1815 void wxStyledTextCtrl::ZoomIn() {
1816 SendMsg(2333, 0, 0);
1819 // Make the displayed text smaller by decreasing the sizes by 1 point.
1820 void wxStyledTextCtrl::ZoomOut() {
1821 SendMsg(2334, 0, 0);
1824 // Delete the word to the left of the caret.
1825 void wxStyledTextCtrl::DelWordLeft() {
1826 SendMsg(2335, 0, 0);
1829 // Delete the word to the right of the caret.
1830 void wxStyledTextCtrl::DelWordRight() {
1831 SendMsg(2336, 0, 0);
1834 // Cut the line containing the caret.
1835 void wxStyledTextCtrl::LineCut() {
1836 SendMsg(2337, 0, 0);
1839 // Delete the line containing the caret.
1840 void wxStyledTextCtrl::LineDelete() {
1841 SendMsg(2338, 0, 0);
1844 // Switch the current line with the previous.
1845 void wxStyledTextCtrl::LineTranspose() {
1846 SendMsg(2339, 0, 0);
1849 // Duplicate the current line.
1850 void wxStyledTextCtrl::LineDuplicate() {
1851 SendMsg(2404, 0, 0);
1854 // Transform the selection to lower case.
1855 void wxStyledTextCtrl::LowerCase() {
1856 SendMsg(2340, 0, 0);
1859 // Transform the selection to upper case.
1860 void wxStyledTextCtrl::UpperCase() {
1861 SendMsg(2341, 0, 0);
1864 // Scroll the document down, keeping the caret visible.
1865 void wxStyledTextCtrl::LineScrollDown() {
1866 SendMsg(2342, 0, 0);
1869 // Scroll the document up, keeping the caret visible.
1870 void wxStyledTextCtrl::LineScrollUp() {
1871 SendMsg(2343, 0, 0);
1874 // Delete the selection or if no selection, the character before the caret.
1875 // Will not delete the character before at the start of a line.
1876 void wxStyledTextCtrl::DeleteBackNotLine() {
1877 SendMsg(2344, 0, 0);
1880 // Move caret to first position on display line.
1881 void wxStyledTextCtrl::HomeDisplay() {
1882 SendMsg(2345, 0, 0);
1885 // Move caret to first position on display line extending selection to
1886 // new caret position.
1887 void wxStyledTextCtrl::HomeDisplayExtend() {
1888 SendMsg(2346, 0, 0);
1891 // Move caret to last position on display line.
1892 void wxStyledTextCtrl::LineEndDisplay() {
1893 SendMsg(2347, 0, 0);
1896 // Move caret to last position on display line extending selection to new
1898 void wxStyledTextCtrl::LineEndDisplayExtend() {
1899 SendMsg(2348, 0, 0);
1902 // These are like their namesakes Home(Extend)?, LineEnd(Extend)?, VCHome(Extend)?
1903 // except they behave differently when word-wrap is enabled:
1904 // They go first to the start / end of the display line, like (Home|LineEnd)Display
1905 // The difference is that, the cursor is already at the point, it goes on to the start
1906 // or end of the document line, as appropriate for (Home|LineEnd|VCHome)(Extend)?.
1907 void wxStyledTextCtrl::HomeWrap() {
1908 SendMsg(2349, 0, 0);
1910 void wxStyledTextCtrl::HomeWrapExtend() {
1911 SendMsg(2450, 0, 0);
1913 void wxStyledTextCtrl::LineEndWrap() {
1914 SendMsg(2451, 0, 0);
1916 void wxStyledTextCtrl::LineEndWrapExtend() {
1917 SendMsg(2452, 0, 0);
1919 void wxStyledTextCtrl::VCHomeWrap() {
1920 SendMsg(2453, 0, 0);
1922 void wxStyledTextCtrl::VCHomeWrapExtend() {
1923 SendMsg(2454, 0, 0);
1926 // Copy the line containing the caret.
1927 void wxStyledTextCtrl::LineCopy() {
1928 SendMsg(2455, 0, 0);
1931 // Move the caret inside current view if it's not there already.
1932 void wxStyledTextCtrl::MoveCaretInsideView() {
1933 SendMsg(2401, 0, 0);
1936 // How many characters are on a line, not including end of line characters?
1937 int wxStyledTextCtrl::LineLength(int line
) {
1938 return SendMsg(2350, line
, 0);
1941 // Highlight the characters at two positions.
1942 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1943 SendMsg(2351, pos1
, pos2
);
1946 // Highlight the character at a position indicating there is no matching brace.
1947 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1948 SendMsg(2352, pos
, 0);
1951 // Find the position of a matching brace or INVALID_POSITION if no match.
1952 int wxStyledTextCtrl::BraceMatch(int pos
) {
1953 return SendMsg(2353, pos
, 0);
1956 // Are the end of line characters visible?
1957 bool wxStyledTextCtrl::GetViewEOL() {
1958 return SendMsg(2355, 0, 0) != 0;
1961 // Make the end of line characters visible or invisible.
1962 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1963 SendMsg(2356, visible
, 0);
1966 // Retrieve a pointer to the document object.
1967 void* wxStyledTextCtrl::GetDocPointer() {
1968 return (void*)SendMsg(2357);
1971 // Change the document object used.
1972 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1973 SendMsg(2358, 0, (long)docPointer
);
1976 // Set which document modification events are sent to the container.
1977 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1978 SendMsg(2359, mask
, 0);
1981 // Retrieve the column number which text should be kept within.
1982 int wxStyledTextCtrl::GetEdgeColumn() {
1983 return SendMsg(2360, 0, 0);
1986 // Set the column number of the edge.
1987 // If text goes past the edge then it is highlighted.
1988 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1989 SendMsg(2361, column
, 0);
1992 // Retrieve the edge highlight mode.
1993 int wxStyledTextCtrl::GetEdgeMode() {
1994 return SendMsg(2362, 0, 0);
1997 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1998 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1999 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
2000 SendMsg(2363, mode
, 0);
2003 // Retrieve the colour used in edge indication.
2004 wxColour
wxStyledTextCtrl::GetEdgeColour() {
2005 long c
= SendMsg(2364, 0, 0);
2006 return wxColourFromLong(c
);
2009 // Change the colour used in edge indication.
2010 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
2011 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
2014 // Sets the current caret position to be the search anchor.
2015 void wxStyledTextCtrl::SearchAnchor() {
2016 SendMsg(2366, 0, 0);
2019 // Find some text starting at the search anchor.
2020 // Does not ensure the selection is visible.
2021 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
2022 return SendMsg(2367, flags
, (long)(const char*)wx2stc(text
));
2025 // Find some text starting at the search anchor and moving backwards.
2026 // Does not ensure the selection is visible.
2027 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
2028 return SendMsg(2368, flags
, (long)(const char*)wx2stc(text
));
2031 // Retrieves the number of lines completely visible.
2032 int wxStyledTextCtrl::LinesOnScreen() {
2033 return SendMsg(2370, 0, 0);
2036 // Set whether a pop up menu is displayed automatically when the user presses
2037 // the wrong mouse button.
2038 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
2039 SendMsg(2371, allowPopUp
, 0);
2042 // Is the selection rectangular? The alternative is the more common stream selection.
2043 bool wxStyledTextCtrl::SelectionIsRectangle() {
2044 return SendMsg(2372, 0, 0) != 0;
2047 // Set the zoom level. This number of points is added to the size of all fonts.
2048 // It may be positive to magnify or negative to reduce.
2049 void wxStyledTextCtrl::SetZoom(int zoom
) {
2050 SendMsg(2373, zoom
, 0);
2053 // Retrieve the zoom level.
2054 int wxStyledTextCtrl::GetZoom() {
2055 return SendMsg(2374, 0, 0);
2058 // Create a new document object.
2059 // Starts with reference count of 1 and not selected into editor.
2060 void* wxStyledTextCtrl::CreateDocument() {
2061 return (void*)SendMsg(2375);
2064 // Extend life of document.
2065 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
2066 SendMsg(2376, 0, (long)docPointer
);
2069 // Release a reference to the document, deleting document if it fades to black.
2070 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
2071 SendMsg(2377, 0, (long)docPointer
);
2074 // Get which document modification events are sent to the container.
2075 int wxStyledTextCtrl::GetModEventMask() {
2076 return SendMsg(2378, 0, 0);
2079 // Change internal focus flag.
2080 void wxStyledTextCtrl::SetSTCFocus(bool focus
) {
2081 SendMsg(2380, focus
, 0);
2084 // Get internal focus flag.
2085 bool wxStyledTextCtrl::GetSTCFocus() {
2086 return SendMsg(2381, 0, 0) != 0;
2089 // Change error status - 0 = OK.
2090 void wxStyledTextCtrl::SetStatus(int statusCode
) {
2091 SendMsg(2382, statusCode
, 0);
2094 // Get error status.
2095 int wxStyledTextCtrl::GetStatus() {
2096 return SendMsg(2383, 0, 0);
2099 // Set whether the mouse is captured when its button is pressed.
2100 void wxStyledTextCtrl::SetMouseDownCaptures(bool captures
) {
2101 SendMsg(2384, captures
, 0);
2104 // Get whether mouse gets captured.
2105 bool wxStyledTextCtrl::GetMouseDownCaptures() {
2106 return SendMsg(2385, 0, 0) != 0;
2109 // Sets the cursor to one of the SC_CURSOR* values.
2110 void wxStyledTextCtrl::SetSTCCursor(int cursorType
) {
2111 SendMsg(2386, cursorType
, 0);
2115 int wxStyledTextCtrl::GetSTCCursor() {
2116 return SendMsg(2387, 0, 0);
2119 // Change the way control characters are displayed:
2120 // If symbol is < 32, keep the drawn way, else, use the given character.
2121 void wxStyledTextCtrl::SetControlCharSymbol(int symbol
) {
2122 SendMsg(2388, symbol
, 0);
2125 // Get the way control characters are displayed.
2126 int wxStyledTextCtrl::GetControlCharSymbol() {
2127 return SendMsg(2389, 0, 0);
2130 // Move to the previous change in capitalisation.
2131 void wxStyledTextCtrl::WordPartLeft() {
2132 SendMsg(2390, 0, 0);
2135 // Move to the previous change in capitalisation extending selection
2136 // to new caret position.
2137 void wxStyledTextCtrl::WordPartLeftExtend() {
2138 SendMsg(2391, 0, 0);
2141 // Move to the change next in capitalisation.
2142 void wxStyledTextCtrl::WordPartRight() {
2143 SendMsg(2392, 0, 0);
2146 // Move to the next change in capitalisation extending selection
2147 // to new caret position.
2148 void wxStyledTextCtrl::WordPartRightExtend() {
2149 SendMsg(2393, 0, 0);
2152 // Set the way the display area is determined when a particular line
2153 // is to be moved to by Find, FindNext, GotoLine, etc.
2154 void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy
, int visibleSlop
) {
2155 SendMsg(2394, visiblePolicy
, visibleSlop
);
2158 // Delete back from the current position to the start of the line.
2159 void wxStyledTextCtrl::DelLineLeft() {
2160 SendMsg(2395, 0, 0);
2163 // Delete forwards from the current position to the end of the line.
2164 void wxStyledTextCtrl::DelLineRight() {
2165 SendMsg(2396, 0, 0);
2168 // Get and Set the xOffset (ie, horizonal scroll position).
2169 void wxStyledTextCtrl::SetXOffset(int newOffset
) {
2170 SendMsg(2397, newOffset
, 0);
2172 int wxStyledTextCtrl::GetXOffset() {
2173 return SendMsg(2398, 0, 0);
2176 // Set the last x chosen value to be the caret x position.
2177 void wxStyledTextCtrl::ChooseCaretX() {
2178 SendMsg(2399, 0, 0);
2181 // Set the way the caret is kept visible when going sideway.
2182 // The exclusion zone is given in pixels.
2183 void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy
, int caretSlop
) {
2184 SendMsg(2402, caretPolicy
, caretSlop
);
2187 // Set the way the line the caret is on is kept visible.
2188 // The exclusion zone is given in lines.
2189 void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy
, int caretSlop
) {
2190 SendMsg(2403, caretPolicy
, caretSlop
);
2193 // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE).
2194 void wxStyledTextCtrl::SetPrintWrapMode(int mode
) {
2195 SendMsg(2406, mode
, 0);
2198 // Is printing line wrapped?
2199 int wxStyledTextCtrl::GetPrintWrapMode() {
2200 return SendMsg(2407, 0, 0);
2203 // Set a fore colour for active hotspots.
2204 void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting
, const wxColour
& fore
) {
2205 SendMsg(2410, useSetting
, wxColourAsLong(fore
));
2208 // Set a back colour for active hotspots.
2209 void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting
, const wxColour
& back
) {
2210 SendMsg(2411, useSetting
, wxColourAsLong(back
));
2213 // Enable / Disable underlining active hotspots.
2214 void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline
) {
2215 SendMsg(2412, underline
, 0);
2218 // Limit hotspots to single line so hotspots on two lines don't merge.
2219 void wxStyledTextCtrl::SetHotspotSingleLine(bool singleLine
) {
2220 SendMsg(2421, singleLine
, 0);
2223 // Move caret between paragraphs (delimited by empty lines).
2224 void wxStyledTextCtrl::ParaDown() {
2225 SendMsg(2413, 0, 0);
2227 void wxStyledTextCtrl::ParaDownExtend() {
2228 SendMsg(2414, 0, 0);
2230 void wxStyledTextCtrl::ParaUp() {
2231 SendMsg(2415, 0, 0);
2233 void wxStyledTextCtrl::ParaUpExtend() {
2234 SendMsg(2416, 0, 0);
2237 // Given a valid document position, return the previous position taking code
2238 // page into account. Returns 0 if passed 0.
2239 int wxStyledTextCtrl::PositionBefore(int pos
) {
2240 return SendMsg(2417, pos
, 0);
2243 // Given a valid document position, return the next position taking code
2244 // page into account. Maximum value returned is the last position in the document.
2245 int wxStyledTextCtrl::PositionAfter(int pos
) {
2246 return SendMsg(2418, pos
, 0);
2249 // Copy a range of text to the clipboard. Positions are clipped into the document.
2250 void wxStyledTextCtrl::CopyRange(int start
, int end
) {
2251 SendMsg(2419, start
, end
);
2254 // Copy argument text to the clipboard.
2255 void wxStyledTextCtrl::CopyText(int length
, const wxString
& text
) {
2256 SendMsg(2420, length
, (long)(const char*)wx2stc(text
));
2259 // Set the selection mode to stream (SC_SEL_STREAM) or rectangular (SC_SEL_RECTANGLE) or
2260 // by lines (SC_SEL_LINES).
2261 void wxStyledTextCtrl::SetSelectionMode(int mode
) {
2262 SendMsg(2422, mode
, 0);
2265 // Get the mode of the current selection.
2266 int wxStyledTextCtrl::GetSelectionMode() {
2267 return SendMsg(2423, 0, 0);
2270 // Retrieve the position of the start of the selection at the given line (INVALID_POSITION if no selection on this line).
2271 int wxStyledTextCtrl::GetLineSelStartPosition(int line
) {
2272 return SendMsg(2424, line
, 0);
2275 // Retrieve the position of the end of the selection at the given line (INVALID_POSITION if no selection on this line).
2276 int wxStyledTextCtrl::GetLineSelEndPosition(int line
) {
2277 return SendMsg(2425, line
, 0);
2280 // Move caret down one line, extending rectangular selection to new caret position.
2281 void wxStyledTextCtrl::LineDownRectExtend() {
2282 SendMsg(2426, 0, 0);
2285 // Move caret up one line, extending rectangular selection to new caret position.
2286 void wxStyledTextCtrl::LineUpRectExtend() {
2287 SendMsg(2427, 0, 0);
2290 // Move caret left one character, extending rectangular selection to new caret position.
2291 void wxStyledTextCtrl::CharLeftRectExtend() {
2292 SendMsg(2428, 0, 0);
2295 // Move caret right one character, extending rectangular selection to new caret position.
2296 void wxStyledTextCtrl::CharRightRectExtend() {
2297 SendMsg(2429, 0, 0);
2300 // Move caret to first position on line, extending rectangular selection to new caret position.
2301 void wxStyledTextCtrl::HomeRectExtend() {
2302 SendMsg(2430, 0, 0);
2305 // Move caret to before first visible character on line.
2306 // If already there move to first character on line.
2307 // In either case, extend rectangular selection to new caret position.
2308 void wxStyledTextCtrl::VCHomeRectExtend() {
2309 SendMsg(2431, 0, 0);
2312 // Move caret to last position on line, extending rectangular selection to new caret position.
2313 void wxStyledTextCtrl::LineEndRectExtend() {
2314 SendMsg(2432, 0, 0);
2317 // Move caret one page up, extending rectangular selection to new caret position.
2318 void wxStyledTextCtrl::PageUpRectExtend() {
2319 SendMsg(2433, 0, 0);
2322 // Move caret one page down, extending rectangular selection to new caret position.
2323 void wxStyledTextCtrl::PageDownRectExtend() {
2324 SendMsg(2434, 0, 0);
2327 // Move caret to top of page, or one page up if already at top of page.
2328 void wxStyledTextCtrl::StutteredPageUp() {
2329 SendMsg(2435, 0, 0);
2332 // Move caret to top of page, or one page up if already at top of page, extending selection to new caret position.
2333 void wxStyledTextCtrl::StutteredPageUpExtend() {
2334 SendMsg(2436, 0, 0);
2337 // Move caret to bottom of page, or one page down if already at bottom of page.
2338 void wxStyledTextCtrl::StutteredPageDown() {
2339 SendMsg(2437, 0, 0);
2342 // Move caret to bottom of page, or one page down if already at bottom of page, extending selection to new caret position.
2343 void wxStyledTextCtrl::StutteredPageDownExtend() {
2344 SendMsg(2438, 0, 0);
2347 // Move caret left one word, position cursor at end of word.
2348 void wxStyledTextCtrl::WordLeftEnd() {
2349 SendMsg(2439, 0, 0);
2352 // Move caret left one word, position cursor at end of word, extending selection to new caret position.
2353 void wxStyledTextCtrl::WordLeftEndExtend() {
2354 SendMsg(2440, 0, 0);
2357 // Move caret right one word, position cursor at end of word.
2358 void wxStyledTextCtrl::WordRightEnd() {
2359 SendMsg(2441, 0, 0);
2362 // Move caret right one word, position cursor at end of word, extending selection to new caret position.
2363 void wxStyledTextCtrl::WordRightEndExtend() {
2364 SendMsg(2442, 0, 0);
2367 // Set the set of characters making up whitespace for when moving or selecting by word.
2368 // Should be called after SetWordChars.
2369 void wxStyledTextCtrl::SetWhitespaceChars(const wxString
& characters
) {
2370 SendMsg(2443, 0, (long)(const char*)wx2stc(characters
));
2373 // Reset the set of characters for whitespace and word characters to the defaults.
2374 void wxStyledTextCtrl::SetCharsDefault() {
2375 SendMsg(2444, 0, 0);
2378 // Get currently selected item position in the auto-completion list
2379 int wxStyledTextCtrl::AutoCompGetCurrent() {
2380 return SendMsg(2445, 0, 0);
2383 // Enlarge the document to a particular size of text bytes.
2384 void wxStyledTextCtrl::Allocate(int bytes
) {
2385 SendMsg(2446, bytes
, 0);
2388 // Start notifying the container of all key presses and commands.
2389 void wxStyledTextCtrl::StartRecord() {
2390 SendMsg(3001, 0, 0);
2393 // Stop notifying the container of all key presses and commands.
2394 void wxStyledTextCtrl::StopRecord() {
2395 SendMsg(3002, 0, 0);
2398 // Set the lexing language of the document.
2399 void wxStyledTextCtrl::SetLexer(int lexer
) {
2400 SendMsg(4001, lexer
, 0);
2403 // Retrieve the lexing language of the document.
2404 int wxStyledTextCtrl::GetLexer() {
2405 return SendMsg(4002, 0, 0);
2408 // Colourise a segment of the document using the current lexing language.
2409 void wxStyledTextCtrl::Colourise(int start
, int end
) {
2410 SendMsg(4003, start
, end
);
2413 // Set up a value that may be used by a lexer for some optional feature.
2414 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
2415 SendMsg(4004, (long)(const char*)wx2stc(key
), (long)(const char*)wx2stc(value
));
2418 // Set up the key words used by the lexer.
2419 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
2420 SendMsg(4005, keywordSet
, (long)(const char*)wx2stc(keyWords
));
2423 // Set the lexing language of the document based on string name.
2424 void wxStyledTextCtrl::SetLexerLanguage(const wxString
& language
) {
2425 SendMsg(4006, 0, (long)(const char*)wx2stc(language
));
2428 // END of generated section
2429 //----------------------------------------------------------------------
2432 // Returns the line number of the line with the caret.
2433 int wxStyledTextCtrl::GetCurrentLine() {
2434 int line
= LineFromPosition(GetCurrentPos());
2439 // Extract style settings from a spec-string which is composed of one or
2440 // more of the following comma separated elements:
2442 // bold turns on bold
2443 // italic turns on italics
2444 // fore:[name or #RRGGBB] sets the foreground colour
2445 // back:[name or #RRGGBB] sets the background colour
2446 // face:[facename] sets the font face name to use
2447 // size:[num] sets the font size in points
2448 // eol turns on eol filling
2449 // underline turns on underlining
2451 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
2453 wxStringTokenizer
tkz(spec
, wxT(","));
2454 while (tkz
.HasMoreTokens()) {
2455 wxString token
= tkz
.GetNextToken();
2457 wxString option
= token
.BeforeFirst(':');
2458 wxString val
= token
.AfterFirst(':');
2460 if (option
== wxT("bold"))
2461 StyleSetBold(styleNum
, true);
2463 else if (option
== wxT("italic"))
2464 StyleSetItalic(styleNum
, true);
2466 else if (option
== wxT("underline"))
2467 StyleSetUnderline(styleNum
, true);
2469 else if (option
== wxT("eol"))
2470 StyleSetEOLFilled(styleNum
, true);
2472 else if (option
== wxT("size")) {
2474 if (val
.ToLong(&points
))
2475 StyleSetSize(styleNum
, points
);
2478 else if (option
== wxT("face"))
2479 StyleSetFaceName(styleNum
, val
);
2481 else if (option
== wxT("fore"))
2482 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
2484 else if (option
== wxT("back"))
2485 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
2490 // Set style size, face, bold, italic, and underline attributes from
2491 // a wxFont's attributes.
2492 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
2494 // Ensure that the native font is initialized
2496 GetTextExtent(wxT("X"), &x
, &y
, NULL
, NULL
, &font
);
2498 int size
= font
.GetPointSize();
2499 wxString faceName
= font
.GetFaceName();
2500 bool bold
= font
.GetWeight() == wxBOLD
;
2501 bool italic
= font
.GetStyle() != wxNORMAL
;
2502 bool under
= font
.GetUnderlined();
2504 // TODO: add encoding/charset mapping
2505 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
2508 // Set all font style attributes at once.
2509 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
2510 const wxString
& faceName
,
2511 bool bold
, bool italic
,
2513 StyleSetSize(styleNum
, size
);
2514 StyleSetFaceName(styleNum
, faceName
);
2515 StyleSetBold(styleNum
, bold
);
2516 StyleSetItalic(styleNum
, italic
);
2517 StyleSetUnderline(styleNum
, underline
);
2519 // TODO: add encoding/charset mapping
2523 // Perform one of the operations defined by the wxSTC_CMD_* constants.
2524 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
2529 // Set the left and right margin in the edit area, measured in pixels.
2530 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
2531 SetMarginLeft(left
);
2532 SetMarginRight(right
);
2536 // Retrieve the start and end positions of the current selection.
2537 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
2538 if (startPos
!= NULL
)
2539 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
2541 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
2545 // Retrieve the point in the window where a position is displayed.
2546 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
2547 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
2548 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
2549 return wxPoint(x
, y
);
2552 // Scroll enough to make the given line visible
2553 void wxStyledTextCtrl::ScrollToLine(int line
) {
2554 m_swx
->DoScrollToLine(line
);
2558 // Scroll enough to make the given column visible
2559 void wxStyledTextCtrl::ScrollToColumn(int column
) {
2560 m_swx
->DoScrollToColumn(column
);
2564 bool wxStyledTextCtrl::SaveFile(const wxString
& filename
)
2566 wxFile
file(filename
, wxFile::write
);
2568 if (!file
.IsOpened())
2571 bool success
= file
.Write(GetText(), *wxConvCurrent
);
2579 bool wxStyledTextCtrl::LoadFile(const wxString
& filename
)
2581 bool success
= false;
2582 wxFile
file(filename
, wxFile::read
);
2584 if (file
.IsOpened())
2587 size_t len
= (size_t)file
.Length();
2591 wxMemoryBuffer
buffer(len
+1);
2592 success
= (file
.Read(buffer
.GetData(), len
) == len
);
2594 ((char*)buffer
.GetData())[len
] = 0;
2595 contents
= wxString(buffer
, *wxConvCurrent
, len
);
2599 success
= (file
.Read(wxStringBuffer(buffer
, len
), len
) == len
);
2604 success
= true; // empty file is ok
2618 #if wxUSE_DRAG_AND_DROP
2619 wxDragResult
wxStyledTextCtrl::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
2620 return m_swx
->DoDragOver(x
, y
, def
);
2624 bool wxStyledTextCtrl::DoDropText(long x
, long y
, const wxString
& data
) {
2625 return m_swx
->DoDropText(x
, y
, data
);
2630 void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA
) {
2631 m_swx
->SetUseAntiAliasing(useAA
);
2634 bool wxStyledTextCtrl::GetUseAntiAliasing() {
2635 return m_swx
->GetUseAntiAliasing();
2638 //----------------------------------------------------------------------
2641 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
2643 m_swx
->DoPaint(&dc
, GetUpdateRegion().GetBox());
2646 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
2647 if (evt
.GetOrientation() == wxHORIZONTAL
)
2648 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2650 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2653 void wxStyledTextCtrl::OnScroll(wxScrollEvent
& evt
) {
2654 wxScrollBar
* sb
= wxDynamicCast(evt
.GetEventObject(), wxScrollBar
);
2656 if (sb
->IsVertical())
2657 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
2659 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
2663 void wxStyledTextCtrl::OnSize(wxSizeEvent
& WXUNUSED(evt
)) {
2665 wxSize sz
= GetClientSize();
2666 m_swx
->DoSize(sz
.x
, sz
.y
);
2670 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
2672 wxPoint pt
= evt
.GetPosition();
2673 m_swx
->DoLeftButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2674 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
2677 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
2678 wxPoint pt
= evt
.GetPosition();
2679 m_swx
->DoLeftButtonMove(Point(pt
.x
, pt
.y
));
2682 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
2683 wxPoint pt
= evt
.GetPosition();
2684 m_swx
->DoLeftButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
2689 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
2690 wxPoint pt
= evt
.GetPosition();
2691 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2695 void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent
& evt
) {
2696 wxPoint pt
= evt
.GetPosition();
2697 m_swx
->DoMiddleButtonUp(Point(pt
.x
, pt
.y
));
2700 void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent
& evt
) {
2701 wxPoint pt
= evt
.GetPosition();
2702 ScreenToClient(&pt
.x
, &pt
.y
);
2704 Show context menu at event point if it's within the window,
2705 or at caret location if not
2707 wxHitTest ht
= this->HitTest(pt
);
2708 if (ht
!= wxHT_WINDOW_INSIDE
) {
2709 pt
= this->PointFromPosition(this->GetCurrentPos());
2711 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
2715 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
2716 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
2717 evt
.GetWheelDelta(),
2718 evt
.GetLinesPerAction(),
2720 evt
.IsPageScroll());
2724 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
2725 // On (some?) non-US keyboards the AltGr key is required to enter some
2726 // common characters. It comes to us as both Alt and Ctrl down so we need
2727 // to let the char through in that case, otherwise if only ctrl or only
2728 // alt let's skip it.
2729 bool ctrl
= evt
.ControlDown();
2731 // On the Mac the Alt key is just a modifier key (like Shift) so we need
2732 // to allow the char events to be processed when Alt is pressed.
2733 // TODO: Should we check MetaDown instead in this case?
2736 bool alt
= evt
.AltDown();
2738 bool skip
= ((ctrl
|| alt
) && ! (ctrl
&& alt
));
2740 int key
= evt
.GetKeyCode();
2742 // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n",
2743 // key, m_lastKeyDownConsumed, ctrl, alt, skip);
2745 if ( (key
<= WXK_START
|| key
> WXK_COMMAND
) &&
2746 !m_lastKeyDownConsumed
&& !skip
) {
2747 m_swx
->DoAddChar(key
);
2754 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
2755 int key
= evt
.GetKeyCode();
2756 bool shift
= evt
.ShiftDown(),
2757 ctrl
= evt
.ControlDown(),
2758 alt
= evt
.AltDown(),
2759 meta
= evt
.MetaDown();
2761 int processed
= m_swx
->DoKeyDown(key
, shift
, ctrl
, alt
, meta
, &m_lastKeyDownConsumed
);
2763 // printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n",
2764 // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed);
2766 if (!processed
&& !m_lastKeyDownConsumed
)
2771 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
2772 m_swx
->DoLoseFocus();
2777 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
2778 m_swx
->DoGainFocus();
2783 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& WXUNUSED(evt
)) {
2784 m_swx
->DoSysColourChange();
2788 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& WXUNUSED(evt
)) {
2789 // do nothing to help avoid flashing
2794 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
2795 m_swx
->DoCommand(evt
.GetId());
2799 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& WXUNUSED(evt
)) {
2800 m_swx
->DoOnListBox();
2804 void wxStyledTextCtrl::OnIdle(wxIdleEvent
& evt
) {
2805 m_swx
->DoOnIdle(evt
);
2809 wxSize
wxStyledTextCtrl::DoGetBestSize() const
2811 // What would be the best size for a wxSTC?
2812 // Just give a reasonable minimum until something else can be figured out.
2813 return wxSize(200,100);
2817 //----------------------------------------------------------------------
2818 // Turn notifications from Scintilla into events
2821 void wxStyledTextCtrl::NotifyChange() {
2822 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
2823 evt
.SetEventObject(this);
2824 GetEventHandler()->ProcessEvent(evt
);
2828 static void SetEventText(wxStyledTextEvent
& evt
, const char* text
,
2832 // The unicode conversion MUST have a null byte to terminate the
2833 // string so move it into a buffer first and give it one.
2834 wxMemoryBuffer
buf(length
+1);
2835 buf
.AppendData((void*)text
, length
);
2837 evt
.SetText(stc2wx(buf
));
2841 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
2842 SCNotification
& scn
= *_scn
;
2843 wxStyledTextEvent
evt(0, GetId());
2845 evt
.SetEventObject(this);
2846 evt
.SetPosition(scn
.position
);
2848 evt
.SetModifiers(scn
.modifiers
);
2850 switch (scn
.nmhdr
.code
) {
2851 case SCN_STYLENEEDED
:
2852 evt
.SetEventType(wxEVT_STC_STYLENEEDED
);
2856 evt
.SetEventType(wxEVT_STC_CHARADDED
);
2859 case SCN_SAVEPOINTREACHED
:
2860 evt
.SetEventType(wxEVT_STC_SAVEPOINTREACHED
);
2863 case SCN_SAVEPOINTLEFT
:
2864 evt
.SetEventType(wxEVT_STC_SAVEPOINTLEFT
);
2867 case SCN_MODIFYATTEMPTRO
:
2868 evt
.SetEventType(wxEVT_STC_ROMODIFYATTEMPT
);
2872 evt
.SetEventType(wxEVT_STC_KEY
);
2875 case SCN_DOUBLECLICK
:
2876 evt
.SetEventType(wxEVT_STC_DOUBLECLICK
);
2880 evt
.SetEventType(wxEVT_STC_UPDATEUI
);
2884 evt
.SetEventType(wxEVT_STC_MODIFIED
);
2885 evt
.SetModificationType(scn
.modificationType
);
2886 SetEventText(evt
, scn
.text
, scn
.length
);
2887 evt
.SetLength(scn
.length
);
2888 evt
.SetLinesAdded(scn
.linesAdded
);
2889 evt
.SetLine(scn
.line
);
2890 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
2891 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
2894 case SCN_MACRORECORD
:
2895 evt
.SetEventType(wxEVT_STC_MACRORECORD
);
2896 evt
.SetMessage(scn
.message
);
2897 evt
.SetWParam(scn
.wParam
);
2898 evt
.SetLParam(scn
.lParam
);
2901 case SCN_MARGINCLICK
:
2902 evt
.SetEventType(wxEVT_STC_MARGINCLICK
);
2903 evt
.SetMargin(scn
.margin
);
2907 evt
.SetEventType(wxEVT_STC_NEEDSHOWN
);
2908 evt
.SetLength(scn
.length
);
2912 evt
.SetEventType(wxEVT_STC_PAINTED
);
2915 case SCN_USERLISTSELECTION
:
2916 evt
.SetEventType(wxEVT_STC_USERLISTSELECTION
);
2917 evt
.SetListType(scn
.listType
);
2918 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2921 case SCN_URIDROPPED
:
2922 evt
.SetEventType(wxEVT_STC_URIDROPPED
);
2923 SetEventText(evt
, scn
.text
, strlen(scn
.text
));
2926 case SCN_DWELLSTART
:
2927 evt
.SetEventType(wxEVT_STC_DWELLSTART
);
2933 evt
.SetEventType(wxEVT_STC_DWELLEND
);
2939 evt
.SetEventType(wxEVT_STC_ZOOM
);
2942 case SCN_HOTSPOTCLICK
:
2943 evt
.SetEventType(wxEVT_STC_HOTSPOT_CLICK
);
2946 case SCN_HOTSPOTDOUBLECLICK
:
2947 evt
.SetEventType(wxEVT_STC_HOTSPOT_DCLICK
);
2950 case SCN_CALLTIPCLICK
:
2951 evt
.SetEventType(wxEVT_STC_CALLTIP_CLICK
);
2958 GetEventHandler()->ProcessEvent(evt
);
2962 //----------------------------------------------------------------------
2963 //----------------------------------------------------------------------
2964 //----------------------------------------------------------------------
2966 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
2967 : wxCommandEvent(commandType
, id
)
2972 m_modificationType
= 0;
2977 m_foldLevelPrev
= 0;
2985 m_dragAllowMove
= false;
2986 #if wxUSE_DRAG_AND_DROP
2987 m_dragResult
= wxDragNone
;
2991 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
2992 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
2993 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
2996 wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent
& event
):
2997 wxCommandEvent(event
)
2999 m_position
= event
.m_position
;
3000 m_key
= event
.m_key
;
3001 m_modifiers
= event
.m_modifiers
;
3002 m_modificationType
= event
.m_modificationType
;
3003 m_text
= event
.m_text
;
3004 m_length
= event
.m_length
;
3005 m_linesAdded
= event
.m_linesAdded
;
3006 m_line
= event
.m_line
;
3007 m_foldLevelNow
= event
.m_foldLevelNow
;
3008 m_foldLevelPrev
= event
.m_foldLevelPrev
;
3010 m_margin
= event
.m_margin
;
3012 m_message
= event
.m_message
;
3013 m_wParam
= event
.m_wParam
;
3014 m_lParam
= event
.m_lParam
;
3016 m_listType
= event
.m_listType
;
3020 m_dragText
= event
.m_dragText
;
3021 m_dragAllowMove
=event
.m_dragAllowMove
;
3022 #if wxUSE_DRAG_AND_DROP
3023 m_dragResult
= event
.m_dragResult
;
3027 //----------------------------------------------------------------------
3028 //----------------------------------------------------------------------