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
)
92 // Let Scintilla see the double click as a second click
93 EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown
)
95 EVT_MOTION (wxStyledTextCtrl::OnMouseMove
)
96 EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp
)
97 EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp
)
98 EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel
)
99 EVT_CHAR (wxStyledTextCtrl::OnChar
)
100 EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown
)
101 EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus
)
102 EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus
)
103 EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged
)
104 EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground
)
105 EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu
)
106 EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox
)
110 IMPLEMENT_CLASS(wxStyledTextCtrl
, wxControl
)
111 IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent
, wxCommandEvent
)
113 //----------------------------------------------------------------------
114 // Constructor and Destructor
116 wxStyledTextCtrl::wxStyledTextCtrl(wxWindow
*parent
,
121 const wxString
& name
) :
122 wxControl(parent
, id
, pos
, size
,
123 style
| wxVSCROLL
| wxHSCROLL
| wxWANTS_CHARS
| wxCLIP_CHILDREN
,
124 wxDefaultValidator
, name
)
126 m_swx
= new ScintillaWX(this);
131 wxStyledTextCtrl::~wxStyledTextCtrl() {
136 //----------------------------------------------------------------------
138 long wxStyledTextCtrl::SendMsg(int msg
, long wp
, long lp
) {
140 return m_swx
->WndProc(msg
, wp
, lp
);
148 #define MAKELONG(a, b) ((a) | ((b) << 16))
151 static long wxColourAsLong(const wxColour
& co
) {
152 return (((long)co
.Blue() << 16) |
153 ((long)co
.Green() << 8) |
157 static wxColour
wxColourFromLong(long c
) {
159 clr
.Set(c
& 0xff, (c
>> 8) & 0xff, (c
>> 16) & 0xff);
164 static wxColour
wxColourFromSpec(const wxString
& spec
) {
165 // spec should be #RRGGBB
167 int red
= strtol(spec
.Mid(1,2), &junk
, 16);
168 int green
= strtol(spec
.Mid(3,2), &junk
, 16);
169 int blue
= strtol(spec
.Mid(5,2), &junk
, 16);
170 return wxColour(red
, green
, blue
);
174 //----------------------------------------------------------------------
175 // BEGIN generated section. The following code is automatically generated
176 // by gen_iface.py from the contents of Scintilla.iface. Do not edit
177 // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate.
180 // Add text to the document
181 void wxStyledTextCtrl::AddText(const wxString
& text
) {
182 SendMsg(2001, text
.Len(), (long)text
.c_str());
185 // Add array of cells to document
186 void wxStyledTextCtrl::AddStyledText(const wxString
& text
) {
187 SendMsg(2002, text
.Len(), (long)text
.c_str());
190 // Insert string at a position
191 void wxStyledTextCtrl::InsertText(int pos
, const wxString
& text
) {
192 SendMsg(2003, pos
, (long)text
.c_str());
195 // Delete all text in the document
196 void wxStyledTextCtrl::ClearAll() {
200 // Set all style bytes to 0, remove all folding information
201 void wxStyledTextCtrl::ClearDocumentStyle() {
205 // The number of characters in the document
206 int wxStyledTextCtrl::GetLength() {
207 return SendMsg(2006, 0, 0);
210 // Returns the character byte at the position
211 int wxStyledTextCtrl::GetCharAt(int pos
) {
212 return SendMsg(2007, pos
, 0);
215 // Returns the position of the caret
216 int wxStyledTextCtrl::GetCurrentPos() {
217 return SendMsg(2008, 0, 0);
220 // Returns the position of the opposite end of the selection to the caret
221 int wxStyledTextCtrl::GetAnchor() {
222 return SendMsg(2009, 0, 0);
225 // Returns the style byte at the position
226 int wxStyledTextCtrl::GetStyleAt(int pos
) {
227 return SendMsg(2010, pos
, 0);
230 // Redoes the next action on the undo history
231 void wxStyledTextCtrl::Redo() {
235 // Choose between collecting actions into the undo
236 // history and discarding them.
237 void wxStyledTextCtrl::SetUndoCollection(bool collectUndo
) {
238 SendMsg(2012, collectUndo
, 0);
241 // Select all the text in the document.
242 void wxStyledTextCtrl::SelectAll() {
246 // Remember the current position in the undo history as the position
247 // at which the document was saved.
248 void wxStyledTextCtrl::SetSavePoint() {
252 // Retrieve a buffer of cells.
253 wxString
wxStyledTextCtrl::GetStyledText(int startPos
, int endPos
) {
255 int len
= endPos
- startPos
;
258 tr
.lpstrText
= text
.GetWriteBuf(len
*2);
259 tr
.chrg
.cpMin
= startPos
;
260 tr
.chrg
.cpMax
= endPos
;
261 SendMsg(2015, 0, (long)&tr
);
262 text
.UngetWriteBuf(len
*2);
266 // Are there any redoable actions in the undo history.
267 bool wxStyledTextCtrl::CanRedo() {
268 return SendMsg(2016, 0, 0) != 0;
271 // Retrieve the line number at which a particular marker is located
272 int wxStyledTextCtrl::MarkerLineFromHandle(int handle
) {
273 return SendMsg(2017, handle
, 0);
277 void wxStyledTextCtrl::MarkerDeleteHandle(int handle
) {
278 SendMsg(2018, handle
, 0);
281 // Is undo history being collected?
282 bool wxStyledTextCtrl::GetUndoCollection() {
283 return SendMsg(2019, 0, 0) != 0;
286 // Are white space characters currently visible?
287 // Returns one of SCWS_* constants.
288 int wxStyledTextCtrl::GetViewWhiteSpace() {
289 return SendMsg(2020, 0, 0);
292 // Make white space characters invisible, always visible or visible outside indentation.
293 void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS
) {
294 SendMsg(2021, viewWS
, 0);
297 // Find the position from a point within the window.
298 int wxStyledTextCtrl::PositionFromPoint(wxPoint pt
) {
299 return SendMsg(2022, pt
.x
, pt
.y
);
302 // Set caret to start of a line and ensure it is visible.
303 void wxStyledTextCtrl::GotoLine(int line
) {
304 SendMsg(2024, line
, 0);
307 // Set caret to a position and ensure it is visible.
308 void wxStyledTextCtrl::GotoPos(int pos
) {
309 SendMsg(2025, pos
, 0);
312 // Set the selection anchor to a position. The anchor is the opposite
313 // end of the selection from the caret.
314 void wxStyledTextCtrl::SetAnchor(int posAnchor
) {
315 SendMsg(2026, posAnchor
, 0);
318 // Retrieve the text of the line containing the caret.
319 // Returns the index of the caret on the line.
320 wxString
wxStyledTextCtrl::GetCurLine(int* linePos
) {
322 int len
= LineLength(GetCurrentLine());
324 char* buf
= text
.GetWriteBuf(len
);
326 int pos
= SendMsg(2027, len
, (long)buf
);
327 text
.UngetWriteBuf(len
);
328 if (linePos
) *linePos
= pos
;
333 // Retrieve the position of the last correctly styled character.
334 int wxStyledTextCtrl::GetEndStyled() {
335 return SendMsg(2028, 0, 0);
338 // Convert all line endings in the document to use the current mode.
339 void wxStyledTextCtrl::ConvertEOLs() {
343 // Retrieve the current end of line mode - one of CRLF, CR, or LF.
344 int wxStyledTextCtrl::GetEOLMode() {
345 return SendMsg(2030, 0, 0);
348 // Set the current end of line mode.
349 void wxStyledTextCtrl::SetEOLMode(int eolMode
) {
350 SendMsg(2031, eolMode
, 0);
353 // Set the current styling position to pos and the styling mask to mask.
354 // The styling mask can be used to protect some bits in each styling byte from
356 void wxStyledTextCtrl::StartStyling(int pos
, int mask
) {
357 SendMsg(2032, pos
, mask
);
360 // Change style from current styling position for length characters to a style
361 // and move the current styling position to after this newly styled segment.
362 void wxStyledTextCtrl::SetStyling(int length
, int style
) {
363 SendMsg(2033, length
, style
);
366 // Is drawing done first into a buffer or direct to the screen.
367 bool wxStyledTextCtrl::GetBufferedDraw() {
368 return SendMsg(2034, 0, 0) != 0;
371 // If drawing is buffered then each line of text is drawn into a bitmap buffer
372 // before drawing it to the screen to avoid flicker.
373 void wxStyledTextCtrl::SetBufferedDraw(bool buffered
) {
374 SendMsg(2035, buffered
, 0);
377 // Change the visible size of a tab to be a multiple of the width of a space
379 void wxStyledTextCtrl::SetTabWidth(int tabWidth
) {
380 SendMsg(2036, tabWidth
, 0);
383 // Retrieve the visible size of a tab.
384 int wxStyledTextCtrl::GetTabWidth() {
385 return SendMsg(2121, 0, 0);
388 // Set the code page used to interpret the bytes of the document as characters.
389 // The SC_CP_UTF8 value can be used to enter Unicode mode.
390 void wxStyledTextCtrl::SetCodePage(int codePage
) {
391 SendMsg(2037, codePage
, 0);
394 // Set the symbol used for a particular marker number,
395 // and optionally the for and background colours.
396 void wxStyledTextCtrl::MarkerDefine(int markerNumber
, int markerSymbol
,
397 const wxColour
& foreground
,
398 const wxColour
& background
) {
400 SendMsg(2040, markerNumber
, markerSymbol
);
402 MarkerSetForeground(markerNumber
, foreground
);
404 MarkerSetBackground(markerNumber
, background
);
407 // Set the foreground colour used for a particular marker number.
408 void wxStyledTextCtrl::MarkerSetForeground(int markerNumber
, const wxColour
& fore
) {
409 SendMsg(2041, markerNumber
, wxColourAsLong(fore
));
412 // Set the background colour used for a particular marker number.
413 void wxStyledTextCtrl::MarkerSetBackground(int markerNumber
, const wxColour
& back
) {
414 SendMsg(2042, markerNumber
, wxColourAsLong(back
));
417 // Add a marker to a line.
418 void wxStyledTextCtrl::MarkerAdd(int line
, int markerNumber
) {
419 SendMsg(2043, line
, markerNumber
);
422 // Delete a marker from a line
423 void wxStyledTextCtrl::MarkerDelete(int line
, int markerNumber
) {
424 SendMsg(2044, line
, markerNumber
);
427 // Delete all markers with a particular number from all lines
428 void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber
) {
429 SendMsg(2045, markerNumber
, 0);
432 // Get a bit mask of all the markers set on a line.
433 int wxStyledTextCtrl::MarkerGet(int line
) {
434 return SendMsg(2046, line
, 0);
437 // Find the next line after lineStart that includes a marker in mask.
438 int wxStyledTextCtrl::MarkerNext(int lineStart
, int markerMask
) {
439 return SendMsg(2047, lineStart
, markerMask
);
442 // Find the previous line before lineStart that includes a marker in mask.
443 int wxStyledTextCtrl::MarkerPrevious(int lineStart
, int markerMask
) {
444 return SendMsg(2048, lineStart
, markerMask
);
447 // Set a margin to be either numeric or symbolic.
448 void wxStyledTextCtrl::SetMarginType(int margin
, int marginType
) {
449 SendMsg(2240, margin
, marginType
);
452 // Retrieve the type of a margin.
453 int wxStyledTextCtrl::GetMarginType(int margin
) {
454 return SendMsg(2241, margin
, 0);
457 // Set the width of a margin to a width expressed in pixels.
458 void wxStyledTextCtrl::SetMarginWidth(int margin
, int pixelWidth
) {
459 SendMsg(2242, margin
, pixelWidth
);
462 // Retrieve the width of a margin in pixels.
463 int wxStyledTextCtrl::GetMarginWidth(int margin
) {
464 return SendMsg(2243, margin
, 0);
467 // Set a mask that determines which markers are displayed in a margin.
468 void wxStyledTextCtrl::SetMarginMask(int margin
, int mask
) {
469 SendMsg(2244, margin
, mask
);
472 // Retrieve the marker mask of a margin.
473 int wxStyledTextCtrl::GetMarginMask(int margin
) {
474 return SendMsg(2245, margin
, 0);
477 // Make a margin sensitive or insensitive to mouse clicks.
478 void wxStyledTextCtrl::SetMarginSensitive(int margin
, bool sensitive
) {
479 SendMsg(2246, margin
, sensitive
);
482 // Retrieve the mouse click sensitivity of a margin.
483 bool wxStyledTextCtrl::GetMarginSensitive(int margin
) {
484 return SendMsg(2247, margin
, 0) != 0;
487 // Clear all the styles and make equivalent to the global default style.
488 void wxStyledTextCtrl::StyleClearAll() {
492 // Set the foreground colour of a style.
493 void wxStyledTextCtrl::StyleSetForeground(int style
, const wxColour
& fore
) {
494 SendMsg(2051, style
, wxColourAsLong(fore
));
497 // Set the background colour of a style.
498 void wxStyledTextCtrl::StyleSetBackground(int style
, const wxColour
& back
) {
499 SendMsg(2052, style
, wxColourAsLong(back
));
502 // Set a style to be bold or not.
503 void wxStyledTextCtrl::StyleSetBold(int style
, bool bold
) {
504 SendMsg(2053, style
, bold
);
507 // Set a style to be italic or not.
508 void wxStyledTextCtrl::StyleSetItalic(int style
, bool italic
) {
509 SendMsg(2054, style
, italic
);
512 // Set the size of characters of a style.
513 void wxStyledTextCtrl::StyleSetSize(int style
, int sizePoints
) {
514 SendMsg(2055, style
, sizePoints
);
517 // Set the font of a style.
518 void wxStyledTextCtrl::StyleSetFaceName(int style
, const wxString
& fontName
) {
519 SendMsg(2056, style
, (long)fontName
.c_str());
522 // Set a style to have its end of line filled or not.
523 void wxStyledTextCtrl::StyleSetEOLFilled(int style
, bool filled
) {
524 SendMsg(2057, style
, filled
);
527 // Reset the default style to its state at startup
528 void wxStyledTextCtrl::StyleResetDefault() {
532 // Set a style to be underlined or not.
533 void wxStyledTextCtrl::StyleSetUnderline(int style
, bool underline
) {
534 SendMsg(2059, style
, underline
);
537 // Set the foreground colour of the selection and whether to use this setting.
538 void wxStyledTextCtrl::SetSelForeground(bool useSetting
, const wxColour
& fore
) {
539 SendMsg(2067, useSetting
, wxColourAsLong(fore
));
542 // Set the background colour of the selection and whether to use this setting.
543 void wxStyledTextCtrl::SetSelBackground(bool useSetting
, const wxColour
& back
) {
544 SendMsg(2068, useSetting
, wxColourAsLong(back
));
547 // Set the foreground colour of the caret.
548 void wxStyledTextCtrl::SetCaretForeground(const wxColour
& fore
) {
549 SendMsg(2069, wxColourAsLong(fore
), 0);
552 // When key+modifier combination km is pressed perform msg.
553 void wxStyledTextCtrl::CmdKeyAssign(int key
, int modifiers
, int cmd
) {
554 SendMsg(2070, MAKELONG(key
, modifiers
), cmd
);
557 // When key+modifier combination km do nothing.
558 void wxStyledTextCtrl::CmdKeyClear(int key
, int modifiers
) {
559 SendMsg(2071, MAKELONG(key
, modifiers
));
562 // Drop all key mappings.
563 void wxStyledTextCtrl::CmdKeyClearAll() {
567 // Set the styles for a segment of the document.
568 void wxStyledTextCtrl::SetStyleBytes(int length
, char* styleBytes
) {
569 SendMsg(2073, length
, (long)styleBytes
);
572 // Set a style to be visible or not.
573 void wxStyledTextCtrl::StyleSetVisible(int style
, bool visible
) {
574 SendMsg(2074, style
, visible
);
577 // Get the time in milliseconds that the caret is on and off.
578 int wxStyledTextCtrl::GetCaretPeriod() {
579 return SendMsg(2075, 0, 0);
582 // Get the time in milliseconds that the caret is on and off. 0 = steady on.
583 void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds
) {
584 SendMsg(2076, periodMilliseconds
, 0);
587 // Set the set of characters making up words for when moving or selecting
589 void wxStyledTextCtrl::SetWordChars(const wxString
& characters
) {
590 SendMsg(2077, 0, (long)characters
.c_str());
593 // Start a sequence of actions that is undone and redone as a unit.
595 void wxStyledTextCtrl::BeginUndoAction() {
599 // End a sequence of actions that is undone and redone as a unit.
600 void wxStyledTextCtrl::EndUndoAction() {
604 // Set an indicator to plain, squiggle or TT.
605 void wxStyledTextCtrl::IndicatorSetStyle(int indic
, int style
) {
606 SendMsg(2080, indic
, style
);
609 // Retrieve the style of an indicator.
610 int wxStyledTextCtrl::IndicatorGetStyle(int indic
) {
611 return SendMsg(2081, indic
, 0);
614 // Set the foreground colour of an indicator.
615 void wxStyledTextCtrl::IndicatorSetForeground(int indic
, const wxColour
& fore
) {
616 SendMsg(2082, indic
, wxColourAsLong(fore
));
619 // Retrieve the foreground colour of an indicator.
620 wxColour
wxStyledTextCtrl::IndicatorGetForeground(int indic
) {
621 long c
= SendMsg(2083, indic
, 0);
622 return wxColourFromLong(c
);
625 // Divide each styling byte into lexical class bits (default:5) and indicator
626 // bits (default:3). If a lexer requires more than 32 lexical states, then this
627 // is used to expand the possible states.
628 void wxStyledTextCtrl::SetStyleBits(int bits
) {
629 SendMsg(2090, bits
, 0);
632 // Retrieve number of bits in style bytes used to hold the lexical state.
633 int wxStyledTextCtrl::GetStyleBits() {
634 return SendMsg(2091, 0, 0);
637 // Used to hold extra styling information for each line.
638 void wxStyledTextCtrl::SetLineState(int line
, int state
) {
639 SendMsg(2092, line
, state
);
642 // Retrieve the extra styling information for a line.
643 int wxStyledTextCtrl::GetLineState(int line
) {
644 return SendMsg(2093, line
, 0);
647 // Retrieve the last line number that has line state.
648 int wxStyledTextCtrl::GetMaxLineState() {
649 return SendMsg(2094, 0, 0);
652 // Display a auto-completion list.
653 // The lenEntered parameter indicates how many characters before
654 // the caret should be used to provide context.
655 void wxStyledTextCtrl::AutoCompShow(int lenEntered
, const wxString
& itemList
) {
656 SendMsg(2100, lenEntered
, (long)itemList
.c_str());
659 // Remove the auto-completion list from the screen.
660 void wxStyledTextCtrl::AutoCompCancel() {
664 // Is there an auto-completion list visible?
665 bool wxStyledTextCtrl::AutoCompActive() {
666 return SendMsg(2102, 0, 0) != 0;
669 // Retrieve the position of the caret when the auto-completion list was
671 int wxStyledTextCtrl::AutoCompPosStart() {
672 return SendMsg(2103, 0, 0);
675 // User has selected an item so remove the list and insert the selection.
676 void wxStyledTextCtrl::AutoCompComplete() {
680 // Define a set of character that when typed cancel the auto-completion list.
681 void wxStyledTextCtrl::AutoCompStops(const wxString
& characterSet
) {
682 SendMsg(2105, 0, (long)characterSet
.c_str());
685 // Change the separator character in the string setting up an auto-completion
686 // list. Default is space but can be changed if items contain space.
687 void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter
) {
688 SendMsg(2106, separatorCharacter
, 0);
691 // Retrieve the auto-completion list separator character.
692 int wxStyledTextCtrl::AutoCompGetSeparator() {
693 return SendMsg(2107, 0, 0);
696 // Select the item in the auto-completion list that starts with a string.
697 void wxStyledTextCtrl::AutoCompSelect(const wxString
& text
) {
698 SendMsg(2108, 0, (long)text
.c_str());
701 // Should the auto-completion list be cancelled if the user backspaces to a
702 // position before where the box was created.
703 void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel
) {
704 SendMsg(2110, cancel
, 0);
707 // Retrieve whether auto-completion cancelled by backspacing before start.
708 bool wxStyledTextCtrl::AutoCompGetCancelAtStart() {
709 return SendMsg(2111, 0, 0) != 0;
712 // Define a set of character that when typed fills up the selected word.
713 void wxStyledTextCtrl::AutoCompSetFillUps(const wxString
& characterSet
) {
714 SendMsg(2112, 0, (long)characterSet
.c_str());
717 // Should a single item auto-completion list automatically choose the item.
718 void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle
) {
719 SendMsg(2113, chooseSingle
, 0);
722 // Retrieve whether a single item auto-completion list automatically choose the item.
723 bool wxStyledTextCtrl::AutoCompGetChooseSingle() {
724 return SendMsg(2114, 0, 0) != 0;
727 // Set whether case is significant when performing auto-completion searches.
728 void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase
) {
729 SendMsg(2115, ignoreCase
, 0);
732 // Retrieve state of ignore case flag.
733 bool wxStyledTextCtrl::AutoCompGetIgnoreCase() {
734 return SendMsg(2116, 0, 0) != 0;
737 // Set the number of spaces used for one level of indentation.
738 void wxStyledTextCtrl::SetIndent(int indentSize
) {
739 SendMsg(2122, indentSize
, 0);
742 // Retrieve indentation size.
743 int wxStyledTextCtrl::GetIndent() {
744 return SendMsg(2123, 0, 0);
747 // Indentation will only use space characters if useTabs is false, otherwise
748 // it will use a combination of tabs and spaces.
749 void wxStyledTextCtrl::SetUseTabs(bool useTabs
) {
750 SendMsg(2124, useTabs
, 0);
753 // Retrieve whether tabs will be used in indentation.
754 bool wxStyledTextCtrl::GetUseTabs() {
755 return SendMsg(2125, 0, 0) != 0;
758 // Change the indentation of a line to a number of columns.
759 void wxStyledTextCtrl::SetLineIndentation(int line
, int indentSize
) {
760 SendMsg(2126, line
, indentSize
);
763 // Retrieve the number of columns that a line is indented.
764 int wxStyledTextCtrl::GetLineIndentation(int line
) {
765 return SendMsg(2127, line
, 0);
768 // Retrieve the position before the first non indentation character on a line.
769 int wxStyledTextCtrl::GetLineIndentPosition(int line
) {
770 return SendMsg(2128, line
, 0);
773 // Retrieve the column number of a position, taking tab width into account.
774 int wxStyledTextCtrl::GetColumn(int pos
) {
775 return SendMsg(2129, pos
, 0);
778 // Show or hide the horizontal scroll bar.
779 void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show
) {
780 SendMsg(2130, show
, 0);
783 // Is the horizontal scroll bar visible?
784 bool wxStyledTextCtrl::GetUseHorizontalScrollBar() {
785 return SendMsg(2131, 0, 0) != 0;
788 // Show or hide indentation guides.
789 void wxStyledTextCtrl::SetIndentationGuides(bool show
) {
790 SendMsg(2132, show
, 0);
793 // Are the indentation guides visible?
794 bool wxStyledTextCtrl::GetIndentationGuides() {
795 return SendMsg(2133, 0, 0) != 0;
798 // Set the highlighted indentation guide column.
799 // 0 = no highlighted guide.
800 void wxStyledTextCtrl::SetHighlightGuide(int column
) {
801 SendMsg(2134, column
, 0);
804 // Get the highlighted indentation guide column.
805 int wxStyledTextCtrl::GetHighlightGuide() {
806 return SendMsg(2135, 0, 0);
809 // Get the position after the last visible characters on a line.
810 int wxStyledTextCtrl::GetLineEndPosition(int line
) {
811 return SendMsg(2136, line
, 0);
814 // Get the code page used to interpret the bytes of the document as characters.
815 int wxStyledTextCtrl::GetCodePage() {
816 return SendMsg(2137, 0, 0);
819 // Get the foreground colour of the caret.
820 wxColour
wxStyledTextCtrl::GetCaretForeground() {
821 long c
= SendMsg(2138, 0, 0);
822 return wxColourFromLong(c
);
825 // In read-only mode?
826 bool wxStyledTextCtrl::GetReadOnly() {
827 return SendMsg(2140, 0, 0) != 0;
830 // Sets the position of the caret.
831 void wxStyledTextCtrl::SetCurrentPos(int pos
) {
832 SendMsg(2141, pos
, 0);
835 // Sets the position that starts the selection - this becomes the anchor.
836 void wxStyledTextCtrl::SetSelectionStart(int pos
) {
837 SendMsg(2142, pos
, 0);
840 // Returns the position at the start of the selection.
841 int wxStyledTextCtrl::GetSelectionStart() {
842 return SendMsg(2143, 0, 0);
845 // Sets the position that ends the selection - this becomes the currentPosition.
846 void wxStyledTextCtrl::SetSelectionEnd(int pos
) {
847 SendMsg(2144, pos
, 0);
850 // Returns the position at the end of the selection.
851 int wxStyledTextCtrl::GetSelectionEnd() {
852 return SendMsg(2145, 0, 0);
855 // Sets the print magnification added to the point size of each style for printing.
856 void wxStyledTextCtrl::SetPrintMagnification(int magnification
) {
857 SendMsg(2146, magnification
, 0);
860 // Returns the print magnification.
861 int wxStyledTextCtrl::GetPrintMagnification() {
862 return SendMsg(2147, 0, 0);
865 // Modify colours when printing for clearer printed text.
866 void wxStyledTextCtrl::SetPrintColourMode(int mode
) {
867 SendMsg(2148, mode
, 0);
870 // Returns the print colour mode.
871 int wxStyledTextCtrl::GetPrintColourMode() {
872 return SendMsg(2149, 0, 0);
875 // Find some text in the document.
876 int wxStyledTextCtrl::FindText(int minPos
, int maxPos
,
877 const wxString
& text
,
878 bool caseSensitive
, bool wholeWord
) {
882 flags
|= caseSensitive
? SCFIND_MATCHCASE
: 0;
883 flags
|= wholeWord
? SCFIND_WHOLEWORD
: 0;
884 ft
.chrg
.cpMin
= minPos
;
885 ft
.chrg
.cpMax
= maxPos
;
886 ft
.lpstrText
= (char*)text
.c_str();
888 return SendMsg(2150, flags
, (long)&ft
);
891 // On Windows will draw the document into a display context such as a printer.
892 int wxStyledTextCtrl::FormatRange(bool doDraw
,
896 wxDC
* target
, // Why does it use two? Can they be the same?
902 fr
.hdcTarget
= target
;
903 fr
.rc
.top
= renderRect
.GetTop();
904 fr
.rc
.left
= renderRect
.GetLeft();
905 fr
.rc
.right
= renderRect
.GetRight();
906 fr
.rc
.bottom
= renderRect
.GetBottom();
907 fr
.rcPage
.top
= pageRect
.GetTop();
908 fr
.rcPage
.left
= pageRect
.GetLeft();
909 fr
.rcPage
.right
= pageRect
.GetRight();
910 fr
.rcPage
.bottom
= pageRect
.GetBottom();
911 fr
.chrg
.cpMin
= startPos
;
912 fr
.chrg
.cpMax
= endPos
;
914 return SendMsg(2151, doDraw
, (long)&fr
);
917 // Retrieve the line at the top of the display.
918 int wxStyledTextCtrl::GetFirstVisibleLine() {
919 return SendMsg(2152, 0, 0);
922 // Retrieve the contents of a line.
923 wxString
wxStyledTextCtrl::GetLine(int line
) {
925 int len
= LineLength(line
);
927 char* buf
= text
.GetWriteBuf(len
);
929 int pos
= SendMsg(2153, line
, (long)buf
);
930 text
.UngetWriteBuf(len
);
935 // Returns the number of lines in the document. There is always at least one.
936 int wxStyledTextCtrl::GetLineCount() {
937 return SendMsg(2154, 0, 0);
940 // Sets the size in pixels of the left margin.
941 void wxStyledTextCtrl::SetMarginLeft(int width
) {
942 SendMsg(2155, 0, width
);
945 // Returns the size in pixels of the left margin.
946 int wxStyledTextCtrl::GetMarginLeft() {
947 return SendMsg(2156, 0, 0);
950 // Sets the size in pixels of the right margin.
951 void wxStyledTextCtrl::SetMarginRight(int width
) {
952 SendMsg(2157, 0, width
);
955 // Returns the size in pixels of the right margin.
956 int wxStyledTextCtrl::GetMarginRight() {
957 return SendMsg(2158, 0, 0);
960 // Is the document different from when it was last saved?
961 bool wxStyledTextCtrl::GetModify() {
962 return SendMsg(2159, 0, 0) != 0;
965 // Select a range of text.
966 void wxStyledTextCtrl::SetSelection(int start
, int end
) {
967 SendMsg(2160, start
, end
);
970 // Retrieve the selected text.
971 wxString
wxStyledTextCtrl::GetSelectedText() {
976 GetSelection(&start
, &end
);
977 int len
= end
- start
;
979 char* buff
= text
.GetWriteBuf(len
);
981 SendMsg(2161, 0, (long)buff
);
982 text
.UngetWriteBuf(len
);
986 // Retrieve a range of text.
987 wxString
wxStyledTextCtrl::GetTextRange(int startPos
, int endPos
) {
989 int len
= endPos
- startPos
;
991 char* buff
= text
.GetWriteBuf(len
);
994 tr
.chrg
.cpMin
= startPos
;
995 tr
.chrg
.cpMax
= endPos
;
997 SendMsg(2162, 0, (long)&tr
);
998 text
.UngetWriteBuf(len
);
1002 // Draw the selection in normal style or with selection highlighted.
1003 void wxStyledTextCtrl::HideSelection(bool normal
) {
1004 SendMsg(2163, normal
, 0);
1007 // Retrieve the line containing a position.
1008 int wxStyledTextCtrl::LineFromPosition(int pos
) {
1009 return SendMsg(2166, pos
, 0);
1012 // Retrieve the position at the start of a line.
1013 int wxStyledTextCtrl::PositionFromLine(int line
) {
1014 return SendMsg(2167, line
, 0);
1017 // Scroll horizontally and vertically.
1018 void wxStyledTextCtrl::LineScroll(int columns
, int lines
) {
1019 SendMsg(2168, columns
, lines
);
1022 // Ensure the caret is visible.
1023 void wxStyledTextCtrl::EnsureCaretVisible() {
1024 SendMsg(2169, 0, 0);
1027 // Replace the selected text with the argument text.
1028 void wxStyledTextCtrl::ReplaceSelection(const wxString
& text
) {
1029 SendMsg(2170, 0, (long)text
.c_str());
1032 // Set to read only or read write.
1033 void wxStyledTextCtrl::SetReadOnly(bool readOnly
) {
1034 SendMsg(2171, readOnly
, 0);
1037 // Will a paste succeed?
1038 bool wxStyledTextCtrl::CanPaste() {
1039 return SendMsg(2173, 0, 0) != 0;
1042 // Are there any undoable actions in the undo history.
1043 bool wxStyledTextCtrl::CanUndo() {
1044 return SendMsg(2174, 0, 0) != 0;
1047 // Delete the undo history.
1048 void wxStyledTextCtrl::EmptyUndoBuffer() {
1049 SendMsg(2175, 0, 0);
1052 // Undo one action in the undo history.
1053 void wxStyledTextCtrl::Undo() {
1054 SendMsg(2176, 0, 0);
1057 // Cut the selection to the clipboard.
1058 void wxStyledTextCtrl::Cut() {
1059 SendMsg(2177, 0, 0);
1062 // Copy the selection to the clipboard.
1063 void wxStyledTextCtrl::Copy() {
1064 SendMsg(2178, 0, 0);
1067 // Paste the contents of the clipboard into the document replacing the selection.
1068 void wxStyledTextCtrl::Paste() {
1069 SendMsg(2179, 0, 0);
1072 // Clear the selection.
1073 void wxStyledTextCtrl::Clear() {
1074 SendMsg(2180, 0, 0);
1077 // Replace the contents of the document with the argument text.
1078 void wxStyledTextCtrl::SetText(const wxString
& text
) {
1079 SendMsg(2181, 0, (long)text
.c_str());
1082 // Retrieve all the text in the document.
1083 wxString
wxStyledTextCtrl::GetText() {
1085 int len
= GetTextLength()+1;
1086 char* buff
= text
.GetWriteBuf(len
);
1088 SendMsg(2182, len
, (long)buff
);
1089 text
.UngetWriteBuf(len
-1);
1093 // Retrieve the number of characters in the document.
1094 int wxStyledTextCtrl::GetTextLength() {
1095 return SendMsg(2183, 0, 0);
1098 // Set to overtype (true) or insert mode
1099 void wxStyledTextCtrl::SetOvertype(bool overtype
) {
1100 SendMsg(2186, overtype
, 0);
1103 // Returns true if overtype mode is active otherwise false is returned.
1104 bool wxStyledTextCtrl::GetOvertype() {
1105 return SendMsg(2187, 0, 0) != 0;
1108 // Show a call tip containing a definition near position pos.
1109 void wxStyledTextCtrl::CallTipShow(int pos
, const wxString
& definition
) {
1110 SendMsg(2200, pos
, (long)definition
.c_str());
1113 // Remove the call tip from the screen.
1114 void wxStyledTextCtrl::CallTipCancel() {
1115 SendMsg(2201, 0, 0);
1118 // Is there an active call tip?
1119 bool wxStyledTextCtrl::CallTipActive() {
1120 return SendMsg(2202, 0, 0) != 0;
1123 // Retrieve the position where the caret was before displaying the call tip.
1124 int wxStyledTextCtrl::CallTipPosAtStart() {
1125 return SendMsg(2203, 0, 0);
1128 // Highlight a segment of the definition.
1129 void wxStyledTextCtrl::CallTipSetHighlight(int start
, int end
) {
1130 SendMsg(2204, start
, end
);
1133 // Set the background colour for the call tip.
1134 void wxStyledTextCtrl::CallTipSetBackground(const wxColour
& back
) {
1135 SendMsg(2205, wxColourAsLong(back
), 0);
1138 // Find the display line of a document line taking hidden lines into account.
1139 int wxStyledTextCtrl::VisibleFromDocLine(int line
) {
1140 return SendMsg(2220, line
, 0);
1143 // Find the document line of a display line taking hidden lines into account.
1144 int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay
) {
1145 return SendMsg(2221, lineDisplay
, 0);
1148 // Set the fold level of a line.
1149 // This encodes an integer level along with flags indicating whether the
1150 // line is a header and whether it is effectively white space.
1151 void wxStyledTextCtrl::SetFoldLevel(int line
, int level
) {
1152 SendMsg(2222, line
, level
);
1155 // Retrieve the fold level of a line.
1156 int wxStyledTextCtrl::GetFoldLevel(int line
) {
1157 return SendMsg(2223, line
, 0);
1160 // Find the last child line of a header line.
1161 int wxStyledTextCtrl::GetLastChild(int line
, int level
) {
1162 return SendMsg(2224, line
, level
);
1165 // Find the parent line of a child line.
1166 int wxStyledTextCtrl::GetFoldParent(int line
) {
1167 return SendMsg(2225, line
, 0);
1170 // Make a range of lines visible.
1171 void wxStyledTextCtrl::ShowLines(int lineStart
, int lineEnd
) {
1172 SendMsg(2226, lineStart
, lineEnd
);
1175 // Make a range of lines invisible.
1176 void wxStyledTextCtrl::HideLines(int lineStart
, int lineEnd
) {
1177 SendMsg(2227, lineStart
, lineEnd
);
1180 // Is a line visible?
1181 bool wxStyledTextCtrl::GetLineVisible(int line
) {
1182 return SendMsg(2228, line
, 0) != 0;
1185 // Show the children of a header line.
1186 void wxStyledTextCtrl::SetFoldExpanded(int line
, bool expanded
) {
1187 SendMsg(2229, line
, expanded
);
1190 // Is a header line expanded?
1191 bool wxStyledTextCtrl::GetFoldExpanded(int line
) {
1192 return SendMsg(2230, line
, 0) != 0;
1195 // Switch a header line between expanded and contracted.
1196 void wxStyledTextCtrl::ToggleFold(int line
) {
1197 SendMsg(2231, line
, 0);
1200 // Ensure a particular line is visible by expanding any header line hiding it.
1201 void wxStyledTextCtrl::EnsureVisible(int line
) {
1202 SendMsg(2232, line
, 0);
1205 // Set some debugging options for folding
1206 void wxStyledTextCtrl::SetFoldFlags(int flags
) {
1207 SendMsg(2233, flags
, 0);
1210 // How many characters are on a line, not including end of line characters.
1211 int wxStyledTextCtrl::LineLength(int line
) {
1212 return SendMsg(2350, line
, 0);
1215 // Highlight the characters at two positions.
1216 void wxStyledTextCtrl::BraceHighlight(int pos1
, int pos2
) {
1217 SendMsg(2351, pos1
, pos2
);
1220 // Highlight the character at a position indicating there is no matching brace.
1221 void wxStyledTextCtrl::BraceBadLight(int pos
) {
1222 SendMsg(2352, pos
, 0);
1225 // Find the position of a matching brace or INVALID_POSITION if no match.
1226 int wxStyledTextCtrl::BraceMatch(int pos
) {
1227 return SendMsg(2353, pos
, 0);
1230 // Are the end of line characters visible.
1231 bool wxStyledTextCtrl::GetViewEOL() {
1232 return SendMsg(2355, 0, 0) != 0;
1235 // Make the end of line characters visible or invisible
1236 void wxStyledTextCtrl::SetViewEOL(bool visible
) {
1237 SendMsg(2356, visible
, 0);
1240 // Retrieve a pointer to the document object.
1241 void* wxStyledTextCtrl::GetDocPointer() {
1242 return (void*)SendMsg(2357);
1245 // Change the document object used.
1246 void wxStyledTextCtrl::SetDocPointer(void* docPointer
) {
1247 SendMsg(2358, (long)docPointer
);
1250 // Set which document modification events are sent to the container.
1251 void wxStyledTextCtrl::SetModEventMask(int mask
) {
1252 SendMsg(2359, mask
, 0);
1255 // Retrieve the column number which text should be kept within.
1256 int wxStyledTextCtrl::GetEdgeColumn() {
1257 return SendMsg(2360, 0, 0);
1260 // Set the column number of the edge.
1261 // If text goes past the edge then it is highlighted.
1262 void wxStyledTextCtrl::SetEdgeColumn(int column
) {
1263 SendMsg(2361, column
, 0);
1266 // Retrieve the edge highlight mode.
1267 int wxStyledTextCtrl::GetEdgeMode() {
1268 return SendMsg(2362, 0, 0);
1271 // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that
1272 // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE).
1273 void wxStyledTextCtrl::SetEdgeMode(int mode
) {
1274 SendMsg(2363, mode
, 0);
1277 // Retrieve the colour used in edge indication.
1278 wxColour
wxStyledTextCtrl::GetEdgeColour() {
1279 long c
= SendMsg(2364, 0, 0);
1280 return wxColourFromLong(c
);
1283 // Change the colour used in edge indication.
1284 void wxStyledTextCtrl::SetEdgeColour(const wxColour
& edgeColour
) {
1285 SendMsg(2365, wxColourAsLong(edgeColour
), 0);
1288 // Sets the current caret position to be the search anchor.
1289 void wxStyledTextCtrl::SearchAnchor() {
1290 SendMsg(2366, 0, 0);
1293 // Find some text starting at the search anchor.
1294 int wxStyledTextCtrl::SearchNext(int flags
, const wxString
& text
) {
1295 return SendMsg(2367, flags
, (long)text
.c_str());
1298 // Find some text starting at the search anchor and moving backwards.
1299 int wxStyledTextCtrl::SearchPrev(int flags
, const wxString
& text
) {
1300 return SendMsg(2368, flags
, (long)text
.c_str());
1303 // Set the way the line the caret is on is kept visible.
1304 void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy
, int caretSlop
) {
1305 SendMsg(2369, caretPolicy
, caretSlop
);
1308 // Retrieves the number of lines completely visible.
1309 int wxStyledTextCtrl::LinesOnScreen() {
1310 return SendMsg(2370, 0, 0);
1313 // Set whether a pop up menu is displayed automatically when the user presses
1314 // the wrong mouse button.
1315 void wxStyledTextCtrl::UsePopUp(bool allowPopUp
) {
1316 SendMsg(2371, allowPopUp
, 0);
1319 // Is the selection a rectangular. The alternative is the more common stream selection.
1320 bool wxStyledTextCtrl::SelectionIsRectangle() {
1321 return SendMsg(2372, 0, 0) != 0;
1324 // Set the zoom level. This number of points is added to the size of all fonts.
1325 // It may be positive to magnify or negative to reduce.
1326 void wxStyledTextCtrl::SetZoom(int zoom
) {
1327 SendMsg(2373, zoom
, 0);
1330 // Retrieve the zoom level.
1331 int wxStyledTextCtrl::GetZoom() {
1332 return SendMsg(2374, 0, 0);
1335 // Create a new document object.
1336 // Starts with reference count of 1 and not selected into editor.
1337 void* wxStyledTextCtrl::CreateDocument() {
1338 return (void*)SendMsg(2375);
1341 // Extend life of document.
1342 void wxStyledTextCtrl::AddRefDocument(void* docPointer
) {
1343 SendMsg(2376, (long)docPointer
);
1346 // Release a reference to the document, deleting document if it fades to black.
1347 void wxStyledTextCtrl::ReleaseDocument(void* docPointer
) {
1348 SendMsg(2377, (long)docPointer
);
1351 // Get which document modification events are sent to the container.
1352 int wxStyledTextCtrl::GetModEventMask() {
1353 return SendMsg(2378, 0, 0);
1356 // Start notifying the container of all key presses and commands.
1357 void wxStyledTextCtrl::StartRecord() {
1358 SendMsg(3001, 0, 0);
1361 // Stop notifying the container of all key presses and commands.
1362 void wxStyledTextCtrl::StopRecord() {
1363 SendMsg(3002, 0, 0);
1366 // Set the lexing language of the document.
1367 void wxStyledTextCtrl::SetLexer(int lexer
) {
1368 SendMsg(4001, lexer
, 0);
1371 // Retrieve the lexing language of the document.
1372 int wxStyledTextCtrl::GetLexer() {
1373 return SendMsg(4002, 0, 0);
1376 // Colourise a segment of the document using the current lexing language.
1377 void wxStyledTextCtrl::Colourise(int start
, int end
) {
1378 SendMsg(4003, start
, end
);
1381 // Set up a value that may be used by a lexer for some optional feature.
1382 void wxStyledTextCtrl::SetProperty(const wxString
& key
, const wxString
& value
) {
1383 SendMsg(4004, (long)key
.c_str(), (long)value
.c_str());
1386 // Set up the key words used by the lexer.
1387 void wxStyledTextCtrl::SetKeyWords(int keywordSet
, const wxString
& keyWords
) {
1388 SendMsg(4005, keywordSet
, (long)keyWords
.c_str());
1391 // END of generated section
1392 //----------------------------------------------------------------------
1395 // Returns the line number of the line with the caret.
1396 int wxStyledTextCtrl::GetCurrentLine() {
1397 int line
= LineFromPosition(GetCurrentPos());
1402 // Extract style settings from a spec-string which is composed of one or
1403 // more of the following comma separated elements:
1405 // bold turns on bold
1406 // italic turns on italics
1407 // fore:#RRGGBB sets the foreground colour
1408 // back:#RRGGBB sets the background colour
1409 // face:[facename] sets the font face name to use
1410 // size:[num] sets the font size in points
1411 // eol turns on eol filling
1412 // underline turns on underlining
1414 void wxStyledTextCtrl::StyleSetSpec(int styleNum
, const wxString
& spec
) {
1416 wxStringTokenizer
tkz(spec
, ",");
1417 while (tkz
.HasMoreTokens()) {
1418 wxString token
= tkz
.GetNextToken();
1420 wxString option
= token
.BeforeFirst(':');
1421 wxString val
= token
.AfterFirst(':');
1423 if (option
== "bold")
1424 StyleSetBold(styleNum
, true);
1426 else if (option
== "italic")
1427 StyleSetItalic(styleNum
, true);
1429 else if (option
== "underline")
1430 StyleSetUnderline(styleNum
, true);
1432 else if (option
== "eol")
1433 StyleSetEOLFilled(styleNum
, true);
1435 else if (option
== "size") {
1437 if (val
.ToLong(&points
))
1438 StyleSetSize(styleNum
, points
);
1441 else if (option
== "face")
1442 StyleSetFaceName(styleNum
, val
);
1444 else if (option
== "fore")
1445 StyleSetForeground(styleNum
, wxColourFromSpec(val
));
1447 else if (option
== "back")
1448 StyleSetBackground(styleNum
, wxColourFromSpec(val
));
1453 // Set style size, face, bold, italic, and underline attributes from
1454 // a wxFont's attributes.
1455 void wxStyledTextCtrl::StyleSetFont(int styleNum
, wxFont
& font
) {
1456 int size
= font
.GetPointSize();
1457 wxString faceName
= font
.GetFaceName();
1458 bool bold
= font
.GetWeight() == wxBOLD
;
1459 bool italic
= font
.GetStyle() != wxNORMAL
;
1460 bool under
= font
.GetUnderlined();
1462 // TODO: add encoding/charset mapping
1463 StyleSetFontAttr(styleNum
, size
, faceName
, bold
, italic
, under
);
1466 // Set all font style attributes at once.
1467 void wxStyledTextCtrl::StyleSetFontAttr(int styleNum
, int size
,
1468 const wxString
& faceName
,
1469 bool bold
, bool italic
,
1471 StyleSetSize(styleNum
, size
);
1472 StyleSetFaceName(styleNum
, faceName
);
1473 StyleSetBold(styleNum
, bold
);
1474 StyleSetItalic(styleNum
, italic
);
1475 StyleSetUnderline(styleNum
, underline
);
1477 // TODO: add encoding/charset mapping
1481 // Perform one of the operations defined by the wxSTC_CMD_* constants.
1482 void wxStyledTextCtrl::CmdKeyExecute(int cmd
) {
1487 // Set the left and right margin in the edit area, measured in pixels.
1488 void wxStyledTextCtrl::SetMargins(int left
, int right
) {
1489 SetMarginLeft(left
);
1490 SetMarginRight(right
);
1494 // Retrieve the start and end positions of the current selection.
1495 void wxStyledTextCtrl::GetSelection(int* startPos
, int* endPos
) {
1496 if (startPos
!= NULL
)
1497 *startPos
= SendMsg(SCI_GETSELECTIONSTART
);
1499 *endPos
= SendMsg(SCI_GETSELECTIONEND
);
1503 // Retrieve the point in the window where a position is displayed.
1504 wxPoint
wxStyledTextCtrl::PointFromPosition(int pos
) {
1505 int x
= SendMsg(SCI_POINTXFROMPOSITION
, 0, pos
);
1506 int y
= SendMsg(SCI_POINTYFROMPOSITION
, 0, pos
);
1507 return wxPoint(x
, y
);
1510 // Scroll enough to make the given line visible
1511 void wxStyledTextCtrl::ScrollToLine(int line
) {
1512 m_swx
->DoScrollToLine(line
);
1516 // Scroll enough to make the given column visible
1517 void wxStyledTextCtrl::ScrollToColumn(int column
) {
1518 m_swx
->DoScrollToColumn(column
);
1523 //----------------------------------------------------------------------
1526 void wxStyledTextCtrl::OnPaint(wxPaintEvent
& evt
) {
1528 wxRegion region
= GetUpdateRegion();
1530 m_swx
->DoPaint(&dc
, region
.GetBox());
1533 void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent
& evt
) {
1534 if (evt
.GetOrientation() == wxHORIZONTAL
)
1535 m_swx
->DoHScroll(evt
.GetEventType(), evt
.GetPosition());
1537 m_swx
->DoVScroll(evt
.GetEventType(), evt
.GetPosition());
1540 void wxStyledTextCtrl::OnSize(wxSizeEvent
& evt
) {
1541 wxSize sz
= GetClientSize();
1542 m_swx
->DoSize(sz
.x
, sz
.y
);
1545 void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent
& evt
) {
1546 wxPoint pt
= evt
.GetPosition();
1547 m_swx
->DoButtonDown(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1548 evt
.ShiftDown(), evt
.ControlDown(), evt
.AltDown());
1551 void wxStyledTextCtrl::OnMouseMove(wxMouseEvent
& evt
) {
1552 wxPoint pt
= evt
.GetPosition();
1553 m_swx
->DoButtonMove(Point(pt
.x
, pt
.y
));
1556 void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent
& evt
) {
1557 wxPoint pt
= evt
.GetPosition();
1558 m_swx
->DoButtonUp(Point(pt
.x
, pt
.y
), m_stopWatch
.Time(),
1563 void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent
& evt
) {
1564 wxPoint pt
= evt
.GetPosition();
1565 m_swx
->DoContextMenu(Point(pt
.x
, pt
.y
));
1569 void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent
& evt
) {
1570 m_swx
->DoMouseWheel(evt
.GetWheelRotation(),
1571 evt
.GetWheelDelta(),
1572 evt
.GetLinesPerAction());
1576 void wxStyledTextCtrl::OnChar(wxKeyEvent
& evt
) {
1577 long key
= evt
.KeyCode();
1578 if ((key
> WXK_ESCAPE
) &&
1579 (key
!= WXK_DELETE
) && (key
< 255) &&
1580 !evt
.ControlDown() && !evt
.AltDown()) {
1582 m_swx
->DoAddChar(key
);
1589 void wxStyledTextCtrl::OnKeyDown(wxKeyEvent
& evt
) {
1590 long key
= evt
.KeyCode();
1592 int processed
= m_swx
->DoKeyDown(key
, evt
.ShiftDown(),
1593 evt
.ControlDown(), evt
.AltDown());
1598 void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent
& evt
) {
1599 m_swx
->DoLoseFocus();
1602 void wxStyledTextCtrl::OnGainFocus(wxFocusEvent
& evt
) {
1603 m_swx
->DoGainFocus();
1606 void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent
& evt
) {
1607 m_swx
->DoSysColourChange();
1610 void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent
& evt
) {
1611 // do nothing to help avoid flashing
1616 void wxStyledTextCtrl::OnMenu(wxCommandEvent
& evt
) {
1617 m_swx
->DoCommand(evt
.GetId());
1621 void wxStyledTextCtrl::OnListBox(wxCommandEvent
& evt
) {
1622 m_swx
->DoOnListBox();
1626 //----------------------------------------------------------------------
1627 // Turn notifications from Scintilla into events
1630 void wxStyledTextCtrl::NotifyChange() {
1631 wxStyledTextEvent
evt(wxEVT_STC_CHANGE
, GetId());
1632 GetEventHandler()->ProcessEvent(evt
);
1635 void wxStyledTextCtrl::NotifyParent(SCNotification
* _scn
) {
1636 SCNotification
& scn
= *_scn
;
1638 switch (scn
.nmhdr
.code
) {
1639 case SCN_STYLENEEDED
:
1640 eventType
= wxEVT_STC_STYLENEEDED
;
1643 eventType
= wxEVT_STC_CHARADDED
;
1646 eventType
= wxEVT_STC_UPDATEUI
;
1648 case SCN_SAVEPOINTREACHED
:
1649 eventType
= wxEVT_STC_SAVEPOINTREACHED
;
1651 case SCN_SAVEPOINTLEFT
:
1652 eventType
= wxEVT_STC_SAVEPOINTLEFT
;
1654 case SCN_MODIFYATTEMPTRO
:
1655 eventType
= wxEVT_STC_ROMODIFYATTEMPT
;
1657 case SCN_DOUBLECLICK
:
1658 eventType
= wxEVT_STC_DOUBLECLICK
;
1661 eventType
= wxEVT_STC_MODIFIED
;
1664 eventType
= wxEVT_STC_KEY
;
1666 case SCN_MACRORECORD
:
1667 eventType
= wxEVT_STC_MACRORECORD
;
1669 case SCN_MARGINCLICK
:
1670 eventType
= wxEVT_STC_MARGINCLICK
;
1673 eventType
= wxEVT_STC_NEEDSHOWN
;
1675 case SCN_POSCHANGED
:
1676 eventType
= wxEVT_STC_POSCHANGED
;
1680 wxStyledTextEvent
evt(eventType
, GetId());
1681 evt
.SetPosition(scn
.position
);
1683 evt
.SetModifiers(scn
.modifiers
);
1684 if (eventType
== wxEVT_STC_MODIFIED
) {
1685 evt
.SetModificationType(scn
.modificationType
);
1687 evt
.SetText(wxString(scn
.text
, scn
.length
));
1688 evt
.SetLength(scn
.length
);
1689 evt
.SetLinesAdded(scn
.linesAdded
);
1690 evt
.SetLine(scn
.line
);
1691 evt
.SetFoldLevelNow(scn
.foldLevelNow
);
1692 evt
.SetFoldLevelPrev(scn
.foldLevelPrev
);
1694 if (eventType
== wxEVT_STC_MARGINCLICK
)
1695 evt
.SetMargin(scn
.margin
);
1696 if (eventType
== wxEVT_STC_MACRORECORD
) {
1697 evt
.SetMessage(scn
.message
);
1698 evt
.SetWParam(scn
.wParam
);
1699 evt
.SetLParam(scn
.lParam
);
1702 GetEventHandler()->ProcessEvent(evt
);
1708 //----------------------------------------------------------------------
1709 //----------------------------------------------------------------------
1710 //----------------------------------------------------------------------
1712 wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType
, int id
)
1713 : wxCommandEvent(commandType
, id
)
1718 m_modificationType
= 0;
1723 m_foldLevelPrev
= 0;
1732 bool wxStyledTextEvent::GetShift() const { return (m_modifiers
& SCI_SHIFT
) != 0; }
1733 bool wxStyledTextEvent::GetControl() const { return (m_modifiers
& SCI_CTRL
) != 0; }
1734 bool wxStyledTextEvent::GetAlt() const { return (m_modifiers
& SCI_ALT
) != 0; }
1736 void wxStyledTextEvent::CopyObject(wxObject
& obj
) const {
1737 wxCommandEvent::CopyObject(obj
);
1739 wxStyledTextEvent
* o
= (wxStyledTextEvent
*)&obj
;
1740 o
->m_position
= m_position
;
1742 o
->m_modifiers
= m_modifiers
;
1743 o
->m_modificationType
= m_modificationType
;
1745 o
->m_length
= m_length
;
1746 o
->m_linesAdded
= m_linesAdded
;
1748 o
->m_foldLevelNow
= m_foldLevelNow
;
1749 o
->m_foldLevelPrev
= m_foldLevelPrev
;
1751 o
->m_margin
= m_margin
;
1753 o
->m_message
= m_message
;
1754 o
->m_wParam
= m_wParam
;
1755 o
->m_lParam
= m_lParam
;
1761 //----------------------------------------------------------------------
1762 //----------------------------------------------------------------------