]>
Commit | Line | Data |
---|---|---|
9ce192d4 RD |
1 | //////////////////////////////////////////////////////////////////////////// |
2 | // Name: stc.cpp | |
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 | |
f6bcfd97 | 8 | // namespace with all the classes and identifiers from Scintilla. |
9ce192d4 RD |
9 | // |
10 | // Author: Robin Dunn | |
11 | // | |
12 | // Created: 13-Jan-2000 | |
13 | // RCS-ID: $Id$ | |
14 | // Copyright: (c) 2000 by Total Control Software | |
15 | // Licence: wxWindows license | |
16 | ///////////////////////////////////////////////////////////////////////////// | |
17 | ||
f6bcfd97 BP |
18 | #include <ctype.h> |
19 | ||
9ce192d4 RD |
20 | #include "wx/stc/stc.h" |
21 | #include "ScintillaWX.h" | |
22 | ||
9e730a78 | 23 | #include <wx/wx.h> |
9ce192d4 | 24 | #include <wx/tokenzr.h> |
9e730a78 RD |
25 | #include <wx/mstream.h> |
26 | #include <wx/image.h> | |
51566b0b | 27 | #include <wx/file.h> |
9ce192d4 | 28 | |
f6bcfd97 | 29 | |
9ce192d4 RD |
30 | //---------------------------------------------------------------------- |
31 | ||
10ef30eb | 32 | const wxChar* wxSTCNameStr = wxT("stcwindow"); |
9ce192d4 | 33 | |
451c5cc7 RD |
34 | #ifdef MAKELONG |
35 | #undef MAKELONG | |
36 | #endif | |
37 | ||
38 | #define MAKELONG(a, b) ((a) | ((b) << 16)) | |
39 | ||
40 | ||
41 | static long wxColourAsLong(const wxColour& co) { | |
42 | return (((long)co.Blue() << 16) | | |
43 | ((long)co.Green() << 8) | | |
44 | ((long)co.Red())); | |
45 | } | |
46 | ||
47 | static wxColour wxColourFromLong(long c) { | |
48 | wxColour clr; | |
49 | clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); | |
50 | return clr; | |
51 | } | |
52 | ||
53 | ||
54 | static wxColour wxColourFromSpec(const wxString& spec) { | |
55 | // spec should be "#RRGGBB" | |
56 | long red, green, blue; | |
57 | red = green = blue = 0; | |
58 | spec.Mid(1,2).ToLong(&red, 16); | |
59 | spec.Mid(3,2).ToLong(&green, 16); | |
60 | spec.Mid(5,2).ToLong(&blue, 16); | |
61 | return wxColour(red, green, blue); | |
62 | } | |
63 | ||
64 | //---------------------------------------------------------------------- | |
65 | ||
d25f5fbb RD |
66 | DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) |
67 | DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) | |
68 | DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) | |
d25f5fbb RD |
69 | DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ) |
70 | DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ) | |
71 | DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ) | |
65ec6247 | 72 | DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) |
d25f5fbb | 73 | DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK ) |
65ec6247 | 74 | DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI ) |
d25f5fbb | 75 | DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED ) |
d25f5fbb RD |
76 | DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) |
77 | DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) | |
78 | DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) | |
79 | DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED ) | |
65ec6247 RD |
80 | DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED ) |
81 | DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) | |
82 | DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) | |
83 | DEFINE_EVENT_TYPE( wxEVT_STC_DWELLSTART ) | |
84 | DEFINE_EVENT_TYPE( wxEVT_STC_DWELLEND ) | |
a29a241f RD |
85 | DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) |
86 | DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) | |
87 | DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) | |
a834585d | 88 | DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM ) |
9e730a78 RD |
89 | DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK ) |
90 | DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK ) | |
91 | DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK ) | |
92 | ||
d25f5fbb RD |
93 | |
94 | ||
9ce192d4 RD |
95 | BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) |
96 | EVT_PAINT (wxStyledTextCtrl::OnPaint) | |
97 | EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin) | |
5fa4613c | 98 | EVT_SCROLL (wxStyledTextCtrl::OnScroll) |
9ce192d4 RD |
99 | EVT_SIZE (wxStyledTextCtrl::OnSize) |
100 | EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) | |
4ceb1196 RD |
101 | // Let Scintilla see the double click as a second click |
102 | EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) | |
9ce192d4 RD |
103 | EVT_MOTION (wxStyledTextCtrl::OnMouseMove) |
104 | EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) | |
451c5cc7 | 105 | #if defined(__WXGTK__) || defined(__WXMAC__) |
ddf2da08 RD |
106 | EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) |
107 | #else | |
65ec6247 | 108 | EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) |
ddf2da08 | 109 | #endif |
37d62433 | 110 | EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) |
2b5f62a0 | 111 | EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp) |
9ce192d4 | 112 | EVT_CHAR (wxStyledTextCtrl::OnChar) |
f6bcfd97 | 113 | EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) |
9ce192d4 RD |
114 | EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus) |
115 | EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus) | |
116 | EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) | |
117 | EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) | |
dd4aa550 | 118 | EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu) |
f6bcfd97 | 119 | EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox) |
9ce192d4 RD |
120 | END_EVENT_TABLE() |
121 | ||
f6bcfd97 BP |
122 | |
123 | IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl) | |
124 | IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) | |
125 | ||
40716a51 | 126 | #ifdef LINK_LEXERS |
1a2fb4cd | 127 | // forces the linking of the lexer modules |
a834585d | 128 | int Scintilla_LinkLexers(); |
40716a51 | 129 | #endif |
1a2fb4cd | 130 | |
9ce192d4 RD |
131 | //---------------------------------------------------------------------- |
132 | // Constructor and Destructor | |
133 | ||
134 | wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, | |
135 | wxWindowID id, | |
136 | const wxPoint& pos, | |
137 | const wxSize& size, | |
138 | long style, | |
139 | const wxString& name) : | |
140 | wxControl(parent, id, pos, size, | |
f97d84a6 | 141 | style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, |
9ce192d4 RD |
142 | wxDefaultValidator, name) |
143 | { | |
40716a51 | 144 | #ifdef LINK_LEXERS |
a834585d | 145 | Scintilla_LinkLexers(); |
40716a51 | 146 | #endif |
9ce192d4 | 147 | m_swx = new ScintillaWX(this); |
9ce192d4 | 148 | m_stopWatch.Start(); |
d6582821 | 149 | m_lastKeyDownConsumed = FALSE; |
5fa4613c RD |
150 | m_vScrollBar = NULL; |
151 | m_hScrollBar = NULL; | |
10ef30eb RD |
152 | #if wxUSE_UNICODE |
153 | // Put Scintilla into unicode (UTF-8) mode | |
154 | SetCodePage(wxSTC_CP_UTF8); | |
155 | #endif | |
9ce192d4 RD |
156 | } |
157 | ||
158 | ||
159 | wxStyledTextCtrl::~wxStyledTextCtrl() { | |
160 | delete m_swx; | |
9ce192d4 RD |
161 | } |
162 | ||
163 | ||
164 | //---------------------------------------------------------------------- | |
165 | ||
f6bcfd97 | 166 | long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { |
9ce192d4 RD |
167 | |
168 | return m_swx->WndProc(msg, wp, lp); | |
169 | } | |
170 | ||
171 | ||
9ce192d4 | 172 | |
4370573a RD |
173 | //---------------------------------------------------------------------- |
174 | // BEGIN generated section. The following code is automatically generated | |
175 | // by gen_iface.py from the contents of Scintilla.iface. Do not edit | |
176 | // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate. | |
9ce192d4 RD |
177 | |
178 | ||
a834585d | 179 | // Add text to the document. |
9ce192d4 | 180 | void wxStyledTextCtrl::AddText(const wxString& text) { |
0c5b83b0 | 181 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); |
10ef30eb | 182 | SendMsg(2001, strlen(buf), (long)(const char*)buf); |
9ce192d4 RD |
183 | } |
184 | ||
a834585d | 185 | // Add array of cells to document. |
10ef30eb RD |
186 | void wxStyledTextCtrl::AddStyledText(const wxMemoryBuffer& data) { |
187 | SendMsg(2002, data.GetDataLen(), (long)data.GetData()); | |
9ce192d4 RD |
188 | } |
189 | ||
a834585d | 190 | // Insert string at a position. |
9ce192d4 | 191 | void wxStyledTextCtrl::InsertText(int pos, const wxString& text) { |
0c5b83b0 | 192 | SendMsg(2003, pos, (long)(const char*)wx2stc(text)); |
9ce192d4 RD |
193 | } |
194 | ||
a834585d | 195 | // Delete all text in the document. |
9ce192d4 | 196 | void wxStyledTextCtrl::ClearAll() { |
4370573a | 197 | SendMsg(2004, 0, 0); |
9ce192d4 RD |
198 | } |
199 | ||
a834585d | 200 | // Set all style bytes to 0, remove all folding information. |
4370573a RD |
201 | void wxStyledTextCtrl::ClearDocumentStyle() { |
202 | SendMsg(2005, 0, 0); | |
9ce192d4 RD |
203 | } |
204 | ||
a834585d | 205 | // The number of characters in the document. |
4370573a RD |
206 | int wxStyledTextCtrl::GetLength() { |
207 | return SendMsg(2006, 0, 0); | |
9ce192d4 RD |
208 | } |
209 | ||
a834585d | 210 | // Returns the character byte at the position. |
4370573a | 211 | int wxStyledTextCtrl::GetCharAt(int pos) { |
9e730a78 | 212 | return (unsigned char)SendMsg(2007, pos, 0); |
9ce192d4 RD |
213 | } |
214 | ||
a834585d | 215 | // Returns the position of the caret. |
4370573a RD |
216 | int wxStyledTextCtrl::GetCurrentPos() { |
217 | return SendMsg(2008, 0, 0); | |
9ce192d4 RD |
218 | } |
219 | ||
a834585d | 220 | // Returns the position of the opposite end of the selection to the caret. |
4370573a RD |
221 | int wxStyledTextCtrl::GetAnchor() { |
222 | return SendMsg(2009, 0, 0); | |
9ce192d4 RD |
223 | } |
224 | ||
a834585d | 225 | // Returns the style byte at the position. |
4370573a | 226 | int wxStyledTextCtrl::GetStyleAt(int pos) { |
9e730a78 | 227 | return (unsigned char)SendMsg(2010, pos, 0); |
9ce192d4 RD |
228 | } |
229 | ||
a834585d | 230 | // Redoes the next action on the undo history. |
9ce192d4 | 231 | void wxStyledTextCtrl::Redo() { |
4370573a | 232 | SendMsg(2011, 0, 0); |
9ce192d4 RD |
233 | } |
234 | ||
4370573a RD |
235 | // Choose between collecting actions into the undo |
236 | // history and discarding them. | |
237 | void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) { | |
238 | SendMsg(2012, collectUndo, 0); | |
9ce192d4 RD |
239 | } |
240 | ||
4370573a RD |
241 | // Select all the text in the document. |
242 | void wxStyledTextCtrl::SelectAll() { | |
243 | SendMsg(2013, 0, 0); | |
9ce192d4 RD |
244 | } |
245 | ||
4370573a RD |
246 | // Remember the current position in the undo history as the position |
247 | // at which the document was saved. | |
248 | void wxStyledTextCtrl::SetSavePoint() { | |
249 | SendMsg(2014, 0, 0); | |
9ce192d4 RD |
250 | } |
251 | ||
4370573a | 252 | // Retrieve a buffer of cells. |
10ef30eb | 253 | wxMemoryBuffer wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { |
9e730a78 RD |
254 | wxMemoryBuffer buf; |
255 | if (endPos < startPos) { | |
256 | int temp = startPos; | |
257 | startPos = endPos; | |
258 | endPos = temp; | |
259 | } | |
260 | int len = endPos - startPos; | |
261 | if (!len) return buf; | |
262 | TextRange tr; | |
263 | tr.lpstrText = (char*)buf.GetWriteBuf(len*2+1); | |
264 | tr.chrg.cpMin = startPos; | |
265 | tr.chrg.cpMax = endPos; | |
266 | len = SendMsg(2015, 0, (long)&tr); | |
267 | buf.UngetWriteBuf(len); | |
268 | return buf; | |
9ce192d4 RD |
269 | } |
270 | ||
a834585d | 271 | // Are there any redoable actions in the undo history? |
4370573a RD |
272 | bool wxStyledTextCtrl::CanRedo() { |
273 | return SendMsg(2016, 0, 0) != 0; | |
9ce192d4 RD |
274 | } |
275 | ||
a834585d | 276 | // Retrieve the line number at which a particular marker is located. |
4370573a RD |
277 | int wxStyledTextCtrl::MarkerLineFromHandle(int handle) { |
278 | return SendMsg(2017, handle, 0); | |
9ce192d4 RD |
279 | } |
280 | ||
4370573a RD |
281 | // Delete a marker. |
282 | void wxStyledTextCtrl::MarkerDeleteHandle(int handle) { | |
283 | SendMsg(2018, handle, 0); | |
9ce192d4 RD |
284 | } |
285 | ||
4370573a RD |
286 | // Is undo history being collected? |
287 | bool wxStyledTextCtrl::GetUndoCollection() { | |
288 | return SendMsg(2019, 0, 0) != 0; | |
9ce192d4 RD |
289 | } |
290 | ||
4370573a RD |
291 | // Are white space characters currently visible? |
292 | // Returns one of SCWS_* constants. | |
293 | int wxStyledTextCtrl::GetViewWhiteSpace() { | |
294 | return SendMsg(2020, 0, 0); | |
9ce192d4 RD |
295 | } |
296 | ||
4370573a RD |
297 | // Make white space characters invisible, always visible or visible outside indentation. |
298 | void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) { | |
299 | SendMsg(2021, viewWS, 0); | |
9ce192d4 RD |
300 | } |
301 | ||
4370573a | 302 | // Find the position from a point within the window. |
9ce192d4 | 303 | int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) { |
9e730a78 | 304 | return SendMsg(2022, pt.x, pt.y); |
9ce192d4 RD |
305 | } |
306 | ||
65ec6247 RD |
307 | // Find the position from a point within the window but return |
308 | // INVALID_POSITION if not close to text. | |
309 | int wxStyledTextCtrl::PositionFromPointClose(int x, int y) { | |
310 | return SendMsg(2023, x, y); | |
311 | } | |
312 | ||
4370573a RD |
313 | // Set caret to start of a line and ensure it is visible. |
314 | void wxStyledTextCtrl::GotoLine(int line) { | |
315 | SendMsg(2024, line, 0); | |
9ce192d4 RD |
316 | } |
317 | ||
4370573a | 318 | // Set caret to a position and ensure it is visible. |
9ce192d4 | 319 | void wxStyledTextCtrl::GotoPos(int pos) { |
4370573a | 320 | SendMsg(2025, pos, 0); |
9ce192d4 RD |
321 | } |
322 | ||
4370573a RD |
323 | // Set the selection anchor to a position. The anchor is the opposite |
324 | // end of the selection from the caret. | |
325 | void wxStyledTextCtrl::SetAnchor(int posAnchor) { | |
326 | SendMsg(2026, posAnchor, 0); | |
9ce192d4 RD |
327 | } |
328 | ||
4370573a RD |
329 | // Retrieve the text of the line containing the caret. |
330 | // Returns the index of the caret on the line. | |
331 | wxString wxStyledTextCtrl::GetCurLine(int* linePos) { | |
9e730a78 RD |
332 | int len = LineLength(GetCurrentLine()); |
333 | if (!len) { | |
334 | if (linePos) *linePos = 0; | |
335 | return wxEmptyString; | |
336 | } | |
10ef30eb | 337 | |
9e730a78 RD |
338 | wxMemoryBuffer mbuf(len+1); |
339 | char* buf = (char*)mbuf.GetWriteBuf(len+1); | |
8de28db9 | 340 | |
9e730a78 RD |
341 | int pos = SendMsg(2027, len+1, (long)buf); |
342 | mbuf.UngetWriteBuf(len); | |
343 | mbuf.AppendByte(0); | |
344 | if (linePos) *linePos = pos; | |
345 | return stc2wx(buf); | |
9ce192d4 RD |
346 | } |
347 | ||
4370573a RD |
348 | // Retrieve the position of the last correctly styled character. |
349 | int wxStyledTextCtrl::GetEndStyled() { | |
350 | return SendMsg(2028, 0, 0); | |
9ce192d4 RD |
351 | } |
352 | ||
65ec6247 RD |
353 | // Convert all line endings in the document to one mode. |
354 | void wxStyledTextCtrl::ConvertEOLs(int eolMode) { | |
355 | SendMsg(2029, eolMode, 0); | |
9ce192d4 RD |
356 | } |
357 | ||
4370573a RD |
358 | // Retrieve the current end of line mode - one of CRLF, CR, or LF. |
359 | int wxStyledTextCtrl::GetEOLMode() { | |
360 | return SendMsg(2030, 0, 0); | |
9ce192d4 RD |
361 | } |
362 | ||
4370573a RD |
363 | // Set the current end of line mode. |
364 | void wxStyledTextCtrl::SetEOLMode(int eolMode) { | |
365 | SendMsg(2031, eolMode, 0); | |
9ce192d4 RD |
366 | } |
367 | ||
4370573a | 368 | // Set the current styling position to pos and the styling mask to mask. |
a834585d | 369 | // The styling mask can be used to protect some bits in each styling byte from modification. |
4370573a RD |
370 | void wxStyledTextCtrl::StartStyling(int pos, int mask) { |
371 | SendMsg(2032, pos, mask); | |
9ce192d4 RD |
372 | } |
373 | ||
4370573a RD |
374 | // Change style from current styling position for length characters to a style |
375 | // and move the current styling position to after this newly styled segment. | |
376 | void wxStyledTextCtrl::SetStyling(int length, int style) { | |
377 | SendMsg(2033, length, style); | |
f6bcfd97 BP |
378 | } |
379 | ||
a834585d | 380 | // Is drawing done first into a buffer or direct to the screen? |
4370573a RD |
381 | bool wxStyledTextCtrl::GetBufferedDraw() { |
382 | return SendMsg(2034, 0, 0) != 0; | |
f6bcfd97 BP |
383 | } |
384 | ||
4370573a RD |
385 | // If drawing is buffered then each line of text is drawn into a bitmap buffer |
386 | // before drawing it to the screen to avoid flicker. | |
387 | void wxStyledTextCtrl::SetBufferedDraw(bool buffered) { | |
388 | SendMsg(2035, buffered, 0); | |
f6bcfd97 BP |
389 | } |
390 | ||
a834585d | 391 | // Change the visible size of a tab to be a multiple of the width of a space character. |
4370573a RD |
392 | void wxStyledTextCtrl::SetTabWidth(int tabWidth) { |
393 | SendMsg(2036, tabWidth, 0); | |
f6bcfd97 BP |
394 | } |
395 | ||
4370573a RD |
396 | // Retrieve the visible size of a tab. |
397 | int wxStyledTextCtrl::GetTabWidth() { | |
398 | return SendMsg(2121, 0, 0); | |
9ce192d4 RD |
399 | } |
400 | ||
4370573a | 401 | // Set the code page used to interpret the bytes of the document as characters. |
4370573a | 402 | void wxStyledTextCtrl::SetCodePage(int codePage) { |
10ef30eb RD |
403 | #if wxUSE_UNICODE |
404 | wxASSERT_MSG(codePage == wxSTC_CP_UTF8, | |
405 | wxT("Only wxSTC_CP_UTF8 may be used when wxUSE_UNICODE is on.")); | |
406 | #else | |
407 | wxASSERT_MSG(codePage != wxSTC_CP_UTF8, | |
408 | wxT("wxSTC_CP_UTF8 may not be used when wxUSE_UNICODE is off.")); | |
409 | #endif | |
9e730a78 | 410 | SendMsg(2037, codePage); |
9ce192d4 RD |
411 | } |
412 | ||
4370573a | 413 | // Set the symbol used for a particular marker number, |
1a2fb4cd | 414 | // and optionally the fore and background colours. |
4370573a | 415 | void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol, |
9e730a78 RD |
416 | const wxColour& foreground, |
417 | const wxColour& background) { | |
9ce192d4 | 418 | |
9e730a78 RD |
419 | SendMsg(2040, markerNumber, markerSymbol); |
420 | if (foreground.Ok()) | |
421 | MarkerSetForeground(markerNumber, foreground); | |
422 | if (background.Ok()) | |
423 | MarkerSetBackground(markerNumber, background); | |
9ce192d4 RD |
424 | } |
425 | ||
4370573a RD |
426 | // Set the foreground colour used for a particular marker number. |
427 | void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) { | |
428 | SendMsg(2041, markerNumber, wxColourAsLong(fore)); | |
9ce192d4 RD |
429 | } |
430 | ||
4370573a RD |
431 | // Set the background colour used for a particular marker number. |
432 | void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) { | |
433 | SendMsg(2042, markerNumber, wxColourAsLong(back)); | |
9ce192d4 RD |
434 | } |
435 | ||
1a2fb4cd RD |
436 | // Add a marker to a line, returning an ID which can be used to find or delete the marker. |
437 | int wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) { | |
438 | return SendMsg(2043, line, markerNumber); | |
9ce192d4 RD |
439 | } |
440 | ||
a834585d | 441 | // Delete a marker from a line. |
4370573a RD |
442 | void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) { |
443 | SendMsg(2044, line, markerNumber); | |
9ce192d4 RD |
444 | } |
445 | ||
a834585d | 446 | // Delete all markers with a particular number from all lines. |
4370573a RD |
447 | void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) { |
448 | SendMsg(2045, markerNumber, 0); | |
9ce192d4 RD |
449 | } |
450 | ||
4370573a RD |
451 | // Get a bit mask of all the markers set on a line. |
452 | int wxStyledTextCtrl::MarkerGet(int line) { | |
453 | return SendMsg(2046, line, 0); | |
9ce192d4 RD |
454 | } |
455 | ||
4370573a RD |
456 | // Find the next line after lineStart that includes a marker in mask. |
457 | int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) { | |
458 | return SendMsg(2047, lineStart, markerMask); | |
9ce192d4 RD |
459 | } |
460 | ||
4370573a RD |
461 | // Find the previous line before lineStart that includes a marker in mask. |
462 | int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) { | |
463 | return SendMsg(2048, lineStart, markerMask); | |
9ce192d4 RD |
464 | } |
465 | ||
9e730a78 RD |
466 | // Define a marker from a bitmap |
467 | void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp) { | |
468 | // convert bmp to a xpm in a string | |
469 | wxMemoryOutputStream strm; | |
470 | wxImage img = bmp.ConvertToImage(); | |
471 | img.SaveFile(strm, wxBITMAP_TYPE_XPM); | |
472 | size_t len = strm.GetSize(); | |
473 | char* buff = new char[len+1]; | |
474 | strm.CopyTo(buff, len); | |
475 | buff[len] = 0; | |
476 | SendMsg(2049, markerNumber, (long)buff); | |
477 | delete [] buff; | |
88a8b04e | 478 | |
9e730a78 RD |
479 | } |
480 | ||
4370573a RD |
481 | // Set a margin to be either numeric or symbolic. |
482 | void wxStyledTextCtrl::SetMarginType(int margin, int marginType) { | |
483 | SendMsg(2240, margin, marginType); | |
9ce192d4 RD |
484 | } |
485 | ||
4370573a RD |
486 | // Retrieve the type of a margin. |
487 | int wxStyledTextCtrl::GetMarginType(int margin) { | |
488 | return SendMsg(2241, margin, 0); | |
9ce192d4 RD |
489 | } |
490 | ||
4370573a RD |
491 | // Set the width of a margin to a width expressed in pixels. |
492 | void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) { | |
493 | SendMsg(2242, margin, pixelWidth); | |
9ce192d4 RD |
494 | } |
495 | ||
4370573a RD |
496 | // Retrieve the width of a margin in pixels. |
497 | int wxStyledTextCtrl::GetMarginWidth(int margin) { | |
498 | return SendMsg(2243, margin, 0); | |
f6bcfd97 BP |
499 | } |
500 | ||
4370573a RD |
501 | // Set a mask that determines which markers are displayed in a margin. |
502 | void wxStyledTextCtrl::SetMarginMask(int margin, int mask) { | |
503 | SendMsg(2244, margin, mask); | |
f6bcfd97 BP |
504 | } |
505 | ||
4370573a RD |
506 | // Retrieve the marker mask of a margin. |
507 | int wxStyledTextCtrl::GetMarginMask(int margin) { | |
508 | return SendMsg(2245, margin, 0); | |
9ce192d4 RD |
509 | } |
510 | ||
4370573a RD |
511 | // Make a margin sensitive or insensitive to mouse clicks. |
512 | void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) { | |
513 | SendMsg(2246, margin, sensitive); | |
9ce192d4 RD |
514 | } |
515 | ||
4370573a RD |
516 | // Retrieve the mouse click sensitivity of a margin. |
517 | bool wxStyledTextCtrl::GetMarginSensitive(int margin) { | |
518 | return SendMsg(2247, margin, 0) != 0; | |
9ce192d4 RD |
519 | } |
520 | ||
4370573a | 521 | // Clear all the styles and make equivalent to the global default style. |
9ce192d4 | 522 | void wxStyledTextCtrl::StyleClearAll() { |
4370573a | 523 | SendMsg(2050, 0, 0); |
9ce192d4 RD |
524 | } |
525 | ||
4370573a RD |
526 | // Set the foreground colour of a style. |
527 | void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) { | |
528 | SendMsg(2051, style, wxColourAsLong(fore)); | |
9ce192d4 RD |
529 | } |
530 | ||
4370573a RD |
531 | // Set the background colour of a style. |
532 | void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) { | |
533 | SendMsg(2052, style, wxColourAsLong(back)); | |
9ce192d4 RD |
534 | } |
535 | ||
4370573a RD |
536 | // Set a style to be bold or not. |
537 | void wxStyledTextCtrl::StyleSetBold(int style, bool bold) { | |
538 | SendMsg(2053, style, bold); | |
9ce192d4 RD |
539 | } |
540 | ||
4370573a RD |
541 | // Set a style to be italic or not. |
542 | void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) { | |
543 | SendMsg(2054, style, italic); | |
9ce192d4 RD |
544 | } |
545 | ||
4370573a RD |
546 | // Set the size of characters of a style. |
547 | void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) { | |
548 | SendMsg(2055, style, sizePoints); | |
9ce192d4 RD |
549 | } |
550 | ||
4370573a RD |
551 | // Set the font of a style. |
552 | void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) { | |
0c5b83b0 | 553 | SendMsg(2056, style, (long)(const char*)wx2stc(fontName)); |
9ce192d4 RD |
554 | } |
555 | ||
4370573a RD |
556 | // Set a style to have its end of line filled or not. |
557 | void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) { | |
558 | SendMsg(2057, style, filled); | |
9ce192d4 RD |
559 | } |
560 | ||
4370573a RD |
561 | // Reset the default style to its state at startup |
562 | void wxStyledTextCtrl::StyleResetDefault() { | |
563 | SendMsg(2058, 0, 0); | |
9ce192d4 RD |
564 | } |
565 | ||
4370573a RD |
566 | // Set a style to be underlined or not. |
567 | void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) { | |
568 | SendMsg(2059, style, underline); | |
9ce192d4 RD |
569 | } |
570 | ||
65ec6247 RD |
571 | // Set a style to be mixed case, or to force upper or lower case. |
572 | void wxStyledTextCtrl::StyleSetCase(int style, int caseForce) { | |
573 | SendMsg(2060, style, caseForce); | |
574 | } | |
575 | ||
10ef30eb RD |
576 | // Set the character set of the font in a style. |
577 | void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) { | |
578 | SendMsg(2066, style, characterSet); | |
579 | } | |
580 | ||
9e730a78 RD |
581 | // Set a style to be a hotspot or not. |
582 | void wxStyledTextCtrl::StyleSetHotSpot(int style, bool hotspot) { | |
583 | SendMsg(2409, style, hotspot); | |
584 | } | |
585 | ||
4370573a RD |
586 | // Set the foreground colour of the selection and whether to use this setting. |
587 | void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { | |
588 | SendMsg(2067, useSetting, wxColourAsLong(fore)); | |
9ce192d4 RD |
589 | } |
590 | ||
4370573a RD |
591 | // Set the background colour of the selection and whether to use this setting. |
592 | void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) { | |
593 | SendMsg(2068, useSetting, wxColourAsLong(back)); | |
9ce192d4 RD |
594 | } |
595 | ||
4370573a RD |
596 | // Set the foreground colour of the caret. |
597 | void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) { | |
598 | SendMsg(2069, wxColourAsLong(fore), 0); | |
9ce192d4 RD |
599 | } |
600 | ||
4370573a RD |
601 | // When key+modifier combination km is pressed perform msg. |
602 | void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) { | |
9e730a78 | 603 | SendMsg(2070, MAKELONG(key, modifiers), cmd); |
9ce192d4 RD |
604 | } |
605 | ||
4370573a RD |
606 | // When key+modifier combination km do nothing. |
607 | void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) { | |
9e730a78 | 608 | SendMsg(2071, MAKELONG(key, modifiers)); |
9ce192d4 RD |
609 | } |
610 | ||
4370573a RD |
611 | // Drop all key mappings. |
612 | void wxStyledTextCtrl::CmdKeyClearAll() { | |
613 | SendMsg(2072, 0, 0); | |
614 | } | |
9ce192d4 | 615 | |
4370573a RD |
616 | // Set the styles for a segment of the document. |
617 | void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) { | |
9e730a78 | 618 | SendMsg(2073, length, (long)styleBytes); |
9ce192d4 RD |
619 | } |
620 | ||
4370573a RD |
621 | // Set a style to be visible or not. |
622 | void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) { | |
623 | SendMsg(2074, style, visible); | |
624 | } | |
9ce192d4 | 625 | |
4370573a | 626 | // Get the time in milliseconds that the caret is on and off. |
9ce192d4 | 627 | int wxStyledTextCtrl::GetCaretPeriod() { |
4370573a | 628 | return SendMsg(2075, 0, 0); |
9ce192d4 RD |
629 | } |
630 | ||
4370573a RD |
631 | // Get the time in milliseconds that the caret is on and off. 0 = steady on. |
632 | void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) { | |
633 | SendMsg(2076, periodMilliseconds, 0); | |
634 | } | |
9ce192d4 | 635 | |
a834585d | 636 | // Set the set of characters making up words for when moving or selecting by word. |
4370573a | 637 | void wxStyledTextCtrl::SetWordChars(const wxString& characters) { |
0c5b83b0 | 638 | SendMsg(2077, 0, (long)(const char*)wx2stc(characters)); |
9ce192d4 RD |
639 | } |
640 | ||
4370573a RD |
641 | // Start a sequence of actions that is undone and redone as a unit. |
642 | // May be nested. | |
643 | void wxStyledTextCtrl::BeginUndoAction() { | |
644 | SendMsg(2078, 0, 0); | |
645 | } | |
9ce192d4 | 646 | |
4370573a RD |
647 | // End a sequence of actions that is undone and redone as a unit. |
648 | void wxStyledTextCtrl::EndUndoAction() { | |
649 | SendMsg(2079, 0, 0); | |
650 | } | |
9ce192d4 | 651 | |
4370573a RD |
652 | // Set an indicator to plain, squiggle or TT. |
653 | void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) { | |
654 | SendMsg(2080, indic, style); | |
655 | } | |
9ce192d4 | 656 | |
4370573a RD |
657 | // Retrieve the style of an indicator. |
658 | int wxStyledTextCtrl::IndicatorGetStyle(int indic) { | |
659 | return SendMsg(2081, indic, 0); | |
660 | } | |
9ce192d4 | 661 | |
4370573a RD |
662 | // Set the foreground colour of an indicator. |
663 | void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) { | |
664 | SendMsg(2082, indic, wxColourAsLong(fore)); | |
9ce192d4 RD |
665 | } |
666 | ||
4370573a RD |
667 | // Retrieve the foreground colour of an indicator. |
668 | wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) { | |
669 | long c = SendMsg(2083, indic, 0); | |
670 | return wxColourFromLong(c); | |
671 | } | |
9ce192d4 | 672 | |
f114b858 RD |
673 | // Set the foreground colour of all whitespace and whether to use this setting. |
674 | void wxStyledTextCtrl::SetWhitespaceForeground(bool useSetting, const wxColour& fore) { | |
675 | SendMsg(2084, useSetting, wxColourAsLong(fore)); | |
676 | } | |
677 | ||
678 | // Set the background colour of all whitespace and whether to use this setting. | |
679 | void wxStyledTextCtrl::SetWhitespaceBackground(bool useSetting, const wxColour& back) { | |
680 | SendMsg(2085, useSetting, wxColourAsLong(back)); | |
681 | } | |
682 | ||
a834585d RD |
683 | // Divide each styling byte into lexical class bits (default: 5) and indicator |
684 | // bits (default: 3). If a lexer requires more than 32 lexical states, then this | |
4370573a RD |
685 | // is used to expand the possible states. |
686 | void wxStyledTextCtrl::SetStyleBits(int bits) { | |
687 | SendMsg(2090, bits, 0); | |
9ce192d4 RD |
688 | } |
689 | ||
4370573a RD |
690 | // Retrieve number of bits in style bytes used to hold the lexical state. |
691 | int wxStyledTextCtrl::GetStyleBits() { | |
692 | return SendMsg(2091, 0, 0); | |
693 | } | |
9ce192d4 | 694 | |
4370573a RD |
695 | // Used to hold extra styling information for each line. |
696 | void wxStyledTextCtrl::SetLineState(int line, int state) { | |
697 | SendMsg(2092, line, state); | |
f6bcfd97 BP |
698 | } |
699 | ||
4370573a RD |
700 | // Retrieve the extra styling information for a line. |
701 | int wxStyledTextCtrl::GetLineState(int line) { | |
702 | return SendMsg(2093, line, 0); | |
703 | } | |
f6bcfd97 | 704 | |
4370573a RD |
705 | // Retrieve the last line number that has line state. |
706 | int wxStyledTextCtrl::GetMaxLineState() { | |
707 | return SendMsg(2094, 0, 0); | |
f6bcfd97 BP |
708 | } |
709 | ||
65ec6247 RD |
710 | // Is the background of the line containing the caret in a different colour? |
711 | bool wxStyledTextCtrl::GetCaretLineVisible() { | |
712 | return SendMsg(2095, 0, 0) != 0; | |
713 | } | |
714 | ||
a834585d | 715 | // Display the background of the line containing the caret in a different colour. |
65ec6247 RD |
716 | void wxStyledTextCtrl::SetCaretLineVisible(bool show) { |
717 | SendMsg(2096, show, 0); | |
718 | } | |
719 | ||
720 | // Get the colour of the background of the line containing the caret. | |
721 | wxColour wxStyledTextCtrl::GetCaretLineBack() { | |
722 | long c = SendMsg(2097, 0, 0); | |
723 | return wxColourFromLong(c); | |
724 | } | |
725 | ||
726 | // Set the colour of the background of the line containing the caret. | |
727 | void wxStyledTextCtrl::SetCaretLineBack(const wxColour& back) { | |
728 | SendMsg(2098, wxColourAsLong(back), 0); | |
729 | } | |
730 | ||
1a2fb4cd RD |
731 | // Set a style to be changeable or not (read only). |
732 | // Experimental feature, currently buggy. | |
733 | void wxStyledTextCtrl::StyleSetChangeable(int style, bool changeable) { | |
734 | SendMsg(2099, style, changeable); | |
735 | } | |
736 | ||
4370573a RD |
737 | // Display a auto-completion list. |
738 | // The lenEntered parameter indicates how many characters before | |
739 | // the caret should be used to provide context. | |
740 | void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) { | |
0c5b83b0 | 741 | SendMsg(2100, lenEntered, (long)(const char*)wx2stc(itemList)); |
4370573a | 742 | } |
f6bcfd97 | 743 | |
4370573a RD |
744 | // Remove the auto-completion list from the screen. |
745 | void wxStyledTextCtrl::AutoCompCancel() { | |
746 | SendMsg(2101, 0, 0); | |
f6bcfd97 BP |
747 | } |
748 | ||
4370573a RD |
749 | // Is there an auto-completion list visible? |
750 | bool wxStyledTextCtrl::AutoCompActive() { | |
751 | return SendMsg(2102, 0, 0) != 0; | |
752 | } | |
f6bcfd97 | 753 | |
a834585d | 754 | // Retrieve the position of the caret when the auto-completion list was displayed. |
4370573a RD |
755 | int wxStyledTextCtrl::AutoCompPosStart() { |
756 | return SendMsg(2103, 0, 0); | |
f6bcfd97 BP |
757 | } |
758 | ||
4370573a RD |
759 | // User has selected an item so remove the list and insert the selection. |
760 | void wxStyledTextCtrl::AutoCompComplete() { | |
761 | SendMsg(2104, 0, 0); | |
762 | } | |
f6bcfd97 | 763 | |
4370573a RD |
764 | // Define a set of character that when typed cancel the auto-completion list. |
765 | void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) { | |
0c5b83b0 | 766 | SendMsg(2105, 0, (long)(const char*)wx2stc(characterSet)); |
f6bcfd97 BP |
767 | } |
768 | ||
a834585d RD |
769 | // Change the separator character in the string setting up an auto-completion list. |
770 | // Default is space but can be changed if items contain space. | |
4370573a RD |
771 | void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) { |
772 | SendMsg(2106, separatorCharacter, 0); | |
773 | } | |
f6bcfd97 | 774 | |
4370573a RD |
775 | // Retrieve the auto-completion list separator character. |
776 | int wxStyledTextCtrl::AutoCompGetSeparator() { | |
777 | return SendMsg(2107, 0, 0); | |
9ce192d4 RD |
778 | } |
779 | ||
4370573a RD |
780 | // Select the item in the auto-completion list that starts with a string. |
781 | void wxStyledTextCtrl::AutoCompSelect(const wxString& text) { | |
0c5b83b0 | 782 | SendMsg(2108, 0, (long)(const char*)wx2stc(text)); |
4370573a | 783 | } |
9ce192d4 | 784 | |
4370573a RD |
785 | // Should the auto-completion list be cancelled if the user backspaces to a |
786 | // position before where the box was created. | |
787 | void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) { | |
788 | SendMsg(2110, cancel, 0); | |
f6bcfd97 BP |
789 | } |
790 | ||
4370573a RD |
791 | // Retrieve whether auto-completion cancelled by backspacing before start. |
792 | bool wxStyledTextCtrl::AutoCompGetCancelAtStart() { | |
793 | return SendMsg(2111, 0, 0) != 0; | |
794 | } | |
f6bcfd97 | 795 | |
1a2fb4cd RD |
796 | // Define a set of characters that when typed will cause the autocompletion to |
797 | // choose the selected item. | |
4370573a | 798 | void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) { |
0c5b83b0 | 799 | SendMsg(2112, 0, (long)(const char*)wx2stc(characterSet)); |
4370573a | 800 | } |
9ce192d4 | 801 | |
4370573a RD |
802 | // Should a single item auto-completion list automatically choose the item. |
803 | void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) { | |
804 | SendMsg(2113, chooseSingle, 0); | |
805 | } | |
9ce192d4 | 806 | |
4370573a RD |
807 | // Retrieve whether a single item auto-completion list automatically choose the item. |
808 | bool wxStyledTextCtrl::AutoCompGetChooseSingle() { | |
809 | return SendMsg(2114, 0, 0) != 0; | |
9ce192d4 RD |
810 | } |
811 | ||
4370573a RD |
812 | // Set whether case is significant when performing auto-completion searches. |
813 | void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) { | |
814 | SendMsg(2115, ignoreCase, 0); | |
815 | } | |
9ce192d4 | 816 | |
4370573a RD |
817 | // Retrieve state of ignore case flag. |
818 | bool wxStyledTextCtrl::AutoCompGetIgnoreCase() { | |
819 | return SendMsg(2116, 0, 0) != 0; | |
9ce192d4 RD |
820 | } |
821 | ||
65ec6247 RD |
822 | // Display a list of strings and send notification when user chooses one. |
823 | void wxStyledTextCtrl::UserListShow(int listType, const wxString& itemList) { | |
0c5b83b0 | 824 | SendMsg(2117, listType, (long)(const char*)wx2stc(itemList)); |
65ec6247 RD |
825 | } |
826 | ||
a834585d | 827 | // Set whether or not autocompletion is hidden automatically when nothing matches. |
65ec6247 RD |
828 | void wxStyledTextCtrl::AutoCompSetAutoHide(bool autoHide) { |
829 | SendMsg(2118, autoHide, 0); | |
830 | } | |
831 | ||
a834585d | 832 | // Retrieve whether or not autocompletion is hidden automatically when nothing matches. |
65ec6247 RD |
833 | bool wxStyledTextCtrl::AutoCompGetAutoHide() { |
834 | return SendMsg(2119, 0, 0) != 0; | |
835 | } | |
836 | ||
a834585d RD |
837 | // Set whether or not autocompletion deletes any word characters |
838 | // after the inserted text upon completion. | |
1a2fb4cd RD |
839 | void wxStyledTextCtrl::AutoCompSetDropRestOfWord(bool dropRestOfWord) { |
840 | SendMsg(2270, dropRestOfWord, 0); | |
841 | } | |
842 | ||
a834585d RD |
843 | // Retrieve whether or not autocompletion deletes any word characters |
844 | // after the inserted text upon completion. | |
1a2fb4cd RD |
845 | bool wxStyledTextCtrl::AutoCompGetDropRestOfWord() { |
846 | return SendMsg(2271, 0, 0) != 0; | |
847 | } | |
848 | ||
9e730a78 RD |
849 | // Register an image for use in autocompletion lists. |
850 | void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) { | |
851 | // convert bmp to a xpm in a string | |
852 | wxMemoryOutputStream strm; | |
853 | wxImage img = bmp.ConvertToImage(); | |
854 | img.SaveFile(strm, wxBITMAP_TYPE_XPM); | |
855 | size_t len = strm.GetSize(); | |
856 | char* buff = new char[len+1]; | |
857 | strm.CopyTo(buff, len); | |
858 | buff[len] = 0; | |
859 | SendMsg(2405, type, (long)buff); | |
860 | delete [] buff; | |
88a8b04e | 861 | |
9e730a78 RD |
862 | } |
863 | ||
864 | // Clear all the registered images. | |
865 | void wxStyledTextCtrl::ClearRegisteredImages() { | |
866 | SendMsg(2408, 0, 0); | |
867 | } | |
868 | ||
869 | // Retrieve the auto-completion list type-separator character. | |
870 | int wxStyledTextCtrl::AutoCompGetTypeSeparator() { | |
871 | return SendMsg(2285, 0, 0); | |
872 | } | |
873 | ||
874 | // Change the type-separator character in the string setting up an auto-completion list. | |
875 | // Default is '?' but can be changed if items contain '?'. | |
876 | void wxStyledTextCtrl::AutoCompSetTypeSeparator(int separatorCharacter) { | |
877 | SendMsg(2286, separatorCharacter, 0); | |
878 | } | |
879 | ||
4370573a RD |
880 | // Set the number of spaces used for one level of indentation. |
881 | void wxStyledTextCtrl::SetIndent(int indentSize) { | |
882 | SendMsg(2122, indentSize, 0); | |
883 | } | |
9ce192d4 | 884 | |
4370573a RD |
885 | // Retrieve indentation size. |
886 | int wxStyledTextCtrl::GetIndent() { | |
887 | return SendMsg(2123, 0, 0); | |
9ce192d4 RD |
888 | } |
889 | ||
4370573a RD |
890 | // Indentation will only use space characters if useTabs is false, otherwise |
891 | // it will use a combination of tabs and spaces. | |
892 | void wxStyledTextCtrl::SetUseTabs(bool useTabs) { | |
893 | SendMsg(2124, useTabs, 0); | |
894 | } | |
9ce192d4 | 895 | |
4370573a RD |
896 | // Retrieve whether tabs will be used in indentation. |
897 | bool wxStyledTextCtrl::GetUseTabs() { | |
898 | return SendMsg(2125, 0, 0) != 0; | |
899 | } | |
9ce192d4 | 900 | |
4370573a RD |
901 | // Change the indentation of a line to a number of columns. |
902 | void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) { | |
903 | SendMsg(2126, line, indentSize); | |
904 | } | |
9ce192d4 | 905 | |
4370573a RD |
906 | // Retrieve the number of columns that a line is indented. |
907 | int wxStyledTextCtrl::GetLineIndentation(int line) { | |
908 | return SendMsg(2127, line, 0); | |
9ce192d4 RD |
909 | } |
910 | ||
4370573a RD |
911 | // Retrieve the position before the first non indentation character on a line. |
912 | int wxStyledTextCtrl::GetLineIndentPosition(int line) { | |
913 | return SendMsg(2128, line, 0); | |
914 | } | |
9ce192d4 | 915 | |
4370573a RD |
916 | // Retrieve the column number of a position, taking tab width into account. |
917 | int wxStyledTextCtrl::GetColumn(int pos) { | |
918 | return SendMsg(2129, pos, 0); | |
9ce192d4 RD |
919 | } |
920 | ||
4370573a RD |
921 | // Show or hide the horizontal scroll bar. |
922 | void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) { | |
923 | SendMsg(2130, show, 0); | |
924 | } | |
9ce192d4 | 925 | |
4370573a RD |
926 | // Is the horizontal scroll bar visible? |
927 | bool wxStyledTextCtrl::GetUseHorizontalScrollBar() { | |
928 | return SendMsg(2131, 0, 0) != 0; | |
9ce192d4 RD |
929 | } |
930 | ||
4370573a RD |
931 | // Show or hide indentation guides. |
932 | void wxStyledTextCtrl::SetIndentationGuides(bool show) { | |
933 | SendMsg(2132, show, 0); | |
934 | } | |
9ce192d4 | 935 | |
4370573a RD |
936 | // Are the indentation guides visible? |
937 | bool wxStyledTextCtrl::GetIndentationGuides() { | |
938 | return SendMsg(2133, 0, 0) != 0; | |
9ce192d4 RD |
939 | } |
940 | ||
4370573a RD |
941 | // Set the highlighted indentation guide column. |
942 | // 0 = no highlighted guide. | |
943 | void wxStyledTextCtrl::SetHighlightGuide(int column) { | |
944 | SendMsg(2134, column, 0); | |
945 | } | |
9ce192d4 | 946 | |
4370573a RD |
947 | // Get the highlighted indentation guide column. |
948 | int wxStyledTextCtrl::GetHighlightGuide() { | |
949 | return SendMsg(2135, 0, 0); | |
9ce192d4 RD |
950 | } |
951 | ||
4370573a RD |
952 | // Get the position after the last visible characters on a line. |
953 | int wxStyledTextCtrl::GetLineEndPosition(int line) { | |
954 | return SendMsg(2136, line, 0); | |
955 | } | |
9ce192d4 | 956 | |
4370573a RD |
957 | // Get the code page used to interpret the bytes of the document as characters. |
958 | int wxStyledTextCtrl::GetCodePage() { | |
959 | return SendMsg(2137, 0, 0); | |
9ce192d4 RD |
960 | } |
961 | ||
4370573a RD |
962 | // Get the foreground colour of the caret. |
963 | wxColour wxStyledTextCtrl::GetCaretForeground() { | |
964 | long c = SendMsg(2138, 0, 0); | |
965 | return wxColourFromLong(c); | |
966 | } | |
9ce192d4 | 967 | |
4370573a RD |
968 | // In read-only mode? |
969 | bool wxStyledTextCtrl::GetReadOnly() { | |
970 | return SendMsg(2140, 0, 0) != 0; | |
9ce192d4 RD |
971 | } |
972 | ||
4370573a RD |
973 | // Sets the position of the caret. |
974 | void wxStyledTextCtrl::SetCurrentPos(int pos) { | |
975 | SendMsg(2141, pos, 0); | |
976 | } | |
9ce192d4 | 977 | |
4370573a RD |
978 | // Sets the position that starts the selection - this becomes the anchor. |
979 | void wxStyledTextCtrl::SetSelectionStart(int pos) { | |
980 | SendMsg(2142, pos, 0); | |
9ce192d4 RD |
981 | } |
982 | ||
4370573a RD |
983 | // Returns the position at the start of the selection. |
984 | int wxStyledTextCtrl::GetSelectionStart() { | |
985 | return SendMsg(2143, 0, 0); | |
986 | } | |
9ce192d4 | 987 | |
4370573a RD |
988 | // Sets the position that ends the selection - this becomes the currentPosition. |
989 | void wxStyledTextCtrl::SetSelectionEnd(int pos) { | |
990 | SendMsg(2144, pos, 0); | |
9ce192d4 RD |
991 | } |
992 | ||
4370573a RD |
993 | // Returns the position at the end of the selection. |
994 | int wxStyledTextCtrl::GetSelectionEnd() { | |
995 | return SendMsg(2145, 0, 0); | |
996 | } | |
9ce192d4 | 997 | |
4370573a RD |
998 | // Sets the print magnification added to the point size of each style for printing. |
999 | void wxStyledTextCtrl::SetPrintMagnification(int magnification) { | |
1000 | SendMsg(2146, magnification, 0); | |
9ce192d4 RD |
1001 | } |
1002 | ||
4370573a RD |
1003 | // Returns the print magnification. |
1004 | int wxStyledTextCtrl::GetPrintMagnification() { | |
1005 | return SendMsg(2147, 0, 0); | |
1006 | } | |
9ce192d4 | 1007 | |
4370573a RD |
1008 | // Modify colours when printing for clearer printed text. |
1009 | void wxStyledTextCtrl::SetPrintColourMode(int mode) { | |
1010 | SendMsg(2148, mode, 0); | |
9ce192d4 RD |
1011 | } |
1012 | ||
4370573a RD |
1013 | // Returns the print colour mode. |
1014 | int wxStyledTextCtrl::GetPrintColourMode() { | |
1015 | return SendMsg(2149, 0, 0); | |
1016 | } | |
9ce192d4 | 1017 | |
4370573a RD |
1018 | // Find some text in the document. |
1019 | int wxStyledTextCtrl::FindText(int minPos, int maxPos, | |
9e730a78 RD |
1020 | const wxString& text, |
1021 | int flags) { | |
1022 | TextToFind ft; | |
1023 | ft.chrg.cpMin = minPos; | |
1024 | ft.chrg.cpMax = maxPos; | |
1025 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1026 | ft.lpstrText = (char*)(const char*)buf; | |
4370573a | 1027 | |
9e730a78 | 1028 | return SendMsg(2150, flags, (long)&ft); |
4370573a RD |
1029 | } |
1030 | ||
a834585d | 1031 | // On Windows, will draw the document into a display context such as a printer. |
4370573a | 1032 | int wxStyledTextCtrl::FormatRange(bool doDraw, |
9e730a78 RD |
1033 | int startPos, |
1034 | int endPos, | |
1035 | wxDC* draw, | |
1036 | wxDC* target, // Why does it use two? Can they be the same? | |
1037 | wxRect renderRect, | |
1038 | wxRect pageRect) { | |
1039 | RangeToFormat fr; | |
1040 | ||
1041 | if (endPos < startPos) { | |
1042 | int temp = startPos; | |
1043 | startPos = endPos; | |
1044 | endPos = temp; | |
1045 | } | |
1046 | fr.hdc = draw; | |
1047 | fr.hdcTarget = target; | |
1048 | fr.rc.top = renderRect.GetTop(); | |
1049 | fr.rc.left = renderRect.GetLeft(); | |
1050 | fr.rc.right = renderRect.GetRight(); | |
1051 | fr.rc.bottom = renderRect.GetBottom(); | |
1052 | fr.rcPage.top = pageRect.GetTop(); | |
1053 | fr.rcPage.left = pageRect.GetLeft(); | |
1054 | fr.rcPage.right = pageRect.GetRight(); | |
1055 | fr.rcPage.bottom = pageRect.GetBottom(); | |
1056 | fr.chrg.cpMin = startPos; | |
1057 | fr.chrg.cpMax = endPos; | |
1058 | ||
1059 | return SendMsg(2151, doDraw, (long)&fr); | |
1060 | } | |
1061 | ||
1062 | // Retrieve the display line at the top of the display. | |
4370573a RD |
1063 | int wxStyledTextCtrl::GetFirstVisibleLine() { |
1064 | return SendMsg(2152, 0, 0); | |
9ce192d4 RD |
1065 | } |
1066 | ||
4370573a RD |
1067 | // Retrieve the contents of a line. |
1068 | wxString wxStyledTextCtrl::GetLine(int line) { | |
9e730a78 RD |
1069 | int len = LineLength(line); |
1070 | if (!len) return wxEmptyString; | |
9ce192d4 | 1071 | |
9e730a78 RD |
1072 | wxMemoryBuffer mbuf(len+1); |
1073 | char* buf = (char*)mbuf.GetWriteBuf(len+1); | |
1074 | SendMsg(2153, line, (long)buf); | |
1075 | mbuf.UngetWriteBuf(len); | |
1076 | mbuf.AppendByte(0); | |
1077 | return stc2wx(buf); | |
4370573a RD |
1078 | } |
1079 | ||
1080 | // Returns the number of lines in the document. There is always at least one. | |
1081 | int wxStyledTextCtrl::GetLineCount() { | |
1082 | return SendMsg(2154, 0, 0); | |
1083 | } | |
9ce192d4 | 1084 | |
4370573a | 1085 | // Sets the size in pixels of the left margin. |
65ec6247 RD |
1086 | void wxStyledTextCtrl::SetMarginLeft(int pixelWidth) { |
1087 | SendMsg(2155, 0, pixelWidth); | |
4370573a | 1088 | } |
9ce192d4 | 1089 | |
4370573a RD |
1090 | // Returns the size in pixels of the left margin. |
1091 | int wxStyledTextCtrl::GetMarginLeft() { | |
1092 | return SendMsg(2156, 0, 0); | |
9ce192d4 RD |
1093 | } |
1094 | ||
4370573a | 1095 | // Sets the size in pixels of the right margin. |
65ec6247 RD |
1096 | void wxStyledTextCtrl::SetMarginRight(int pixelWidth) { |
1097 | SendMsg(2157, 0, pixelWidth); | |
4370573a | 1098 | } |
9ce192d4 | 1099 | |
4370573a RD |
1100 | // Returns the size in pixels of the right margin. |
1101 | int wxStyledTextCtrl::GetMarginRight() { | |
1102 | return SendMsg(2158, 0, 0); | |
9ce192d4 RD |
1103 | } |
1104 | ||
4370573a RD |
1105 | // Is the document different from when it was last saved? |
1106 | bool wxStyledTextCtrl::GetModify() { | |
1107 | return SendMsg(2159, 0, 0) != 0; | |
1108 | } | |
9ce192d4 | 1109 | |
4370573a RD |
1110 | // Select a range of text. |
1111 | void wxStyledTextCtrl::SetSelection(int start, int end) { | |
1112 | SendMsg(2160, start, end); | |
9ce192d4 RD |
1113 | } |
1114 | ||
4370573a RD |
1115 | // Retrieve the selected text. |
1116 | wxString wxStyledTextCtrl::GetSelectedText() { | |
9e730a78 RD |
1117 | int start; |
1118 | int end; | |
9ce192d4 | 1119 | |
9e730a78 RD |
1120 | GetSelection(&start, &end); |
1121 | int len = end - start; | |
1122 | if (!len) return wxEmptyString; | |
9ce192d4 | 1123 | |
3d7a4fe8 | 1124 | wxMemoryBuffer mbuf(len+2); |
9e730a78 RD |
1125 | char* buf = (char*)mbuf.GetWriteBuf(len+1); |
1126 | SendMsg(2161, 0, (long)buf); | |
1127 | mbuf.UngetWriteBuf(len); | |
1128 | mbuf.AppendByte(0); | |
1129 | return stc2wx(buf); | |
4370573a | 1130 | } |
9ce192d4 | 1131 | |
4370573a RD |
1132 | // Retrieve a range of text. |
1133 | wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { | |
9e730a78 RD |
1134 | if (endPos < startPos) { |
1135 | int temp = startPos; | |
1136 | startPos = endPos; | |
1137 | endPos = temp; | |
1138 | } | |
1139 | int len = endPos - startPos; | |
1140 | if (!len) return wxEmptyString; | |
1141 | wxMemoryBuffer mbuf(len+1); | |
1142 | char* buf = (char*)mbuf.GetWriteBuf(len); | |
1143 | TextRange tr; | |
1144 | tr.lpstrText = buf; | |
1145 | tr.chrg.cpMin = startPos; | |
1146 | tr.chrg.cpMax = endPos; | |
1147 | SendMsg(2162, 0, (long)&tr); | |
1148 | mbuf.UngetWriteBuf(len); | |
1149 | mbuf.AppendByte(0); | |
1150 | return stc2wx(buf); | |
9ce192d4 RD |
1151 | } |
1152 | ||
4370573a RD |
1153 | // Draw the selection in normal style or with selection highlighted. |
1154 | void wxStyledTextCtrl::HideSelection(bool normal) { | |
1155 | SendMsg(2163, normal, 0); | |
1156 | } | |
9ce192d4 | 1157 | |
4370573a RD |
1158 | // Retrieve the line containing a position. |
1159 | int wxStyledTextCtrl::LineFromPosition(int pos) { | |
1160 | return SendMsg(2166, pos, 0); | |
9ce192d4 RD |
1161 | } |
1162 | ||
4370573a RD |
1163 | // Retrieve the position at the start of a line. |
1164 | int wxStyledTextCtrl::PositionFromLine(int line) { | |
1165 | return SendMsg(2167, line, 0); | |
1166 | } | |
9ce192d4 | 1167 | |
4370573a RD |
1168 | // Scroll horizontally and vertically. |
1169 | void wxStyledTextCtrl::LineScroll(int columns, int lines) { | |
1170 | SendMsg(2168, columns, lines); | |
9ce192d4 RD |
1171 | } |
1172 | ||
4370573a RD |
1173 | // Ensure the caret is visible. |
1174 | void wxStyledTextCtrl::EnsureCaretVisible() { | |
1175 | SendMsg(2169, 0, 0); | |
1176 | } | |
9ce192d4 | 1177 | |
4370573a RD |
1178 | // Replace the selected text with the argument text. |
1179 | void wxStyledTextCtrl::ReplaceSelection(const wxString& text) { | |
0c5b83b0 | 1180 | SendMsg(2170, 0, (long)(const char*)wx2stc(text)); |
9ce192d4 RD |
1181 | } |
1182 | ||
4370573a RD |
1183 | // Set to read only or read write. |
1184 | void wxStyledTextCtrl::SetReadOnly(bool readOnly) { | |
1185 | SendMsg(2171, readOnly, 0); | |
1186 | } | |
9ce192d4 | 1187 | |
4370573a RD |
1188 | // Will a paste succeed? |
1189 | bool wxStyledTextCtrl::CanPaste() { | |
1190 | return SendMsg(2173, 0, 0) != 0; | |
9ce192d4 RD |
1191 | } |
1192 | ||
a834585d | 1193 | // Are there any undoable actions in the undo history? |
4370573a RD |
1194 | bool wxStyledTextCtrl::CanUndo() { |
1195 | return SendMsg(2174, 0, 0) != 0; | |
1196 | } | |
9ce192d4 | 1197 | |
4370573a RD |
1198 | // Delete the undo history. |
1199 | void wxStyledTextCtrl::EmptyUndoBuffer() { | |
1200 | SendMsg(2175, 0, 0); | |
9ce192d4 RD |
1201 | } |
1202 | ||
4370573a RD |
1203 | // Undo one action in the undo history. |
1204 | void wxStyledTextCtrl::Undo() { | |
1205 | SendMsg(2176, 0, 0); | |
1206 | } | |
9ce192d4 | 1207 | |
4370573a RD |
1208 | // Cut the selection to the clipboard. |
1209 | void wxStyledTextCtrl::Cut() { | |
1210 | SendMsg(2177, 0, 0); | |
f6bcfd97 BP |
1211 | } |
1212 | ||
4370573a RD |
1213 | // Copy the selection to the clipboard. |
1214 | void wxStyledTextCtrl::Copy() { | |
1215 | SendMsg(2178, 0, 0); | |
1216 | } | |
f6bcfd97 | 1217 | |
4370573a RD |
1218 | // Paste the contents of the clipboard into the document replacing the selection. |
1219 | void wxStyledTextCtrl::Paste() { | |
1220 | SendMsg(2179, 0, 0); | |
f6bcfd97 BP |
1221 | } |
1222 | ||
4370573a RD |
1223 | // Clear the selection. |
1224 | void wxStyledTextCtrl::Clear() { | |
1225 | SendMsg(2180, 0, 0); | |
1226 | } | |
f6bcfd97 | 1227 | |
4370573a RD |
1228 | // Replace the contents of the document with the argument text. |
1229 | void wxStyledTextCtrl::SetText(const wxString& text) { | |
0c5b83b0 | 1230 | SendMsg(2181, 0, (long)(const char*)wx2stc(text)); |
f6bcfd97 BP |
1231 | } |
1232 | ||
4370573a RD |
1233 | // Retrieve all the text in the document. |
1234 | wxString wxStyledTextCtrl::GetText() { | |
9e730a78 RD |
1235 | int len = GetTextLength(); |
1236 | wxMemoryBuffer mbuf(len+1); // leave room for the null... | |
1237 | char* buf = (char*)mbuf.GetWriteBuf(len+1); | |
1238 | SendMsg(2182, len+1, (long)buf); | |
1239 | mbuf.UngetWriteBuf(len); | |
1240 | mbuf.AppendByte(0); | |
1241 | return stc2wx(buf); | |
4370573a | 1242 | } |
9ce192d4 | 1243 | |
4370573a RD |
1244 | // Retrieve the number of characters in the document. |
1245 | int wxStyledTextCtrl::GetTextLength() { | |
1246 | return SendMsg(2183, 0, 0); | |
9ce192d4 RD |
1247 | } |
1248 | ||
a834585d | 1249 | // Set to overtype (true) or insert mode. |
4370573a RD |
1250 | void wxStyledTextCtrl::SetOvertype(bool overtype) { |
1251 | SendMsg(2186, overtype, 0); | |
1252 | } | |
9ce192d4 | 1253 | |
4370573a RD |
1254 | // Returns true if overtype mode is active otherwise false is returned. |
1255 | bool wxStyledTextCtrl::GetOvertype() { | |
1256 | return SendMsg(2187, 0, 0) != 0; | |
9ce192d4 RD |
1257 | } |
1258 | ||
a834585d | 1259 | // Set the width of the insert mode caret. |
65ec6247 RD |
1260 | void wxStyledTextCtrl::SetCaretWidth(int pixelWidth) { |
1261 | SendMsg(2188, pixelWidth, 0); | |
1262 | } | |
1263 | ||
a834585d | 1264 | // Returns the width of the insert mode caret. |
65ec6247 RD |
1265 | int wxStyledTextCtrl::GetCaretWidth() { |
1266 | return SendMsg(2189, 0, 0); | |
1267 | } | |
1268 | ||
1269 | // Sets the position that starts the target which is used for updating the | |
1270 | // document without affecting the scroll position. | |
1271 | void wxStyledTextCtrl::SetTargetStart(int pos) { | |
1272 | SendMsg(2190, pos, 0); | |
1273 | } | |
1274 | ||
1275 | // Get the position that starts the target. | |
1276 | int wxStyledTextCtrl::GetTargetStart() { | |
1277 | return SendMsg(2191, 0, 0); | |
1278 | } | |
1279 | ||
1280 | // Sets the position that ends the target which is used for updating the | |
1281 | // document without affecting the scroll position. | |
1282 | void wxStyledTextCtrl::SetTargetEnd(int pos) { | |
1283 | SendMsg(2192, pos, 0); | |
1284 | } | |
1285 | ||
1286 | // Get the position that ends the target. | |
1287 | int wxStyledTextCtrl::GetTargetEnd() { | |
1288 | return SendMsg(2193, 0, 0); | |
1289 | } | |
1290 | ||
1291 | // Replace the target text with the argument text. | |
b8b0e402 | 1292 | // Text is counted so it can contain nulls. |
65ec6247 RD |
1293 | // Returns the length of the replacement text. |
1294 | ||
9e730a78 RD |
1295 | int wxStyledTextCtrl::ReplaceTarget(const wxString& text) { |
1296 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1297 | return SendMsg(2194, strlen(buf), (long)(const char*)buf); | |
65ec6247 RD |
1298 | } |
1299 | ||
1300 | // Replace the target text with the argument text after \d processing. | |
b8b0e402 | 1301 | // Text is counted so it can contain nulls. |
65ec6247 RD |
1302 | // Looks for \d where d is between 1 and 9 and replaces these with the strings |
1303 | // matched in the last search operation which were surrounded by \( and \). | |
1304 | // Returns the length of the replacement text including any change | |
1305 | // caused by processing the \d patterns. | |
1306 | ||
9e730a78 RD |
1307 | int wxStyledTextCtrl::ReplaceTargetRE(const wxString& text) { |
1308 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1309 | return SendMsg(2195, strlen(buf), (long)(const char*)buf); | |
65ec6247 RD |
1310 | } |
1311 | ||
1312 | // Search for a counted string in the target and set the target to the found | |
b8b0e402 | 1313 | // range. Text is counted so it can contain nulls. |
65ec6247 RD |
1314 | // Returns length of range or -1 for failure in which case target is not moved. |
1315 | ||
9e730a78 RD |
1316 | int wxStyledTextCtrl::SearchInTarget(const wxString& text) { |
1317 | wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text); | |
1318 | return SendMsg(2197, strlen(buf), (long)(const char*)buf); | |
65ec6247 RD |
1319 | } |
1320 | ||
a834585d | 1321 | // Set the search flags used by SearchInTarget. |
65ec6247 RD |
1322 | void wxStyledTextCtrl::SetSearchFlags(int flags) { |
1323 | SendMsg(2198, flags, 0); | |
1324 | } | |
1325 | ||
a834585d | 1326 | // Get the search flags used by SearchInTarget. |
65ec6247 RD |
1327 | int wxStyledTextCtrl::GetSearchFlags() { |
1328 | return SendMsg(2199, 0, 0); | |
1329 | } | |
1330 | ||
4370573a RD |
1331 | // Show a call tip containing a definition near position pos. |
1332 | void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { | |
0c5b83b0 | 1333 | SendMsg(2200, pos, (long)(const char*)wx2stc(definition)); |
4370573a | 1334 | } |
9ce192d4 | 1335 | |
4370573a RD |
1336 | // Remove the call tip from the screen. |
1337 | void wxStyledTextCtrl::CallTipCancel() { | |
1338 | SendMsg(2201, 0, 0); | |
9ce192d4 RD |
1339 | } |
1340 | ||
4370573a RD |
1341 | // Is there an active call tip? |
1342 | bool wxStyledTextCtrl::CallTipActive() { | |
1343 | return SendMsg(2202, 0, 0) != 0; | |
1344 | } | |
9ce192d4 | 1345 | |
4370573a | 1346 | // Retrieve the position where the caret was before displaying the call tip. |
9ce192d4 | 1347 | int wxStyledTextCtrl::CallTipPosAtStart() { |
4370573a | 1348 | return SendMsg(2203, 0, 0); |
9ce192d4 RD |
1349 | } |
1350 | ||
4370573a | 1351 | // Highlight a segment of the definition. |
9ce192d4 | 1352 | void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) { |
4370573a | 1353 | SendMsg(2204, start, end); |
9ce192d4 RD |
1354 | } |
1355 | ||
4370573a RD |
1356 | // Set the background colour for the call tip. |
1357 | void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) { | |
1358 | SendMsg(2205, wxColourAsLong(back), 0); | |
1359 | } | |
9ce192d4 | 1360 | |
9e730a78 RD |
1361 | // Set the foreground colour for the call tip. |
1362 | void wxStyledTextCtrl::CallTipSetForeground(const wxColour& fore) { | |
1363 | SendMsg(2206, wxColourAsLong(fore), 0); | |
1364 | } | |
1365 | ||
1366 | // Set the foreground colour for the highlighted part of the call tip. | |
1367 | void wxStyledTextCtrl::CallTipSetForegroundHighlight(const wxColour& fore) { | |
1368 | SendMsg(2207, wxColourAsLong(fore), 0); | |
1369 | } | |
1370 | ||
4370573a RD |
1371 | // Find the display line of a document line taking hidden lines into account. |
1372 | int wxStyledTextCtrl::VisibleFromDocLine(int line) { | |
1373 | return SendMsg(2220, line, 0); | |
9ce192d4 RD |
1374 | } |
1375 | ||
4370573a RD |
1376 | // Find the document line of a display line taking hidden lines into account. |
1377 | int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) { | |
1378 | return SendMsg(2221, lineDisplay, 0); | |
1379 | } | |
9ce192d4 | 1380 | |
4370573a RD |
1381 | // Set the fold level of a line. |
1382 | // This encodes an integer level along with flags indicating whether the | |
1383 | // line is a header and whether it is effectively white space. | |
1384 | void wxStyledTextCtrl::SetFoldLevel(int line, int level) { | |
1385 | SendMsg(2222, line, level); | |
1386 | } | |
9ce192d4 | 1387 | |
4370573a RD |
1388 | // Retrieve the fold level of a line. |
1389 | int wxStyledTextCtrl::GetFoldLevel(int line) { | |
1390 | return SendMsg(2223, line, 0); | |
1391 | } | |
d134f170 | 1392 | |
4370573a RD |
1393 | // Find the last child line of a header line. |
1394 | int wxStyledTextCtrl::GetLastChild(int line, int level) { | |
1395 | return SendMsg(2224, line, level); | |
9ce192d4 RD |
1396 | } |
1397 | ||
4370573a RD |
1398 | // Find the parent line of a child line. |
1399 | int wxStyledTextCtrl::GetFoldParent(int line) { | |
1400 | return SendMsg(2225, line, 0); | |
1401 | } | |
9ce192d4 | 1402 | |
4370573a RD |
1403 | // Make a range of lines visible. |
1404 | void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) { | |
1405 | SendMsg(2226, lineStart, lineEnd); | |
9ce192d4 RD |
1406 | } |
1407 | ||
4370573a RD |
1408 | // Make a range of lines invisible. |
1409 | void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) { | |
1410 | SendMsg(2227, lineStart, lineEnd); | |
1411 | } | |
9ce192d4 | 1412 | |
4370573a RD |
1413 | // Is a line visible? |
1414 | bool wxStyledTextCtrl::GetLineVisible(int line) { | |
1415 | return SendMsg(2228, line, 0) != 0; | |
9ce192d4 RD |
1416 | } |
1417 | ||
4370573a RD |
1418 | // Show the children of a header line. |
1419 | void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) { | |
1420 | SendMsg(2229, line, expanded); | |
1421 | } | |
9ce192d4 | 1422 | |
4370573a RD |
1423 | // Is a header line expanded? |
1424 | bool wxStyledTextCtrl::GetFoldExpanded(int line) { | |
1425 | return SendMsg(2230, line, 0) != 0; | |
9ce192d4 RD |
1426 | } |
1427 | ||
4370573a RD |
1428 | // Switch a header line between expanded and contracted. |
1429 | void wxStyledTextCtrl::ToggleFold(int line) { | |
1430 | SendMsg(2231, line, 0); | |
1431 | } | |
9ce192d4 | 1432 | |
4370573a RD |
1433 | // Ensure a particular line is visible by expanding any header line hiding it. |
1434 | void wxStyledTextCtrl::EnsureVisible(int line) { | |
1435 | SendMsg(2232, line, 0); | |
1436 | } | |
9ce192d4 | 1437 | |
9e730a78 | 1438 | // Set some style options for folding. |
4370573a RD |
1439 | void wxStyledTextCtrl::SetFoldFlags(int flags) { |
1440 | SendMsg(2233, flags, 0); | |
9ce192d4 RD |
1441 | } |
1442 | ||
65ec6247 RD |
1443 | // Ensure a particular line is visible by expanding any header line hiding it. |
1444 | // Use the currently set visibility policy to determine which range to display. | |
1445 | void wxStyledTextCtrl::EnsureVisibleEnforcePolicy(int line) { | |
1446 | SendMsg(2234, line, 0); | |
1447 | } | |
1448 | ||
a834585d | 1449 | // Sets whether a tab pressed when caret is within indentation indents. |
65ec6247 RD |
1450 | void wxStyledTextCtrl::SetTabIndents(bool tabIndents) { |
1451 | SendMsg(2260, tabIndents, 0); | |
1452 | } | |
1453 | ||
1454 | // Does a tab pressed when caret is within indentation indent? | |
1455 | bool wxStyledTextCtrl::GetTabIndents() { | |
1456 | return SendMsg(2261, 0, 0) != 0; | |
1457 | } | |
1458 | ||
a834585d | 1459 | // Sets whether a backspace pressed when caret is within indentation unindents. |
65ec6247 RD |
1460 | void wxStyledTextCtrl::SetBackSpaceUnIndents(bool bsUnIndents) { |
1461 | SendMsg(2262, bsUnIndents, 0); | |
1462 | } | |
1463 | ||
1464 | // Does a backspace pressed when caret is within indentation unindent? | |
1465 | bool wxStyledTextCtrl::GetBackSpaceUnIndents() { | |
1466 | return SendMsg(2263, 0, 0) != 0; | |
1467 | } | |
1468 | ||
a834585d | 1469 | // Sets the time the mouse must sit still to generate a mouse dwell event. |
65ec6247 RD |
1470 | void wxStyledTextCtrl::SetMouseDwellTime(int periodMilliseconds) { |
1471 | SendMsg(2264, periodMilliseconds, 0); | |
1472 | } | |
1473 | ||
a834585d | 1474 | // Retrieve the time the mouse must sit still to generate a mouse dwell event. |
65ec6247 RD |
1475 | int wxStyledTextCtrl::GetMouseDwellTime() { |
1476 | return SendMsg(2265, 0, 0); | |
1477 | } | |
1478 | ||
a834585d | 1479 | // Get position of start of word. |
1a2fb4cd RD |
1480 | int wxStyledTextCtrl::WordStartPosition(int pos, bool onlyWordCharacters) { |
1481 | return SendMsg(2266, pos, onlyWordCharacters); | |
1482 | } | |
1483 | ||
a834585d | 1484 | // Get position of end of word. |
1a2fb4cd RD |
1485 | int wxStyledTextCtrl::WordEndPosition(int pos, bool onlyWordCharacters) { |
1486 | return SendMsg(2267, pos, onlyWordCharacters); | |
1487 | } | |
1488 | ||
a834585d | 1489 | // Sets whether text is word wrapped. |
1a2fb4cd RD |
1490 | void wxStyledTextCtrl::SetWrapMode(int mode) { |
1491 | SendMsg(2268, mode, 0); | |
1492 | } | |
1493 | ||
a834585d | 1494 | // Retrieve whether text is word wrapped. |
1a2fb4cd RD |
1495 | int wxStyledTextCtrl::GetWrapMode() { |
1496 | return SendMsg(2269, 0, 0); | |
1497 | } | |
1498 | ||
a834585d | 1499 | // Sets the degree of caching of layout information. |
1a2fb4cd RD |
1500 | void wxStyledTextCtrl::SetLayoutCache(int mode) { |
1501 | SendMsg(2272, mode, 0); | |
1502 | } | |
1503 | ||
a834585d | 1504 | // Retrieve the degree of caching of layout information. |
1a2fb4cd RD |
1505 | int wxStyledTextCtrl::GetLayoutCache() { |
1506 | return SendMsg(2273, 0, 0); | |
1507 | } | |
1508 | ||
a834585d RD |
1509 | // Sets the document width assumed for scrolling. |
1510 | void wxStyledTextCtrl::SetScrollWidth(int pixelWidth) { | |
1511 | SendMsg(2274, pixelWidth, 0); | |
1512 | } | |
1513 | ||
1514 | // Retrieve the document width assumed for scrolling. | |
1515 | int wxStyledTextCtrl::GetScrollWidth() { | |
1516 | return SendMsg(2275, 0, 0); | |
1517 | } | |
1518 | ||
1519 | // Measure the pixel width of some text in a particular style. | |
1520 | // Nul terminated text argument. | |
1521 | // Does not handle tab or control characters. | |
1522 | int wxStyledTextCtrl::TextWidth(int style, const wxString& text) { | |
1523 | return SendMsg(2276, style, (long)(const char*)wx2stc(text)); | |
1524 | } | |
1525 | ||
1526 | // Sets the scroll range so that maximum scroll position has | |
1527 | // the last line at the bottom of the view (default). | |
1528 | // Setting this to false allows scrolling one page below the last line. | |
1529 | void wxStyledTextCtrl::SetEndAtLastLine(bool endAtLastLine) { | |
1530 | SendMsg(2277, endAtLastLine, 0); | |
1531 | } | |
1532 | ||
1533 | // Retrieve whether the maximum scroll position has the last | |
1534 | // line at the bottom of the view. | |
1535 | int wxStyledTextCtrl::GetEndAtLastLine() { | |
1536 | return SendMsg(2278, 0, 0); | |
1537 | } | |
1538 | ||
1539 | // Retrieve the height of a particular line of text in pixels. | |
1540 | int wxStyledTextCtrl::TextHeight(int line) { | |
1541 | return SendMsg(2279, line, 0); | |
1542 | } | |
1543 | ||
9e730a78 RD |
1544 | // Show or hide the vertical scroll bar. |
1545 | void wxStyledTextCtrl::SetUseVerticalScrollBar(bool show) { | |
1546 | SendMsg(2280, show, 0); | |
1547 | } | |
1548 | ||
1549 | // Is the vertical scroll bar visible? | |
1550 | bool wxStyledTextCtrl::GetUseVerticalScrollBar() { | |
1551 | return SendMsg(2281, 0, 0) != 0; | |
1552 | } | |
1553 | ||
1554 | // Append a string to the end of the document without changing the selection. | |
1555 | void wxStyledTextCtrl::AppendText(int length, const wxString& text) { | |
1556 | SendMsg(2282, length, (long)(const char*)wx2stc(text)); | |
1557 | } | |
1558 | ||
1559 | // Is drawing done in two phases with backgrounds drawn before foregrounds? | |
1560 | bool wxStyledTextCtrl::GetTwoPhaseDraw() { | |
1561 | return SendMsg(2283, 0, 0) != 0; | |
1562 | } | |
1563 | ||
1564 | // In twoPhaseDraw mode, drawing is performed in two phases, first the background | |
1565 | // and then the foreground. This avoids chopping off characters that overlap the next run. | |
1566 | void wxStyledTextCtrl::SetTwoPhaseDraw(bool twoPhase) { | |
1567 | SendMsg(2284, twoPhase, 0); | |
1568 | } | |
1569 | ||
1570 | // Make the target range start and end be the same as the selection range start and end. | |
1571 | void wxStyledTextCtrl::TargetFromSelection() { | |
1572 | SendMsg(2287, 0, 0); | |
1573 | } | |
1574 | ||
1575 | // Join the lines in the target. | |
1576 | void wxStyledTextCtrl::LinesJoin() { | |
1577 | SendMsg(2288, 0, 0); | |
1578 | } | |
1579 | ||
1580 | // Split the lines in the target into lines that are less wide than pixelWidth | |
1581 | // where possible. | |
1582 | void wxStyledTextCtrl::LinesSplit(int pixelWidth) { | |
1583 | SendMsg(2289, pixelWidth, 0); | |
1584 | } | |
1585 | ||
1586 | // Set the colours used as a chequerboard pattern in the fold margin | |
1587 | void wxStyledTextCtrl::SetFoldMarginColour(bool useSetting, const wxColour& back) { | |
1588 | SendMsg(2290, useSetting, wxColourAsLong(back)); | |
1589 | } | |
1590 | void wxStyledTextCtrl::SetFoldMarginHiColour(bool useSetting, const wxColour& fore) { | |
1591 | SendMsg(2291, useSetting, wxColourAsLong(fore)); | |
1592 | } | |
1593 | ||
1594 | // Duplicate the current line. | |
1595 | void wxStyledTextCtrl::LineDuplicate() { | |
1596 | SendMsg(2404, 0, 0); | |
1597 | } | |
1598 | ||
f114b858 RD |
1599 | // Move caret to first position on display line. |
1600 | void wxStyledTextCtrl::HomeDisplay() { | |
1601 | SendMsg(2345, 0, 0); | |
1602 | } | |
1603 | ||
2b5f62a0 | 1604 | // Move caret to first position on display line extending selection to |
f114b858 RD |
1605 | // new caret position. |
1606 | void wxStyledTextCtrl::HomeDisplayExtend() { | |
1607 | SendMsg(2346, 0, 0); | |
1608 | } | |
1609 | ||
1610 | // Move caret to last position on display line. | |
1611 | void wxStyledTextCtrl::LineEndDisplay() { | |
1612 | SendMsg(2347, 0, 0); | |
1613 | } | |
1614 | ||
2b5f62a0 | 1615 | // Move caret to last position on display line extending selection to new |
f114b858 RD |
1616 | // caret position. |
1617 | void wxStyledTextCtrl::LineEndDisplayExtend() { | |
1618 | SendMsg(2348, 0, 0); | |
1619 | } | |
1620 | ||
e14d10b0 RD |
1621 | // Copy the line containing the caret. |
1622 | void wxStyledTextCtrl::LineCopy() { | |
1623 | SendMsg(2455, 0, 0); | |
1624 | } | |
1625 | ||
a834585d | 1626 | // Move the caret inside current view if it's not there already. |
65ec6247 RD |
1627 | void wxStyledTextCtrl::MoveCaretInsideView() { |
1628 | SendMsg(2401, 0, 0); | |
1629 | } | |
1630 | ||
a834585d | 1631 | // How many characters are on a line, not including end of line characters? |
4370573a RD |
1632 | int wxStyledTextCtrl::LineLength(int line) { |
1633 | return SendMsg(2350, line, 0); | |
1634 | } | |
9ce192d4 | 1635 | |
4370573a RD |
1636 | // Highlight the characters at two positions. |
1637 | void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) { | |
1638 | SendMsg(2351, pos1, pos2); | |
1639 | } | |
9ce192d4 | 1640 | |
4370573a RD |
1641 | // Highlight the character at a position indicating there is no matching brace. |
1642 | void wxStyledTextCtrl::BraceBadLight(int pos) { | |
1643 | SendMsg(2352, pos, 0); | |
9ce192d4 RD |
1644 | } |
1645 | ||
4370573a RD |
1646 | // Find the position of a matching brace or INVALID_POSITION if no match. |
1647 | int wxStyledTextCtrl::BraceMatch(int pos) { | |
1648 | return SendMsg(2353, pos, 0); | |
1649 | } | |
9ce192d4 | 1650 | |
a834585d | 1651 | // Are the end of line characters visible? |
4370573a RD |
1652 | bool wxStyledTextCtrl::GetViewEOL() { |
1653 | return SendMsg(2355, 0, 0) != 0; | |
9ce192d4 RD |
1654 | } |
1655 | ||
a834585d | 1656 | // Make the end of line characters visible or invisible. |
4370573a RD |
1657 | void wxStyledTextCtrl::SetViewEOL(bool visible) { |
1658 | SendMsg(2356, visible, 0); | |
1659 | } | |
9ce192d4 | 1660 | |
4370573a RD |
1661 | // Retrieve a pointer to the document object. |
1662 | void* wxStyledTextCtrl::GetDocPointer() { | |
9e730a78 | 1663 | return (void*)SendMsg(2357); |
4370573a | 1664 | } |
67003d1a | 1665 | |
4370573a RD |
1666 | // Change the document object used. |
1667 | void wxStyledTextCtrl::SetDocPointer(void* docPointer) { | |
9e730a78 | 1668 | SendMsg(2358, 0, (long)docPointer); |
67003d1a RD |
1669 | } |
1670 | ||
4370573a RD |
1671 | // Set which document modification events are sent to the container. |
1672 | void wxStyledTextCtrl::SetModEventMask(int mask) { | |
1673 | SendMsg(2359, mask, 0); | |
1674 | } | |
67003d1a | 1675 | |
4370573a RD |
1676 | // Retrieve the column number which text should be kept within. |
1677 | int wxStyledTextCtrl::GetEdgeColumn() { | |
1678 | return SendMsg(2360, 0, 0); | |
67003d1a RD |
1679 | } |
1680 | ||
4370573a RD |
1681 | // Set the column number of the edge. |
1682 | // If text goes past the edge then it is highlighted. | |
1683 | void wxStyledTextCtrl::SetEdgeColumn(int column) { | |
1684 | SendMsg(2361, column, 0); | |
1685 | } | |
67003d1a | 1686 | |
4370573a RD |
1687 | // Retrieve the edge highlight mode. |
1688 | int wxStyledTextCtrl::GetEdgeMode() { | |
1689 | return SendMsg(2362, 0, 0); | |
67003d1a RD |
1690 | } |
1691 | ||
4370573a RD |
1692 | // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that |
1693 | // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE). | |
1694 | void wxStyledTextCtrl::SetEdgeMode(int mode) { | |
1695 | SendMsg(2363, mode, 0); | |
1696 | } | |
67003d1a | 1697 | |
4370573a RD |
1698 | // Retrieve the colour used in edge indication. |
1699 | wxColour wxStyledTextCtrl::GetEdgeColour() { | |
1700 | long c = SendMsg(2364, 0, 0); | |
1701 | return wxColourFromLong(c); | |
67003d1a RD |
1702 | } |
1703 | ||
4370573a RD |
1704 | // Change the colour used in edge indication. |
1705 | void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) { | |
1706 | SendMsg(2365, wxColourAsLong(edgeColour), 0); | |
1707 | } | |
67003d1a | 1708 | |
4370573a RD |
1709 | // Sets the current caret position to be the search anchor. |
1710 | void wxStyledTextCtrl::SearchAnchor() { | |
1711 | SendMsg(2366, 0, 0); | |
67003d1a RD |
1712 | } |
1713 | ||
4370573a | 1714 | // Find some text starting at the search anchor. |
65ec6247 | 1715 | // Does not ensure the selection is visible. |
4370573a | 1716 | int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { |
0c5b83b0 | 1717 | return SendMsg(2367, flags, (long)(const char*)wx2stc(text)); |
4370573a | 1718 | } |
67003d1a | 1719 | |
4370573a | 1720 | // Find some text starting at the search anchor and moving backwards. |
65ec6247 | 1721 | // Does not ensure the selection is visible. |
4370573a | 1722 | int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { |
0c5b83b0 | 1723 | return SendMsg(2368, flags, (long)(const char*)wx2stc(text)); |
67003d1a RD |
1724 | } |
1725 | ||
4370573a RD |
1726 | // Retrieves the number of lines completely visible. |
1727 | int wxStyledTextCtrl::LinesOnScreen() { | |
1728 | return SendMsg(2370, 0, 0); | |
67003d1a RD |
1729 | } |
1730 | ||
4370573a RD |
1731 | // Set whether a pop up menu is displayed automatically when the user presses |
1732 | // the wrong mouse button. | |
1733 | void wxStyledTextCtrl::UsePopUp(bool allowPopUp) { | |
1734 | SendMsg(2371, allowPopUp, 0); | |
1735 | } | |
67003d1a | 1736 | |
a834585d | 1737 | // Is the selection rectangular? The alternative is the more common stream selection. |
4370573a RD |
1738 | bool wxStyledTextCtrl::SelectionIsRectangle() { |
1739 | return SendMsg(2372, 0, 0) != 0; | |
67003d1a RD |
1740 | } |
1741 | ||
4370573a RD |
1742 | // Set the zoom level. This number of points is added to the size of all fonts. |
1743 | // It may be positive to magnify or negative to reduce. | |
1744 | void wxStyledTextCtrl::SetZoom(int zoom) { | |
1745 | SendMsg(2373, zoom, 0); | |
1746 | } | |
67003d1a | 1747 | |
4370573a RD |
1748 | // Retrieve the zoom level. |
1749 | int wxStyledTextCtrl::GetZoom() { | |
1750 | return SendMsg(2374, 0, 0); | |
67003d1a RD |
1751 | } |
1752 | ||
4370573a RD |
1753 | // Create a new document object. |
1754 | // Starts with reference count of 1 and not selected into editor. | |
1755 | void* wxStyledTextCtrl::CreateDocument() { | |
9e730a78 | 1756 | return (void*)SendMsg(2375); |
4370573a | 1757 | } |
67003d1a | 1758 | |
4370573a RD |
1759 | // Extend life of document. |
1760 | void wxStyledTextCtrl::AddRefDocument(void* docPointer) { | |
9e730a78 | 1761 | SendMsg(2376, 0, (long)docPointer); |
67003d1a RD |
1762 | } |
1763 | ||
4370573a RD |
1764 | // Release a reference to the document, deleting document if it fades to black. |
1765 | void wxStyledTextCtrl::ReleaseDocument(void* docPointer) { | |
9e730a78 | 1766 | SendMsg(2377, 0, (long)docPointer); |
4370573a | 1767 | } |
67003d1a | 1768 | |
4370573a RD |
1769 | // Get which document modification events are sent to the container. |
1770 | int wxStyledTextCtrl::GetModEventMask() { | |
1771 | return SendMsg(2378, 0, 0); | |
67003d1a RD |
1772 | } |
1773 | ||
a834585d | 1774 | // Change internal focus flag. |
8de28db9 | 1775 | void wxStyledTextCtrl::SetSTCFocus(bool focus) { |
65ec6247 RD |
1776 | SendMsg(2380, focus, 0); |
1777 | } | |
1778 | ||
a834585d | 1779 | // Get internal focus flag. |
8de28db9 | 1780 | bool wxStyledTextCtrl::GetSTCFocus() { |
65ec6247 RD |
1781 | return SendMsg(2381, 0, 0) != 0; |
1782 | } | |
1783 | ||
a834585d | 1784 | // Change error status - 0 = OK. |
65ec6247 RD |
1785 | void wxStyledTextCtrl::SetStatus(int statusCode) { |
1786 | SendMsg(2382, statusCode, 0); | |
1787 | } | |
1788 | ||
a834585d | 1789 | // Get error status. |
65ec6247 RD |
1790 | int wxStyledTextCtrl::GetStatus() { |
1791 | return SendMsg(2383, 0, 0); | |
1792 | } | |
1793 | ||
a834585d | 1794 | // Set whether the mouse is captured when its button is pressed. |
65ec6247 RD |
1795 | void wxStyledTextCtrl::SetMouseDownCaptures(bool captures) { |
1796 | SendMsg(2384, captures, 0); | |
1797 | } | |
1798 | ||
a834585d | 1799 | // Get whether mouse gets captured. |
65ec6247 RD |
1800 | bool wxStyledTextCtrl::GetMouseDownCaptures() { |
1801 | return SendMsg(2385, 0, 0) != 0; | |
1802 | } | |
1803 | ||
a834585d | 1804 | // Sets the cursor to one of the SC_CURSOR* values. |
88a8b04e | 1805 | void wxStyledTextCtrl::SetSTCCursor(int cursorType) { |
65ec6247 RD |
1806 | SendMsg(2386, cursorType, 0); |
1807 | } | |
1808 | ||
a834585d | 1809 | // Get cursor type. |
88a8b04e | 1810 | int wxStyledTextCtrl::GetSTCCursor() { |
65ec6247 RD |
1811 | return SendMsg(2387, 0, 0); |
1812 | } | |
1813 | ||
1a2fb4cd | 1814 | // Change the way control characters are displayed: |
a834585d | 1815 | // If symbol is < 32, keep the drawn way, else, use the given character. |
1a2fb4cd RD |
1816 | void wxStyledTextCtrl::SetControlCharSymbol(int symbol) { |
1817 | SendMsg(2388, symbol, 0); | |
1818 | } | |
1819 | ||
a834585d | 1820 | // Get the way control characters are displayed. |
1a2fb4cd RD |
1821 | int wxStyledTextCtrl::GetControlCharSymbol() { |
1822 | return SendMsg(2389, 0, 0); | |
1823 | } | |
1824 | ||
a834585d | 1825 | // Move to the previous change in capitalisation. |
65ec6247 RD |
1826 | void wxStyledTextCtrl::WordPartLeft() { |
1827 | SendMsg(2390, 0, 0); | |
1828 | } | |
1829 | ||
a834585d RD |
1830 | // Move to the previous change in capitalisation extending selection |
1831 | // to new caret position. | |
65ec6247 RD |
1832 | void wxStyledTextCtrl::WordPartLeftExtend() { |
1833 | SendMsg(2391, 0, 0); | |
1834 | } | |
1835 | ||
a834585d | 1836 | // Move to the change next in capitalisation. |
65ec6247 RD |
1837 | void wxStyledTextCtrl::WordPartRight() { |
1838 | SendMsg(2392, 0, 0); | |
1839 | } | |
1840 | ||
a834585d RD |
1841 | // Move to the next change in capitalisation extending selection |
1842 | // to new caret position. | |
65ec6247 RD |
1843 | void wxStyledTextCtrl::WordPartRightExtend() { |
1844 | SendMsg(2393, 0, 0); | |
1845 | } | |
1846 | ||
a834585d RD |
1847 | // Set the way the display area is determined when a particular line |
1848 | // is to be moved to by Find, FindNext, GotoLine, etc. | |
65ec6247 RD |
1849 | void wxStyledTextCtrl::SetVisiblePolicy(int visiblePolicy, int visibleSlop) { |
1850 | SendMsg(2394, visiblePolicy, visibleSlop); | |
1851 | } | |
1852 | ||
a834585d | 1853 | // Delete back from the current position to the start of the line. |
65ec6247 RD |
1854 | void wxStyledTextCtrl::DelLineLeft() { |
1855 | SendMsg(2395, 0, 0); | |
1856 | } | |
1857 | ||
a834585d | 1858 | // Delete forwards from the current position to the end of the line. |
65ec6247 RD |
1859 | void wxStyledTextCtrl::DelLineRight() { |
1860 | SendMsg(2396, 0, 0); | |
1861 | } | |
1862 | ||
a834585d | 1863 | // Get and Set the xOffset (ie, horizonal scroll position). |
1a2fb4cd RD |
1864 | void wxStyledTextCtrl::SetXOffset(int newOffset) { |
1865 | SendMsg(2397, newOffset, 0); | |
1866 | } | |
1867 | int wxStyledTextCtrl::GetXOffset() { | |
1868 | return SendMsg(2398, 0, 0); | |
1869 | } | |
1870 | ||
9e730a78 RD |
1871 | // Set the last x chosen value to be the caret x position |
1872 | void wxStyledTextCtrl::ChooseCaretX() { | |
1873 | SendMsg(2399, 0, 0); | |
1874 | } | |
1875 | ||
a834585d RD |
1876 | // Set the way the caret is kept visible when going sideway. |
1877 | // The exclusion zone is given in pixels. | |
1878 | void wxStyledTextCtrl::SetXCaretPolicy(int caretPolicy, int caretSlop) { | |
1879 | SendMsg(2402, caretPolicy, caretSlop); | |
1880 | } | |
1881 | ||
1882 | // Set the way the line the caret is on is kept visible. | |
1883 | // The exclusion zone is given in lines. | |
1884 | void wxStyledTextCtrl::SetYCaretPolicy(int caretPolicy, int caretSlop) { | |
1885 | SendMsg(2403, caretPolicy, caretSlop); | |
1886 | } | |
1887 | ||
9e730a78 RD |
1888 | // Set printing to line wrapped (SC_WRAP_WORD) or not line wrapped (SC_WRAP_NONE). |
1889 | void wxStyledTextCtrl::SetPrintWrapMode(int mode) { | |
1890 | SendMsg(2406, mode, 0); | |
1891 | } | |
1892 | ||
1893 | // Is printing line wrapped. | |
1894 | int wxStyledTextCtrl::GetPrintWrapMode() { | |
1895 | return SendMsg(2407, 0, 0); | |
1896 | } | |
1897 | ||
1898 | // Set a fore colour for active hotspots. | |
1899 | void wxStyledTextCtrl::SetHotspotActiveForeground(bool useSetting, const wxColour& fore) { | |
1900 | SendMsg(2410, useSetting, wxColourAsLong(fore)); | |
1901 | } | |
1902 | ||
1903 | // Set a back colour for active hotspots. | |
1904 | void wxStyledTextCtrl::SetHotspotActiveBackground(bool useSetting, const wxColour& back) { | |
1905 | SendMsg(2411, useSetting, wxColourAsLong(back)); | |
1906 | } | |
1907 | ||
1908 | // Enable / Disable underlining active hotspots. | |
1909 | void wxStyledTextCtrl::SetHotspotActiveUnderline(bool underline) { | |
1910 | SendMsg(2412, underline, 0); | |
1911 | } | |
1912 | ||
e14d10b0 RD |
1913 | // Given a valid document position, return the previous position taking code |
1914 | // page into account. Returns 0 if passed 0. | |
1915 | int wxStyledTextCtrl::PositionBefore(int pos) { | |
1916 | return SendMsg(2417, pos, 0); | |
1917 | } | |
1918 | ||
1919 | // Given a valid document position, return the next position taking code | |
1920 | // page into account. Maximum value returned is the last position in the document. | |
1921 | int wxStyledTextCtrl::PositionAfter(int pos) { | |
1922 | return SendMsg(2418, pos, 0); | |
1923 | } | |
1924 | ||
1925 | // Copy a range of text to the clipboard. Positions are clipped into the document. | |
1926 | void wxStyledTextCtrl::CopyRange(int start, int end) { | |
1927 | SendMsg(2419, start, end); | |
1928 | } | |
1929 | ||
1930 | // Copy argument text to the clipboard. | |
1931 | void wxStyledTextCtrl::CopyText(int length, const wxString& text) { | |
1932 | SendMsg(2420, length, (long)(const char*)wx2stc(text)); | |
1933 | } | |
1934 | ||
4370573a RD |
1935 | // Start notifying the container of all key presses and commands. |
1936 | void wxStyledTextCtrl::StartRecord() { | |
1937 | SendMsg(3001, 0, 0); | |
1938 | } | |
67003d1a | 1939 | |
4370573a RD |
1940 | // Stop notifying the container of all key presses and commands. |
1941 | void wxStyledTextCtrl::StopRecord() { | |
1942 | SendMsg(3002, 0, 0); | |
67003d1a RD |
1943 | } |
1944 | ||
4370573a RD |
1945 | // Set the lexing language of the document. |
1946 | void wxStyledTextCtrl::SetLexer(int lexer) { | |
1947 | SendMsg(4001, lexer, 0); | |
1948 | } | |
67003d1a | 1949 | |
4370573a RD |
1950 | // Retrieve the lexing language of the document. |
1951 | int wxStyledTextCtrl::GetLexer() { | |
1952 | return SendMsg(4002, 0, 0); | |
67003d1a RD |
1953 | } |
1954 | ||
4370573a RD |
1955 | // Colourise a segment of the document using the current lexing language. |
1956 | void wxStyledTextCtrl::Colourise(int start, int end) { | |
1957 | SendMsg(4003, start, end); | |
1958 | } | |
67003d1a | 1959 | |
4370573a RD |
1960 | // Set up a value that may be used by a lexer for some optional feature. |
1961 | void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) { | |
0c5b83b0 | 1962 | SendMsg(4004, (long)(const char*)wx2stc(key), (long)(const char*)wx2stc(value)); |
f6bcfd97 BP |
1963 | } |
1964 | ||
4370573a RD |
1965 | // Set up the key words used by the lexer. |
1966 | void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) { | |
0c5b83b0 | 1967 | SendMsg(4005, keywordSet, (long)(const char*)wx2stc(keyWords)); |
4370573a | 1968 | } |
f6bcfd97 | 1969 | |
65ec6247 RD |
1970 | // Set the lexing language of the document based on string name. |
1971 | void wxStyledTextCtrl::SetLexerLanguage(const wxString& language) { | |
0c5b83b0 | 1972 | SendMsg(4006, 0, (long)(const char*)wx2stc(language)); |
65ec6247 RD |
1973 | } |
1974 | ||
4370573a | 1975 | // END of generated section |
f6bcfd97 | 1976 | //---------------------------------------------------------------------- |
f6bcfd97 BP |
1977 | |
1978 | ||
4370573a RD |
1979 | // Returns the line number of the line with the caret. |
1980 | int wxStyledTextCtrl::GetCurrentLine() { | |
1981 | int line = LineFromPosition(GetCurrentPos()); | |
1982 | return line; | |
f6bcfd97 BP |
1983 | } |
1984 | ||
1985 | ||
4370573a RD |
1986 | // Extract style settings from a spec-string which is composed of one or |
1987 | // more of the following comma separated elements: | |
1988 | // | |
1989 | // bold turns on bold | |
1990 | // italic turns on italics | |
1991 | // fore:#RRGGBB sets the foreground colour | |
1992 | // back:#RRGGBB sets the background colour | |
1993 | // face:[facename] sets the font face name to use | |
1994 | // size:[num] sets the font size in points | |
1995 | // eol turns on eol filling | |
1996 | // underline turns on underlining | |
1997 | // | |
1998 | void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { | |
1999 | ||
451c5cc7 | 2000 | wxStringTokenizer tkz(spec, wxT(",")); |
4370573a RD |
2001 | while (tkz.HasMoreTokens()) { |
2002 | wxString token = tkz.GetNextToken(); | |
f6bcfd97 | 2003 | |
4370573a RD |
2004 | wxString option = token.BeforeFirst(':'); |
2005 | wxString val = token.AfterFirst(':'); | |
f6bcfd97 | 2006 | |
451c5cc7 | 2007 | if (option == wxT("bold")) |
4370573a | 2008 | StyleSetBold(styleNum, true); |
f6bcfd97 | 2009 | |
451c5cc7 | 2010 | else if (option == wxT("italic")) |
4370573a | 2011 | StyleSetItalic(styleNum, true); |
9ce192d4 | 2012 | |
451c5cc7 | 2013 | else if (option == wxT("underline")) |
4370573a | 2014 | StyleSetUnderline(styleNum, true); |
9ce192d4 | 2015 | |
451c5cc7 | 2016 | else if (option == wxT("eol")) |
4370573a | 2017 | StyleSetEOLFilled(styleNum, true); |
9ce192d4 | 2018 | |
451c5cc7 | 2019 | else if (option == wxT("size")) { |
4370573a RD |
2020 | long points; |
2021 | if (val.ToLong(&points)) | |
2022 | StyleSetSize(styleNum, points); | |
2023 | } | |
9ce192d4 | 2024 | |
451c5cc7 | 2025 | else if (option == wxT("face")) |
4370573a | 2026 | StyleSetFaceName(styleNum, val); |
9ce192d4 | 2027 | |
451c5cc7 | 2028 | else if (option == wxT("fore")) |
4370573a | 2029 | StyleSetForeground(styleNum, wxColourFromSpec(val)); |
9ce192d4 | 2030 | |
451c5cc7 | 2031 | else if (option == wxT("back")) |
4370573a RD |
2032 | StyleSetBackground(styleNum, wxColourFromSpec(val)); |
2033 | } | |
9ce192d4 RD |
2034 | } |
2035 | ||
2036 | ||
4370573a RD |
2037 | // Set style size, face, bold, italic, and underline attributes from |
2038 | // a wxFont's attributes. | |
2039 | void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) { | |
7475e814 RD |
2040 | #ifdef __WXGTK__ |
2041 | // Ensure that the native font is initialized | |
2042 | int x, y; | |
2043 | GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font); | |
2044 | #endif | |
4370573a RD |
2045 | int size = font.GetPointSize(); |
2046 | wxString faceName = font.GetFaceName(); | |
2047 | bool bold = font.GetWeight() == wxBOLD; | |
2048 | bool italic = font.GetStyle() != wxNORMAL; | |
2049 | bool under = font.GetUnderlined(); | |
9ce192d4 | 2050 | |
4370573a RD |
2051 | // TODO: add encoding/charset mapping |
2052 | StyleSetFontAttr(styleNum, size, faceName, bold, italic, under); | |
9ce192d4 RD |
2053 | } |
2054 | ||
4370573a RD |
2055 | // Set all font style attributes at once. |
2056 | void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, | |
2057 | const wxString& faceName, | |
2058 | bool bold, bool italic, | |
2059 | bool underline) { | |
2060 | StyleSetSize(styleNum, size); | |
2061 | StyleSetFaceName(styleNum, faceName); | |
2062 | StyleSetBold(styleNum, bold); | |
2063 | StyleSetItalic(styleNum, italic); | |
2064 | StyleSetUnderline(styleNum, underline); | |
9ce192d4 | 2065 | |
4370573a | 2066 | // TODO: add encoding/charset mapping |
9ce192d4 RD |
2067 | } |
2068 | ||
2069 | ||
4370573a RD |
2070 | // Perform one of the operations defined by the wxSTC_CMD_* constants. |
2071 | void wxStyledTextCtrl::CmdKeyExecute(int cmd) { | |
2072 | SendMsg(cmd); | |
9ce192d4 RD |
2073 | } |
2074 | ||
2075 | ||
4370573a RD |
2076 | // Set the left and right margin in the edit area, measured in pixels. |
2077 | void wxStyledTextCtrl::SetMargins(int left, int right) { | |
2078 | SetMarginLeft(left); | |
2079 | SetMarginRight(right); | |
9ce192d4 RD |
2080 | } |
2081 | ||
2082 | ||
4370573a RD |
2083 | // Retrieve the start and end positions of the current selection. |
2084 | void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) { | |
2085 | if (startPos != NULL) | |
2086 | *startPos = SendMsg(SCI_GETSELECTIONSTART); | |
2087 | if (endPos != NULL) | |
2088 | *endPos = SendMsg(SCI_GETSELECTIONEND); | |
9ce192d4 RD |
2089 | } |
2090 | ||
2091 | ||
4370573a RD |
2092 | // Retrieve the point in the window where a position is displayed. |
2093 | wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { | |
2094 | int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); | |
2095 | int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); | |
2096 | return wxPoint(x, y); | |
f6bcfd97 BP |
2097 | } |
2098 | ||
f97d84a6 RD |
2099 | // Scroll enough to make the given line visible |
2100 | void wxStyledTextCtrl::ScrollToLine(int line) { | |
2101 | m_swx->DoScrollToLine(line); | |
2102 | } | |
2103 | ||
2104 | ||
2105 | // Scroll enough to make the given column visible | |
2106 | void wxStyledTextCtrl::ScrollToColumn(int column) { | |
2107 | m_swx->DoScrollToColumn(column); | |
2108 | } | |
2109 | ||
f6bcfd97 | 2110 | |
51566b0b RD |
2111 | bool wxStyledTextCtrl::SaveFile(const wxString& filename) |
2112 | { | |
2113 | wxFile file(filename, wxFile::write); | |
2114 | ||
2115 | if (!file.IsOpened()) | |
2116 | return FALSE; | |
2117 | ||
88a8b04e | 2118 | bool success = file.Write(GetText(), *wxConvCurrent); |
51566b0b | 2119 | |
4a65f2c8 | 2120 | if (success) |
51566b0b | 2121 | SetSavePoint(); |
4a65f2c8 | 2122 | |
51566b0b RD |
2123 | return success; |
2124 | } | |
2125 | ||
2126 | bool wxStyledTextCtrl::LoadFile(const wxString& filename) | |
2127 | { | |
041973c5 | 2128 | bool success = false; |
51566b0b RD |
2129 | wxFile file(filename, wxFile::read); |
2130 | ||
041973c5 | 2131 | if (file.IsOpened()) |
51566b0b | 2132 | { |
041973c5 | 2133 | wxString contents; |
88a8b04e RD |
2134 | #if wxUSE_UNICODE |
2135 | wxMemoryBuffer buffer; | |
2136 | #else | |
2137 | wxString buffer; | |
2138 | #endif | |
041973c5 | 2139 | off_t len = file.Length(); |
041973c5 RD |
2140 | if (len > 0) |
2141 | { | |
88a8b04e RD |
2142 | void *bufptr = buffer.GetWriteBuf(len); |
2143 | success = (file.Read(bufptr, len) == len); | |
2144 | buffer.UngetWriteBuf(len); | |
1e545382 | 2145 | #if wxUSE_UNICODE |
88a8b04e RD |
2146 | contents = wxString(buffer, *wxConvCurrent); |
2147 | #else | |
2148 | contents = buffer; | |
2149 | #endif | |
041973c5 RD |
2150 | } |
2151 | else | |
2152 | success = true; // empty file is ok | |
2153 | ||
2154 | if (success) | |
2155 | { | |
2156 | SetText(contents); | |
2157 | EmptyUndoBuffer(); | |
2158 | SetSavePoint(); | |
2159 | } | |
51566b0b RD |
2160 | } |
2161 | ||
2162 | return success; | |
2163 | } | |
2164 | ||
d25f5fbb | 2165 | |
2fcce896 | 2166 | #if wxUSE_DRAG_AND_DROP |
4a65f2c8 RD |
2167 | wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { |
2168 | return m_swx->DoDragOver(x, y, def); | |
2169 | } | |
2170 | ||
2171 | ||
2172 | bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { | |
2173 | return m_swx->DoDropText(x, y, data); | |
2174 | } | |
2fcce896 | 2175 | #endif |
4a65f2c8 RD |
2176 | |
2177 | ||
9ce192d4 RD |
2178 | //---------------------------------------------------------------------- |
2179 | // Event handlers | |
2180 | ||
88a8b04e | 2181 | void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) { |
9ce192d4 | 2182 | wxPaintDC dc(this); |
9e730a78 | 2183 | m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); |
9ce192d4 RD |
2184 | } |
2185 | ||
2186 | void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { | |
2187 | if (evt.GetOrientation() == wxHORIZONTAL) | |
2188 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
2189 | else | |
2190 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
2191 | } | |
2192 | ||
5fa4613c RD |
2193 | void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) { |
2194 | wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar); | |
2195 | if (sb) { | |
2196 | if (sb->IsVertical()) | |
2197 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
2198 | else | |
2199 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
2200 | } | |
2201 | } | |
2202 | ||
88a8b04e | 2203 | void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) { |
9ce192d4 RD |
2204 | wxSize sz = GetClientSize(); |
2205 | m_swx->DoSize(sz.x, sz.y); | |
2206 | } | |
2207 | ||
2208 | void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { | |
cb1871ca | 2209 | SetFocus(); |
9ce192d4 | 2210 | wxPoint pt = evt.GetPosition(); |
2b5f62a0 | 2211 | m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(), |
9ce192d4 RD |
2212 | evt.ShiftDown(), evt.ControlDown(), evt.AltDown()); |
2213 | } | |
2214 | ||
2215 | void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) { | |
2216 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 2217 | m_swx->DoLeftButtonMove(Point(pt.x, pt.y)); |
9ce192d4 RD |
2218 | } |
2219 | ||
2220 | void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) { | |
2221 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 2222 | m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(), |
9ce192d4 RD |
2223 | evt.ControlDown()); |
2224 | } | |
2225 | ||
2226 | ||
ddf2da08 RD |
2227 | void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { |
2228 | wxPoint pt = evt.GetPosition(); | |
2229 | m_swx->DoContextMenu(Point(pt.x, pt.y)); | |
2230 | } | |
2231 | ||
2232 | ||
2b5f62a0 VZ |
2233 | void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { |
2234 | wxPoint pt = evt.GetPosition(); | |
2235 | m_swx->DoMiddleButtonUp(Point(pt.x, pt.y)); | |
2236 | } | |
2237 | ||
65ec6247 | 2238 | void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { |
9ce192d4 | 2239 | wxPoint pt = evt.GetPosition(); |
65ec6247 | 2240 | ScreenToClient(&pt.x, &pt.y); |
9ce192d4 RD |
2241 | m_swx->DoContextMenu(Point(pt.x, pt.y)); |
2242 | } | |
2243 | ||
37d62433 RD |
2244 | |
2245 | void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) { | |
2246 | m_swx->DoMouseWheel(evt.GetWheelRotation(), | |
2247 | evt.GetWheelDelta(), | |
65ec6247 | 2248 | evt.GetLinesPerAction(), |
9b9337da RD |
2249 | evt.ControlDown(), |
2250 | evt.IsPageScroll()); | |
37d62433 RD |
2251 | } |
2252 | ||
2253 | ||
9ce192d4 | 2254 | void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { |
f3c2c221 RD |
2255 | // On (some?) non-US keyboards the AltGr key is required to enter some |
2256 | // common characters. It comes to us as both Alt and Ctrl down so we need | |
2257 | // to let the char through in that case, otherwise if only ctrl or only | |
2258 | // alt let's skip it. | |
2259 | bool ctrl = evt.ControlDown(); | |
2260 | bool alt = evt.AltDown(); | |
00c64037 | 2261 | bool skip = ((ctrl || alt) && ! (ctrl && alt)); |
f3c2c221 | 2262 | |
2b5f62a0 VZ |
2263 | int key = evt.GetKeyCode(); |
2264 | ||
0f9479da RD |
2265 | // printf("OnChar key:%d consumed:%d ctrl:%d alt:%d skip:%d\n", |
2266 | // key, m_lastKeyDownConsumed, ctrl, alt, skip); | |
10ef30eb | 2267 | |
2b5f62a0 VZ |
2268 | if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) && |
2269 | !m_lastKeyDownConsumed && !skip) { | |
d25f5fbb | 2270 | m_swx->DoAddChar(key); |
f3c2c221 | 2271 | return; |
d25f5fbb | 2272 | } |
f3c2c221 | 2273 | evt.Skip(); |
f6bcfd97 BP |
2274 | } |
2275 | ||
d6582821 | 2276 | |
f6bcfd97 | 2277 | void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { |
10ef30eb | 2278 | int key = evt.GetKeyCode(); |
f3c2c221 | 2279 | bool shift = evt.ShiftDown(), |
10ef30eb | 2280 | ctrl = evt.ControlDown(), |
88a8b04e RD |
2281 | alt = evt.AltDown(), |
2282 | meta = evt.MetaDown(); | |
f3c2c221 | 2283 | |
88a8b04e | 2284 | int processed = m_swx->DoKeyDown(key, shift, ctrl, alt, meta, &m_lastKeyDownConsumed); |
f3c2c221 | 2285 | |
0f9479da RD |
2286 | // printf("KeyDn key:%d shift:%d ctrl:%d alt:%d processed:%d consumed:%d\n", |
2287 | // key, shift, ctrl, alt, processed, m_lastKeyDownConsumed); | |
f3c2c221 | 2288 | |
d6582821 | 2289 | if (!processed && !m_lastKeyDownConsumed) |
9ce192d4 RD |
2290 | evt.Skip(); |
2291 | } | |
2292 | ||
d6582821 | 2293 | |
88a8b04e | 2294 | void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) { |
9ce192d4 RD |
2295 | m_swx->DoLoseFocus(); |
2296 | } | |
2297 | ||
d6582821 | 2298 | |
88a8b04e | 2299 | void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) { |
9ce192d4 RD |
2300 | m_swx->DoGainFocus(); |
2301 | } | |
2302 | ||
d6582821 | 2303 | |
88a8b04e | 2304 | void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) { |
9ce192d4 RD |
2305 | m_swx->DoSysColourChange(); |
2306 | } | |
2307 | ||
d6582821 | 2308 | |
88a8b04e | 2309 | void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { |
9ce192d4 RD |
2310 | // do nothing to help avoid flashing |
2311 | } | |
2312 | ||
2313 | ||
2314 | ||
2315 | void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) { | |
2316 | m_swx->DoCommand(evt.GetId()); | |
2317 | } | |
2318 | ||
2319 | ||
88a8b04e | 2320 | void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { |
f6bcfd97 BP |
2321 | m_swx->DoOnListBox(); |
2322 | } | |
2323 | ||
2324 | ||
9ce192d4 RD |
2325 | //---------------------------------------------------------------------- |
2326 | // Turn notifications from Scintilla into events | |
2327 | ||
f6bcfd97 | 2328 | |
9ce192d4 RD |
2329 | void wxStyledTextCtrl::NotifyChange() { |
2330 | wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); | |
a29a241f | 2331 | evt.SetEventObject(this); |
9ce192d4 RD |
2332 | GetEventHandler()->ProcessEvent(evt); |
2333 | } | |
2334 | ||
2b5f62a0 VZ |
2335 | |
2336 | static void SetEventText(wxStyledTextEvent& evt, const char* text, | |
2337 | size_t length) { | |
2338 | if(!text) return; | |
2339 | ||
2340 | // The unicode conversion MUST have a null byte to terminate the | |
2341 | // string so move it into a buffer first and give it one. | |
2342 | wxMemoryBuffer buf(length+1); | |
2343 | buf.AppendData((void*)text, length); | |
2344 | buf.AppendByte(0); | |
2345 | evt.SetText(stc2wx(buf)); | |
2346 | } | |
2347 | ||
2348 | ||
9ce192d4 RD |
2349 | void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { |
2350 | SCNotification& scn = *_scn; | |
65ec6247 RD |
2351 | wxStyledTextEvent evt(0, GetId()); |
2352 | ||
a29a241f | 2353 | evt.SetEventObject(this); |
65ec6247 RD |
2354 | evt.SetPosition(scn.position); |
2355 | evt.SetKey(scn.ch); | |
2356 | evt.SetModifiers(scn.modifiers); | |
2357 | ||
9ce192d4 RD |
2358 | switch (scn.nmhdr.code) { |
2359 | case SCN_STYLENEEDED: | |
65ec6247 | 2360 | evt.SetEventType(wxEVT_STC_STYLENEEDED); |
9ce192d4 | 2361 | break; |
65ec6247 | 2362 | |
9ce192d4 | 2363 | case SCN_CHARADDED: |
65ec6247 | 2364 | evt.SetEventType(wxEVT_STC_CHARADDED); |
9ce192d4 | 2365 | break; |
65ec6247 | 2366 | |
9ce192d4 | 2367 | case SCN_SAVEPOINTREACHED: |
65ec6247 | 2368 | evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED); |
9ce192d4 | 2369 | break; |
65ec6247 | 2370 | |
9ce192d4 | 2371 | case SCN_SAVEPOINTLEFT: |
65ec6247 | 2372 | evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT); |
9ce192d4 | 2373 | break; |
65ec6247 | 2374 | |
9ce192d4 | 2375 | case SCN_MODIFYATTEMPTRO: |
65ec6247 | 2376 | evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT); |
9ce192d4 | 2377 | break; |
65ec6247 RD |
2378 | |
2379 | case SCN_KEY: | |
2380 | evt.SetEventType(wxEVT_STC_KEY); | |
2381 | break; | |
2382 | ||
9ce192d4 | 2383 | case SCN_DOUBLECLICK: |
65ec6247 | 2384 | evt.SetEventType(wxEVT_STC_DOUBLECLICK); |
9ce192d4 | 2385 | break; |
65ec6247 RD |
2386 | |
2387 | case SCN_UPDATEUI: | |
2388 | evt.SetEventType(wxEVT_STC_UPDATEUI); | |
9ce192d4 | 2389 | break; |
65ec6247 RD |
2390 | |
2391 | case SCN_MODIFIED: | |
2392 | evt.SetEventType(wxEVT_STC_MODIFIED); | |
2393 | evt.SetModificationType(scn.modificationType); | |
2b5f62a0 | 2394 | SetEventText(evt, scn.text, scn.length); |
65ec6247 RD |
2395 | evt.SetLength(scn.length); |
2396 | evt.SetLinesAdded(scn.linesAdded); | |
2397 | evt.SetLine(scn.line); | |
2398 | evt.SetFoldLevelNow(scn.foldLevelNow); | |
2399 | evt.SetFoldLevelPrev(scn.foldLevelPrev); | |
9ce192d4 | 2400 | break; |
65ec6247 | 2401 | |
9ce192d4 | 2402 | case SCN_MACRORECORD: |
65ec6247 RD |
2403 | evt.SetEventType(wxEVT_STC_MACRORECORD); |
2404 | evt.SetMessage(scn.message); | |
2405 | evt.SetWParam(scn.wParam); | |
2406 | evt.SetLParam(scn.lParam); | |
9ce192d4 | 2407 | break; |
65ec6247 | 2408 | |
9ce192d4 | 2409 | case SCN_MARGINCLICK: |
65ec6247 RD |
2410 | evt.SetEventType(wxEVT_STC_MARGINCLICK); |
2411 | evt.SetMargin(scn.margin); | |
9ce192d4 | 2412 | break; |
65ec6247 | 2413 | |
9ce192d4 | 2414 | case SCN_NEEDSHOWN: |
65ec6247 RD |
2415 | evt.SetEventType(wxEVT_STC_NEEDSHOWN); |
2416 | evt.SetLength(scn.length); | |
9ce192d4 | 2417 | break; |
65ec6247 | 2418 | |
65ec6247 RD |
2419 | case SCN_PAINTED: |
2420 | evt.SetEventType(wxEVT_STC_PAINTED); | |
2421 | break; | |
2422 | ||
2423 | case SCN_USERLISTSELECTION: | |
2424 | evt.SetEventType(wxEVT_STC_USERLISTSELECTION); | |
2425 | evt.SetListType(scn.listType); | |
2b5f62a0 | 2426 | SetEventText(evt, scn.text, strlen(scn.text)); |
65ec6247 RD |
2427 | break; |
2428 | ||
2429 | case SCN_URIDROPPED: | |
2430 | evt.SetEventType(wxEVT_STC_URIDROPPED); | |
2b5f62a0 | 2431 | SetEventText(evt, scn.text, strlen(scn.text)); |
65ec6247 RD |
2432 | break; |
2433 | ||
2434 | case SCN_DWELLSTART: | |
2435 | evt.SetEventType(wxEVT_STC_DWELLSTART); | |
2436 | evt.SetX(scn.x); | |
2437 | evt.SetY(scn.y); | |
2438 | break; | |
2439 | ||
2440 | case SCN_DWELLEND: | |
2441 | evt.SetEventType(wxEVT_STC_DWELLEND); | |
2442 | evt.SetX(scn.x); | |
2443 | evt.SetY(scn.y); | |
2444 | break; | |
2445 | ||
a834585d RD |
2446 | case SCN_ZOOM: |
2447 | evt.SetEventType(wxEVT_STC_ZOOM); | |
2448 | break; | |
2449 | ||
9e730a78 RD |
2450 | case SCN_HOTSPOTCLICK: |
2451 | evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK); | |
2452 | break; | |
2453 | ||
2454 | case SCN_HOTSPOTDOUBLECLICK: | |
2455 | evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK); | |
2456 | break; | |
2457 | ||
2458 | case SCN_CALLTIPCLICK: | |
2459 | evt.SetEventType(wxEVT_STC_CALLTIP_CLICK); | |
2460 | break; | |
2461 | ||
65ec6247 RD |
2462 | default: |
2463 | return; | |
9ce192d4 | 2464 | } |
65ec6247 RD |
2465 | |
2466 | GetEventHandler()->ProcessEvent(evt); | |
9ce192d4 RD |
2467 | } |
2468 | ||
2469 | ||
9ce192d4 RD |
2470 | //---------------------------------------------------------------------- |
2471 | //---------------------------------------------------------------------- | |
2472 | //---------------------------------------------------------------------- | |
2473 | ||
2474 | wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) | |
2475 | : wxCommandEvent(commandType, id) | |
2476 | { | |
2477 | m_position = 0; | |
2478 | m_key = 0; | |
2479 | m_modifiers = 0; | |
2480 | m_modificationType = 0; | |
2481 | m_length = 0; | |
2482 | m_linesAdded = 0; | |
2483 | m_line = 0; | |
2484 | m_foldLevelNow = 0; | |
2485 | m_foldLevelPrev = 0; | |
2486 | m_margin = 0; | |
2487 | m_message = 0; | |
2488 | m_wParam = 0; | |
2489 | m_lParam = 0; | |
65ec6247 RD |
2490 | m_listType = 0; |
2491 | m_x = 0; | |
2492 | m_y = 0; | |
a29a241f | 2493 | m_dragAllowMove = FALSE; |
92bbd64f | 2494 | #if wxUSE_DRAG_AND_DROP |
a29a241f | 2495 | m_dragResult = wxDragNone; |
92bbd64f | 2496 | #endif |
9ce192d4 RD |
2497 | } |
2498 | ||
2499 | bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } | |
2500 | bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; } | |
2501 | bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; } | |
2502 | ||
5fa4613c | 2503 | |
41286fd1 JS |
2504 | wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): |
2505 | wxCommandEvent(event) | |
2506 | { | |
2507 | m_position = event.m_position; | |
2508 | m_key = event.m_key; | |
2509 | m_modifiers = event.m_modifiers; | |
2510 | m_modificationType = event.m_modificationType; | |
2511 | m_text = event.m_text; | |
2512 | m_length = event.m_length; | |
2513 | m_linesAdded = event.m_linesAdded; | |
2514 | m_line = event.m_line; | |
2515 | m_foldLevelNow = event.m_foldLevelNow; | |
2516 | m_foldLevelPrev = event.m_foldLevelPrev; | |
2517 | ||
2518 | m_margin = event.m_margin; | |
2519 | ||
2520 | m_message = event.m_message; | |
2521 | m_wParam = event.m_wParam; | |
2522 | m_lParam = event.m_lParam; | |
2523 | ||
2524 | m_listType = event.m_listType; | |
2525 | m_x = event.m_x; | |
2526 | m_y = event.m_y; | |
9ce192d4 | 2527 | |
41286fd1 JS |
2528 | m_dragText = event.m_dragText; |
2529 | m_dragAllowMove =event.m_dragAllowMove; | |
92bbd64f | 2530 | #if wxUSE_DRAG_AND_DROP |
41286fd1 | 2531 | m_dragResult = event.m_dragResult; |
92bbd64f | 2532 | #endif |
9ce192d4 RD |
2533 | } |
2534 | ||
2535 | //---------------------------------------------------------------------- | |
2536 | //---------------------------------------------------------------------- | |
2537 | ||
a29a241f RD |
2538 | |
2539 | ||
2540 | ||
5fa4613c RD |
2541 | |
2542 | ||
2543 | ||
2544 | ||
2545 |