]>
Commit | Line | Data |
---|---|---|
9ce192d4 RD |
1 | //////////////////////////////////////////////////////////////////////////// |
2 | // Name: stc.cpp | |
3 | // Purpose: A wxWindows 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 | |
f6bcfd97 | 8 | // namespace with all the classes and identifiers from Scintilla. |
9ce192d4 RD |
9 | // |
10 | // Author: Robin Dunn | |
11 | // | |
12 | // Created: 13-Jan-2000 | |
13 | // RCS-ID: $Id$ | |
14 | // Copyright: (c) 2000 by Total Control Software | |
15 | // Licence: wxWindows license | |
16 | ///////////////////////////////////////////////////////////////////////////// | |
17 | ||
f6bcfd97 BP |
18 | #include <ctype.h> |
19 | ||
9ce192d4 RD |
20 | #include "wx/stc/stc.h" |
21 | #include "ScintillaWX.h" | |
22 | ||
23 | #include <wx/tokenzr.h> | |
24 | ||
f6bcfd97 BP |
25 | // The following code forces a reference to all of the Scintilla lexers. |
26 | // If we don't do something like this, then the linker tends to "optimize" | |
27 | // them away. (eric@sourcegear.com) | |
28 | ||
4370573a | 29 | int wxForceScintillaLexers(void) |
f6bcfd97 BP |
30 | { |
31 | extern LexerModule lmCPP; | |
32 | extern LexerModule lmHTML; | |
33 | extern LexerModule lmXML; | |
34 | extern LexerModule lmProps; | |
35 | extern LexerModule lmErrorList; | |
36 | extern LexerModule lmMake; | |
37 | extern LexerModule lmBatch; | |
38 | extern LexerModule lmPerl; | |
39 | extern LexerModule lmPython; | |
40 | extern LexerModule lmSQL; | |
41 | extern LexerModule lmVB; | |
42 | ||
43 | if ( | |
44 | &lmCPP | |
45 | && &lmHTML | |
46 | && &lmXML | |
47 | && &lmProps | |
48 | && &lmErrorList | |
49 | && &lmMake | |
50 | && &lmBatch | |
51 | && &lmPerl | |
52 | && &lmPython | |
53 | && &lmSQL | |
54 | && &lmVB | |
55 | ) | |
56 | { | |
57 | return 1; | |
58 | } | |
4370573a RD |
59 | else |
60 | { | |
61 | return 0; | |
62 | } | |
f6bcfd97 BP |
63 | } |
64 | ||
9ce192d4 RD |
65 | //---------------------------------------------------------------------- |
66 | ||
67 | const wxChar* wxSTCNameStr = "stcwindow"; | |
68 | ||
d25f5fbb RD |
69 | |
70 | DEFINE_EVENT_TYPE( wxEVT_STC_CHANGE ) | |
71 | DEFINE_EVENT_TYPE( wxEVT_STC_STYLENEEDED ) | |
72 | DEFINE_EVENT_TYPE( wxEVT_STC_CHARADDED ) | |
73 | DEFINE_EVENT_TYPE( wxEVT_STC_UPDATEUI ) | |
74 | DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTREACHED ) | |
75 | DEFINE_EVENT_TYPE( wxEVT_STC_SAVEPOINTLEFT ) | |
76 | DEFINE_EVENT_TYPE( wxEVT_STC_ROMODIFYATTEMPT ) | |
77 | DEFINE_EVENT_TYPE( wxEVT_STC_DOUBLECLICK ) | |
78 | DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED ) | |
79 | DEFINE_EVENT_TYPE( wxEVT_STC_KEY ) | |
80 | DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) | |
81 | DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) | |
82 | DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) | |
83 | DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED ) | |
84 | ||
85 | ||
9ce192d4 RD |
86 | BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) |
87 | EVT_PAINT (wxStyledTextCtrl::OnPaint) | |
88 | EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin) | |
89 | EVT_SIZE (wxStyledTextCtrl::OnSize) | |
90 | EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) | |
91 | EVT_MOTION (wxStyledTextCtrl::OnMouseMove) | |
92 | EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) | |
93 | EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) | |
94 | EVT_CHAR (wxStyledTextCtrl::OnChar) | |
f6bcfd97 | 95 | EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) |
9ce192d4 RD |
96 | EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus) |
97 | EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus) | |
98 | EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) | |
99 | EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) | |
100 | EVT_MENU_RANGE (-1, -1, wxStyledTextCtrl::OnMenu) | |
f6bcfd97 | 101 | EVT_LISTBOX_DCLICK (-1, wxStyledTextCtrl::OnListBox) |
9ce192d4 RD |
102 | END_EVENT_TABLE() |
103 | ||
f6bcfd97 BP |
104 | |
105 | IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl) | |
106 | IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) | |
107 | ||
9ce192d4 RD |
108 | //---------------------------------------------------------------------- |
109 | // Constructor and Destructor | |
110 | ||
111 | wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, | |
112 | wxWindowID id, | |
113 | const wxPoint& pos, | |
114 | const wxSize& size, | |
115 | long style, | |
116 | const wxString& name) : | |
117 | wxControl(parent, id, pos, size, | |
f97d84a6 | 118 | style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, |
9ce192d4 RD |
119 | wxDefaultValidator, name) |
120 | { | |
121 | m_swx = new ScintillaWX(this); | |
9ce192d4 | 122 | m_stopWatch.Start(); |
9ce192d4 RD |
123 | } |
124 | ||
125 | ||
126 | wxStyledTextCtrl::~wxStyledTextCtrl() { | |
127 | delete m_swx; | |
9ce192d4 RD |
128 | } |
129 | ||
130 | ||
131 | //---------------------------------------------------------------------- | |
132 | ||
f6bcfd97 | 133 | long wxStyledTextCtrl::SendMsg(int msg, long wp, long lp) { |
9ce192d4 RD |
134 | |
135 | return m_swx->WndProc(msg, wp, lp); | |
136 | } | |
137 | ||
138 | ||
f97d84a6 RD |
139 | #ifdef MAKELONG |
140 | #undef MAKELONG | |
141 | #endif | |
142 | ||
4370573a | 143 | #define MAKELONG(a, b) ((a) | ((b) << 16)) |
9ce192d4 RD |
144 | |
145 | ||
4370573a RD |
146 | static long wxColourAsLong(const wxColour& co) { |
147 | return (((long)co.Blue() << 16) | | |
148 | ((long)co.Green() << 8) | | |
149 | ((long)co.Red())); | |
9ce192d4 RD |
150 | } |
151 | ||
4370573a RD |
152 | static wxColour wxColourFromLong(long c) { |
153 | wxColour clr; | |
154 | clr.Set(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); | |
155 | return clr; | |
9ce192d4 RD |
156 | } |
157 | ||
158 | ||
4370573a RD |
159 | static wxColour wxColourFromSpec(const wxString& spec) { |
160 | // spec should be #RRGGBB | |
161 | char* junk; | |
162 | int red = strtol(spec.Mid(1,2), &junk, 16); | |
163 | int green = strtol(spec.Mid(3,2), &junk, 16); | |
164 | int blue = strtol(spec.Mid(5,2), &junk, 16); | |
165 | return wxColour(red, green, blue); | |
9ce192d4 RD |
166 | } |
167 | ||
168 | ||
4370573a RD |
169 | //---------------------------------------------------------------------- |
170 | // BEGIN generated section. The following code is automatically generated | |
171 | // by gen_iface.py from the contents of Scintilla.iface. Do not edit | |
172 | // this file. Edit stc.cpp.in or gen_iface.py instead and regenerate. | |
9ce192d4 RD |
173 | |
174 | ||
4370573a | 175 | // Add text to the document |
9ce192d4 | 176 | void wxStyledTextCtrl::AddText(const wxString& text) { |
4370573a | 177 | SendMsg(2001, text.Len(), (long)text.c_str()); |
9ce192d4 RD |
178 | } |
179 | ||
4370573a | 180 | // Add array of cells to document |
9ce192d4 | 181 | void wxStyledTextCtrl::AddStyledText(const wxString& text) { |
4370573a | 182 | SendMsg(2002, text.Len(), (long)text.c_str()); |
9ce192d4 RD |
183 | } |
184 | ||
4370573a | 185 | // Insert string at a position |
9ce192d4 | 186 | void wxStyledTextCtrl::InsertText(int pos, const wxString& text) { |
4370573a | 187 | SendMsg(2003, pos, (long)text.c_str()); |
9ce192d4 RD |
188 | } |
189 | ||
4370573a | 190 | // Delete all text in the document |
9ce192d4 | 191 | void wxStyledTextCtrl::ClearAll() { |
4370573a | 192 | SendMsg(2004, 0, 0); |
9ce192d4 RD |
193 | } |
194 | ||
4370573a RD |
195 | // Set all style bytes to 0, remove all folding information |
196 | void wxStyledTextCtrl::ClearDocumentStyle() { | |
197 | SendMsg(2005, 0, 0); | |
9ce192d4 RD |
198 | } |
199 | ||
4370573a RD |
200 | // The number of characters in the document |
201 | int wxStyledTextCtrl::GetLength() { | |
202 | return SendMsg(2006, 0, 0); | |
9ce192d4 RD |
203 | } |
204 | ||
4370573a RD |
205 | // Returns the character byte at the position |
206 | int wxStyledTextCtrl::GetCharAt(int pos) { | |
207 | return SendMsg(2007, pos, 0); | |
9ce192d4 RD |
208 | } |
209 | ||
4370573a RD |
210 | // Returns the position of the caret |
211 | int wxStyledTextCtrl::GetCurrentPos() { | |
212 | return SendMsg(2008, 0, 0); | |
9ce192d4 RD |
213 | } |
214 | ||
4370573a RD |
215 | // Returns the position of the opposite end of the selection to the caret |
216 | int wxStyledTextCtrl::GetAnchor() { | |
217 | return SendMsg(2009, 0, 0); | |
9ce192d4 RD |
218 | } |
219 | ||
4370573a RD |
220 | // Returns the style byte at the position |
221 | int wxStyledTextCtrl::GetStyleAt(int pos) { | |
222 | return SendMsg(2010, pos, 0); | |
9ce192d4 RD |
223 | } |
224 | ||
4370573a | 225 | // Redoes the next action on the undo history |
9ce192d4 | 226 | void wxStyledTextCtrl::Redo() { |
4370573a | 227 | SendMsg(2011, 0, 0); |
9ce192d4 RD |
228 | } |
229 | ||
4370573a RD |
230 | // Choose between collecting actions into the undo |
231 | // history and discarding them. | |
232 | void wxStyledTextCtrl::SetUndoCollection(bool collectUndo) { | |
233 | SendMsg(2012, collectUndo, 0); | |
9ce192d4 RD |
234 | } |
235 | ||
4370573a RD |
236 | // Select all the text in the document. |
237 | void wxStyledTextCtrl::SelectAll() { | |
238 | SendMsg(2013, 0, 0); | |
9ce192d4 RD |
239 | } |
240 | ||
4370573a RD |
241 | // Remember the current position in the undo history as the position |
242 | // at which the document was saved. | |
243 | void wxStyledTextCtrl::SetSavePoint() { | |
244 | SendMsg(2014, 0, 0); | |
9ce192d4 RD |
245 | } |
246 | ||
4370573a RD |
247 | // Retrieve a buffer of cells. |
248 | wxString wxStyledTextCtrl::GetStyledText(int startPos, int endPos) { | |
249 | wxString text; | |
250 | int len = endPos - startPos; | |
251 | TextRange tr; | |
252 | tr.lpstrText = text.GetWriteBuf(len*2+1); | |
253 | tr.chrg.cpMin = startPos; | |
254 | tr.chrg.cpMax = endPos; | |
255 | SendMsg(2015, 0, (long)&tr); | |
256 | text.UngetWriteBuf(len*2); | |
257 | return text; | |
9ce192d4 RD |
258 | } |
259 | ||
4370573a RD |
260 | // Are there any redoable actions in the undo history. |
261 | bool wxStyledTextCtrl::CanRedo() { | |
262 | return SendMsg(2016, 0, 0) != 0; | |
9ce192d4 RD |
263 | } |
264 | ||
4370573a RD |
265 | // Retrieve the line number at which a particular marker is located |
266 | int wxStyledTextCtrl::MarkerLineFromHandle(int handle) { | |
267 | return SendMsg(2017, handle, 0); | |
9ce192d4 RD |
268 | } |
269 | ||
4370573a RD |
270 | // Delete a marker. |
271 | void wxStyledTextCtrl::MarkerDeleteHandle(int handle) { | |
272 | SendMsg(2018, handle, 0); | |
9ce192d4 RD |
273 | } |
274 | ||
4370573a RD |
275 | // Is undo history being collected? |
276 | bool wxStyledTextCtrl::GetUndoCollection() { | |
277 | return SendMsg(2019, 0, 0) != 0; | |
9ce192d4 RD |
278 | } |
279 | ||
4370573a RD |
280 | // Are white space characters currently visible? |
281 | // Returns one of SCWS_* constants. | |
282 | int wxStyledTextCtrl::GetViewWhiteSpace() { | |
283 | return SendMsg(2020, 0, 0); | |
9ce192d4 RD |
284 | } |
285 | ||
4370573a RD |
286 | // Make white space characters invisible, always visible or visible outside indentation. |
287 | void wxStyledTextCtrl::SetViewWhiteSpace(int viewWS) { | |
288 | SendMsg(2021, viewWS, 0); | |
9ce192d4 RD |
289 | } |
290 | ||
4370573a | 291 | // Find the position from a point within the window. |
9ce192d4 | 292 | int wxStyledTextCtrl::PositionFromPoint(wxPoint pt) { |
4370573a | 293 | return SendMsg(2022, pt.x, pt.y); |
9ce192d4 RD |
294 | } |
295 | ||
4370573a RD |
296 | // Set caret to start of a line and ensure it is visible. |
297 | void wxStyledTextCtrl::GotoLine(int line) { | |
298 | SendMsg(2024, line, 0); | |
9ce192d4 RD |
299 | } |
300 | ||
4370573a | 301 | // Set caret to a position and ensure it is visible. |
9ce192d4 | 302 | void wxStyledTextCtrl::GotoPos(int pos) { |
4370573a | 303 | SendMsg(2025, pos, 0); |
9ce192d4 RD |
304 | } |
305 | ||
4370573a RD |
306 | // Set the selection anchor to a position. The anchor is the opposite |
307 | // end of the selection from the caret. | |
308 | void wxStyledTextCtrl::SetAnchor(int posAnchor) { | |
309 | SendMsg(2026, posAnchor, 0); | |
9ce192d4 RD |
310 | } |
311 | ||
4370573a RD |
312 | // Retrieve the text of the line containing the caret. |
313 | // Returns the index of the caret on the line. | |
314 | wxString wxStyledTextCtrl::GetCurLine(int* linePos) { | |
315 | wxString text; | |
316 | int len = LineLength(GetCurrentLine()); | |
317 | char* buf = text.GetWriteBuf(len+1); | |
9ce192d4 | 318 | |
4370573a RD |
319 | int pos = SendMsg(2027, len, (long)buf); |
320 | text.UngetWriteBuf(); | |
321 | if (linePos) *linePos = pos; | |
9ce192d4 | 322 | |
4370573a | 323 | return text; |
9ce192d4 RD |
324 | } |
325 | ||
4370573a RD |
326 | // Retrieve the position of the last correctly styled character. |
327 | int wxStyledTextCtrl::GetEndStyled() { | |
328 | return SendMsg(2028, 0, 0); | |
9ce192d4 RD |
329 | } |
330 | ||
4370573a RD |
331 | // Convert all line endings in the document to use the current mode. |
332 | void wxStyledTextCtrl::ConvertEOLs() { | |
333 | SendMsg(2029, 0, 0); | |
9ce192d4 RD |
334 | } |
335 | ||
4370573a RD |
336 | // Retrieve the current end of line mode - one of CRLF, CR, or LF. |
337 | int wxStyledTextCtrl::GetEOLMode() { | |
338 | return SendMsg(2030, 0, 0); | |
9ce192d4 RD |
339 | } |
340 | ||
4370573a RD |
341 | // Set the current end of line mode. |
342 | void wxStyledTextCtrl::SetEOLMode(int eolMode) { | |
343 | SendMsg(2031, eolMode, 0); | |
9ce192d4 RD |
344 | } |
345 | ||
4370573a RD |
346 | // Set the current styling position to pos and the styling mask to mask. |
347 | // The styling mask can be used to protect some bits in each styling byte from | |
348 | // modification. | |
349 | void wxStyledTextCtrl::StartStyling(int pos, int mask) { | |
350 | SendMsg(2032, pos, mask); | |
9ce192d4 RD |
351 | } |
352 | ||
4370573a RD |
353 | // Change style from current styling position for length characters to a style |
354 | // and move the current styling position to after this newly styled segment. | |
355 | void wxStyledTextCtrl::SetStyling(int length, int style) { | |
356 | SendMsg(2033, length, style); | |
f6bcfd97 BP |
357 | } |
358 | ||
4370573a RD |
359 | // Is drawing done first into a buffer or direct to the screen. |
360 | bool wxStyledTextCtrl::GetBufferedDraw() { | |
361 | return SendMsg(2034, 0, 0) != 0; | |
f6bcfd97 BP |
362 | } |
363 | ||
4370573a RD |
364 | // If drawing is buffered then each line of text is drawn into a bitmap buffer |
365 | // before drawing it to the screen to avoid flicker. | |
366 | void wxStyledTextCtrl::SetBufferedDraw(bool buffered) { | |
367 | SendMsg(2035, buffered, 0); | |
f6bcfd97 BP |
368 | } |
369 | ||
4370573a RD |
370 | // Change the visible size of a tab to be a multiple of the width of a space |
371 | // character. | |
372 | void wxStyledTextCtrl::SetTabWidth(int tabWidth) { | |
373 | SendMsg(2036, tabWidth, 0); | |
f6bcfd97 BP |
374 | } |
375 | ||
4370573a RD |
376 | // Retrieve the visible size of a tab. |
377 | int wxStyledTextCtrl::GetTabWidth() { | |
378 | return SendMsg(2121, 0, 0); | |
9ce192d4 RD |
379 | } |
380 | ||
4370573a RD |
381 | // Set the code page used to interpret the bytes of the document as characters. |
382 | // The SC_CP_UTF8 value can be used to enter Unicode mode. | |
383 | void wxStyledTextCtrl::SetCodePage(int codePage) { | |
384 | SendMsg(2037, codePage, 0); | |
9ce192d4 RD |
385 | } |
386 | ||
4370573a RD |
387 | // Set the symbol used for a particular marker number, |
388 | // and optionally the for and background colours. | |
389 | void wxStyledTextCtrl::MarkerDefine(int markerNumber, int markerSymbol, | |
390 | const wxColour& foreground, | |
391 | const wxColour& background) { | |
9ce192d4 | 392 | |
4370573a RD |
393 | SendMsg(2040, markerNumber, markerSymbol); |
394 | if (foreground.Ok()) | |
395 | MarkerSetForeground(markerNumber, foreground); | |
396 | if (background.Ok()) | |
397 | MarkerSetBackground(markerNumber, background); | |
9ce192d4 RD |
398 | } |
399 | ||
4370573a RD |
400 | // Set the foreground colour used for a particular marker number. |
401 | void wxStyledTextCtrl::MarkerSetForeground(int markerNumber, const wxColour& fore) { | |
402 | SendMsg(2041, markerNumber, wxColourAsLong(fore)); | |
9ce192d4 RD |
403 | } |
404 | ||
4370573a RD |
405 | // Set the background colour used for a particular marker number. |
406 | void wxStyledTextCtrl::MarkerSetBackground(int markerNumber, const wxColour& back) { | |
407 | SendMsg(2042, markerNumber, wxColourAsLong(back)); | |
9ce192d4 RD |
408 | } |
409 | ||
4370573a RD |
410 | // Add a marker to a line. |
411 | void wxStyledTextCtrl::MarkerAdd(int line, int markerNumber) { | |
412 | SendMsg(2043, line, markerNumber); | |
9ce192d4 RD |
413 | } |
414 | ||
4370573a RD |
415 | // Delete a marker from a line |
416 | void wxStyledTextCtrl::MarkerDelete(int line, int markerNumber) { | |
417 | SendMsg(2044, line, markerNumber); | |
9ce192d4 RD |
418 | } |
419 | ||
4370573a RD |
420 | // Delete all markers with a particular number from all lines |
421 | void wxStyledTextCtrl::MarkerDeleteAll(int markerNumber) { | |
422 | SendMsg(2045, markerNumber, 0); | |
9ce192d4 RD |
423 | } |
424 | ||
4370573a RD |
425 | // Get a bit mask of all the markers set on a line. |
426 | int wxStyledTextCtrl::MarkerGet(int line) { | |
427 | return SendMsg(2046, line, 0); | |
9ce192d4 RD |
428 | } |
429 | ||
4370573a RD |
430 | // Find the next line after lineStart that includes a marker in mask. |
431 | int wxStyledTextCtrl::MarkerNext(int lineStart, int markerMask) { | |
432 | return SendMsg(2047, lineStart, markerMask); | |
9ce192d4 RD |
433 | } |
434 | ||
4370573a RD |
435 | // Find the previous line before lineStart that includes a marker in mask. |
436 | int wxStyledTextCtrl::MarkerPrevious(int lineStart, int markerMask) { | |
437 | return SendMsg(2048, lineStart, markerMask); | |
9ce192d4 RD |
438 | } |
439 | ||
4370573a RD |
440 | // Set a margin to be either numeric or symbolic. |
441 | void wxStyledTextCtrl::SetMarginType(int margin, int marginType) { | |
442 | SendMsg(2240, margin, marginType); | |
9ce192d4 RD |
443 | } |
444 | ||
4370573a RD |
445 | // Retrieve the type of a margin. |
446 | int wxStyledTextCtrl::GetMarginType(int margin) { | |
447 | return SendMsg(2241, margin, 0); | |
9ce192d4 RD |
448 | } |
449 | ||
4370573a RD |
450 | // Set the width of a margin to a width expressed in pixels. |
451 | void wxStyledTextCtrl::SetMarginWidth(int margin, int pixelWidth) { | |
452 | SendMsg(2242, margin, pixelWidth); | |
9ce192d4 RD |
453 | } |
454 | ||
4370573a RD |
455 | // Retrieve the width of a margin in pixels. |
456 | int wxStyledTextCtrl::GetMarginWidth(int margin) { | |
457 | return SendMsg(2243, margin, 0); | |
f6bcfd97 BP |
458 | } |
459 | ||
4370573a RD |
460 | // Set a mask that determines which markers are displayed in a margin. |
461 | void wxStyledTextCtrl::SetMarginMask(int margin, int mask) { | |
462 | SendMsg(2244, margin, mask); | |
f6bcfd97 BP |
463 | } |
464 | ||
4370573a RD |
465 | // Retrieve the marker mask of a margin. |
466 | int wxStyledTextCtrl::GetMarginMask(int margin) { | |
467 | return SendMsg(2245, margin, 0); | |
9ce192d4 RD |
468 | } |
469 | ||
4370573a RD |
470 | // Make a margin sensitive or insensitive to mouse clicks. |
471 | void wxStyledTextCtrl::SetMarginSensitive(int margin, bool sensitive) { | |
472 | SendMsg(2246, margin, sensitive); | |
9ce192d4 RD |
473 | } |
474 | ||
4370573a RD |
475 | // Retrieve the mouse click sensitivity of a margin. |
476 | bool wxStyledTextCtrl::GetMarginSensitive(int margin) { | |
477 | return SendMsg(2247, margin, 0) != 0; | |
9ce192d4 RD |
478 | } |
479 | ||
4370573a | 480 | // Clear all the styles and make equivalent to the global default style. |
9ce192d4 | 481 | void wxStyledTextCtrl::StyleClearAll() { |
4370573a | 482 | SendMsg(2050, 0, 0); |
9ce192d4 RD |
483 | } |
484 | ||
4370573a RD |
485 | // Set the foreground colour of a style. |
486 | void wxStyledTextCtrl::StyleSetForeground(int style, const wxColour& fore) { | |
487 | SendMsg(2051, style, wxColourAsLong(fore)); | |
9ce192d4 RD |
488 | } |
489 | ||
4370573a RD |
490 | // Set the background colour of a style. |
491 | void wxStyledTextCtrl::StyleSetBackground(int style, const wxColour& back) { | |
492 | SendMsg(2052, style, wxColourAsLong(back)); | |
9ce192d4 RD |
493 | } |
494 | ||
4370573a RD |
495 | // Set a style to be bold or not. |
496 | void wxStyledTextCtrl::StyleSetBold(int style, bool bold) { | |
497 | SendMsg(2053, style, bold); | |
9ce192d4 RD |
498 | } |
499 | ||
4370573a RD |
500 | // Set a style to be italic or not. |
501 | void wxStyledTextCtrl::StyleSetItalic(int style, bool italic) { | |
502 | SendMsg(2054, style, italic); | |
9ce192d4 RD |
503 | } |
504 | ||
4370573a RD |
505 | // Set the size of characters of a style. |
506 | void wxStyledTextCtrl::StyleSetSize(int style, int sizePoints) { | |
507 | SendMsg(2055, style, sizePoints); | |
9ce192d4 RD |
508 | } |
509 | ||
4370573a RD |
510 | // Set the font of a style. |
511 | void wxStyledTextCtrl::StyleSetFaceName(int style, const wxString& fontName) { | |
512 | SendMsg(2056, style, (long)fontName.c_str()); | |
9ce192d4 RD |
513 | } |
514 | ||
4370573a RD |
515 | // Set a style to have its end of line filled or not. |
516 | void wxStyledTextCtrl::StyleSetEOLFilled(int style, bool filled) { | |
517 | SendMsg(2057, style, filled); | |
9ce192d4 RD |
518 | } |
519 | ||
4370573a RD |
520 | // Reset the default style to its state at startup |
521 | void wxStyledTextCtrl::StyleResetDefault() { | |
522 | SendMsg(2058, 0, 0); | |
9ce192d4 RD |
523 | } |
524 | ||
4370573a RD |
525 | // Set a style to be underlined or not. |
526 | void wxStyledTextCtrl::StyleSetUnderline(int style, bool underline) { | |
527 | SendMsg(2059, style, underline); | |
9ce192d4 RD |
528 | } |
529 | ||
4370573a RD |
530 | // Set the foreground colour of the selection and whether to use this setting. |
531 | void wxStyledTextCtrl::SetSelForeground(bool useSetting, const wxColour& fore) { | |
532 | SendMsg(2067, useSetting, wxColourAsLong(fore)); | |
9ce192d4 RD |
533 | } |
534 | ||
4370573a RD |
535 | // Set the background colour of the selection and whether to use this setting. |
536 | void wxStyledTextCtrl::SetSelBackground(bool useSetting, const wxColour& back) { | |
537 | SendMsg(2068, useSetting, wxColourAsLong(back)); | |
9ce192d4 RD |
538 | } |
539 | ||
4370573a RD |
540 | // Set the foreground colour of the caret. |
541 | void wxStyledTextCtrl::SetCaretForeground(const wxColour& fore) { | |
542 | SendMsg(2069, wxColourAsLong(fore), 0); | |
9ce192d4 RD |
543 | } |
544 | ||
4370573a RD |
545 | // When key+modifier combination km is pressed perform msg. |
546 | void wxStyledTextCtrl::CmdKeyAssign(int key, int modifiers, int cmd) { | |
547 | SendMsg(2070, MAKELONG(key, modifiers), cmd); | |
9ce192d4 RD |
548 | } |
549 | ||
4370573a RD |
550 | // When key+modifier combination km do nothing. |
551 | void wxStyledTextCtrl::CmdKeyClear(int key, int modifiers) { | |
552 | SendMsg(2071, MAKELONG(key, modifiers)); | |
9ce192d4 RD |
553 | } |
554 | ||
4370573a RD |
555 | // Drop all key mappings. |
556 | void wxStyledTextCtrl::CmdKeyClearAll() { | |
557 | SendMsg(2072, 0, 0); | |
558 | } | |
9ce192d4 | 559 | |
4370573a RD |
560 | // Set the styles for a segment of the document. |
561 | void wxStyledTextCtrl::SetStyleBytes(int length, char* styleBytes) { | |
562 | SendMsg(2073, length, (long)styleBytes); | |
9ce192d4 RD |
563 | } |
564 | ||
4370573a RD |
565 | // Set a style to be visible or not. |
566 | void wxStyledTextCtrl::StyleSetVisible(int style, bool visible) { | |
567 | SendMsg(2074, style, visible); | |
568 | } | |
9ce192d4 | 569 | |
4370573a | 570 | // Get the time in milliseconds that the caret is on and off. |
9ce192d4 | 571 | int wxStyledTextCtrl::GetCaretPeriod() { |
4370573a | 572 | return SendMsg(2075, 0, 0); |
9ce192d4 RD |
573 | } |
574 | ||
4370573a RD |
575 | // Get the time in milliseconds that the caret is on and off. 0 = steady on. |
576 | void wxStyledTextCtrl::SetCaretPeriod(int periodMilliseconds) { | |
577 | SendMsg(2076, periodMilliseconds, 0); | |
578 | } | |
9ce192d4 | 579 | |
4370573a RD |
580 | // Set the set of characters making up words for when moving or selecting |
581 | // by word. | |
582 | void wxStyledTextCtrl::SetWordChars(const wxString& characters) { | |
583 | SendMsg(2077, 0, (long)characters.c_str()); | |
9ce192d4 RD |
584 | } |
585 | ||
4370573a RD |
586 | // Start a sequence of actions that is undone and redone as a unit. |
587 | // May be nested. | |
588 | void wxStyledTextCtrl::BeginUndoAction() { | |
589 | SendMsg(2078, 0, 0); | |
590 | } | |
9ce192d4 | 591 | |
4370573a RD |
592 | // End a sequence of actions that is undone and redone as a unit. |
593 | void wxStyledTextCtrl::EndUndoAction() { | |
594 | SendMsg(2079, 0, 0); | |
595 | } | |
9ce192d4 | 596 | |
4370573a RD |
597 | // Set an indicator to plain, squiggle or TT. |
598 | void wxStyledTextCtrl::IndicatorSetStyle(int indic, int style) { | |
599 | SendMsg(2080, indic, style); | |
600 | } | |
9ce192d4 | 601 | |
4370573a RD |
602 | // Retrieve the style of an indicator. |
603 | int wxStyledTextCtrl::IndicatorGetStyle(int indic) { | |
604 | return SendMsg(2081, indic, 0); | |
605 | } | |
9ce192d4 | 606 | |
4370573a RD |
607 | // Set the foreground colour of an indicator. |
608 | void wxStyledTextCtrl::IndicatorSetForeground(int indic, const wxColour& fore) { | |
609 | SendMsg(2082, indic, wxColourAsLong(fore)); | |
9ce192d4 RD |
610 | } |
611 | ||
4370573a RD |
612 | // Retrieve the foreground colour of an indicator. |
613 | wxColour wxStyledTextCtrl::IndicatorGetForeground(int indic) { | |
614 | long c = SendMsg(2083, indic, 0); | |
615 | return wxColourFromLong(c); | |
616 | } | |
9ce192d4 | 617 | |
4370573a RD |
618 | // Divide each styling byte into lexical class bits (default:5) and indicator |
619 | // bits (default:3). If a lexer requires more than 32 lexical states, then this | |
620 | // is used to expand the possible states. | |
621 | void wxStyledTextCtrl::SetStyleBits(int bits) { | |
622 | SendMsg(2090, bits, 0); | |
9ce192d4 RD |
623 | } |
624 | ||
4370573a RD |
625 | // Retrieve number of bits in style bytes used to hold the lexical state. |
626 | int wxStyledTextCtrl::GetStyleBits() { | |
627 | return SendMsg(2091, 0, 0); | |
628 | } | |
9ce192d4 | 629 | |
4370573a RD |
630 | // Used to hold extra styling information for each line. |
631 | void wxStyledTextCtrl::SetLineState(int line, int state) { | |
632 | SendMsg(2092, line, state); | |
f6bcfd97 BP |
633 | } |
634 | ||
4370573a RD |
635 | // Retrieve the extra styling information for a line. |
636 | int wxStyledTextCtrl::GetLineState(int line) { | |
637 | return SendMsg(2093, line, 0); | |
638 | } | |
f6bcfd97 | 639 | |
4370573a RD |
640 | // Retrieve the last line number that has line state. |
641 | int wxStyledTextCtrl::GetMaxLineState() { | |
642 | return SendMsg(2094, 0, 0); | |
f6bcfd97 BP |
643 | } |
644 | ||
4370573a RD |
645 | // Display a auto-completion list. |
646 | // The lenEntered parameter indicates how many characters before | |
647 | // the caret should be used to provide context. | |
648 | void wxStyledTextCtrl::AutoCompShow(int lenEntered, const wxString& itemList) { | |
649 | SendMsg(2100, lenEntered, (long)itemList.c_str()); | |
650 | } | |
f6bcfd97 | 651 | |
4370573a RD |
652 | // Remove the auto-completion list from the screen. |
653 | void wxStyledTextCtrl::AutoCompCancel() { | |
654 | SendMsg(2101, 0, 0); | |
f6bcfd97 BP |
655 | } |
656 | ||
4370573a RD |
657 | // Is there an auto-completion list visible? |
658 | bool wxStyledTextCtrl::AutoCompActive() { | |
659 | return SendMsg(2102, 0, 0) != 0; | |
660 | } | |
f6bcfd97 | 661 | |
4370573a RD |
662 | // Retrieve the position of the caret when the auto-completion list was |
663 | // displayed. | |
664 | int wxStyledTextCtrl::AutoCompPosStart() { | |
665 | return SendMsg(2103, 0, 0); | |
f6bcfd97 BP |
666 | } |
667 | ||
4370573a RD |
668 | // User has selected an item so remove the list and insert the selection. |
669 | void wxStyledTextCtrl::AutoCompComplete() { | |
670 | SendMsg(2104, 0, 0); | |
671 | } | |
f6bcfd97 | 672 | |
4370573a RD |
673 | // Define a set of character that when typed cancel the auto-completion list. |
674 | void wxStyledTextCtrl::AutoCompStops(const wxString& characterSet) { | |
675 | SendMsg(2105, 0, (long)characterSet.c_str()); | |
f6bcfd97 BP |
676 | } |
677 | ||
4370573a RD |
678 | // Change the separator character in the string setting up an auto-completion |
679 | // list. Default is space but can be changed if items contain space. | |
680 | void wxStyledTextCtrl::AutoCompSetSeparator(int separatorCharacter) { | |
681 | SendMsg(2106, separatorCharacter, 0); | |
682 | } | |
f6bcfd97 | 683 | |
4370573a RD |
684 | // Retrieve the auto-completion list separator character. |
685 | int wxStyledTextCtrl::AutoCompGetSeparator() { | |
686 | return SendMsg(2107, 0, 0); | |
9ce192d4 RD |
687 | } |
688 | ||
4370573a RD |
689 | // Select the item in the auto-completion list that starts with a string. |
690 | void wxStyledTextCtrl::AutoCompSelect(const wxString& text) { | |
691 | SendMsg(2108, 0, (long)text.c_str()); | |
692 | } | |
9ce192d4 | 693 | |
4370573a RD |
694 | // Should the auto-completion list be cancelled if the user backspaces to a |
695 | // position before where the box was created. | |
696 | void wxStyledTextCtrl::AutoCompSetCancelAtStart(bool cancel) { | |
697 | SendMsg(2110, cancel, 0); | |
f6bcfd97 BP |
698 | } |
699 | ||
4370573a RD |
700 | // Retrieve whether auto-completion cancelled by backspacing before start. |
701 | bool wxStyledTextCtrl::AutoCompGetCancelAtStart() { | |
702 | return SendMsg(2111, 0, 0) != 0; | |
703 | } | |
f6bcfd97 | 704 | |
4370573a RD |
705 | // Define a set of character that when typed fills up the selected word. |
706 | void wxStyledTextCtrl::AutoCompSetFillUps(const wxString& characterSet) { | |
707 | SendMsg(2112, 0, (long)characterSet.c_str()); | |
708 | } | |
9ce192d4 | 709 | |
4370573a RD |
710 | // Should a single item auto-completion list automatically choose the item. |
711 | void wxStyledTextCtrl::AutoCompSetChooseSingle(bool chooseSingle) { | |
712 | SendMsg(2113, chooseSingle, 0); | |
713 | } | |
9ce192d4 | 714 | |
4370573a RD |
715 | // Retrieve whether a single item auto-completion list automatically choose the item. |
716 | bool wxStyledTextCtrl::AutoCompGetChooseSingle() { | |
717 | return SendMsg(2114, 0, 0) != 0; | |
9ce192d4 RD |
718 | } |
719 | ||
4370573a RD |
720 | // Set whether case is significant when performing auto-completion searches. |
721 | void wxStyledTextCtrl::AutoCompSetIgnoreCase(bool ignoreCase) { | |
722 | SendMsg(2115, ignoreCase, 0); | |
723 | } | |
9ce192d4 | 724 | |
4370573a RD |
725 | // Retrieve state of ignore case flag. |
726 | bool wxStyledTextCtrl::AutoCompGetIgnoreCase() { | |
727 | return SendMsg(2116, 0, 0) != 0; | |
9ce192d4 RD |
728 | } |
729 | ||
4370573a RD |
730 | // Set the number of spaces used for one level of indentation. |
731 | void wxStyledTextCtrl::SetIndent(int indentSize) { | |
732 | SendMsg(2122, indentSize, 0); | |
733 | } | |
9ce192d4 | 734 | |
4370573a RD |
735 | // Retrieve indentation size. |
736 | int wxStyledTextCtrl::GetIndent() { | |
737 | return SendMsg(2123, 0, 0); | |
9ce192d4 RD |
738 | } |
739 | ||
4370573a RD |
740 | // Indentation will only use space characters if useTabs is false, otherwise |
741 | // it will use a combination of tabs and spaces. | |
742 | void wxStyledTextCtrl::SetUseTabs(bool useTabs) { | |
743 | SendMsg(2124, useTabs, 0); | |
744 | } | |
9ce192d4 | 745 | |
4370573a RD |
746 | // Retrieve whether tabs will be used in indentation. |
747 | bool wxStyledTextCtrl::GetUseTabs() { | |
748 | return SendMsg(2125, 0, 0) != 0; | |
749 | } | |
9ce192d4 | 750 | |
4370573a RD |
751 | // Change the indentation of a line to a number of columns. |
752 | void wxStyledTextCtrl::SetLineIndentation(int line, int indentSize) { | |
753 | SendMsg(2126, line, indentSize); | |
754 | } | |
9ce192d4 | 755 | |
4370573a RD |
756 | // Retrieve the number of columns that a line is indented. |
757 | int wxStyledTextCtrl::GetLineIndentation(int line) { | |
758 | return SendMsg(2127, line, 0); | |
9ce192d4 RD |
759 | } |
760 | ||
4370573a RD |
761 | // Retrieve the position before the first non indentation character on a line. |
762 | int wxStyledTextCtrl::GetLineIndentPosition(int line) { | |
763 | return SendMsg(2128, line, 0); | |
764 | } | |
9ce192d4 | 765 | |
4370573a RD |
766 | // Retrieve the column number of a position, taking tab width into account. |
767 | int wxStyledTextCtrl::GetColumn(int pos) { | |
768 | return SendMsg(2129, pos, 0); | |
9ce192d4 RD |
769 | } |
770 | ||
4370573a RD |
771 | // Show or hide the horizontal scroll bar. |
772 | void wxStyledTextCtrl::SetUseHorizontalScrollBar(bool show) { | |
773 | SendMsg(2130, show, 0); | |
774 | } | |
9ce192d4 | 775 | |
4370573a RD |
776 | // Is the horizontal scroll bar visible? |
777 | bool wxStyledTextCtrl::GetUseHorizontalScrollBar() { | |
778 | return SendMsg(2131, 0, 0) != 0; | |
9ce192d4 RD |
779 | } |
780 | ||
4370573a RD |
781 | // Show or hide indentation guides. |
782 | void wxStyledTextCtrl::SetIndentationGuides(bool show) { | |
783 | SendMsg(2132, show, 0); | |
784 | } | |
9ce192d4 | 785 | |
4370573a RD |
786 | // Are the indentation guides visible? |
787 | bool wxStyledTextCtrl::GetIndentationGuides() { | |
788 | return SendMsg(2133, 0, 0) != 0; | |
9ce192d4 RD |
789 | } |
790 | ||
4370573a RD |
791 | // Set the highlighted indentation guide column. |
792 | // 0 = no highlighted guide. | |
793 | void wxStyledTextCtrl::SetHighlightGuide(int column) { | |
794 | SendMsg(2134, column, 0); | |
795 | } | |
9ce192d4 | 796 | |
4370573a RD |
797 | // Get the highlighted indentation guide column. |
798 | int wxStyledTextCtrl::GetHighlightGuide() { | |
799 | return SendMsg(2135, 0, 0); | |
9ce192d4 RD |
800 | } |
801 | ||
4370573a RD |
802 | // Get the position after the last visible characters on a line. |
803 | int wxStyledTextCtrl::GetLineEndPosition(int line) { | |
804 | return SendMsg(2136, line, 0); | |
805 | } | |
9ce192d4 | 806 | |
4370573a RD |
807 | // Get the code page used to interpret the bytes of the document as characters. |
808 | int wxStyledTextCtrl::GetCodePage() { | |
809 | return SendMsg(2137, 0, 0); | |
9ce192d4 RD |
810 | } |
811 | ||
4370573a RD |
812 | // Get the foreground colour of the caret. |
813 | wxColour wxStyledTextCtrl::GetCaretForeground() { | |
814 | long c = SendMsg(2138, 0, 0); | |
815 | return wxColourFromLong(c); | |
816 | } | |
9ce192d4 | 817 | |
4370573a RD |
818 | // In read-only mode? |
819 | bool wxStyledTextCtrl::GetReadOnly() { | |
820 | return SendMsg(2140, 0, 0) != 0; | |
9ce192d4 RD |
821 | } |
822 | ||
4370573a RD |
823 | // Sets the position of the caret. |
824 | void wxStyledTextCtrl::SetCurrentPos(int pos) { | |
825 | SendMsg(2141, pos, 0); | |
826 | } | |
9ce192d4 | 827 | |
4370573a RD |
828 | // Sets the position that starts the selection - this becomes the anchor. |
829 | void wxStyledTextCtrl::SetSelectionStart(int pos) { | |
830 | SendMsg(2142, pos, 0); | |
9ce192d4 RD |
831 | } |
832 | ||
4370573a RD |
833 | // Returns the position at the start of the selection. |
834 | int wxStyledTextCtrl::GetSelectionStart() { | |
835 | return SendMsg(2143, 0, 0); | |
836 | } | |
9ce192d4 | 837 | |
4370573a RD |
838 | // Sets the position that ends the selection - this becomes the currentPosition. |
839 | void wxStyledTextCtrl::SetSelectionEnd(int pos) { | |
840 | SendMsg(2144, pos, 0); | |
9ce192d4 RD |
841 | } |
842 | ||
4370573a RD |
843 | // Returns the position at the end of the selection. |
844 | int wxStyledTextCtrl::GetSelectionEnd() { | |
845 | return SendMsg(2145, 0, 0); | |
846 | } | |
9ce192d4 | 847 | |
4370573a RD |
848 | // Sets the print magnification added to the point size of each style for printing. |
849 | void wxStyledTextCtrl::SetPrintMagnification(int magnification) { | |
850 | SendMsg(2146, magnification, 0); | |
9ce192d4 RD |
851 | } |
852 | ||
4370573a RD |
853 | // Returns the print magnification. |
854 | int wxStyledTextCtrl::GetPrintMagnification() { | |
855 | return SendMsg(2147, 0, 0); | |
856 | } | |
9ce192d4 | 857 | |
4370573a RD |
858 | // Modify colours when printing for clearer printed text. |
859 | void wxStyledTextCtrl::SetPrintColourMode(int mode) { | |
860 | SendMsg(2148, mode, 0); | |
9ce192d4 RD |
861 | } |
862 | ||
4370573a RD |
863 | // Returns the print colour mode. |
864 | int wxStyledTextCtrl::GetPrintColourMode() { | |
865 | return SendMsg(2149, 0, 0); | |
866 | } | |
9ce192d4 | 867 | |
4370573a RD |
868 | // Find some text in the document. |
869 | int wxStyledTextCtrl::FindText(int minPos, int maxPos, | |
870 | const wxString& text, | |
871 | bool caseSensitive, bool wholeWord) { | |
872 | TextToFind ft; | |
873 | int flags = 0; | |
874 | ||
875 | flags |= caseSensitive ? SCFIND_MATCHCASE : 0; | |
876 | flags |= wholeWord ? SCFIND_WHOLEWORD : 0; | |
877 | ft.chrg.cpMin = minPos; | |
878 | ft.chrg.cpMax = maxPos; | |
879 | ft.lpstrText = (char*)text.c_str(); | |
880 | ||
881 | return SendMsg(2150, flags, (long)&ft); | |
882 | } | |
883 | ||
884 | // On Windows will draw the document into a display context such as a printer. | |
885 | int wxStyledTextCtrl::FormatRange(bool doDraw, | |
886 | int startPos, | |
887 | int endPos, | |
888 | wxDC* draw, | |
889 | wxDC* target, // Why does it use two? Can they be the same? | |
890 | wxRect renderRect, | |
891 | wxRect pageRect) { | |
892 | RangeToFormat fr; | |
893 | ||
894 | fr.hdc = draw; | |
895 | fr.hdcTarget = target; | |
896 | fr.rc.top = renderRect.GetTop(); | |
897 | fr.rc.left = renderRect.GetLeft(); | |
898 | fr.rc.right = renderRect.GetRight(); | |
899 | fr.rc.bottom = renderRect.GetBottom(); | |
900 | fr.rcPage.top = pageRect.GetTop(); | |
901 | fr.rcPage.left = pageRect.GetLeft(); | |
902 | fr.rcPage.right = pageRect.GetRight(); | |
903 | fr.rcPage.bottom = pageRect.GetBottom(); | |
904 | fr.chrg.cpMin = startPos; | |
905 | fr.chrg.cpMax = endPos; | |
906 | ||
907 | return SendMsg(2151, doDraw, (long)&fr); | |
908 | } | |
909 | ||
910 | // Retrieve the line at the top of the display. | |
911 | int wxStyledTextCtrl::GetFirstVisibleLine() { | |
912 | return SendMsg(2152, 0, 0); | |
9ce192d4 RD |
913 | } |
914 | ||
4370573a RD |
915 | // Retrieve the contents of a line. |
916 | wxString wxStyledTextCtrl::GetLine(int line) { | |
917 | wxString text; | |
918 | int len = LineLength(line); | |
919 | char* buf = text.GetWriteBuf(len+1); | |
9ce192d4 | 920 | |
4370573a RD |
921 | int pos = SendMsg(2153, line, (long)buf); |
922 | text.UngetWriteBuf(); | |
9ce192d4 | 923 | |
4370573a RD |
924 | return text; |
925 | } | |
926 | ||
927 | // Returns the number of lines in the document. There is always at least one. | |
928 | int wxStyledTextCtrl::GetLineCount() { | |
929 | return SendMsg(2154, 0, 0); | |
930 | } | |
9ce192d4 | 931 | |
4370573a RD |
932 | // Sets the size in pixels of the left margin. |
933 | void wxStyledTextCtrl::SetMarginLeft(int width) { | |
934 | SendMsg(2155, 0, width); | |
935 | } | |
9ce192d4 | 936 | |
4370573a RD |
937 | // Returns the size in pixels of the left margin. |
938 | int wxStyledTextCtrl::GetMarginLeft() { | |
939 | return SendMsg(2156, 0, 0); | |
9ce192d4 RD |
940 | } |
941 | ||
4370573a RD |
942 | // Sets the size in pixels of the right margin. |
943 | void wxStyledTextCtrl::SetMarginRight(int width) { | |
944 | SendMsg(2157, 0, width); | |
945 | } | |
9ce192d4 | 946 | |
4370573a RD |
947 | // Returns the size in pixels of the right margin. |
948 | int wxStyledTextCtrl::GetMarginRight() { | |
949 | return SendMsg(2158, 0, 0); | |
9ce192d4 RD |
950 | } |
951 | ||
4370573a RD |
952 | // Is the document different from when it was last saved? |
953 | bool wxStyledTextCtrl::GetModify() { | |
954 | return SendMsg(2159, 0, 0) != 0; | |
955 | } | |
9ce192d4 | 956 | |
4370573a RD |
957 | // Select a range of text. |
958 | void wxStyledTextCtrl::SetSelection(int start, int end) { | |
959 | SendMsg(2160, start, end); | |
9ce192d4 RD |
960 | } |
961 | ||
4370573a RD |
962 | // Retrieve the selected text. |
963 | wxString wxStyledTextCtrl::GetSelectedText() { | |
964 | wxString text; | |
965 | int start; | |
966 | int end; | |
9ce192d4 | 967 | |
4370573a RD |
968 | GetSelection(&start, &end); |
969 | int len = end - start; | |
970 | char* buff = text.GetWriteBuf(len+1); | |
9ce192d4 | 971 | |
4370573a RD |
972 | SendMsg(2161, 0, (long)buff); |
973 | text.UngetWriteBuf(); | |
974 | return text; | |
975 | } | |
9ce192d4 | 976 | |
4370573a RD |
977 | // Retrieve a range of text. |
978 | wxString wxStyledTextCtrl::GetTextRange(int startPos, int endPos) { | |
979 | wxString text; | |
980 | int len = endPos - startPos; | |
981 | char* buff = text.GetWriteBuf(len+1); | |
982 | TextRange tr; | |
983 | tr.lpstrText = buff; | |
984 | tr.chrg.cpMin = startPos; | |
985 | tr.chrg.cpMax = endPos; | |
9ce192d4 | 986 | |
4370573a RD |
987 | SendMsg(2162, 0, (long)&tr); |
988 | text.UngetWriteBuf(); | |
989 | return text; | |
9ce192d4 RD |
990 | } |
991 | ||
4370573a RD |
992 | // Draw the selection in normal style or with selection highlighted. |
993 | void wxStyledTextCtrl::HideSelection(bool normal) { | |
994 | SendMsg(2163, normal, 0); | |
995 | } | |
9ce192d4 | 996 | |
4370573a RD |
997 | // Retrieve the line containing a position. |
998 | int wxStyledTextCtrl::LineFromPosition(int pos) { | |
999 | return SendMsg(2166, pos, 0); | |
9ce192d4 RD |
1000 | } |
1001 | ||
4370573a RD |
1002 | // Retrieve the position at the start of a line. |
1003 | int wxStyledTextCtrl::PositionFromLine(int line) { | |
1004 | return SendMsg(2167, line, 0); | |
1005 | } | |
9ce192d4 | 1006 | |
4370573a RD |
1007 | // Scroll horizontally and vertically. |
1008 | void wxStyledTextCtrl::LineScroll(int columns, int lines) { | |
1009 | SendMsg(2168, columns, lines); | |
9ce192d4 RD |
1010 | } |
1011 | ||
4370573a RD |
1012 | // Ensure the caret is visible. |
1013 | void wxStyledTextCtrl::EnsureCaretVisible() { | |
1014 | SendMsg(2169, 0, 0); | |
1015 | } | |
9ce192d4 | 1016 | |
4370573a RD |
1017 | // Replace the selected text with the argument text. |
1018 | void wxStyledTextCtrl::ReplaceSelection(const wxString& text) { | |
1019 | SendMsg(2170, 0, (long)text.c_str()); | |
9ce192d4 RD |
1020 | } |
1021 | ||
4370573a RD |
1022 | // Set to read only or read write. |
1023 | void wxStyledTextCtrl::SetReadOnly(bool readOnly) { | |
1024 | SendMsg(2171, readOnly, 0); | |
1025 | } | |
9ce192d4 | 1026 | |
4370573a RD |
1027 | // Will a paste succeed? |
1028 | bool wxStyledTextCtrl::CanPaste() { | |
1029 | return SendMsg(2173, 0, 0) != 0; | |
9ce192d4 RD |
1030 | } |
1031 | ||
4370573a RD |
1032 | // Are there any undoable actions in the undo history. |
1033 | bool wxStyledTextCtrl::CanUndo() { | |
1034 | return SendMsg(2174, 0, 0) != 0; | |
1035 | } | |
9ce192d4 | 1036 | |
4370573a RD |
1037 | // Delete the undo history. |
1038 | void wxStyledTextCtrl::EmptyUndoBuffer() { | |
1039 | SendMsg(2175, 0, 0); | |
9ce192d4 RD |
1040 | } |
1041 | ||
4370573a RD |
1042 | // Undo one action in the undo history. |
1043 | void wxStyledTextCtrl::Undo() { | |
1044 | SendMsg(2176, 0, 0); | |
1045 | } | |
9ce192d4 | 1046 | |
4370573a RD |
1047 | // Cut the selection to the clipboard. |
1048 | void wxStyledTextCtrl::Cut() { | |
1049 | SendMsg(2177, 0, 0); | |
f6bcfd97 BP |
1050 | } |
1051 | ||
4370573a RD |
1052 | // Copy the selection to the clipboard. |
1053 | void wxStyledTextCtrl::Copy() { | |
1054 | SendMsg(2178, 0, 0); | |
1055 | } | |
f6bcfd97 | 1056 | |
4370573a RD |
1057 | // Paste the contents of the clipboard into the document replacing the selection. |
1058 | void wxStyledTextCtrl::Paste() { | |
1059 | SendMsg(2179, 0, 0); | |
f6bcfd97 BP |
1060 | } |
1061 | ||
4370573a RD |
1062 | // Clear the selection. |
1063 | void wxStyledTextCtrl::Clear() { | |
1064 | SendMsg(2180, 0, 0); | |
1065 | } | |
f6bcfd97 | 1066 | |
4370573a RD |
1067 | // Replace the contents of the document with the argument text. |
1068 | void wxStyledTextCtrl::SetText(const wxString& text) { | |
1069 | SendMsg(2181, 0, (long)text.c_str()); | |
f6bcfd97 BP |
1070 | } |
1071 | ||
4370573a RD |
1072 | // Retrieve all the text in the document. |
1073 | wxString wxStyledTextCtrl::GetText() { | |
1074 | wxString text; | |
1075 | int len = GetTextLength(); | |
1076 | char* buff = text.GetWriteBuf(len+1); | |
f6bcfd97 | 1077 | |
4370573a RD |
1078 | SendMsg(2182, len, (long)buff); |
1079 | buff[len] = 0; | |
1080 | text.UngetWriteBuf(); | |
1081 | return text; | |
1082 | } | |
9ce192d4 | 1083 | |
4370573a RD |
1084 | // Retrieve the number of characters in the document. |
1085 | int wxStyledTextCtrl::GetTextLength() { | |
1086 | return SendMsg(2183, 0, 0); | |
9ce192d4 RD |
1087 | } |
1088 | ||
4370573a RD |
1089 | // Set to overtype (true) or insert mode |
1090 | void wxStyledTextCtrl::SetOvertype(bool overtype) { | |
1091 | SendMsg(2186, overtype, 0); | |
1092 | } | |
9ce192d4 | 1093 | |
4370573a RD |
1094 | // Returns true if overtype mode is active otherwise false is returned. |
1095 | bool wxStyledTextCtrl::GetOvertype() { | |
1096 | return SendMsg(2187, 0, 0) != 0; | |
9ce192d4 RD |
1097 | } |
1098 | ||
4370573a RD |
1099 | // Show a call tip containing a definition near position pos. |
1100 | void wxStyledTextCtrl::CallTipShow(int pos, const wxString& definition) { | |
1101 | SendMsg(2200, pos, (long)definition.c_str()); | |
1102 | } | |
9ce192d4 | 1103 | |
4370573a RD |
1104 | // Remove the call tip from the screen. |
1105 | void wxStyledTextCtrl::CallTipCancel() { | |
1106 | SendMsg(2201, 0, 0); | |
9ce192d4 RD |
1107 | } |
1108 | ||
4370573a RD |
1109 | // Is there an active call tip? |
1110 | bool wxStyledTextCtrl::CallTipActive() { | |
1111 | return SendMsg(2202, 0, 0) != 0; | |
1112 | } | |
9ce192d4 | 1113 | |
4370573a | 1114 | // Retrieve the position where the caret was before displaying the call tip. |
9ce192d4 | 1115 | int wxStyledTextCtrl::CallTipPosAtStart() { |
4370573a | 1116 | return SendMsg(2203, 0, 0); |
9ce192d4 RD |
1117 | } |
1118 | ||
4370573a | 1119 | // Highlight a segment of the definition. |
9ce192d4 | 1120 | void wxStyledTextCtrl::CallTipSetHighlight(int start, int end) { |
4370573a | 1121 | SendMsg(2204, start, end); |
9ce192d4 RD |
1122 | } |
1123 | ||
4370573a RD |
1124 | // Set the background colour for the call tip. |
1125 | void wxStyledTextCtrl::CallTipSetBackground(const wxColour& back) { | |
1126 | SendMsg(2205, wxColourAsLong(back), 0); | |
1127 | } | |
9ce192d4 | 1128 | |
4370573a RD |
1129 | // Find the display line of a document line taking hidden lines into account. |
1130 | int wxStyledTextCtrl::VisibleFromDocLine(int line) { | |
1131 | return SendMsg(2220, line, 0); | |
9ce192d4 RD |
1132 | } |
1133 | ||
4370573a RD |
1134 | // Find the document line of a display line taking hidden lines into account. |
1135 | int wxStyledTextCtrl::DocLineFromVisible(int lineDisplay) { | |
1136 | return SendMsg(2221, lineDisplay, 0); | |
1137 | } | |
9ce192d4 | 1138 | |
4370573a RD |
1139 | // Set the fold level of a line. |
1140 | // This encodes an integer level along with flags indicating whether the | |
1141 | // line is a header and whether it is effectively white space. | |
1142 | void wxStyledTextCtrl::SetFoldLevel(int line, int level) { | |
1143 | SendMsg(2222, line, level); | |
1144 | } | |
9ce192d4 | 1145 | |
4370573a RD |
1146 | // Retrieve the fold level of a line. |
1147 | int wxStyledTextCtrl::GetFoldLevel(int line) { | |
1148 | return SendMsg(2223, line, 0); | |
1149 | } | |
d134f170 | 1150 | |
4370573a RD |
1151 | // Find the last child line of a header line. |
1152 | int wxStyledTextCtrl::GetLastChild(int line, int level) { | |
1153 | return SendMsg(2224, line, level); | |
9ce192d4 RD |
1154 | } |
1155 | ||
4370573a RD |
1156 | // Find the parent line of a child line. |
1157 | int wxStyledTextCtrl::GetFoldParent(int line) { | |
1158 | return SendMsg(2225, line, 0); | |
1159 | } | |
9ce192d4 | 1160 | |
4370573a RD |
1161 | // Make a range of lines visible. |
1162 | void wxStyledTextCtrl::ShowLines(int lineStart, int lineEnd) { | |
1163 | SendMsg(2226, lineStart, lineEnd); | |
9ce192d4 RD |
1164 | } |
1165 | ||
4370573a RD |
1166 | // Make a range of lines invisible. |
1167 | void wxStyledTextCtrl::HideLines(int lineStart, int lineEnd) { | |
1168 | SendMsg(2227, lineStart, lineEnd); | |
1169 | } | |
9ce192d4 | 1170 | |
4370573a RD |
1171 | // Is a line visible? |
1172 | bool wxStyledTextCtrl::GetLineVisible(int line) { | |
1173 | return SendMsg(2228, line, 0) != 0; | |
9ce192d4 RD |
1174 | } |
1175 | ||
4370573a RD |
1176 | // Show the children of a header line. |
1177 | void wxStyledTextCtrl::SetFoldExpanded(int line, bool expanded) { | |
1178 | SendMsg(2229, line, expanded); | |
1179 | } | |
9ce192d4 | 1180 | |
4370573a RD |
1181 | // Is a header line expanded? |
1182 | bool wxStyledTextCtrl::GetFoldExpanded(int line) { | |
1183 | return SendMsg(2230, line, 0) != 0; | |
9ce192d4 RD |
1184 | } |
1185 | ||
4370573a RD |
1186 | // Switch a header line between expanded and contracted. |
1187 | void wxStyledTextCtrl::ToggleFold(int line) { | |
1188 | SendMsg(2231, line, 0); | |
1189 | } | |
9ce192d4 | 1190 | |
4370573a RD |
1191 | // Ensure a particular line is visible by expanding any header line hiding it. |
1192 | void wxStyledTextCtrl::EnsureVisible(int line) { | |
1193 | SendMsg(2232, line, 0); | |
1194 | } | |
9ce192d4 | 1195 | |
4370573a RD |
1196 | // Set some debugging options for folding |
1197 | void wxStyledTextCtrl::SetFoldFlags(int flags) { | |
1198 | SendMsg(2233, flags, 0); | |
9ce192d4 RD |
1199 | } |
1200 | ||
4370573a RD |
1201 | // How many characters are on a line, not including end of line characters. |
1202 | int wxStyledTextCtrl::LineLength(int line) { | |
1203 | return SendMsg(2350, line, 0); | |
1204 | } | |
9ce192d4 | 1205 | |
4370573a RD |
1206 | // Highlight the characters at two positions. |
1207 | void wxStyledTextCtrl::BraceHighlight(int pos1, int pos2) { | |
1208 | SendMsg(2351, pos1, pos2); | |
1209 | } | |
9ce192d4 | 1210 | |
4370573a RD |
1211 | // Highlight the character at a position indicating there is no matching brace. |
1212 | void wxStyledTextCtrl::BraceBadLight(int pos) { | |
1213 | SendMsg(2352, pos, 0); | |
9ce192d4 RD |
1214 | } |
1215 | ||
4370573a RD |
1216 | // Find the position of a matching brace or INVALID_POSITION if no match. |
1217 | int wxStyledTextCtrl::BraceMatch(int pos) { | |
1218 | return SendMsg(2353, pos, 0); | |
1219 | } | |
9ce192d4 | 1220 | |
4370573a RD |
1221 | // Are the end of line characters visible. |
1222 | bool wxStyledTextCtrl::GetViewEOL() { | |
1223 | return SendMsg(2355, 0, 0) != 0; | |
9ce192d4 RD |
1224 | } |
1225 | ||
4370573a RD |
1226 | // Make the end of line characters visible or invisible |
1227 | void wxStyledTextCtrl::SetViewEOL(bool visible) { | |
1228 | SendMsg(2356, visible, 0); | |
1229 | } | |
9ce192d4 | 1230 | |
4370573a RD |
1231 | // Retrieve a pointer to the document object. |
1232 | void* wxStyledTextCtrl::GetDocPointer() { | |
1233 | return (void*)SendMsg(2357); | |
1234 | } | |
67003d1a | 1235 | |
4370573a RD |
1236 | // Change the document object used. |
1237 | void wxStyledTextCtrl::SetDocPointer(void* docPointer) { | |
1238 | SendMsg(2358, (long)docPointer); | |
67003d1a RD |
1239 | } |
1240 | ||
4370573a RD |
1241 | // Set which document modification events are sent to the container. |
1242 | void wxStyledTextCtrl::SetModEventMask(int mask) { | |
1243 | SendMsg(2359, mask, 0); | |
1244 | } | |
67003d1a | 1245 | |
4370573a RD |
1246 | // Retrieve the column number which text should be kept within. |
1247 | int wxStyledTextCtrl::GetEdgeColumn() { | |
1248 | return SendMsg(2360, 0, 0); | |
67003d1a RD |
1249 | } |
1250 | ||
4370573a RD |
1251 | // Set the column number of the edge. |
1252 | // If text goes past the edge then it is highlighted. | |
1253 | void wxStyledTextCtrl::SetEdgeColumn(int column) { | |
1254 | SendMsg(2361, column, 0); | |
1255 | } | |
67003d1a | 1256 | |
4370573a RD |
1257 | // Retrieve the edge highlight mode. |
1258 | int wxStyledTextCtrl::GetEdgeMode() { | |
1259 | return SendMsg(2362, 0, 0); | |
67003d1a RD |
1260 | } |
1261 | ||
4370573a RD |
1262 | // The edge may be displayed by a line (EDGE_LINE) or by highlighting text that |
1263 | // goes beyond it (EDGE_BACKGROUND) or not displayed at all (EDGE_NONE). | |
1264 | void wxStyledTextCtrl::SetEdgeMode(int mode) { | |
1265 | SendMsg(2363, mode, 0); | |
1266 | } | |
67003d1a | 1267 | |
4370573a RD |
1268 | // Retrieve the colour used in edge indication. |
1269 | wxColour wxStyledTextCtrl::GetEdgeColour() { | |
1270 | long c = SendMsg(2364, 0, 0); | |
1271 | return wxColourFromLong(c); | |
67003d1a RD |
1272 | } |
1273 | ||
4370573a RD |
1274 | // Change the colour used in edge indication. |
1275 | void wxStyledTextCtrl::SetEdgeColour(const wxColour& edgeColour) { | |
1276 | SendMsg(2365, wxColourAsLong(edgeColour), 0); | |
1277 | } | |
67003d1a | 1278 | |
4370573a RD |
1279 | // Sets the current caret position to be the search anchor. |
1280 | void wxStyledTextCtrl::SearchAnchor() { | |
1281 | SendMsg(2366, 0, 0); | |
67003d1a RD |
1282 | } |
1283 | ||
4370573a RD |
1284 | // Find some text starting at the search anchor. |
1285 | int wxStyledTextCtrl::SearchNext(int flags, const wxString& text) { | |
1286 | return SendMsg(2367, flags, (long)text.c_str()); | |
1287 | } | |
67003d1a | 1288 | |
4370573a RD |
1289 | // Find some text starting at the search anchor and moving backwards. |
1290 | int wxStyledTextCtrl::SearchPrev(int flags, const wxString& text) { | |
1291 | return SendMsg(2368, flags, (long)text.c_str()); | |
67003d1a RD |
1292 | } |
1293 | ||
4370573a RD |
1294 | // Set the way the line the caret is on is kept visible. |
1295 | void wxStyledTextCtrl::SetCaretPolicy(int caretPolicy, int caretSlop) { | |
1296 | SendMsg(2369, caretPolicy, caretSlop); | |
1297 | } | |
67003d1a | 1298 | |
4370573a RD |
1299 | // Retrieves the number of lines completely visible. |
1300 | int wxStyledTextCtrl::LinesOnScreen() { | |
1301 | return SendMsg(2370, 0, 0); | |
67003d1a RD |
1302 | } |
1303 | ||
4370573a RD |
1304 | // Set whether a pop up menu is displayed automatically when the user presses |
1305 | // the wrong mouse button. | |
1306 | void wxStyledTextCtrl::UsePopUp(bool allowPopUp) { | |
1307 | SendMsg(2371, allowPopUp, 0); | |
1308 | } | |
67003d1a | 1309 | |
4370573a RD |
1310 | // Is the selection a rectangular. The alternative is the more common stream selection. |
1311 | bool wxStyledTextCtrl::SelectionIsRectangle() { | |
1312 | return SendMsg(2372, 0, 0) != 0; | |
67003d1a RD |
1313 | } |
1314 | ||
4370573a RD |
1315 | // Set the zoom level. This number of points is added to the size of all fonts. |
1316 | // It may be positive to magnify or negative to reduce. | |
1317 | void wxStyledTextCtrl::SetZoom(int zoom) { | |
1318 | SendMsg(2373, zoom, 0); | |
1319 | } | |
67003d1a | 1320 | |
4370573a RD |
1321 | // Retrieve the zoom level. |
1322 | int wxStyledTextCtrl::GetZoom() { | |
1323 | return SendMsg(2374, 0, 0); | |
67003d1a RD |
1324 | } |
1325 | ||
4370573a RD |
1326 | // Create a new document object. |
1327 | // Starts with reference count of 1 and not selected into editor. | |
1328 | void* wxStyledTextCtrl::CreateDocument() { | |
1329 | return (void*)SendMsg(2375); | |
1330 | } | |
67003d1a | 1331 | |
4370573a RD |
1332 | // Extend life of document. |
1333 | void wxStyledTextCtrl::AddRefDocument(void* docPointer) { | |
1334 | SendMsg(2376, (long)docPointer); | |
67003d1a RD |
1335 | } |
1336 | ||
4370573a RD |
1337 | // Release a reference to the document, deleting document if it fades to black. |
1338 | void wxStyledTextCtrl::ReleaseDocument(void* docPointer) { | |
1339 | SendMsg(2377, (long)docPointer); | |
1340 | } | |
67003d1a | 1341 | |
4370573a RD |
1342 | // Get which document modification events are sent to the container. |
1343 | int wxStyledTextCtrl::GetModEventMask() { | |
1344 | return SendMsg(2378, 0, 0); | |
67003d1a RD |
1345 | } |
1346 | ||
4370573a RD |
1347 | // Start notifying the container of all key presses and commands. |
1348 | void wxStyledTextCtrl::StartRecord() { | |
1349 | SendMsg(3001, 0, 0); | |
1350 | } | |
67003d1a | 1351 | |
4370573a RD |
1352 | // Stop notifying the container of all key presses and commands. |
1353 | void wxStyledTextCtrl::StopRecord() { | |
1354 | SendMsg(3002, 0, 0); | |
67003d1a RD |
1355 | } |
1356 | ||
4370573a RD |
1357 | // Set the lexing language of the document. |
1358 | void wxStyledTextCtrl::SetLexer(int lexer) { | |
1359 | SendMsg(4001, lexer, 0); | |
1360 | } | |
67003d1a | 1361 | |
4370573a RD |
1362 | // Retrieve the lexing language of the document. |
1363 | int wxStyledTextCtrl::GetLexer() { | |
1364 | return SendMsg(4002, 0, 0); | |
67003d1a RD |
1365 | } |
1366 | ||
4370573a RD |
1367 | // Colourise a segment of the document using the current lexing language. |
1368 | void wxStyledTextCtrl::Colourise(int start, int end) { | |
1369 | SendMsg(4003, start, end); | |
1370 | } | |
67003d1a | 1371 | |
4370573a RD |
1372 | // Set up a value that may be used by a lexer for some optional feature. |
1373 | void wxStyledTextCtrl::SetProperty(const wxString& key, const wxString& value) { | |
1374 | SendMsg(4004, (long)key.c_str(), (long)value.c_str()); | |
f6bcfd97 BP |
1375 | } |
1376 | ||
4370573a RD |
1377 | // Set up the key words used by the lexer. |
1378 | void wxStyledTextCtrl::SetKeyWords(int keywordSet, const wxString& keyWords) { | |
1379 | SendMsg(4005, keywordSet, (long)keyWords.c_str()); | |
1380 | } | |
f6bcfd97 | 1381 | |
4370573a | 1382 | // END of generated section |
f6bcfd97 | 1383 | //---------------------------------------------------------------------- |
f6bcfd97 BP |
1384 | |
1385 | ||
4370573a RD |
1386 | // Returns the line number of the line with the caret. |
1387 | int wxStyledTextCtrl::GetCurrentLine() { | |
1388 | int line = LineFromPosition(GetCurrentPos()); | |
1389 | return line; | |
f6bcfd97 BP |
1390 | } |
1391 | ||
1392 | ||
4370573a RD |
1393 | // Extract style settings from a spec-string which is composed of one or |
1394 | // more of the following comma separated elements: | |
1395 | // | |
1396 | // bold turns on bold | |
1397 | // italic turns on italics | |
1398 | // fore:#RRGGBB sets the foreground colour | |
1399 | // back:#RRGGBB sets the background colour | |
1400 | // face:[facename] sets the font face name to use | |
1401 | // size:[num] sets the font size in points | |
1402 | // eol turns on eol filling | |
1403 | // underline turns on underlining | |
1404 | // | |
1405 | void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { | |
1406 | ||
1407 | wxStringTokenizer tkz(spec, ","); | |
1408 | while (tkz.HasMoreTokens()) { | |
1409 | wxString token = tkz.GetNextToken(); | |
f6bcfd97 | 1410 | |
4370573a RD |
1411 | wxString option = token.BeforeFirst(':'); |
1412 | wxString val = token.AfterFirst(':'); | |
f6bcfd97 | 1413 | |
4370573a RD |
1414 | if (option == "bold") |
1415 | StyleSetBold(styleNum, true); | |
f6bcfd97 | 1416 | |
4370573a RD |
1417 | else if (option == "italic") |
1418 | StyleSetItalic(styleNum, true); | |
9ce192d4 | 1419 | |
4370573a RD |
1420 | else if (option == "underline") |
1421 | StyleSetUnderline(styleNum, true); | |
9ce192d4 | 1422 | |
4370573a RD |
1423 | else if (option == "eol") |
1424 | StyleSetEOLFilled(styleNum, true); | |
9ce192d4 | 1425 | |
4370573a RD |
1426 | else if (option == "size") { |
1427 | long points; | |
1428 | if (val.ToLong(&points)) | |
1429 | StyleSetSize(styleNum, points); | |
1430 | } | |
9ce192d4 | 1431 | |
4370573a RD |
1432 | else if (option == "face") |
1433 | StyleSetFaceName(styleNum, val); | |
9ce192d4 | 1434 | |
4370573a RD |
1435 | else if (option == "fore") |
1436 | StyleSetForeground(styleNum, wxColourFromSpec(val)); | |
9ce192d4 | 1437 | |
4370573a RD |
1438 | else if (option == "back") |
1439 | StyleSetBackground(styleNum, wxColourFromSpec(val)); | |
1440 | } | |
9ce192d4 RD |
1441 | } |
1442 | ||
1443 | ||
4370573a RD |
1444 | // Set style size, face, bold, italic, and underline attributes from |
1445 | // a wxFont's attributes. | |
1446 | void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) { | |
1447 | int size = font.GetPointSize(); | |
1448 | wxString faceName = font.GetFaceName(); | |
1449 | bool bold = font.GetWeight() == wxBOLD; | |
1450 | bool italic = font.GetStyle() != wxNORMAL; | |
1451 | bool under = font.GetUnderlined(); | |
9ce192d4 | 1452 | |
4370573a RD |
1453 | // TODO: add encoding/charset mapping |
1454 | StyleSetFontAttr(styleNum, size, faceName, bold, italic, under); | |
9ce192d4 RD |
1455 | } |
1456 | ||
4370573a RD |
1457 | // Set all font style attributes at once. |
1458 | void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, | |
1459 | const wxString& faceName, | |
1460 | bool bold, bool italic, | |
1461 | bool underline) { | |
1462 | StyleSetSize(styleNum, size); | |
1463 | StyleSetFaceName(styleNum, faceName); | |
1464 | StyleSetBold(styleNum, bold); | |
1465 | StyleSetItalic(styleNum, italic); | |
1466 | StyleSetUnderline(styleNum, underline); | |
9ce192d4 | 1467 | |
4370573a | 1468 | // TODO: add encoding/charset mapping |
9ce192d4 RD |
1469 | } |
1470 | ||
1471 | ||
4370573a RD |
1472 | // Perform one of the operations defined by the wxSTC_CMD_* constants. |
1473 | void wxStyledTextCtrl::CmdKeyExecute(int cmd) { | |
1474 | SendMsg(cmd); | |
9ce192d4 RD |
1475 | } |
1476 | ||
1477 | ||
4370573a RD |
1478 | // Set the left and right margin in the edit area, measured in pixels. |
1479 | void wxStyledTextCtrl::SetMargins(int left, int right) { | |
1480 | SetMarginLeft(left); | |
1481 | SetMarginRight(right); | |
9ce192d4 RD |
1482 | } |
1483 | ||
1484 | ||
4370573a RD |
1485 | // Retrieve the start and end positions of the current selection. |
1486 | void wxStyledTextCtrl::GetSelection(int* startPos, int* endPos) { | |
1487 | if (startPos != NULL) | |
1488 | *startPos = SendMsg(SCI_GETSELECTIONSTART); | |
1489 | if (endPos != NULL) | |
1490 | *endPos = SendMsg(SCI_GETSELECTIONEND); | |
9ce192d4 RD |
1491 | } |
1492 | ||
1493 | ||
4370573a RD |
1494 | // Retrieve the point in the window where a position is displayed. |
1495 | wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { | |
1496 | int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); | |
1497 | int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); | |
1498 | return wxPoint(x, y); | |
f6bcfd97 BP |
1499 | } |
1500 | ||
f97d84a6 RD |
1501 | // Scroll enough to make the given line visible |
1502 | void wxStyledTextCtrl::ScrollToLine(int line) { | |
1503 | m_swx->DoScrollToLine(line); | |
1504 | } | |
1505 | ||
1506 | ||
1507 | // Scroll enough to make the given column visible | |
1508 | void wxStyledTextCtrl::ScrollToColumn(int column) { | |
1509 | m_swx->DoScrollToColumn(column); | |
1510 | } | |
1511 | ||
f6bcfd97 | 1512 | |
d25f5fbb | 1513 | |
9ce192d4 RD |
1514 | //---------------------------------------------------------------------- |
1515 | // Event handlers | |
1516 | ||
1517 | void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) { | |
1518 | wxPaintDC dc(this); | |
1519 | wxRegion region = GetUpdateRegion(); | |
1520 | ||
1521 | m_swx->DoPaint(&dc, region.GetBox()); | |
1522 | } | |
1523 | ||
1524 | void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { | |
1525 | if (evt.GetOrientation() == wxHORIZONTAL) | |
1526 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
1527 | else | |
1528 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
1529 | } | |
1530 | ||
1531 | void wxStyledTextCtrl::OnSize(wxSizeEvent& evt) { | |
1532 | wxSize sz = GetClientSize(); | |
1533 | m_swx->DoSize(sz.x, sz.y); | |
1534 | } | |
1535 | ||
1536 | void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { | |
1537 | wxPoint pt = evt.GetPosition(); | |
1538 | m_swx->DoButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(), | |
1539 | evt.ShiftDown(), evt.ControlDown(), evt.AltDown()); | |
1540 | } | |
1541 | ||
1542 | void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) { | |
1543 | wxPoint pt = evt.GetPosition(); | |
1544 | m_swx->DoButtonMove(Point(pt.x, pt.y)); | |
1545 | } | |
1546 | ||
1547 | void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) { | |
1548 | wxPoint pt = evt.GetPosition(); | |
1549 | m_swx->DoButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(), | |
1550 | evt.ControlDown()); | |
1551 | } | |
1552 | ||
1553 | ||
1554 | void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { | |
1555 | wxPoint pt = evt.GetPosition(); | |
1556 | m_swx->DoContextMenu(Point(pt.x, pt.y)); | |
1557 | } | |
1558 | ||
1559 | void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { | |
9ce192d4 | 1560 | long key = evt.KeyCode(); |
d25f5fbb RD |
1561 | if ((key > WXK_ESCAPE) && |
1562 | (key != WXK_DELETE) && (key < 255) && | |
1563 | !evt.ControlDown() && !evt.AltDown()) { | |
1564 | ||
1565 | m_swx->DoAddChar(key); | |
1566 | } | |
1567 | else { | |
1568 | evt.Skip(); | |
9ce192d4 | 1569 | } |
f6bcfd97 BP |
1570 | } |
1571 | ||
1572 | void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { | |
1573 | long key = evt.KeyCode(); | |
1574 | key = toupper(key); | |
1575 | int processed = m_swx->DoKeyDown(key, evt.ShiftDown(), | |
1576 | evt.ControlDown(), evt.AltDown()); | |
9ce192d4 RD |
1577 | if (! processed) |
1578 | evt.Skip(); | |
1579 | } | |
1580 | ||
1581 | void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { | |
1582 | m_swx->DoLoseFocus(); | |
1583 | } | |
1584 | ||
1585 | void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { | |
1586 | m_swx->DoGainFocus(); | |
1587 | } | |
1588 | ||
1589 | void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& evt) { | |
1590 | m_swx->DoSysColourChange(); | |
1591 | } | |
1592 | ||
1593 | void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& evt) { | |
1594 | // do nothing to help avoid flashing | |
1595 | } | |
1596 | ||
1597 | ||
1598 | ||
1599 | void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) { | |
1600 | m_swx->DoCommand(evt.GetId()); | |
1601 | } | |
1602 | ||
1603 | ||
f6bcfd97 BP |
1604 | void wxStyledTextCtrl::OnListBox(wxCommandEvent& evt) { |
1605 | m_swx->DoOnListBox(); | |
1606 | } | |
1607 | ||
1608 | ||
9ce192d4 RD |
1609 | //---------------------------------------------------------------------- |
1610 | // Turn notifications from Scintilla into events | |
1611 | ||
f6bcfd97 | 1612 | |
9ce192d4 RD |
1613 | void wxStyledTextCtrl::NotifyChange() { |
1614 | wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); | |
1615 | GetEventHandler()->ProcessEvent(evt); | |
1616 | } | |
1617 | ||
1618 | void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { | |
1619 | SCNotification& scn = *_scn; | |
1620 | int eventType = 0; | |
1621 | switch (scn.nmhdr.code) { | |
1622 | case SCN_STYLENEEDED: | |
1623 | eventType = wxEVT_STC_STYLENEEDED; | |
1624 | break; | |
1625 | case SCN_CHARADDED: | |
1626 | eventType = wxEVT_STC_CHARADDED; | |
1627 | break; | |
1628 | case SCN_UPDATEUI: | |
1629 | eventType = wxEVT_STC_UPDATEUI; | |
1630 | break; | |
1631 | case SCN_SAVEPOINTREACHED: | |
1632 | eventType = wxEVT_STC_SAVEPOINTREACHED; | |
1633 | break; | |
1634 | case SCN_SAVEPOINTLEFT: | |
1635 | eventType = wxEVT_STC_SAVEPOINTLEFT; | |
1636 | break; | |
1637 | case SCN_MODIFYATTEMPTRO: | |
1638 | eventType = wxEVT_STC_ROMODIFYATTEMPT; | |
1639 | break; | |
1640 | case SCN_DOUBLECLICK: | |
1641 | eventType = wxEVT_STC_DOUBLECLICK; | |
1642 | break; | |
1643 | case SCN_MODIFIED: | |
1644 | eventType = wxEVT_STC_MODIFIED; | |
1645 | break; | |
1646 | case SCN_KEY: | |
1647 | eventType = wxEVT_STC_KEY; | |
1648 | break; | |
1649 | case SCN_MACRORECORD: | |
1650 | eventType = wxEVT_STC_MACRORECORD; | |
1651 | break; | |
1652 | case SCN_MARGINCLICK: | |
1653 | eventType = wxEVT_STC_MARGINCLICK; | |
1654 | break; | |
1655 | case SCN_NEEDSHOWN: | |
1656 | eventType = wxEVT_STC_NEEDSHOWN; | |
1657 | break; | |
4370573a RD |
1658 | case SCN_POSCHANGED: |
1659 | eventType = wxEVT_STC_POSCHANGED; | |
1660 | break; | |
9ce192d4 RD |
1661 | } |
1662 | if (eventType) { | |
1663 | wxStyledTextEvent evt(eventType, GetId()); | |
1664 | evt.SetPosition(scn.position); | |
1665 | evt.SetKey(scn.ch); | |
1666 | evt.SetModifiers(scn.modifiers); | |
1667 | if (eventType == wxEVT_STC_MODIFIED) { | |
1668 | evt.SetModificationType(scn.modificationType); | |
f6bcfd97 BP |
1669 | if (scn.text) |
1670 | evt.SetText(wxString(scn.text, scn.length)); | |
9ce192d4 RD |
1671 | evt.SetLength(scn.length); |
1672 | evt.SetLinesAdded(scn.linesAdded); | |
1673 | evt.SetLine(scn.line); | |
1674 | evt.SetFoldLevelNow(scn.foldLevelNow); | |
1675 | evt.SetFoldLevelPrev(scn.foldLevelPrev); | |
1676 | } | |
1677 | if (eventType == wxEVT_STC_MARGINCLICK) | |
1678 | evt.SetMargin(scn.margin); | |
1679 | if (eventType == wxEVT_STC_MACRORECORD) { | |
1680 | evt.SetMessage(scn.message); | |
1681 | evt.SetWParam(scn.wParam); | |
1682 | evt.SetLParam(scn.lParam); | |
1683 | } | |
1684 | ||
1685 | GetEventHandler()->ProcessEvent(evt); | |
1686 | } | |
1687 | } | |
1688 | ||
1689 | ||
1690 | ||
1691 | //---------------------------------------------------------------------- | |
1692 | //---------------------------------------------------------------------- | |
1693 | //---------------------------------------------------------------------- | |
1694 | ||
1695 | wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) | |
1696 | : wxCommandEvent(commandType, id) | |
1697 | { | |
1698 | m_position = 0; | |
1699 | m_key = 0; | |
1700 | m_modifiers = 0; | |
1701 | m_modificationType = 0; | |
1702 | m_length = 0; | |
1703 | m_linesAdded = 0; | |
1704 | m_line = 0; | |
1705 | m_foldLevelNow = 0; | |
1706 | m_foldLevelPrev = 0; | |
1707 | m_margin = 0; | |
1708 | m_message = 0; | |
1709 | m_wParam = 0; | |
1710 | m_lParam = 0; | |
1711 | ||
1712 | ||
1713 | } | |
1714 | ||
1715 | bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } | |
1716 | bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; } | |
1717 | bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; } | |
1718 | ||
1719 | void wxStyledTextEvent::CopyObject(wxObject& obj) const { | |
1720 | wxCommandEvent::CopyObject(obj); | |
1721 | ||
1722 | wxStyledTextEvent* o = (wxStyledTextEvent*)&obj; | |
1723 | o->m_position = m_position; | |
1724 | o->m_key = m_key; | |
1725 | o->m_modifiers = m_modifiers; | |
1726 | o->m_modificationType = m_modificationType; | |
1727 | o->m_text = m_text; | |
1728 | o->m_length = m_length; | |
1729 | o->m_linesAdded = m_linesAdded; | |
1730 | o->m_line = m_line; | |
1731 | o->m_foldLevelNow = m_foldLevelNow; | |
1732 | o->m_foldLevelPrev = m_foldLevelPrev; | |
1733 | ||
1734 | o->m_margin = m_margin; | |
1735 | ||
1736 | o->m_message = m_message; | |
1737 | o->m_wParam = m_wParam; | |
1738 | o->m_lParam = m_lParam; | |
1739 | ||
1740 | ||
1741 | ||
1742 | } | |
1743 | ||
1744 | //---------------------------------------------------------------------- | |
1745 | //---------------------------------------------------------------------- | |
1746 |