1 ////////////////////////////////////////////////////////////////////////////
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.
14 // Created: 13-Jan-2000
16 // Copyright: (c) 2000 by Total Control Software
17 // Licence: wxWindows license
18 /////////////////////////////////////////////////////////////////////////////
26 //----------------------------------------------------------------------
27 // BEGIN generated section. The following code is automatically generated
28 // by gen_iface.py. Do not edit this file. Edit stc.h.in instead
33 // END of generated section
34 //----------------------------------------------------------------------
37 #define wxSTC_MASK_FOLDERS ((1 << wxSTC_MARKNUM_FOLDER) | (1 << wxSTC_MARKNUM_FOLDEROPEN))
41 //----------------------------------------------------------------------
43 class ScintillaWX
; // forward declare
45 struct SCNotification
;
48 extern const wxChar
* wxSTCNameStr
;
50 //----------------------------------------------------------------------
52 class wxStyledTextCtrl
: public wxControl
{
56 wxStyledTextCtrl(wxWindow
*parent
, wxWindowID id
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
, long style
= 0,
59 const char* name
= "styledtext");
60 %%pragma
(python
) addtomethod
= "__init__:self._setOORInfo(self)"
63 wxStyledTextCtrl(wxWindow
*parent
, wxWindowID id
,
64 const wxPoint
& pos
= wxDefaultPosition
,
65 const wxSize
& size
= wxDefaultSize
, long style
= 0,
66 const wxString
& name
= wxSTCNameStr
);
74 //----------------------------------------------------------------------
75 // BEGIN generated section. The following code is automatically generated
76 // by gen_iface.py. Do not edit this file. Edit stc.h.in instead
81 // END of generated section
82 //----------------------------------------------------------------------
86 // Returns the line number of the line with the caret.
89 // Extract style settings from a spec-string which is composed of one or
90 // more of the following comma separated elements:
93 // italic turns on italics
94 // fore:#RRGGBB sets the foreground colour
95 // back:#RRGGBB sets the background colour
96 // face:[facename] sets the font face name to use
97 // size:[num] sets the font size in points
98 // eol turns on eol filling
99 // underline turns on underlining
101 void StyleSetSpec(int styleNum
, const wxString
& spec
);
105 // Set style size, face, bold, italic, and underline attributes from
106 // a wxFont's attributes.
107 void StyleSetFont(int styleNum
, wxFont
& font
);
111 // Set all font style attributes at once.
112 void StyleSetFontAttr(int styleNum
, int size
,
113 const wxString
& faceName
,
114 bool bold
, bool italic
,
119 // Perform one of the operations defined by the wxSTC_CMD_* constants.
120 void CmdKeyExecute(int cmd
);
124 // Set the left and right margin in the edit area, measured in pixels.
125 void SetMargins(int left
, int right
);
128 // Retrieve the start and end positions of the current selection.
130 void GetSelection(int* OUTPUT
, int* OUTPUT
);
132 void GetSelection(int* startPos
, int* endPos
);
135 // Retrieve the point in the window where a position is displayed.
136 wxPoint
PointFromPosition(int pos
);
139 // Scroll enough to make the given line visible
140 void ScrollToLine(int line
);
143 // Scroll enough to make the given column visible
144 void ScrollToColumn(int column
);
147 // Send a message to Scintilla
148 long SendMsg(int msg
, long wp
=0, long lp
=0);
150 //----------------------------------------------------------------------
156 void OnPaint(wxPaintEvent
& evt
);
157 void OnScrollWin(wxScrollWinEvent
& evt
);
158 void OnSize(wxSizeEvent
& evt
);
159 void OnMouseLeftDown(wxMouseEvent
& evt
);
160 void OnMouseMove(wxMouseEvent
& evt
);
161 void OnMouseLeftUp(wxMouseEvent
& evt
);
162 void OnContextMenu(wxContextMenuEvent
& evt
);
163 void OnMouseWheel(wxMouseEvent
& evt
);
164 void OnChar(wxKeyEvent
& evt
);
165 void OnKeyDown(wxKeyEvent
& evt
);
166 void OnLoseFocus(wxFocusEvent
& evt
);
167 void OnGainFocus(wxFocusEvent
& evt
);
168 void OnSysColourChanged(wxSysColourChangedEvent
& evt
);
169 void OnEraseBackground(wxEraseEvent
& evt
);
170 void OnMenu(wxCommandEvent
& evt
);
171 void OnListBox(wxCommandEvent
& evt
);
174 // Turn notifications from Scintilla into events
176 void NotifyParent(SCNotification
* scn
);
179 DECLARE_EVENT_TABLE()
180 DECLARE_CLASS(wxStyledTextCtrl
)
183 wxStopWatch m_stopWatch
;
185 bool m_lastKeyDownConsumed
;
187 friend class ScintillaWX
;
188 friend class Platform
;
192 //----------------------------------------------------------------------
194 class wxStyledTextEvent
: public wxCommandEvent
{
196 wxStyledTextEvent(wxEventType commandType
=0, int id
=0);
197 ~wxStyledTextEvent() {}
199 void SetPosition(int pos
) { m_position
= pos
; }
200 void SetKey(int k
) { m_key
= k
; }
201 void SetModifiers(int m
) { m_modifiers
= m
; }
202 void SetModificationType(int t
) { m_modificationType
= t
; }
203 void SetText(const char* t
) { m_text
= t
; }
204 void SetLength(int len
) { m_length
= len
; }
205 void SetLinesAdded(int num
) { m_linesAdded
= num
; }
206 void SetLine(int val
) { m_line
= val
; }
207 void SetFoldLevelNow(int val
) { m_foldLevelNow
= val
; }
208 void SetFoldLevelPrev(int val
) { m_foldLevelPrev
= val
; }
209 void SetMargin(int val
) { m_margin
= val
; }
210 void SetMessage(int val
) { m_message
= val
; }
211 void SetWParam(int val
) { m_wParam
= val
; }
212 void SetLParam(int val
) { m_lParam
= val
; }
213 void SetListType(int val
) { m_listType
= val
; }
214 void SetX(int val
) { m_x
= val
; }
215 void SetY(int val
) { m_y
= val
; }
217 int GetPosition() const { return m_position
; }
218 int GetKey() const { return m_key
; }
219 int GetModifiers() const { return m_modifiers
; }
220 int GetModificationType() const { return m_modificationType
; }
221 wxString
GetText() const { return m_text
; }
222 int GetLength() const { return m_length
; }
223 int GetLinesAdded() const { return m_linesAdded
; }
224 int GetLine() const { return m_line
; }
225 int GetFoldLevelNow() const { return m_foldLevelNow
; }
226 int GetFoldLevelPrev() const { return m_foldLevelPrev
; }
227 int GetMargin() const { return m_margin
; }
228 int GetMessage() const { return m_message
; }
229 int GetWParam() const { return m_wParam
; }
230 int GetLParam() const { return m_lParam
; }
231 int GetListType() const { return m_listType
; }
232 int GetX() const { return m_x
; }
233 int GetY() const { return m_y
; }
235 bool GetShift() const;
236 bool GetControl() const;
239 void CopyObject(wxObject
& obj
) const;
243 DECLARE_DYNAMIC_CLASS(wxStyledTextEvent
)
249 int m_modificationType
; // wxEVT_STC_MODIFIED
257 int m_margin
; // wxEVT_STC_MARGINCLICK
259 int m_message
; // wxEVT_STC_MACRORECORD
270 BEGIN_DECLARE_EVENT_TYPES()
271 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE
, 1650)
272 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED
, 1651)
273 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED
, 1652)
274 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED
, 1653)
275 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT
, 1654)
276 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT
, 1655)
277 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY
, 1656)
278 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK
, 1657)
279 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI
, 1658)
280 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED
, 1659)
281 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD
, 1660)
282 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK
, 1661)
283 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN
, 1662)
284 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED
, 1663)
285 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_PAINTED
, 1664)
286 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_USERLISTSELECTION
, 1665)
287 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_URIDROPPED
, 1666)
288 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLSTART
, 1667)
289 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DWELLEND
, 1668)
290 END_DECLARE_EVENT_TYPES()
294 wxEVT_STC_STYLENEEDED
,
296 wxEVT_STC_SAVEPOINTREACHED
,
297 wxEVT_STC_SAVEPOINTLEFT
,
298 wxEVT_STC_ROMODIFYATTEMPT
,
300 wxEVT_STC_DOUBLECLICK
,
303 wxEVT_STC_MACRORECORD
,
304 wxEVT_STC_MARGINCLICK
,
306 wxEVT_STC_POSCHANGED
,
308 wxEVT_STC_USERLISTSELECTION
,
309 wxEVT_STC_URIDROPPED
,
310 wxEVT_STC_DWELLSTART
,
318 typedef void (wxEvtHandler::*wxStyledTextEventFunction
)(wxStyledTextEvent
&);
320 #define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
321 #define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
322 #define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
323 #define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
324 #define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
325 #define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
326 #define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
327 #define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
328 #define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
329 #define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
330 #define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
331 #define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
332 #define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
333 #define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
334 #define EVT_STC_PAINTED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_PAINTED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
335 #define EVT_STC_USERLISTSELECTION(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_USERLISTSELECTION, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
336 #define EVT_STC_URIDROPPED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_URIDROPPED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
337 #define EVT_STC_DWELLSTART(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLSTART, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
338 #define EVT_STC_DWELLEND(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DWELLEND, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
343 //----------------------------------------------------------------------
344 //----------------------------------------------------------------------