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"
23 //----------------------------------------------------------------------
26 class wxSTCTimer
: public wxTimer
{
28 wxSTCTimer(ScintillaWX
* swx
) {
41 #if wxUSE_DRAG_AND_DROP
42 bool wxSTCDropTarget::OnDropText(wxCoord x
, wxCoord y
, const wxString
& data
) {
43 return swx
->DoDropText(x
, y
, data
);
46 wxDragResult
wxSTCDropTarget::OnEnter(wxCoord x
, wxCoord y
, wxDragResult def
) {
47 return swx
->DoDragEnter(x
, y
, def
);
50 wxDragResult
wxSTCDropTarget::OnDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
51 return swx
->DoDragOver(x
, y
, def
);
54 void wxSTCDropTarget::OnLeave() {
61 #undef wxSTC_USE_POPUP
62 #define wxSTC_USE_POPUP 0
65 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
66 #include <wx/popupwin.h>
67 #define wxSTCCallTipBase wxPopupWindow
68 #define param2 wxBORDER_NONE // popup's 2nd param is flags
70 #define wxSTCCallTipBase wxWindow
71 #define param2 -1 // wxWindow's 2nd param is ID
74 class wxSTCCallTip
: public wxSTCCallTipBase
{
76 wxSTCCallTip(wxWindow
* parent
, CallTip
* ct
, ScintillaWX
* swx
)
77 : wxSTCCallTipBase(parent
, param2
),
85 bool AcceptsFocus() const { return FALSE
; }
87 void OnPaint(wxPaintEvent
& evt
) {
89 Surface
* surfaceWindow
= Surface::Allocate();
90 surfaceWindow
->Init(&dc
, m_ct
->wDraw
.GetID());
91 m_ct
->PaintCT(surfaceWindow
);
92 surfaceWindow
->Release();
96 void OnFocus(wxFocusEvent
& event
) {
97 GetParent()->SetFocus();
101 void OnLeftDown(wxMouseEvent
& event
) {
102 wxPoint pt
= event
.GetPosition();
105 m_swx
->CallTipClick();
108 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
109 virtual void DoSetSize(int x
, int y
,
110 int width
, int height
,
111 int sizeFlags
= wxSIZE_AUTO
) {
113 GetParent()->ClientToScreen(&x
, NULL
);
115 GetParent()->ClientToScreen(NULL
, &y
);
116 wxSTCCallTipBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
123 DECLARE_EVENT_TABLE()
126 BEGIN_EVENT_TABLE(wxSTCCallTip
, wxSTCCallTipBase
)
127 EVT_PAINT(wxSTCCallTip::OnPaint
)
128 EVT_SET_FOCUS(wxSTCCallTip::OnFocus
)
129 EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown
)
133 //----------------------------------------------------------------------
134 // Constructor/Destructor
137 ScintillaWX::ScintillaWX(wxStyledTextCtrl
* win
) {
138 capturedMouse
= false;
147 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();
170 void ScintillaWX::StartDrag() {
171 #if wxUSE_DRAG_AND_DROP
172 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
174 // Send an event to allow the drag text to be changed
175 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
176 evt
.SetEventObject(stc
);
177 evt
.SetDragText(dragText
);
178 evt
.SetDragAllowMove(TRUE
);
179 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
180 stc
->GetSelectionEnd()));
181 stc
->GetEventHandler()->ProcessEvent(evt
);
182 dragText
= evt
.GetDragText();
184 if (dragText
.Length()) {
185 wxDropSource
source(stc
);
186 wxTextDataObject
data(dragText
);
189 source
.SetData(data
);
190 dropWentOutside
= TRUE
;
191 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
192 if (result
== wxDragMove
&& dropWentOutside
)
195 SetDragPosition(invalidPosition
);
201 void ScintillaWX::SetTicking(bool on
) {
202 wxSTCTimer
* steTimer
;
203 if (timer
.ticking
!= on
) {
206 steTimer
= new wxSTCTimer(this);
207 steTimer
->Start(timer
.tickSize
);
208 timer
.tickerID
= steTimer
;
210 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
216 timer
.ticksToWait
= caret
.period
;
220 void ScintillaWX::SetMouseCapture(bool on
) {
221 if (on
&& !capturedMouse
)
223 else if (!on
&& capturedMouse
&& stc
->HasCapture())
229 bool ScintillaWX::HaveMouseCapture() {
230 return capturedMouse
;
234 void ScintillaWX::ScrollText(int linesToMove
) {
235 int dy
= vs
.lineHeight
* (linesToMove
);
236 stc
->ScrollWindow(0, dy
);
240 void ScintillaWX::SetVerticalScrollPos() {
241 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
242 stc
->SetScrollPos(wxVERTICAL
, topLine
);
244 else { // otherwise use the one that's been given to us
245 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
249 void ScintillaWX::SetHorizontalScrollPos() {
250 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
251 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
253 else { // otherwise use the one that's been given to us
254 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
259 const int H_SCROLL_STEP
= 20;
261 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
262 bool modified
= false;
265 if (!verticalScrollBarVisible
)
268 // Check the vertical scrollbar
269 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
270 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
271 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
272 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
273 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
274 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
278 else { // otherwise use the one that's been given to us
279 int sbMax
= stc
->m_vScrollBar
->GetRange();
280 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
281 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
282 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
283 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
289 // Check the horizontal scrollbar
290 PRectangle rcText
= GetTextRectangle();
291 int horizEnd
= scrollWidth
;
294 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
296 int pageWidth
= rcText
.Width();
298 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
299 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
300 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
301 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
302 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
303 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
305 if (scrollWidth
< pageWidth
) {
306 HorizontalScrollTo(0);
310 else { // otherwise use the one that's been given to us
311 int sbMax
= stc
->m_hScrollBar
->GetRange();
312 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
313 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
314 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
315 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
317 if (scrollWidth
< pageWidth
) {
318 HorizontalScrollTo(0);
327 void ScintillaWX::NotifyChange() {
332 void ScintillaWX::NotifyParent(SCNotification scn
) {
333 stc
->NotifyParent(&scn
);
337 // This method is overloaded from ScintillaBase in order to prevent the
338 // AutoComplete window from being destroyed when it gets the focus. There is
339 // a side effect that the AutoComp will also not be destroyed when switching
340 // to another window, but I think that is okay.
341 void ScintillaWX::CancelModes() {
343 AutoCompleteCancel();
345 Editor::CancelModes();
350 void ScintillaWX::Copy() {
351 if (currentPos
!= anchor
) {
353 CopySelectionRange(&st
);
359 void ScintillaWX::Paste() {
360 pdoc
->BeginUndoAction();
363 wxTextDataObject data
;
364 bool gotData
= FALSE
;
366 if (wxTheClipboard
->Open()) {
367 wxTheClipboard
->UsePrimarySelection(FALSE
);
368 gotData
= wxTheClipboard
->GetData(data
);
369 wxTheClipboard
->Close();
372 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
373 int len
= strlen(buf
);
374 pdoc
->InsertString(currentPos
, buf
, len
);
375 SetEmptySelection(currentPos
+ len
);
378 pdoc
->EndUndoAction();
384 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
385 if (wxTheClipboard
->Open()) {
386 wxTheClipboard
->UsePrimarySelection(FALSE
);
387 wxString text
= stc2wx(st
.s
, st
.len
);
388 wxTheClipboard
->SetData(new wxTextDataObject(text
));
389 wxTheClipboard
->Close();
394 bool ScintillaWX::CanPaste() {
395 bool canPaste
= FALSE
;
398 if (Editor::CanPaste()) {
399 didOpen
= !wxTheClipboard
->IsOpened();
401 wxTheClipboard
->Open();
403 if (wxTheClipboard
->IsOpened()) {
404 wxTheClipboard
->UsePrimarySelection(FALSE
);
405 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
407 wxTheClipboard
->Close();
413 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
414 if (! ct
.wCallTip
.Created() ) {
415 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
416 ct
.wDraw
= ct
.wCallTip
;
421 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
423 ((wxMenu
*)popup
.GetID())->AppendSeparator();
425 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
428 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
432 // This is called by the Editor base class whenever something is selected
433 void ScintillaWX::ClaimSelection() {
435 // Until wxGTK is able to support using both the primary selection and the
436 // clipboard at the same time I think it causes more problems than it is
437 // worth to implement this method. Selecting text should not clear the
438 // clipboard. --Robin
440 // Put the selected text in the PRIMARY selection
441 if (currentPos
!= anchor
) {
443 CopySelectionRange(&st
);
444 if (wxTheClipboard
->Open()) {
445 wxTheClipboard
->UsePrimarySelection(TRUE
);
446 wxString text
= stc2wx(st
.s
, st
.len
);
447 wxTheClipboard
->SetData(new wxTextDataObject(text
));
448 wxTheClipboard
->UsePrimarySelection(FALSE
);
449 wxTheClipboard
->Close();
457 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
461 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
463 case SCI_CALLTIPSHOW
: {
464 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
465 // because of the little tweak that needs done below for wxGTK.
466 // When updating new versions double check that this is still
467 // needed, and that any new code there is copied here too.
468 Point pt
= LocationFromPosition(wParam
);
469 char* defn
= reinterpret_cast<char *>(lParam
);
470 AutoCompleteCancel();
471 pt
.y
+= vs
.lineHeight
;
472 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
474 vs
.styles
[STYLE_DEFAULT
].fontName
,
475 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
478 // If the call-tip window would be out of the client
479 // space, adjust so it displays above the text.
480 PRectangle rcClient
= GetClientRectangle();
481 if (rc
.bottom
> rcClient
.bottom
) {
483 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
485 int offset
= vs
.lineHeight
+ rc
.Height();
490 // Now display the window.
491 CreateCallTipWindow(rc
);
492 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
498 case SCI_LOADLEXERLIBRARY
:
499 LexerManager::GetInstance()->Load((const char*)lParam
);
503 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
510 //----------------------------------------------------------------------
513 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
515 paintState
= painting
;
516 Surface
* surfaceWindow
= Surface::Allocate();
517 surfaceWindow
->Init(dc
, wMain
.GetID());
518 rcPaint
= PRectangleFromwxRect(rect
);
519 PRectangle rcClient
= GetClientRectangle();
520 paintingAllText
= rcPaint
.Contains(rcClient
);
523 ClipChildren(*dc
, rcPaint
);
524 Paint(surfaceWindow
, rcPaint
);
527 delete surfaceWindow
;
528 if (paintState
== paintAbandoned
) {
529 // Painting area was insufficient to cover new styling or brace highlight positions
532 paintState
= notPainting
;
536 void ScintillaWX::DoHScroll(int type
, int pos
) {
538 PRectangle rcText
= GetTextRectangle();
539 int pageWidth
= rcText
.Width() * 2 / 3;
540 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
541 xPos
-= H_SCROLL_STEP
;
542 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
543 xPos
+= H_SCROLL_STEP
;
544 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
546 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
548 if (xPos
> scrollWidth
- rcText
.Width()) {
549 xPos
= scrollWidth
- rcText
.Width();
552 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
554 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
556 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
559 HorizontalScrollTo(xPos
);
562 void ScintillaWX::DoVScroll(int type
, int pos
) {
563 int topLineNew
= topLine
;
564 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
566 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
568 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
569 topLineNew
-= LinesToScroll();
570 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
571 topLineNew
+= LinesToScroll();
572 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
574 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
575 topLineNew
= MaxScrollPos();
576 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
579 ScrollTo(topLineNew
);
582 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
583 int linesPerAction
, int ctrlDown
,
584 bool isPageScroll
) {
585 int topLineNew
= topLine
;
588 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
590 KeyCommand(SCI_ZOOMIN
);
593 KeyCommand(SCI_ZOOMOUT
);
596 else { // otherwise just scroll the window
599 wheelRotation
+= rotation
;
600 lines
= wheelRotation
/ delta
;
601 wheelRotation
-= lines
* delta
;
604 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
606 lines
*= linesPerAction
;
608 ScrollTo(topLineNew
);
614 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
615 // PRectangle rcClient(0,0,width,height);
616 // SetScrollBarsTo(rcClient);
621 void ScintillaWX::DoLoseFocus(){
623 SetFocusState(false);
627 void ScintillaWX::DoGainFocus(){
633 void ScintillaWX::DoSysColourChange() {
634 InvalidateStyleData();
637 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
638 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
641 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
642 ButtonUp(pt
, curTime
, ctrl
);
645 void ScintillaWX::DoLeftButtonMove(Point pt
) {
650 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
651 // Set the current position to the mouse click point and
652 // then paste in the PRIMARY selection, if any. wxGTK only.
653 int newPos
= PositionFromLocation(pt
);
654 MovePositionTo(newPos
, 0, 1);
656 pdoc
->BeginUndoAction();
657 wxTextDataObject data
;
658 bool gotData
= FALSE
;
659 if (wxTheClipboard
->Open()) {
660 wxTheClipboard
->UsePrimarySelection(TRUE
);
661 gotData
= wxTheClipboard
->GetData(data
);
662 wxTheClipboard
->UsePrimarySelection(FALSE
);
663 wxTheClipboard
->Close();
666 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
667 int len
= strlen(buf
);
668 pdoc
->InsertString(currentPos
, buf
, len
);
669 SetEmptySelection(currentPos
+ len
);
671 pdoc
->EndUndoAction();
675 ShowCaretAtCurrentPosition();
676 EnsureCaretVisible();
679 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
684 void ScintillaWX::DoAddChar(int key
) {
689 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
690 AddCharUTF((char*)buf
.data(), strlen(buf
));
698 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
700 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
702 #if defined(__WXGTK__) || defined(__WXMAC__)
703 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
704 // TODO: Check this, it shouldn't be true any longer.
705 if (ctrl
&& key
>= 1 && key
<= 26)
710 case WXK_DOWN
: key
= SCK_DOWN
; break;
711 case WXK_UP
: key
= SCK_UP
; break;
712 case WXK_LEFT
: key
= SCK_LEFT
; break;
713 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
714 case WXK_HOME
: key
= SCK_HOME
; break;
715 case WXK_END
: key
= SCK_END
; break;
716 case WXK_PAGEUP
: // fall through
717 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
718 case WXK_PAGEDOWN
: // fall through
719 case WXK_NEXT
: key
= SCK_NEXT
; break;
720 case WXK_DELETE
: key
= SCK_DELETE
; break;
721 case WXK_INSERT
: key
= SCK_INSERT
; break;
722 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
723 case WXK_BACK
: key
= SCK_BACK
; break;
724 case WXK_TAB
: key
= SCK_TAB
; break;
725 case WXK_RETURN
: key
= SCK_RETURN
; break;
726 case WXK_ADD
: // fall through
727 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
728 case WXK_SUBTRACT
: // fall through
729 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
730 case WXK_DIVIDE
: // fall through
731 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
732 case WXK_CONTROL
: key
= 0; break;
733 case WXK_ALT
: key
= 0; break;
734 case WXK_SHIFT
: key
= 0; break;
735 case WXK_MENU
: key
= 0; break;
740 // check for a few common Mac Meta-key combos and remap them to Ctrl
747 case 'A': // Select All
754 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
763 void ScintillaWX::DoCommand(int ID
) {
768 void ScintillaWX::DoContextMenu(Point pt
) {
769 if (displayPopupMenu
)
773 void ScintillaWX::DoOnListBox() {
774 AutoCompleteCompleted();
777 //----------------------------------------------------------------------
779 #if wxUSE_DRAG_AND_DROP
780 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
781 SetDragPosition(invalidPosition
);
783 // Send an event to allow the drag details to be changed
784 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
785 evt
.SetEventObject(stc
);
786 evt
.SetDragResult(dragResult
);
789 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
790 evt
.SetDragText(data
);
791 stc
->GetEventHandler()->ProcessEvent(evt
);
793 dragResult
= evt
.GetDragResult();
794 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
795 DropAt(evt
.GetPosition(),
796 wx2stc(evt
.GetDragText()),
797 dragResult
== wxDragMove
,
798 FALSE
); // TODO: rectangular?
805 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
811 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
812 SetDragPosition(PositionFromLocation(Point(x
, y
)));
814 // Send an event to allow the drag result to be changed
815 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
816 evt
.SetEventObject(stc
);
817 evt
.SetDragResult(def
);
820 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
821 stc
->GetEventHandler()->ProcessEvent(evt
);
823 dragResult
= evt
.GetDragResult();
828 void ScintillaWX::DoDragLeave() {
829 SetDragPosition(invalidPosition
);
832 //----------------------------------------------------------------------
834 // Redraw all of text area. This paint will not be abandoned.
835 void ScintillaWX::FullPaint() {
836 paintState
= painting
;
837 rcPaint
= GetClientRectangle();
838 paintingAllText
= true;
840 Surface
* surfaceWindow
= Surface::Allocate();
841 surfaceWindow
->Init(&dc
, wMain
.GetID());
844 ClipChildren(dc
, rcPaint
);
845 Paint(surfaceWindow
, rcPaint
);
848 delete surfaceWindow
;
849 paintState
= notPainting
;
853 void ScintillaWX::DoScrollToLine(int line
) {
858 void ScintillaWX::DoScrollToColumn(int column
) {
859 HorizontalScrollTo(column
* vs
.spaceWidth
);
863 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
864 wxRegion
rgn(wxRectFromPRectangle(rect
));
866 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
867 rgn
.Subtract(childRect
);
869 if (ct
.inCallTipMode
) {
870 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
871 rgn
.Subtract(childRect
);
874 dc
.SetClippingRegion(rgn
);
877 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
881 //----------------------------------------------------------------------
882 //----------------------------------------------------------------------