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