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