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