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