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