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