1 ////////////////////////////////////////////////////////////////////////////
3 // Purpose: A wxWindows implementation of Scintilla. This class is the
4 // one meant to be used directly by wx applications. It does not
5 // derive directly from the Scintilla classes, but instead
6 // delegates most things to the real Scintilla class.
7 // This allows the use of Scintilla without polluting the
8 // namespace with all the classes and identifiers from Scintilla.
12 // Created: 13-Jan-2000
14 // Copyright: (c) 2000 by Total Control Software
15 // Licence: wxWindows license
16 /////////////////////////////////////////////////////////////////////////////
20 #include "wx/stc/stc.h"
21 #include "ScintillaWX.h"
23 #include <wx/tokenzr.h>
25 // The following code forces a reference to all of the Scintilla lexers.
26 // If we don't do something like this, then the linker tends to "optimize"
27 // them away. (eric@sourcegear.com)
29 int wxForceScintillaLexers(void)
31 extern LexerModule lmCPP
;
32 extern LexerModule lmHTML
;
33 extern LexerModule lmXML
;
34 extern LexerModule lmProps
;
35 extern LexerModule lmErrorList
;
36 extern LexerModule lmMake
;
37 extern LexerModule lmBatch
;
38 extern LexerModule lmPerl
;
39 extern LexerModule lmPython
;
40 extern LexerModule lmSQL
;
41 extern LexerModule lmVB
;
65 //----------------------------------------------------------------------
67 const wxChar
* wxSTCNameStr
= "stcwindow";
69 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
70 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
71 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
72 EVT_SIZE (wxStyledTextCtrl::OnSize
)
73 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
74 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
75 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
76 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
77 EVT_CHAR (wxStyledTextCtrl::OnChar
)
78 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
79 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
80 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
81 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
82 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
83 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu
)
84 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox
)
88 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
89 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
91 //----------------------------------------------------------------------
92 // Constructor and Destructor
94 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
99 const wxString
& name
) :
100 wxControl(parent
, id
, pos
, size
,
101 style
| wxVSCROLL
| wxHSCROLL
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
102 wxDefaultValidator
, name
)
104 m_swx
= new ScintillaWX(this);
109 wxStyledTextCtrl::~wxStyledTextCtrl() {
114 //----------------------------------------------------------------------
116 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
118 return m_swx
->WndProc(msg
, wp
, lp
);
126 #define MAKELONG(a, b) ((a) | ((b) << 16))
129 static long wxColourAsLong(const wxColour
& co
) {
130 return (((long)co
.Blue() << 16) |
131 ((long)co
.Green() << 8) |
135 static wxColour
wxColourFromLong(long c
) {
137 clr
.Set(c
& 0xff, (c
>> 8) & 0xff, (c
>> 16) & 0xff);
142 static wxColour
wxColourFromSpec(const wxString
& spec
) {
143 // spec should be #RRGGBB
145 int red
= strtol(spec
.Mid(1,2), &junk
, 16);
146 int green
= strtol(spec
.Mid(3,2), &junk
, 16);
147 int blue
= strtol(spec
.Mid(5,2), &junk
, 16);
148 return wxColour(red
, green
, blue
);
152 //----------------------------------------------------------------------
153 // BEGIN generated section. The following code is automatically generated
154 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
155 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
158 // Add text to the document
159 void wxStyledTextCtrl::AddText(const wxString
& text
) {
160 SendMsg(2001, text
.Len(), (long)text
.c_str());
163 // Add array of cells to document
164 void wxStyledTextCtrl::AddStyledText(const wxString
& text
) {
165 SendMsg(2002, text
.Len(), (long)text
.c_str());
168 // Insert string at a position
169 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
170 SendMsg(2003, pos
, (long)text
.c_str());
173 // Delete all text in the document
174 void wxStyledTextCtrl::ClearAll() {
178 // Set all style bytes to 0, remove all folding information
179 void wxStyledTextCtrl::ClearDocumentStyle() {
183 // The number of characters in the document
184 int wxStyledTextCtrl::GetLength() {
185 return SendMsg(2006, 0, 0);
188 // Returns the character byte at the position
189 int wxStyledTextCtrl::GetCharAt(int pos
) {
190 return SendMsg(2007, pos
, 0);
193 // Returns the position of the caret
194 int wxStyledTextCtrl::GetCurrentPos() {
195 return SendMsg(2008, 0, 0);
198 // Returns the position of the opposite end of the selection to the caret
199 int wxStyledTextCtrl::GetAnchor() {
200 return SendMsg(2009, 0, 0);
203 // Returns the style byte at the position
204 int wxStyledTextCtrl::GetStyleAt(int pos
) {
205 return SendMsg(2010, pos
, 0);
208 // Redoes the next action on the undo history
209 void wxStyledTextCtrl::Redo() {
213 // Choose between collecting actions into the undo
214 // history and discarding them.
215 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
216 SendMsg(2012, collectUndo
, 0);
219 // Select all the text in the document.
220 void wxStyledTextCtrl::SelectAll() {
224 // Remember the current position in the undo history as the position
225 // at which the document was saved.
226 void wxStyledTextCtrl::SetSavePoint() {
230 // Retrieve a buffer of cells.
231 wxString
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
233 int len
= endPos
- startPos
;
235 tr
.lpstrText
= text
.GetWriteBuf(len
*2+1);
236 tr
.chrg
.cpMin
= startPos
;
237 tr
.chrg
.cpMax
= endPos
;
238 SendMsg(2015, 0, (long)&tr
);
239 text
.UngetWriteBuf(len
*2);
243 // Are there any redoable actions in the undo history.
244 bool wxStyledTextCtrl::CanRedo() {
245 return SendMsg(2016, 0, 0) != 0;
248 // Retrieve the line number at which a particular marker is located
249 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
250 return SendMsg(2017, handle
, 0);
254 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
255 SendMsg(2018, handle
, 0);
258 // Is undo history being collected?
259 bool wxStyledTextCtrl::GetUndoCollection() {
260 return SendMsg(2019, 0, 0) != 0;
263 // Are white space characters currently visible?
264 // Returns one of SCWS_* constants.
265 int wxStyledTextCtrl::GetViewWhiteSpace() {
266 return SendMsg(2020, 0, 0);
269 // Make white space characters invisible, always visible or visible outside indentation.
270 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
271 SendMsg(2021, viewWS
, 0);
274 // Find the position from a point within the window.
275 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
276 return SendMsg(2022, pt
.x
, pt
.y
);
279 // Set caret to start of a line and ensure it is visible.
280 void wxStyledTextCtrl::GotoLine(int line
) {
281 SendMsg(2024, line
, 0);
284 // Set caret to a position and ensure it is visible.
285 void wxStyledTextCtrl::GotoPos(int pos
) {
286 SendMsg(2025, pos
, 0);
289 // Set the selection anchor to a position. The anchor is the opposite
290 // end of the selection from the caret.
291 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
292 SendMsg(2026, posAnchor
, 0);
295 // Retrieve the text of the line containing the caret.
296 // Returns the index of the caret on the line.
297 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
299 int len
= LineLength(GetCurrentLine());
300 char* buf
= text
.GetWriteBuf(len
+1);
302 int pos
= SendMsg(2027, len
, (long)buf
);
303 text
.UngetWriteBuf();
304 if (linePos
) *linePos
= pos
;
309 // Retrieve the position of the last correctly styled character.
310 int wxStyledTextCtrl::GetEndStyled() {
311 return SendMsg(2028, 0, 0);
314 // Convert all line endings in the document to use the current mode.
315 void wxStyledTextCtrl::ConvertEOLs() {
319 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
320 int wxStyledTextCtrl::GetEOLMode() {
321 return SendMsg(2030, 0, 0);
324 // Set the current end of line mode.
325 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
326 SendMsg(2031, eolMode
, 0);
329 // Set the current styling position to pos and the styling mask to mask.
330 // The styling mask can be used to protect some bits in each styling byte from
332 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
333 SendMsg(2032, pos
, mask
);
336 // Change style from current styling position for length characters to a style
337 // and move the current styling position to after this newly styled segment.
338 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
339 SendMsg(2033, length
, style
);
342 // Is drawing done first into a buffer or direct to the screen.
343 bool wxStyledTextCtrl::GetBufferedDraw() {
344 return SendMsg(2034, 0, 0) != 0;
347 // If drawing is buffered then each line of text is drawn into a bitmap buffer
348 // before drawing it to the screen to avoid flicker.
349 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
350 SendMsg(2035, buffered
, 0);
353 // Change the visible size of a tab to be a multiple of the width of a space
355 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
356 SendMsg(2036, tabWidth
, 0);
359 // Retrieve the visible size of a tab.
360 int wxStyledTextCtrl::GetTabWidth() {
361 return SendMsg(2121, 0, 0);
364 // Set the code page used to interpret the bytes of the document as characters.
365 // The SC_CP_UTF8 value can be used to enter Unicode mode.
366 void wxStyledTextCtrl::SetCodePage(int codePage
) {
367 SendMsg(2037, codePage
, 0);
370 // Set the symbol used for a particular marker number,
371 // and optionally the for and background colours.
372 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
373 const wxColour
& foreground
,
374 const wxColour
& background
) {
376 SendMsg(2040, markerNumber
, markerSymbol
);
378 MarkerSetForeground(markerNumber
, foreground
);
380 MarkerSetBackground(markerNumber
, background
);
383 // Set the foreground colour used for a particular marker number.
384 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
385 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
388 // Set the background colour used for a particular marker number.
389 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
390 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
393 // Add a marker to a line.
394 void wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
395 SendMsg(2043, line
, markerNumber
);
398 // Delete a marker from a line
399 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
400 SendMsg(2044, line
, markerNumber
);
403 // Delete all markers with a particular number from all lines
404 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
405 SendMsg(2045, markerNumber
, 0);
408 // Get a bit mask of all the markers set on a line.
409 int wxStyledTextCtrl::MarkerGet(int line
) {
410 return SendMsg(2046, line
, 0);
413 // Find the next line after lineStart that includes a marker in mask.
414 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
415 return SendMsg(2047, lineStart
, markerMask
);
418 // Find the previous line before lineStart that includes a marker in mask.
419 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
420 return SendMsg(2048, lineStart
, markerMask
);
423 // Set a margin to be either numeric or symbolic.
424 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
425 SendMsg(2240, margin
, marginType
);
428 // Retrieve the type of a margin.
429 int wxStyledTextCtrl::GetMarginType(int margin
) {
430 return SendMsg(2241, margin
, 0);
433 // Set the width of a margin to a width expressed in pixels.
434 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
435 SendMsg(2242, margin
, pixelWidth
);
438 // Retrieve the width of a margin in pixels.
439 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
440 return SendMsg(2243, margin
, 0);
443 // Set a mask that determines which markers are displayed in a margin.
444 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
445 SendMsg(2244, margin
, mask
);
448 // Retrieve the marker mask of a margin.
449 int wxStyledTextCtrl::GetMarginMask(int margin
) {
450 return SendMsg(2245, margin
, 0);
453 // Make a margin sensitive or insensitive to mouse clicks.
454 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
455 SendMsg(2246, margin
, sensitive
);
458 // Retrieve the mouse click sensitivity of a margin.
459 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
460 return SendMsg(2247, margin
, 0) != 0;
463 // Clear all the styles and make equivalent to the global default style.
464 void wxStyledTextCtrl::StyleClearAll() {
468 // Set the foreground colour of a style.
469 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
470 SendMsg(2051, style
, wxColourAsLong(fore
));
473 // Set the background colour of a style.
474 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
475 SendMsg(2052, style
, wxColourAsLong(back
));
478 // Set a style to be bold or not.
479 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
480 SendMsg(2053, style
, bold
);
483 // Set a style to be italic or not.
484 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
485 SendMsg(2054, style
, italic
);
488 // Set the size of characters of a style.
489 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
490 SendMsg(2055, style
, sizePoints
);
493 // Set the font of a style.
494 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
495 SendMsg(2056, style
, (long)fontName
.c_str());
498 // Set a style to have its end of line filled or not.
499 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
500 SendMsg(2057, style
, filled
);
503 // Reset the default style to its state at startup
504 void wxStyledTextCtrl::StyleResetDefault() {
508 // Set a style to be underlined or not.
509 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
510 SendMsg(2059, style
, underline
);
513 // Set the foreground colour of the selection and whether to use this setting.
514 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
515 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
518 // Set the background colour of the selection and whether to use this setting.
519 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
520 SendMsg(2068, useSetting
, wxColourAsLong(back
));
523 // Set the foreground colour of the caret.
524 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
525 SendMsg(2069, wxColourAsLong(fore
), 0);
528 // When key+modifier combination km is pressed perform msg.
529 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
530 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
533 // When key+modifier combination km do nothing.
534 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
535 SendMsg(2071, MAKELONG(key
, modifiers
));
538 // Drop all key mappings.
539 void wxStyledTextCtrl::CmdKeyClearAll() {
543 // Set the styles for a segment of the document.
544 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
545 SendMsg(2073, length
, (long)styleBytes
);
548 // Set a style to be visible or not.
549 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
550 SendMsg(2074, style
, visible
);
553 // Get the time in milliseconds that the caret is on and off.
554 int wxStyledTextCtrl::GetCaretPeriod() {
555 return SendMsg(2075, 0, 0);
558 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
559 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
560 SendMsg(2076, periodMilliseconds
, 0);
563 // Set the set of characters making up words for when moving or selecting
565 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
566 SendMsg(2077, 0, (long)characters
.c_str());
569 // Start a sequence of actions that is undone and redone as a unit.
571 void wxStyledTextCtrl::BeginUndoAction() {
575 // End a sequence of actions that is undone and redone as a unit.
576 void wxStyledTextCtrl::EndUndoAction() {
580 // Set an indicator to plain, squiggle or TT.
581 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
582 SendMsg(2080, indic
, style
);
585 // Retrieve the style of an indicator.
586 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
587 return SendMsg(2081, indic
, 0);
590 // Set the foreground colour of an indicator.
591 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
592 SendMsg(2082, indic
, wxColourAsLong(fore
));
595 // Retrieve the foreground colour of an indicator.
596 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
597 long c
= SendMsg(2083, indic
, 0);
598 return wxColourFromLong(c
);
601 // Divide each styling byte into lexical class bits (default:5) and indicator
602 // bits (default:3). If a lexer requires more than 32 lexical states, then this
603 // is used to expand the possible states.
604 void wxStyledTextCtrl::SetStyleBits(int bits
) {
605 SendMsg(2090, bits
, 0);
608 // Retrieve number of bits in style bytes used to hold the lexical state.
609 int wxStyledTextCtrl::GetStyleBits() {
610 return SendMsg(2091, 0, 0);
613 // Used to hold extra styling information for each line.
614 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
615 SendMsg(2092, line
, state
);
618 // Retrieve the extra styling information for a line.
619 int wxStyledTextCtrl::GetLineState(int line
) {
620 return SendMsg(2093, line
, 0);
623 // Retrieve the last line number that has line state.
624 int wxStyledTextCtrl::GetMaxLineState() {
625 return SendMsg(2094, 0, 0);
628 // Display a auto-completion list.
629 // The lenEntered parameter indicates how many characters before
630 // the caret should be used to provide context.
631 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
632 SendMsg(2100, lenEntered
, (long)itemList
.c_str());
635 // Remove the auto-completion list from the screen.
636 void wxStyledTextCtrl::AutoCompCancel() {
640 // Is there an auto-completion list visible?
641 bool wxStyledTextCtrl::AutoCompActive() {
642 return SendMsg(2102, 0, 0) != 0;
645 // Retrieve the position of the caret when the auto-completion list was
647 int wxStyledTextCtrl::AutoCompPosStart() {
648 return SendMsg(2103, 0, 0);
651 // User has selected an item so remove the list and insert the selection.
652 void wxStyledTextCtrl::AutoCompComplete() {
656 // Define a set of character that when typed cancel the auto-completion list.
657 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
658 SendMsg(2105, 0, (long)characterSet
.c_str());
661 // Change the separator character in the string setting up an auto-completion
662 // list. Default is space but can be changed if items contain space.
663 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
664 SendMsg(2106, separatorCharacter
, 0);
667 // Retrieve the auto-completion list separator character.
668 int wxStyledTextCtrl::AutoCompGetSeparator() {
669 return SendMsg(2107, 0, 0);
672 // Select the item in the auto-completion list that starts with a string.
673 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
674 SendMsg(2108, 0, (long)text
.c_str());
677 // Should the auto-completion list be cancelled if the user backspaces to a
678 // position before where the box was created.
679 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
680 SendMsg(2110, cancel
, 0);
683 // Retrieve whether auto-completion cancelled by backspacing before start.
684 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
685 return SendMsg(2111, 0, 0) != 0;
688 // Define a set of character that when typed fills up the selected word.
689 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
690 SendMsg(2112, 0, (long)characterSet
.c_str());
693 // Should a single item auto-completion list automatically choose the item.
694 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
695 SendMsg(2113, chooseSingle
, 0);
698 // Retrieve whether a single item auto-completion list automatically choose the item.
699 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
700 return SendMsg(2114, 0, 0) != 0;
703 // Set whether case is significant when performing auto-completion searches.
704 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
705 SendMsg(2115, ignoreCase
, 0);
708 // Retrieve state of ignore case flag.
709 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
710 return SendMsg(2116, 0, 0) != 0;
713 // Set the number of spaces used for one level of indentation.
714 void wxStyledTextCtrl::SetIndent(int indentSize
) {
715 SendMsg(2122, indentSize
, 0);
718 // Retrieve indentation size.
719 int wxStyledTextCtrl::GetIndent() {
720 return SendMsg(2123, 0, 0);
723 // Indentation will only use space characters if useTabs is false, otherwise
724 // it will use a combination of tabs and spaces.
725 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
726 SendMsg(2124, useTabs
, 0);
729 // Retrieve whether tabs will be used in indentation.
730 bool wxStyledTextCtrl::GetUseTabs() {
731 return SendMsg(2125, 0, 0) != 0;
734 // Change the indentation of a line to a number of columns.
735 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
736 SendMsg(2126, line
, indentSize
);
739 // Retrieve the number of columns that a line is indented.
740 int wxStyledTextCtrl::GetLineIndentation(int line
) {
741 return SendMsg(2127, line
, 0);
744 // Retrieve the position before the first non indentation character on a line.
745 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
746 return SendMsg(2128, line
, 0);
749 // Retrieve the column number of a position, taking tab width into account.
750 int wxStyledTextCtrl::GetColumn(int pos
) {
751 return SendMsg(2129, pos
, 0);
754 // Show or hide the horizontal scroll bar.
755 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
756 SendMsg(2130, show
, 0);
759 // Is the horizontal scroll bar visible?
760 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
761 return SendMsg(2131, 0, 0) != 0;
764 // Show or hide indentation guides.
765 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
766 SendMsg(2132, show
, 0);
769 // Are the indentation guides visible?
770 bool wxStyledTextCtrl::GetIndentationGuides() {
771 return SendMsg(2133, 0, 0) != 0;
774 // Set the highlighted indentation guide column.
775 // 0 = no highlighted guide.
776 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
777 SendMsg(2134, column
, 0);
780 // Get the highlighted indentation guide column.
781 int wxStyledTextCtrl::GetHighlightGuide() {
782 return SendMsg(2135, 0, 0);
785 // Get the position after the last visible characters on a line.
786 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
787 return SendMsg(2136, line
, 0);
790 // Get the code page used to interpret the bytes of the document as characters.
791 int wxStyledTextCtrl::GetCodePage() {
792 return SendMsg(2137, 0, 0);
795 // Get the foreground colour of the caret.
796 wxColour
wxStyledTextCtrl::GetCaretForeground() {
797 long c
= SendMsg(2138, 0, 0);
798 return wxColourFromLong(c
);
801 // In read-only mode?
802 bool wxStyledTextCtrl::GetReadOnly() {
803 return SendMsg(2140, 0, 0) != 0;
806 // Sets the position of the caret.
807 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
808 SendMsg(2141, pos
, 0);
811 // Sets the position that starts the selection - this becomes the anchor.
812 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
813 SendMsg(2142, pos
, 0);
816 // Returns the position at the start of the selection.
817 int wxStyledTextCtrl::GetSelectionStart() {
818 return SendMsg(2143, 0, 0);
821 // Sets the position that ends the selection - this becomes the currentPosition.
822 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
823 SendMsg(2144, pos
, 0);
826 // Returns the position at the end of the selection.
827 int wxStyledTextCtrl::GetSelectionEnd() {
828 return SendMsg(2145, 0, 0);
831 // Sets the print magnification added to the point size of each style for printing.
832 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
833 SendMsg(2146, magnification
, 0);
836 // Returns the print magnification.
837 int wxStyledTextCtrl::GetPrintMagnification() {
838 return SendMsg(2147, 0, 0);
841 // Modify colours when printing for clearer printed text.
842 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
843 SendMsg(2148, mode
, 0);
846 // Returns the print colour mode.
847 int wxStyledTextCtrl::GetPrintColourMode() {
848 return SendMsg(2149, 0, 0);
851 // Find some text in the document.
852 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
853 const wxString
& text
,
854 bool caseSensitive
, bool wholeWord
) {
858 flags
|= caseSensitive
? SCFIND_MATCHCASE
: 0;
859 flags
|= wholeWord
? SCFIND_WHOLEWORD
: 0;
860 ft
.chrg
.cpMin
= minPos
;
861 ft
.chrg
.cpMax
= maxPos
;
862 ft
.lpstrText
= (char*)text
.c_str();
864 return SendMsg(2150, flags
, (long)&ft
);
867 // On Windows will draw the document into a display context such as a printer.
868 int wxStyledTextCtrl::FormatRange(bool doDraw
,
872 wxDC
* target
, // Why does it use two? Can they be the same?
878 fr
.hdcTarget
= target
;
879 fr
.rc
.top
= renderRect
.GetTop();
880 fr
.rc
.left
= renderRect
.GetLeft();
881 fr
.rc
.right
= renderRect
.GetRight();
882 fr
.rc
.bottom
= renderRect
.GetBottom();
883 fr
.rcPage
.top
= pageRect
.GetTop();
884 fr
.rcPage
.left
= pageRect
.GetLeft();
885 fr
.rcPage
.right
= pageRect
.GetRight();
886 fr
.rcPage
.bottom
= pageRect
.GetBottom();
887 fr
.chrg
.cpMin
= startPos
;
888 fr
.chrg
.cpMax
= endPos
;
890 return SendMsg(2151, doDraw
, (long)&fr
);
893 // Retrieve the line at the top of the display.
894 int wxStyledTextCtrl::GetFirstVisibleLine() {
895 return SendMsg(2152, 0, 0);
898 // Retrieve the contents of a line.
899 wxString
wxStyledTextCtrl::GetLine(int line
) {
901 int len
= LineLength(line
);
902 char* buf
= text
.GetWriteBuf(len
+1);
904 int pos
= SendMsg(2153, line
, (long)buf
);
905 text
.UngetWriteBuf();
910 // Returns the number of lines in the document. There is always at least one.
911 int wxStyledTextCtrl::GetLineCount() {
912 return SendMsg(2154, 0, 0);
915 // Sets the size in pixels of the left margin.
916 void wxStyledTextCtrl::SetMarginLeft(int width
) {
917 SendMsg(2155, 0, width
);
920 // Returns the size in pixels of the left margin.
921 int wxStyledTextCtrl::GetMarginLeft() {
922 return SendMsg(2156, 0, 0);
925 // Sets the size in pixels of the right margin.
926 void wxStyledTextCtrl::SetMarginRight(int width
) {
927 SendMsg(2157, 0, width
);
930 // Returns the size in pixels of the right margin.
931 int wxStyledTextCtrl::GetMarginRight() {
932 return SendMsg(2158, 0, 0);
935 // Is the document different from when it was last saved?
936 bool wxStyledTextCtrl::GetModify() {
937 return SendMsg(2159, 0, 0) != 0;
940 // Select a range of text.
941 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
942 SendMsg(2160, start
, end
);
945 // Retrieve the selected text.
946 wxString
wxStyledTextCtrl::GetSelectedText() {
951 GetSelection(&start
, &end
);
952 int len
= end
- start
;
953 char* buff
= text
.GetWriteBuf(len
+1);
955 SendMsg(2161, 0, (long)buff
);
956 text
.UngetWriteBuf();
960 // Retrieve a range of text.
961 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
963 int len
= endPos
- startPos
;
964 char* buff
= text
.GetWriteBuf(len
+1);
967 tr
.chrg
.cpMin
= startPos
;
968 tr
.chrg
.cpMax
= endPos
;
970 SendMsg(2162, 0, (long)&tr
);
971 text
.UngetWriteBuf();
975 // Draw the selection in normal style or with selection highlighted.
976 void wxStyledTextCtrl::HideSelection(bool normal
) {
977 SendMsg(2163, normal
, 0);
980 // Retrieve the line containing a position.
981 int wxStyledTextCtrl::LineFromPosition(int pos
) {
982 return SendMsg(2166, pos
, 0);
985 // Retrieve the position at the start of a line.
986 int wxStyledTextCtrl::PositionFromLine(int line
) {
987 return SendMsg(2167, line
, 0);
990 // Scroll horizontally and vertically.
991 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
992 SendMsg(2168, columns
, lines
);
995 // Ensure the caret is visible.
996 void wxStyledTextCtrl::EnsureCaretVisible() {
1000 // Replace the selected text with the argument text.
1001 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1002 SendMsg(2170, 0, (long)text
.c_str());
1005 // Set to read only or read write.
1006 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1007 SendMsg(2171, readOnly
, 0);
1010 // Will a paste succeed?
1011 bool wxStyledTextCtrl::CanPaste() {
1012 return SendMsg(2173, 0, 0) != 0;
1015 // Are there any undoable actions in the undo history.
1016 bool wxStyledTextCtrl::CanUndo() {
1017 return SendMsg(2174, 0, 0) != 0;
1020 // Delete the undo history.
1021 void wxStyledTextCtrl::EmptyUndoBuffer() {
1022 SendMsg(2175, 0, 0);
1025 // Undo one action in the undo history.
1026 void wxStyledTextCtrl::Undo() {
1027 SendMsg(2176, 0, 0);
1030 // Cut the selection to the clipboard.
1031 void wxStyledTextCtrl::Cut() {
1032 SendMsg(2177, 0, 0);
1035 // Copy the selection to the clipboard.
1036 void wxStyledTextCtrl::Copy() {
1037 SendMsg(2178, 0, 0);
1040 // Paste the contents of the clipboard into the document replacing the selection.
1041 void wxStyledTextCtrl::Paste() {
1042 SendMsg(2179, 0, 0);
1045 // Clear the selection.
1046 void wxStyledTextCtrl::Clear() {
1047 SendMsg(2180, 0, 0);
1050 // Replace the contents of the document with the argument text.
1051 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1052 SendMsg(2181, 0, (long)text
.c_str());
1055 // Retrieve all the text in the document.
1056 wxString
wxStyledTextCtrl::GetText() {
1058 int len
= GetTextLength();
1059 char* buff
= text
.GetWriteBuf(len
+1);
1061 SendMsg(2182, len
, (long)buff
);
1063 text
.UngetWriteBuf();
1067 // Retrieve the number of characters in the document.
1068 int wxStyledTextCtrl::GetTextLength() {
1069 return SendMsg(2183, 0, 0);
1072 // Set to overtype (true) or insert mode
1073 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1074 SendMsg(2186, overtype
, 0);
1077 // Returns true if overtype mode is active otherwise false is returned.
1078 bool wxStyledTextCtrl::GetOvertype() {
1079 return SendMsg(2187, 0, 0) != 0;
1082 // Show a call tip containing a definition near position pos.
1083 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1084 SendMsg(2200, pos
, (long)definition
.c_str());
1087 // Remove the call tip from the screen.
1088 void wxStyledTextCtrl::CallTipCancel() {
1089 SendMsg(2201, 0, 0);
1092 // Is there an active call tip?
1093 bool wxStyledTextCtrl::CallTipActive() {
1094 return SendMsg(2202, 0, 0) != 0;
1097 // Retrieve the position where the caret was before displaying the call tip.
1098 int wxStyledTextCtrl::CallTipPosAtStart() {
1099 return SendMsg(2203, 0, 0);
1102 // Highlight a segment of the definition.
1103 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1104 SendMsg(2204, start
, end
);
1107 // Set the background colour for the call tip.
1108 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1109 SendMsg(2205, wxColourAsLong(back
), 0);
1112 // Find the display line of a document line taking hidden lines into account.
1113 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1114 return SendMsg(2220, line
, 0);
1117 // Find the document line of a display line taking hidden lines into account.
1118 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1119 return SendMsg(2221, lineDisplay
, 0);
1122 // Set the fold level of a line.
1123 // This encodes an integer level along with flags indicating whether the
1124 // line is a header and whether it is effectively white space.
1125 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1126 SendMsg(2222, line
, level
);
1129 // Retrieve the fold level of a line.
1130 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1131 return SendMsg(2223, line
, 0);
1134 // Find the last child line of a header line.
1135 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1136 return SendMsg(2224, line
, level
);
1139 // Find the parent line of a child line.
1140 int wxStyledTextCtrl::GetFoldParent(int line
) {
1141 return SendMsg(2225, line
, 0);
1144 // Make a range of lines visible.
1145 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1146 SendMsg(2226, lineStart
, lineEnd
);
1149 // Make a range of lines invisible.
1150 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1151 SendMsg(2227, lineStart
, lineEnd
);
1154 // Is a line visible?
1155 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1156 return SendMsg(2228, line
, 0) != 0;
1159 // Show the children of a header line.
1160 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1161 SendMsg(2229, line
, expanded
);
1164 // Is a header line expanded?
1165 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1166 return SendMsg(2230, line
, 0) != 0;
1169 // Switch a header line between expanded and contracted.
1170 void wxStyledTextCtrl::ToggleFold(int line
) {
1171 SendMsg(2231, line
, 0);
1174 // Ensure a particular line is visible by expanding any header line hiding it.
1175 void wxStyledTextCtrl::EnsureVisible(int line
) {
1176 SendMsg(2232, line
, 0);
1179 // Set some debugging options for folding
1180 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1181 SendMsg(2233, flags
, 0);
1184 // How many characters are on a line, not including end of line characters.
1185 int wxStyledTextCtrl::LineLength(int line
) {
1186 return SendMsg(2350, line
, 0);
1189 // Highlight the characters at two positions.
1190 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1191 SendMsg(2351, pos1
, pos2
);
1194 // Highlight the character at a position indicating there is no matching brace.
1195 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1196 SendMsg(2352, pos
, 0);
1199 // Find the position of a matching brace or INVALID_POSITION if no match.
1200 int wxStyledTextCtrl::BraceMatch(int pos
) {
1201 return SendMsg(2353, pos
, 0);
1204 // Are the end of line characters visible.
1205 bool wxStyledTextCtrl::GetViewEOL() {
1206 return SendMsg(2355, 0, 0) != 0;
1209 // Make the end of line characters visible or invisible
1210 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1211 SendMsg(2356, visible
, 0);
1214 // Retrieve a pointer to the document object.
1215 void* wxStyledTextCtrl::GetDocPointer() {
1216 return (void*)SendMsg(2357);
1219 // Change the document object used.
1220 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1221 SendMsg(2358, (long)docPointer
);
1224 // Set which document modification events are sent to the container.
1225 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1226 SendMsg(2359, mask
, 0);
1229 // Retrieve the column number which text should be kept within.
1230 int wxStyledTextCtrl::GetEdgeColumn() {
1231 return SendMsg(2360, 0, 0);
1234 // Set the column number of the edge.
1235 // If text goes past the edge then it is highlighted.
1236 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1237 SendMsg(2361, column
, 0);
1240 // Retrieve the edge highlight mode.
1241 int wxStyledTextCtrl::GetEdgeMode() {
1242 return SendMsg(2362, 0, 0);
1245 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1246 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1247 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
1248 SendMsg(2363, mode
, 0);
1251 // Retrieve the colour used in edge indication.
1252 wxColour
wxStyledTextCtrl::GetEdgeColour() {
1253 long c
= SendMsg(2364, 0, 0);
1254 return wxColourFromLong(c
);
1257 // Change the colour used in edge indication.
1258 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
1259 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
1262 // Sets the current caret position to be the search anchor.
1263 void wxStyledTextCtrl::SearchAnchor() {
1264 SendMsg(2366, 0, 0);
1267 // Find some text starting at the search anchor.
1268 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
1269 return SendMsg(2367, flags
, (long)text
.c_str());
1272 // Find some text starting at the search anchor and moving backwards.
1273 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
1274 return SendMsg(2368, flags
, (long)text
.c_str());
1277 // Set the way the line the caret is on is kept visible.
1278 void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy
, int caretSlop
) {
1279 SendMsg(2369, caretPolicy
, caretSlop
);
1282 // Retrieves the number of lines completely visible.
1283 int wxStyledTextCtrl::LinesOnScreen() {
1284 return SendMsg(2370, 0, 0);
1287 // Set whether a pop up menu is displayed automatically when the user presses
1288 // the wrong mouse button.
1289 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
1290 SendMsg(2371, allowPopUp
, 0);
1293 // Is the selection a rectangular. The alternative is the more common stream selection.
1294 bool wxStyledTextCtrl::SelectionIsRectangle() {
1295 return SendMsg(2372, 0, 0) != 0;
1298 // Set the zoom level. This number of points is added to the size of all fonts.
1299 // It may be positive to magnify or negative to reduce.
1300 void wxStyledTextCtrl::SetZoom(int zoom
) {
1301 SendMsg(2373, zoom
, 0);
1304 // Retrieve the zoom level.
1305 int wxStyledTextCtrl::GetZoom() {
1306 return SendMsg(2374, 0, 0);
1309 // Create a new document object.
1310 // Starts with reference count of 1 and not selected into editor.
1311 void* wxStyledTextCtrl::CreateDocument() {
1312 return (void*)SendMsg(2375);
1315 // Extend life of document.
1316 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
1317 SendMsg(2376, (long)docPointer
);
1320 // Release a reference to the document, deleting document if it fades to black.
1321 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
1322 SendMsg(2377, (long)docPointer
);
1325 // Get which document modification events are sent to the container.
1326 int wxStyledTextCtrl::GetModEventMask() {
1327 return SendMsg(2378, 0, 0);
1330 // Start notifying the container of all key presses and commands.
1331 void wxStyledTextCtrl::StartRecord() {
1332 SendMsg(3001, 0, 0);
1335 // Stop notifying the container of all key presses and commands.
1336 void wxStyledTextCtrl::StopRecord() {
1337 SendMsg(3002, 0, 0);
1340 // Set the lexing language of the document.
1341 void wxStyledTextCtrl::SetLexer(int lexer
) {
1342 SendMsg(4001, lexer
, 0);
1345 // Retrieve the lexing language of the document.
1346 int wxStyledTextCtrl::GetLexer() {
1347 return SendMsg(4002, 0, 0);
1350 // Colourise a segment of the document using the current lexing language.
1351 void wxStyledTextCtrl::Colourise(int start
, int end
) {
1352 SendMsg(4003, start
, end
);
1355 // Set up a value that may be used by a lexer for some optional feature.
1356 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
1357 SendMsg(4004, (long)key
.c_str(), (long)value
.c_str());
1360 // Set up the key words used by the lexer.
1361 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
1362 SendMsg(4005, keywordSet
, (long)keyWords
.c_str());
1365 // END of generated section
1366 //----------------------------------------------------------------------
1369 // Returns the line number of the line with the caret.
1370 int wxStyledTextCtrl::GetCurrentLine() {
1371 int line
= LineFromPosition(GetCurrentPos());
1376 // Extract style settings from a spec-string which is composed of one or
1377 // more of the following comma separated elements:
1379 // bold turns on bold
1380 // italic turns on italics
1381 // fore:#RRGGBB sets the foreground colour
1382 // back:#RRGGBB sets the background colour
1383 // face:[facename] sets the font face name to use
1384 // size:[num] sets the font size in points
1385 // eol turns on eol filling
1386 // underline turns on underlining
1388 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
1390 wxStringTokenizer
tkz(spec
, ",");
1391 while (tkz
.HasMoreTokens()) {
1392 wxString token
= tkz
.GetNextToken();
1394 wxString option
= token
.BeforeFirst(':');
1395 wxString val
= token
.AfterFirst(':');
1397 if (option
== "bold")
1398 StyleSetBold(styleNum
, true);
1400 else if (option
== "italic")
1401 StyleSetItalic(styleNum
, true);
1403 else if (option
== "underline")
1404 StyleSetUnderline(styleNum
, true);
1406 else if (option
== "eol")
1407 StyleSetEOLFilled(styleNum
, true);
1409 else if (option
== "size") {
1411 if (val
.ToLong(&points
))
1412 StyleSetSize(styleNum
, points
);
1415 else if (option
== "face")
1416 StyleSetFaceName(styleNum
, val
);
1418 else if (option
== "fore")
1419 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
1421 else if (option
== "back")
1422 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
1427 // Set style size, face, bold, italic, and underline attributes from
1428 // a wxFont's attributes.
1429 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
1430 int size
= font
.GetPointSize();
1431 wxString faceName
= font
.GetFaceName();
1432 bool bold
= font
.GetWeight() == wxBOLD
;
1433 bool italic
= font
.GetStyle() != wxNORMAL
;
1434 bool under
= font
.GetUnderlined();
1436 // TODO: add encoding/charset mapping
1437 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
1440 // Set all font style attributes at once.
1441 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
1442 const wxString
& faceName
,
1443 bool bold
, bool italic
,
1445 StyleSetSize(styleNum
, size
);
1446 StyleSetFaceName(styleNum
, faceName
);
1447 StyleSetBold(styleNum
, bold
);
1448 StyleSetItalic(styleNum
, italic
);
1449 StyleSetUnderline(styleNum
, underline
);
1451 // TODO: add encoding/charset mapping
1455 // Perform one of the operations defined by the wxSTC_CMD_* constants.
1456 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
1461 // Set the left and right margin in the edit area, measured in pixels.
1462 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
1463 SetMarginLeft(left
);
1464 SetMarginRight(right
);
1468 // Retrieve the start and end positions of the current selection.
1469 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
1470 if (startPos
!= NULL
)
1471 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
1473 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
1477 // Retrieve the point in the window where a position is displayed.
1478 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
1479 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
1480 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
1481 return wxPoint(x
, y
);
1485 // Scroll enough to make the given line visible
1486 void wxStyledTextCtrl::ScrollToLine(int line
) {
1487 m_swx
->DoScrollToLine(line
);
1491 // Scroll enough to make the given column visible
1492 void wxStyledTextCtrl::ScrollToColumn(int column
) {
1493 m_swx
->DoScrollToColumn(column
);
1497 //----------------------------------------------------------------------
1500 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& evt
) {
1502 wxRegion region
= GetUpdateRegion();
1504 m_swx
->DoPaint(&dc
, region
.GetBox());
1507 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
1508 if (evt
.GetOrientation() == wxHORIZONTAL
)
1509 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1511 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1514 void wxStyledTextCtrl::OnSize(wxSizeEvent
& evt
) {
1515 wxSize sz
= GetClientSize();
1516 m_swx
->DoSize(sz
.x
, sz
.y
);
1519 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
1520 wxPoint pt
= evt
.GetPosition();
1521 m_swx
->DoButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1522 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
1525 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
1526 wxPoint pt
= evt
.GetPosition();
1527 m_swx
->DoButtonMove(Point(pt
.x
, pt
.y
));
1530 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
1531 wxPoint pt
= evt
.GetPosition();
1532 m_swx
->DoButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1537 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
1538 wxPoint pt
= evt
.GetPosition();
1539 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1542 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
1543 long key
= evt
.KeyCode();
1544 if ((key
> WXK_ESCAPE
) &&
1545 (key
!= WXK_DELETE
) && (key
< 255) &&
1546 !evt
.ControlDown() && !evt
.AltDown()) {
1548 m_swx
->DoAddChar(key
);
1555 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
1556 long key
= evt
.KeyCode();
1558 int processed
= m_swx
->DoKeyDown(key
, evt
.ShiftDown(),
1559 evt
.ControlDown(), evt
.AltDown());
1564 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
1565 m_swx
->DoLoseFocus();
1568 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
1569 m_swx
->DoGainFocus();
1572 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& evt
) {
1573 m_swx
->DoSysColourChange();
1576 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& evt
) {
1577 // do nothing to help avoid flashing
1582 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
1583 m_swx
->DoCommand(evt
.GetId());
1587 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& evt
) {
1588 m_swx
->DoOnListBox();
1592 //----------------------------------------------------------------------
1593 // Turn notifications from Scintilla into events
1596 void wxStyledTextCtrl::NotifyChange() {
1597 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
1598 GetEventHandler()->ProcessEvent(evt
);
1601 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
1602 SCNotification
& scn
= *_scn
;
1604 switch (scn
.nmhdr
.code
) {
1605 case SCN_STYLENEEDED
:
1606 eventType
= wxEVT_STC_STYLENEEDED
;
1609 eventType
= wxEVT_STC_CHARADDED
;
1612 eventType
= wxEVT_STC_UPDATEUI
;
1614 case SCN_SAVEPOINTREACHED
:
1615 eventType
= wxEVT_STC_SAVEPOINTREACHED
;
1617 case SCN_SAVEPOINTLEFT
:
1618 eventType
= wxEVT_STC_SAVEPOINTLEFT
;
1620 case SCN_MODIFYATTEMPTRO
:
1621 eventType
= wxEVT_STC_ROMODIFYATTEMPT
;
1623 case SCN_DOUBLECLICK
:
1624 eventType
= wxEVT_STC_DOUBLECLICK
;
1627 eventType
= wxEVT_STC_MODIFIED
;
1630 eventType
= wxEVT_STC_KEY
;
1632 case SCN_MACRORECORD
:
1633 eventType
= wxEVT_STC_MACRORECORD
;
1635 case SCN_MARGINCLICK
:
1636 eventType
= wxEVT_STC_MARGINCLICK
;
1639 eventType
= wxEVT_STC_NEEDSHOWN
;
1641 case SCN_POSCHANGED
:
1642 eventType
= wxEVT_STC_POSCHANGED
;
1646 wxStyledTextEvent
evt(eventType
, GetId());
1647 evt
.SetPosition(scn
.position
);
1649 evt
.SetModifiers(scn
.modifiers
);
1650 if (eventType
== wxEVT_STC_MODIFIED
) {
1651 evt
.SetModificationType(scn
.modificationType
);
1653 evt
.SetText(wxString(scn
.text
, scn
.length
));
1654 evt
.SetLength(scn
.length
);
1655 evt
.SetLinesAdded(scn
.linesAdded
);
1656 evt
.SetLine(scn
.line
);
1657 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
1658 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
1660 if (eventType
== wxEVT_STC_MARGINCLICK
)
1661 evt
.SetMargin(scn
.margin
);
1662 if (eventType
== wxEVT_STC_MACRORECORD
) {
1663 evt
.SetMessage(scn
.message
);
1664 evt
.SetWParam(scn
.wParam
);
1665 evt
.SetLParam(scn
.lParam
);
1668 GetEventHandler()->ProcessEvent(evt
);
1674 //----------------------------------------------------------------------
1675 //----------------------------------------------------------------------
1676 //----------------------------------------------------------------------
1678 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
1679 : wxCommandEvent(commandType
, id
)
1684 m_modificationType
= 0;
1689 m_foldLevelPrev
= 0;
1698 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
1699 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
1700 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
1702 void wxStyledTextEvent::CopyObject(wxObject
& obj
) const {
1703 wxCommandEvent::CopyObject(obj
);
1705 wxStyledTextEvent
* o
= (wxStyledTextEvent
*)&obj
;
1706 o
->m_position
= m_position
;
1708 o
->m_modifiers
= m_modifiers
;
1709 o
->m_modificationType
= m_modificationType
;
1711 o
->m_length
= m_length
;
1712 o
->m_linesAdded
= m_linesAdded
;
1714 o
->m_foldLevelNow
= m_foldLevelNow
;
1715 o
->m_foldLevelPrev
= m_foldLevelPrev
;
1717 o
->m_margin
= m_margin
;
1719 o
->m_message
= m_message
;
1720 o
->m_wParam
= m_wParam
;
1721 o
->m_lParam
= m_lParam
;
1727 //----------------------------------------------------------------------
1728 //----------------------------------------------------------------------