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.
11 // Created: 13-Jan-2000
13 // Copyright: (c) 2000 by Total Control Software
14 // Licence: wxWindows license
15 /////////////////////////////////////////////////////////////////////////////
18 #include "ScintillaWX.h"
19 #include "ExternalLexer.h"
20 #include "wx/stc/stc.h"
22 #include <wx/textbuf.h>
24 //----------------------------------------------------------------------
27 class wxSTCTimer
: public wxTimer
{
29 wxSTCTimer(ScintillaWX
* swx
) {
42 #if wxUSE_DRAG_AND_DROP
43 bool wxSTCDropTarget::OnDropText(wxCoord x
, wxCoord y
, const wxString
& data
) {
44 return swx
->DoDropText(x
, y
, data
);
47 wxDragResult
wxSTCDropTarget::OnEnter(wxCoord x
, wxCoord y
, wxDragResult def
) {
48 return swx
->DoDragEnter(x
, y
, def
);
51 wxDragResult
wxSTCDropTarget::OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
52 return swx
->DoDragOver(x
, y
, def
);
55 void wxSTCDropTarget::OnLeave() {
62 #undef wxSTC_USE_POPUP
63 #define wxSTC_USE_POPUP 0
66 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
67 #include <wx/popupwin.h>
68 #define wxSTCCallTipBase wxPopupWindow
69 #define param2 wxBORDER_NONE // popup's 2nd param is flags
71 #define wxSTCCallTipBase wxWindow
72 #define param2 -1 // wxWindow's 2nd param is ID
75 class wxSTCCallTip
: public wxSTCCallTipBase
{
77 wxSTCCallTip(wxWindow
* parent
, CallTip
* ct
, ScintillaWX
* swx
)
78 : wxSTCCallTipBase(parent
, param2
),
86 bool AcceptsFocus() const { return FALSE
; }
88 void OnPaint(wxPaintEvent
& evt
) {
90 Surface
* surfaceWindow
= Surface::Allocate();
91 surfaceWindow
->Init(&dc
, m_ct
->wDraw
.GetID());
92 m_ct
->PaintCT(surfaceWindow
);
93 surfaceWindow
->Release();
97 void OnFocus(wxFocusEvent
& event
) {
98 GetParent()->SetFocus();
102 void OnLeftDown(wxMouseEvent
& event
) {
103 wxPoint pt
= event
.GetPosition();
106 m_swx
->CallTipClick();
109 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
110 virtual void DoSetSize(int x
, int y
,
111 int width
, int height
,
112 int sizeFlags
= wxSIZE_AUTO
) {
114 GetParent()->ClientToScreen(&x
, NULL
);
116 GetParent()->ClientToScreen(NULL
, &y
);
117 wxSTCCallTipBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
124 DECLARE_EVENT_TABLE()
127 BEGIN_EVENT_TABLE(wxSTCCallTip
, wxSTCCallTipBase
)
128 EVT_PAINT(wxSTCCallTip::OnPaint
)
129 EVT_SET_FOCUS(wxSTCCallTip::OnFocus
)
130 EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown
)
134 //----------------------------------------------------------------------
135 // Constructor/Destructor
138 ScintillaWX::ScintillaWX(wxStyledTextCtrl
* win
) {
139 capturedMouse
= false;
148 ScintillaWX::~ScintillaWX() {
151 //----------------------------------------------------------------------
152 // base class virtuals
155 void ScintillaWX::Initialise() {
156 //ScintillaBase::Initialise();
157 #if wxUSE_DRAG_AND_DROP
158 dropTarget
= new wxSTCDropTarget
;
159 dropTarget
->SetScintilla(this);
160 stc
->SetDropTarget(dropTarget
);
165 void ScintillaWX::Finalise() {
166 ScintillaBase::Finalise();
172 void ScintillaWX::StartDrag() {
173 #if wxUSE_DRAG_AND_DROP
174 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
176 // Send an event to allow the drag text to be changed
177 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
178 evt
.SetEventObject(stc
);
179 evt
.SetDragText(dragText
);
180 evt
.SetDragAllowMove(TRUE
);
181 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
182 stc
->GetSelectionEnd()));
183 stc
->GetEventHandler()->ProcessEvent(evt
);
184 dragText
= evt
.GetDragText();
186 if (dragText
.Length()) {
187 wxDropSource
source(stc
);
188 wxTextDataObject
data(dragText
);
191 source
.SetData(data
);
192 dropWentOutside
= TRUE
;
193 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
194 if (result
== wxDragMove
&& dropWentOutside
)
197 SetDragPosition(invalidPosition
);
203 bool ScintillaWX::SetIdle(bool on
) {
204 if (idler
.state
!= on
) {
205 // connect or disconnect the EVT_IDLE handler
207 stc
->Connect(-1, wxEVT_IDLE
, (wxObjectEventFunction
)&wxStyledTextCtrl::OnIdle
);
209 stc
->Disconnect(-1, wxEVT_IDLE
, (wxObjectEventFunction
)&wxStyledTextCtrl::OnIdle
);
216 void ScintillaWX::SetTicking(bool on
) {
217 wxSTCTimer
* steTimer
;
218 if (timer
.ticking
!= on
) {
221 steTimer
= new wxSTCTimer(this);
222 steTimer
->Start(timer
.tickSize
);
223 timer
.tickerID
= steTimer
;
225 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
231 timer
.ticksToWait
= caret
.period
;
235 void ScintillaWX::SetMouseCapture(bool on
) {
236 if (mouseDownCaptures
) {
237 if (on
&& !capturedMouse
)
239 else if (!on
&& capturedMouse
&& stc
->HasCapture())
246 bool ScintillaWX::HaveMouseCapture() {
247 return capturedMouse
;
251 void ScintillaWX::ScrollText(int linesToMove
) {
252 int dy
= vs
.lineHeight
* (linesToMove
);
253 stc
->ScrollWindow(0, dy
);
257 void ScintillaWX::SetVerticalScrollPos() {
258 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
259 stc
->SetScrollPos(wxVERTICAL
, topLine
);
261 else { // otherwise use the one that's been given to us
262 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
266 void ScintillaWX::SetHorizontalScrollPos() {
267 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
268 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
270 else { // otherwise use the one that's been given to us
271 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
276 const int H_SCROLL_STEP
= 20;
278 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
279 bool modified
= false;
282 if (!verticalScrollBarVisible
)
285 // Check the vertical scrollbar
286 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
287 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
288 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
289 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
290 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
291 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
295 else { // otherwise use the one that's been given to us
296 int sbMax
= stc
->m_vScrollBar
->GetRange();
297 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
298 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
299 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
300 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
306 // Check the horizontal scrollbar
307 PRectangle rcText
= GetTextRectangle();
308 int horizEnd
= scrollWidth
;
311 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
313 int pageWidth
= rcText
.Width();
315 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
316 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
317 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
318 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
319 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
320 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
322 if (scrollWidth
< pageWidth
) {
323 HorizontalScrollTo(0);
327 else { // otherwise use the one that's been given to us
328 int sbMax
= stc
->m_hScrollBar
->GetRange();
329 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
330 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
331 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
332 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
334 if (scrollWidth
< pageWidth
) {
335 HorizontalScrollTo(0);
344 void ScintillaWX::NotifyChange() {
349 void ScintillaWX::NotifyParent(SCNotification scn
) {
350 stc
->NotifyParent(&scn
);
354 // This method is overloaded from ScintillaBase in order to prevent the
355 // AutoComplete window from being destroyed when it gets the focus. There is
356 // a side effect that the AutoComp will also not be destroyed when switching
357 // to another window, but I think that is okay.
358 void ScintillaWX::CancelModes() {
360 AutoCompleteCancel();
362 Editor::CancelModes();
367 void ScintillaWX::Copy() {
368 if (currentPos
!= anchor
) {
370 CopySelectionRange(&st
);
376 void ScintillaWX::Paste() {
377 pdoc
->BeginUndoAction();
380 wxTextDataObject data
;
381 bool gotData
= FALSE
;
383 if (wxTheClipboard
->Open()) {
384 wxTheClipboard
->UsePrimarySelection(FALSE
);
385 gotData
= wxTheClipboard
->GetData(data
);
386 wxTheClipboard
->Close();
389 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
390 int len
= strlen(buf
);
391 pdoc
->InsertString(currentPos
, buf
, len
);
392 SetEmptySelection(currentPos
+ len
);
395 pdoc
->EndUndoAction();
401 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
402 if (wxTheClipboard
->Open()) {
403 wxTheClipboard
->UsePrimarySelection(FALSE
);
404 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
405 wxTheClipboard
->SetData(new wxTextDataObject(text
));
406 wxTheClipboard
->Close();
411 bool ScintillaWX::CanPaste() {
412 bool canPaste
= FALSE
;
415 if (Editor::CanPaste()) {
416 didOpen
= !wxTheClipboard
->IsOpened();
418 wxTheClipboard
->Open();
420 if (wxTheClipboard
->IsOpened()) {
421 wxTheClipboard
->UsePrimarySelection(FALSE
);
422 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
424 wxTheClipboard
->Close();
430 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
431 if (! ct
.wCallTip
.Created() ) {
432 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
433 ct
.wDraw
= ct
.wCallTip
;
438 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
440 ((wxMenu
*)popup
.GetID())->AppendSeparator();
442 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
445 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
449 // This is called by the Editor base class whenever something is selected
450 void ScintillaWX::ClaimSelection() {
452 // Until wxGTK is able to support using both the primary selection and the
453 // clipboard at the same time I think it causes more problems than it is
454 // worth to implement this method. Selecting text should not clear the
455 // clipboard. --Robin
457 // Put the selected text in the PRIMARY selection
458 if (currentPos
!= anchor
) {
460 CopySelectionRange(&st
);
461 if (wxTheClipboard
->Open()) {
462 wxTheClipboard
->UsePrimarySelection(TRUE
);
463 wxString text
= stc2wx(st
.s
, st
.len
);
464 wxTheClipboard
->SetData(new wxTextDataObject(text
));
465 wxTheClipboard
->UsePrimarySelection(FALSE
);
466 wxTheClipboard
->Close();
474 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
478 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
480 case SCI_CALLTIPSHOW
: {
481 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
482 // because of the little tweak that needs done below for wxGTK.
483 // When updating new versions double check that this is still
484 // needed, and that any new code there is copied here too.
485 Point pt
= LocationFromPosition(wParam
);
486 char* defn
= reinterpret_cast<char *>(lParam
);
487 AutoCompleteCancel();
488 pt
.y
+= vs
.lineHeight
;
489 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
491 vs
.styles
[STYLE_DEFAULT
].fontName
,
492 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
495 // If the call-tip window would be out of the client
496 // space, adjust so it displays above the text.
497 PRectangle rcClient
= GetClientRectangle();
498 if (rc
.bottom
> rcClient
.bottom
) {
500 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
502 int offset
= vs
.lineHeight
+ rc
.Height();
507 // Now display the window.
508 CreateCallTipWindow(rc
);
509 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
515 case SCI_LOADLEXERLIBRARY
:
516 LexerManager::GetInstance()->Load((const char*)lParam
);
520 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
527 //----------------------------------------------------------------------
530 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
532 paintState
= painting
;
533 Surface
* surfaceWindow
= Surface::Allocate();
534 surfaceWindow
->Init(dc
, wMain
.GetID());
535 rcPaint
= PRectangleFromwxRect(rect
);
536 PRectangle rcClient
= GetClientRectangle();
537 paintingAllText
= rcPaint
.Contains(rcClient
);
540 ClipChildren(*dc
, rcPaint
);
541 Paint(surfaceWindow
, rcPaint
);
544 delete surfaceWindow
;
545 if (paintState
== paintAbandoned
) {
546 // Painting area was insufficient to cover new styling or brace highlight positions
549 paintState
= notPainting
;
553 void ScintillaWX::DoHScroll(int type
, int pos
) {
555 PRectangle rcText
= GetTextRectangle();
556 int pageWidth
= rcText
.Width() * 2 / 3;
557 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
558 xPos
-= H_SCROLL_STEP
;
559 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
560 xPos
+= H_SCROLL_STEP
;
561 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
563 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
565 if (xPos
> scrollWidth
- rcText
.Width()) {
566 xPos
= scrollWidth
- rcText
.Width();
569 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
571 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
573 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
576 HorizontalScrollTo(xPos
);
579 void ScintillaWX::DoVScroll(int type
, int pos
) {
580 int topLineNew
= topLine
;
581 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
583 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
585 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
586 topLineNew
-= LinesToScroll();
587 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
588 topLineNew
+= LinesToScroll();
589 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
591 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
592 topLineNew
= MaxScrollPos();
593 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
596 ScrollTo(topLineNew
);
599 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
600 int linesPerAction
, int ctrlDown
,
601 bool isPageScroll
) {
602 int topLineNew
= topLine
;
605 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
607 KeyCommand(SCI_ZOOMIN
);
610 KeyCommand(SCI_ZOOMOUT
);
613 else { // otherwise just scroll the window
616 wheelRotation
+= rotation
;
617 lines
= wheelRotation
/ delta
;
618 wheelRotation
-= lines
* delta
;
621 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
623 lines
*= linesPerAction
;
625 ScrollTo(topLineNew
);
631 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
632 // PRectangle rcClient(0,0,width,height);
633 // SetScrollBarsTo(rcClient);
638 void ScintillaWX::DoLoseFocus(){
640 SetFocusState(false);
644 void ScintillaWX::DoGainFocus(){
650 void ScintillaWX::DoSysColourChange() {
651 InvalidateStyleData();
654 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
655 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
658 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
659 ButtonUp(pt
, curTime
, ctrl
);
662 void ScintillaWX::DoLeftButtonMove(Point pt
) {
667 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
668 // Set the current position to the mouse click point and
669 // then paste in the PRIMARY selection, if any. wxGTK only.
670 int newPos
= PositionFromLocation(pt
);
671 MovePositionTo(newPos
, noSel
, true);
673 pdoc
->BeginUndoAction();
674 wxTextDataObject data
;
675 bool gotData
= FALSE
;
676 if (wxTheClipboard
->Open()) {
677 wxTheClipboard
->UsePrimarySelection(TRUE
);
678 gotData
= wxTheClipboard
->GetData(data
);
679 wxTheClipboard
->UsePrimarySelection(FALSE
);
680 wxTheClipboard
->Close();
683 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
684 int len
= strlen(buf
);
685 pdoc
->InsertString(currentPos
, buf
, len
);
686 SetEmptySelection(currentPos
+ len
);
688 pdoc
->EndUndoAction();
692 ShowCaretAtCurrentPosition();
693 EnsureCaretVisible();
696 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
701 void ScintillaWX::DoAddChar(int key
) {
706 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
707 AddCharUTF((char*)buf
.data(), strlen(buf
));
715 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
717 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
719 #if defined(__WXGTK__) || defined(__WXMAC__)
720 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
721 // TODO: Check this, it shouldn't be true any longer.
722 if (ctrl
&& key
>= 1 && key
<= 26)
727 case WXK_DOWN
: key
= SCK_DOWN
; break;
728 case WXK_UP
: key
= SCK_UP
; break;
729 case WXK_LEFT
: key
= SCK_LEFT
; break;
730 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
731 case WXK_HOME
: key
= SCK_HOME
; break;
732 case WXK_END
: key
= SCK_END
; break;
733 case WXK_PAGEUP
: // fall through
734 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
735 case WXK_PAGEDOWN
: // fall through
736 case WXK_NEXT
: key
= SCK_NEXT
; break;
737 case WXK_DELETE
: key
= SCK_DELETE
; break;
738 case WXK_INSERT
: key
= SCK_INSERT
; break;
739 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
740 case WXK_BACK
: key
= SCK_BACK
; break;
741 case WXK_TAB
: key
= SCK_TAB
; break;
742 case WXK_RETURN
: key
= SCK_RETURN
; break;
743 case WXK_ADD
: // fall through
744 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
745 case WXK_SUBTRACT
: // fall through
746 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
747 case WXK_DIVIDE
: // fall through
748 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
749 case WXK_CONTROL
: key
= 0; break;
750 case WXK_ALT
: key
= 0; break;
751 case WXK_SHIFT
: key
= 0; break;
752 case WXK_MENU
: key
= 0; break;
757 // check for a few common Mac Meta-key combos and remap them to Ctrl
764 case 'A': // Select All
771 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
780 void ScintillaWX::DoCommand(int ID
) {
785 void ScintillaWX::DoContextMenu(Point pt
) {
786 if (displayPopupMenu
)
790 void ScintillaWX::DoOnListBox() {
791 AutoCompleteCompleted();
795 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
803 //----------------------------------------------------------------------
805 #if wxUSE_DRAG_AND_DROP
806 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
807 SetDragPosition(invalidPosition
);
809 // Send an event to allow the drag details to be changed
810 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
811 evt
.SetEventObject(stc
);
812 evt
.SetDragResult(dragResult
);
815 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
816 evt
.SetDragText(data
);
817 stc
->GetEventHandler()->ProcessEvent(evt
);
819 dragResult
= evt
.GetDragResult();
820 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
821 DropAt(evt
.GetPosition(),
822 wx2stc(evt
.GetDragText()),
823 dragResult
== wxDragMove
,
824 FALSE
); // TODO: rectangular?
831 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
837 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
838 SetDragPosition(PositionFromLocation(Point(x
, y
)));
840 // Send an event to allow the drag result to be changed
841 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
842 evt
.SetEventObject(stc
);
843 evt
.SetDragResult(def
);
846 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
847 stc
->GetEventHandler()->ProcessEvent(evt
);
849 dragResult
= evt
.GetDragResult();
854 void ScintillaWX::DoDragLeave() {
855 SetDragPosition(invalidPosition
);
858 //----------------------------------------------------------------------
860 // Redraw all of text area. This paint will not be abandoned.
861 void ScintillaWX::FullPaint(wxDC
*dc
) {
862 wxCHECK_RET(dc
!= NULL
, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
863 paintState
= painting
;
864 rcPaint
= GetClientRectangle();
865 paintingAllText
= true;
866 Surface
* surfaceWindow
= Surface::Allocate();
867 surfaceWindow
->Init(dc
, wMain
.GetID());
870 ClipChildren(*dc
, rcPaint
);
871 Paint(surfaceWindow
, rcPaint
);
874 delete surfaceWindow
;
875 paintState
= notPainting
;
879 void ScintillaWX::DoScrollToLine(int line
) {
884 void ScintillaWX::DoScrollToColumn(int column
) {
885 HorizontalScrollTo(column
* vs
.spaceWidth
);
889 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
890 wxRegion
rgn(wxRectFromPRectangle(rect
));
892 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
893 rgn
.Subtract(childRect
);
895 if (ct
.inCallTipMode
) {
896 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
897 rgn
.Subtract(childRect
);
900 dc
.SetClippingRegion(rgn
);
903 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
907 //----------------------------------------------------------------------
908 //----------------------------------------------------------------------