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