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;
146 ScintillaWX::~ScintillaWX() {
150 //----------------------------------------------------------------------
151 // base class virtuals
154 void ScintillaWX::Initialise() {
155 //ScintillaBase::Initialise();
156 #if wxUSE_DRAG_AND_DROP
157 dropTarget
= new wxSTCDropTarget
;
158 dropTarget
->SetScintilla(this);
159 stc
->SetDropTarget(dropTarget
);
164 void ScintillaWX::Finalise() {
165 ScintillaBase::Finalise();
169 void ScintillaWX::StartDrag() {
170 #if wxUSE_DRAG_AND_DROP
171 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
173 // Send an event to allow the drag text to be changed
174 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
175 evt
.SetEventObject(stc
);
176 evt
.SetDragText(dragText
);
177 evt
.SetDragAllowMove(TRUE
);
178 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
179 stc
->GetSelectionEnd()));
180 stc
->GetEventHandler()->ProcessEvent(evt
);
181 dragText
= evt
.GetDragText();
183 if (dragText
.Length()) {
184 wxDropSource
source(stc
);
185 wxTextDataObject
data(dragText
);
188 source
.SetData(data
);
189 dropWentOutside
= TRUE
;
190 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
191 if (result
== wxDragMove
&& dropWentOutside
)
194 SetDragPosition(invalidPosition
);
200 void ScintillaWX::SetTicking(bool on
) {
201 wxSTCTimer
* steTimer
;
202 if (timer
.ticking
!= on
) {
205 steTimer
= new wxSTCTimer(this);
206 steTimer
->Start(timer
.tickSize
);
207 timer
.tickerID
= steTimer
;
209 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
215 timer
.ticksToWait
= caret
.period
;
219 void ScintillaWX::SetMouseCapture(bool on
) {
220 if (on
&& !capturedMouse
)
222 else if (!on
&& capturedMouse
&& stc
->HasCapture())
228 bool ScintillaWX::HaveMouseCapture() {
229 return capturedMouse
;
233 void ScintillaWX::ScrollText(int linesToMove
) {
234 int dy
= vs
.lineHeight
* (linesToMove
);
235 stc
->ScrollWindow(0, dy
);
239 void ScintillaWX::SetVerticalScrollPos() {
240 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
241 stc
->SetScrollPos(wxVERTICAL
, topLine
);
243 else { // otherwise use the one that's been given to us
244 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
248 void ScintillaWX::SetHorizontalScrollPos() {
249 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
250 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
252 else { // otherwise use the one that's been given to us
253 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
258 const int H_SCROLL_STEP
= 20;
260 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
261 bool modified
= false;
264 if (!verticalScrollBarVisible
)
267 // Check the vertical scrollbar
268 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
269 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
270 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
271 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
272 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
273 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
277 else { // otherwise use the one that's been given to us
278 int sbMax
= stc
->m_vScrollBar
->GetRange();
279 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
280 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
281 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
282 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
288 // Check the horizontal scrollbar
289 PRectangle rcText
= GetTextRectangle();
290 int horizEnd
= scrollWidth
;
293 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
295 int pageWidth
= rcText
.Width();
297 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
298 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
299 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
300 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
301 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
302 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
304 if (scrollWidth
< pageWidth
) {
305 HorizontalScrollTo(0);
309 else { // otherwise use the one that's been given to us
310 int sbMax
= stc
->m_hScrollBar
->GetRange();
311 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
312 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
313 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
314 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
316 if (scrollWidth
< pageWidth
) {
317 HorizontalScrollTo(0);
326 void ScintillaWX::NotifyChange() {
331 void ScintillaWX::NotifyParent(SCNotification scn
) {
332 stc
->NotifyParent(&scn
);
337 void ScintillaWX::Copy() {
338 if (currentPos
!= anchor
) {
340 CopySelectionRange(&st
);
346 void ScintillaWX::Paste() {
347 pdoc
->BeginUndoAction();
350 wxTextDataObject data
;
351 bool gotData
= FALSE
;
353 if (wxTheClipboard
->Open()) {
354 wxTheClipboard
->UsePrimarySelection(FALSE
);
355 gotData
= wxTheClipboard
->GetData(data
);
356 wxTheClipboard
->Close();
359 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
360 int len
= strlen(buf
);
361 pdoc
->InsertString(currentPos
, buf
, len
);
362 SetEmptySelection(currentPos
+ len
);
365 pdoc
->EndUndoAction();
371 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
372 if (wxTheClipboard
->Open()) {
373 wxTheClipboard
->UsePrimarySelection(FALSE
);
374 wxString text
= stc2wx(st
.s
, st
.len
);
375 wxTheClipboard
->SetData(new wxTextDataObject(text
));
376 wxTheClipboard
->Close();
381 bool ScintillaWX::CanPaste() {
382 bool canPaste
= FALSE
;
385 if (Editor::CanPaste()) {
386 didOpen
= !wxTheClipboard
->IsOpened();
388 wxTheClipboard
->Open();
390 if (wxTheClipboard
->IsOpened()) {
391 wxTheClipboard
->UsePrimarySelection(FALSE
);
392 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
394 wxTheClipboard
->Close();
400 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
401 if (! ct
.wCallTip
.Created() ) {
402 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
403 ct
.wDraw
= ct
.wCallTip
;
408 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
410 ((wxMenu
*)popup
.GetID())->AppendSeparator();
412 ((wxMenu
*)popup
.GetID())->Append(cmd
, stc2wx(label
));
415 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
419 // This is called by the Editor base class whenever something is selected
420 void ScintillaWX::ClaimSelection() {
422 // Until wxGTK is able to support using both the primary selection and the
423 // clipboard at the same time I think it causes more problems than it is
424 // worth to implement this method. Selecting text should not clear the
425 // clipboard. --Robin
427 // Put the selected text in the PRIMARY selection
428 if (currentPos
!= anchor
) {
430 CopySelectionRange(&st
);
431 if (wxTheClipboard
->Open()) {
432 wxTheClipboard
->UsePrimarySelection(TRUE
);
433 wxString text
= stc2wx(st
.s
, st
.len
);
434 wxTheClipboard
->SetData(new wxTextDataObject(text
));
435 wxTheClipboard
->UsePrimarySelection(FALSE
);
436 wxTheClipboard
->Close();
444 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
448 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
450 case SCI_CALLTIPSHOW
: {
451 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
452 // because of the little tweak that needs done below for wxGTK.
453 // When updating new versions double check that this is still
454 // needed, and that any new code there is copied here too.
455 Point pt
= LocationFromPosition(wParam
);
456 char* defn
= reinterpret_cast<char *>(lParam
);
457 AutoCompleteCancel();
458 pt
.y
+= vs
.lineHeight
;
459 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
461 vs
.styles
[STYLE_DEFAULT
].fontName
,
462 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
465 // If the call-tip window would be out of the client
466 // space, adjust so it displays above the text.
467 PRectangle rcClient
= GetClientRectangle();
468 if (rc
.bottom
> rcClient
.bottom
) {
470 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
472 int offset
= vs
.lineHeight
+ rc
.Height();
477 // Now display the window.
478 CreateCallTipWindow(rc
);
479 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
485 case SCI_LOADLEXERLIBRARY
:
486 LexerManager::GetInstance()->Load((const char*)lParam
);
490 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
497 //----------------------------------------------------------------------
500 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
502 paintState
= painting
;
503 Surface
* surfaceWindow
= Surface::Allocate();
504 surfaceWindow
->Init(dc
, wMain
.GetID());
505 rcPaint
= PRectangleFromwxRect(rect
);
506 PRectangle rcClient
= GetClientRectangle();
507 paintingAllText
= rcPaint
.Contains(rcClient
);
510 ClipChildren(*dc
, rcPaint
);
511 Paint(surfaceWindow
, rcPaint
);
514 delete surfaceWindow
;
515 if (paintState
== paintAbandoned
) {
516 // Painting area was insufficient to cover new styling or brace highlight positions
519 paintState
= notPainting
;
523 void ScintillaWX::DoHScroll(int type
, int pos
) {
525 PRectangle rcText
= GetTextRectangle();
526 int pageWidth
= rcText
.Width() * 2 / 3;
527 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
528 xPos
-= H_SCROLL_STEP
;
529 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
530 xPos
+= H_SCROLL_STEP
;
531 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
533 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
535 if (xPos
> scrollWidth
- rcText
.Width()) {
536 xPos
= scrollWidth
- rcText
.Width();
539 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
541 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
543 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
546 HorizontalScrollTo(xPos
);
549 void ScintillaWX::DoVScroll(int type
, int pos
) {
550 int topLineNew
= topLine
;
551 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
553 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
555 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
556 topLineNew
-= LinesToScroll();
557 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
558 topLineNew
+= LinesToScroll();
559 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
561 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
562 topLineNew
= MaxScrollPos();
563 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
566 ScrollTo(topLineNew
);
569 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
570 int linesPerAction
, int ctrlDown
,
571 bool isPageScroll
) {
572 int topLineNew
= topLine
;
575 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
577 KeyCommand(SCI_ZOOMIN
);
580 KeyCommand(SCI_ZOOMOUT
);
583 else { // otherwise just scroll the window
586 wheelRotation
+= rotation
;
587 lines
= wheelRotation
/ delta
;
588 wheelRotation
-= lines
* delta
;
591 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
593 lines
*= linesPerAction
;
595 ScrollTo(topLineNew
);
601 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
602 // PRectangle rcClient(0,0,width,height);
603 // SetScrollBarsTo(rcClient);
608 void ScintillaWX::DoLoseFocus(){
609 SetFocusState(false);
612 void ScintillaWX::DoGainFocus(){
616 void ScintillaWX::DoSysColourChange() {
617 InvalidateStyleData();
620 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
621 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
624 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
625 ButtonUp(pt
, curTime
, ctrl
);
628 void ScintillaWX::DoLeftButtonMove(Point pt
) {
633 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
634 // Set the current position to the mouse click point and
635 // then paste in the PRIMARY selection, if any. wxGTK only.
636 int newPos
= PositionFromLocation(pt
);
637 MovePositionTo(newPos
, 0, 1);
639 pdoc
->BeginUndoAction();
640 wxTextDataObject data
;
641 bool gotData
= FALSE
;
642 if (wxTheClipboard
->Open()) {
643 wxTheClipboard
->UsePrimarySelection(TRUE
);
644 gotData
= wxTheClipboard
->GetData(data
);
645 wxTheClipboard
->UsePrimarySelection(FALSE
);
646 wxTheClipboard
->Close();
649 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
650 int len
= strlen(buf
);
651 pdoc
->InsertString(currentPos
, buf
, len
);
652 SetEmptySelection(currentPos
+ len
);
654 pdoc
->EndUndoAction();
658 ShowCaretAtCurrentPosition();
659 EnsureCaretVisible();
662 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
667 void ScintillaWX::DoAddChar(int key
) {
672 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
673 AddCharUTF((char*)buf
.data(), strlen(buf
));
681 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
683 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
685 #if defined(__WXGTK__) || defined(__WXMAC__)
686 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
687 // TODO: Check this, it shouldn't be true any longer.
688 if (ctrl
&& key
>= 1 && key
<= 26)
693 case WXK_DOWN
: key
= SCK_DOWN
; break;
694 case WXK_UP
: key
= SCK_UP
; break;
695 case WXK_LEFT
: key
= SCK_LEFT
; break;
696 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
697 case WXK_HOME
: key
= SCK_HOME
; break;
698 case WXK_END
: key
= SCK_END
; break;
699 case WXK_PAGEUP
: // fall through
700 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
701 case WXK_PAGEDOWN
: // fall through
702 case WXK_NEXT
: key
= SCK_NEXT
; break;
703 case WXK_DELETE
: key
= SCK_DELETE
; break;
704 case WXK_INSERT
: key
= SCK_INSERT
; break;
705 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
706 case WXK_BACK
: key
= SCK_BACK
; break;
707 case WXK_TAB
: key
= SCK_TAB
; break;
708 case WXK_RETURN
: key
= SCK_RETURN
; break;
709 case WXK_ADD
: // fall through
710 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
711 case WXK_SUBTRACT
: // fall through
712 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
713 case WXK_DIVIDE
: // fall through
714 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
715 case WXK_CONTROL
: key
= 0; break;
716 case WXK_ALT
: key
= 0; break;
717 case WXK_SHIFT
: key
= 0; break;
718 case WXK_MENU
: key
= 0; break;
723 // check for a few common Mac Meta-key combos and remap them to Ctrl
730 case 'A': // Select All
736 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
745 void ScintillaWX::DoCommand(int ID
) {
750 void ScintillaWX::DoContextMenu(Point pt
) {
751 if (displayPopupMenu
)
755 void ScintillaWX::DoOnListBox() {
756 AutoCompleteCompleted();
759 //----------------------------------------------------------------------
761 #if wxUSE_DRAG_AND_DROP
762 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
763 SetDragPosition(invalidPosition
);
765 // Send an event to allow the drag details to be changed
766 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
767 evt
.SetEventObject(stc
);
768 evt
.SetDragResult(dragResult
);
771 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
772 evt
.SetDragText(data
);
773 stc
->GetEventHandler()->ProcessEvent(evt
);
775 dragResult
= evt
.GetDragResult();
776 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
777 DropAt(evt
.GetPosition(),
778 wx2stc(evt
.GetDragText()),
779 dragResult
== wxDragMove
,
780 FALSE
); // TODO: rectangular?
787 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
793 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
794 SetDragPosition(PositionFromLocation(Point(x
, y
)));
796 // Send an event to allow the drag result to be changed
797 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
798 evt
.SetEventObject(stc
);
799 evt
.SetDragResult(def
);
802 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
803 stc
->GetEventHandler()->ProcessEvent(evt
);
805 dragResult
= evt
.GetDragResult();
810 void ScintillaWX::DoDragLeave() {
811 SetDragPosition(invalidPosition
);
814 //----------------------------------------------------------------------
816 // Redraw all of text area. This paint will not be abandoned.
817 void ScintillaWX::FullPaint() {
818 paintState
= painting
;
819 rcPaint
= GetClientRectangle();
820 paintingAllText
= true;
822 Surface
* surfaceWindow
= Surface::Allocate();
823 surfaceWindow
->Init(&dc
, wMain
.GetID());
826 ClipChildren(dc
, rcPaint
);
827 Paint(surfaceWindow
, rcPaint
);
830 delete surfaceWindow
;
831 paintState
= notPainting
;
835 void ScintillaWX::DoScrollToLine(int line
) {
840 void ScintillaWX::DoScrollToColumn(int column
) {
841 HorizontalScrollTo(column
* vs
.spaceWidth
);
845 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
846 wxRegion
rgn(wxRectFromPRectangle(rect
));
848 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
849 rgn
.Subtract(childRect
);
851 if (ct
.inCallTipMode
) {
852 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
853 rgn
.Subtract(childRect
);
856 dc
.SetClippingRegion(rgn
);
859 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
863 //----------------------------------------------------------------------
864 //----------------------------------------------------------------------