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() {
152 //----------------------------------------------------------------------
153 // base class virtuals
156 void ScintillaWX::Initialise() {
157 //ScintillaBase::Initialise();
158 #if wxUSE_DRAG_AND_DROP
159 dropTarget
= new wxSTCDropTarget
;
160 dropTarget
->SetScintilla(this);
161 stc
->SetDropTarget(dropTarget
);
166 void ScintillaWX::Finalise() {
167 ScintillaBase::Finalise();
173 void ScintillaWX::StartDrag() {
174 #if wxUSE_DRAG_AND_DROP
175 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
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();
187 if (dragText
.Length()) {
188 wxDropSource
source(stc
);
189 wxTextDataObject
data(dragText
);
192 source
.SetData(data
);
193 dropWentOutside
= TRUE
;
194 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
195 if (result
== wxDragMove
&& dropWentOutside
)
198 SetDragPosition(invalidPosition
);
204 bool ScintillaWX::SetIdle(bool on
) {
205 if (idler
.state
!= on
) {
206 // connect or disconnect the EVT_IDLE handler
208 stc
->Connect(-1, wxEVT_IDLE
, (wxObjectEventFunction
)&wxStyledTextCtrl::OnIdle
);
210 stc
->Disconnect(-1, wxEVT_IDLE
, (wxObjectEventFunction
)&wxStyledTextCtrl::OnIdle
);
217 void ScintillaWX::SetTicking(bool on
) {
218 wxSTCTimer
* steTimer
;
219 if (timer
.ticking
!= on
) {
222 steTimer
= new wxSTCTimer(this);
223 steTimer
->Start(timer
.tickSize
);
224 timer
.tickerID
= steTimer
;
226 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
232 timer
.ticksToWait
= caret
.period
;
236 void ScintillaWX::SetMouseCapture(bool on
) {
237 if (mouseDownCaptures
) {
238 if (on
&& !capturedMouse
)
240 else if (!on
&& capturedMouse
&& stc
->HasCapture())
247 bool ScintillaWX::HaveMouseCapture() {
248 return capturedMouse
;
252 void ScintillaWX::ScrollText(int linesToMove
) {
253 int dy
= vs
.lineHeight
* (linesToMove
);
254 stc
->ScrollWindow(0, dy
);
258 void ScintillaWX::SetVerticalScrollPos() {
259 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
260 stc
->SetScrollPos(wxVERTICAL
, topLine
);
262 else { // otherwise use the one that's been given to us
263 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
267 void ScintillaWX::SetHorizontalScrollPos() {
268 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
269 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
271 else { // otherwise use the one that's been given to us
272 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
277 const int H_SCROLL_STEP
= 20;
279 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
280 bool modified
= false;
283 if (!verticalScrollBarVisible
)
286 // Check the vertical scrollbar
287 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
288 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
289 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
290 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
291 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
292 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
296 else { // otherwise use the one that's been given to us
297 int sbMax
= stc
->m_vScrollBar
->GetRange();
298 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
299 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
300 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
301 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
307 // Check the horizontal scrollbar
308 PRectangle rcText
= GetTextRectangle();
309 int horizEnd
= scrollWidth
;
312 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
314 int pageWidth
= rcText
.Width();
316 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
317 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
318 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
319 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
320 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
321 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
323 if (scrollWidth
< pageWidth
) {
324 HorizontalScrollTo(0);
328 else { // otherwise use the one that's been given to us
329 int sbMax
= stc
->m_hScrollBar
->GetRange();
330 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
331 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
332 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
333 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
335 if (scrollWidth
< pageWidth
) {
336 HorizontalScrollTo(0);
345 void ScintillaWX::NotifyChange() {
350 void ScintillaWX::NotifyParent(SCNotification scn
) {
351 stc
->NotifyParent(&scn
);
355 // This method is overloaded from ScintillaBase in order to prevent the
356 // AutoComplete window from being destroyed when it gets the focus. There is
357 // a side effect that the AutoComp will also not be destroyed when switching
358 // to another window, but I think that is okay.
359 void ScintillaWX::CancelModes() {
361 AutoCompleteCancel();
363 Editor::CancelModes();
368 void ScintillaWX::Copy() {
369 if (currentPos
!= anchor
) {
371 CopySelectionRange(&st
);
377 void ScintillaWX::Paste() {
378 pdoc
->BeginUndoAction();
381 wxTextDataObject data
;
382 bool gotData
= FALSE
;
384 if (wxTheClipboard
->Open()) {
385 wxTheClipboard
->UsePrimarySelection(FALSE
);
386 gotData
= wxTheClipboard
->GetData(data
);
387 wxTheClipboard
->Close();
390 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
391 int len
= strlen(buf
);
392 pdoc
->InsertString(currentPos
, buf
, len
);
393 SetEmptySelection(currentPos
+ len
);
396 pdoc
->EndUndoAction();
402 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
403 if (wxTheClipboard
->Open()) {
404 wxTheClipboard
->UsePrimarySelection(FALSE
);
405 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
406 wxTheClipboard
->SetData(new wxTextDataObject(text
));
407 wxTheClipboard
->Close();
412 bool ScintillaWX::CanPaste() {
413 bool canPaste
= FALSE
;
416 if (Editor::CanPaste()) {
417 didOpen
= !wxTheClipboard
->IsOpened();
419 wxTheClipboard
->Open();
421 if (wxTheClipboard
->IsOpened()) {
422 wxTheClipboard
->UsePrimarySelection(FALSE
);
423 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
425 wxTheClipboard
->Close();
431 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
432 if (! ct
.wCallTip
.Created() ) {
433 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
434 ct
.wDraw
= ct
.wCallTip
;
439 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
441 ((wxMenu
*)popup
.GetID())->AppendSeparator();
443 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
446 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
450 // This is called by the Editor base class whenever something is selected
451 void ScintillaWX::ClaimSelection() {
453 // Until wxGTK is able to support using both the primary selection and the
454 // clipboard at the same time I think it causes more problems than it is
455 // worth to implement this method. Selecting text should not clear the
456 // clipboard. --Robin
458 // Put the selected text in the PRIMARY selection
459 if (currentPos
!= anchor
) {
461 CopySelectionRange(&st
);
462 if (wxTheClipboard
->Open()) {
463 wxTheClipboard
->UsePrimarySelection(TRUE
);
464 wxString text
= stc2wx(st
.s
, st
.len
);
465 wxTheClipboard
->SetData(new wxTextDataObject(text
));
466 wxTheClipboard
->UsePrimarySelection(FALSE
);
467 wxTheClipboard
->Close();
475 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
479 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
481 case SCI_CALLTIPSHOW
: {
482 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
483 // because of the little tweak that needs done below for wxGTK.
484 // When updating new versions double check that this is still
485 // needed, and that any new code there is copied here too.
486 Point pt
= LocationFromPosition(wParam
);
487 char* defn
= reinterpret_cast<char *>(lParam
);
488 AutoCompleteCancel();
489 pt
.y
+= vs
.lineHeight
;
490 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
492 vs
.styles
[STYLE_DEFAULT
].fontName
,
493 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
496 // If the call-tip window would be out of the client
497 // space, adjust so it displays above the text.
498 PRectangle rcClient
= GetClientRectangle();
499 if (rc
.bottom
> rcClient
.bottom
) {
501 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
503 int offset
= vs
.lineHeight
+ rc
.Height();
508 // Now display the window.
509 CreateCallTipWindow(rc
);
510 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
516 case SCI_LOADLEXERLIBRARY
:
517 LexerManager::GetInstance()->Load((const char*)lParam
);
521 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
528 //----------------------------------------------------------------------
531 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
533 paintState
= painting
;
534 Surface
* surfaceWindow
= Surface::Allocate();
535 surfaceWindow
->Init(dc
, wMain
.GetID());
536 rcPaint
= PRectangleFromwxRect(rect
);
537 PRectangle rcClient
= GetClientRectangle();
538 paintingAllText
= rcPaint
.Contains(rcClient
);
541 ClipChildren(*dc
, rcPaint
);
542 Paint(surfaceWindow
, rcPaint
);
545 delete surfaceWindow
;
546 if (paintState
== paintAbandoned
) {
547 // Painting area was insufficient to cover new styling or brace highlight positions
550 paintState
= notPainting
;
554 void ScintillaWX::DoHScroll(int type
, int pos
) {
556 PRectangle rcText
= GetTextRectangle();
557 int pageWidth
= rcText
.Width() * 2 / 3;
558 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
559 xPos
-= H_SCROLL_STEP
;
560 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
561 xPos
+= H_SCROLL_STEP
;
562 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
564 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
566 if (xPos
> scrollWidth
- rcText
.Width()) {
567 xPos
= scrollWidth
- rcText
.Width();
570 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
572 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
574 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
577 HorizontalScrollTo(xPos
);
580 void ScintillaWX::DoVScroll(int type
, int pos
) {
581 int topLineNew
= topLine
;
582 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
584 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
586 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
587 topLineNew
-= LinesToScroll();
588 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
589 topLineNew
+= LinesToScroll();
590 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
592 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
593 topLineNew
= MaxScrollPos();
594 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
597 ScrollTo(topLineNew
);
600 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
601 int linesPerAction
, int ctrlDown
,
602 bool isPageScroll
) {
603 int topLineNew
= topLine
;
606 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
608 KeyCommand(SCI_ZOOMIN
);
611 KeyCommand(SCI_ZOOMOUT
);
614 else { // otherwise just scroll the window
617 wheelRotation
+= rotation
;
618 lines
= wheelRotation
/ delta
;
619 wheelRotation
-= lines
* delta
;
622 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
624 lines
*= linesPerAction
;
626 ScrollTo(topLineNew
);
632 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
633 // PRectangle rcClient(0,0,width,height);
634 // SetScrollBarsTo(rcClient);
639 void ScintillaWX::DoLoseFocus(){
641 SetFocusState(false);
645 void ScintillaWX::DoGainFocus(){
651 void ScintillaWX::DoSysColourChange() {
652 InvalidateStyleData();
655 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
656 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
659 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
660 ButtonUp(pt
, curTime
, ctrl
);
663 void ScintillaWX::DoLeftButtonMove(Point pt
) {
668 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
669 // Set the current position to the mouse click point and
670 // then paste in the PRIMARY selection, if any. wxGTK only.
671 int newPos
= PositionFromLocation(pt
);
672 MovePositionTo(newPos
, noSel
, true);
674 pdoc
->BeginUndoAction();
675 wxTextDataObject data
;
676 bool gotData
= FALSE
;
677 if (wxTheClipboard
->Open()) {
678 wxTheClipboard
->UsePrimarySelection(TRUE
);
679 gotData
= wxTheClipboard
->GetData(data
);
680 wxTheClipboard
->UsePrimarySelection(FALSE
);
681 wxTheClipboard
->Close();
684 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
685 int len
= strlen(buf
);
686 pdoc
->InsertString(currentPos
, buf
, len
);
687 SetEmptySelection(currentPos
+ len
);
689 pdoc
->EndUndoAction();
693 ShowCaretAtCurrentPosition();
694 EnsureCaretVisible();
697 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
702 void ScintillaWX::DoAddChar(int key
) {
707 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
708 AddCharUTF((char*)buf
.data(), strlen(buf
));
716 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
718 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
720 #if defined(__WXGTK__) || defined(__WXMAC__)
721 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
722 // TODO: Check this, it shouldn't be true any longer.
723 if (ctrl
&& key
>= 1 && key
<= 26)
728 case WXK_DOWN
: key
= SCK_DOWN
; break;
729 case WXK_UP
: key
= SCK_UP
; break;
730 case WXK_LEFT
: key
= SCK_LEFT
; break;
731 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
732 case WXK_HOME
: key
= SCK_HOME
; break;
733 case WXK_END
: key
= SCK_END
; break;
734 case WXK_PAGEUP
: // fall through
735 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
736 case WXK_PAGEDOWN
: // fall through
737 case WXK_NEXT
: key
= SCK_NEXT
; break;
738 case WXK_DELETE
: key
= SCK_DELETE
; break;
739 case WXK_INSERT
: key
= SCK_INSERT
; break;
740 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
741 case WXK_BACK
: key
= SCK_BACK
; break;
742 case WXK_TAB
: key
= SCK_TAB
; break;
743 case WXK_RETURN
: key
= SCK_RETURN
; break;
744 case WXK_ADD
: // fall through
745 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
746 case WXK_SUBTRACT
: // fall through
747 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
748 case WXK_DIVIDE
: // fall through
749 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
750 case WXK_CONTROL
: key
= 0; break;
751 case WXK_ALT
: key
= 0; break;
752 case WXK_SHIFT
: key
= 0; break;
753 case WXK_MENU
: key
= 0; break;
758 // check for a few common Mac Meta-key combos and remap them to Ctrl
765 case 'A': // Select All
772 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
781 void ScintillaWX::DoCommand(int ID
) {
786 void ScintillaWX::DoContextMenu(Point pt
) {
787 if (displayPopupMenu
)
791 void ScintillaWX::DoOnListBox() {
792 AutoCompleteCompleted();
796 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
804 //----------------------------------------------------------------------
806 #if wxUSE_DRAG_AND_DROP
807 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
808 SetDragPosition(invalidPosition
);
810 // Send an event to allow the drag details to be changed
811 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
812 evt
.SetEventObject(stc
);
813 evt
.SetDragResult(dragResult
);
816 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
817 evt
.SetDragText(data
);
818 stc
->GetEventHandler()->ProcessEvent(evt
);
820 dragResult
= evt
.GetDragResult();
821 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
822 DropAt(evt
.GetPosition(),
823 wx2stc(evt
.GetDragText()),
824 dragResult
== wxDragMove
,
825 FALSE
); // TODO: rectangular?
832 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
838 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
839 SetDragPosition(PositionFromLocation(Point(x
, y
)));
841 // Send an event to allow the drag result to be changed
842 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
843 evt
.SetEventObject(stc
);
844 evt
.SetDragResult(def
);
847 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
848 stc
->GetEventHandler()->ProcessEvent(evt
);
850 dragResult
= evt
.GetDragResult();
855 void ScintillaWX::DoDragLeave() {
856 SetDragPosition(invalidPosition
);
859 //----------------------------------------------------------------------
861 // Redraw all of text area. This paint will not be abandoned.
862 void ScintillaWX::FullPaint(wxDC
*dc
) {
863 wxCHECK_RET(dc
!= NULL
, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
864 paintState
= painting
;
865 rcPaint
= GetClientRectangle();
866 paintingAllText
= true;
867 Surface
* surfaceWindow
= Surface::Allocate();
868 surfaceWindow
->Init(dc
, wMain
.GetID());
871 ClipChildren(*dc
, rcPaint
);
872 Paint(surfaceWindow
, rcPaint
);
875 delete surfaceWindow
;
876 paintState
= notPainting
;
880 void ScintillaWX::DoScrollToLine(int line
) {
885 void ScintillaWX::DoScrollToColumn(int column
) {
886 HorizontalScrollTo(column
* vs
.spaceWidth
);
890 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
891 wxRegion
rgn(wxRectFromPRectangle(rect
));
893 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
894 rgn
.Subtract(childRect
);
896 if (ct
.inCallTipMode
) {
897 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
898 rgn
.Subtract(childRect
);
901 dc
.SetClippingRegion(rgn
);
904 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
908 //----------------------------------------------------------------------
909 //----------------------------------------------------------------------