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