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