]>
Commit | Line | Data |
---|---|---|
9ce192d4 RD |
1 | //////////////////////////////////////////////////////////////////////////// |
2 | // Name: ScintillaWX.cxx | |
3 | // Purpose: A wxWindows implementation of Scintilla. A class derived | |
4 | // from ScintillaBase that uses the "wx platform" defined in | |
5 | // PlatformWX.cxx This class is one end of a bridge between | |
6 | // the wx world and the Scintilla world. It needs a peer | |
7 | // object of type wxStyledTextCtrl to function. | |
8 | // | |
9 | // Author: Robin Dunn | |
10 | // | |
11 | // Created: 13-Jan-2000 | |
12 | // RCS-ID: $Id$ | |
13 | // Copyright: (c) 2000 by Total Control Software | |
14 | // Licence: wxWindows license | |
15 | ///////////////////////////////////////////////////////////////////////////// | |
16 | ||
f6bcfd97 BP |
17 | #include <ctype.h> |
18 | ||
9ce192d4 RD |
19 | #include "ScintillaWX.h" |
20 | #include "wx/stc/stc.h" | |
21 | ||
22 | ||
23 | //---------------------------------------------------------------------- | |
24 | ||
5fa4613c | 25 | const int H_SCROLL_MAX = 4000; |
9ce192d4 RD |
26 | const int H_SCROLL_STEP = 20; |
27 | const int H_SCROLL_PAGE = 200; | |
28 | ||
29 | //---------------------------------------------------------------------- | |
30 | // Helper classes | |
31 | ||
32 | class wxSTCTimer : public wxTimer { | |
33 | public: | |
34 | wxSTCTimer(ScintillaWX* swx) { | |
35 | this->swx = swx; | |
36 | } | |
37 | ||
38 | void Notify() { | |
39 | swx->DoTick(); | |
40 | } | |
41 | ||
42 | private: | |
43 | ScintillaWX* swx; | |
44 | }; | |
45 | ||
46 | ||
1bc32508 | 47 | #if wxUSE_DRAG_AND_DROP |
9ce192d4 RD |
48 | bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) { |
49 | return swx->DoDropText(x, y, data); | |
50 | } | |
51 | ||
52 | wxDragResult wxSTCDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) { | |
53 | return swx->DoDragEnter(x, y, def); | |
54 | } | |
55 | ||
56 | wxDragResult wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) { | |
57 | return swx->DoDragOver(x, y, def); | |
58 | } | |
59 | ||
60 | void wxSTCDropTarget::OnLeave() { | |
61 | swx->DoDragLeave(); | |
62 | } | |
1bc32508 | 63 | #endif |
9ce192d4 RD |
64 | |
65 | ||
769a9cb2 RD |
66 | #if wxUSE_POPUPWIN |
67 | #include <wx/popupwin.h> | |
68 | #define wxSTCCallTipBase wxPopupWindow | |
69 | #define param2 wxBORDER_NONE // popup's 2nd param is flags | |
70 | #else | |
71 | #define wxSTCCallTipBase wxWindow | |
72 | #define param2 -1 // wxWindows 2nd param is ID | |
73 | #endif | |
74 | ||
75 | class wxSTCCallTip : public wxSTCCallTipBase { | |
f6bcfd97 | 76 | public: |
769a9cb2 RD |
77 | wxSTCCallTip(wxWindow* parent, CallTip* ct) |
78 | : wxSTCCallTipBase(parent, param2) | |
f6bcfd97 BP |
79 | { |
80 | m_ct = ct; | |
81 | } | |
82 | ||
83 | void OnPaint(wxPaintEvent& evt) { | |
84 | wxPaintDC dc(this); | |
85 | Surface surfaceWindow; | |
86 | surfaceWindow.Init(&dc); | |
87 | m_ct->PaintCT(&surfaceWindow); | |
88 | surfaceWindow.Release(); | |
89 | } | |
90 | ||
769a9cb2 RD |
91 | #if wxUSE_POPUPWIN |
92 | virtual void DoSetSize(int x, int y, | |
93 | int width, int height, | |
94 | int sizeFlags = wxSIZE_AUTO) { | |
95 | if (x != -1) | |
96 | GetParent()->ClientToScreen(&x, NULL); | |
97 | if (y != -1) | |
98 | GetParent()->ClientToScreen(NULL, &y); | |
99 | wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); | |
100 | } | |
101 | #endif | |
102 | ||
103 | private: | |
f6bcfd97 BP |
104 | CallTip* m_ct; |
105 | DECLARE_EVENT_TABLE() | |
106 | }; | |
107 | ||
769a9cb2 | 108 | BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) |
f6bcfd97 BP |
109 | EVT_PAINT(wxSTCCallTip::OnPaint) |
110 | END_EVENT_TABLE() | |
9ce192d4 | 111 | |
769a9cb2 | 112 | |
9ce192d4 RD |
113 | //---------------------------------------------------------------------- |
114 | // Constructor/Destructor | |
115 | ||
116 | ||
117 | ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) { | |
118 | capturedMouse = false; | |
119 | wMain = win; | |
9ce192d4 | 120 | stc = win; |
37d62433 | 121 | wheelRotation = 0; |
9ce192d4 RD |
122 | Initialise(); |
123 | } | |
124 | ||
125 | ||
126 | ScintillaWX::~ScintillaWX() { | |
127 | SetTicking(false); | |
128 | } | |
129 | ||
130 | //---------------------------------------------------------------------- | |
131 | // base class virtuals | |
132 | ||
133 | ||
134 | void ScintillaWX::Initialise() { | |
135 | //ScintillaBase::Initialise(); | |
1bc32508 | 136 | #if wxUSE_DRAG_AND_DROP |
9eb662e9 RD |
137 | dropTarget = new wxSTCDropTarget; |
138 | dropTarget->SetScintilla(this); | |
139 | stc->SetDropTarget(dropTarget); | |
1bc32508 | 140 | #endif |
9ce192d4 RD |
141 | } |
142 | ||
143 | ||
144 | void ScintillaWX::Finalise() { | |
145 | ScintillaBase::Finalise(); | |
146 | } | |
147 | ||
148 | ||
149 | void ScintillaWX::StartDrag() { | |
1bc32508 | 150 | #if wxUSE_DRAG_AND_DROP |
a29a241f RD |
151 | wxString dragText(drag.s, drag.len); |
152 | ||
153 | // Send an event to allow the drag text to be changed | |
154 | wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId()); | |
155 | evt.SetEventObject(stc); | |
156 | evt.SetDragText(dragText); | |
157 | evt.SetDragAllowMove(TRUE); | |
158 | evt.SetPosition(wxMin(stc->GetSelectionStart(), | |
159 | stc->GetSelectionEnd())); | |
160 | stc->GetEventHandler()->ProcessEvent(evt); | |
161 | dragText = evt.GetDragText(); | |
162 | ||
163 | if (dragText.Length()) { | |
5fa4613c | 164 | wxDropSource source(stc); |
a29a241f RD |
165 | wxTextDataObject data(dragText); |
166 | wxDragResult result; | |
167 | ||
168 | source.SetData(data); | |
169 | dropWentOutside = TRUE; | |
170 | result = source.DoDragDrop(evt.GetDragAllowMove()); | |
171 | if (result == wxDragMove && dropWentOutside) | |
172 | ClearSelection(); | |
173 | inDragDrop = FALSE; | |
174 | SetDragPosition(invalidPosition); | |
175 | } | |
1bc32508 | 176 | #endif |
9ce192d4 RD |
177 | } |
178 | ||
179 | ||
180 | void ScintillaWX::SetTicking(bool on) { | |
181 | wxSTCTimer* steTimer; | |
182 | if (timer.ticking != on) { | |
183 | timer.ticking = on; | |
184 | if (timer.ticking) { | |
185 | steTimer = new wxSTCTimer(this); | |
186 | steTimer->Start(timer.tickSize); | |
187 | timer.tickerID = (int)steTimer; | |
188 | } else { | |
189 | steTimer = (wxSTCTimer*)timer.tickerID; | |
190 | steTimer->Stop(); | |
191 | delete steTimer; | |
192 | timer.tickerID = 0; | |
193 | } | |
194 | } | |
195 | timer.ticksToWait = caret.period; | |
196 | } | |
197 | ||
198 | ||
199 | void ScintillaWX::SetMouseCapture(bool on) { | |
8759d4d5 | 200 | if (on && !capturedMouse) |
5fa4613c | 201 | stc->CaptureMouse(); |
8759d4d5 | 202 | else if (!on && capturedMouse) |
5fa4613c | 203 | stc->ReleaseMouse(); |
9ce192d4 RD |
204 | capturedMouse = on; |
205 | } | |
206 | ||
207 | ||
208 | bool ScintillaWX::HaveMouseCapture() { | |
209 | return capturedMouse; | |
210 | } | |
211 | ||
212 | ||
213 | void ScintillaWX::ScrollText(int linesToMove) { | |
214 | int dy = vs.lineHeight * (linesToMove); | |
5fa4613c RD |
215 | stc->ScrollWindow(0, dy); |
216 | stc->Update(); | |
9ce192d4 RD |
217 | } |
218 | ||
219 | void ScintillaWX::SetVerticalScrollPos() { | |
5fa4613c RD |
220 | if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar |
221 | stc->SetScrollPos(wxVERTICAL, topLine); | |
222 | } | |
223 | else { // otherwise use the one that's been given to us | |
224 | stc->m_vScrollBar->SetThumbPosition(topLine); | |
225 | } | |
9ce192d4 RD |
226 | } |
227 | ||
228 | void ScintillaWX::SetHorizontalScrollPos() { | |
5fa4613c RD |
229 | if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar |
230 | stc->SetScrollPos(wxHORIZONTAL, xOffset); | |
231 | } | |
232 | else { // otherwise use the one that's been given to us | |
233 | stc->m_hScrollBar->SetThumbPosition(xOffset); | |
234 | } | |
9ce192d4 RD |
235 | } |
236 | ||
237 | ||
238 | bool ScintillaWX::ModifyScrollBars(int nMax, int nPage) { | |
239 | bool modified = false; | |
9ce192d4 | 240 | |
5fa4613c RD |
241 | if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar |
242 | int sbMax = stc->GetScrollRange(wxVERTICAL); | |
243 | int sbThumb = stc->GetScrollThumb(wxVERTICAL); | |
244 | int sbPos = stc->GetScrollPos(wxVERTICAL); | |
245 | if (sbMax != nMax || sbThumb != nPage) { | |
246 | stc->SetScrollbar(wxVERTICAL, sbPos, nPage, nMax); | |
247 | modified = true; | |
248 | } | |
249 | } | |
250 | else { // otherwise use the one that's been given to us | |
251 | int sbMax = stc->m_vScrollBar->GetRange(); | |
252 | int sbPage = stc->m_vScrollBar->GetPageSize(); | |
253 | int sbPos = stc->m_vScrollBar->GetThumbPosition(); | |
254 | if (sbMax != nMax || sbPage != nPage) { | |
255 | stc->m_vScrollBar->SetScrollbar(sbPos, nPage, nMax, nPage); | |
256 | modified = true; | |
257 | } | |
9ce192d4 RD |
258 | } |
259 | ||
5fa4613c | 260 | |
3928c4fd | 261 | if (horizontalScrollBarVisible) { |
5fa4613c RD |
262 | if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar |
263 | int sbMax = stc->GetScrollRange(wxHORIZONTAL); | |
264 | int sbThumb = stc->GetScrollThumb(wxHORIZONTAL); | |
265 | if ((sbMax != H_SCROLL_MAX) || (sbThumb != H_SCROLL_STEP)) { | |
266 | stc->SetScrollbar(wxHORIZONTAL, 0, H_SCROLL_STEP, H_SCROLL_MAX); | |
267 | modified = true; | |
268 | } | |
269 | } | |
270 | else { // otherwise use the one that's been given to us | |
271 | int sbMax = stc->m_hScrollBar->GetRange(); | |
272 | int sbPage = stc->m_hScrollBar->GetPageSize(); | |
273 | if ((sbMax != H_SCROLL_MAX) || (sbPage != H_SCROLL_STEP)) { | |
274 | stc->m_hScrollBar->SetScrollbar(0, H_SCROLL_STEP, H_SCROLL_MAX, H_SCROLL_STEP); | |
275 | modified = true; | |
276 | } | |
3928c4fd | 277 | } |
9ce192d4 RD |
278 | } |
279 | return modified; | |
280 | } | |
281 | ||
282 | ||
283 | void ScintillaWX::NotifyChange() { | |
284 | stc->NotifyChange(); | |
285 | } | |
286 | ||
287 | ||
288 | void ScintillaWX::NotifyParent(SCNotification scn) { | |
289 | stc->NotifyParent(&scn); | |
290 | } | |
291 | ||
292 | ||
293 | ||
294 | void ScintillaWX::Copy() { | |
295 | if (currentPos != anchor) { | |
b8b0e402 RD |
296 | SelectionText st; |
297 | CopySelectionRange(&st); | |
9ce192d4 | 298 | wxTheClipboard->Open(); |
b8b0e402 | 299 | wxTheClipboard->SetData(new wxTextDataObject(wxString(st.s, st.len))); |
9ce192d4 RD |
300 | wxTheClipboard->Close(); |
301 | } | |
302 | } | |
303 | ||
304 | ||
305 | void ScintillaWX::Paste() { | |
306 | pdoc->BeginUndoAction(); | |
307 | ClearSelection(); | |
308 | ||
309 | wxTextDataObject data; | |
e26c0634 | 310 | bool gotData; |
9ce192d4 RD |
311 | |
312 | wxTheClipboard->Open(); | |
e26c0634 | 313 | gotData = wxTheClipboard->GetData(data); |
9ce192d4 | 314 | wxTheClipboard->Close(); |
e26c0634 | 315 | if (gotData) { |
9ce192d4 RD |
316 | wxString str = data.GetText(); |
317 | int len = str.Length(); | |
318 | pdoc->InsertString(currentPos, str.c_str(), len); | |
319 | SetEmptySelection(currentPos + len); | |
320 | } | |
321 | ||
322 | pdoc->EndUndoAction(); | |
323 | NotifyChange(); | |
324 | Redraw(); | |
325 | } | |
326 | ||
327 | ||
328 | bool ScintillaWX::CanPaste() { | |
9ce192d4 RD |
329 | bool canPaste; |
330 | ||
331 | wxTheClipboard->Open(); | |
e26c0634 | 332 | canPaste = wxTheClipboard->IsSupported( wxDF_TEXT ); |
9ce192d4 RD |
333 | wxTheClipboard->Close(); |
334 | ||
335 | return canPaste; | |
336 | } | |
337 | ||
338 | void ScintillaWX::CreateCallTipWindow(PRectangle) { | |
769a9cb2 | 339 | ct.wCallTip = new wxSTCCallTip(stc, &ct); |
9ce192d4 RD |
340 | ct.wDraw = ct.wCallTip; |
341 | } | |
342 | ||
343 | ||
344 | void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) { | |
345 | if (!label[0]) | |
346 | popup.GetID()->AppendSeparator(); | |
347 | else | |
348 | popup.GetID()->Append(cmd, label); | |
349 | ||
350 | if (!enabled) | |
351 | popup.GetID()->Enable(cmd, enabled); | |
9ce192d4 RD |
352 | } |
353 | ||
354 | ||
355 | void ScintillaWX::ClaimSelection() { | |
356 | ||
357 | } | |
358 | ||
359 | ||
d134f170 | 360 | long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) { |
9ce192d4 RD |
361 | return 0; |
362 | } | |
363 | ||
d134f170 RD |
364 | long ScintillaWX::WndProc(unsigned int iMessage, unsigned long wParam, long lParam) { |
365 | // switch (iMessage) { | |
366 | // case EM_CANPASTE: | |
367 | // return CanPaste(); | |
368 | // default: | |
9ce192d4 | 369 | return ScintillaBase::WndProc(iMessage, wParam, lParam); |
d134f170 RD |
370 | // } |
371 | // return 0; | |
9ce192d4 RD |
372 | } |
373 | ||
374 | ||
375 | ||
376 | //---------------------------------------------------------------------- | |
377 | // Event delegates | |
378 | ||
379 | void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) { | |
380 | ||
381 | paintState = painting; | |
382 | Surface surfaceWindow; | |
383 | surfaceWindow.Init(dc); | |
384 | PRectangle rcPaint = PRectangleFromwxRect(rect); | |
385 | dc->BeginDrawing(); | |
386 | Paint(&surfaceWindow, rcPaint); | |
387 | dc->EndDrawing(); | |
388 | surfaceWindow.Release(); | |
389 | if (paintState == paintAbandoned) { | |
390 | // Painting area was insufficient to cover new styling or brace highlight positions | |
391 | FullPaint(); | |
392 | } | |
393 | paintState = notPainting; | |
f97d84a6 RD |
394 | #ifdef __WXGTK__ |
395 | // On wxGTK the editor window paints can overwrite the listbox... | |
396 | if (ac.Active()) | |
397 | ((wxWindow*)ac.lb.GetID())->Refresh(TRUE); | |
398 | #endif | |
9ce192d4 RD |
399 | } |
400 | ||
401 | ||
402 | void ScintillaWX::DoHScroll(int type, int pos) { | |
403 | int xPos = xOffset; | |
5fa4613c | 404 | if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) |
9ce192d4 | 405 | xPos -= H_SCROLL_STEP; |
5fa4613c | 406 | else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) |
9ce192d4 | 407 | xPos += H_SCROLL_STEP; |
5fa4613c | 408 | else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) |
9ce192d4 | 409 | xPos -= H_SCROLL_PAGE; |
5fa4613c | 410 | else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) |
9ce192d4 | 411 | xPos += H_SCROLL_PAGE; |
5fa4613c | 412 | else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) |
9ce192d4 | 413 | xPos = 0; |
5fa4613c | 414 | else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) |
9ce192d4 | 415 | xPos = H_SCROLL_MAX; |
5fa4613c | 416 | else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) |
9ce192d4 | 417 | xPos = pos; |
ce1ecc6d | 418 | |
9ce192d4 RD |
419 | HorizontalScrollTo(xPos); |
420 | } | |
421 | ||
422 | void ScintillaWX::DoVScroll(int type, int pos) { | |
423 | int topLineNew = topLine; | |
5fa4613c | 424 | if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP) |
9ce192d4 | 425 | topLineNew -= 1; |
5fa4613c | 426 | else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN) |
9ce192d4 | 427 | topLineNew += 1; |
5fa4613c | 428 | else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP) |
9ce192d4 | 429 | topLineNew -= LinesToScroll(); |
5fa4613c | 430 | else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) |
9ce192d4 | 431 | topLineNew += LinesToScroll(); |
5fa4613c | 432 | else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP) |
9ce192d4 | 433 | topLineNew = 0; |
5fa4613c | 434 | else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM) |
9ce192d4 | 435 | topLineNew = MaxScrollPos(); |
5fa4613c | 436 | else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK) |
9ce192d4 | 437 | topLineNew = pos; |
ce1ecc6d | 438 | |
9ce192d4 RD |
439 | ScrollTo(topLineNew); |
440 | } | |
441 | ||
37d62433 | 442 | |
65ec6247 | 443 | void ScintillaWX::DoMouseWheel(int rotation, int delta, int linesPerAction, int ctrlDown) { |
37d62433 RD |
444 | int topLineNew = topLine; |
445 | int lines; | |
446 | ||
65ec6247 RD |
447 | if (ctrlDown) { // Zoom the fonts if Ctrl key down |
448 | if (rotation < 0) { | |
449 | KeyCommand(SCI_ZOOMIN); | |
450 | } | |
451 | else { | |
452 | KeyCommand(SCI_ZOOMOUT); | |
453 | } | |
454 | } | |
455 | else { // otherwise just scroll the window | |
456 | wheelRotation += rotation; | |
457 | lines = wheelRotation / delta; | |
458 | wheelRotation -= lines * delta; | |
459 | if (lines != 0) { | |
460 | lines *= linesPerAction; | |
461 | topLineNew -= lines; | |
462 | ScrollTo(topLineNew); | |
463 | } | |
37d62433 RD |
464 | } |
465 | } | |
466 | ||
467 | ||
9ce192d4 RD |
468 | void ScintillaWX::DoSize(int width, int height) { |
469 | PRectangle rcClient(0,0,width,height); | |
470 | SetScrollBarsTo(rcClient); | |
471 | DropGraphics(); | |
472 | } | |
473 | ||
474 | void ScintillaWX::DoLoseFocus(){ | |
65ec6247 | 475 | SetFocusState(false); |
9ce192d4 RD |
476 | } |
477 | ||
478 | void ScintillaWX::DoGainFocus(){ | |
65ec6247 | 479 | SetFocusState(true); |
9ce192d4 RD |
480 | } |
481 | ||
482 | void ScintillaWX::DoSysColourChange() { | |
483 | InvalidateStyleData(); | |
484 | } | |
485 | ||
486 | void ScintillaWX::DoButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) { | |
487 | ButtonDown(pt, curTime, shift, ctrl, alt); | |
488 | } | |
489 | ||
490 | void ScintillaWX::DoButtonUp(Point pt, unsigned int curTime, bool ctrl) { | |
491 | ButtonUp(pt, curTime, ctrl); | |
492 | } | |
493 | ||
494 | void ScintillaWX::DoButtonMove(Point pt) { | |
495 | ButtonMove(pt); | |
496 | } | |
497 | ||
498 | ||
499 | void ScintillaWX::DoAddChar(char ch) { | |
500 | AddChar(ch); | |
501 | } | |
502 | ||
65ec6247 | 503 | int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) { |
39178e3b RD |
504 | #ifdef __WXGTK__ |
505 | // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK... | |
506 | if (ctrl && key >= 1 && key <= 26) | |
507 | key += 'A' - 1; | |
508 | #endif | |
509 | ||
d134f170 | 510 | switch (key) { |
d6582821 RD |
511 | case WXK_DOWN: key = SCK_DOWN; break; |
512 | case WXK_UP: key = SCK_UP; break; | |
513 | case WXK_LEFT: key = SCK_LEFT; break; | |
514 | case WXK_RIGHT: key = SCK_RIGHT; break; | |
515 | case WXK_HOME: key = SCK_HOME; break; | |
516 | case WXK_END: key = SCK_END; break; | |
517 | case WXK_PRIOR: key = SCK_PRIOR; break; | |
518 | case WXK_NEXT: key = SCK_NEXT; break; | |
519 | case WXK_DELETE: key = SCK_DELETE; break; | |
520 | case WXK_INSERT: key = SCK_INSERT; break; | |
521 | case WXK_ESCAPE: key = SCK_ESCAPE; break; | |
522 | case WXK_BACK: key = SCK_BACK; break; | |
523 | case WXK_TAB: key = SCK_TAB; break; | |
524 | case WXK_RETURN: key = SCK_RETURN; break; | |
525 | case WXK_ADD: | |
526 | case WXK_NUMPAD_ADD: | |
527 | key = SCK_ADD; break; | |
528 | case WXK_SUBTRACT: | |
529 | case WXK_NUMPAD_SUBTRACT: | |
530 | key = SCK_SUBTRACT; break; | |
531 | case WXK_DIVIDE: | |
532 | case WXK_NUMPAD_DIVIDE: | |
533 | key = SCK_DIVIDE; break; | |
534 | case WXK_CONTROL: key = 0; break; | |
535 | case WXK_ALT: key = 0; break; | |
536 | case WXK_SHIFT: key = 0; break; | |
537 | case WXK_MENU: key = 0; break; | |
d134f170 RD |
538 | } |
539 | ||
d6582821 | 540 | int rv = KeyDown(key, shift, ctrl, alt, consumed); |
0122b7e3 | 541 | |
d6582821 RD |
542 | if (key) |
543 | return rv; | |
544 | else | |
545 | return 1; | |
9ce192d4 RD |
546 | } |
547 | ||
548 | ||
549 | void ScintillaWX::DoCommand(int ID) { | |
550 | Command(ID); | |
551 | } | |
552 | ||
553 | ||
554 | void ScintillaWX::DoContextMenu(Point pt) { | |
555 | ContextMenu(pt); | |
556 | } | |
557 | ||
f6bcfd97 BP |
558 | void ScintillaWX::DoOnListBox() { |
559 | AutoCompleteCompleted(); | |
560 | } | |
9ce192d4 RD |
561 | |
562 | //---------------------------------------------------------------------- | |
563 | ||
1bc32508 | 564 | #if wxUSE_DRAG_AND_DROP |
9ce192d4 RD |
565 | bool ScintillaWX::DoDropText(long x, long y, const wxString& data) { |
566 | SetDragPosition(invalidPosition); | |
a29a241f RD |
567 | |
568 | // Send an event to allow the drag details to be changed | |
569 | wxStyledTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId()); | |
570 | evt.SetEventObject(stc); | |
571 | evt.SetDragResult(dragResult); | |
572 | evt.SetX(x); | |
573 | evt.SetY(y); | |
574 | evt.SetPosition(PositionFromLocation(Point(x,y))); | |
575 | evt.SetDragText(data); | |
576 | stc->GetEventHandler()->ProcessEvent(evt); | |
577 | ||
578 | dragResult = evt.GetDragResult(); | |
579 | if (dragResult == wxDragMove || dragResult == wxDragCopy) { | |
580 | DropAt(evt.GetPosition(), | |
581 | evt.GetDragText(), | |
582 | dragResult == wxDragMove, | |
583 | FALSE); // TODO: rectangular? | |
584 | return TRUE; | |
585 | } | |
586 | return FALSE; | |
9ce192d4 RD |
587 | } |
588 | ||
589 | ||
590 | wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) { | |
b8b0e402 RD |
591 | dragResult = def; |
592 | return dragResult; | |
9ce192d4 RD |
593 | } |
594 | ||
595 | ||
596 | wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) { | |
597 | SetDragPosition(PositionFromLocation(Point(x, y))); | |
a29a241f RD |
598 | |
599 | // Send an event to allow the drag result to be changed | |
600 | wxStyledTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId()); | |
601 | evt.SetEventObject(stc); | |
602 | evt.SetDragResult(def); | |
603 | evt.SetX(x); | |
604 | evt.SetY(y); | |
605 | evt.SetPosition(PositionFromLocation(Point(x,y))); | |
606 | stc->GetEventHandler()->ProcessEvent(evt); | |
607 | ||
608 | dragResult = evt.GetDragResult(); | |
b8b0e402 | 609 | return dragResult; |
9ce192d4 RD |
610 | } |
611 | ||
612 | ||
613 | void ScintillaWX::DoDragLeave() { | |
614 | SetDragPosition(invalidPosition); | |
615 | } | |
1bc32508 | 616 | #endif |
9ce192d4 RD |
617 | //---------------------------------------------------------------------- |
618 | ||
619 | // Redraw all of text area. This paint will not be abandoned. | |
620 | void ScintillaWX::FullPaint() { | |
621 | paintState = painting; | |
a7642be1 RD |
622 | rcPaint = GetTextRectangle(); |
623 | paintingAllText = true; | |
5fa4613c | 624 | wxClientDC dc(stc); |
a7642be1 RD |
625 | Surface surfaceWindow; |
626 | surfaceWindow.Init(&dc); | |
627 | Paint(&surfaceWindow, rcPaint); | |
628 | surfaceWindow.Release(); | |
629 | ||
5fa4613c | 630 | // stc->Refresh(FALSE); |
a7642be1 | 631 | |
9ce192d4 RD |
632 | paintState = notPainting; |
633 | } | |
634 | ||
635 | ||
636 | void ScintillaWX::DoScrollToLine(int line) { | |
637 | ScrollTo(line); | |
638 | } | |
639 | ||
640 | ||
641 | void ScintillaWX::DoScrollToColumn(int column) { | |
642 | HorizontalScrollTo(column * vs.spaceWidth); | |
643 | } | |
644 | ||
645 | ||
646 | ||
647 | //---------------------------------------------------------------------- | |
648 | //---------------------------------------------------------------------- |