]>
Commit | Line | Data |
---|---|---|
f97d84a6 | 1 | //////////////////////////////////////////////////////////////////////////// |
a5c2ccf2 | 2 | // Name: wx/stc/stc.h |
be698f50 | 3 | // Purpose: A wxWidgets implementation of Scintilla. This class is the |
f97d84a6 RD |
4 | // one meant to be used directly by wx applications. It does not |
5 | // derive directly from the Scintilla classes, and in fact there | |
6 | // is no mention of Scintilla classes at all in this header. | |
7 | // This class delegates all method calls and events to the | |
8 | // Scintilla objects and so forth. This allows the use of | |
9 | // Scintilla without polluting the namespace with all the | |
10 | // classes and itentifiers from Scintilla. | |
11 | // | |
12 | // Author: Robin Dunn | |
13 | // | |
14 | // Created: 13-Jan-2000 | |
f97d84a6 | 15 | // Copyright: (c) 2000 by Total Control Software |
526954c5 | 16 | // Licence: wxWindows licence |
f97d84a6 RD |
17 | ///////////////////////////////////////////////////////////////////////////// |
18 | ||
a5c2ccf2 VZ |
19 | /* |
20 | IMPORTANT: include/wx/stc/stc.h is generated by src/stc/gen_iface.py from | |
21 | src/stc/stc.h.in, don't edit stc.h file as your changes will be | |
22 | lost after the next regeneration, edit stc.h.in and rerun the | |
23 | gen_iface.py script instead! | |
24 | ||
25 | Parts of this file generated by the script are found in between | |
26 | the special "{{{" and "}}}" markers, the rest of it is copied | |
27 | verbatim from src.h.in. | |
28 | */ | |
29 | ||
ea88e9bc VS |
30 | #ifndef _WX_STC_STC_H_ |
31 | #define _WX_STC_STC_H_ | |
f97d84a6 | 32 | |
29825f5f | 33 | #include "wx/defs.h" |
f97d84a6 | 34 | |
29825f5f PC |
35 | #if wxUSE_STC |
36 | ||
37 | #include "wx/control.h" | |
d6655166 | 38 | #include "wx/dnd.h" |
29825f5f | 39 | #include "wx/stopwatch.h" |
ccec9093 | 40 | #include "wx/versioninfo.h" |
f97d84a6 | 41 | |
93578927 | 42 | #include "wx/textentry.h" |
2bfca191 VZ |
43 | #if wxUSE_TEXTCTRL |
44 | #include "wx/textctrl.h" | |
45 | #endif // wxUSE_TEXTCTRL | |
46 | ||
7e0c58e9 | 47 | class WXDLLIMPEXP_FWD_CORE wxScrollBar; |
2b5f62a0 | 48 | |
9d41f689 RD |
49 | // SWIG can't handle "#if" type of conditionals, only "#ifdef" |
50 | #ifdef SWIG | |
51 | #define STC_USE_DND 1 | |
52 | #else | |
53 | #if wxUSE_DRAG_AND_DROP | |
54 | #define STC_USE_DND 1 | |
55 | #endif | |
56 | #endif | |
57 | ||
f97d84a6 | 58 | //---------------------------------------------------------------------- |
a5c2ccf2 | 59 | // STC constants generated section {{{ |
f97d84a6 RD |
60 | |
61 | %(VALUES)s | |
62 | ||
a5c2ccf2 VZ |
63 | //}}} |
64 | //---------------------------------------------------------------------- | |
2b5f62a0 | 65 | |
a5c2ccf2 VZ |
66 | //---------------------------------------------------------------------- |
67 | // Commands that can be bound to keystrokes section {{{ | |
88a8b04e | 68 | |
2b5f62a0 VZ |
69 | %(CMDS)s |
70 | ||
a5c2ccf2 | 71 | //}}} |
f97d84a6 RD |
72 | //---------------------------------------------------------------------- |
73 | ||
74 | class ScintillaWX; // forward declare | |
75 | class WordList; | |
76 | struct SCNotification; | |
77 | ||
2b5f62a0 | 78 | #ifndef SWIG |
23318a53 | 79 | extern WXDLLIMPEXP_DATA_STC(const char) wxSTCNameStr[]; |
7e0c58e9 RD |
80 | class WXDLLIMPEXP_FWD_STC wxStyledTextCtrl; |
81 | class WXDLLIMPEXP_FWD_STC wxStyledTextEvent; | |
2b5f62a0 | 82 | #endif |
f97d84a6 RD |
83 | |
84 | //---------------------------------------------------------------------- | |
85 | ||
3396739d | 86 | class WXDLLIMPEXP_STC wxStyledTextCtrl : public wxControl, |
2bfca191 | 87 | #if wxUSE_TEXTCTRL |
3396739d VZ |
88 | public wxTextCtrlIface |
89 | #else // !wxUSE_TEXTCTRL | |
90 | public wxTextEntryBase | |
91 | #endif // wxUSE_TEXTCTRL/!wxUSE_TEXTCTRL | |
8e0945da | 92 | { |
f97d84a6 RD |
93 | public: |
94 | ||
95 | #ifdef SWIG | |
faadde7e RD |
96 | %%pythonAppend wxStyledTextCtrl "self._setOORInfo(self)" |
97 | %%pythonAppend wxStyledTextCtrl() "" | |
39c0acb6 | 98 | |
f325fa52 | 99 | wxStyledTextCtrl(wxWindow *parent, wxWindowID id=wxID_ANY, |
f97d84a6 RD |
100 | const wxPoint& pos = wxDefaultPosition, |
101 | const wxSize& size = wxDefaultSize, long style = 0, | |
137b5242 | 102 | const wxString& name = wxPySTCNameStr); |
3c1705d9 | 103 | %%RenameCtor(PreStyledTextCtrl, wxStyledTextCtrl()); |
dc8005e2 | 104 | |
f97d84a6 | 105 | #else |
f325fa52 | 106 | wxStyledTextCtrl(wxWindow *parent, wxWindowID id=wxID_ANY, |
f97d84a6 RD |
107 | const wxPoint& pos = wxDefaultPosition, |
108 | const wxSize& size = wxDefaultSize, long style = 0, | |
109 | const wxString& name = wxSTCNameStr); | |
39c0acb6 RD |
110 | wxStyledTextCtrl() { m_swx = NULL; } |
111 | ~wxStyledTextCtrl(); | |
dc8005e2 | 112 | |
f97d84a6 RD |
113 | #endif |
114 | ||
a48cb415 RD |
115 | bool Create(wxWindow *parent, wxWindowID id=wxID_ANY, |
116 | const wxPoint& pos = wxDefaultPosition, | |
117 | const wxSize& size = wxDefaultSize, long style = 0, | |
118 | const wxString& name = wxSTCNameStr); | |
f97d84a6 | 119 | |
f97d84a6 | 120 | |
a5c2ccf2 VZ |
121 | //---------------------------------------------------------------------- |
122 | // Generated method declaration section {{{ | |
f97d84a6 RD |
123 | |
124 | %(METHOD_DEFS)s | |
125 | ||
a5c2ccf2 VZ |
126 | //}}} |
127 | //---------------------------------------------------------------------- | |
f97d84a6 | 128 | |
a5c2ccf2 | 129 | // Manually declared methods |
f97d84a6 RD |
130 | |
131 | // Returns the line number of the line with the caret. | |
132 | int GetCurrentLine(); | |
133 | ||
134 | // Extract style settings from a spec-string which is composed of one or | |
135 | // more of the following comma separated elements: | |
136 | // | |
137 | // bold turns on bold | |
138 | // italic turns on italics | |
5ee1d760 RD |
139 | // fore:[name or #RRGGBB] sets the foreground colour |
140 | // back:[name or #RRGGBB] sets the background colour | |
f97d84a6 RD |
141 | // face:[facename] sets the font face name to use |
142 | // size:[num] sets the font size in points | |
143 | // eol turns on eol filling | |
144 | // underline turns on underlining | |
145 | // | |
146 | void StyleSetSpec(int styleNum, const wxString& spec); | |
147 | ||
148 | ||
7e0c58e9 RD |
149 | // Get the font of a style. |
150 | wxFont StyleGetFont(int style); | |
151 | ||
f97d84a6 RD |
152 | |
153 | // Set style size, face, bold, italic, and underline attributes from | |
154 | // a wxFont's attributes. | |
155 | void StyleSetFont(int styleNum, wxFont& font); | |
156 | ||
157 | ||
158 | ||
159 | // Set all font style attributes at once. | |
160 | void StyleSetFontAttr(int styleNum, int size, | |
161 | const wxString& faceName, | |
162 | bool bold, bool italic, | |
3727c043 RD |
163 | bool underline, |
164 | wxFontEncoding encoding=wxFONTENCODING_DEFAULT); | |
f97d84a6 RD |
165 | |
166 | ||
3727c043 RD |
167 | // Set the character set of the font in a style. Converts the Scintilla |
168 | // character set values to a wxFontEncoding. | |
169 | void StyleSetCharacterSet(int style, int characterSet); | |
170 | ||
171 | // Set the font encoding to be used by a style. | |
172 | void StyleSetFontEncoding(int style, wxFontEncoding encoding); | |
a5c2ccf2 | 173 | |
f97d84a6 RD |
174 | |
175 | // Perform one of the operations defined by the wxSTC_CMD_* constants. | |
176 | void CmdKeyExecute(int cmd); | |
177 | ||
178 | ||
f97d84a6 RD |
179 | // Set the left and right margin in the edit area, measured in pixels. |
180 | void SetMargins(int left, int right); | |
181 | ||
182 | ||
f97d84a6 RD |
183 | // Retrieve the point in the window where a position is displayed. |
184 | wxPoint PointFromPosition(int pos); | |
185 | ||
186 | ||
187 | // Scroll enough to make the given line visible | |
188 | void ScrollToLine(int line); | |
189 | ||
190 | ||
191 | // Scroll enough to make the given column visible | |
192 | void ScrollToColumn(int column); | |
193 | ||
65ec6247 RD |
194 | |
195 | // Send a message to Scintilla | |
8e0945da VZ |
196 | // |
197 | // NB: this method is not really const as it can modify the control but it | |
198 | // has to be declared as such as it's called from both const and | |
199 | // non-const methods and we can't distinguish between the two | |
fafd43c5 | 200 | wxIntPtr SendMsg(int msg, wxUIntPtr wp=0, wxIntPtr lp=0) const; |
65ec6247 | 201 | |
5fa4613c RD |
202 | |
203 | // Set the vertical scrollbar to use instead of the ont that's built-in. | |
ccfc3219 | 204 | void SetVScrollBar(wxScrollBar* bar); |
5fa4613c RD |
205 | |
206 | ||
207 | // Set the horizontal scrollbar to use instead of the ont that's built-in. | |
ccfc3219 | 208 | void SetHScrollBar(wxScrollBar* bar); |
5fa4613c | 209 | |
0b9dfbc0 RD |
210 | // Can be used to prevent the EVT_CHAR handler from adding the char |
211 | bool GetLastKeydownProcessed() { return m_lastKeyDownConsumed; } | |
212 | void SetLastKeydownProcessed(bool val) { m_lastKeyDownConsumed = val; } | |
213 | ||
2bfca191 VZ |
214 | // if we derive from wxTextAreaBase it already provides these methods |
215 | #if !wxUSE_TEXTCTRL | |
51566b0b RD |
216 | // Write the contents of the editor to filename |
217 | bool SaveFile(const wxString& filename); | |
218 | ||
219 | // Load the contents of filename into the editor | |
220 | bool LoadFile(const wxString& filename); | |
2bfca191 | 221 | #endif // !wxUSE_TEXTCTRL |
51566b0b | 222 | |
9d41f689 | 223 | #ifdef STC_USE_DND |
4a65f2c8 | 224 | // Allow for simulating a DnD DragOver |
dc8005e2 | 225 | wxDragResult DoDragOver(wxCoord x, wxCoord y, wxDragResult def); |
4a65f2c8 RD |
226 | |
227 | // Allow for simulating a DnD DropText | |
228 | bool DoDropText(long x, long y, const wxString& data); | |
2fcce896 MB |
229 | #endif |
230 | ||
d1558f3d RD |
231 | // Specify whether anti-aliased fonts should be used. Will have no effect |
232 | // on some platforms, but on some (wxMac for example) can greatly improve | |
233 | // performance. | |
234 | void SetUseAntiAliasing(bool useAA); | |
4a65f2c8 | 235 | |
d1558f3d RD |
236 | // Returns the current UseAntiAliasing setting. |
237 | bool GetUseAntiAliasing(); | |
dc8005e2 | 238 | |
95725e35 VZ |
239 | // Clear annotations from the given line. |
240 | void AnnotationClearLine(int line); | |
241 | ||
0b9dfbc0 | 242 | |
a5c2ccf2 | 243 | |
4c51a665 | 244 | // The following methods are nearly equivalent to their similarly named |
41a499cd RD |
245 | // cousins above. The difference is that these methods bypass wxString |
246 | // and always use a char* even if used in a unicode build of wxWidgets. | |
247 | // In that case the character data will be utf-8 encoded since that is | |
248 | // what is used internally by Scintilla in unicode builds. | |
a5c2ccf2 | 249 | |
41a499cd | 250 | // Add text to the document at current position. |
6f67e6d2 | 251 | void AddTextRaw(const char* text, int length=-1); |
41a499cd RD |
252 | |
253 | // Insert string at a position. | |
254 | void InsertTextRaw(int pos, const char* text); | |
255 | ||
256 | // Retrieve the text of the line containing the caret. | |
257 | // Returns the index of the caret on the line. | |
258 | #ifdef SWIG | |
259 | wxCharBuffer GetCurLineRaw(int* OUTPUT); | |
260 | #else | |
261 | wxCharBuffer GetCurLineRaw(int* linePos=NULL); | |
262 | #endif | |
263 | ||
264 | // Retrieve the contents of a line. | |
265 | wxCharBuffer GetLineRaw(int line); | |
266 | ||
267 | // Retrieve the selected text. | |
268 | wxCharBuffer GetSelectedTextRaw(); | |
269 | ||
270 | // Retrieve a range of text. | |
271 | wxCharBuffer GetTextRangeRaw(int startPos, int endPos); | |
272 | ||
273 | // Replace the contents of the document with the argument text. | |
274 | void SetTextRaw(const char* text); | |
275 | ||
276 | // Retrieve all the text in the document. | |
277 | wxCharBuffer GetTextRaw(); | |
278 | ||
279 | // Append a string to the end of the document without changing the selection. | |
6f67e6d2 | 280 | void AppendTextRaw(const char* text, int length=-1); |
41a499cd | 281 | |
1ce1bd84 | 282 | #ifdef SWIG |
f2ccce28 | 283 | %%pythoncode "_stc_utf8_methods.py" |
1ce1bd84 | 284 | #endif |
f97d84a6 RD |
285 | |
286 | ||
93578927 VZ |
287 | // implement wxTextEntryBase pure virtual methods |
288 | // ---------------------------------------------- | |
289 | ||
933be2dc VZ |
290 | virtual void WriteText(const wxString& text) |
291 | { | |
292 | ReplaceSelection(text); | |
293 | } | |
294 | ||
93578927 VZ |
295 | virtual void Remove(long from, long to) |
296 | { | |
297 | Replace(from, to, ""); | |
298 | } | |
299 | virtual void Replace(long from, long to, const wxString& text) | |
300 | { | |
17473a77 VS |
301 | SetTargetStart((int)from); |
302 | SetTargetEnd((int)to); | |
93578927 VZ |
303 | ReplaceTarget(text); |
304 | } | |
305 | ||
306 | /* | |
307 | These functions are already declared in the generated section. | |
308 | ||
309 | virtual void Copy(); | |
310 | virtual void Cut(); | |
311 | virtual void Paste(); | |
312 | ||
313 | virtual void Undo(); | |
314 | virtual void Redo(); | |
315 | ||
316 | virtual bool CanUndo() const; | |
317 | virtual bool CanRedo() const; | |
318 | ||
319 | */ | |
320 | ||
1054bcb2 VZ |
321 | virtual void SetInsertionPoint(long pos) |
322 | { | |
17473a77 | 323 | SetCurrentPos(int(pos == -1 ? GetLastPosition() : pos)); |
1054bcb2 | 324 | } |
93578927 VZ |
325 | virtual long GetInsertionPoint() const { return GetCurrentPos(); } |
326 | virtual long GetLastPosition() const { return GetTextLength(); } | |
327 | ||
328 | virtual void SetSelection(long from, long to) | |
329 | { | |
330 | if ( from == -1 && to == -1 ) | |
331 | { | |
332 | SelectAll(); | |
333 | } | |
334 | else | |
335 | { | |
17473a77 VS |
336 | SetSelectionStart((int)from); |
337 | SetSelectionEnd((int)to); | |
93578927 VZ |
338 | } |
339 | } | |
340 | ||
33e659d7 VZ |
341 | virtual void SelectNone() |
342 | { | |
343 | ClearSelections(); | |
344 | } | |
345 | ||
fa70ec2b RD |
346 | #ifdef SWIG |
347 | void GetSelection(long* OUTPUT, long* OUTPUT) const; | |
348 | #else | |
93578927 VZ |
349 | virtual void GetSelection(long *from, long *to) const |
350 | { | |
351 | if ( from ) | |
352 | *from = GetSelectionStart(); | |
353 | if ( to ) | |
354 | *to = GetSelectionEnd(); | |
355 | } | |
23318a53 | 356 | |
fa70ec2b RD |
357 | // kept for compatibility only |
358 | void GetSelection(int *from, int *to) | |
359 | { | |
360 | long f, t; | |
361 | GetSelection(&f, &t); | |
362 | if ( from ) | |
17473a77 | 363 | *from = (int)f; |
fa70ec2b | 364 | if ( to ) |
17473a77 | 365 | *to = (int)t; |
fa70ec2b RD |
366 | } |
367 | #endif | |
23318a53 | 368 | |
93578927 VZ |
369 | virtual bool IsEditable() const { return !GetReadOnly(); } |
370 | virtual void SetEditable(bool editable) { SetReadOnly(!editable); } | |
371 | ||
2bfca191 VZ |
372 | // implement wxTextAreaBase pure virtual methods |
373 | // --------------------------------------------- | |
374 | ||
223862cb | 375 | virtual int GetLineLength(long lineNo) const { return static_cast<int>(GetLineText(lineNo).length()); } |
cd41ef6f VZ |
376 | virtual wxString GetLineText(long lineNo) const |
377 | { | |
378 | wxString text = GetLine(static_cast<int>(lineNo)); | |
379 | size_t lastNewLine = text.find_last_not_of(wxS("\r\n")); | |
380 | ||
381 | if ( lastNewLine != wxString::npos ) | |
382 | text.erase(lastNewLine + 1); // remove trailing cr+lf | |
383 | else | |
384 | text.clear(); | |
385 | return text; | |
386 | } | |
2bfca191 VZ |
387 | virtual int GetNumberOfLines() const { return GetLineCount(); } |
388 | ||
389 | virtual bool IsModified() const { return GetModify(); } | |
390 | virtual void MarkDirty() { wxFAIL_MSG("not implemented"); } | |
391 | virtual void DiscardEdits() { SetSavePoint(); } | |
392 | ||
393 | virtual bool SetStyle(long WXUNUSED(start), long WXUNUSED(end), | |
394 | const wxTextAttr& WXUNUSED(style)) | |
395 | { | |
396 | wxFAIL_MSG("not implemented"); | |
397 | ||
398 | return false; | |
399 | } | |
400 | ||
401 | virtual bool GetStyle(long WXUNUSED(position), wxTextAttr& WXUNUSED(style)) | |
402 | { | |
403 | wxFAIL_MSG("not implemented"); | |
404 | ||
405 | return false; | |
406 | } | |
407 | ||
408 | virtual bool SetDefaultStyle(const wxTextAttr& WXUNUSED(style)) | |
409 | { | |
410 | wxFAIL_MSG("not implemented"); | |
411 | ||
412 | return false; | |
413 | } | |
414 | ||
415 | virtual long XYToPosition(long x, long y) const | |
416 | { | |
17473a77 | 417 | long pos = PositionFromLine((int)y); |
2bfca191 VZ |
418 | pos += x; |
419 | return pos; | |
420 | } | |
421 | ||
422 | virtual bool PositionToXY(long pos, long *x, long *y) const | |
423 | { | |
17473a77 | 424 | int l = LineFromPosition((int)pos); |
0cd7db14 VZ |
425 | if ( l == -1 ) |
426 | return false; | |
427 | ||
2bfca191 | 428 | if ( x ) |
0cd7db14 | 429 | *x = pos - PositionFromLine(l); |
2bfca191 VZ |
430 | |
431 | if ( y ) | |
2bfca191 | 432 | *y = l; |
2bfca191 VZ |
433 | |
434 | return true; | |
435 | } | |
436 | ||
17473a77 | 437 | virtual void ShowPosition(long pos) { GotoPos((int)pos); } |
2bfca191 | 438 | |
a2fd8a45 VZ |
439 | // FIXME-VC6: can't use wxWindow here because of "error C2603: illegal |
440 | // access declaration: 'wxWindow' is not a direct base of | |
441 | // 'wxStyledTextCtrl'" with VC6 | |
442 | using wxControl::HitTest; | |
2bfca191 VZ |
443 | |
444 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const | |
445 | { | |
446 | const long l = PositionFromPoint(pt); | |
447 | if ( l == -1 ) | |
448 | return wxTE_HT_BELOW; // we don't really know where it was | |
449 | ||
450 | if ( pos ) | |
451 | *pos = l; | |
452 | ||
453 | return wxTE_HT_ON_TEXT; | |
454 | } | |
455 | ||
0aa619b5 VZ |
456 | // just unhide it |
457 | virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, | |
458 | wxTextCoord *col, | |
459 | wxTextCoord *row) const | |
460 | { | |
461 | return wxTextAreaBase::HitTest(pt, col, row); | |
462 | } | |
463 | ||
ccec9093 VZ |
464 | static wxVersionInfo GetLibraryVersionInfo(); |
465 | ||
5e6880e6 | 466 | protected: |
ce364c4e | 467 | virtual void DoSetValue(const wxString& value, int flags); |
d0a22afc VZ |
468 | virtual wxString DoGetValue() const { return GetText(); } |
469 | virtual wxWindow *GetEditableWindow() { return this; } | |
470 | ||
471 | #ifndef SWIG | |
2bfca191 VZ |
472 | virtual bool DoLoadFile(const wxString& file, int fileType); |
473 | virtual bool DoSaveFile(const wxString& file, int fileType); | |
474 | ||
f97d84a6 RD |
475 | // Event handlers |
476 | void OnPaint(wxPaintEvent& evt); | |
477 | void OnScrollWin(wxScrollWinEvent& evt); | |
5fa4613c | 478 | void OnScroll(wxScrollEvent& evt); |
f97d84a6 RD |
479 | void OnSize(wxSizeEvent& evt); |
480 | void OnMouseLeftDown(wxMouseEvent& evt); | |
481 | void OnMouseMove(wxMouseEvent& evt); | |
482 | void OnMouseLeftUp(wxMouseEvent& evt); | |
ddf2da08 | 483 | void OnMouseRightUp(wxMouseEvent& evt); |
2b5f62a0 | 484 | void OnMouseMiddleUp(wxMouseEvent& evt); |
65ec6247 | 485 | void OnContextMenu(wxContextMenuEvent& evt); |
37d62433 | 486 | void OnMouseWheel(wxMouseEvent& evt); |
f97d84a6 RD |
487 | void OnChar(wxKeyEvent& evt); |
488 | void OnKeyDown(wxKeyEvent& evt); | |
489 | void OnLoseFocus(wxFocusEvent& evt); | |
490 | void OnGainFocus(wxFocusEvent& evt); | |
491 | void OnSysColourChanged(wxSysColourChangedEvent& evt); | |
492 | void OnEraseBackground(wxEraseEvent& evt); | |
493 | void OnMenu(wxCommandEvent& evt); | |
494 | void OnListBox(wxCommandEvent& evt); | |
8e54aaed | 495 | void OnIdle(wxIdleEvent& evt); |
dc8005e2 | 496 | |
8ae4f086 | 497 | virtual wxSize DoGetBestSize() const; |
f97d84a6 RD |
498 | |
499 | // Turn notifications from Scintilla into events | |
500 | void NotifyChange(); | |
501 | void NotifyParent(SCNotification* scn); | |
502 | ||
5e6880e6 | 503 | private: |
f97d84a6 | 504 | DECLARE_EVENT_TABLE() |
ba8a4f66 | 505 | DECLARE_DYNAMIC_CLASS(wxStyledTextCtrl) |
f97d84a6 | 506 | |
9e730a78 RD |
507 | protected: |
508 | ||
f97d84a6 RD |
509 | ScintillaWX* m_swx; |
510 | wxStopWatch m_stopWatch; | |
5fa4613c RD |
511 | wxScrollBar* m_vScrollBar; |
512 | wxScrollBar* m_hScrollBar; | |
f97d84a6 | 513 | |
d6582821 | 514 | bool m_lastKeyDownConsumed; |
f97d84a6 RD |
515 | |
516 | friend class ScintillaWX; | |
517 | friend class Platform; | |
2bfca191 | 518 | #endif // !SWIG |
f97d84a6 RD |
519 | }; |
520 | ||
521 | //---------------------------------------------------------------------- | |
522 | ||
ba8a4f66 | 523 | class WXDLLIMPEXP_STC wxStyledTextEvent : public wxCommandEvent { |
f97d84a6 RD |
524 | public: |
525 | wxStyledTextEvent(wxEventType commandType=0, int id=0); | |
4161723f RD |
526 | #ifndef SWIG |
527 | wxStyledTextEvent(const wxStyledTextEvent& event); | |
528 | #endif | |
f97d84a6 RD |
529 | ~wxStyledTextEvent() {} |
530 | ||
a29a241f RD |
531 | void SetPosition(int pos) { m_position = pos; } |
532 | void SetKey(int k) { m_key = k; } | |
533 | void SetModifiers(int m) { m_modifiers = m; } | |
534 | void SetModificationType(int t) { m_modificationType = t; } | |
10ef30eb | 535 | void SetText(const wxString& t) { m_text = t; } |
a29a241f RD |
536 | void SetLength(int len) { m_length = len; } |
537 | void SetLinesAdded(int num) { m_linesAdded = num; } | |
538 | void SetLine(int val) { m_line = val; } | |
539 | void SetFoldLevelNow(int val) { m_foldLevelNow = val; } | |
540 | void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } | |
541 | void SetMargin(int val) { m_margin = val; } | |
542 | void SetMessage(int val) { m_message = val; } | |
543 | void SetWParam(int val) { m_wParam = val; } | |
544 | void SetLParam(int val) { m_lParam = val; } | |
545 | void SetListType(int val) { m_listType = val; } | |
546 | void SetX(int val) { m_x = val; } | |
547 | void SetY(int val) { m_y = val; } | |
54173563 RD |
548 | void SetToken(int val) { m_token = val; } |
549 | void SetAnnotationLinesAdded(int val) { m_annotationLinesAdded = val; } | |
550 | void SetUpdated(int val) { m_updated = val; } | |
92bbd64f | 551 | #ifdef STC_USE_DND |
35f8d83d VZ |
552 | void SetDragText(const wxString& val) { m_dragText = val; } |
553 | void SetDragFlags(int flags) { m_dragFlags = flags; } | |
a29a241f | 554 | void SetDragResult(wxDragResult val) { m_dragResult = val; } |
35f8d83d VZ |
555 | |
556 | // This method is kept mainly for backwards compatibility, use | |
557 | // SetDragFlags() in the new code. | |
558 | void SetDragAllowMove(bool allow) | |
559 | { | |
560 | if ( allow ) | |
561 | m_dragFlags |= wxDrag_AllowMove; | |
562 | else | |
563 | m_dragFlags &= ~(wxDrag_AllowMove | wxDrag_DefaultMove); | |
564 | } | |
92bbd64f | 565 | #endif |
f97d84a6 RD |
566 | |
567 | int GetPosition() const { return m_position; } | |
568 | int GetKey() const { return m_key; } | |
569 | int GetModifiers() const { return m_modifiers; } | |
570 | int GetModificationType() const { return m_modificationType; } | |
571 | wxString GetText() const { return m_text; } | |
572 | int GetLength() const { return m_length; } | |
573 | int GetLinesAdded() const { return m_linesAdded; } | |
574 | int GetLine() const { return m_line; } | |
575 | int GetFoldLevelNow() const { return m_foldLevelNow; } | |
576 | int GetFoldLevelPrev() const { return m_foldLevelPrev; } | |
577 | int GetMargin() const { return m_margin; } | |
578 | int GetMessage() const { return m_message; } | |
579 | int GetWParam() const { return m_wParam; } | |
580 | int GetLParam() const { return m_lParam; } | |
65ec6247 RD |
581 | int GetListType() const { return m_listType; } |
582 | int GetX() const { return m_x; } | |
583 | int GetY() const { return m_y; } | |
54173563 RD |
584 | int GetToken() const { return m_token; } |
585 | int GetAnnotationsLinesAdded() const { return m_annotationLinesAdded; } | |
586 | int GetUpdated() const { return m_updated; } | |
587 | ||
92bbd64f | 588 | #ifdef STC_USE_DND |
35f8d83d VZ |
589 | wxString GetDragText() { return m_dragText; } |
590 | int GetDragFlags() { return m_dragFlags; } | |
a29a241f | 591 | wxDragResult GetDragResult() { return m_dragResult; } |
35f8d83d VZ |
592 | |
593 | bool GetDragAllowMove() { return (GetDragFlags() & wxDrag_AllowMove) != 0; } | |
92bbd64f | 594 | #endif |
f97d84a6 RD |
595 | |
596 | bool GetShift() const; | |
597 | bool GetControl() const; | |
598 | bool GetAlt() const; | |
599 | ||
5fa4613c | 600 | virtual wxEvent* Clone() const { return new wxStyledTextEvent(*this); } |
f97d84a6 RD |
601 | |
602 | #ifndef SWIG | |
603 | private: | |
604 | DECLARE_DYNAMIC_CLASS(wxStyledTextEvent) | |
605 | ||
606 | int m_position; | |
607 | int m_key; | |
608 | int m_modifiers; | |
609 | ||
610 | int m_modificationType; // wxEVT_STC_MODIFIED | |
611 | wxString m_text; | |
612 | int m_length; | |
613 | int m_linesAdded; | |
614 | int m_line; | |
615 | int m_foldLevelNow; | |
616 | int m_foldLevelPrev; | |
617 | ||
618 | int m_margin; // wxEVT_STC_MARGINCLICK | |
619 | ||
620 | int m_message; // wxEVT_STC_MACRORECORD | |
621 | int m_wParam; | |
622 | int m_lParam; | |
65ec6247 RD |
623 | |
624 | int m_listType; | |
625 | int m_x; | |
626 | int m_y; | |
a29a241f | 627 | |
d01ca1e4 RD |
628 | int m_token; // wxEVT_STC__MODIFIED with SC_MOD_CONTAINER |
629 | int m_annotationLinesAdded; // wxEVT_STC_MODIFIED with SC_MOD_CHANGEANNOTATION | |
54173563 RD |
630 | int m_updated; // wxEVT_STC_UPDATEUI |
631 | ||
632 | ||
92bbd64f | 633 | #if wxUSE_DRAG_AND_DROP |
35f8d83d VZ |
634 | wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP |
635 | int m_dragFlags; // wxEVT_STC_START_DRAG | |
636 | wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP | |
f97d84a6 | 637 | #endif |
92bbd64f | 638 | #endif |
f97d84a6 RD |
639 | }; |
640 | ||
9e730a78 RD |
641 | |
642 | ||
d25f5fbb | 643 | #ifndef SWIG |
9b11752c VZ |
644 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CHANGE, wxStyledTextEvent ); |
645 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_STYLENEEDED, wxStyledTextEvent ); | |
646 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CHARADDED, wxStyledTextEvent ); | |
647 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent ); | |
648 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent ); | |
649 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent ); | |
650 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_KEY, wxStyledTextEvent ); | |
651 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_DOUBLECLICK, wxStyledTextEvent ); | |
652 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_UPDATEUI, wxStyledTextEvent ); | |
653 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_MODIFIED, wxStyledTextEvent ); | |
654 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_MACRORECORD, wxStyledTextEvent ); | |
655 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_MARGINCLICK, wxStyledTextEvent ); | |
656 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_NEEDSHOWN, wxStyledTextEvent ); | |
657 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_PAINTED, wxStyledTextEvent ); | |
658 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent ); | |
659 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_URIDROPPED, wxStyledTextEvent ); | |
660 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_DWELLSTART, wxStyledTextEvent ); | |
661 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_DWELLEND, wxStyledTextEvent ); | |
662 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_START_DRAG, wxStyledTextEvent ); | |
663 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_DRAG_OVER, wxStyledTextEvent ); | |
664 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_DO_DROP, wxStyledTextEvent ); | |
665 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_ZOOM, wxStyledTextEvent ); | |
666 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent ); | |
667 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent ); | |
668 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent ); | |
669 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent ); | |
670 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent ); | |
671 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent ); | |
9e96e16f RD |
672 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent ); |
673 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent ); | |
54173563 | 674 | wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_HOTSPOT_RELEASE_CLICK, wxStyledTextEvent ); |
d25f5fbb RD |
675 | #else |
676 | enum { | |
677 | wxEVT_STC_CHANGE, | |
678 | wxEVT_STC_STYLENEEDED, | |
679 | wxEVT_STC_CHARADDED, | |
d25f5fbb RD |
680 | wxEVT_STC_SAVEPOINTREACHED, |
681 | wxEVT_STC_SAVEPOINTLEFT, | |
682 | wxEVT_STC_ROMODIFYATTEMPT, | |
65ec6247 | 683 | wxEVT_STC_KEY, |
d25f5fbb | 684 | wxEVT_STC_DOUBLECLICK, |
65ec6247 | 685 | wxEVT_STC_UPDATEUI, |
d25f5fbb | 686 | wxEVT_STC_MODIFIED, |
d25f5fbb RD |
687 | wxEVT_STC_MACRORECORD, |
688 | wxEVT_STC_MARGINCLICK, | |
689 | wxEVT_STC_NEEDSHOWN, | |
65ec6247 RD |
690 | wxEVT_STC_PAINTED, |
691 | wxEVT_STC_USERLISTSELECTION, | |
692 | wxEVT_STC_URIDROPPED, | |
693 | wxEVT_STC_DWELLSTART, | |
694 | wxEVT_STC_DWELLEND, | |
a29a241f RD |
695 | wxEVT_STC_START_DRAG, |
696 | wxEVT_STC_DRAG_OVER, | |
697 | wxEVT_STC_DO_DROP, | |
a834585d | 698 | wxEVT_STC_ZOOM, |
9e730a78 RD |
699 | wxEVT_STC_HOTSPOT_CLICK, |
700 | wxEVT_STC_HOTSPOT_DCLICK, | |
1e9bafca | 701 | wxEVT_STC_CALLTIP_CLICK, |
7e0c58e9 RD |
702 | wxEVT_STC_AUTOCOMP_SELECTION, |
703 | wxEVT_STC_INDICATOR_CLICK, | |
9e96e16f RD |
704 | wxEVT_STC_INDICATOR_RELEASE, |
705 | wxEVT_STC_AUTOCOMP_CANCELLED, | |
54173563 RD |
706 | wxEVT_STC_AUTOCOMP_CHAR_DELETED, |
707 | wxEVT_STC_HOTSPOT_RELEASE_CLICK | |
d25f5fbb RD |
708 | }; |
709 | #endif | |
f97d84a6 | 710 | |
f97d84a6 RD |
711 | |
712 | ||
713 | #ifndef SWIG | |
714 | typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); | |
715 | ||
3c778901 VZ |
716 | #define wxStyledTextEventHandler( func ) \ |
717 | wxEVENT_HANDLER_CAST( wxStyledTextEventFunction, func ) | |
718 | ||
53ba4eb4 RD |
719 | #define EVT_STC_CHANGE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), |
720 | #define EVT_STC_STYLENEEDED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
721 | #define EVT_STC_CHARADDED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
722 | #define EVT_STC_SAVEPOINTREACHED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
723 | #define EVT_STC_SAVEPOINTLEFT(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
724 | #define EVT_STC_ROMODIFYATTEMPT(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
725 | #define EVT_STC_KEY(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
726 | #define EVT_STC_DOUBLECLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
727 | #define EVT_STC_UPDATEUI(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
728 | #define EVT_STC_MODIFIED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
729 | #define EVT_STC_MACRORECORD(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
730 | #define EVT_STC_MARGINCLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
731 | #define EVT_STC_NEEDSHOWN(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
732 | #define EVT_STC_PAINTED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_PAINTED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
733 | #define EVT_STC_USERLISTSELECTION(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_USERLISTSELECTION, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
734 | #define EVT_STC_URIDROPPED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
735 | #define EVT_STC_DWELLSTART(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
736 | #define EVT_STC_DWELLEND(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
737 | #define EVT_STC_START_DRAG(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
738 | #define EVT_STC_DRAG_OVER(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
739 | #define EVT_STC_DO_DROP(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
740 | #define EVT_STC_ZOOM(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ZOOM, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
741 | #define EVT_STC_HOTSPOT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_HOTSPOT_CLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
742 | #define EVT_STC_HOTSPOT_DCLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_HOTSPOT_DCLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
743 | #define EVT_STC_CALLTIP_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CALLTIP_CLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
744 | #define EVT_STC_AUTOCOMP_SELECTION(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_SELECTION, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
745 | #define EVT_STC_INDICATOR_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_CLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
746 | #define EVT_STC_INDICATOR_RELEASE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_INDICATOR_RELEASE, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
747 | #define EVT_STC_AUTOCOMP_CANCELLED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_CANCELLED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
748 | #define EVT_STC_AUTOCOMP_CHAR_DELETED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_CHAR_DELETED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), | |
54173563 | 749 | #define EVT_STC_HOTSPOT_RELEASE_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_HOTSPOT_RELEASE_CLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), |
7e0c58e9 | 750 | |
1bc32508 | 751 | #endif |
f97d84a6 | 752 | |
29825f5f | 753 | #endif // wxUSE_STC |
ea88e9bc VS |
754 | |
755 | #endif // _WX_STC_STC_H_ |