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");
61 wxStyledTextCtrl(wxWindow
*parent
, wxWindowID id
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
, long style
= 0,
64 const wxString
& name
= wxSTCNameStr
);
72 //----------------------------------------------------------------------
73 // BEGIN generated section. The following code is automatically generated
74 // by gen_iface.py. Do not edit this file. Edit stc.h.in instead
79 // END of generated section
80 //----------------------------------------------------------------------
84 // Returns the line number of the line with the caret.
87 // Extract style settings from a spec-string which is composed of one or
88 // more of the following comma separated elements:
91 // italic turns on italics
92 // fore:#RRGGBB sets the foreground colour
93 // back:#RRGGBB sets the background colour
94 // face:[facename] sets the font face name to use
95 // size:[num] sets the font size in points
96 // eol turns on eol filling
97 // underline turns on underlining
99 void StyleSetSpec(int styleNum
, const wxString
& spec
);
103 // Set style size, face, bold, italic, and underline attributes from
104 // a wxFont's attributes.
105 void StyleSetFont(int styleNum
, wxFont
& font
);
109 // Set all font style attributes at once.
110 void StyleSetFontAttr(int styleNum
, int size
,
111 const wxString
& faceName
,
112 bool bold
, bool italic
,
117 // Perform one of the operations defined by the wxSTC_CMD_* constants.
118 void CmdKeyExecute(int cmd
);
122 // Set the left and right margin in the edit area, measured in pixels.
123 void SetMargins(int left
, int right
);
126 // Retrieve the start and end positions of the current selection.
128 void GetSelection(int* OUTPUT
, int* OUTPUT
);
130 void GetSelection(int* startPos
, int* endPos
);
133 // Retrieve the point in the window where a position is displayed.
134 wxPoint
PointFromPosition(int pos
);
137 // Scroll enough to make the given line visible
138 void ScrollToLine(int line
);
141 // Scroll enough to make the given column visible
142 void ScrollToColumn(int column
);
144 //----------------------------------------------------------------------
150 void OnPaint(wxPaintEvent
& evt
);
151 void OnScrollWin(wxScrollWinEvent
& evt
);
152 void OnSize(wxSizeEvent
& evt
);
153 void OnMouseLeftDown(wxMouseEvent
& evt
);
154 void OnMouseMove(wxMouseEvent
& evt
);
155 void OnMouseLeftUp(wxMouseEvent
& evt
);
156 void OnMouseRightUp(wxMouseEvent
& evt
);
157 void OnChar(wxKeyEvent
& evt
);
158 void OnKeyDown(wxKeyEvent
& evt
);
159 void OnLoseFocus(wxFocusEvent
& evt
);
160 void OnGainFocus(wxFocusEvent
& evt
);
161 void OnSysColourChanged(wxSysColourChangedEvent
& evt
);
162 void OnEraseBackground(wxEraseEvent
& evt
);
163 void OnMenu(wxCommandEvent
& evt
);
164 void OnListBox(wxCommandEvent
& evt
);
167 // Turn notifications from Scintilla into events
169 void NotifyParent(SCNotification
* scn
);
171 long SendMsg(int msg
, long wp
=0, long lp
=0);
174 DECLARE_EVENT_TABLE()
175 DECLARE_CLASS(wxStyledTextCtrl
)
178 wxStopWatch m_stopWatch
;
181 friend class ScintillaWX
;
182 friend class Platform
;
186 //----------------------------------------------------------------------
188 class wxStyledTextEvent
: public wxCommandEvent
{
190 wxStyledTextEvent(wxEventType commandType
=0, int id
=0);
191 ~wxStyledTextEvent() {}
193 void SetPosition(int pos
) { m_position
= pos
; }
194 void SetKey(int k
) { m_key
= k
; }
195 void SetModifiers(int m
) { m_modifiers
= m
; }
196 void SetModificationType(int t
) { m_modificationType
= t
; }
197 void SetText(const char* t
) { m_text
= t
; }
198 void SetLength(int len
) { m_length
= len
; }
199 void SetLinesAdded(int num
) { m_linesAdded
= num
; }
200 void SetLine(int val
) { m_line
= val
; }
201 void SetFoldLevelNow(int val
) { m_foldLevelNow
= val
; }
202 void SetFoldLevelPrev(int val
) { m_foldLevelPrev
= val
; }
203 void SetMargin(int val
) { m_margin
= val
; }
204 void SetMessage(int val
) { m_message
= val
; }
205 void SetWParam(int val
) { m_wParam
= val
; }
206 void SetLParam(int val
) { m_lParam
= val
; }
208 int GetPosition() const { return m_position
; }
209 int GetKey() const { return m_key
; }
210 int GetModifiers() const { return m_modifiers
; }
211 int GetModificationType() const { return m_modificationType
; }
212 wxString
GetText() const { return m_text
; }
213 int GetLength() const { return m_length
; }
214 int GetLinesAdded() const { return m_linesAdded
; }
215 int GetLine() const { return m_line
; }
216 int GetFoldLevelNow() const { return m_foldLevelNow
; }
217 int GetFoldLevelPrev() const { return m_foldLevelPrev
; }
218 int GetMargin() const { return m_margin
; }
219 int GetMessage() const { return m_message
; }
220 int GetWParam() const { return m_wParam
; }
221 int GetLParam() const { return m_lParam
; }
223 bool GetShift() const;
224 bool GetControl() const;
227 void CopyObject(wxObject
& obj
) const;
231 DECLARE_DYNAMIC_CLASS(wxStyledTextEvent
)
237 int m_modificationType
; // wxEVT_STC_MODIFIED
245 int m_margin
; // wxEVT_STC_MARGINCLICK
247 int m_message
; // wxEVT_STC_MACRORECORD
254 BEGIN_DECLARE_EVENT_TYPES()
255 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHANGE
, 1650)
256 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_STYLENEEDED
, 1651)
257 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_CHARADDED
, 1652)
258 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_UPDATEUI
, 1653)
259 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTREACHED
, 1654)
260 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_SAVEPOINTLEFT
, 1655)
261 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_ROMODIFYATTEMPT
, 1656)
262 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_DOUBLECLICK
, 1657)
263 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MODIFIED
, 1658)
264 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_KEY
, 1659)
265 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MACRORECORD
, 1660)
266 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_MARGINCLICK
, 1661)
267 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_NEEDSHOWN
, 1662)
268 DECLARE_LOCAL_EVENT_TYPE(wxEVT_STC_POSCHANGED
, 1663)
269 END_DECLARE_EVENT_TYPES()
273 wxEVT_STC_STYLENEEDED
,
276 wxEVT_STC_SAVEPOINTREACHED
,
277 wxEVT_STC_SAVEPOINTLEFT
,
278 wxEVT_STC_ROMODIFYATTEMPT
,
279 wxEVT_STC_DOUBLECLICK
,
282 wxEVT_STC_MACRORECORD
,
283 wxEVT_STC_MARGINCLICK
,
292 typedef void (wxEvtHandler::*wxStyledTextEventFunction
)(wxStyledTextEvent
&);
294 #define EVT_STC_CHANGE(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHANGE, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
295 #define EVT_STC_STYLENEEDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_STYLENEEDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
296 #define EVT_STC_CHARADDED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CHARADDED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
297 #define EVT_STC_UPDATEUI(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_UPDATEUI, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
298 #define EVT_STC_SAVEPOINTREACHED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTREACHED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
299 #define EVT_STC_SAVEPOINTLEFT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_SAVEPOINTLEFT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
300 #define EVT_STC_ROMODIFYATTEMPT(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_ROMODIFYATTEMPT, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
301 #define EVT_STC_DOUBLECLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_DOUBLECLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
302 #define EVT_STC_MODIFIED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MODIFIED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
303 #define EVT_STC_KEY(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_KEY, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
304 #define EVT_STC_MACRORECORD(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MACRORECORD, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
305 #define EVT_STC_MARGINCLICK(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGINCLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
306 #define EVT_STC_NEEDSHOWN(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_NEEDSHOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
307 #define EVT_STC_POSCHANGED(id, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_POSCHANGED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxStyledTextEventFunction) & fn, (wxObject *) NULL ),
311 //----------------------------------------------------------------------
312 //----------------------------------------------------------------------