]>
Commit | Line | Data |
---|---|---|
f97d84a6 RD |
1 | //////////////////////////////////////////////////////////////////////////// |
2 | // Name: stc.cpp | |
be5a51fb | 3 | // Purpose: A wxWidgets implementation of Scintilla. This class is the |
f97d84a6 RD |
4 | // one meant to be used directly by wx applications. It does not |
5 | // derive directly from the Scintilla classes, but instead | |
6 | // delegates most things to the real Scintilla class. | |
7 | // This allows the use of Scintilla without polluting the | |
8 | // namespace with all the classes and identifiers from Scintilla. | |
9 | // | |
10 | // Author: Robin Dunn | |
11 | // | |
12 | // Created: 13-Jan-2000 | |
13 | // RCS-ID: $Id$ | |
14 | // Copyright: (c) 2000 by Total Control Software | |
526954c5 | 15 | // Licence: wxWindows licence |
f97d84a6 RD |
16 | ///////////////////////////////////////////////////////////////////////////// |
17 | ||
a5c2ccf2 VZ |
18 | /* |
19 | IMPORTANT: src/stc/stc.cpp is generated by src/stc/gen_iface.py from | |
20 | src/stc/stc.cpp.in, don't edit stc.cpp file as your changes will be | |
21 | lost after the next regeneration, edit stc.cpp.in and rerun the | |
22 | gen_iface.py script instead! | |
23 | ||
24 | Parts of this file generated by the script are found in between | |
25 | the special "{{{" and "}}}" markers, the rest of it is copied | |
26 | verbatim from src.h.in. | |
27 | */ | |
28 | ||
54429bb3 RD |
29 | // For compilers that support precompilation, includes "wx.h". |
30 | #include "wx/wxprec.h" | |
31 | ||
32 | #ifdef __BORLANDC__ | |
33 | #pragma hdrstop | |
34 | #endif | |
35 | ||
29825f5f PC |
36 | #if wxUSE_STC |
37 | ||
38 | #include "wx/stc/stc.h" | |
4c784823 | 39 | #include "wx/stc/private.h" |
54429bb3 RD |
40 | |
41 | #ifndef WX_PRECOMP | |
29825f5f | 42 | #include "wx/wx.h" |
54429bb3 RD |
43 | #endif // WX_PRECOMP |
44 | ||
f97d84a6 RD |
45 | #include <ctype.h> |
46 | ||
d6655166 WS |
47 | #include "wx/tokenzr.h" |
48 | #include "wx/mstream.h" | |
49 | #include "wx/image.h" | |
3396739d | 50 | #include "wx/ffile.h" |
f97d84a6 | 51 | |
f9ee2e27 | 52 | #include "ScintillaWX.h" |
f97d84a6 RD |
53 | |
54 | //---------------------------------------------------------------------- | |
55 | ||
23318a53 | 56 | const char wxSTCNameStr[] = "stcwindow"; |
f97d84a6 | 57 | |
451c5cc7 RD |
58 | #ifdef MAKELONG |
59 | #undef MAKELONG | |
60 | #endif | |
61 | ||
62 | #define MAKELONG(a, b) ((a) | ((b) << 16)) | |
63 | ||
64 | ||
65 | static long wxColourAsLong(const wxColour& co) { | |
66 | return (((long)co.Blue() << 16) | | |
67 | ((long)co.Green() << 8) | | |
68 | ((long)co.Red())); | |
69 | } | |
70 | ||
71 | static wxColour wxColourFromLong(long c) { | |
72 | wxColour clr; | |
a5b274d7 WS |
73 | clr.Set((unsigned char)(c & 0xff), |
74 | (unsigned char)((c >> 8) & 0xff), | |
75 | (unsigned char)((c >> 16) & 0xff)); | |
451c5cc7 RD |
76 | return clr; |
77 | } | |
78 | ||
79 | ||
80 | static wxColour wxColourFromSpec(const wxString& spec) { | |
5ee1d760 RD |
81 | // spec should be a colour name or "#RRGGBB" |
82 | if (spec.GetChar(0) == wxT('#')) { | |
dc8005e2 | 83 | |
5ee1d760 RD |
84 | long red, green, blue; |
85 | red = green = blue = 0; | |
86 | spec.Mid(1,2).ToLong(&red, 16); | |
87 | spec.Mid(3,2).ToLong(&green, 16); | |
88 | spec.Mid(5,2).ToLong(&blue, 16); | |
a5b274d7 WS |
89 | return wxColour((unsigned char)red, |
90 | (unsigned char)green, | |
91 | (unsigned char)blue); | |
5ee1d760 RD |
92 | } |
93 | else | |
94 | return wxColour(spec); | |
451c5cc7 RD |
95 | } |
96 | ||
97 | //---------------------------------------------------------------------- | |
98 | ||
9b11752c VZ |
99 | wxDEFINE_EVENT( wxEVT_STC_CHANGE, wxStyledTextEvent ); |
100 | wxDEFINE_EVENT( wxEVT_STC_STYLENEEDED, wxStyledTextEvent ); | |
101 | wxDEFINE_EVENT( wxEVT_STC_CHARADDED, wxStyledTextEvent ); | |
102 | wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTREACHED, wxStyledTextEvent ); | |
103 | wxDEFINE_EVENT( wxEVT_STC_SAVEPOINTLEFT, wxStyledTextEvent ); | |
104 | wxDEFINE_EVENT( wxEVT_STC_ROMODIFYATTEMPT, wxStyledTextEvent ); | |
105 | wxDEFINE_EVENT( wxEVT_STC_KEY, wxStyledTextEvent ); | |
106 | wxDEFINE_EVENT( wxEVT_STC_DOUBLECLICK, wxStyledTextEvent ); | |
107 | wxDEFINE_EVENT( wxEVT_STC_UPDATEUI, wxStyledTextEvent ); | |
108 | wxDEFINE_EVENT( wxEVT_STC_MODIFIED, wxStyledTextEvent ); | |
109 | wxDEFINE_EVENT( wxEVT_STC_MACRORECORD, wxStyledTextEvent ); | |
110 | wxDEFINE_EVENT( wxEVT_STC_MARGINCLICK, wxStyledTextEvent ); | |
111 | wxDEFINE_EVENT( wxEVT_STC_NEEDSHOWN, wxStyledTextEvent ); | |
112 | wxDEFINE_EVENT( wxEVT_STC_PAINTED, wxStyledTextEvent ); | |
113 | wxDEFINE_EVENT( wxEVT_STC_USERLISTSELECTION, wxStyledTextEvent ); | |
114 | wxDEFINE_EVENT( wxEVT_STC_URIDROPPED, wxStyledTextEvent ); | |
115 | wxDEFINE_EVENT( wxEVT_STC_DWELLSTART, wxStyledTextEvent ); | |
116 | wxDEFINE_EVENT( wxEVT_STC_DWELLEND, wxStyledTextEvent ); | |
117 | wxDEFINE_EVENT( wxEVT_STC_START_DRAG, wxStyledTextEvent ); | |
118 | wxDEFINE_EVENT( wxEVT_STC_DRAG_OVER, wxStyledTextEvent ); | |
119 | wxDEFINE_EVENT( wxEVT_STC_DO_DROP, wxStyledTextEvent ); | |
120 | wxDEFINE_EVENT( wxEVT_STC_ZOOM, wxStyledTextEvent ); | |
121 | wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_CLICK, wxStyledTextEvent ); | |
122 | wxDEFINE_EVENT( wxEVT_STC_HOTSPOT_DCLICK, wxStyledTextEvent ); | |
123 | wxDEFINE_EVENT( wxEVT_STC_CALLTIP_CLICK, wxStyledTextEvent ); | |
124 | wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION, wxStyledTextEvent ); | |
125 | wxDEFINE_EVENT( wxEVT_STC_INDICATOR_CLICK, wxStyledTextEvent ); | |
126 | wxDEFINE_EVENT( wxEVT_STC_INDICATOR_RELEASE, wxStyledTextEvent ); | |
9e96e16f RD |
127 | wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CANCELLED, wxStyledTextEvent ); |
128 | wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_CHAR_DELETED, wxStyledTextEvent ); | |
9e730a78 | 129 | |
d25f5fbb RD |
130 | |
131 | ||
f97d84a6 RD |
132 | BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) |
133 | EVT_PAINT (wxStyledTextCtrl::OnPaint) | |
134 | EVT_SCROLLWIN (wxStyledTextCtrl::OnScrollWin) | |
5fa4613c | 135 | EVT_SCROLL (wxStyledTextCtrl::OnScroll) |
f97d84a6 RD |
136 | EVT_SIZE (wxStyledTextCtrl::OnSize) |
137 | EVT_LEFT_DOWN (wxStyledTextCtrl::OnMouseLeftDown) | |
4ceb1196 RD |
138 | // Let Scintilla see the double click as a second click |
139 | EVT_LEFT_DCLICK (wxStyledTextCtrl::OnMouseLeftDown) | |
f97d84a6 RD |
140 | EVT_MOTION (wxStyledTextCtrl::OnMouseMove) |
141 | EVT_LEFT_UP (wxStyledTextCtrl::OnMouseLeftUp) | |
451c5cc7 | 142 | #if defined(__WXGTK__) || defined(__WXMAC__) |
ddf2da08 RD |
143 | EVT_RIGHT_UP (wxStyledTextCtrl::OnMouseRightUp) |
144 | #else | |
65ec6247 | 145 | EVT_CONTEXT_MENU (wxStyledTextCtrl::OnContextMenu) |
ddf2da08 | 146 | #endif |
37d62433 | 147 | EVT_MOUSEWHEEL (wxStyledTextCtrl::OnMouseWheel) |
2b5f62a0 | 148 | EVT_MIDDLE_UP (wxStyledTextCtrl::OnMouseMiddleUp) |
f97d84a6 RD |
149 | EVT_CHAR (wxStyledTextCtrl::OnChar) |
150 | EVT_KEY_DOWN (wxStyledTextCtrl::OnKeyDown) | |
151 | EVT_KILL_FOCUS (wxStyledTextCtrl::OnLoseFocus) | |
152 | EVT_SET_FOCUS (wxStyledTextCtrl::OnGainFocus) | |
153 | EVT_SYS_COLOUR_CHANGED (wxStyledTextCtrl::OnSysColourChanged) | |
154 | EVT_ERASE_BACKGROUND (wxStyledTextCtrl::OnEraseBackground) | |
dd4aa550 | 155 | EVT_MENU_RANGE (10, 16, wxStyledTextCtrl::OnMenu) |
dc8005e2 | 156 | EVT_LISTBOX_DCLICK (wxID_ANY, wxStyledTextCtrl::OnListBox) |
f97d84a6 RD |
157 | END_EVENT_TABLE() |
158 | ||
159 | ||
160 | IMPLEMENT_CLASS(wxStyledTextCtrl, wxControl) | |
161 | IMPLEMENT_DYNAMIC_CLASS(wxStyledTextEvent, wxCommandEvent) | |
162 | ||
40716a51 | 163 | #ifdef LINK_LEXERS |
1a2fb4cd | 164 | // forces the linking of the lexer modules |
a834585d | 165 | int Scintilla_LinkLexers(); |
40716a51 | 166 | #endif |
1a2fb4cd | 167 | |
f97d84a6 RD |
168 | //---------------------------------------------------------------------- |
169 | // Constructor and Destructor | |
170 | ||
171 | wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, | |
172 | wxWindowID id, | |
173 | const wxPoint& pos, | |
174 | const wxSize& size, | |
175 | long style, | |
39c0acb6 RD |
176 | const wxString& name) |
177 | { | |
178 | m_swx = NULL; | |
179 | Create(parent, id, pos, size, style, name); | |
180 | } | |
181 | ||
182 | ||
a48cb415 RD |
183 | bool wxStyledTextCtrl::Create(wxWindow *parent, |
184 | wxWindowID id, | |
185 | const wxPoint& pos, | |
186 | const wxSize& size, | |
187 | long style, | |
188 | const wxString& name) | |
f97d84a6 | 189 | { |
2659dad3 | 190 | style |= wxVSCROLL | wxHSCROLL; |
a48cb415 RD |
191 | if (!wxControl::Create(parent, id, pos, size, |
192 | style | wxWANTS_CHARS | wxCLIP_CHILDREN, | |
193 | wxDefaultValidator, name)) | |
194 | return false; | |
39c0acb6 | 195 | |
40716a51 | 196 | #ifdef LINK_LEXERS |
a834585d | 197 | Scintilla_LinkLexers(); |
40716a51 | 198 | #endif |
f97d84a6 RD |
199 | m_swx = new ScintillaWX(this); |
200 | m_stopWatch.Start(); | |
dc8005e2 | 201 | m_lastKeyDownConsumed = false; |
5fa4613c RD |
202 | m_vScrollBar = NULL; |
203 | m_hScrollBar = NULL; | |
10ef30eb RD |
204 | #if wxUSE_UNICODE |
205 | // Put Scintilla into unicode (UTF-8) mode | |
206 | SetCodePage(wxSTC_CP_UTF8); | |
207 | #endif | |
8ae4f086 | 208 | |
170acdc9 | 209 | SetInitialSize(size); |
f9ee2e27 RD |
210 | |
211 | // Reduces flicker on GTK+/X11 | |
c69612de | 212 | SetBackgroundStyle(wxBG_STYLE_PAINT); |
5e328f38 RD |
213 | |
214 | // Make sure it can take the focus | |
215 | SetCanFocus(true); | |
216 | ||
a48cb415 | 217 | return true; |
f97d84a6 RD |
218 | } |
219 | ||
220 | ||
221 | wxStyledTextCtrl::~wxStyledTextCtrl() { | |
222 | delete m_swx; | |
223 | } | |
224 | ||
225 | ||
226 | //---------------------------------------------------------------------- | |
227 | ||
fafd43c5 | 228 | wxIntPtr wxStyledTextCtrl::SendMsg(int msg, wxUIntPtr wp, wxIntPtr lp) const |
8e0945da | 229 | { |
f97d84a6 RD |
230 | return m_swx->WndProc(msg, wp, lp); |
231 | } | |
232 | ||
ccfc3219 RD |
233 | //---------------------------------------------------------------------- |
234 | ||
235 | // Set the vertical scrollbar to use instead of the ont that's built-in. | |
236 | void wxStyledTextCtrl::SetVScrollBar(wxScrollBar* bar) { | |
237 | m_vScrollBar = bar; | |
238 | if (bar != NULL) { | |
239 | // ensure that the built-in scrollbar is not visible | |
240 | SetScrollbar(wxVERTICAL, 0, 0, 0); | |
241 | } | |
242 | } | |
f97d84a6 | 243 | |
f97d84a6 | 244 | |
ccfc3219 RD |
245 | // Set the horizontal scrollbar to use instead of the ont that's built-in. |
246 | void wxStyledTextCtrl::SetHScrollBar(wxScrollBar* bar) { | |
247 | m_hScrollBar = bar; | |
248 | if (bar != NULL) { | |
249 | // ensure that the built-in scrollbar is not visible | |
250 | SetScrollbar(wxHORIZONTAL, 0, 0, 0); | |
251 | } | |
252 | } | |
253 | ||
f97d84a6 | 254 | //---------------------------------------------------------------------- |
a5c2ccf2 | 255 | // Generated methods implementation section {{{ |
f97d84a6 RD |
256 | |
257 | %(METHOD_IMPS)s | |
258 | ||
a5c2ccf2 | 259 | //}}} |
f97d84a6 RD |
260 | //---------------------------------------------------------------------- |
261 | ||
262 | ||
263 | // Returns the line number of the line with the caret. | |
264 | int wxStyledTextCtrl::GetCurrentLine() { | |
265 | int line = LineFromPosition(GetCurrentPos()); | |
266 | return line; | |
267 | } | |
268 | ||
269 | ||
270 | // Extract style settings from a spec-string which is composed of one or | |
271 | // more of the following comma separated elements: | |
272 | // | |
273 | // bold turns on bold | |
274 | // italic turns on italics | |
5ee1d760 RD |
275 | // fore:[name or #RRGGBB] sets the foreground colour |
276 | // back:[name or #RRGGBB] sets the background colour | |
f97d84a6 RD |
277 | // face:[facename] sets the font face name to use |
278 | // size:[num] sets the font size in points | |
279 | // eol turns on eol filling | |
280 | // underline turns on underlining | |
281 | // | |
282 | void wxStyledTextCtrl::StyleSetSpec(int styleNum, const wxString& spec) { | |
283 | ||
451c5cc7 | 284 | wxStringTokenizer tkz(spec, wxT(",")); |
f97d84a6 RD |
285 | while (tkz.HasMoreTokens()) { |
286 | wxString token = tkz.GetNextToken(); | |
287 | ||
288 | wxString option = token.BeforeFirst(':'); | |
289 | wxString val = token.AfterFirst(':'); | |
290 | ||
451c5cc7 | 291 | if (option == wxT("bold")) |
f97d84a6 RD |
292 | StyleSetBold(styleNum, true); |
293 | ||
451c5cc7 | 294 | else if (option == wxT("italic")) |
f97d84a6 RD |
295 | StyleSetItalic(styleNum, true); |
296 | ||
451c5cc7 | 297 | else if (option == wxT("underline")) |
f97d84a6 RD |
298 | StyleSetUnderline(styleNum, true); |
299 | ||
451c5cc7 | 300 | else if (option == wxT("eol")) |
f97d84a6 RD |
301 | StyleSetEOLFilled(styleNum, true); |
302 | ||
451c5cc7 | 303 | else if (option == wxT("size")) { |
f97d84a6 RD |
304 | long points; |
305 | if (val.ToLong(&points)) | |
306 | StyleSetSize(styleNum, points); | |
307 | } | |
308 | ||
451c5cc7 | 309 | else if (option == wxT("face")) |
f97d84a6 RD |
310 | StyleSetFaceName(styleNum, val); |
311 | ||
451c5cc7 | 312 | else if (option == wxT("fore")) |
f97d84a6 RD |
313 | StyleSetForeground(styleNum, wxColourFromSpec(val)); |
314 | ||
451c5cc7 | 315 | else if (option == wxT("back")) |
f97d84a6 RD |
316 | StyleSetBackground(styleNum, wxColourFromSpec(val)); |
317 | } | |
318 | } | |
319 | ||
320 | ||
7e0c58e9 RD |
321 | // Get the font of a style |
322 | wxFont wxStyledTextCtrl::StyleGetFont(int style) { | |
323 | wxFont font; | |
324 | font.SetPointSize(StyleGetSize(style)); | |
325 | font.SetFaceName(StyleGetFaceName(style)); | |
326 | if( StyleGetBold(style) ) | |
327 | font.SetWeight(wxFONTWEIGHT_BOLD); | |
328 | else | |
329 | font.SetWeight(wxFONTWEIGHT_NORMAL); | |
330 | ||
331 | if( StyleGetItalic(style) ) | |
332 | font.SetStyle(wxFONTSTYLE_ITALIC); | |
333 | else | |
334 | font.SetStyle(wxFONTSTYLE_NORMAL); | |
335 | ||
336 | return font; | |
337 | } | |
338 | ||
339 | ||
f97d84a6 RD |
340 | // Set style size, face, bold, italic, and underline attributes from |
341 | // a wxFont's attributes. | |
342 | void wxStyledTextCtrl::StyleSetFont(int styleNum, wxFont& font) { | |
7475e814 RD |
343 | #ifdef __WXGTK__ |
344 | // Ensure that the native font is initialized | |
345 | int x, y; | |
346 | GetTextExtent(wxT("X"), &x, &y, NULL, NULL, &font); | |
347 | #endif | |
af0531a5 RD |
348 | int size = font.GetPointSize(); |
349 | wxString faceName = font.GetFaceName(); | |
350 | bool bold = font.GetWeight() == wxBOLD; | |
351 | bool italic = font.GetStyle() != wxNORMAL; | |
352 | bool under = font.GetUnderlined(); | |
c5bd09bf | 353 | wxFontEncoding encoding = font.GetEncoding(); |
7e0c58e9 | 354 | |
af0531a5 | 355 | StyleSetFontAttr(styleNum, size, faceName, bold, italic, under, encoding); |
f97d84a6 RD |
356 | } |
357 | ||
358 | // Set all font style attributes at once. | |
359 | void wxStyledTextCtrl::StyleSetFontAttr(int styleNum, int size, | |
360 | const wxString& faceName, | |
361 | bool bold, bool italic, | |
3727c043 RD |
362 | bool underline, |
363 | wxFontEncoding encoding) { | |
f97d84a6 RD |
364 | StyleSetSize(styleNum, size); |
365 | StyleSetFaceName(styleNum, faceName); | |
366 | StyleSetBold(styleNum, bold); | |
367 | StyleSetItalic(styleNum, italic); | |
368 | StyleSetUnderline(styleNum, underline); | |
3727c043 RD |
369 | StyleSetFontEncoding(styleNum, encoding); |
370 | } | |
f97d84a6 | 371 | |
3727c043 RD |
372 | |
373 | // Set the character set of the font in a style. Converts the Scintilla | |
374 | // character set values to a wxFontEncoding. | |
375 | void wxStyledTextCtrl::StyleSetCharacterSet(int style, int characterSet) | |
376 | { | |
377 | wxFontEncoding encoding; | |
378 | ||
379 | // Translate the Scintilla characterSet to a wxFontEncoding | |
380 | switch (characterSet) { | |
381 | default: | |
382 | case wxSTC_CHARSET_ANSI: | |
383 | case wxSTC_CHARSET_DEFAULT: | |
384 | encoding = wxFONTENCODING_DEFAULT; | |
385 | break; | |
386 | ||
387 | case wxSTC_CHARSET_BALTIC: | |
388 | encoding = wxFONTENCODING_ISO8859_13; | |
389 | break; | |
390 | ||
391 | case wxSTC_CHARSET_CHINESEBIG5: | |
392 | encoding = wxFONTENCODING_CP950; | |
393 | break; | |
394 | ||
395 | case wxSTC_CHARSET_EASTEUROPE: | |
396 | encoding = wxFONTENCODING_ISO8859_2; | |
397 | break; | |
398 | ||
399 | case wxSTC_CHARSET_GB2312: | |
400 | encoding = wxFONTENCODING_CP936; | |
401 | break; | |
402 | ||
403 | case wxSTC_CHARSET_GREEK: | |
404 | encoding = wxFONTENCODING_ISO8859_7; | |
405 | break; | |
406 | ||
407 | case wxSTC_CHARSET_HANGUL: | |
408 | encoding = wxFONTENCODING_CP949; | |
409 | break; | |
410 | ||
411 | case wxSTC_CHARSET_MAC: | |
412 | encoding = wxFONTENCODING_DEFAULT; | |
413 | break; | |
414 | ||
415 | case wxSTC_CHARSET_OEM: | |
416 | encoding = wxFONTENCODING_DEFAULT; | |
417 | break; | |
418 | ||
419 | case wxSTC_CHARSET_RUSSIAN: | |
420 | encoding = wxFONTENCODING_KOI8; | |
421 | break; | |
422 | ||
423 | case wxSTC_CHARSET_SHIFTJIS: | |
424 | encoding = wxFONTENCODING_CP932; | |
425 | break; | |
426 | ||
427 | case wxSTC_CHARSET_SYMBOL: | |
428 | encoding = wxFONTENCODING_DEFAULT; | |
429 | break; | |
430 | ||
431 | case wxSTC_CHARSET_TURKISH: | |
432 | encoding = wxFONTENCODING_ISO8859_9; | |
433 | break; | |
434 | ||
435 | case wxSTC_CHARSET_JOHAB: | |
436 | encoding = wxFONTENCODING_DEFAULT; | |
437 | break; | |
438 | ||
439 | case wxSTC_CHARSET_HEBREW: | |
440 | encoding = wxFONTENCODING_ISO8859_8; | |
441 | break; | |
442 | ||
443 | case wxSTC_CHARSET_ARABIC: | |
444 | encoding = wxFONTENCODING_ISO8859_6; | |
445 | break; | |
446 | ||
447 | case wxSTC_CHARSET_VIETNAMESE: | |
448 | encoding = wxFONTENCODING_DEFAULT; | |
449 | break; | |
450 | ||
451 | case wxSTC_CHARSET_THAI: | |
452 | encoding = wxFONTENCODING_ISO8859_11; | |
453 | break; | |
1e9bafca RD |
454 | |
455 | case wxSTC_CHARSET_CYRILLIC: | |
456 | encoding = wxFONTENCODING_ISO8859_5; | |
457 | break; | |
7e0c58e9 | 458 | |
1e9bafca RD |
459 | case wxSTC_CHARSET_8859_15: |
460 | encoding = wxFONTENCODING_ISO8859_15;; | |
461 | break; | |
3727c043 RD |
462 | } |
463 | ||
464 | // We just have Scintilla track the wxFontEncoding for us. It gets used | |
465 | // in Font::Create in PlatWX.cpp. We add one to the value so that the | |
466 | // effective wxFONENCODING_DEFAULT == SC_SHARSET_DEFAULT and so when | |
467 | // Scintilla internally uses SC_CHARSET_DEFAULT we will translate it back | |
468 | // to wxFONENCODING_DEFAULT in Font::Create. | |
469 | SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); | |
470 | } | |
471 | ||
472 | ||
473 | // Set the font encoding to be used by a style. | |
474 | void wxStyledTextCtrl::StyleSetFontEncoding(int style, wxFontEncoding encoding) | |
475 | { | |
476 | SendMsg(SCI_STYLESETCHARACTERSET, style, encoding+1); | |
f97d84a6 RD |
477 | } |
478 | ||
479 | ||
480 | // Perform one of the operations defined by the wxSTC_CMD_* constants. | |
481 | void wxStyledTextCtrl::CmdKeyExecute(int cmd) { | |
482 | SendMsg(cmd); | |
483 | } | |
484 | ||
485 | ||
486 | // Set the left and right margin in the edit area, measured in pixels. | |
487 | void wxStyledTextCtrl::SetMargins(int left, int right) { | |
488 | SetMarginLeft(left); | |
489 | SetMarginRight(right); | |
490 | } | |
491 | ||
492 | ||
f97d84a6 RD |
493 | // Retrieve the point in the window where a position is displayed. |
494 | wxPoint wxStyledTextCtrl::PointFromPosition(int pos) { | |
495 | int x = SendMsg(SCI_POINTXFROMPOSITION, 0, pos); | |
496 | int y = SendMsg(SCI_POINTYFROMPOSITION, 0, pos); | |
497 | return wxPoint(x, y); | |
498 | } | |
499 | ||
500 | // Scroll enough to make the given line visible | |
501 | void wxStyledTextCtrl::ScrollToLine(int line) { | |
502 | m_swx->DoScrollToLine(line); | |
503 | } | |
504 | ||
505 | ||
506 | // Scroll enough to make the given column visible | |
507 | void wxStyledTextCtrl::ScrollToColumn(int column) { | |
508 | m_swx->DoScrollToColumn(column); | |
509 | } | |
510 | ||
511 | ||
2bfca191 | 512 | #if wxUSE_TEXTCTRL |
3396739d VZ |
513 | bool wxStyledTextCtrl::DoSaveFile(const wxString& filename, int fileType) |
514 | { | |
515 | bool ok = wxTextAreaBase::DoSaveFile(filename, fileType); | |
2bfca191 | 516 | #else |
51566b0b RD |
517 | bool wxStyledTextCtrl::SaveFile(const wxString& filename) |
518 | { | |
3396739d VZ |
519 | #if wxUSE_FFILE |
520 | wxFFile file(filename, wxT("w")); | |
521 | bool ok = file.IsOpened() && file.Write(GetValue(), *wxConvCurrent); | |
522 | #else | |
523 | bool ok = false; | |
524 | #endif // wxUSE_FFILE | |
525 | #endif | |
526 | if (ok) | |
527 | { | |
51566b0b | 528 | SetSavePoint(); |
3396739d VZ |
529 | } |
530 | return ok; | |
51566b0b RD |
531 | } |
532 | ||
2bfca191 | 533 | #if wxUSE_TEXTCTRL |
3396739d VZ |
534 | bool wxStyledTextCtrl::DoLoadFile(const wxString& filename, int fileType) |
535 | { | |
536 | bool ok = wxTextAreaBase::DoLoadFile(filename, fileType); | |
2bfca191 | 537 | #else |
51566b0b RD |
538 | bool wxStyledTextCtrl::LoadFile(const wxString& filename) |
539 | { | |
3396739d VZ |
540 | #if wxUSE_FFILE |
541 | wxFFile file(filename); | |
542 | bool ok = file.IsOpened(); | |
543 | if (ok) | |
51566b0b | 544 | { |
3396739d VZ |
545 | wxString text; |
546 | ok = file.ReadAll(&text, *wxConvCurrent); | |
547 | if (ok) | |
041973c5 | 548 | { |
3396739d | 549 | SetValue(text); |
041973c5 | 550 | } |
51566b0b | 551 | } |
3396739d VZ |
552 | #else |
553 | bool ok = false; | |
554 | #endif // wxUSE_FFILE | |
555 | #endif | |
556 | if (ok) | |
557 | { | |
558 | EmptyUndoBuffer(); | |
559 | SetSavePoint(); | |
560 | } | |
561 | return ok; | |
51566b0b RD |
562 | } |
563 | ||
2fcce896 | 564 | #if wxUSE_DRAG_AND_DROP |
dc8005e2 RD |
565 | wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { |
566 | return m_swx->DoDragOver(x, y, def); | |
567 | } | |
4a65f2c8 RD |
568 | |
569 | ||
dc8005e2 | 570 | bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { |
4a65f2c8 RD |
571 | return m_swx->DoDropText(x, y, data); |
572 | } | |
2fcce896 | 573 | #endif |
4a65f2c8 RD |
574 | |
575 | ||
d1558f3d RD |
576 | void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) { |
577 | m_swx->SetUseAntiAliasing(useAA); | |
578 | } | |
579 | ||
580 | bool wxStyledTextCtrl::GetUseAntiAliasing() { | |
581 | return m_swx->GetUseAntiAliasing(); | |
582 | } | |
583 | ||
41a499cd RD |
584 | |
585 | ||
586 | ||
587 | ||
6f67e6d2 | 588 | void wxStyledTextCtrl::AddTextRaw(const char* text, int length) |
41a499cd | 589 | { |
6f67e6d2 RD |
590 | if (length == -1) |
591 | length = strlen(text); | |
592 | SendMsg(SCI_ADDTEXT, length, (sptr_t)text); | |
41a499cd RD |
593 | } |
594 | ||
595 | void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text) | |
596 | { | |
b796ba39 | 597 | SendMsg(SCI_INSERTTEXT, pos, (sptr_t)text); |
41a499cd RD |
598 | } |
599 | ||
600 | wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos) | |
601 | { | |
602 | int len = LineLength(GetCurrentLine()); | |
603 | if (!len) { | |
604 | if (linePos) *linePos = 0; | |
605 | wxCharBuffer empty; | |
606 | return empty; | |
607 | } | |
608 | ||
609 | wxCharBuffer buf(len); | |
b796ba39 | 610 | int pos = SendMsg(SCI_GETCURLINE, len, (sptr_t)buf.data()); |
41a499cd RD |
611 | if (linePos) *linePos = pos; |
612 | return buf; | |
613 | } | |
614 | ||
615 | wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line) | |
616 | { | |
617 | int len = LineLength(line); | |
618 | if (!len) { | |
619 | wxCharBuffer empty; | |
620 | return empty; | |
621 | } | |
622 | ||
623 | wxCharBuffer buf(len); | |
b796ba39 | 624 | SendMsg(SCI_GETLINE, line, (sptr_t)buf.data()); |
41a499cd RD |
625 | return buf; |
626 | } | |
627 | ||
628 | wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw() | |
629 | { | |
1a692f0f VZ |
630 | // Calculate the length needed first. |
631 | const int len = SendMsg(SCI_GETSELTEXT, 0, (sptr_t)0); | |
41a499cd | 632 | |
1a692f0f | 633 | // And then really get the data. |
41a499cd | 634 | wxCharBuffer buf(len); |
b796ba39 | 635 | SendMsg(SCI_GETSELTEXT, 0, (sptr_t)buf.data()); |
41a499cd RD |
636 | return buf; |
637 | } | |
638 | ||
639 | wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos) | |
640 | { | |
641 | if (endPos < startPos) { | |
642 | int temp = startPos; | |
643 | startPos = endPos; | |
644 | endPos = temp; | |
645 | } | |
646 | int len = endPos - startPos; | |
647 | if (!len) { | |
648 | wxCharBuffer empty; | |
649 | return empty; | |
7e0c58e9 | 650 | } |
41a499cd RD |
651 | |
652 | wxCharBuffer buf(len); | |
653 | TextRange tr; | |
654 | tr.lpstrText = buf.data(); | |
655 | tr.chrg.cpMin = startPos; | |
656 | tr.chrg.cpMax = endPos; | |
b796ba39 | 657 | SendMsg(SCI_GETTEXTRANGE, 0, (sptr_t)&tr); |
41a499cd RD |
658 | return buf; |
659 | } | |
660 | ||
661 | void wxStyledTextCtrl::SetTextRaw(const char* text) | |
662 | { | |
b796ba39 | 663 | SendMsg(SCI_SETTEXT, 0, (sptr_t)text); |
41a499cd RD |
664 | } |
665 | ||
666 | wxCharBuffer wxStyledTextCtrl::GetTextRaw() | |
667 | { | |
949750de VZ |
668 | int len = GetTextLength(); |
669 | wxCharBuffer buf(len); // adds 1 for NUL automatically | |
b796ba39 | 670 | SendMsg(SCI_GETTEXT, len + 1, (sptr_t)buf.data()); |
41a499cd RD |
671 | return buf; |
672 | } | |
673 | ||
6f67e6d2 | 674 | void wxStyledTextCtrl::AppendTextRaw(const char* text, int length) |
41a499cd | 675 | { |
6f67e6d2 RD |
676 | if (length == -1) |
677 | length = strlen(text); | |
678 | SendMsg(SCI_APPENDTEXT, length, (sptr_t)text); | |
41a499cd RD |
679 | } |
680 | ||
681 | ||
682 | ||
683 | ||
684 | ||
f97d84a6 RD |
685 | //---------------------------------------------------------------------- |
686 | // Event handlers | |
687 | ||
88a8b04e | 688 | void wxStyledTextCtrl::OnPaint(wxPaintEvent& WXUNUSED(evt)) { |
f97d84a6 | 689 | wxPaintDC dc(this); |
9e730a78 | 690 | m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); |
f97d84a6 RD |
691 | } |
692 | ||
693 | void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { | |
694 | if (evt.GetOrientation() == wxHORIZONTAL) | |
695 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
696 | else | |
697 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
698 | } | |
699 | ||
5fa4613c RD |
700 | void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) { |
701 | wxScrollBar* sb = wxDynamicCast(evt.GetEventObject(), wxScrollBar); | |
702 | if (sb) { | |
703 | if (sb->IsVertical()) | |
704 | m_swx->DoVScroll(evt.GetEventType(), evt.GetPosition()); | |
705 | else | |
706 | m_swx->DoHScroll(evt.GetEventType(), evt.GetPosition()); | |
707 | } | |
708 | } | |
709 | ||
88a8b04e | 710 | void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) { |
39c0acb6 RD |
711 | if (m_swx) { |
712 | wxSize sz = GetClientSize(); | |
713 | m_swx->DoSize(sz.x, sz.y); | |
714 | } | |
f97d84a6 RD |
715 | } |
716 | ||
717 | void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) { | |
cb1871ca | 718 | SetFocus(); |
f97d84a6 | 719 | wxPoint pt = evt.GetPosition(); |
2b5f62a0 | 720 | m_swx->DoLeftButtonDown(Point(pt.x, pt.y), m_stopWatch.Time(), |
f97d84a6 RD |
721 | evt.ShiftDown(), evt.ControlDown(), evt.AltDown()); |
722 | } | |
723 | ||
724 | void wxStyledTextCtrl::OnMouseMove(wxMouseEvent& evt) { | |
725 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 726 | m_swx->DoLeftButtonMove(Point(pt.x, pt.y)); |
f97d84a6 RD |
727 | } |
728 | ||
729 | void wxStyledTextCtrl::OnMouseLeftUp(wxMouseEvent& evt) { | |
730 | wxPoint pt = evt.GetPosition(); | |
2b5f62a0 | 731 | m_swx->DoLeftButtonUp(Point(pt.x, pt.y), m_stopWatch.Time(), |
f97d84a6 RD |
732 | evt.ControlDown()); |
733 | } | |
734 | ||
735 | ||
ddf2da08 RD |
736 | void wxStyledTextCtrl::OnMouseRightUp(wxMouseEvent& evt) { |
737 | wxPoint pt = evt.GetPosition(); | |
738 | m_swx->DoContextMenu(Point(pt.x, pt.y)); | |
739 | } | |
740 | ||
741 | ||
2b5f62a0 VZ |
742 | void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { |
743 | wxPoint pt = evt.GetPosition(); | |
744 | m_swx->DoMiddleButtonUp(Point(pt.x, pt.y)); | |
745 | } | |
746 | ||
65ec6247 | 747 | void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { |
f97d84a6 | 748 | wxPoint pt = evt.GetPosition(); |
65ec6247 | 749 | ScreenToClient(&pt.x, &pt.y); |
25484746 RD |
750 | /* |
751 | Show context menu at event point if it's within the window, | |
752 | or at caret location if not | |
753 | */ | |
754 | wxHitTest ht = this->HitTest(pt); | |
755 | if (ht != wxHT_WINDOW_INSIDE) { | |
756 | pt = this->PointFromPosition(this->GetCurrentPos()); | |
757 | } | |
f97d84a6 RD |
758 | m_swx->DoContextMenu(Point(pt.x, pt.y)); |
759 | } | |
760 | ||
37d62433 | 761 | |
60957703 VZ |
762 | void wxStyledTextCtrl::OnMouseWheel(wxMouseEvent& evt) |
763 | { | |
42a4299b VZ |
764 | m_swx->DoMouseWheel(evt.GetWheelRotation(), |
765 | evt.GetWheelDelta(), | |
766 | evt.GetLinesPerAction(), | |
767 | evt.ControlDown(), | |
768 | evt.IsPageScroll()); | |
37d62433 RD |
769 | } |
770 | ||
771 | ||
f97d84a6 | 772 | void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { |
5fd656d5 | 773 | // On (some?) non-US PC keyboards the AltGr key is required to enter some |
f3c2c221 RD |
774 | // common characters. It comes to us as both Alt and Ctrl down so we need |
775 | // to let the char through in that case, otherwise if only ctrl or only | |
776 | // alt let's skip it. | |
777 | bool ctrl = evt.ControlDown(); | |
28e0c28e RD |
778 | #ifdef __WXMAC__ |
779 | // On the Mac the Alt key is just a modifier key (like Shift) so we need | |
780 | // to allow the char events to be processed when Alt is pressed. | |
781 | // TODO: Should we check MetaDown instead in this case? | |
782 | bool alt = false; | |
783 | #else | |
f3c2c221 | 784 | bool alt = evt.AltDown(); |
28e0c28e | 785 | #endif |
00c64037 | 786 | bool skip = ((ctrl || alt) && ! (ctrl && alt)); |
f3c2c221 | 787 | |
4358b585 VZ |
788 | #if wxUSE_UNICODE |
789 | // apparently if we don't do this, Unicode keys pressed after non-char | |
790 | // ASCII ones (e.g. Enter, Tab) are not taken into account (patch 1615989) | |
791 | if (m_lastKeyDownConsumed && evt.GetUnicodeKey() > 255) | |
792 | m_lastKeyDownConsumed = false; | |
793 | #endif | |
794 | ||
5fd656d5 RD |
795 | if (!m_lastKeyDownConsumed && !skip) { |
796 | #if wxUSE_UNICODE | |
797 | int key = evt.GetUnicodeKey(); | |
798 | bool keyOk = true; | |
799 | ||
800 | // if the unicode key code is not really a unicode character (it may | |
801 | // be a function key or etc., the platforms appear to always give us a | |
802 | // small value in this case) then fallback to the ascii key code but | |
803 | // don't do anything for function keys or etc. | |
1b14227e | 804 | if (key <= 127) { |
5fd656d5 | 805 | key = evt.GetKeyCode(); |
1b14227e | 806 | keyOk = (key <= 127); |
5fd656d5 RD |
807 | } |
808 | if (keyOk) { | |
809 | m_swx->DoAddChar(key); | |
810 | return; | |
811 | } | |
812 | #else | |
813 | int key = evt.GetKeyCode(); | |
814 | if (key <= WXK_START || key > WXK_COMMAND) { | |
815 | m_swx->DoAddChar(key); | |
816 | return; | |
817 | } | |
818 | #endif | |
f97d84a6 | 819 | } |
7e0c58e9 | 820 | |
f3c2c221 | 821 | evt.Skip(); |
f97d84a6 RD |
822 | } |
823 | ||
d6582821 | 824 | |
f97d84a6 | 825 | void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { |
5fd656d5 | 826 | int processed = m_swx->DoKeyDown(evt, &m_lastKeyDownConsumed); |
d6582821 | 827 | if (!processed && !m_lastKeyDownConsumed) |
f97d84a6 RD |
828 | evt.Skip(); |
829 | } | |
830 | ||
d6582821 | 831 | |
b6bfd8e8 | 832 | void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { |
ec830416 | 833 | m_swx->DoLoseFocus(); |
b6bfd8e8 | 834 | evt.Skip(); |
f97d84a6 RD |
835 | } |
836 | ||
d6582821 | 837 | |
b6bfd8e8 | 838 | void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { |
f97d84a6 | 839 | m_swx->DoGainFocus(); |
b6bfd8e8 | 840 | evt.Skip(); |
f97d84a6 RD |
841 | } |
842 | ||
d6582821 | 843 | |
88a8b04e | 844 | void wxStyledTextCtrl::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(evt)) { |
f97d84a6 RD |
845 | m_swx->DoSysColourChange(); |
846 | } | |
847 | ||
d6582821 | 848 | |
88a8b04e | 849 | void wxStyledTextCtrl::OnEraseBackground(wxEraseEvent& WXUNUSED(evt)) { |
f97d84a6 RD |
850 | // do nothing to help avoid flashing |
851 | } | |
852 | ||
853 | ||
854 | ||
855 | void wxStyledTextCtrl::OnMenu(wxCommandEvent& evt) { | |
856 | m_swx->DoCommand(evt.GetId()); | |
857 | } | |
858 | ||
859 | ||
88a8b04e | 860 | void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { |
f97d84a6 RD |
861 | m_swx->DoOnListBox(); |
862 | } | |
863 | ||
864 | ||
8e54aaed RD |
865 | void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { |
866 | m_swx->DoOnIdle(evt); | |
867 | } | |
868 | ||
869 | ||
8ae4f086 RD |
870 | wxSize wxStyledTextCtrl::DoGetBestSize() const |
871 | { | |
872 | // What would be the best size for a wxSTC? | |
873 | // Just give a reasonable minimum until something else can be figured out. | |
874 | return wxSize(200,100); | |
875 | } | |
876 | ||
877 | ||
f97d84a6 RD |
878 | //---------------------------------------------------------------------- |
879 | // Turn notifications from Scintilla into events | |
880 | ||
881 | ||
882 | void wxStyledTextCtrl::NotifyChange() { | |
883 | wxStyledTextEvent evt(wxEVT_STC_CHANGE, GetId()); | |
a29a241f | 884 | evt.SetEventObject(this); |
f97d84a6 RD |
885 | GetEventHandler()->ProcessEvent(evt); |
886 | } | |
887 | ||
2b5f62a0 VZ |
888 | |
889 | static void SetEventText(wxStyledTextEvent& evt, const char* text, | |
890 | size_t length) { | |
891 | if(!text) return; | |
892 | ||
1c930beb | 893 | evt.SetText(stc2wx(text, length)); |
2b5f62a0 VZ |
894 | } |
895 | ||
896 | ||
f97d84a6 RD |
897 | void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { |
898 | SCNotification& scn = *_scn; | |
65ec6247 RD |
899 | wxStyledTextEvent evt(0, GetId()); |
900 | ||
a29a241f | 901 | evt.SetEventObject(this); |
65ec6247 RD |
902 | evt.SetPosition(scn.position); |
903 | evt.SetKey(scn.ch); | |
904 | evt.SetModifiers(scn.modifiers); | |
905 | ||
f97d84a6 RD |
906 | switch (scn.nmhdr.code) { |
907 | case SCN_STYLENEEDED: | |
65ec6247 | 908 | evt.SetEventType(wxEVT_STC_STYLENEEDED); |
f97d84a6 | 909 | break; |
65ec6247 | 910 | |
f97d84a6 | 911 | case SCN_CHARADDED: |
65ec6247 | 912 | evt.SetEventType(wxEVT_STC_CHARADDED); |
f97d84a6 | 913 | break; |
65ec6247 | 914 | |
f97d84a6 | 915 | case SCN_SAVEPOINTREACHED: |
65ec6247 | 916 | evt.SetEventType(wxEVT_STC_SAVEPOINTREACHED); |
f97d84a6 | 917 | break; |
65ec6247 | 918 | |
f97d84a6 | 919 | case SCN_SAVEPOINTLEFT: |
65ec6247 | 920 | evt.SetEventType(wxEVT_STC_SAVEPOINTLEFT); |
f97d84a6 | 921 | break; |
65ec6247 | 922 | |
f97d84a6 | 923 | case SCN_MODIFYATTEMPTRO: |
65ec6247 RD |
924 | evt.SetEventType(wxEVT_STC_ROMODIFYATTEMPT); |
925 | break; | |
926 | ||
927 | case SCN_KEY: | |
928 | evt.SetEventType(wxEVT_STC_KEY); | |
f97d84a6 | 929 | break; |
65ec6247 | 930 | |
f97d84a6 | 931 | case SCN_DOUBLECLICK: |
65ec6247 | 932 | evt.SetEventType(wxEVT_STC_DOUBLECLICK); |
f97d84a6 | 933 | break; |
65ec6247 RD |
934 | |
935 | case SCN_UPDATEUI: | |
936 | evt.SetEventType(wxEVT_STC_UPDATEUI); | |
f97d84a6 | 937 | break; |
65ec6247 RD |
938 | |
939 | case SCN_MODIFIED: | |
940 | evt.SetEventType(wxEVT_STC_MODIFIED); | |
941 | evt.SetModificationType(scn.modificationType); | |
2b5f62a0 | 942 | SetEventText(evt, scn.text, scn.length); |
65ec6247 RD |
943 | evt.SetLength(scn.length); |
944 | evt.SetLinesAdded(scn.linesAdded); | |
945 | evt.SetLine(scn.line); | |
946 | evt.SetFoldLevelNow(scn.foldLevelNow); | |
947 | evt.SetFoldLevelPrev(scn.foldLevelPrev); | |
f97d84a6 | 948 | break; |
65ec6247 | 949 | |
f97d84a6 | 950 | case SCN_MACRORECORD: |
65ec6247 RD |
951 | evt.SetEventType(wxEVT_STC_MACRORECORD); |
952 | evt.SetMessage(scn.message); | |
953 | evt.SetWParam(scn.wParam); | |
954 | evt.SetLParam(scn.lParam); | |
f97d84a6 | 955 | break; |
65ec6247 | 956 | |
f97d84a6 | 957 | case SCN_MARGINCLICK: |
65ec6247 RD |
958 | evt.SetEventType(wxEVT_STC_MARGINCLICK); |
959 | evt.SetMargin(scn.margin); | |
f97d84a6 | 960 | break; |
65ec6247 | 961 | |
f97d84a6 | 962 | case SCN_NEEDSHOWN: |
65ec6247 RD |
963 | evt.SetEventType(wxEVT_STC_NEEDSHOWN); |
964 | evt.SetLength(scn.length); | |
f97d84a6 | 965 | break; |
65ec6247 | 966 | |
65ec6247 RD |
967 | case SCN_PAINTED: |
968 | evt.SetEventType(wxEVT_STC_PAINTED); | |
969 | break; | |
970 | ||
0daf5e6b RD |
971 | case SCN_AUTOCSELECTION: |
972 | evt.SetEventType(wxEVT_STC_AUTOCOMP_SELECTION); | |
973 | evt.SetListType(scn.listType); | |
974 | SetEventText(evt, scn.text, strlen(scn.text)); | |
975 | evt.SetPosition(scn.lParam); | |
976 | break; | |
7e0c58e9 | 977 | |
65ec6247 RD |
978 | case SCN_USERLISTSELECTION: |
979 | evt.SetEventType(wxEVT_STC_USERLISTSELECTION); | |
980 | evt.SetListType(scn.listType); | |
2b5f62a0 | 981 | SetEventText(evt, scn.text, strlen(scn.text)); |
0daf5e6b | 982 | evt.SetPosition(scn.lParam); |
f97d84a6 | 983 | break; |
f97d84a6 | 984 | |
65ec6247 RD |
985 | case SCN_URIDROPPED: |
986 | evt.SetEventType(wxEVT_STC_URIDROPPED); | |
2b5f62a0 | 987 | SetEventText(evt, scn.text, strlen(scn.text)); |
65ec6247 RD |
988 | break; |
989 | ||
990 | case SCN_DWELLSTART: | |
991 | evt.SetEventType(wxEVT_STC_DWELLSTART); | |
992 | evt.SetX(scn.x); | |
993 | evt.SetY(scn.y); | |
994 | break; | |
995 | ||
996 | case SCN_DWELLEND: | |
997 | evt.SetEventType(wxEVT_STC_DWELLEND); | |
998 | evt.SetX(scn.x); | |
999 | evt.SetY(scn.y); | |
1000 | break; | |
1001 | ||
a834585d RD |
1002 | case SCN_ZOOM: |
1003 | evt.SetEventType(wxEVT_STC_ZOOM); | |
1004 | break; | |
1005 | ||
9e730a78 RD |
1006 | case SCN_HOTSPOTCLICK: |
1007 | evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK); | |
1008 | break; | |
1009 | ||
1010 | case SCN_HOTSPOTDOUBLECLICK: | |
1011 | evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK); | |
1012 | break; | |
1013 | ||
1014 | case SCN_CALLTIPCLICK: | |
1015 | evt.SetEventType(wxEVT_STC_CALLTIP_CLICK); | |
1016 | break; | |
7e0c58e9 RD |
1017 | |
1018 | case SCN_INDICATORCLICK: | |
1019 | evt.SetEventType(wxEVT_STC_INDICATOR_CLICK); | |
1020 | break; | |
1021 | ||
1022 | case SCN_INDICATORRELEASE: | |
1023 | evt.SetEventType(wxEVT_STC_INDICATOR_RELEASE); | |
1024 | break; | |
1025 | ||
9e96e16f RD |
1026 | case SCN_AUTOCCANCELLED: |
1027 | evt.SetEventType(wxEVT_STC_AUTOCOMP_CANCELLED); | |
1028 | break; | |
1029 | ||
1030 | case SCN_AUTOCCHARDELETED: | |
1031 | evt.SetEventType(wxEVT_STC_AUTOCOMP_CHAR_DELETED); | |
1032 | break; | |
1033 | ||
65ec6247 RD |
1034 | default: |
1035 | return; | |
f97d84a6 | 1036 | } |
65ec6247 RD |
1037 | |
1038 | GetEventHandler()->ProcessEvent(evt); | |
f97d84a6 RD |
1039 | } |
1040 | ||
1041 | ||
f97d84a6 RD |
1042 | //---------------------------------------------------------------------- |
1043 | //---------------------------------------------------------------------- | |
1044 | //---------------------------------------------------------------------- | |
1045 | ||
1046 | wxStyledTextEvent::wxStyledTextEvent(wxEventType commandType, int id) | |
1047 | : wxCommandEvent(commandType, id) | |
1048 | { | |
1049 | m_position = 0; | |
1050 | m_key = 0; | |
1051 | m_modifiers = 0; | |
1052 | m_modificationType = 0; | |
1053 | m_length = 0; | |
1054 | m_linesAdded = 0; | |
1055 | m_line = 0; | |
1056 | m_foldLevelNow = 0; | |
1057 | m_foldLevelPrev = 0; | |
1058 | m_margin = 0; | |
1059 | m_message = 0; | |
1060 | m_wParam = 0; | |
1061 | m_lParam = 0; | |
65ec6247 RD |
1062 | m_listType = 0; |
1063 | m_x = 0; | |
1064 | m_y = 0; | |
92bbd64f | 1065 | #if wxUSE_DRAG_AND_DROP |
35f8d83d | 1066 | m_dragFlags = wxDrag_CopyOnly; |
a29a241f | 1067 | m_dragResult = wxDragNone; |
92bbd64f | 1068 | #endif |
f97d84a6 RD |
1069 | } |
1070 | ||
1071 | bool wxStyledTextEvent::GetShift() const { return (m_modifiers & SCI_SHIFT) != 0; } | |
1072 | bool wxStyledTextEvent::GetControl() const { return (m_modifiers & SCI_CTRL) != 0; } | |
1073 | bool wxStyledTextEvent::GetAlt() const { return (m_modifiers & SCI_ALT) != 0; } | |
1074 | ||
f97d84a6 | 1075 | |
5fa4613c RD |
1076 | wxStyledTextEvent::wxStyledTextEvent(const wxStyledTextEvent& event): |
1077 | wxCommandEvent(event) | |
1078 | { | |
1079 | m_position = event.m_position; | |
1080 | m_key = event.m_key; | |
1081 | m_modifiers = event.m_modifiers; | |
1082 | m_modificationType = event.m_modificationType; | |
1083 | m_text = event.m_text; | |
1084 | m_length = event.m_length; | |
1085 | m_linesAdded = event.m_linesAdded; | |
1086 | m_line = event.m_line; | |
1087 | m_foldLevelNow = event.m_foldLevelNow; | |
1088 | m_foldLevelPrev = event.m_foldLevelPrev; | |
1089 | ||
1090 | m_margin = event.m_margin; | |
1091 | ||
1092 | m_message = event.m_message; | |
1093 | m_wParam = event.m_wParam; | |
1094 | m_lParam = event.m_lParam; | |
1095 | ||
1096 | m_listType = event.m_listType; | |
1097 | m_x = event.m_x; | |
1098 | m_y = event.m_y; | |
f97d84a6 | 1099 | |
92bbd64f | 1100 | #if wxUSE_DRAG_AND_DROP |
35f8d83d VZ |
1101 | m_dragText = event.m_dragText; |
1102 | m_dragFlags = event.m_dragFlags; | |
5fa4613c | 1103 | m_dragResult = event.m_dragResult; |
92bbd64f | 1104 | #endif |
f97d84a6 RD |
1105 | } |
1106 | ||
1107 | //---------------------------------------------------------------------- | |
1108 | //---------------------------------------------------------------------- | |
1109 | ||
ccec9093 VZ |
1110 | /*static*/ wxVersionInfo wxStyledTextCtrl::GetLibraryVersionInfo() |
1111 | { | |
9c1f960f | 1112 | return wxVersionInfo("Scintilla", 2, 3, 0, "Scintilla 2.03"); |
ccec9093 VZ |
1113 | } |
1114 | ||
29825f5f | 1115 | #endif // wxUSE_STC |