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