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
& WXUNUSED(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
);
164 vs
.extraFontFlag
= false; // UseAntiAliasing
166 vs
.extraFontFlag
= true; // UseAntiAliasing
171 void ScintillaWX::Finalise() {
172 ScintillaBase::Finalise();
178 void ScintillaWX::StartDrag() {
179 #if wxUSE_DRAG_AND_DROP
180 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
182 // Send an event to allow the drag text to be changed
183 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
184 evt
.SetEventObject(stc
);
185 evt
.SetDragText(dragText
);
186 evt
.SetDragAllowMove(TRUE
);
187 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
188 stc
->GetSelectionEnd()));
189 stc
->GetEventHandler()->ProcessEvent(evt
);
190 dragText
= evt
.GetDragText();
192 if (dragText
.Length()) {
193 wxDropSource
source(stc
);
194 wxTextDataObject
data(dragText
);
197 source
.SetData(data
);
198 dropWentOutside
= TRUE
;
199 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
200 if (result
== wxDragMove
&& dropWentOutside
)
203 SetDragPosition(invalidPosition
);
209 bool ScintillaWX::SetIdle(bool on
) {
210 if (idler
.state
!= on
) {
211 // connect or disconnect the EVT_IDLE handler
213 stc
->Connect(-1, wxEVT_IDLE
,
214 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
216 stc
->Disconnect(-1, wxEVT_IDLE
,
217 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
224 void ScintillaWX::SetTicking(bool on
) {
225 wxSTCTimer
* steTimer
;
226 if (timer
.ticking
!= on
) {
229 steTimer
= new wxSTCTimer(this);
230 steTimer
->Start(timer
.tickSize
);
231 timer
.tickerID
= steTimer
;
233 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
239 timer
.ticksToWait
= caret
.period
;
243 void ScintillaWX::SetMouseCapture(bool on
) {
244 if (mouseDownCaptures
) {
245 if (on
&& !capturedMouse
)
247 else if (!on
&& capturedMouse
&& stc
->HasCapture())
254 bool ScintillaWX::HaveMouseCapture() {
255 return capturedMouse
;
259 void ScintillaWX::ScrollText(int linesToMove
) {
260 int dy
= vs
.lineHeight
* (linesToMove
);
261 stc
->ScrollWindow(0, dy
);
265 void ScintillaWX::SetVerticalScrollPos() {
266 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
267 stc
->SetScrollPos(wxVERTICAL
, topLine
);
269 else { // otherwise use the one that's been given to us
270 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
274 void ScintillaWX::SetHorizontalScrollPos() {
275 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
276 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
278 else { // otherwise use the one that's been given to us
279 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
284 const int H_SCROLL_STEP
= 20;
286 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
287 bool modified
= false;
290 if (!verticalScrollBarVisible
)
293 // Check the vertical scrollbar
294 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
295 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
296 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
297 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
298 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
299 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
303 else { // otherwise use the one that's been given to us
304 int sbMax
= stc
->m_vScrollBar
->GetRange();
305 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
306 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
307 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
308 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
314 // Check the horizontal scrollbar
315 PRectangle rcText
= GetTextRectangle();
316 int horizEnd
= scrollWidth
;
319 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
321 int pageWidth
= rcText
.Width();
323 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
324 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
325 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
326 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
327 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
328 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
330 if (scrollWidth
< pageWidth
) {
331 HorizontalScrollTo(0);
335 else { // otherwise use the one that's been given to us
336 int sbMax
= stc
->m_hScrollBar
->GetRange();
337 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
338 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
339 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
340 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
342 if (scrollWidth
< pageWidth
) {
343 HorizontalScrollTo(0);
352 void ScintillaWX::NotifyChange() {
357 void ScintillaWX::NotifyParent(SCNotification scn
) {
358 stc
->NotifyParent(&scn
);
362 // This method is overloaded from ScintillaBase in order to prevent the
363 // AutoComplete window from being destroyed when it gets the focus. There is
364 // a side effect that the AutoComp will also not be destroyed when switching
365 // to another window, but I think that is okay.
366 void ScintillaWX::CancelModes() {
368 AutoCompleteCancel();
370 Editor::CancelModes();
375 void ScintillaWX::Copy() {
376 if (currentPos
!= anchor
) {
378 CopySelectionRange(&st
);
384 void ScintillaWX::Paste() {
385 pdoc
->BeginUndoAction();
388 wxTextDataObject data
;
389 bool gotData
= FALSE
;
391 if (wxTheClipboard
->Open()) {
392 wxTheClipboard
->UsePrimarySelection(FALSE
);
393 gotData
= wxTheClipboard
->GetData(data
);
394 wxTheClipboard
->Close();
397 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
398 int len
= strlen(buf
);
399 pdoc
->InsertString(currentPos
, buf
, len
);
400 SetEmptySelection(currentPos
+ len
);
403 pdoc
->EndUndoAction();
409 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
410 if (wxTheClipboard
->Open()) {
411 wxTheClipboard
->UsePrimarySelection(FALSE
);
412 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
413 wxTheClipboard
->SetData(new wxTextDataObject(text
));
414 wxTheClipboard
->Close();
419 bool ScintillaWX::CanPaste() {
420 bool canPaste
= FALSE
;
423 if (Editor::CanPaste()) {
424 didOpen
= !wxTheClipboard
->IsOpened();
426 wxTheClipboard
->Open();
428 if (wxTheClipboard
->IsOpened()) {
429 wxTheClipboard
->UsePrimarySelection(FALSE
);
430 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
432 wxTheClipboard
->Close();
438 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
439 if (! ct
.wCallTip
.Created() ) {
440 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
441 ct
.wDraw
= ct
.wCallTip
;
446 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
448 ((wxMenu
*)popup
.GetID())->AppendSeparator();
450 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
453 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
457 // This is called by the Editor base class whenever something is selected
458 void ScintillaWX::ClaimSelection() {
460 // Until wxGTK is able to support using both the primary selection and the
461 // clipboard at the same time I think it causes more problems than it is
462 // worth to implement this method. Selecting text should not clear the
463 // clipboard. --Robin
465 // Put the selected text in the PRIMARY selection
466 if (currentPos
!= anchor
) {
468 CopySelectionRange(&st
);
469 if (wxTheClipboard
->Open()) {
470 wxTheClipboard
->UsePrimarySelection(TRUE
);
471 wxString text
= stc2wx(st
.s
, st
.len
);
472 wxTheClipboard
->SetData(new wxTextDataObject(text
));
473 wxTheClipboard
->UsePrimarySelection(FALSE
);
474 wxTheClipboard
->Close();
482 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
486 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
488 case SCI_CALLTIPSHOW
: {
489 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
490 // because of the little tweak that needs done below for wxGTK.
491 // When updating new versions double check that this is still
492 // needed, and that any new code there is copied here too.
493 Point pt
= LocationFromPosition(wParam
);
494 char* defn
= reinterpret_cast<char *>(lParam
);
495 AutoCompleteCancel();
496 pt
.y
+= vs
.lineHeight
;
497 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
499 vs
.styles
[STYLE_DEFAULT
].fontName
,
500 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
503 // If the call-tip window would be out of the client
504 // space, adjust so it displays above the text.
505 PRectangle rcClient
= GetClientRectangle();
506 if (rc
.bottom
> rcClient
.bottom
) {
508 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
510 int offset
= vs
.lineHeight
+ rc
.Height();
515 // Now display the window.
516 CreateCallTipWindow(rc
);
517 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
523 case SCI_LOADLEXERLIBRARY
:
524 LexerManager::GetInstance()->Load((const char*)lParam
);
528 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
535 //----------------------------------------------------------------------
538 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
540 paintState
= painting
;
541 Surface
* surfaceWindow
= Surface::Allocate();
542 surfaceWindow
->Init(dc
, wMain
.GetID());
543 rcPaint
= PRectangleFromwxRect(rect
);
544 PRectangle rcClient
= GetClientRectangle();
545 paintingAllText
= rcPaint
.Contains(rcClient
);
548 ClipChildren(*dc
, rcPaint
);
549 Paint(surfaceWindow
, rcPaint
);
552 delete surfaceWindow
;
553 if (paintState
== paintAbandoned
) {
554 // Painting area was insufficient to cover new styling or brace highlight positions
557 paintState
= notPainting
;
561 void ScintillaWX::DoHScroll(int type
, int pos
) {
563 PRectangle rcText
= GetTextRectangle();
564 int pageWidth
= rcText
.Width() * 2 / 3;
565 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
566 xPos
-= H_SCROLL_STEP
;
567 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
568 xPos
+= H_SCROLL_STEP
;
569 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
571 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
573 if (xPos
> scrollWidth
- rcText
.Width()) {
574 xPos
= scrollWidth
- rcText
.Width();
577 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
579 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
581 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
584 HorizontalScrollTo(xPos
);
587 void ScintillaWX::DoVScroll(int type
, int pos
) {
588 int topLineNew
= topLine
;
589 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
591 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
593 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
594 topLineNew
-= LinesToScroll();
595 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
596 topLineNew
+= LinesToScroll();
597 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
599 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
600 topLineNew
= MaxScrollPos();
601 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
604 ScrollTo(topLineNew
);
607 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
608 int linesPerAction
, int ctrlDown
,
609 bool isPageScroll
) {
610 int topLineNew
= topLine
;
613 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
615 KeyCommand(SCI_ZOOMIN
);
618 KeyCommand(SCI_ZOOMOUT
);
621 else { // otherwise just scroll the window
624 wheelRotation
+= rotation
;
625 lines
= wheelRotation
/ delta
;
626 wheelRotation
-= lines
* delta
;
629 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
631 lines
*= linesPerAction
;
633 ScrollTo(topLineNew
);
639 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
640 // PRectangle rcClient(0,0,width,height);
641 // SetScrollBarsTo(rcClient);
646 void ScintillaWX::DoLoseFocus(){
648 SetFocusState(false);
652 void ScintillaWX::DoGainFocus(){
658 void ScintillaWX::DoSysColourChange() {
659 InvalidateStyleData();
662 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
663 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
666 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
667 ButtonUp(pt
, curTime
, ctrl
);
670 void ScintillaWX::DoLeftButtonMove(Point pt
) {
675 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
676 // Set the current position to the mouse click point and
677 // then paste in the PRIMARY selection, if any. wxGTK only.
678 int newPos
= PositionFromLocation(pt
);
679 MovePositionTo(newPos
, noSel
, true);
681 pdoc
->BeginUndoAction();
682 wxTextDataObject data
;
683 bool gotData
= FALSE
;
684 if (wxTheClipboard
->Open()) {
685 wxTheClipboard
->UsePrimarySelection(TRUE
);
686 gotData
= wxTheClipboard
->GetData(data
);
687 wxTheClipboard
->UsePrimarySelection(FALSE
);
688 wxTheClipboard
->Close();
691 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
692 int len
= strlen(buf
);
693 pdoc
->InsertString(currentPos
, buf
, len
);
694 SetEmptySelection(currentPos
+ len
);
696 pdoc
->EndUndoAction();
700 ShowCaretAtCurrentPosition();
701 EnsureCaretVisible();
704 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
709 void ScintillaWX::DoAddChar(int key
) {
714 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
715 AddCharUTF((char*)buf
.data(), strlen(buf
));
723 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
725 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
727 #if defined(__WXGTK__) || defined(__WXMAC__)
728 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
729 // TODO: Check this, it shouldn't be true any longer.
730 if (ctrl
&& key
>= 1 && key
<= 26)
735 case WXK_DOWN
: key
= SCK_DOWN
; break;
736 case WXK_UP
: key
= SCK_UP
; break;
737 case WXK_LEFT
: key
= SCK_LEFT
; break;
738 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
739 case WXK_HOME
: key
= SCK_HOME
; break;
740 case WXK_END
: key
= SCK_END
; break;
741 case WXK_PAGEUP
: // fall through
742 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
743 case WXK_PAGEDOWN
: // fall through
744 case WXK_NEXT
: key
= SCK_NEXT
; break;
745 case WXK_DELETE
: key
= SCK_DELETE
; break;
746 case WXK_INSERT
: key
= SCK_INSERT
; break;
747 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
748 case WXK_BACK
: key
= SCK_BACK
; break;
749 case WXK_TAB
: key
= SCK_TAB
; break;
750 case WXK_RETURN
: key
= SCK_RETURN
; break;
751 case WXK_ADD
: // fall through
752 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
753 case WXK_SUBTRACT
: // fall through
754 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
755 case WXK_DIVIDE
: // fall through
756 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
757 case WXK_CONTROL
: key
= 0; break;
758 case WXK_ALT
: key
= 0; break;
759 case WXK_SHIFT
: key
= 0; break;
760 case WXK_MENU
: key
= 0; break;
765 // check for a few common Mac Meta-key combos and remap them to Ctrl
772 case 'A': // Select All
779 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
788 void ScintillaWX::DoCommand(int ID
) {
793 void ScintillaWX::DoContextMenu(Point pt
) {
794 if (displayPopupMenu
)
798 void ScintillaWX::DoOnListBox() {
799 AutoCompleteCompleted();
803 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
811 //----------------------------------------------------------------------
813 #if wxUSE_DRAG_AND_DROP
814 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
815 SetDragPosition(invalidPosition
);
817 // Send an event to allow the drag details to be changed
818 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
819 evt
.SetEventObject(stc
);
820 evt
.SetDragResult(dragResult
);
823 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
824 evt
.SetDragText(data
);
825 stc
->GetEventHandler()->ProcessEvent(evt
);
827 dragResult
= evt
.GetDragResult();
828 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
829 DropAt(evt
.GetPosition(),
830 wx2stc(evt
.GetDragText()),
831 dragResult
== wxDragMove
,
832 FALSE
); // TODO: rectangular?
839 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
845 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
846 SetDragPosition(PositionFromLocation(Point(x
, y
)));
848 // Send an event to allow the drag result to be changed
849 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
850 evt
.SetEventObject(stc
);
851 evt
.SetDragResult(def
);
854 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
855 stc
->GetEventHandler()->ProcessEvent(evt
);
857 dragResult
= evt
.GetDragResult();
862 void ScintillaWX::DoDragLeave() {
863 SetDragPosition(invalidPosition
);
866 //----------------------------------------------------------------------
868 // Redraw all of text area. This paint will not be abandoned.
869 void ScintillaWX::FullPaint(wxDC
*dc
) {
870 wxCHECK_RET(dc
!= NULL
, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
871 paintState
= painting
;
872 rcPaint
= GetClientRectangle();
873 paintingAllText
= true;
874 Surface
* surfaceWindow
= Surface::Allocate();
875 surfaceWindow
->Init(dc
, wMain
.GetID());
878 ClipChildren(*dc
, rcPaint
);
879 Paint(surfaceWindow
, rcPaint
);
882 delete surfaceWindow
;
883 paintState
= notPainting
;
887 void ScintillaWX::DoScrollToLine(int line
) {
892 void ScintillaWX::DoScrollToColumn(int column
) {
893 HorizontalScrollTo(column
* vs
.spaceWidth
);
897 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
898 wxRegion
rgn(wxRectFromPRectangle(rect
));
900 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
901 rgn
.Subtract(childRect
);
903 if (ct
.inCallTipMode
) {
904 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
905 rgn
.Subtract(childRect
);
908 dc
.SetClippingRegion(rgn
);
911 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
916 void ScintillaWX::SetUseAntiAliasing(bool useAA
) {
917 vs
.extraFontFlag
= useAA
;
918 InvalidateStyleRedraw();
921 bool ScintillaWX::GetUseAntiAliasing() {
922 return vs
.extraFontFlag
;
925 //----------------------------------------------------------------------
926 //----------------------------------------------------------------------