]> git.saurik.com Git - wxWidgets.git/blame - contrib/src/stc/stc.h.in
Actually check if the menu should be shown before popping it up
[wxWidgets.git] / contrib / src / stc / stc.h.in
CommitLineData
f97d84a6
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>
a29a241f 25#include <wx/dnd.h>
f97d84a6 26
9c46ea66
RD
27//----------------------------------------------------------------------
28
29// Should a wxPopupWindow be used for the call tips and autocomplete windows?
30#ifndef wxSTC_USE_POPUP
31#define wxSTC_USE_POPUP 1
32#endif
33
f97d84a6
RD
34//----------------------------------------------------------------------
35// BEGIN generated section. The following code is automatically generated
36// by gen_iface.py. Do not edit this file. Edit stc.h.in instead
37// and regenerate
38
39%(VALUES)s
40
41// END of generated section
f97d84a6
RD
42//----------------------------------------------------------------------
43
44class ScintillaWX; // forward declare
45class WordList;
46struct SCNotification;
47
48
49extern const wxChar* wxSTCNameStr;
50
51//----------------------------------------------------------------------
52
53class wxStyledTextCtrl : public wxControl {
54public:
55
56#ifdef SWIG
57 wxStyledTextCtrl(wxWindow *parent, wxWindowID id,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize, long style = 0,
137b5242 60 const wxString& name = wxPySTCNameStr);
0122b7e3
RD
61 %%pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
62
f97d84a6
RD
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
65ec6247
RD
147
148 // Send a message to Scintilla
149 long SendMsg(int msg, long wp=0, long lp=0);
150
5fa4613c
RD
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
0b9dfbc0
RD
159 // Can be used to prevent the EVT_CHAR handler from adding the char
160 bool GetLastKeydownProcessed() { return m_lastKeyDownConsumed; }
161 void SetLastKeydownProcessed(bool val) { m_lastKeyDownConsumed = val; }
162
163
f97d84a6
RD
164//----------------------------------------------------------------------
165
166
167#ifndef SWIG
168private:
169 // Event handlers
170 void OnPaint(wxPaintEvent& evt);
171 void OnScrollWin(wxScrollWinEvent& evt);
5fa4613c 172 void OnScroll(wxScrollEvent& evt);
f97d84a6
RD
173 void OnSize(wxSizeEvent& evt);
174 void OnMouseLeftDown(wxMouseEvent& evt);
175 void OnMouseMove(wxMouseEvent& evt);
176 void OnMouseLeftUp(wxMouseEvent& evt);
ddf2da08 177 void OnMouseRightUp(wxMouseEvent& evt);
65ec6247 178 void OnContextMenu(wxContextMenuEvent& evt);
37d62433 179 void OnMouseWheel(wxMouseEvent& evt);
f97d84a6
RD
180 void OnChar(wxKeyEvent& evt);
181 void OnKeyDown(wxKeyEvent& evt);
182 void OnLoseFocus(wxFocusEvent& evt);
183 void OnGainFocus(wxFocusEvent& evt);
184 void OnSysColourChanged(wxSysColourChangedEvent& evt);
185 void OnEraseBackground(wxEraseEvent& evt);
186 void OnMenu(wxCommandEvent& evt);
187 void OnListBox(wxCommandEvent& evt);
188
189
190 // Turn notifications from Scintilla into events
191 void NotifyChange();
192 void NotifyParent(SCNotification* scn);
193
a29a241f 194
f97d84a6
RD
195private:
196 DECLARE_EVENT_TABLE()
197 DECLARE_CLASS(wxStyledTextCtrl)
198
199 ScintillaWX* m_swx;
200 wxStopWatch m_stopWatch;
5fa4613c
RD
201 wxScrollBar* m_vScrollBar;
202 wxScrollBar* m_hScrollBar;
f97d84a6 203
d6582821 204 bool m_lastKeyDownConsumed;
f97d84a6
RD
205
206 friend class ScintillaWX;
207 friend class Platform;
208#endif
209};
210
211//----------------------------------------------------------------------
212
92bbd64f
RD
213// SWIG can't handle "#if" type of conditionals, onlu "#ifdef"
214#ifdef SWIG
215#define STC_USE_DND 1
216#else
217#if wxUSE_DRAG_AND_DROP
218#define STC_USE_DND 1
219#endif
220#endif
221
f97d84a6
RD
222class wxStyledTextEvent : public wxCommandEvent {
223public:
224 wxStyledTextEvent(wxEventType commandType=0, int id=0);
4161723f
RD
225#ifndef SWIG
226 wxStyledTextEvent(const wxStyledTextEvent& event);
227#endif
f97d84a6
RD
228 ~wxStyledTextEvent() {}
229
a29a241f
RD
230 void SetPosition(int pos) { m_position = pos; }
231 void SetKey(int k) { m_key = k; }
232 void SetModifiers(int m) { m_modifiers = m; }
233 void SetModificationType(int t) { m_modificationType = t; }
10ef30eb 234 void SetText(const wxString& t) { m_text = t; }
a29a241f
RD
235 void SetLength(int len) { m_length = len; }
236 void SetLinesAdded(int num) { m_linesAdded = num; }
237 void SetLine(int val) { m_line = val; }
238 void SetFoldLevelNow(int val) { m_foldLevelNow = val; }
239 void SetFoldLevelPrev(int val) { m_foldLevelPrev = val; }
240 void SetMargin(int val) { m_margin = val; }
241 void SetMessage(int val) { m_message = val; }
242 void SetWParam(int val) { m_wParam = val; }
243 void SetLParam(int val) { m_lParam = val; }
244 void SetListType(int val) { m_listType = val; }
245 void SetX(int val) { m_x = val; }
246 void SetY(int val) { m_y = val; }
247 void SetDragText(const wxString& val) { m_dragText = val; }
248 void SetDragAllowMove(bool val) { m_dragAllowMove = val; }
92bbd64f 249#ifdef STC_USE_DND
a29a241f 250 void SetDragResult(wxDragResult val) { m_dragResult = val; }
92bbd64f 251#endif
f97d84a6
RD
252
253 int GetPosition() const { return m_position; }
254 int GetKey() const { return m_key; }
255 int GetModifiers() const { return m_modifiers; }
256 int GetModificationType() const { return m_modificationType; }
257 wxString GetText() const { return m_text; }
258 int GetLength() const { return m_length; }
259 int GetLinesAdded() const { return m_linesAdded; }
260 int GetLine() const { return m_line; }
261 int GetFoldLevelNow() const { return m_foldLevelNow; }
262 int GetFoldLevelPrev() const { return m_foldLevelPrev; }
263 int GetMargin() const { return m_margin; }
264 int GetMessage() const { return m_message; }
265 int GetWParam() const { return m_wParam; }
266 int GetLParam() const { return m_lParam; }
65ec6247
RD
267 int GetListType() const { return m_listType; }
268 int GetX() const { return m_x; }
269 int GetY() const { return m_y; }
a29a241f
RD
270 wxString GetDragText() { return m_dragText; }
271 bool GetDragAllowMove() { return m_dragAllowMove; }
92bbd64f 272#ifdef STC_USE_DND
a29a241f 273 wxDragResult GetDragResult() { return m_dragResult; }
92bbd64f 274#endif
f97d84a6
RD
275
276 bool GetShift() const;
277 bool GetControl() const;
278 bool GetAlt() const;
279
5fa4613c 280 virtual wxEvent* Clone() const { return new wxStyledTextEvent(*this); }
f97d84a6
RD
281
282#ifndef SWIG
283private:
284 DECLARE_DYNAMIC_CLASS(wxStyledTextEvent)
285
286 int m_position;
287 int m_key;
288 int m_modifiers;
289
290 int m_modificationType; // wxEVT_STC_MODIFIED
291 wxString m_text;
292 int m_length;
293 int m_linesAdded;
294 int m_line;
295 int m_foldLevelNow;
296 int m_foldLevelPrev;
297
298 int m_margin; // wxEVT_STC_MARGINCLICK
299
300 int m_message; // wxEVT_STC_MACRORECORD
301 int m_wParam;
302 int m_lParam;
65ec6247
RD
303
304 int m_listType;
305 int m_x;
306 int m_y;
a29a241f
RD
307
308 wxString m_dragText; // wxEVT_STC_START_DRAG, wxEVT_STC_DO_DROP
309 bool m_dragAllowMove; // wxEVT_STC_START_DRAG
310
92bbd64f 311#if wxUSE_DRAG_AND_DROP
a29a241f 312 wxDragResult m_dragResult; // wxEVT_STC_DRAG_OVER,wxEVT_STC_DO_DROP
f97d84a6 313#endif
92bbd64f 314#endif
f97d84a6
RD
315};
316
d25f5fbb
RD
317#ifndef SWIG
318BEGIN_DECLARE_EVENT_TYPES()
65ec6247
RD
319 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE, 1650)
320 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED, 1651)
321 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED, 1652)
322 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED, 1653)
323 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT, 1654)
324 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT, 1655)
325 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY, 1656)
326 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK, 1657)
327 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI, 1658)
328 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED, 1659)
329 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD, 1660)
330 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK, 1661)
331 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN, 1662)
332 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED, 1663)
333 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_PAINTED, 1664)
334 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_USERLISTSELECTION, 1665)
335 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED, 1666)
336 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART, 1667)
337 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND, 1668)
a29a241f
RD
338 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_START_DRAG, 1669)
339 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DRAG_OVER, 1670)
340 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DO_DROP, 1671)
d25f5fbb
RD
341END_DECLARE_EVENT_TYPES()
342#else
343 enum {
344 wxEVT_STC_CHANGE,
345 wxEVT_STC_STYLENEEDED,
346 wxEVT_STC_CHARADDED,
d25f5fbb
RD
347 wxEVT_STC_SAVEPOINTREACHED,
348 wxEVT_STC_SAVEPOINTLEFT,
349 wxEVT_STC_ROMODIFYATTEMPT,
65ec6247 350 wxEVT_STC_KEY,
d25f5fbb 351 wxEVT_STC_DOUBLECLICK,
65ec6247 352 wxEVT_STC_UPDATEUI,
d25f5fbb 353 wxEVT_STC_MODIFIED,
d25f5fbb
RD
354 wxEVT_STC_MACRORECORD,
355 wxEVT_STC_MARGINCLICK,
356 wxEVT_STC_NEEDSHOWN,
65ec6247
RD
357 wxEVT_STC_POSCHANGED,
358 wxEVT_STC_PAINTED,
359 wxEVT_STC_USERLISTSELECTION,
360 wxEVT_STC_URIDROPPED,
361 wxEVT_STC_DWELLSTART,
362 wxEVT_STC_DWELLEND,
a29a241f
RD
363 wxEVT_STC_START_DRAG,
364 wxEVT_STC_DRAG_OVER,
365 wxEVT_STC_DO_DROP,
d25f5fbb
RD
366 };
367#endif
f97d84a6 368
f97d84a6
RD
369
370
371#ifndef SWIG
372typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&);
373
65ec6247
RD
374#define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
375#define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
376#define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
377#define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
378#define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
379#define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
380#define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
381#define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
382#define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
383#define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
384#define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
385#define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
386#define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
387#define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
388#define EVT_STC_PAINTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_PAINTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
389#define EVT_STC_USERLISTSELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_USERLISTSELECTION, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
390#define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
391#define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
392#define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
a29a241f
RD
393#define EVT_STC_START_DRAG(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_START_DRAG, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
394#define EVT_STC_DRAG_OVER(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DRAG_OVER, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
395#define EVT_STC_DO_DROP(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DO_DROP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
1bc32508 396#endif
f97d84a6
RD
397
398//----------------------------------------------------------------------
0c5b83b0
RD
399// Utility functions used within wxSTC
400
401#ifndef SWIG
402
403inline wxString stc2wx(const char* str) {
404#if wxUSE_UNICODE
405 return wxString(str, wxConvUTF8);
406#else
407 return wxString(str);
408#endif
409}
410
411inline wxString stc2wx(const char* str, size_t len) {
412#if wxUSE_UNICODE
413 return wxString(str, wxConvUTF8, len);
414#else
415 return wxString(str, len);
416#endif
417}
418
419#if wxUSE_UNICODE
420inline const wxWX2MBbuf wx2stc(const wxString& str) {
421 return str.mb_str(wxConvUTF8);
422}
423#else
424inline const wxWX2MBbuf wx2stc(const wxString& str) {
425 return str.mbc_str();
426}
427#endif
428
429#endif
430
431
f97d84a6
RD
432//----------------------------------------------------------------------
433#endif
434
435