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
);
163 vs
.extraFontFlag
= true;
167 void ScintillaWX::Finalise() {
168 ScintillaBase::Finalise();
174 void ScintillaWX::StartDrag() {
175 #if wxUSE_DRAG_AND_DROP
176 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
178 // Send an event to allow the drag text to be changed
179 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
180 evt
.SetEventObject(stc
);
181 evt
.SetDragText(dragText
);
182 evt
.SetDragAllowMove(TRUE
);
183 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
184 stc
->GetSelectionEnd()));
185 stc
->GetEventHandler()->ProcessEvent(evt
);
186 dragText
= evt
.GetDragText();
188 if (dragText
.Length()) {
189 wxDropSource
source(stc
);
190 wxTextDataObject
data(dragText
);
193 source
.SetData(data
);
194 dropWentOutside
= TRUE
;
195 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
196 if (result
== wxDragMove
&& dropWentOutside
)
199 SetDragPosition(invalidPosition
);
205 bool ScintillaWX::SetIdle(bool on
) {
206 if (idler
.state
!= on
) {
207 // connect or disconnect the EVT_IDLE handler
209 stc
->Connect(-1, wxEVT_IDLE
,
210 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
212 stc
->Disconnect(-1, wxEVT_IDLE
,
213 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
220 void ScintillaWX::SetTicking(bool on
) {
221 wxSTCTimer
* steTimer
;
222 if (timer
.ticking
!= on
) {
225 steTimer
= new wxSTCTimer(this);
226 steTimer
->Start(timer
.tickSize
);
227 timer
.tickerID
= steTimer
;
229 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
235 timer
.ticksToWait
= caret
.period
;
239 void ScintillaWX::SetMouseCapture(bool on
) {
240 if (mouseDownCaptures
) {
241 if (on
&& !capturedMouse
)
243 else if (!on
&& capturedMouse
&& stc
->HasCapture())
250 bool ScintillaWX::HaveMouseCapture() {
251 return capturedMouse
;
255 void ScintillaWX::ScrollText(int linesToMove
) {
256 int dy
= vs
.lineHeight
* (linesToMove
);
257 stc
->ScrollWindow(0, dy
);
261 void ScintillaWX::SetVerticalScrollPos() {
262 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
263 stc
->SetScrollPos(wxVERTICAL
, topLine
);
265 else { // otherwise use the one that's been given to us
266 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
270 void ScintillaWX::SetHorizontalScrollPos() {
271 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
272 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
274 else { // otherwise use the one that's been given to us
275 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
280 const int H_SCROLL_STEP
= 20;
282 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
283 bool modified
= false;
286 if (!verticalScrollBarVisible
)
289 // Check the vertical scrollbar
290 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
291 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
292 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
293 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
294 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
295 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
299 else { // otherwise use the one that's been given to us
300 int sbMax
= stc
->m_vScrollBar
->GetRange();
301 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
302 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
303 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
304 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
310 // Check the horizontal scrollbar
311 PRectangle rcText
= GetTextRectangle();
312 int horizEnd
= scrollWidth
;
315 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
317 int pageWidth
= rcText
.Width();
319 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
320 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
321 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
322 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
323 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
324 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
326 if (scrollWidth
< pageWidth
) {
327 HorizontalScrollTo(0);
331 else { // otherwise use the one that's been given to us
332 int sbMax
= stc
->m_hScrollBar
->GetRange();
333 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
334 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
335 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
336 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
338 if (scrollWidth
< pageWidth
) {
339 HorizontalScrollTo(0);
348 void ScintillaWX::NotifyChange() {
353 void ScintillaWX::NotifyParent(SCNotification scn
) {
354 stc
->NotifyParent(&scn
);
358 // This method is overloaded from ScintillaBase in order to prevent the
359 // AutoComplete window from being destroyed when it gets the focus. There is
360 // a side effect that the AutoComp will also not be destroyed when switching
361 // to another window, but I think that is okay.
362 void ScintillaWX::CancelModes() {
364 AutoCompleteCancel();
366 Editor::CancelModes();
371 void ScintillaWX::Copy() {
372 if (currentPos
!= anchor
) {
374 CopySelectionRange(&st
);
380 void ScintillaWX::Paste() {
381 pdoc
->BeginUndoAction();
384 wxTextDataObject data
;
385 bool gotData
= FALSE
;
387 if (wxTheClipboard
->Open()) {
388 wxTheClipboard
->UsePrimarySelection(FALSE
);
389 gotData
= wxTheClipboard
->GetData(data
);
390 wxTheClipboard
->Close();
393 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
394 int len
= strlen(buf
);
395 pdoc
->InsertString(currentPos
, buf
, len
);
396 SetEmptySelection(currentPos
+ len
);
399 pdoc
->EndUndoAction();
405 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
406 if (wxTheClipboard
->Open()) {
407 wxTheClipboard
->UsePrimarySelection(FALSE
);
408 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
409 wxTheClipboard
->SetData(new wxTextDataObject(text
));
410 wxTheClipboard
->Close();
415 bool ScintillaWX::CanPaste() {
416 bool canPaste
= FALSE
;
419 if (Editor::CanPaste()) {
420 didOpen
= !wxTheClipboard
->IsOpened();
422 wxTheClipboard
->Open();
424 if (wxTheClipboard
->IsOpened()) {
425 wxTheClipboard
->UsePrimarySelection(FALSE
);
426 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
428 wxTheClipboard
->Close();
434 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
435 if (! ct
.wCallTip
.Created() ) {
436 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
437 ct
.wDraw
= ct
.wCallTip
;
442 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
444 ((wxMenu
*)popup
.GetID())->AppendSeparator();
446 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
449 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
453 // This is called by the Editor base class whenever something is selected
454 void ScintillaWX::ClaimSelection() {
456 // Until wxGTK is able to support using both the primary selection and the
457 // clipboard at the same time I think it causes more problems than it is
458 // worth to implement this method. Selecting text should not clear the
459 // clipboard. --Robin
461 // Put the selected text in the PRIMARY selection
462 if (currentPos
!= anchor
) {
464 CopySelectionRange(&st
);
465 if (wxTheClipboard
->Open()) {
466 wxTheClipboard
->UsePrimarySelection(TRUE
);
467 wxString text
= stc2wx(st
.s
, st
.len
);
468 wxTheClipboard
->SetData(new wxTextDataObject(text
));
469 wxTheClipboard
->UsePrimarySelection(FALSE
);
470 wxTheClipboard
->Close();
478 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
482 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
484 case SCI_CALLTIPSHOW
: {
485 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
486 // because of the little tweak that needs done below for wxGTK.
487 // When updating new versions double check that this is still
488 // needed, and that any new code there is copied here too.
489 Point pt
= LocationFromPosition(wParam
);
490 char* defn
= reinterpret_cast<char *>(lParam
);
491 AutoCompleteCancel();
492 pt
.y
+= vs
.lineHeight
;
493 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
495 vs
.styles
[STYLE_DEFAULT
].fontName
,
496 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
499 // If the call-tip window would be out of the client
500 // space, adjust so it displays above the text.
501 PRectangle rcClient
= GetClientRectangle();
502 if (rc
.bottom
> rcClient
.bottom
) {
504 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
506 int offset
= vs
.lineHeight
+ rc
.Height();
511 // Now display the window.
512 CreateCallTipWindow(rc
);
513 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
519 case SCI_LOADLEXERLIBRARY
:
520 LexerManager::GetInstance()->Load((const char*)lParam
);
524 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
531 //----------------------------------------------------------------------
534 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
536 paintState
= painting
;
537 Surface
* surfaceWindow
= Surface::Allocate();
538 surfaceWindow
->Init(dc
, wMain
.GetID());
539 rcPaint
= PRectangleFromwxRect(rect
);
540 PRectangle rcClient
= GetClientRectangle();
541 paintingAllText
= rcPaint
.Contains(rcClient
);
544 ClipChildren(*dc
, rcPaint
);
545 Paint(surfaceWindow
, rcPaint
);
548 delete surfaceWindow
;
549 if (paintState
== paintAbandoned
) {
550 // Painting area was insufficient to cover new styling or brace highlight positions
553 paintState
= notPainting
;
557 void ScintillaWX::DoHScroll(int type
, int pos
) {
559 PRectangle rcText
= GetTextRectangle();
560 int pageWidth
= rcText
.Width() * 2 / 3;
561 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
562 xPos
-= H_SCROLL_STEP
;
563 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
564 xPos
+= H_SCROLL_STEP
;
565 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
567 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
569 if (xPos
> scrollWidth
- rcText
.Width()) {
570 xPos
= scrollWidth
- rcText
.Width();
573 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
575 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
577 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
580 HorizontalScrollTo(xPos
);
583 void ScintillaWX::DoVScroll(int type
, int pos
) {
584 int topLineNew
= topLine
;
585 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
587 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
589 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
590 topLineNew
-= LinesToScroll();
591 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
592 topLineNew
+= LinesToScroll();
593 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
595 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
596 topLineNew
= MaxScrollPos();
597 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
600 ScrollTo(topLineNew
);
603 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
604 int linesPerAction
, int ctrlDown
,
605 bool isPageScroll
) {
606 int topLineNew
= topLine
;
609 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
611 KeyCommand(SCI_ZOOMIN
);
614 KeyCommand(SCI_ZOOMOUT
);
617 else { // otherwise just scroll the window
620 wheelRotation
+= rotation
;
621 lines
= wheelRotation
/ delta
;
622 wheelRotation
-= lines
* delta
;
625 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
627 lines
*= linesPerAction
;
629 ScrollTo(topLineNew
);
635 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
636 // PRectangle rcClient(0,0,width,height);
637 // SetScrollBarsTo(rcClient);
642 void ScintillaWX::DoLoseFocus(){
644 SetFocusState(false);
648 void ScintillaWX::DoGainFocus(){
654 void ScintillaWX::DoSysColourChange() {
655 InvalidateStyleData();
658 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
659 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
662 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
663 ButtonUp(pt
, curTime
, ctrl
);
666 void ScintillaWX::DoLeftButtonMove(Point pt
) {
671 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
672 // Set the current position to the mouse click point and
673 // then paste in the PRIMARY selection, if any. wxGTK only.
674 int newPos
= PositionFromLocation(pt
);
675 MovePositionTo(newPos
, noSel
, true);
677 pdoc
->BeginUndoAction();
678 wxTextDataObject data
;
679 bool gotData
= FALSE
;
680 if (wxTheClipboard
->Open()) {
681 wxTheClipboard
->UsePrimarySelection(TRUE
);
682 gotData
= wxTheClipboard
->GetData(data
);
683 wxTheClipboard
->UsePrimarySelection(FALSE
);
684 wxTheClipboard
->Close();
687 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
688 int len
= strlen(buf
);
689 pdoc
->InsertString(currentPos
, buf
, len
);
690 SetEmptySelection(currentPos
+ len
);
692 pdoc
->EndUndoAction();
696 ShowCaretAtCurrentPosition();
697 EnsureCaretVisible();
700 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
705 void ScintillaWX::DoAddChar(int key
) {
710 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
711 AddCharUTF((char*)buf
.data(), strlen(buf
));
719 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
721 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
723 #if defined(__WXGTK__) || defined(__WXMAC__)
724 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
725 // TODO: Check this, it shouldn't be true any longer.
726 if (ctrl
&& key
>= 1 && key
<= 26)
731 case WXK_DOWN
: key
= SCK_DOWN
; break;
732 case WXK_UP
: key
= SCK_UP
; break;
733 case WXK_LEFT
: key
= SCK_LEFT
; break;
734 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
735 case WXK_HOME
: key
= SCK_HOME
; break;
736 case WXK_END
: key
= SCK_END
; break;
737 case WXK_PAGEUP
: // fall through
738 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
739 case WXK_PAGEDOWN
: // fall through
740 case WXK_NEXT
: key
= SCK_NEXT
; break;
741 case WXK_DELETE
: key
= SCK_DELETE
; break;
742 case WXK_INSERT
: key
= SCK_INSERT
; break;
743 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
744 case WXK_BACK
: key
= SCK_BACK
; break;
745 case WXK_TAB
: key
= SCK_TAB
; break;
746 case WXK_RETURN
: key
= SCK_RETURN
; break;
747 case WXK_ADD
: // fall through
748 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
749 case WXK_SUBTRACT
: // fall through
750 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
751 case WXK_DIVIDE
: // fall through
752 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
753 case WXK_CONTROL
: key
= 0; break;
754 case WXK_ALT
: key
= 0; break;
755 case WXK_SHIFT
: key
= 0; break;
756 case WXK_MENU
: key
= 0; break;
761 // check for a few common Mac Meta-key combos and remap them to Ctrl
768 case 'A': // Select All
775 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
784 void ScintillaWX::DoCommand(int ID
) {
789 void ScintillaWX::DoContextMenu(Point pt
) {
790 if (displayPopupMenu
)
794 void ScintillaWX::DoOnListBox() {
795 AutoCompleteCompleted();
799 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
807 //----------------------------------------------------------------------
809 #if wxUSE_DRAG_AND_DROP
810 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
811 SetDragPosition(invalidPosition
);
813 // Send an event to allow the drag details to be changed
814 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
815 evt
.SetEventObject(stc
);
816 evt
.SetDragResult(dragResult
);
819 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
820 evt
.SetDragText(data
);
821 stc
->GetEventHandler()->ProcessEvent(evt
);
823 dragResult
= evt
.GetDragResult();
824 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
825 DropAt(evt
.GetPosition(),
826 wx2stc(evt
.GetDragText()),
827 dragResult
== wxDragMove
,
828 FALSE
); // TODO: rectangular?
835 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
841 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
842 SetDragPosition(PositionFromLocation(Point(x
, y
)));
844 // Send an event to allow the drag result to be changed
845 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
846 evt
.SetEventObject(stc
);
847 evt
.SetDragResult(def
);
850 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
851 stc
->GetEventHandler()->ProcessEvent(evt
);
853 dragResult
= evt
.GetDragResult();
858 void ScintillaWX::DoDragLeave() {
859 SetDragPosition(invalidPosition
);
862 //----------------------------------------------------------------------
864 // Redraw all of text area. This paint will not be abandoned.
865 void ScintillaWX::FullPaint(wxDC
*dc
) {
866 wxCHECK_RET(dc
!= NULL
, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
867 paintState
= painting
;
868 rcPaint
= GetClientRectangle();
869 paintingAllText
= true;
870 Surface
* surfaceWindow
= Surface::Allocate();
871 surfaceWindow
->Init(dc
, wMain
.GetID());
874 ClipChildren(*dc
, rcPaint
);
875 Paint(surfaceWindow
, rcPaint
);
878 delete surfaceWindow
;
879 paintState
= notPainting
;
883 void ScintillaWX::DoScrollToLine(int line
) {
888 void ScintillaWX::DoScrollToColumn(int column
) {
889 HorizontalScrollTo(column
* vs
.spaceWidth
);
893 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
894 wxRegion
rgn(wxRectFromPRectangle(rect
));
896 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
897 rgn
.Subtract(childRect
);
899 if (ct
.inCallTipMode
) {
900 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
901 rgn
.Subtract(childRect
);
904 dc
.SetClippingRegion(rgn
);
907 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
912 void ScintillaWX::SetUseAntiAliasing(bool useAA
) {
913 vs
.extraFontFlag
= useAA
;
914 InvalidateStyleRedraw();
917 bool ScintillaWX::GetUseAntiAliasing() {
918 return vs
.extraFontFlag
;
921 //----------------------------------------------------------------------
922 //----------------------------------------------------------------------