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