]>
Commit | Line | Data |
---|---|---|
9ce192d4 RD |
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> | |
f6bcfd97 | 25 | #include "SciLexer.h" |
9ce192d4 RD |
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; | |
f6bcfd97 | 56 | const int wxSTC_STYLE_MAX = 127; |
9ce192d4 RD |
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; | |
f6bcfd97 BP |
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)); | |
9ce192d4 | 73 | |
f6bcfd97 | 74 | const int wxSTC_INDIC_MAX = 7; |
9ce192d4 RD |
75 | const int wxSTC_INDIC_PLAIN = 0; |
76 | const int wxSTC_INDIC_SQUIGGLE = 1; | |
77 | const int wxSTC_INDIC_TT = 2; | |
f6bcfd97 BP |
78 | const int wxSTC_INDIC_DIAGONAL = 3; |
79 | const int wxSTC_INDIC_STRIKE = 4; | |
9ce192d4 RD |
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 | ||
f6bcfd97 BP |
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 | ||
9ce192d4 RD |
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, | |
f6bcfd97 BP |
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 | |
9ce192d4 RD |
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, | |
f6bcfd97 BP |
155 | wxSTC_LEX_XCODE, |
156 | wxSTC_LEX_LATEX | |
9ce192d4 RD |
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 | ||
f6bcfd97 BP |
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 | |
9ce192d4 RD |
187 | wxStyledTextCtrl(wxWindow *parent, wxWindowID id, |
188 | const wxPoint& pos = wxDefaultPosition, | |
189 | const wxSize& size = wxDefaultSize, long style = 0, | |
190 | const wxString& name = wxSTCNameStr); | |
f6bcfd97 BP |
191 | #endif |
192 | ||
9ce192d4 | 193 | |
f6bcfd97 BP |
194 | #ifndef SWIG |
195 | ~wxStyledTextCtrl(); | |
196 | #endif | |
9ce192d4 RD |
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); | |
f6bcfd97 | 208 | #ifndef SWIG |
9ce192d4 RD |
209 | void GetTextRange(int startPos, int endPos, char* buff); |
210 | void GetStyledTextRange(int startPos, int endPos, char* buff); | |
f6bcfd97 | 211 | #endif |
9ce192d4 RD |
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 | |
f6bcfd97 BP |
243 | #ifdef SWIG |
244 | void GetSelection(int* OUTPUT, int* OUTPUT); | |
245 | #else | |
9ce192d4 | 246 | void GetSelection(int* startPos, int* endPos); |
f6bcfd97 | 247 | #endif |
9ce192d4 RD |
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(); | |
9ce192d4 RD |
257 | int GetLineFromPos(int pos); |
258 | int GetLineStartPos(int line); | |
9ce192d4 | 259 | int GetLineLength(int line); |
f6bcfd97 BP |
260 | #ifdef SWIG |
261 | wxString GetCurrentLineText(int* OUTPUT); | |
262 | #else | |
263 | wxString GetCurrentLineText(int* linePos); | |
264 | #endif | |
9ce192d4 RD |
265 | int GetCurrentLine(); |
266 | int PositionFromPoint(wxPoint pt); | |
9ce192d4 RD |
267 | wxPoint PointFromPosition(int pos); |
268 | int GetCurrentPos(); | |
269 | int GetAnchor(); | |
270 | void SelectAll(); | |
271 | void SetCurrentPosition(int pos); | |
272 | void SetAnchor(int pos); | |
273 | void GotoPos(int pos); | |
274 | void GotoLine(int line); | |
275 | void ChangePosition(int delta, bool extendSelection); | |
276 | void PageMove(int cmdKey, bool extendSelection); | |
277 | ||
278 | void ScrollBy(int columnDelta, int lineDelta); | |
279 | void ScrollToLine(int line); | |
280 | void ScrollToColumn(int column); | |
281 | void EnsureCaretVisible(); | |
282 | void SetCaretPolicy(int policy, int slop=0); | |
f6bcfd97 BP |
283 | int GetLinesOnScreen(); |
284 | bool IsSelectionRectangle(); | |
285 | void SetUseHorizontalScrollBar(bool use); | |
286 | bool GetUseHorizontalScrollBar(); | |
9ce192d4 RD |
287 | |
288 | ||
289 | // Searching | |
290 | int FindText(int minPos, int maxPos, const wxString& text, | |
291 | bool caseSensitive, bool wholeWord); | |
292 | void SearchAnchor(); | |
293 | int SearchNext(const wxString& text, bool caseSensitive, bool wholeWord); | |
294 | int SearchPrev(const wxString& text, bool caseSensitive, bool wholeWord); | |
295 | ||
296 | ||
297 | // Visible whitespace | |
298 | bool GetViewWhitespace(); | |
299 | void SetViewWhitespace(bool visible); | |
300 | ||
301 | ||
302 | // Line endings | |
303 | wxSTC_EOL GetEOLMode(); | |
304 | void SetEOLMode(wxSTC_EOL mode); | |
305 | bool GetViewEOL(); | |
306 | void SetViewEOL(bool visible); | |
307 | void ConvertEOL(wxSTC_EOL mode); | |
308 | ||
309 | ||
310 | // Styling | |
311 | int GetEndStyled(); | |
312 | void StartStyling(int pos, int mask); | |
313 | void SetStyleFor(int length, int style); | |
314 | void SetStyleBytes(int length, char* styleBytes); | |
f6bcfd97 BP |
315 | void SetLineState(int line, int value); |
316 | int GetLineState(int line); | |
9ce192d4 RD |
317 | |
318 | ||
319 | // Style Definition | |
320 | void StyleClearAll(); | |
321 | void StyleResetDefault(); | |
322 | void StyleSetSpec(int styleNum, const wxString& spec); | |
323 | void StyleSetForeground(int styleNum, const wxColour& colour); | |
324 | void StyleSetBackground(int styleNum, const wxColour& colour); | |
325 | void StyleSetFont(int styleNum, wxFont& font); | |
f6bcfd97 | 326 | void StyleSetFontAttr(int styleNum, int size, const wxString& faceName, bool bold=FALSE, bool italic=FALSE, bool underline=FALSE); |
9ce192d4 RD |
327 | void StyleSetBold(int styleNum, bool bold); |
328 | void StyleSetItalic(int styleNum, bool italic); | |
329 | void StyleSetFaceName(int styleNum, const wxString& faceName); | |
330 | void StyleSetSize(int styleNum, int pointSize); | |
331 | void StyleSetEOLFilled(int styleNum, bool fillEOL); | |
f6bcfd97 | 332 | void StyleSetUnderline(int styleNum, bool underline); |
9ce192d4 RD |
333 | |
334 | ||
335 | // Margins in the edit area | |
336 | int GetLeftMargin(); | |
337 | int GetRightMargin(); | |
338 | void SetMargins(int left, int right); | |
339 | ||
340 | ||
341 | // Margins for selection, markers, etc. | |
342 | void SetMarginType(int margin, int type); | |
343 | int GetMarginType(int margin); | |
344 | void SetMarginWidth(int margin, int pixelWidth); | |
345 | int GetMarginWidth(int margin); | |
346 | void SetMarginMask(int margin, int mask); | |
347 | int GetMarginMask(int margin); | |
348 | void SetMarginSensitive(int margin, bool sensitive); | |
349 | bool GetMarginSensitive(int margin); | |
350 | ||
351 | ||
352 | // Selection and Caret styles | |
353 | void SetSelectionForeground(const wxColour& colour); | |
354 | void SetSelectionBackground(const wxColour& colour); | |
355 | void SetCaretForeground(const wxColour& colour); | |
356 | int GetCaretPeriod(); | |
357 | void SetCaretPeriod(int milliseconds); | |
358 | ||
359 | ||
360 | // Other settings | |
361 | void SetBufferedDraw(bool isBuffered); | |
362 | void SetTabWidth(int numChars); | |
f6bcfd97 BP |
363 | void SetIndent(int numChars); |
364 | void SetUseTabs(bool usetabs); | |
365 | void SetLineIndentation(int line, int indentation); | |
366 | int GetLineIndentation(int line); | |
367 | int GetLineIndentationPos(int line); | |
9ce192d4 RD |
368 | void SetWordChars(const wxString& wordChars); |
369 | ||
f6bcfd97 BP |
370 | void SetUsePop(bool usepopup); |
371 | ||
9ce192d4 RD |
372 | |
373 | // Brace highlighting | |
374 | void BraceHighlight(int pos1, int pos2); | |
375 | void BraceBadlight(int pos); | |
376 | int BraceMatch(int pos, int maxReStyle=0); | |
377 | ||
378 | ||
379 | // Markers | |
380 | void MarkerDefine(int markerNumber, int markerSymbol, | |
381 | const wxColour& foreground, | |
382 | const wxColour& background); | |
383 | void MarkerSetType(int markerNumber, int markerSymbol); | |
384 | void MarkerSetForeground(int markerNumber, const wxColour& colour); | |
385 | void MarkerSetBackground(int markerNumber, const wxColour& colour); | |
386 | int MarkerAdd(int line, int markerNumber); | |
387 | void MarkerDelete(int line, int markerNumber); | |
388 | void MarkerDeleteAll(int markerNumber); | |
389 | int MarkerGet(int line); | |
390 | int MarkerGetNextLine(int lineStart, int markerMask); | |
391 | int MarkerGetPrevLine(int lineStart, int markerMask); | |
392 | int MarkerLineFromHandle(int handle); | |
393 | void MarkerDeleteHandle(int handle); | |
394 | ||
395 | ||
396 | // Indicators | |
397 | void IndicatorSetStyle(int indicNum, int indicStyle); | |
398 | int IndicatorGetStyle(int indicNum); | |
399 | void IndicatorSetColour(int indicNum, const wxColour& colour); | |
400 | ||
401 | ||
402 | // Auto completion | |
403 | void AutoCompShow(const wxString& listOfWords); | |
404 | void AutoCompCancel(); | |
405 | bool AutoCompActive(); | |
406 | int AutoCompPosAtStart(); | |
407 | void AutoCompComplete(); | |
408 | void AutoCompStopChars(const wxString& stopChars); | |
f6bcfd97 BP |
409 | void AutoCompSetSeparator(char separator); |
410 | char AutoCompGetSeparator(); | |
411 | void AutoCompSelect(const wxString& stringtoselect); | |
9ce192d4 RD |
412 | |
413 | // Call tips | |
414 | void CallTipShow(int pos, const wxString& text); | |
415 | void CallTipCancel(); | |
416 | bool CallTipActive(); | |
417 | int CallTipPosAtStart(); | |
418 | void CallTipSetHighlight(int start, int end); | |
419 | void CallTipSetBackground(const wxColour& colour); | |
420 | ||
421 | ||
422 | // Key bindings | |
423 | void CmdKeyAssign(int key, int modifiers, int cmd); | |
424 | void CmdKeyClear(int key, int modifiers); | |
425 | void CmdKeyClearAll(); | |
426 | void CmdKeyExecute(int cmd); | |
427 | ||
428 | ||
429 | // Print formatting | |
430 | int FormatRange(bool doDraw, | |
431 | int startPos, | |
432 | int endPos, | |
433 | wxDC* draw, | |
434 | wxDC* target, // Why does it use two? Can they be the same? | |
435 | wxRect renderRect, | |
436 | wxRect pageRect); | |
437 | ||
438 | ||
439 | // Document Sharing (multiple views) | |
440 | void* GetDocument(); | |
441 | void SetDocument(void* document); | |
442 | // TODO: create a wx wrapper for Scintilla's document class | |
443 | ||
444 | ||
67003d1a RD |
445 | // Folding |
446 | int VisibleFromDocLine(int docLine); | |
447 | int DocLineFromVisible(int displayLine); | |
448 | int SetFoldLevel(int line, int level); | |
449 | int GetFoldLevel(int line); | |
f6bcfd97 | 450 | int GetLastChild(int line, int level); |
67003d1a RD |
451 | int GetFoldParent(int line); |
452 | void ShowLines(int lineStart, int lineEnd); | |
453 | void HideLines(int lineStart, int lineEnd); | |
454 | bool GetLineVisible(int line); | |
f6bcfd97 | 455 | void SetFoldExpanded(int line, bool expanded); |
67003d1a RD |
456 | bool GetFoldExpanded(int line); |
457 | void ToggleFold(int line); | |
458 | void EnsureVisible(int line); | |
f6bcfd97 BP |
459 | void SetFoldFlags(int flags); |
460 | ||
461 | ||
462 | // Zooming | |
463 | void ZoomIn(); | |
464 | void ZoomOut(); | |
465 | void SetZoom(int zoom); | |
466 | int GetZoom(); | |
9ce192d4 RD |
467 | |
468 | ||
469 | // Long Lines | |
470 | int GetEdgeColumn(); | |
471 | void SetEdgeColumn(int column); | |
472 | wxSTC_EDGE GetEdgeMode(); | |
473 | void SetEdgeMode(wxSTC_EDGE mode); | |
474 | wxColour GetEdgeColour(); | |
475 | void SetEdgeColour(const wxColour& colour); | |
476 | ||
477 | ||
478 | // Lexer | |
479 | void SetLexer(wxSTC_LEX lexer); | |
480 | wxSTC_LEX GetLexer(); | |
481 | void Colourise(int start, int end); | |
482 | void SetProperty(const wxString& key, const wxString& value); | |
483 | void SetKeywords(int keywordSet, const wxString& keywordList); | |
484 | ||
485 | ||
f6bcfd97 BP |
486 | // Event mask for Modified Event |
487 | void SetModEventMask(int mask); | |
488 | //int GetModEventMask(); | |
9ce192d4 | 489 | |
f6bcfd97 | 490 | #ifndef SWIG |
9ce192d4 RD |
491 | private: |
492 | // Event handlers | |
493 | void OnPaint(wxPaintEvent& evt); | |
494 | void OnScrollWin(wxScrollWinEvent& evt); | |
495 | void OnSize(wxSizeEvent& evt); | |
496 | void OnMouseLeftDown(wxMouseEvent& evt); | |
497 | void OnMouseMove(wxMouseEvent& evt); | |
498 | void OnMouseLeftUp(wxMouseEvent& evt); | |
499 | void OnMouseRightUp(wxMouseEvent& evt); | |
500 | void OnChar(wxKeyEvent& evt); | |
f6bcfd97 | 501 | void OnKeyDown(wxKeyEvent& evt); |
9ce192d4 RD |
502 | void OnLoseFocus(wxFocusEvent& evt); |
503 | void OnGainFocus(wxFocusEvent& evt); | |
504 | void OnSysColourChanged(wxSysColourChangedEvent& evt); | |
505 | void OnEraseBackground(wxEraseEvent& evt); | |
506 | void OnMenu(wxCommandEvent& evt); | |
f6bcfd97 | 507 | void OnListBox(wxCommandEvent& evt); |
9ce192d4 RD |
508 | |
509 | ||
510 | // Turn notifications from Scintilla into events | |
511 | void NotifyChange(); | |
512 | void NotifyParent(SCNotification* scn); | |
513 | ||
514 | long SendMsg(int msg, long wp=0, long lp=0); | |
515 | ||
516 | private: | |
517 | DECLARE_EVENT_TABLE() | |
f6bcfd97 | 518 | DECLARE_CLASS(wxStyledTextCtrl) |
9ce192d4 RD |
519 | |
520 | ScintillaWX* m_swx; | |
521 | wxStopWatch m_stopWatch; | |
522 | bool m_readOnly; | |
523 | wxSTC_UndoType m_undoType; | |
524 | ||
525 | ||
526 | friend class ScintillaWX; | |
527 | friend class Platform; | |
f6bcfd97 | 528 | #endif |
9ce192d4 RD |
529 | }; |
530 | ||
531 | //---------------------------------------------------------------------- | |
532 | ||
533 | class wxStyledTextEvent : public wxCommandEvent { | |
534 | public: | |
f6bcfd97 | 535 | wxStyledTextEvent(wxEventType commandType=0, int id=0); |
9ce192d4 RD |
536 | ~wxStyledTextEvent() {} |
537 | ||
538 | void SetPosition(int pos) { m_position = pos; } | |
539 | void SetKey(int k) { m_key = k; } | |
540 | void SetModifiers(int m) { m_modifiers = m; } | |
541 | void SetModificationType(int t) { m_modificationType = t; } | |
542 | void SetText(const char* t) { m_text = t; } | |
543 | void SetLength(int len) { m_length = len; } | |
544 | void SetLinesAdded(int num) { m_linesAdded = num; } | |
545 | void SetLine(int val) { m_line = val; } | |
546 | void SetFoldLevelNow(int val) { m_foldLevelNow = val; } | |
547 | void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } | |
548 | void SetMargin(int val) { m_margin = val; } | |
549 | void SetMessage(int val) { m_message = val; } | |
550 | void SetWParam(int val) { m_wParam = val; } | |
551 | void SetLParam(int val) { m_lParam = val; } | |
552 | ||
553 | int GetPosition() const { return m_position; } | |
554 | int GetKey() const { return m_key; } | |
555 | int GetModifiers() const { return m_modifiers; } | |
556 | int GetModificationType() const { return m_modificationType; } | |
557 | wxString GetText() const { return m_text; } | |
558 | int GetLength() const { return m_length; } | |
559 | int GetLinesAdded() const { return m_linesAdded; } | |
560 | int GetLine() const { return m_line; } | |
561 | int GetFoldLevelNow() const { return m_foldLevelNow; } | |
562 | int GetFoldLevelPrev() const { return m_foldLevelPrev; } | |
563 | int GetMargin() const { return m_margin; } | |
564 | int GetMessage() const { return m_message; } | |
565 | int GetWParam() const { return m_wParam; } | |
566 | int GetLParam() const { return m_lParam; } | |
567 | ||
568 | bool GetShift() const; | |
569 | bool GetControl() const; | |
570 | bool GetAlt() const; | |
571 | ||
572 | void CopyObject(wxObject& obj) const; | |
573 | ||
f6bcfd97 | 574 | #ifndef SWIG |
9ce192d4 | 575 | private: |
f6bcfd97 BP |
576 | DECLARE_DYNAMIC_CLASS(wxStyledTextEvent) |
577 | ||
9ce192d4 RD |
578 | int m_position; |
579 | int m_key; | |
580 | int m_modifiers; | |
581 | ||
582 | int m_modificationType; // wxEVT_STC_MODIFIED | |
583 | wxString m_text; | |
584 | int m_length; | |
585 | int m_linesAdded; | |
586 | int m_line; | |
587 | int m_foldLevelNow; | |
588 | int m_foldLevelPrev; | |
589 | ||
590 | int m_margin; // wxEVT_STC_MARGINCLICK | |
591 | ||
592 | int m_message; // wxEVT_STC_MACRORECORD | |
593 | int m_wParam; | |
594 | int m_lParam; | |
f6bcfd97 | 595 | #endif |
9ce192d4 RD |
596 | }; |
597 | ||
598 | ||
f6bcfd97 | 599 | // Event types |
9ce192d4 RD |
600 | enum { |
601 | wxEVT_STC_CHANGE = 1650, | |
602 | wxEVT_STC_STYLENEEDED, | |
603 | wxEVT_STC_CHARADDED, | |
604 | wxEVT_STC_UPDATEUI, | |
605 | wxEVT_STC_SAVEPOINTREACHED, | |
606 | wxEVT_STC_SAVEPOINTLEFT, | |
607 | wxEVT_STC_ROMODIFYATTEMPT, | |
608 | wxEVT_STC_DOUBLECLICK, | |
609 | wxEVT_STC_MODIFIED, | |
610 | wxEVT_STC_KEY, | |
611 | wxEVT_STC_MACRORECORD, | |
612 | wxEVT_STC_MARGINCLICK, | |
613 | wxEVT_STC_NEEDSHOWN | |
614 | }; | |
615 | ||
f6bcfd97 BP |
616 | // Modification and action types |
617 | const int wxSTC_MOD_INSERTTEXT = 0x1; | |
618 | const int wxSTC_MOD_DELETETEXT = 0x2; | |
619 | const int wxSTC_MOD_CHANGESTYLE = 0x4; | |
620 | const int wxSTC_MOD_CHANGEFOLD = 0x8; | |
621 | const int wxSTC_PERFORMED_USER = 0x10; | |
622 | const int wxSTC_PERFORMED_UNDO = 0x20; | |
623 | const int wxSTC_PERFORMED_REDO = 0x40; | |
624 | const int wxSTC_LASTSTEPINUNDOREDO = 0x100; | |
625 | const int wxSTC_MOD_CHANGEMARKER = 0x200; | |
626 | const int wxSTC_MOD_BEFOREINSERT = 0x400; | |
627 | const int wxSTC_MOD_BEFOREDELETE = 0x800; | |
628 | ||
629 | ||
630 | #ifndef SWIG | |
9ce192d4 RD |
631 | typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); |
632 | ||
633 | #define EVT_STC_CHANGE(id, fn) { wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
634 | #define EVT_STC_STYLENEEDED(id, fn) { wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
635 | #define EVT_STC_CHARADDED(id, fn) { wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
636 | #define EVT_STC_UPDATEUI(id, fn) { wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
637 | #define EVT_STC_SAVEPOINTREACHED(id, fn) { wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
638 | #define EVT_STC_SAVEPOINTLEFT(id, fn) { wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
639 | #define EVT_STC_ROMODIFYATTEMPT(id, fn) { wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
640 | #define EVT_STC_DOUBLECLICK(id, fn) { wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
641 | #define EVT_STC_MODIFIED(id, fn) { wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
f6bcfd97 BP |
642 | #define EVT_STC_KEY(id, fn) { wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, |
643 | #define EVT_STC_MACRORECORD(id, fn) { wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
644 | #define EVT_STC_MARGINCLICK(id, fn) { wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
645 | #define EVT_STC_NEEDSHOWN(id, fn) { wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL }, | |
9ce192d4 | 646 | |
f6bcfd97 | 647 | #endif |
9ce192d4 RD |
648 | |
649 | //---------------------------------------------------------------------- | |
650 | //---------------------------------------------------------------------- | |
651 | #endif | |
652 | ||
653 |