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