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