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";
70 DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE
)
71 DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED
)
72 DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED
)
73 DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI
)
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_DOUBLECLICK
)
78 DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED
)
79 DEFINE_EVENT_TYPE( wxEVT_STC_KEY
)
80 DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD
)
81 DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK
)
82 DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN
)
83 DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED
)
86 BEGIN_EVENT_TABLE(wxStyledTextCtrl
, wxControl
)
87 EVT_PAINT (wxStyledTextCtrl::OnPaint
)
88 EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin
)
89 EVT_SIZE (wxStyledTextCtrl::OnSize
)
90 EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown
)
91 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
92 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
93 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
94 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
95 EVT_CHAR (wxStyledTextCtrl::OnChar
)
96 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
97 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
98 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
99 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
100 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
101 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu
)
102 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox
)
106 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
107 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
109 //----------------------------------------------------------------------
110 // Constructor and Destructor
112 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
117 const wxString
& name
) :
118 wxControl(parent
, id
, pos
, size
,
119 style
| wxVSCROLL
| wxHSCROLL
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
120 wxDefaultValidator
, name
)
122 m_swx
= new ScintillaWX(this);
127 wxStyledTextCtrl::~wxStyledTextCtrl() {
132 //----------------------------------------------------------------------
134 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
136 return m_swx
->WndProc(msg
, wp
, lp
);
144 #define MAKELONG(a, b) ((a) | ((b) << 16))
147 static long wxColourAsLong(const wxColour
& co
) {
148 return (((long)co
.Blue() << 16) |
149 ((long)co
.Green() << 8) |
153 static wxColour
wxColourFromLong(long c
) {
155 clr
.Set(c
& 0xff, (c
>> 8) & 0xff, (c
>> 16) & 0xff);
160 static wxColour
wxColourFromSpec(const wxString
& spec
) {
161 // spec should be #RRGGBB
163 int red
= strtol(spec
.Mid(1,2), &junk
, 16);
164 int green
= strtol(spec
.Mid(3,2), &junk
, 16);
165 int blue
= strtol(spec
.Mid(5,2), &junk
, 16);
166 return wxColour(red
, green
, blue
);
170 //----------------------------------------------------------------------
171 // BEGIN generated section. The following code is automatically generated
172 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
173 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
176 // Add text to the document
177 void wxStyledTextCtrl::AddText(const wxString
& text
) {
178 SendMsg(2001, text
.Len(), (long)text
.c_str());
181 // Add array of cells to document
182 void wxStyledTextCtrl::AddStyledText(const wxString
& text
) {
183 SendMsg(2002, text
.Len(), (long)text
.c_str());
186 // Insert string at a position
187 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
188 SendMsg(2003, pos
, (long)text
.c_str());
191 // Delete all text in the document
192 void wxStyledTextCtrl::ClearAll() {
196 // Set all style bytes to 0, remove all folding information
197 void wxStyledTextCtrl::ClearDocumentStyle() {
201 // The number of characters in the document
202 int wxStyledTextCtrl::GetLength() {
203 return SendMsg(2006, 0, 0);
206 // Returns the character byte at the position
207 int wxStyledTextCtrl::GetCharAt(int pos
) {
208 return SendMsg(2007, pos
, 0);
211 // Returns the position of the caret
212 int wxStyledTextCtrl::GetCurrentPos() {
213 return SendMsg(2008, 0, 0);
216 // Returns the position of the opposite end of the selection to the caret
217 int wxStyledTextCtrl::GetAnchor() {
218 return SendMsg(2009, 0, 0);
221 // Returns the style byte at the position
222 int wxStyledTextCtrl::GetStyleAt(int pos
) {
223 return SendMsg(2010, pos
, 0);
226 // Redoes the next action on the undo history
227 void wxStyledTextCtrl::Redo() {
231 // Choose between collecting actions into the undo
232 // history and discarding them.
233 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
234 SendMsg(2012, collectUndo
, 0);
237 // Select all the text in the document.
238 void wxStyledTextCtrl::SelectAll() {
242 // Remember the current position in the undo history as the position
243 // at which the document was saved.
244 void wxStyledTextCtrl::SetSavePoint() {
248 // Retrieve a buffer of cells.
249 wxString
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
251 int len
= endPos
- startPos
;
253 tr
.lpstrText
= text
.GetWriteBuf(len
*2+1);
254 tr
.chrg
.cpMin
= startPos
;
255 tr
.chrg
.cpMax
= endPos
;
256 SendMsg(2015, 0, (long)&tr
);
257 text
.UngetWriteBuf(len
*2);
261 // Are there any redoable actions in the undo history.
262 bool wxStyledTextCtrl::CanRedo() {
263 return SendMsg(2016, 0, 0) != 0;
266 // Retrieve the line number at which a particular marker is located
267 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
268 return SendMsg(2017, handle
, 0);
272 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
273 SendMsg(2018, handle
, 0);
276 // Is undo history being collected?
277 bool wxStyledTextCtrl::GetUndoCollection() {
278 return SendMsg(2019, 0, 0) != 0;
281 // Are white space characters currently visible?
282 // Returns one of SCWS_* constants.
283 int wxStyledTextCtrl::GetViewWhiteSpace() {
284 return SendMsg(2020, 0, 0);
287 // Make white space characters invisible, always visible or visible outside indentation.
288 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
289 SendMsg(2021, viewWS
, 0);
292 // Find the position from a point within the window.
293 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
294 return SendMsg(2022, pt
.x
, pt
.y
);
297 // Set caret to start of a line and ensure it is visible.
298 void wxStyledTextCtrl::GotoLine(int line
) {
299 SendMsg(2024, line
, 0);
302 // Set caret to a position and ensure it is visible.
303 void wxStyledTextCtrl::GotoPos(int pos
) {
304 SendMsg(2025, pos
, 0);
307 // Set the selection anchor to a position. The anchor is the opposite
308 // end of the selection from the caret.
309 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
310 SendMsg(2026, posAnchor
, 0);
313 // Retrieve the text of the line containing the caret.
314 // Returns the index of the caret on the line.
315 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
317 int len
= LineLength(GetCurrentLine());
318 char* buf
= text
.GetWriteBuf(len
+1);
320 int pos
= SendMsg(2027, len
, (long)buf
);
321 text
.UngetWriteBuf();
322 if (linePos
) *linePos
= pos
;
327 // Retrieve the position of the last correctly styled character.
328 int wxStyledTextCtrl::GetEndStyled() {
329 return SendMsg(2028, 0, 0);
332 // Convert all line endings in the document to use the current mode.
333 void wxStyledTextCtrl::ConvertEOLs() {
337 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
338 int wxStyledTextCtrl::GetEOLMode() {
339 return SendMsg(2030, 0, 0);
342 // Set the current end of line mode.
343 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
344 SendMsg(2031, eolMode
, 0);
347 // Set the current styling position to pos and the styling mask to mask.
348 // The styling mask can be used to protect some bits in each styling byte from
350 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
351 SendMsg(2032, pos
, mask
);
354 // Change style from current styling position for length characters to a style
355 // and move the current styling position to after this newly styled segment.
356 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
357 SendMsg(2033, length
, style
);
360 // Is drawing done first into a buffer or direct to the screen.
361 bool wxStyledTextCtrl::GetBufferedDraw() {
362 return SendMsg(2034, 0, 0) != 0;
365 // If drawing is buffered then each line of text is drawn into a bitmap buffer
366 // before drawing it to the screen to avoid flicker.
367 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
368 SendMsg(2035, buffered
, 0);
371 // Change the visible size of a tab to be a multiple of the width of a space
373 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
374 SendMsg(2036, tabWidth
, 0);
377 // Retrieve the visible size of a tab.
378 int wxStyledTextCtrl::GetTabWidth() {
379 return SendMsg(2121, 0, 0);
382 // Set the code page used to interpret the bytes of the document as characters.
383 // The SC_CP_UTF8 value can be used to enter Unicode mode.
384 void wxStyledTextCtrl::SetCodePage(int codePage
) {
385 SendMsg(2037, codePage
, 0);
388 // Set the symbol used for a particular marker number,
389 // and optionally the for and background colours.
390 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
391 const wxColour
& foreground
,
392 const wxColour
& background
) {
394 SendMsg(2040, markerNumber
, markerSymbol
);
396 MarkerSetForeground(markerNumber
, foreground
);
398 MarkerSetBackground(markerNumber
, background
);
401 // Set the foreground colour used for a particular marker number.
402 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
403 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
406 // Set the background colour used for a particular marker number.
407 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
408 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
411 // Add a marker to a line.
412 void wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
413 SendMsg(2043, line
, markerNumber
);
416 // Delete a marker from a line
417 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
418 SendMsg(2044, line
, markerNumber
);
421 // Delete all markers with a particular number from all lines
422 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
423 SendMsg(2045, markerNumber
, 0);
426 // Get a bit mask of all the markers set on a line.
427 int wxStyledTextCtrl::MarkerGet(int line
) {
428 return SendMsg(2046, line
, 0);
431 // Find the next line after lineStart that includes a marker in mask.
432 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
433 return SendMsg(2047, lineStart
, markerMask
);
436 // Find the previous line before lineStart that includes a marker in mask.
437 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
438 return SendMsg(2048, lineStart
, markerMask
);
441 // Set a margin to be either numeric or symbolic.
442 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
443 SendMsg(2240, margin
, marginType
);
446 // Retrieve the type of a margin.
447 int wxStyledTextCtrl::GetMarginType(int margin
) {
448 return SendMsg(2241, margin
, 0);
451 // Set the width of a margin to a width expressed in pixels.
452 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
453 SendMsg(2242, margin
, pixelWidth
);
456 // Retrieve the width of a margin in pixels.
457 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
458 return SendMsg(2243, margin
, 0);
461 // Set a mask that determines which markers are displayed in a margin.
462 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
463 SendMsg(2244, margin
, mask
);
466 // Retrieve the marker mask of a margin.
467 int wxStyledTextCtrl::GetMarginMask(int margin
) {
468 return SendMsg(2245, margin
, 0);
471 // Make a margin sensitive or insensitive to mouse clicks.
472 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
473 SendMsg(2246, margin
, sensitive
);
476 // Retrieve the mouse click sensitivity of a margin.
477 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
478 return SendMsg(2247, margin
, 0) != 0;
481 // Clear all the styles and make equivalent to the global default style.
482 void wxStyledTextCtrl::StyleClearAll() {
486 // Set the foreground colour of a style.
487 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
488 SendMsg(2051, style
, wxColourAsLong(fore
));
491 // Set the background colour of a style.
492 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
493 SendMsg(2052, style
, wxColourAsLong(back
));
496 // Set a style to be bold or not.
497 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
498 SendMsg(2053, style
, bold
);
501 // Set a style to be italic or not.
502 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
503 SendMsg(2054, style
, italic
);
506 // Set the size of characters of a style.
507 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
508 SendMsg(2055, style
, sizePoints
);
511 // Set the font of a style.
512 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
513 SendMsg(2056, style
, (long)fontName
.c_str());
516 // Set a style to have its end of line filled or not.
517 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
518 SendMsg(2057, style
, filled
);
521 // Reset the default style to its state at startup
522 void wxStyledTextCtrl::StyleResetDefault() {
526 // Set a style to be underlined or not.
527 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
528 SendMsg(2059, style
, underline
);
531 // Set the foreground colour of the selection and whether to use this setting.
532 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
533 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
536 // Set the background colour of the selection and whether to use this setting.
537 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
538 SendMsg(2068, useSetting
, wxColourAsLong(back
));
541 // Set the foreground colour of the caret.
542 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
543 SendMsg(2069, wxColourAsLong(fore
), 0);
546 // When key+modifier combination km is pressed perform msg.
547 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
548 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
551 // When key+modifier combination km do nothing.
552 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
553 SendMsg(2071, MAKELONG(key
, modifiers
));
556 // Drop all key mappings.
557 void wxStyledTextCtrl::CmdKeyClearAll() {
561 // Set the styles for a segment of the document.
562 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
563 SendMsg(2073, length
, (long)styleBytes
);
566 // Set a style to be visible or not.
567 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
568 SendMsg(2074, style
, visible
);
571 // Get the time in milliseconds that the caret is on and off.
572 int wxStyledTextCtrl::GetCaretPeriod() {
573 return SendMsg(2075, 0, 0);
576 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
577 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
578 SendMsg(2076, periodMilliseconds
, 0);
581 // Set the set of characters making up words for when moving or selecting
583 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
584 SendMsg(2077, 0, (long)characters
.c_str());
587 // Start a sequence of actions that is undone and redone as a unit.
589 void wxStyledTextCtrl::BeginUndoAction() {
593 // End a sequence of actions that is undone and redone as a unit.
594 void wxStyledTextCtrl::EndUndoAction() {
598 // Set an indicator to plain, squiggle or TT.
599 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
600 SendMsg(2080, indic
, style
);
603 // Retrieve the style of an indicator.
604 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
605 return SendMsg(2081, indic
, 0);
608 // Set the foreground colour of an indicator.
609 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
610 SendMsg(2082, indic
, wxColourAsLong(fore
));
613 // Retrieve the foreground colour of an indicator.
614 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
615 long c
= SendMsg(2083, indic
, 0);
616 return wxColourFromLong(c
);
619 // Divide each styling byte into lexical class bits (default:5) and indicator
620 // bits (default:3). If a lexer requires more than 32 lexical states, then this
621 // is used to expand the possible states.
622 void wxStyledTextCtrl::SetStyleBits(int bits
) {
623 SendMsg(2090, bits
, 0);
626 // Retrieve number of bits in style bytes used to hold the lexical state.
627 int wxStyledTextCtrl::GetStyleBits() {
628 return SendMsg(2091, 0, 0);
631 // Used to hold extra styling information for each line.
632 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
633 SendMsg(2092, line
, state
);
636 // Retrieve the extra styling information for a line.
637 int wxStyledTextCtrl::GetLineState(int line
) {
638 return SendMsg(2093, line
, 0);
641 // Retrieve the last line number that has line state.
642 int wxStyledTextCtrl::GetMaxLineState() {
643 return SendMsg(2094, 0, 0);
646 // Display a auto-completion list.
647 // The lenEntered parameter indicates how many characters before
648 // the caret should be used to provide context.
649 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
650 SendMsg(2100, lenEntered
, (long)itemList
.c_str());
653 // Remove the auto-completion list from the screen.
654 void wxStyledTextCtrl::AutoCompCancel() {
658 // Is there an auto-completion list visible?
659 bool wxStyledTextCtrl::AutoCompActive() {
660 return SendMsg(2102, 0, 0) != 0;
663 // Retrieve the position of the caret when the auto-completion list was
665 int wxStyledTextCtrl::AutoCompPosStart() {
666 return SendMsg(2103, 0, 0);
669 // User has selected an item so remove the list and insert the selection.
670 void wxStyledTextCtrl::AutoCompComplete() {
674 // Define a set of character that when typed cancel the auto-completion list.
675 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
676 SendMsg(2105, 0, (long)characterSet
.c_str());
679 // Change the separator character in the string setting up an auto-completion
680 // list. Default is space but can be changed if items contain space.
681 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
682 SendMsg(2106, separatorCharacter
, 0);
685 // Retrieve the auto-completion list separator character.
686 int wxStyledTextCtrl::AutoCompGetSeparator() {
687 return SendMsg(2107, 0, 0);
690 // Select the item in the auto-completion list that starts with a string.
691 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
692 SendMsg(2108, 0, (long)text
.c_str());
695 // Should the auto-completion list be cancelled if the user backspaces to a
696 // position before where the box was created.
697 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
698 SendMsg(2110, cancel
, 0);
701 // Retrieve whether auto-completion cancelled by backspacing before start.
702 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
703 return SendMsg(2111, 0, 0) != 0;
706 // Define a set of character that when typed fills up the selected word.
707 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
708 SendMsg(2112, 0, (long)characterSet
.c_str());
711 // Should a single item auto-completion list automatically choose the item.
712 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
713 SendMsg(2113, chooseSingle
, 0);
716 // Retrieve whether a single item auto-completion list automatically choose the item.
717 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
718 return SendMsg(2114, 0, 0) != 0;
721 // Set whether case is significant when performing auto-completion searches.
722 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
723 SendMsg(2115, ignoreCase
, 0);
726 // Retrieve state of ignore case flag.
727 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
728 return SendMsg(2116, 0, 0) != 0;
731 // Set the number of spaces used for one level of indentation.
732 void wxStyledTextCtrl::SetIndent(int indentSize
) {
733 SendMsg(2122, indentSize
, 0);
736 // Retrieve indentation size.
737 int wxStyledTextCtrl::GetIndent() {
738 return SendMsg(2123, 0, 0);
741 // Indentation will only use space characters if useTabs is false, otherwise
742 // it will use a combination of tabs and spaces.
743 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
744 SendMsg(2124, useTabs
, 0);
747 // Retrieve whether tabs will be used in indentation.
748 bool wxStyledTextCtrl::GetUseTabs() {
749 return SendMsg(2125, 0, 0) != 0;
752 // Change the indentation of a line to a number of columns.
753 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
754 SendMsg(2126, line
, indentSize
);
757 // Retrieve the number of columns that a line is indented.
758 int wxStyledTextCtrl::GetLineIndentation(int line
) {
759 return SendMsg(2127, line
, 0);
762 // Retrieve the position before the first non indentation character on a line.
763 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
764 return SendMsg(2128, line
, 0);
767 // Retrieve the column number of a position, taking tab width into account.
768 int wxStyledTextCtrl::GetColumn(int pos
) {
769 return SendMsg(2129, pos
, 0);
772 // Show or hide the horizontal scroll bar.
773 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
774 SendMsg(2130, show
, 0);
777 // Is the horizontal scroll bar visible?
778 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
779 return SendMsg(2131, 0, 0) != 0;
782 // Show or hide indentation guides.
783 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
784 SendMsg(2132, show
, 0);
787 // Are the indentation guides visible?
788 bool wxStyledTextCtrl::GetIndentationGuides() {
789 return SendMsg(2133, 0, 0) != 0;
792 // Set the highlighted indentation guide column.
793 // 0 = no highlighted guide.
794 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
795 SendMsg(2134, column
, 0);
798 // Get the highlighted indentation guide column.
799 int wxStyledTextCtrl::GetHighlightGuide() {
800 return SendMsg(2135, 0, 0);
803 // Get the position after the last visible characters on a line.
804 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
805 return SendMsg(2136, line
, 0);
808 // Get the code page used to interpret the bytes of the document as characters.
809 int wxStyledTextCtrl::GetCodePage() {
810 return SendMsg(2137, 0, 0);
813 // Get the foreground colour of the caret.
814 wxColour
wxStyledTextCtrl::GetCaretForeground() {
815 long c
= SendMsg(2138, 0, 0);
816 return wxColourFromLong(c
);
819 // In read-only mode?
820 bool wxStyledTextCtrl::GetReadOnly() {
821 return SendMsg(2140, 0, 0) != 0;
824 // Sets the position of the caret.
825 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
826 SendMsg(2141, pos
, 0);
829 // Sets the position that starts the selection - this becomes the anchor.
830 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
831 SendMsg(2142, pos
, 0);
834 // Returns the position at the start of the selection.
835 int wxStyledTextCtrl::GetSelectionStart() {
836 return SendMsg(2143, 0, 0);
839 // Sets the position that ends the selection - this becomes the currentPosition.
840 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
841 SendMsg(2144, pos
, 0);
844 // Returns the position at the end of the selection.
845 int wxStyledTextCtrl::GetSelectionEnd() {
846 return SendMsg(2145, 0, 0);
849 // Sets the print magnification added to the point size of each style for printing.
850 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
851 SendMsg(2146, magnification
, 0);
854 // Returns the print magnification.
855 int wxStyledTextCtrl::GetPrintMagnification() {
856 return SendMsg(2147, 0, 0);
859 // Modify colours when printing for clearer printed text.
860 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
861 SendMsg(2148, mode
, 0);
864 // Returns the print colour mode.
865 int wxStyledTextCtrl::GetPrintColourMode() {
866 return SendMsg(2149, 0, 0);
869 // Find some text in the document.
870 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
871 const wxString
& text
,
872 bool caseSensitive
, bool wholeWord
) {
876 flags
|= caseSensitive
? SCFIND_MATCHCASE
: 0;
877 flags
|= wholeWord
? SCFIND_WHOLEWORD
: 0;
878 ft
.chrg
.cpMin
= minPos
;
879 ft
.chrg
.cpMax
= maxPos
;
880 ft
.lpstrText
= (char*)text
.c_str();
882 return SendMsg(2150, flags
, (long)&ft
);
885 // On Windows will draw the document into a display context such as a printer.
886 int wxStyledTextCtrl::FormatRange(bool doDraw
,
890 wxDC
* target
, // Why does it use two? Can they be the same?
896 fr
.hdcTarget
= target
;
897 fr
.rc
.top
= renderRect
.GetTop();
898 fr
.rc
.left
= renderRect
.GetLeft();
899 fr
.rc
.right
= renderRect
.GetRight();
900 fr
.rc
.bottom
= renderRect
.GetBottom();
901 fr
.rcPage
.top
= pageRect
.GetTop();
902 fr
.rcPage
.left
= pageRect
.GetLeft();
903 fr
.rcPage
.right
= pageRect
.GetRight();
904 fr
.rcPage
.bottom
= pageRect
.GetBottom();
905 fr
.chrg
.cpMin
= startPos
;
906 fr
.chrg
.cpMax
= endPos
;
908 return SendMsg(2151, doDraw
, (long)&fr
);
911 // Retrieve the line at the top of the display.
912 int wxStyledTextCtrl::GetFirstVisibleLine() {
913 return SendMsg(2152, 0, 0);
916 // Retrieve the contents of a line.
917 wxString
wxStyledTextCtrl::GetLine(int line
) {
919 int len
= LineLength(line
);
920 char* buf
= text
.GetWriteBuf(len
+1);
922 int pos
= SendMsg(2153, line
, (long)buf
);
923 text
.UngetWriteBuf();
928 // Returns the number of lines in the document. There is always at least one.
929 int wxStyledTextCtrl::GetLineCount() {
930 return SendMsg(2154, 0, 0);
933 // Sets the size in pixels of the left margin.
934 void wxStyledTextCtrl::SetMarginLeft(int width
) {
935 SendMsg(2155, 0, width
);
938 // Returns the size in pixels of the left margin.
939 int wxStyledTextCtrl::GetMarginLeft() {
940 return SendMsg(2156, 0, 0);
943 // Sets the size in pixels of the right margin.
944 void wxStyledTextCtrl::SetMarginRight(int width
) {
945 SendMsg(2157, 0, width
);
948 // Returns the size in pixels of the right margin.
949 int wxStyledTextCtrl::GetMarginRight() {
950 return SendMsg(2158, 0, 0);
953 // Is the document different from when it was last saved?
954 bool wxStyledTextCtrl::GetModify() {
955 return SendMsg(2159, 0, 0) != 0;
958 // Select a range of text.
959 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
960 SendMsg(2160, start
, end
);
963 // Retrieve the selected text.
964 wxString
wxStyledTextCtrl::GetSelectedText() {
969 GetSelection(&start
, &end
);
970 int len
= end
- start
;
971 char* buff
= text
.GetWriteBuf(len
+1);
973 SendMsg(2161, 0, (long)buff
);
974 text
.UngetWriteBuf();
978 // Retrieve a range of text.
979 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
981 int len
= endPos
- startPos
;
982 char* buff
= text
.GetWriteBuf(len
+1);
985 tr
.chrg
.cpMin
= startPos
;
986 tr
.chrg
.cpMax
= endPos
;
988 SendMsg(2162, 0, (long)&tr
);
989 text
.UngetWriteBuf();
993 // Draw the selection in normal style or with selection highlighted.
994 void wxStyledTextCtrl::HideSelection(bool normal
) {
995 SendMsg(2163, normal
, 0);
998 // Retrieve the line containing a position.
999 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1000 return SendMsg(2166, pos
, 0);
1003 // Retrieve the position at the start of a line.
1004 int wxStyledTextCtrl::PositionFromLine(int line
) {
1005 return SendMsg(2167, line
, 0);
1008 // Scroll horizontally and vertically.
1009 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1010 SendMsg(2168, columns
, lines
);
1013 // Ensure the caret is visible.
1014 void wxStyledTextCtrl::EnsureCaretVisible() {
1015 SendMsg(2169, 0, 0);
1018 // Replace the selected text with the argument text.
1019 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1020 SendMsg(2170, 0, (long)text
.c_str());
1023 // Set to read only or read write.
1024 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1025 SendMsg(2171, readOnly
, 0);
1028 // Will a paste succeed?
1029 bool wxStyledTextCtrl::CanPaste() {
1030 return SendMsg(2173, 0, 0) != 0;
1033 // Are there any undoable actions in the undo history.
1034 bool wxStyledTextCtrl::CanUndo() {
1035 return SendMsg(2174, 0, 0) != 0;
1038 // Delete the undo history.
1039 void wxStyledTextCtrl::EmptyUndoBuffer() {
1040 SendMsg(2175, 0, 0);
1043 // Undo one action in the undo history.
1044 void wxStyledTextCtrl::Undo() {
1045 SendMsg(2176, 0, 0);
1048 // Cut the selection to the clipboard.
1049 void wxStyledTextCtrl::Cut() {
1050 SendMsg(2177, 0, 0);
1053 // Copy the selection to the clipboard.
1054 void wxStyledTextCtrl::Copy() {
1055 SendMsg(2178, 0, 0);
1058 // Paste the contents of the clipboard into the document replacing the selection.
1059 void wxStyledTextCtrl::Paste() {
1060 SendMsg(2179, 0, 0);
1063 // Clear the selection.
1064 void wxStyledTextCtrl::Clear() {
1065 SendMsg(2180, 0, 0);
1068 // Replace the contents of the document with the argument text.
1069 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1070 SendMsg(2181, 0, (long)text
.c_str());
1073 // Retrieve all the text in the document.
1074 wxString
wxStyledTextCtrl::GetText() {
1076 int len
= GetTextLength();
1077 char* buff
= text
.GetWriteBuf(len
+1);
1079 SendMsg(2182, len
, (long)buff
);
1081 text
.UngetWriteBuf();
1085 // Retrieve the number of characters in the document.
1086 int wxStyledTextCtrl::GetTextLength() {
1087 return SendMsg(2183, 0, 0);
1090 // Set to overtype (true) or insert mode
1091 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1092 SendMsg(2186, overtype
, 0);
1095 // Returns true if overtype mode is active otherwise false is returned.
1096 bool wxStyledTextCtrl::GetOvertype() {
1097 return SendMsg(2187, 0, 0) != 0;
1100 // Show a call tip containing a definition near position pos.
1101 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1102 SendMsg(2200, pos
, (long)definition
.c_str());
1105 // Remove the call tip from the screen.
1106 void wxStyledTextCtrl::CallTipCancel() {
1107 SendMsg(2201, 0, 0);
1110 // Is there an active call tip?
1111 bool wxStyledTextCtrl::CallTipActive() {
1112 return SendMsg(2202, 0, 0) != 0;
1115 // Retrieve the position where the caret was before displaying the call tip.
1116 int wxStyledTextCtrl::CallTipPosAtStart() {
1117 return SendMsg(2203, 0, 0);
1120 // Highlight a segment of the definition.
1121 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1122 SendMsg(2204, start
, end
);
1125 // Set the background colour for the call tip.
1126 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1127 SendMsg(2205, wxColourAsLong(back
), 0);
1130 // Find the display line of a document line taking hidden lines into account.
1131 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1132 return SendMsg(2220, line
, 0);
1135 // Find the document line of a display line taking hidden lines into account.
1136 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1137 return SendMsg(2221, lineDisplay
, 0);
1140 // Set the fold level of a line.
1141 // This encodes an integer level along with flags indicating whether the
1142 // line is a header and whether it is effectively white space.
1143 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1144 SendMsg(2222, line
, level
);
1147 // Retrieve the fold level of a line.
1148 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1149 return SendMsg(2223, line
, 0);
1152 // Find the last child line of a header line.
1153 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1154 return SendMsg(2224, line
, level
);
1157 // Find the parent line of a child line.
1158 int wxStyledTextCtrl::GetFoldParent(int line
) {
1159 return SendMsg(2225, line
, 0);
1162 // Make a range of lines visible.
1163 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1164 SendMsg(2226, lineStart
, lineEnd
);
1167 // Make a range of lines invisible.
1168 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1169 SendMsg(2227, lineStart
, lineEnd
);
1172 // Is a line visible?
1173 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1174 return SendMsg(2228, line
, 0) != 0;
1177 // Show the children of a header line.
1178 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1179 SendMsg(2229, line
, expanded
);
1182 // Is a header line expanded?
1183 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1184 return SendMsg(2230, line
, 0) != 0;
1187 // Switch a header line between expanded and contracted.
1188 void wxStyledTextCtrl::ToggleFold(int line
) {
1189 SendMsg(2231, line
, 0);
1192 // Ensure a particular line is visible by expanding any header line hiding it.
1193 void wxStyledTextCtrl::EnsureVisible(int line
) {
1194 SendMsg(2232, line
, 0);
1197 // Set some debugging options for folding
1198 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1199 SendMsg(2233, flags
, 0);
1202 // How many characters are on a line, not including end of line characters.
1203 int wxStyledTextCtrl::LineLength(int line
) {
1204 return SendMsg(2350, line
, 0);
1207 // Highlight the characters at two positions.
1208 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1209 SendMsg(2351, pos1
, pos2
);
1212 // Highlight the character at a position indicating there is no matching brace.
1213 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1214 SendMsg(2352, pos
, 0);
1217 // Find the position of a matching brace or INVALID_POSITION if no match.
1218 int wxStyledTextCtrl::BraceMatch(int pos
) {
1219 return SendMsg(2353, pos
, 0);
1222 // Are the end of line characters visible.
1223 bool wxStyledTextCtrl::GetViewEOL() {
1224 return SendMsg(2355, 0, 0) != 0;
1227 // Make the end of line characters visible or invisible
1228 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1229 SendMsg(2356, visible
, 0);
1232 // Retrieve a pointer to the document object.
1233 void* wxStyledTextCtrl::GetDocPointer() {
1234 return (void*)SendMsg(2357);
1237 // Change the document object used.
1238 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1239 SendMsg(2358, (long)docPointer
);
1242 // Set which document modification events are sent to the container.
1243 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1244 SendMsg(2359, mask
, 0);
1247 // Retrieve the column number which text should be kept within.
1248 int wxStyledTextCtrl::GetEdgeColumn() {
1249 return SendMsg(2360, 0, 0);
1252 // Set the column number of the edge.
1253 // If text goes past the edge then it is highlighted.
1254 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1255 SendMsg(2361, column
, 0);
1258 // Retrieve the edge highlight mode.
1259 int wxStyledTextCtrl::GetEdgeMode() {
1260 return SendMsg(2362, 0, 0);
1263 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1264 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1265 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
1266 SendMsg(2363, mode
, 0);
1269 // Retrieve the colour used in edge indication.
1270 wxColour
wxStyledTextCtrl::GetEdgeColour() {
1271 long c
= SendMsg(2364, 0, 0);
1272 return wxColourFromLong(c
);
1275 // Change the colour used in edge indication.
1276 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
1277 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
1280 // Sets the current caret position to be the search anchor.
1281 void wxStyledTextCtrl::SearchAnchor() {
1282 SendMsg(2366, 0, 0);
1285 // Find some text starting at the search anchor.
1286 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
1287 return SendMsg(2367, flags
, (long)text
.c_str());
1290 // Find some text starting at the search anchor and moving backwards.
1291 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
1292 return SendMsg(2368, flags
, (long)text
.c_str());
1295 // Set the way the line the caret is on is kept visible.
1296 void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy
, int caretSlop
) {
1297 SendMsg(2369, caretPolicy
, caretSlop
);
1300 // Retrieves the number of lines completely visible.
1301 int wxStyledTextCtrl::LinesOnScreen() {
1302 return SendMsg(2370, 0, 0);
1305 // Set whether a pop up menu is displayed automatically when the user presses
1306 // the wrong mouse button.
1307 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
1308 SendMsg(2371, allowPopUp
, 0);
1311 // Is the selection a rectangular. The alternative is the more common stream selection.
1312 bool wxStyledTextCtrl::SelectionIsRectangle() {
1313 return SendMsg(2372, 0, 0) != 0;
1316 // Set the zoom level. This number of points is added to the size of all fonts.
1317 // It may be positive to magnify or negative to reduce.
1318 void wxStyledTextCtrl::SetZoom(int zoom
) {
1319 SendMsg(2373, zoom
, 0);
1322 // Retrieve the zoom level.
1323 int wxStyledTextCtrl::GetZoom() {
1324 return SendMsg(2374, 0, 0);
1327 // Create a new document object.
1328 // Starts with reference count of 1 and not selected into editor.
1329 void* wxStyledTextCtrl::CreateDocument() {
1330 return (void*)SendMsg(2375);
1333 // Extend life of document.
1334 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
1335 SendMsg(2376, (long)docPointer
);
1338 // Release a reference to the document, deleting document if it fades to black.
1339 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
1340 SendMsg(2377, (long)docPointer
);
1343 // Get which document modification events are sent to the container.
1344 int wxStyledTextCtrl::GetModEventMask() {
1345 return SendMsg(2378, 0, 0);
1348 // Start notifying the container of all key presses and commands.
1349 void wxStyledTextCtrl::StartRecord() {
1350 SendMsg(3001, 0, 0);
1353 // Stop notifying the container of all key presses and commands.
1354 void wxStyledTextCtrl::StopRecord() {
1355 SendMsg(3002, 0, 0);
1358 // Set the lexing language of the document.
1359 void wxStyledTextCtrl::SetLexer(int lexer
) {
1360 SendMsg(4001, lexer
, 0);
1363 // Retrieve the lexing language of the document.
1364 int wxStyledTextCtrl::GetLexer() {
1365 return SendMsg(4002, 0, 0);
1368 // Colourise a segment of the document using the current lexing language.
1369 void wxStyledTextCtrl::Colourise(int start
, int end
) {
1370 SendMsg(4003, start
, end
);
1373 // Set up a value that may be used by a lexer for some optional feature.
1374 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
1375 SendMsg(4004, (long)key
.c_str(), (long)value
.c_str());
1378 // Set up the key words used by the lexer.
1379 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
1380 SendMsg(4005, keywordSet
, (long)keyWords
.c_str());
1383 // END of generated section
1384 //----------------------------------------------------------------------
1387 // Returns the line number of the line with the caret.
1388 int wxStyledTextCtrl::GetCurrentLine() {
1389 int line
= LineFromPosition(GetCurrentPos());
1394 // Extract style settings from a spec-string which is composed of one or
1395 // more of the following comma separated elements:
1397 // bold turns on bold
1398 // italic turns on italics
1399 // fore:#RRGGBB sets the foreground colour
1400 // back:#RRGGBB sets the background colour
1401 // face:[facename] sets the font face name to use
1402 // size:[num] sets the font size in points
1403 // eol turns on eol filling
1404 // underline turns on underlining
1406 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
1408 wxStringTokenizer
tkz(spec
, ",");
1409 while (tkz
.HasMoreTokens()) {
1410 wxString token
= tkz
.GetNextToken();
1412 wxString option
= token
.BeforeFirst(':');
1413 wxString val
= token
.AfterFirst(':');
1415 if (option
== "bold")
1416 StyleSetBold(styleNum
, true);
1418 else if (option
== "italic")
1419 StyleSetItalic(styleNum
, true);
1421 else if (option
== "underline")
1422 StyleSetUnderline(styleNum
, true);
1424 else if (option
== "eol")
1425 StyleSetEOLFilled(styleNum
, true);
1427 else if (option
== "size") {
1429 if (val
.ToLong(&points
))
1430 StyleSetSize(styleNum
, points
);
1433 else if (option
== "face")
1434 StyleSetFaceName(styleNum
, val
);
1436 else if (option
== "fore")
1437 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
1439 else if (option
== "back")
1440 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
1445 // Set style size, face, bold, italic, and underline attributes from
1446 // a wxFont's attributes.
1447 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
1448 int size
= font
.GetPointSize();
1449 wxString faceName
= font
.GetFaceName();
1450 bool bold
= font
.GetWeight() == wxBOLD
;
1451 bool italic
= font
.GetStyle() != wxNORMAL
;
1452 bool under
= font
.GetUnderlined();
1454 // TODO: add encoding/charset mapping
1455 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
1458 // Set all font style attributes at once.
1459 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
1460 const wxString
& faceName
,
1461 bool bold
, bool italic
,
1463 StyleSetSize(styleNum
, size
);
1464 StyleSetFaceName(styleNum
, faceName
);
1465 StyleSetBold(styleNum
, bold
);
1466 StyleSetItalic(styleNum
, italic
);
1467 StyleSetUnderline(styleNum
, underline
);
1469 // TODO: add encoding/charset mapping
1473 // Perform one of the operations defined by the wxSTC_CMD_* constants.
1474 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
1479 // Set the left and right margin in the edit area, measured in pixels.
1480 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
1481 SetMarginLeft(left
);
1482 SetMarginRight(right
);
1486 // Retrieve the start and end positions of the current selection.
1487 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
1488 if (startPos
!= NULL
)
1489 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
1491 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
1495 // Retrieve the point in the window where a position is displayed.
1496 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
1497 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
1498 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
1499 return wxPoint(x
, y
);
1502 // Scroll enough to make the given line visible
1503 void wxStyledTextCtrl::ScrollToLine(int line
) {
1504 m_swx
->DoScrollToLine(line
);
1508 // Scroll enough to make the given column visible
1509 void wxStyledTextCtrl::ScrollToColumn(int column
) {
1510 m_swx
->DoScrollToColumn(column
);
1515 //----------------------------------------------------------------------
1518 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& evt
) {
1520 wxRegion region
= GetUpdateRegion();
1522 m_swx
->DoPaint(&dc
, region
.GetBox());
1525 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
1526 if (evt
.GetOrientation() == wxHORIZONTAL
)
1527 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1529 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1532 void wxStyledTextCtrl::OnSize(wxSizeEvent
& evt
) {
1533 wxSize sz
= GetClientSize();
1534 m_swx
->DoSize(sz
.x
, sz
.y
);
1537 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
1538 wxPoint pt
= evt
.GetPosition();
1539 m_swx
->DoButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1540 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
1543 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
1544 wxPoint pt
= evt
.GetPosition();
1545 m_swx
->DoButtonMove(Point(pt
.x
, pt
.y
));
1548 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
1549 wxPoint pt
= evt
.GetPosition();
1550 m_swx
->DoButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1555 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
1556 wxPoint pt
= evt
.GetPosition();
1557 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1561 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
1562 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
1563 evt
.GetWheelDelta(),
1564 evt
.GetLinesPerAction());
1568 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
1569 long key
= evt
.KeyCode();
1570 if ((key
> WXK_ESCAPE
) &&
1571 (key
!= WXK_DELETE
) && (key
< 255) &&
1572 !evt
.ControlDown() && !evt
.AltDown()) {
1574 m_swx
->DoAddChar(key
);
1581 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
1582 long key
= evt
.KeyCode();
1584 int processed
= m_swx
->DoKeyDown(key
, evt
.ShiftDown(),
1585 evt
.ControlDown(), evt
.AltDown());
1590 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
1591 m_swx
->DoLoseFocus();
1594 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
1595 m_swx
->DoGainFocus();
1598 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& evt
) {
1599 m_swx
->DoSysColourChange();
1602 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& evt
) {
1603 // do nothing to help avoid flashing
1608 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
1609 m_swx
->DoCommand(evt
.GetId());
1613 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& evt
) {
1614 m_swx
->DoOnListBox();
1618 //----------------------------------------------------------------------
1619 // Turn notifications from Scintilla into events
1622 void wxStyledTextCtrl::NotifyChange() {
1623 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
1624 GetEventHandler()->ProcessEvent(evt
);
1627 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
1628 SCNotification
& scn
= *_scn
;
1630 switch (scn
.nmhdr
.code
) {
1631 case SCN_STYLENEEDED
:
1632 eventType
= wxEVT_STC_STYLENEEDED
;
1635 eventType
= wxEVT_STC_CHARADDED
;
1638 eventType
= wxEVT_STC_UPDATEUI
;
1640 case SCN_SAVEPOINTREACHED
:
1641 eventType
= wxEVT_STC_SAVEPOINTREACHED
;
1643 case SCN_SAVEPOINTLEFT
:
1644 eventType
= wxEVT_STC_SAVEPOINTLEFT
;
1646 case SCN_MODIFYATTEMPTRO
:
1647 eventType
= wxEVT_STC_ROMODIFYATTEMPT
;
1649 case SCN_DOUBLECLICK
:
1650 eventType
= wxEVT_STC_DOUBLECLICK
;
1653 eventType
= wxEVT_STC_MODIFIED
;
1656 eventType
= wxEVT_STC_KEY
;
1658 case SCN_MACRORECORD
:
1659 eventType
= wxEVT_STC_MACRORECORD
;
1661 case SCN_MARGINCLICK
:
1662 eventType
= wxEVT_STC_MARGINCLICK
;
1665 eventType
= wxEVT_STC_NEEDSHOWN
;
1667 case SCN_POSCHANGED
:
1668 eventType
= wxEVT_STC_POSCHANGED
;
1672 wxStyledTextEvent
evt(eventType
, GetId());
1673 evt
.SetPosition(scn
.position
);
1675 evt
.SetModifiers(scn
.modifiers
);
1676 if (eventType
== wxEVT_STC_MODIFIED
) {
1677 evt
.SetModificationType(scn
.modificationType
);
1679 evt
.SetText(wxString(scn
.text
, scn
.length
));
1680 evt
.SetLength(scn
.length
);
1681 evt
.SetLinesAdded(scn
.linesAdded
);
1682 evt
.SetLine(scn
.line
);
1683 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
1684 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
1686 if (eventType
== wxEVT_STC_MARGINCLICK
)
1687 evt
.SetMargin(scn
.margin
);
1688 if (eventType
== wxEVT_STC_MACRORECORD
) {
1689 evt
.SetMessage(scn
.message
);
1690 evt
.SetWParam(scn
.wParam
);
1691 evt
.SetLParam(scn
.lParam
);
1694 GetEventHandler()->ProcessEvent(evt
);
1700 //----------------------------------------------------------------------
1701 //----------------------------------------------------------------------
1702 //----------------------------------------------------------------------
1704 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
1705 : wxCommandEvent(commandType
, id
)
1710 m_modificationType
= 0;
1715 m_foldLevelPrev
= 0;
1724 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
1725 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
1726 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
1728 void wxStyledTextEvent::CopyObject(wxObject
& obj
) const {
1729 wxCommandEvent::CopyObject(obj
);
1731 wxStyledTextEvent
* o
= (wxStyledTextEvent
*)&obj
;
1732 o
->m_position
= m_position
;
1734 o
->m_modifiers
= m_modifiers
;
1735 o
->m_modificationType
= m_modificationType
;
1737 o
->m_length
= m_length
;
1738 o
->m_linesAdded
= m_linesAdded
;
1740 o
->m_foldLevelNow
= m_foldLevelNow
;
1741 o
->m_foldLevelPrev
= m_foldLevelPrev
;
1743 o
->m_margin
= m_margin
;
1745 o
->m_message
= m_message
;
1746 o
->m_wParam
= m_wParam
;
1747 o
->m_lParam
= m_lParam
;
1753 //----------------------------------------------------------------------
1754 //----------------------------------------------------------------------