]>
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 <wx/dnd.h> | |
26 | ||
27 | //---------------------------------------------------------------------- | |
28 | // BEGIN generated section. The following code is automatically generated | |
29 | // by gen_iface.py. Do not edit this file. Edit stc.h.in instead | |
30 | // and regenerate | |
31 | ||
32 | %(VALUES)s | |
33 | ||
34 | // END of generated section | |
35 | //---------------------------------------------------------------------- | |
36 | // Others | |
37 | ||
38 | #define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | \ | |
39 | (1 << wxSTC_MARKNUM_FOLDEROPEN) | \ | |
40 | (1 << wxSTC_MARKNUM_FOLDERSUB) | \ | |
41 | (1 << wxSTC_MARKNUM_FOLDERTAIL) | \ | |
42 | (1 << wxSTC_MARKNUM_FOLDERMIDTAIL) | \ | |
43 | (1 << wxSTC_MARKNUM_FOLDEROPENMID) | \ | |
44 | (1 << wxSTC_MARKNUM_FOLDEREND)) | |
45 | ||
46 | ||
47 | ||
48 | ||
49 | //---------------------------------------------------------------------- | |
50 | ||
51 | class ScintillaWX; // forward declare | |
52 | class WordList; | |
53 | struct SCNotification; | |
54 | ||
55 | ||
56 | extern const wxChar* wxSTCNameStr; | |
57 | ||
58 | //---------------------------------------------------------------------- | |
59 | ||
60 | class wxStyledTextCtrl : public wxControl { | |
61 | public: | |
62 | ||
63 | #ifdef SWIG | |
64 | wxStyledTextCtrl(wxWindow *parent, wxWindowID id, | |
65 | const wxPoint& pos = wxDefaultPosition, | |
66 | const wxSize& size = wxDefaultSize, long style = 0, | |
67 | const char* name = "styledtext"); | |
68 | %%pragma(python) addtomethod = "__init__:self._setOORInfo(self)" | |
69 | ||
70 | #else | |
71 | wxStyledTextCtrl(wxWindow *parent, wxWindowID id, | |
72 | const wxPoint& pos = wxDefaultPosition, | |
73 | const wxSize& size = wxDefaultSize, long style = 0, | |
74 | const wxString& name = wxSTCNameStr); | |
75 | #endif | |
76 | ||
77 | ||
78 | #ifndef SWIG | |
79 | ~wxStyledTextCtrl(); | |
80 | #endif | |
81 | ||
82 | //---------------------------------------------------------------------- | |
83 | // BEGIN generated section. The following code is automatically generated | |
84 | // by gen_iface.py. Do not edit this file. Edit stc.h.in instead | |
85 | // and regenerate | |
86 | ||
87 | %(METHOD_DEFS)s | |
88 | ||
89 | // END of generated section | |
90 | //---------------------------------------------------------------------- | |
91 | // Others... | |
92 | ||
93 | ||
94 | // Returns the line number of the line with the caret. | |
95 | int GetCurrentLine(); | |
96 | ||
97 | // Extract style settings from a spec-string which is composed of one or | |
98 | // more of the following comma separated elements: | |
99 | // | |
100 | // bold turns on bold | |
101 | // italic turns on italics | |
102 | // fore:#RRGGBB sets the foreground colour | |
103 | // back:#RRGGBB sets the background colour | |
104 | // face:[facename] sets the font face name to use | |
105 | // size:[num] sets the font size in points | |
106 | // eol turns on eol filling | |
107 | // underline turns on underlining | |
108 | // | |
109 | void StyleSetSpec(int styleNum, const wxString& spec); | |
110 | ||
111 | ||
112 | ||
113 | // Set style size, face, bold, italic, and underline attributes from | |
114 | // a wxFont's attributes. | |
115 | void StyleSetFont(int styleNum, wxFont& font); | |
116 | ||
117 | ||
118 | ||
119 | // Set all font style attributes at once. | |
120 | void StyleSetFontAttr(int styleNum, int size, | |
121 | const wxString& faceName, | |
122 | bool bold, bool italic, | |
123 | bool underline); | |
124 | ||
125 | ||
126 | ||
127 | // Perform one of the operations defined by the wxSTC_CMD_* constants. | |
128 | void CmdKeyExecute(int cmd); | |
129 | ||
130 | ||
131 | ||
132 | // Set the left and right margin in the edit area, measured in pixels. | |
133 | void SetMargins(int left, int right); | |
134 | ||
135 | ||
136 | // Retrieve the start and end positions of the current selection. | |
137 | #ifdef SWIG | |
138 | void GetSelection(int* OUTPUT, int* OUTPUT); | |
139 | #else | |
140 | void GetSelection(int* startPos, int* endPos); | |
141 | #endif | |
142 | ||
143 | // Retrieve the point in the window where a position is displayed. | |
144 | wxPoint PointFromPosition(int pos); | |
145 | ||
146 | ||
147 | // Scroll enough to make the given line visible | |
148 | void ScrollToLine(int line); | |
149 | ||
150 | ||
151 | // Scroll enough to make the given column visible | |
152 | void ScrollToColumn(int column); | |
153 | ||
154 | ||
155 | // Send a message to Scintilla | |
156 | long SendMsg(int msg, long wp=0, long lp=0); | |
157 | ||
158 | ||
159 | // Set the vertical scrollbar to use instead of the ont that's built-in. | |
160 | void SetVScrollBar(wxScrollBar* bar) { m_vScrollBar = bar; } | |
161 | ||
162 | ||
163 | // Set the horizontal scrollbar to use instead of the ont that's built-in. | |
164 | void SetHScrollBar(wxScrollBar* bar) { m_hScrollBar = bar; } | |
165 | ||
166 | //---------------------------------------------------------------------- | |
167 | ||
168 | ||
169 | #ifndef SWIG | |
170 | private: | |
171 | // Event handlers | |
172 | void OnPaint(wxPaintEvent& evt); | |
173 | void OnScrollWin(wxScrollWinEvent& evt); | |
174 | void OnScroll(wxScrollEvent& evt); | |
175 | void OnSize(wxSizeEvent& evt); | |
176 | void OnMouseLeftDown(wxMouseEvent& evt); | |
177 | void OnMouseMove(wxMouseEvent& evt); | |
178 | void OnMouseLeftUp(wxMouseEvent& evt); | |
179 | void OnMouseRightUp(wxMouseEvent& evt); | |
180 | void OnContextMenu(wxContextMenuEvent& evt); | |
181 | void OnMouseWheel(wxMouseEvent& evt); | |
182 | void OnChar(wxKeyEvent& evt); | |
183 | void OnKeyDown(wxKeyEvent& evt); | |
184 | void OnLoseFocus(wxFocusEvent& evt); | |
185 | void OnGainFocus(wxFocusEvent& evt); | |
186 | void OnSysColourChanged(wxSysColourChangedEvent& evt); | |
187 | void OnEraseBackground(wxEraseEvent& evt); | |
188 | void OnMenu(wxCommandEvent& evt); | |
189 | void OnListBox(wxCommandEvent& evt); | |
190 | ||
191 | ||
192 | // Turn notifications from Scintilla into events | |
193 | void NotifyChange(); | |
194 | void NotifyParent(SCNotification* scn); | |
195 | ||
196 | ||
197 | private: | |
198 | DECLARE_EVENT_TABLE() | |
199 | DECLARE_CLASS(wxStyledTextCtrl) | |
200 | ||
201 | ScintillaWX* m_swx; | |
202 | wxStopWatch m_stopWatch; | |
203 | wxScrollBar* m_vScrollBar; | |
204 | wxScrollBar* m_hScrollBar; | |
205 | ||
206 | bool m_lastKeyDownConsumed; | |
207 | ||
208 | friend class ScintillaWX; | |
209 | friend class Platform; | |
210 | #endif | |
211 | }; | |
212 | ||
213 | //---------------------------------------------------------------------- | |
214 | ||
215 | class wxStyledTextEvent : public wxCommandEvent { | |
216 | public: | |
217 | wxStyledTextEvent(wxEventType commandType=0, int id=0); | |
218 | #ifndef SWIG | |
219 | wxStyledTextEvent(const wxStyledTextEvent& event); | |
220 | #endif | |
221 | ~wxStyledTextEvent() {} | |
222 | ||
223 | void SetPosition(int pos) { m_position = pos; } | |
224 | void SetKey(int k) { m_key = k; } | |
225 | void SetModifiers(int m) { m_modifiers = m; } | |
226 | void SetModificationType(int t) { m_modificationType = t; } | |
227 | void SetText(const char* t) { m_text = t; } | |
228 | void SetLength(int len) { m_length = len; } | |
229 | void SetLinesAdded(int num) { m_linesAdded = num; } | |
230 | void SetLine(int val) { m_line = val; } | |
231 | void SetFoldLevelNow(int val) { m_foldLevelNow = val; } | |
232 | void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; } | |
233 | void SetMargin(int val) { m_margin = val; } | |
234 | void SetMessage(int val) { m_message = val; } | |
235 | void SetWParam(int val) { m_wParam = val; } | |
236 | void SetLParam(int val) { m_lParam = val; } | |
237 | void SetListType(int val) { m_listType = val; } | |
238 | void SetX(int val) { m_x = val; } | |
239 | void SetY(int val) { m_y = val; } | |
240 | void SetDragText(const wxString& val) { m_dragText = val; } | |
241 | void SetDragAllowMove(bool val) { m_dragAllowMove = val; } | |
242 | void SetDragResult(wxDragResult val) { m_dragResult = val; } | |
243 | ||
244 | int GetPosition() const { return m_position; } | |
245 | int GetKey() const { return m_key; } | |
246 | int GetModifiers() const { return m_modifiers; } | |
247 | int GetModificationType() const { return m_modificationType; } | |
248 | wxString GetText() const { return m_text; } | |
249 | int GetLength() const { return m_length; } | |
250 | int GetLinesAdded() const { return m_linesAdded; } | |
251 | int GetLine() const { return m_line; } | |
252 | int GetFoldLevelNow() const { return m_foldLevelNow; } | |
253 | int GetFoldLevelPrev() const { return m_foldLevelPrev; } | |
254 | int GetMargin() const { return m_margin; } | |
255 | int GetMessage() const { return m_message; } | |
256 | int GetWParam() const { return m_wParam; } | |
257 | int GetLParam() const { return m_lParam; } | |
258 | int GetListType() const { return m_listType; } | |
259 | int GetX() const { return m_x; } | |
260 | int GetY() const { return m_y; } | |
261 | wxString GetDragText() { return m_dragText; } | |
262 | bool GetDragAllowMove() { return m_dragAllowMove; } | |
263 | wxDragResult GetDragResult() { return m_dragResult; } | |
264 | ||
265 | bool GetShift() const; | |
266 | bool GetControl() const; | |
267 | bool GetAlt() const; | |
268 | ||
269 | virtual wxEvent* Clone() const { return new wxStyledTextEvent(*this); } | |
270 | ||
271 | #ifndef SWIG | |
272 | private: | |
273 | DECLARE_DYNAMIC_CLASS(wxStyledTextEvent) | |
274 | ||
275 | int m_position; | |
276 | int m_key; | |
277 | int m_modifiers; | |
278 | ||
279 | int m_modificationType; // wxEVT_STC_MODIFIED | |
280 | wxString m_text; | |
281 | int m_length; | |
282 | int m_linesAdded; | |
283 | int m_line; | |
284 | int m_foldLevelNow; | |
285 | int m_foldLevelPrev; | |
286 | ||
287 | int m_margin; // wxEVT_STC_MARGINCLICK | |
288 | ||
289 | int m_message; // wxEVT_STC_MACRORECORD | |
290 | int m_wParam; | |
291 | int m_lParam; | |
292 | ||
293 | int m_listType; | |
294 | int m_x; | |
295 | int m_y; | |
296 | ||
297 | wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP | |
298 | bool m_dragAllowMove; // wxEVT_STC_START_DRAG | |
299 | ||
300 | wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP | |
301 | #endif | |
302 | }; | |
303 | ||
304 | #ifndef SWIG | |
305 | BEGIN_DECLARE_EVENT_TYPES() | |
306 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650) | |
307 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651) | |
308 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652) | |
309 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1653) | |
310 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1654) | |
311 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1655) | |
312 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1656) | |
313 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657) | |
314 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1658) | |
315 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1659) | |
316 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660) | |
317 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661) | |
318 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662) | |
319 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663) | |
320 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_PAINTED, 1664) | |
321 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_USERLISTSELECTION, 1665) | |
322 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666) | |
323 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667) | |
324 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668) | |
325 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_START_DRAG, 1669) | |
326 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DRAG_OVER, 1670) | |
327 | DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DO_DROP, 1671) | |
328 | END_DECLARE_EVENT_TYPES() | |
329 | #else | |
330 | enum { | |
331 | wxEVT_STC_CHANGE, | |
332 | wxEVT_STC_STYLENEEDED, | |
333 | wxEVT_STC_CHARADDED, | |
334 | wxEVT_STC_SAVEPOINTREACHED, | |
335 | wxEVT_STC_SAVEPOINTLEFT, | |
336 | wxEVT_STC_ROMODIFYATTEMPT, | |
337 | wxEVT_STC_KEY, | |
338 | wxEVT_STC_DOUBLECLICK, | |
339 | wxEVT_STC_UPDATEUI, | |
340 | wxEVT_STC_MODIFIED, | |
341 | wxEVT_STC_MACRORECORD, | |
342 | wxEVT_STC_MARGINCLICK, | |
343 | wxEVT_STC_NEEDSHOWN, | |
344 | wxEVT_STC_POSCHANGED, | |
345 | wxEVT_STC_PAINTED, | |
346 | wxEVT_STC_USERLISTSELECTION, | |
347 | wxEVT_STC_URIDROPPED, | |
348 | wxEVT_STC_DWELLSTART, | |
349 | wxEVT_STC_DWELLEND, | |
350 | wxEVT_STC_START_DRAG, | |
351 | wxEVT_STC_DRAG_OVER, | |
352 | wxEVT_STC_DO_DROP, | |
353 | }; | |
354 | #endif | |
355 | ||
356 | ||
357 | ||
358 | #ifndef SWIG | |
359 | typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); | |
360 | ||
361 | #define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
362 | #define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
363 | #define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
364 | #define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
365 | #define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
366 | #define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
367 | #define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
368 | #define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
369 | #define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
370 | #define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
371 | #define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
372 | #define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
373 | #define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
374 | #define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
375 | #define EVT_STC_PAINTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_PAINTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
376 | #define EVT_STC_USERLISTSELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_USERLISTSELECTION, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
377 | #define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
378 | #define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
379 | #define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
380 | #define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
381 | #define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
382 | #define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ), | |
383 | #endif | |
384 | ||
385 | //---------------------------------------------------------------------- | |
386 | //---------------------------------------------------------------------- | |
387 | #endif | |
388 | ||
389 |