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();
171 void ScintillaWX::StartDrag() {
172 #if wxUSE_DRAG_AND_DROP
173 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
175 // Send an event to allow the drag text to be changed
176 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
177 evt
.SetEventObject(stc
);
178 evt
.SetDragText(dragText
);
179 evt
.SetDragAllowMove(TRUE
);
180 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
181 stc
->GetSelectionEnd()));
182 stc
->GetEventHandler()->ProcessEvent(evt
);
183 dragText
= evt
.GetDragText();
185 if (dragText
.Length()) {
186 wxDropSource
source(stc
);
187 wxTextDataObject
data(dragText
);
190 source
.SetData(data
);
191 dropWentOutside
= TRUE
;
192 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
193 if (result
== wxDragMove
&& dropWentOutside
)
196 SetDragPosition(invalidPosition
);
202 void ScintillaWX::SetTicking(bool on
) {
203 wxSTCTimer
* steTimer
;
204 if (timer
.ticking
!= on
) {
207 steTimer
= new wxSTCTimer(this);
208 steTimer
->Start(timer
.tickSize
);
209 timer
.tickerID
= steTimer
;
211 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
217 timer
.ticksToWait
= caret
.period
;
221 void ScintillaWX::SetMouseCapture(bool on
) {
222 if (on
&& !capturedMouse
)
224 else if (!on
&& capturedMouse
&& stc
->HasCapture())
230 bool ScintillaWX::HaveMouseCapture() {
231 return capturedMouse
;
235 void ScintillaWX::ScrollText(int linesToMove
) {
236 int dy
= vs
.lineHeight
* (linesToMove
);
237 stc
->ScrollWindow(0, dy
);
241 void ScintillaWX::SetVerticalScrollPos() {
242 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
243 stc
->SetScrollPos(wxVERTICAL
, topLine
);
245 else { // otherwise use the one that's been given to us
246 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
250 void ScintillaWX::SetHorizontalScrollPos() {
251 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
252 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
254 else { // otherwise use the one that's been given to us
255 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
260 const int H_SCROLL_STEP
= 20;
262 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
263 bool modified
= false;
266 if (!verticalScrollBarVisible
)
269 // Check the vertical scrollbar
270 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
271 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
272 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
273 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
274 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
275 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
279 else { // otherwise use the one that's been given to us
280 int sbMax
= stc
->m_vScrollBar
->GetRange();
281 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
282 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
283 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
284 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
290 // Check the horizontal scrollbar
291 PRectangle rcText
= GetTextRectangle();
292 int horizEnd
= scrollWidth
;
295 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
297 int pageWidth
= rcText
.Width();
299 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
300 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
301 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
302 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
303 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
304 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
306 if (scrollWidth
< pageWidth
) {
307 HorizontalScrollTo(0);
311 else { // otherwise use the one that's been given to us
312 int sbMax
= stc
->m_hScrollBar
->GetRange();
313 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
314 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
315 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
316 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
318 if (scrollWidth
< pageWidth
) {
319 HorizontalScrollTo(0);
328 void ScintillaWX::NotifyChange() {
333 void ScintillaWX::NotifyParent(SCNotification scn
) {
334 stc
->NotifyParent(&scn
);
338 // This method is overloaded from ScintillaBase in order to prevent the
339 // AutoComplete window from being destroyed when it gets the focus. There is
340 // a side effect that the AutoComp will also not be destroyed when switching
341 // to another window, but I think that is okay.
342 void ScintillaWX::CancelModes() {
344 AutoCompleteCancel();
346 Editor::CancelModes();
351 void ScintillaWX::Copy() {
352 if (currentPos
!= anchor
) {
354 CopySelectionRange(&st
);
360 void ScintillaWX::Paste() {
361 pdoc
->BeginUndoAction();
364 wxTextDataObject data
;
365 bool gotData
= FALSE
;
367 if (wxTheClipboard
->Open()) {
368 wxTheClipboard
->UsePrimarySelection(FALSE
);
369 gotData
= wxTheClipboard
->GetData(data
);
370 wxTheClipboard
->Close();
373 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
374 int len
= strlen(buf
);
375 pdoc
->InsertString(currentPos
, buf
, len
);
376 SetEmptySelection(currentPos
+ len
);
379 pdoc
->EndUndoAction();
385 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
386 if (wxTheClipboard
->Open()) {
387 wxTheClipboard
->UsePrimarySelection(FALSE
);
388 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
389 wxTheClipboard
->SetData(new wxTextDataObject(text
));
390 wxTheClipboard
->Close();
395 bool ScintillaWX::CanPaste() {
396 bool canPaste
= FALSE
;
399 if (Editor::CanPaste()) {
400 didOpen
= !wxTheClipboard
->IsOpened();
402 wxTheClipboard
->Open();
404 if (wxTheClipboard
->IsOpened()) {
405 wxTheClipboard
->UsePrimarySelection(FALSE
);
406 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
408 wxTheClipboard
->Close();
414 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
415 if (! ct
.wCallTip
.Created() ) {
416 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
417 ct
.wDraw
= ct
.wCallTip
;
422 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
424 ((wxMenu
*)popup
.GetID())->AppendSeparator();
426 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
429 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
433 // This is called by the Editor base class whenever something is selected
434 void ScintillaWX::ClaimSelection() {
436 // Until wxGTK is able to support using both the primary selection and the
437 // clipboard at the same time I think it causes more problems than it is
438 // worth to implement this method. Selecting text should not clear the
439 // clipboard. --Robin
441 // Put the selected text in the PRIMARY selection
442 if (currentPos
!= anchor
) {
444 CopySelectionRange(&st
);
445 if (wxTheClipboard
->Open()) {
446 wxTheClipboard
->UsePrimarySelection(TRUE
);
447 wxString text
= stc2wx(st
.s
, st
.len
);
448 wxTheClipboard
->SetData(new wxTextDataObject(text
));
449 wxTheClipboard
->UsePrimarySelection(FALSE
);
450 wxTheClipboard
->Close();
458 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
462 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
464 case SCI_CALLTIPSHOW
: {
465 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
466 // because of the little tweak that needs done below for wxGTK.
467 // When updating new versions double check that this is still
468 // needed, and that any new code there is copied here too.
469 Point pt
= LocationFromPosition(wParam
);
470 char* defn
= reinterpret_cast<char *>(lParam
);
471 AutoCompleteCancel();
472 pt
.y
+= vs
.lineHeight
;
473 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
475 vs
.styles
[STYLE_DEFAULT
].fontName
,
476 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
479 // If the call-tip window would be out of the client
480 // space, adjust so it displays above the text.
481 PRectangle rcClient
= GetClientRectangle();
482 if (rc
.bottom
> rcClient
.bottom
) {
484 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
486 int offset
= vs
.lineHeight
+ rc
.Height();
491 // Now display the window.
492 CreateCallTipWindow(rc
);
493 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
499 case SCI_LOADLEXERLIBRARY
:
500 LexerManager::GetInstance()->Load((const char*)lParam
);
504 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
511 //----------------------------------------------------------------------
514 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
516 paintState
= painting
;
517 Surface
* surfaceWindow
= Surface::Allocate();
518 surfaceWindow
->Init(dc
, wMain
.GetID());
519 rcPaint
= PRectangleFromwxRect(rect
);
520 PRectangle rcClient
= GetClientRectangle();
521 paintingAllText
= rcPaint
.Contains(rcClient
);
524 ClipChildren(*dc
, rcPaint
);
525 Paint(surfaceWindow
, rcPaint
);
528 delete surfaceWindow
;
529 if (paintState
== paintAbandoned
) {
530 // Painting area was insufficient to cover new styling or brace highlight positions
533 paintState
= notPainting
;
537 void ScintillaWX::DoHScroll(int type
, int pos
) {
539 PRectangle rcText
= GetTextRectangle();
540 int pageWidth
= rcText
.Width() * 2 / 3;
541 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
542 xPos
-= H_SCROLL_STEP
;
543 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
544 xPos
+= H_SCROLL_STEP
;
545 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
547 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
549 if (xPos
> scrollWidth
- rcText
.Width()) {
550 xPos
= scrollWidth
- rcText
.Width();
553 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
555 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
557 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
560 HorizontalScrollTo(xPos
);
563 void ScintillaWX::DoVScroll(int type
, int pos
) {
564 int topLineNew
= topLine
;
565 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
567 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
569 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
570 topLineNew
-= LinesToScroll();
571 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
572 topLineNew
+= LinesToScroll();
573 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
575 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
576 topLineNew
= MaxScrollPos();
577 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
580 ScrollTo(topLineNew
);
583 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
584 int linesPerAction
, int ctrlDown
,
585 bool isPageScroll
) {
586 int topLineNew
= topLine
;
589 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
591 KeyCommand(SCI_ZOOMIN
);
594 KeyCommand(SCI_ZOOMOUT
);
597 else { // otherwise just scroll the window
600 wheelRotation
+= rotation
;
601 lines
= wheelRotation
/ delta
;
602 wheelRotation
-= lines
* delta
;
605 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
607 lines
*= linesPerAction
;
609 ScrollTo(topLineNew
);
615 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
616 // PRectangle rcClient(0,0,width,height);
617 // SetScrollBarsTo(rcClient);
622 void ScintillaWX::DoLoseFocus(){
624 SetFocusState(false);
628 void ScintillaWX::DoGainFocus(){
634 void ScintillaWX::DoSysColourChange() {
635 InvalidateStyleData();
638 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
639 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
642 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
643 ButtonUp(pt
, curTime
, ctrl
);
646 void ScintillaWX::DoLeftButtonMove(Point pt
) {
651 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
652 // Set the current position to the mouse click point and
653 // then paste in the PRIMARY selection, if any. wxGTK only.
654 int newPos
= PositionFromLocation(pt
);
655 MovePositionTo(newPos
, 0, 1);
657 pdoc
->BeginUndoAction();
658 wxTextDataObject data
;
659 bool gotData
= FALSE
;
660 if (wxTheClipboard
->Open()) {
661 wxTheClipboard
->UsePrimarySelection(TRUE
);
662 gotData
= wxTheClipboard
->GetData(data
);
663 wxTheClipboard
->UsePrimarySelection(FALSE
);
664 wxTheClipboard
->Close();
667 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
668 int len
= strlen(buf
);
669 pdoc
->InsertString(currentPos
, buf
, len
);
670 SetEmptySelection(currentPos
+ len
);
672 pdoc
->EndUndoAction();
676 ShowCaretAtCurrentPosition();
677 EnsureCaretVisible();
680 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
685 void ScintillaWX::DoAddChar(int key
) {
690 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
691 AddCharUTF((char*)buf
.data(), strlen(buf
));
699 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
701 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
703 #if defined(__WXGTK__) || defined(__WXMAC__)
704 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
705 // TODO: Check this, it shouldn't be true any longer.
706 if (ctrl
&& key
>= 1 && key
<= 26)
711 case WXK_DOWN
: key
= SCK_DOWN
; break;
712 case WXK_UP
: key
= SCK_UP
; break;
713 case WXK_LEFT
: key
= SCK_LEFT
; break;
714 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
715 case WXK_HOME
: key
= SCK_HOME
; break;
716 case WXK_END
: key
= SCK_END
; break;
717 case WXK_PAGEUP
: // fall through
718 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
719 case WXK_PAGEDOWN
: // fall through
720 case WXK_NEXT
: key
= SCK_NEXT
; break;
721 case WXK_DELETE
: key
= SCK_DELETE
; break;
722 case WXK_INSERT
: key
= SCK_INSERT
; break;
723 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
724 case WXK_BACK
: key
= SCK_BACK
; break;
725 case WXK_TAB
: key
= SCK_TAB
; break;
726 case WXK_RETURN
: key
= SCK_RETURN
; break;
727 case WXK_ADD
: // fall through
728 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
729 case WXK_SUBTRACT
: // fall through
730 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
731 case WXK_DIVIDE
: // fall through
732 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
733 case WXK_CONTROL
: key
= 0; break;
734 case WXK_ALT
: key
= 0; break;
735 case WXK_SHIFT
: key
= 0; break;
736 case WXK_MENU
: key
= 0; break;
741 // check for a few common Mac Meta-key combos and remap them to Ctrl
748 case 'A': // Select All
755 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
764 void ScintillaWX::DoCommand(int ID
) {
769 void ScintillaWX::DoContextMenu(Point pt
) {
770 if (displayPopupMenu
)
774 void ScintillaWX::DoOnListBox() {
775 AutoCompleteCompleted();
778 //----------------------------------------------------------------------
780 #if wxUSE_DRAG_AND_DROP
781 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
782 SetDragPosition(invalidPosition
);
784 // Send an event to allow the drag details to be changed
785 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
786 evt
.SetEventObject(stc
);
787 evt
.SetDragResult(dragResult
);
790 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
791 evt
.SetDragText(data
);
792 stc
->GetEventHandler()->ProcessEvent(evt
);
794 dragResult
= evt
.GetDragResult();
795 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
796 DropAt(evt
.GetPosition(),
797 wx2stc(evt
.GetDragText()),
798 dragResult
== wxDragMove
,
799 FALSE
); // TODO: rectangular?
806 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
812 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
813 SetDragPosition(PositionFromLocation(Point(x
, y
)));
815 // Send an event to allow the drag result to be changed
816 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
817 evt
.SetEventObject(stc
);
818 evt
.SetDragResult(def
);
821 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
822 stc
->GetEventHandler()->ProcessEvent(evt
);
824 dragResult
= evt
.GetDragResult();
829 void ScintillaWX::DoDragLeave() {
830 SetDragPosition(invalidPosition
);
833 //----------------------------------------------------------------------
835 // Redraw all of text area. This paint will not be abandoned.
836 void ScintillaWX::FullPaint(wxDC
*dc
) {
837 wxCHECK_RET(dc
!= NULL
, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
838 paintState
= painting
;
839 rcPaint
= GetClientRectangle();
840 paintingAllText
= true;
841 Surface
* surfaceWindow
= Surface::Allocate();
842 surfaceWindow
->Init(dc
, wMain
.GetID());
845 ClipChildren(*dc
, rcPaint
);
846 Paint(surfaceWindow
, rcPaint
);
849 delete surfaceWindow
;
850 paintState
= notPainting
;
854 void ScintillaWX::DoScrollToLine(int line
) {
859 void ScintillaWX::DoScrollToColumn(int column
) {
860 HorizontalScrollTo(column
* vs
.spaceWidth
);
864 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
865 wxRegion
rgn(wxRectFromPRectangle(rect
));
867 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
868 rgn
.Subtract(childRect
);
870 if (ct
.inCallTipMode
) {
871 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
872 rgn
.Subtract(childRect
);
875 dc
.SetClippingRegion(rgn
);
878 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
882 //----------------------------------------------------------------------
883 //----------------------------------------------------------------------