]>
Commit | Line | Data |
---|---|---|
1 | //////////////////////////////////////////////////////////////////////////// | |
2 | // Name: stc.h | |
3 | // Purpose: A wxWindows implementation of Scintilla. This class is the | |
4 | // one meant to be used directly by wx applications. It does not | |
5 | // derive directly from the Scintilla classes, 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 | |
17 | // Licence: wxWindows license | |
18 | ///////////////////////////////////////////////////////////////////////////// | |
19 | ||
20 | #ifndef __stc_h__ | |
21 | #define __stc_h__ | |
22 | ||
23 | ||
24 | #include <wx/wx.h> | |
25 | #include "SciLexer.h" | |
26 | ||
27 | //---------------------------------------------------------------------- | |
28 | // constants and stuff | |
29 | ||
30 | enum wxSTC_UndoType { | |
31 | wxSTC_UndoCollectNone, | |
32 | wxSTC_UndoCollectAutoStart | |
33 | }; | |
34 | ||
35 | ||
36 | enum wxSTC_EOL { | |
37 | wxSTC_EOL_CRLF, | |
38 | wxSTC_EOL_CR, | |
39 | wxSTC_EOL_LF | |
40 | }; | |
41 | ||
42 | enum wxSTC_EDGE { | |
43 | wxSTC_EDGE_NONE, | |
44 | wxSTC_EDGE_LINE, | |
45 | wxSTC_EDGE_BACKGROUND | |
46 | }; | |
47 | ||
48 | ||
49 | ||
50 | const int wxSTC_LEX_STYLE_MAX = 31; | |
51 | const int wxSTC_STYLE_DEFAULT = 32; | |
52 | const int wxSTC_STYLE_LINENUMBER = 33; | |
53 | const int wxSTC_STYLE_BRACELIGHT = 34; | |
54 | const int wxSTC_STYLE_BRACEBAD = 35; | |
55 | const int wxSTC_STYLE_CONTROLCHAR = 36; | |
56 | const int wxSTC_STYLE_MAX = 127; | |
57 | const int wxSTC_STYLE_MASK = 31; | |
58 | ||
59 | const int wxSTC_MARKER_MAX = 31; | |
60 | const int wxSTC_MARK_CIRCLE = 0; | |
61 | const int wxSTC_MARK_ROUNDRECT = 1; | |
62 | const int wxSTC_MARK_ARROW = 2; | |
63 | const int wxSTC_MARK_SMALLRECT = 3; | |
64 | const int wxSTC_MARK_SHORTARROW = 4; | |
65 | const int wxSTC_MARK_EMPTY = 5; | |
66 | const int wxSTC_MARK_ARROWDOWN = 6; | |
67 | const int wxSTC_MARK_MINUS = 7; | |
68 | const int wxSTC_MARK_PLUS = 8; | |
69 | ||
70 | const int wxSTC_MARKNUM_FOLDER = 30; | |
71 | const int wxSTC_MARKNUM_FOLDEROPEN= 31; | |
72 | const int wxSTC_MASK_FOLDERS = ((1 << wxSTC_MARKNUM_FOLDER) | (1 << wxSTC_MARKNUM_FOLDEROPEN)); | |
73 | ||
74 | const int wxSTC_INDIC_MAX = 7; | |
75 | const int wxSTC_INDIC_PLAIN = 0; | |
76 | const int wxSTC_INDIC_SQUIGGLE = 1; | |
77 | const int wxSTC_INDIC_TT = 2; | |
78 | const int wxSTC_INDIC_DIAGONAL = 3; | |
79 | const int wxSTC_INDIC_STRIKE = 4; | |
80 | const int wxSTC_INDIC0_MASK = 32; | |
81 | const int wxSTC_INDIC1_MASK = 64; | |
82 | const int wxSTC_INDIC2_MASK = 128; | |
83 | const int wxSTC_INDICS_MASK = (wxSTC_INDIC0_MASK | wxSTC_INDIC1_MASK | wxSTC_INDIC2_MASK); | |
84 | ||
85 | ||
86 | const int wxSTC_FOLDLEVELBASE = 0x0400; | |
87 | const int wxSTC_FOLDLEVELWHITEFLAG = 0x1000; | |
88 | const int wxSTC_FOLDLEVELHEADERFLAG = 0x2000; | |
89 | const int wxSTC_FOLDLEVELNUMBERMASK = 0x0FFF; | |
90 | ||
91 | ||
92 | // key commands | |
93 | enum { | |
94 | wxSTC_CMD_LINEDOWN = 2300, | |
95 | wxSTC_CMD_LINEDOWNEXTEND, | |
96 | wxSTC_CMD_LINEUP, | |
97 | wxSTC_CMD_LINEUPEXTEND, | |
98 | wxSTC_CMD_CHARLEFT, | |
99 | wxSTC_CMD_CHARLEFTEXTEND, | |
100 | wxSTC_CMD_CHARRIGHT, | |
101 | wxSTC_CMD_CHARRIGHTEXTEND, | |
102 | wxSTC_CMD_WORDLEFT, | |
103 | wxSTC_CMD_WORDLEFTEXTEND, | |
104 | wxSTC_CMD_WORDRIGHT, | |
105 | wxSTC_CMD_WORDRIGHTEXTEND, | |
106 | wxSTC_CMD_HOME, | |
107 | wxSTC_CMD_HOMEEXTEND, | |
108 | wxSTC_CMD_LINEEND, | |
109 | wxSTC_CMD_LINEENDEXTEND, | |
110 | wxSTC_CMD_DOCUMENTSTART, | |
111 | wxSTC_CMD_DOCUMENTSTARTEXTEND, | |
112 | wxSTC_CMD_DOCUMENTEND, | |
113 | wxSTC_CMD_DOCUMENTENDEXTEND, | |
114 | wxSTC_CMD_PAGEUP, | |
115 | wxSTC_CMD_PAGEUPEXTEND, | |
116 | wxSTC_CMD_PAGEDOWN, | |
117 | wxSTC_CMD_PAGEDOWNEXTEND, | |
118 | wxSTC_CMD_EDITTOGGLEOVERTYPE, | |
119 | wxSTC_CMD_CANCEL, | |
120 | wxSTC_CMD_DELETEBACK, | |
121 | wxSTC_CMD_TAB, | |
122 | wxSTC_CMD_BACKTAB, | |
123 | wxSTC_CMD_NEWLINE, | |
124 | wxSTC_CMD_FORMFEED, | |
125 | wxSTC_CMD_VCHOME, | |
126 | wxSTC_CMD_VCHOMEEXTEND, | |
127 | wxSTC_CMD_ZOOMIN, | |
128 | wxSTC_CMD_ZOOMOUT, | |
129 | wxSTC_CMD_DELWORDLEFT, | |
130 | wxSTC_CMD_DELWORDRIGHT, | |
131 | wxSTC_CMD_LINECUT, | |
132 | wxSTC_CMD_LINEDELETE, | |
133 | wxSTC_CMD_LINETRANSPOSE, | |
134 | wxSTC_CMD_LOWERCASE, | |
135 | wxSTC_CMD_UPPERCASE, | |
136 | wxSTC_CMD_LINESCROLLDOWN, | |
137 | wxSTC_CMD_LINESCROLLUP | |
138 | }; | |
139 | ||
140 | ||
141 | enum wxSTC_LEX { | |
142 | wxSTC_LEX_CONTAINER=0, | |
143 | wxSTC_LEX_NULL, | |
144 | wxSTC_LEX_PYTHON, | |
145 | wxSTC_LEX_CPP, | |
146 | wxSTC_LEX_HTML, | |
147 | wxSTC_LEX_XML, | |
148 | wxSTC_LEX_PERL, | |
149 | wxSTC_LEX_SQL, | |
150 | wxSTC_LEX_VB, | |
151 | wxSTC_LEX_PROPERTIES, | |
152 | wxSTC_LEX_ERRORLIST, | |
153 | wxSTC_LEX_MAKEFILE, | |
154 | wxSTC_LEX_BATCH, | |
155 | wxSTC_LEX_XCODE, | |
156 | wxSTC_LEX_LATEX | |
157 | }; | |
158 | ||
159 | ||
160 | ||
161 | const int wxSTC_CARET_SLOP = 0x01; | |
162 | const int WXSTC_CARET_CENTER = 0x02; | |
163 | const int wxSTC_CARET_STRICT = 0x04; | |
164 | ||
165 | const int wxSTC_MARGIN_SYMBOL = 0; | |
166 | const int wxSTC_MARGIN_NUMBER = 1; | |
167 | ||
168 | ||
169 | class ScintillaWX; // forward declare | |
170 | class WordList; | |
171 | struct SCNotification; | |
172 | ||
173 | ||
174 | extern const wxChar* wxSTCNameStr; | |
175 | ||
176 | //---------------------------------------------------------------------- | |
177 | ||
178 | class wxStyledTextCtrl : public wxControl { | |
179 | public: | |
180 | ||
181 | #ifdef SWIG | |
182 | wxStyledTextCtrl(wxWindow *parent, wxWindowID id, | |
183 | const wxPoint& pos = wxDefaultPosition, | |
184 | const wxSize& size = wxDefaultSize, long style = 0, | |
185 | const char* name = "styledtext"); | |
186 | #else | |
187 | wxStyledTextCtrl(wxWindow *parent, wxWindowID id, | |
188 | const wxPoint& pos = wxDefaultPosition, | |
189 | const wxSize& size = wxDefaultSize, long style = 0, | |
190 | const wxString& name = wxSTCNameStr); | |
191 | #endif | |
192 | ||
193 | ||
194 | #ifndef SWIG | |
195 | ~wxStyledTextCtrl(); | |
196 | #endif | |
197 | ||
198 | ||
199 | // Text retrieval and modification | |
200 | wxString GetText(); | |
201 | bool SetText(const wxString& text); | |
202 | wxString GetLine(int line); | |
203 | void ReplaceSelection(const wxString& text); | |
204 | void SetReadOnly(bool readOnly); | |
205 | bool GetReadOnly(); | |
206 | wxString GetTextRange(int startPos, int endPos); | |
207 | wxString GetStyledTextRange(int startPos, int endPos); | |
208 | #ifndef SWIG | |
209 | void GetTextRange(int startPos, int endPos, char* buff); | |
210 | void GetStyledTextRange(int startPos, int endPos, char* buff); | |
211 | #endif | |
212 | void AddText(const wxString& text); | |
213 | void AddStyledText(const wxString& text); | |
214 | void InsertText(int pos, const wxString& text); | |
215 | void ClearAll(); | |
216 | char GetCharAt(int pos); | |
217 | char GetStyleAt(int pos); | |
218 | void SetStyleBits(int bits); | |
219 | int GetStyleBits(); | |
220 | ||
221 | ||
222 | // Clipboard | |
223 | void Cut(); | |
224 | void Copy(); | |
225 | void Paste(); | |
226 | bool CanPaste(); | |
227 | void ClearClipbrd(); // avoiding name conflict with virtual in wxWindow | |
228 | ||
229 | ||
230 | // Undo and Redo | |
231 | void Undo(); | |
232 | bool CanUndo(); | |
233 | void EmptyUndoBuffer(); | |
234 | void Redo(); | |
235 | bool CanRedo(); | |
236 | void SetUndoCollection(wxSTC_UndoType type); | |
237 | wxSTC_UndoType GetUndoCollection(); | |
238 | void BeginUndoAction(); | |
239 | void EndUndoAction(); | |
240 | ||
241 | ||
242 | // Selection and information | |
243 | #ifdef SWIG | |
244 | void GetSelection(int* OUTPUT, int* OUTPUT); | |
245 | #else | |
246 | void GetSelection(int* startPos, int* endPos); | |
247 | #endif | |
248 | void SetSelection(int startPos, int endPos); | |
249 | wxString GetSelectedText(); | |
250 | void HideSelection(bool hide); | |
251 | bool GetHideSelection(); | |
252 | ||
253 | int GetTextLength(); | |
254 | int GetFirstVisibleLine(); | |
255 | bool GetModified(); | |
256 | int GetLineCount(); | |
257 | wxRect GetRect(); | |
258 | int GetLineFromPos(int pos); | |
259 | int GetLineStartPos(int line); | |
260 | int GetLineLengthAtPos(int pos); | |
261 | int GetLineLength(int line); | |
262 | #ifdef SWIG | |
263 | wxString GetCurrentLineText(int* OUTPUT); | |
264 | #else | |
265 | wxString GetCurrentLineText(int* linePos); | |
266 | #endif | |
267 | int GetCurrentLine(); | |
268 | int PositionFromPoint(wxPoint pt); | |
269 | int LineFromPoint(wxPoint pt); | |
270 | wxPoint PointFromPosition(int pos); | |
271 | int GetCurrentPos(); | |
272 | int GetAnchor(); | |
273 | void SelectAll(); | |
274 | void SetCurrentPosition(int pos); | |
275 | void SetAnchor(int pos); | |
276 | void GotoPos(int pos); | |
277 | void GotoLine(int line); | |
278 | void ChangePosition(int delta, bool extendSelection); | |
279 | void PageMove(int cmdKey, bool extendSelection); | |
280 | ||
281 | void ScrollBy(int columnDelta, int lineDelta); | |
282 | void ScrollToLine(int line); | |
283 | void ScrollToColumn(int column); | |
284 | void EnsureCaretVisible(); | |
285 | void SetCaretPolicy(int policy, int slop=0); | |
286 | int GetSelectionType(); | |
287 | int GetLinesOnScreen(); | |
288 | bool IsSelectionRectangle(); | |
289 | void SetUseHorizontalScrollBar(bool use); | |
290 | bool GetUseHorizontalScrollBar(); | |
291 | ||
292 | ||
293 | // Searching | |
294 | int FindText(int minPos, int maxPos, const wxString& text, | |
295 | bool caseSensitive, bool wholeWord); | |
296 | void SearchAnchor(); | |
297 | int SearchNext(const wxString& text, bool caseSensitive, bool wholeWord); | |
298 | int SearchPrev(const wxString& text, bool caseSensitive, bool wholeWord); | |
299 | ||
300 | ||
301 | // Visible whitespace | |
302 | bool GetViewWhitespace(); | |
303 | void SetViewWhitespace(bool visible); | |
304 | ||
305 | ||
306 | // Line endings | |
307 | wxSTC_EOL GetEOLMode(); | |
308 | void SetEOLMode(wxSTC_EOL mode); | |
309 | bool GetViewEOL(); | |
310 | void SetViewEOL(bool visible); | |
311 | void ConvertEOL(wxSTC_EOL mode); | |
312 | ||
313 | ||
314 | // Styling | |
315 | int GetEndStyled(); | |
316 | void StartStyling(int pos, int mask); | |
317 | void SetStyleFor(int length, int style); | |
318 | void SetStyleBytes(int length, char* styleBytes); | |
319 | void SetLineState(int line, int value); | |
320 | int GetLineState(int line); | |
321 | ||
322 | ||
323 | // Style Definition | |
324 | void StyleClearAll(); | |
325 | void StyleResetDefault(); | |
326 | void StyleSetSpec(int styleNum, const wxString& spec); | |
327 | void StyleSetForeground(int styleNum, const wxColour& colour); | |
328 | void StyleSetBackground(int styleNum, const wxColour& colour); | |
329 | void StyleSetFont(int styleNum, wxFont& font); | |
330 | void StyleSetFontAttr(int styleNum, int size, const wxString& faceName, bool bold=FALSE, bool italic=FALSE, bool underline=FALSE); | |
331 | void StyleSetBold(int styleNum, bool bold); | |
332 | void StyleSetItalic(int styleNum, bool italic); | |
333 | void StyleSetFaceName(int styleNum, const wxString& faceName); | |
334 | void StyleSetSize(int styleNum, int pointSize); | |
335 | void StyleSetEOLFilled(int styleNum, bool fillEOL); | |
336 | void StyleSetUnderline(int styleNum, bool underline); | |
337 | ||
338 | ||
339 | // Margins in the edit area | |
340 | int GetLeftMargin(); | |
341 | int GetRightMargin(); | |
342 | void SetMargins(int left, int right); | |
343 | ||
344 | ||
345 | // Margins for selection, markers, etc. | |
346 | void SetMarginType(int margin, int type); | |
347 | int GetMarginType(int margin); | |
348 | void SetMarginWidth(int margin, int pixelWidth); | |
349 | int GetMarginWidth(int margin); | |
350 | void SetMarginMask(int margin, int mask); | |
351 | int GetMarginMask(int margin); | |
352 | void SetMarginSensitive(int margin, bool sensitive); | |
353 | bool GetMarginSensitive(int margin); | |
354 | ||
355 | ||
356 | // Selection and Caret styles | |
357 | void SetSelectionForeground(const wxColour& colour); | |
358 | void SetSelectionBackground(const wxColour& colour); | |
359 | void SetCaretForeground(const wxColour& colour); | |
360 | int GetCaretPeriod(); | |
361 | void SetCaretPeriod(int milliseconds); | |
362 | ||
363 | ||
364 | // Other settings | |
365 | void SetBufferedDraw(bool isBuffered); | |
366 | void SetTabWidth(int numChars); | |
367 | void SetIndent(int numChars); | |
368 | void SetUseTabs(bool usetabs); | |
369 | void SetLineIndentation(int line, int indentation); | |
370 | int GetLineIndentation(int line); | |
371 | int GetLineIndentationPos(int line); | |
372 | void SetWordChars(const wxString& wordChars); | |
373 | ||
374 | void SetUsePop(bool usepopup); | |
375 | ||
376 | ||
377 | // Brace highlighting | |
378 | void BraceHighlight(int pos1, int pos2); | |
379 | void BraceBadlight(int pos); | |
380 | int BraceMatch(int pos, int maxReStyle=0); | |
381 | ||
382 | ||
383 | // Markers | |
384 | void MarkerDefine(int markerNumber, int markerSymbol, | |
385 | const wxColour& foreground, | |
386 | const wxColour& background); | |
387 | void MarkerSetType(int markerNumber, int markerSymbol); | |
388 | void MarkerSetForeground(int markerNumber, const wxColour& colour); | |
389 | void MarkerSetBackground(int markerNumber, const wxColour& colour); | |
390 | int MarkerAdd(int line, int markerNumber); | |
391 | void MarkerDelete(int line, int markerNumber); | |
392 | void MarkerDeleteAll(int markerNumber); | |
393 | int MarkerGet(int line); | |
394 | int MarkerGetNextLine(int lineStart, int markerMask); | |
395 | int MarkerGetPrevLine(int lineStart, int markerMask); | |
396 | int MarkerLineFromHandle(int handle); | |
397 | void MarkerDeleteHandle(int handle); | |
398 | ||
399 | ||
400 | // Indicators | |
401 | void IndicatorSetStyle(int indicNum, int indicStyle); | |
402 | int IndicatorGetStyle(int indicNum); | |
403 | void IndicatorSetColour(int indicNum, const wxColour& colour); | |
404 | ||
405 | ||
406 | // Auto completion | |
407 | void AutoCompShow(const wxString& listOfWords); | |
408 | void AutoCompCancel(); | |
409 | bool AutoCompActive(); | |
410 | int AutoCompPosAtStart(); | |
411 | void AutoCompComplete(); | |
412 | void AutoCompStopChars(const wxString& stopChars); | |
413 | void AutoCompSetSeparator(char separator); | |
414 | char AutoCompGetSeparator(); | |
415 | void AutoCompSelect(const wxString& stringtoselect); | |
416 | ||
417 | // Call tips | |
418 | void CallTipShow(int pos, const wxString& text); | |
419 | void CallTipCancel(); | |
420 | bool CallTipActive(); | |
421 | int CallTipPosAtStart(); | |
422 | void CallTipSetHighlight(int start, int end); | |
423 | void CallTipSetBackground(const wxColour& colour); | |
424 | ||
425 | ||
426 | // Key bindings | |
427 | void CmdKeyAssign(int key, int modifiers, int cmd); | |
428 | void CmdKeyClear(int key, int modifiers); | |
429 | void CmdKeyClearAll(); | |
430 | void CmdKeyExecute(int cmd); | |
431 | ||
432 | ||
433 | // Print formatting | |
434 | int FormatRange(bool doDraw, | |
435 | int startPos, | |
436 | int endPos, | |
437 | wxDC* draw, | |
438 | wxDC* target, // Why does it use two? Can they be the same? | |
439 | wxRect renderRect, | |
440 | wxRect pageRect); | |
441 | ||
442 | ||
443 | // Document Sharing (multiple views) | |
444 | void* GetDocument(); | |
445 | void SetDocument(void* document); | |
446 | // TODO: create a wx wrapper for Scintilla's document class | |
447 | ||
448 | ||
449 | // Folding | |
450 | int VisibleFromDocLine(int docLine); | |
451 | int DocLineFromVisible(int displayLine); | |
452 | int SetFoldLevel(int line, int level); | |
453 | int GetFoldLevel(int line); | |
454 | int GetLastChild(int line, int level); | |
455 | int GetFoldParent(int line); | |
456 | void ShowLines(int lineStart, int lineEnd); | |
457 | void HideLines(int lineStart, int lineEnd); | |
458 | bool GetLineVisible(int line); | |
459 | void SetFoldExpanded(int line, bool expanded); | |
460 | bool GetFoldExpanded(int line); | |
461 | void ToggleFold(int line); | |
462 | void EnsureVisible(int line); | |
463 | void SetFoldFlags(int flags); | |
464 | ||
465 | ||
466 | // Zooming | |
467 | void ZoomIn(); | |
468 | void ZoomOut(); | |
469 | void SetZoom(int zoom); | |
470 | int GetZoom(); | |
471 | ||
472 | ||
473 | // Long Lines | |
474 | int GetEdgeColumn(); | |
475 | void SetEdgeColumn(int column); | |
476 | wxSTC_EDGE GetEdgeMode(); | |
477 | void SetEdgeMode(wxSTC_EDGE mode); | |
478 | wxColour GetEdgeColour(); | |
479 | void SetEdgeColour(const wxColour& colour); | |
480 | ||
481 | ||
482 | // Lexer | |
483 | void SetLexer(wxSTC_LEX lexer); | |
484 | wxSTC_LEX GetLexer(); | |
485 | void Colourise(int start, int end); | |
486 | void SetProperty(const wxString& key, const wxString& value); | |
487 | void SetKeywords(int keywordSet, const wxString& keywordList); | |
488 | ||
489 | ||
490 | // Event mask for Modified Event | |
491 | void SetModEventMask(int mask); | |
492 | //int GetModEventMask(); | |
493 | ||
494 | #ifndef SWIG | |
495 | private: | |
496 | // Event handlers | |
497 | void OnPaint(wxPaintEvent& evt); | |
498 | void OnScrollWin(wxScrollWinEvent& evt); | |
499 | void OnSize(wxSizeEvent& evt); | |
500 | void OnMouseLeftDown(wxMouseEvent& evt); | |
501 | void OnMouseMove(wxMouseEvent& evt); | |
502 | void OnMouseLeftUp(wxMouseEvent& evt); | |
503 | void OnMouseRightUp(wxMouseEvent& evt); | |
504 | void OnChar(wxKeyEvent& evt); | |
505 | void OnKeyDown(wxKeyEvent& evt); | |
506 | void OnLoseFocus(wxFocusEvent& evt); | |
507 | void OnGainFocus(wxFocusEvent& evt); | |
508 | void OnSysColourChanged(wxSysColourChangedEvent& evt); | |
509 | void OnEraseBackground(wxEraseEvent& evt); | |
510 | void OnMenu(wxCommandEvent& evt); | |
511 | void OnListBox(wxCommandEvent& evt); | |
512 | ||
513 | ||
514 | // Turn notifications from Scintilla into events | |
515 | void NotifyChange(); | |
516 | void NotifyParent(SCNotification* scn); | |
517 | ||
518 | long SendMsg(int msg, long wp=0, long lp=0); | |
519 | ||
520 | private: | |
521 | DECLARE_EVENT_TABLE() | |
522 | DECLARE_CLASS(wxStyledTextCtrl) | |
523 | ||
524 | ScintillaWX* m_swx; | |
525 | wxStopWatch m_stopWatch; | |
526 | bool m_readOnly; | |
527 | wxSTC_UndoType m_undoType; | |
528 | ||
529 | ||
530 | friend class ScintillaWX; | |
531 | friend class Platform; | |
532 | #endif | |
533 | }; | |
534 | ||
535 | //---------------------------------------------------------------------- | |
536 | ||
537 | class wxStyledTextEvent : public wxCommandEvent { | |
538 | public: | |
539 | wxStyledTextEvent(wxEventType commandType=0, int id=0); | |
540 | ~wxStyledTextEvent() {} | |
541 | ||
542 | void SetPosition(int pos) { m_position = pos; } | |
543 | void SetKey(int k) { m_key = k; } | |
544 | void SetModifiers(int m) { m_modifiers = m; } | |
545 | void SetModificationType(int t) { m_modificationType = t; } | |
546 | void SetText(const char* t) { m_text = t; } | |
547 | void SetLength(int len) { m_length = len; } | |
548 | void SetLinesAdded(int num) { m_linesAdded = num; } | |
549 | void SetLine(int val) { m_line = val; } | |
550 | void SetFoldLevelNow(int val) { m_foldLevelNow = val; } | |
551 | void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } | |
552 | void SetMargin(int val) { m_margin = val; } | |
553 | void SetMessage(int val) { m_message = val; } | |
554 | void SetWParam(int val) { m_wParam = val; } | |
555 | void SetLParam(int val) { m_lParam = val; } | |
556 | ||
557 | int GetPosition() const { return m_position; } | |
558 | int GetKey() const { return m_key; } | |
559 | int GetModifiers() const { return m_modifiers; } | |
560 | int GetModificationType() const { return m_modificationType; } | |
561 | wxString GetText() const { return m_text; } | |
562 | int GetLength() const { return m_length; } | |
563 | int GetLinesAdded() const { return m_linesAdded; } | |
564 | int GetLine() const { return m_line; } | |
565 | int GetFoldLevelNow() const { return m_foldLevelNow; } | |
566 | int GetFoldLevelPrev() const { return m_foldLevelPrev; } | |
567 | int GetMargin() const { return m_margin; } | |
568 | int GetMessage() const { return m_message; } | |
569 | int GetWParam() const { return m_wParam; } | |
570 | int GetLParam() const { return m_lParam; } | |
571 | ||
572 | bool GetShift() const; | |
573 | bool GetControl() const; | |
574 | bool GetAlt() const; | |
575 | ||
576 | void CopyObject(wxObject& obj) const; | |
577 | ||
578 | #ifndef SWIG | |
579 | private: | |
580 | DECLARE_DYNAMIC_CLASS(wxStyledTextEvent) | |
581 | ||
582 | int m_position; | |
583 | int m_key; | |
584 | int m_modifiers; | |
585 | ||
586 | int m_modificationType; // wxEVT_STC_MODIFIED | |
587 | wxString m_text; | |
588 | int m_length; | |
589 | int m_linesAdded; | |
590 | int m_line; | |
591 | int m_foldLevelNow; | |
592 | int m_foldLevelPrev; | |
593 | ||
594 | int m_margin; // wxEVT_STC_MARGINCLICK | |
595 | ||
596 | int m_message; // wxEVT_STC_MACRORECORD | |
597 | int m_wParam; | |
598 | int m_lParam; | |
599 | #endif | |
600 | }; | |
601 | ||
602 | ||
603 | // Event types | |
604 | enum { | |
605 | wxEVT_STC_CHANGE = 1650, | |
606 | wxEVT_STC_STYLENEEDED, | |
607 | wxEVT_STC_CHARADDED, | |
608 | wxEVT_STC_UPDATEUI, | |
609 | wxEVT_STC_SAVEPOINTREACHED, | |
610 | wxEVT_STC_SAVEPOINTLEFT, | |
611 | wxEVT_STC_ROMODIFYATTEMPT, | |
612 | wxEVT_STC_DOUBLECLICK, | |
613 | wxEVT_STC_MODIFIED, | |
614 | wxEVT_STC_KEY, | |
615 | wxEVT_STC_MACRORECORD, | |
616 | wxEVT_STC_MARGINCLICK, | |
617 | wxEVT_STC_NEEDSHOWN | |
618 | }; | |
619 | ||
620 | // Modification and action types | |
621 | const int wxSTC_MOD_INSERTTEXT = 0x1; | |
622 | const int wxSTC_MOD_DELETETEXT = 0x2; | |
623 | const int wxSTC_MOD_CHANGESTYLE = 0x4; | |
624 | const int wxSTC_MOD_CHANGEFOLD = 0x8; | |
625 | const int wxSTC_PERFORMED_USER = 0x10; | |
626 | const int wxSTC_PERFORMED_UNDO = 0x20; | |
627 | const int wxSTC_PERFORMED_REDO = 0x40; | |
628 | const int wxSTC_LASTSTEPINUNDOREDO = 0x100; | |
629 | const int wxSTC_MOD_CHANGEMARKER = 0x200; | |
630 | const int wxSTC_MOD_BEFOREINSERT = 0x400; | |
631 | const int wxSTC_MOD_BEFOREDELETE = 0x800; | |
632 | ||
633 | ||
634 | #ifndef SWIG | |
635 | typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); | |
636 | ||
637 | #define EVT_STC_CHANGE(id, fn) { wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
638 | #define EVT_STC_STYLENEEDED(id, fn) { wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
639 | #define EVT_STC_CHARADDED(id, fn) { wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
640 | #define EVT_STC_UPDATEUI(id, fn) { wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
641 | #define EVT_STC_SAVEPOINTREACHED(id, fn) { wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
642 | #define EVT_STC_SAVEPOINTLEFT(id, fn) { wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
643 | #define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
644 | #define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
645 | #define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
646 | #define EVT_STC_KEY(id, fn) { wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
647 | #define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
648 | #define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
649 | #define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
650 | ||
651 | #endif | |
652 | ||
653 | //---------------------------------------------------------------------- | |
654 | //---------------------------------------------------------------------- | |
655 | #endif | |
656 | ||
657 |