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