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