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