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