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() {
61 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
62 #include <wx/popupwin.h>
63 #define wxSTCCallTipBase wxPopupWindow
64 #define param2 wxBORDER_NONE // popup's 2nd param is flags
66 #define wxSTCCallTipBase wxWindow
67 #define param2 -1 // wxWindow's 2nd param is ID
70 class wxSTCCallTip
: public wxSTCCallTipBase
{
72 wxSTCCallTip(wxWindow
* parent
, CallTip
* ct
, ScintillaWX
* swx
)
73 : wxSTCCallTipBase(parent
, param2
),
81 bool AcceptsFocus() const { return FALSE
; }
83 void OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
85 Surface
* surfaceWindow
= Surface::Allocate();
86 surfaceWindow
->Init(&dc
, m_ct
->wDraw
.GetID());
87 m_ct
->PaintCT(surfaceWindow
);
88 surfaceWindow
->Release();
92 void OnFocus(wxFocusEvent
& event
) {
93 GetParent()->SetFocus();
97 void OnLeftDown(wxMouseEvent
& event
) {
98 wxPoint pt
= event
.GetPosition();
101 m_swx
->CallTipClick();
104 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
105 virtual void DoSetSize(int x
, int y
,
106 int width
, int height
,
107 int sizeFlags
= wxSIZE_AUTO
) {
109 GetParent()->ClientToScreen(&x
, NULL
);
111 GetParent()->ClientToScreen(NULL
, &y
);
112 wxSTCCallTipBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
119 DECLARE_EVENT_TABLE()
122 BEGIN_EVENT_TABLE(wxSTCCallTip
, wxSTCCallTipBase
)
123 EVT_PAINT(wxSTCCallTip::OnPaint
)
124 EVT_SET_FOCUS(wxSTCCallTip::OnFocus
)
125 EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown
)
129 //----------------------------------------------------------------------
130 // Constructor/Destructor
133 ScintillaWX::ScintillaWX(wxStyledTextCtrl
* win
) {
134 capturedMouse
= false;
143 ScintillaWX::~ScintillaWX() {
147 //----------------------------------------------------------------------
148 // base class virtuals
151 void ScintillaWX::Initialise() {
152 //ScintillaBase::Initialise();
153 #if wxUSE_DRAG_AND_DROP
154 dropTarget
= new wxSTCDropTarget
;
155 dropTarget
->SetScintilla(this);
156 stc
->SetDropTarget(dropTarget
);
159 vs
.extraFontFlag
= false; // UseAntiAliasing
161 vs
.extraFontFlag
= true; // UseAntiAliasing
166 void ScintillaWX::Finalise() {
167 ScintillaBase::Finalise();
173 void ScintillaWX::StartDrag() {
174 #if wxUSE_DRAG_AND_DROP
175 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
177 // Send an event to allow the drag text to be changed
178 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
179 evt
.SetEventObject(stc
);
180 evt
.SetDragText(dragText
);
181 evt
.SetDragAllowMove(TRUE
);
182 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
183 stc
->GetSelectionEnd()));
184 stc
->GetEventHandler()->ProcessEvent(evt
);
185 dragText
= evt
.GetDragText();
187 if (dragText
.Length()) {
188 wxDropSource
source(stc
);
189 wxTextDataObject
data(dragText
);
192 source
.SetData(data
);
193 dropWentOutside
= TRUE
;
194 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
195 if (result
== wxDragMove
&& dropWentOutside
)
198 SetDragPosition(invalidPosition
);
204 bool ScintillaWX::SetIdle(bool on
) {
205 if (idler
.state
!= on
) {
206 // connect or disconnect the EVT_IDLE handler
208 stc
->Connect(-1, wxEVT_IDLE
,
209 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
211 stc
->Disconnect(-1, wxEVT_IDLE
,
212 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
219 void ScintillaWX::SetTicking(bool on
) {
220 wxSTCTimer
* steTimer
;
221 if (timer
.ticking
!= on
) {
224 steTimer
= new wxSTCTimer(this);
225 steTimer
->Start(timer
.tickSize
);
226 timer
.tickerID
= steTimer
;
228 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
234 timer
.ticksToWait
= caret
.period
;
238 void ScintillaWX::SetMouseCapture(bool on
) {
239 if (mouseDownCaptures
) {
240 if (on
&& !capturedMouse
)
242 else if (!on
&& capturedMouse
&& stc
->HasCapture())
249 bool ScintillaWX::HaveMouseCapture() {
250 return capturedMouse
;
254 void ScintillaWX::ScrollText(int linesToMove
) {
255 int dy
= vs
.lineHeight
* (linesToMove
);
256 stc
->ScrollWindow(0, dy
);
260 void ScintillaWX::SetVerticalScrollPos() {
261 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
262 stc
->SetScrollPos(wxVERTICAL
, topLine
);
264 else { // otherwise use the one that's been given to us
265 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
269 void ScintillaWX::SetHorizontalScrollPos() {
270 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
271 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
273 else { // otherwise use the one that's been given to us
274 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
279 const int H_SCROLL_STEP
= 20;
281 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
282 bool modified
= false;
285 if (!verticalScrollBarVisible
)
288 // Check the vertical scrollbar
289 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
290 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
291 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
292 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
293 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
294 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
298 else { // otherwise use the one that's been given to us
299 int sbMax
= stc
->m_vScrollBar
->GetRange();
300 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
301 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
302 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
303 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
309 // Check the horizontal scrollbar
310 PRectangle rcText
= GetTextRectangle();
311 int horizEnd
= scrollWidth
;
314 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
316 int pageWidth
= rcText
.Width();
318 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
319 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
320 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
321 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
322 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
323 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
325 if (scrollWidth
< pageWidth
) {
326 HorizontalScrollTo(0);
330 else { // otherwise use the one that's been given to us
331 int sbMax
= stc
->m_hScrollBar
->GetRange();
332 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
333 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
334 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
335 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
337 if (scrollWidth
< pageWidth
) {
338 HorizontalScrollTo(0);
347 void ScintillaWX::NotifyChange() {
352 void ScintillaWX::NotifyParent(SCNotification scn
) {
353 stc
->NotifyParent(&scn
);
357 // This method is overloaded from ScintillaBase in order to prevent the
358 // AutoComplete window from being destroyed when it gets the focus. There is
359 // a side effect that the AutoComp will also not be destroyed when switching
360 // to another window, but I think that is okay.
361 void ScintillaWX::CancelModes() {
363 AutoCompleteCancel();
365 Editor::CancelModes();
370 void ScintillaWX::Copy() {
371 if (currentPos
!= anchor
) {
373 CopySelectionRange(&st
);
379 void ScintillaWX::Paste() {
380 pdoc
->BeginUndoAction();
383 wxTextDataObject data
;
384 bool gotData
= FALSE
;
386 if (wxTheClipboard
->Open()) {
387 wxTheClipboard
->UsePrimarySelection(FALSE
);
388 gotData
= wxTheClipboard
->GetData(data
);
389 wxTheClipboard
->Close();
392 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
393 int len
= strlen(buf
);
394 pdoc
->InsertString(currentPos
, buf
, len
);
395 SetEmptySelection(currentPos
+ len
);
398 pdoc
->EndUndoAction();
404 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
405 if (wxTheClipboard
->Open()) {
406 wxTheClipboard
->UsePrimarySelection(FALSE
);
407 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
408 wxTheClipboard
->SetData(new wxTextDataObject(text
));
409 wxTheClipboard
->Close();
414 bool ScintillaWX::CanPaste() {
415 bool canPaste
= FALSE
;
418 if (Editor::CanPaste()) {
419 didOpen
= !wxTheClipboard
->IsOpened();
421 wxTheClipboard
->Open();
423 if (wxTheClipboard
->IsOpened()) {
424 wxTheClipboard
->UsePrimarySelection(FALSE
);
425 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
427 wxTheClipboard
->Close();
433 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
434 if (! ct
.wCallTip
.Created() ) {
435 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
436 ct
.wDraw
= ct
.wCallTip
;
441 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
443 ((wxMenu
*)popup
.GetID())->AppendSeparator();
445 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
448 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
452 // This is called by the Editor base class whenever something is selected
453 void ScintillaWX::ClaimSelection() {
455 // Until wxGTK is able to support using both the primary selection and the
456 // clipboard at the same time I think it causes more problems than it is
457 // worth to implement this method. Selecting text should not clear the
458 // clipboard. --Robin
460 // Put the selected text in the PRIMARY selection
461 if (currentPos
!= anchor
) {
463 CopySelectionRange(&st
);
464 if (wxTheClipboard
->Open()) {
465 wxTheClipboard
->UsePrimarySelection(TRUE
);
466 wxString text
= stc2wx(st
.s
, st
.len
);
467 wxTheClipboard
->SetData(new wxTextDataObject(text
));
468 wxTheClipboard
->UsePrimarySelection(FALSE
);
469 wxTheClipboard
->Close();
477 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
481 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
483 case SCI_CALLTIPSHOW
: {
484 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
485 // because of the little tweak that needs done below for wxGTK.
486 // When updating new versions double check that this is still
487 // needed, and that any new code there is copied here too.
488 Point pt
= LocationFromPosition(wParam
);
489 char* defn
= reinterpret_cast<char *>(lParam
);
490 AutoCompleteCancel();
491 pt
.y
+= vs
.lineHeight
;
492 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
494 vs
.styles
[STYLE_DEFAULT
].fontName
,
495 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
498 // If the call-tip window would be out of the client
499 // space, adjust so it displays above the text.
500 PRectangle rcClient
= GetClientRectangle();
501 if (rc
.bottom
> rcClient
.bottom
) {
503 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
505 int offset
= vs
.lineHeight
+ rc
.Height();
510 // Now display the window.
511 CreateCallTipWindow(rc
);
512 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
518 case SCI_LOADLEXERLIBRARY
:
519 LexerManager::GetInstance()->Load((const char*)lParam
);
523 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
530 //----------------------------------------------------------------------
533 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
535 paintState
= painting
;
536 Surface
* surfaceWindow
= Surface::Allocate();
537 surfaceWindow
->Init(dc
, wMain
.GetID());
538 rcPaint
= PRectangleFromwxRect(rect
);
539 PRectangle rcClient
= GetClientRectangle();
540 paintingAllText
= rcPaint
.Contains(rcClient
);
543 ClipChildren(*dc
, rcPaint
);
544 Paint(surfaceWindow
, rcPaint
);
547 delete surfaceWindow
;
548 if (paintState
== paintAbandoned
) {
549 // Painting area was insufficient to cover new styling or brace highlight positions
552 paintState
= notPainting
;
556 void ScintillaWX::DoHScroll(int type
, int pos
) {
558 PRectangle rcText
= GetTextRectangle();
559 int pageWidth
= rcText
.Width() * 2 / 3;
560 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
561 xPos
-= H_SCROLL_STEP
;
562 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
563 xPos
+= H_SCROLL_STEP
;
564 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
566 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
568 if (xPos
> scrollWidth
- rcText
.Width()) {
569 xPos
= scrollWidth
- rcText
.Width();
572 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
574 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
576 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
579 HorizontalScrollTo(xPos
);
582 void ScintillaWX::DoVScroll(int type
, int pos
) {
583 int topLineNew
= topLine
;
584 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
586 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
588 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
589 topLineNew
-= LinesToScroll();
590 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
591 topLineNew
+= LinesToScroll();
592 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
594 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
595 topLineNew
= MaxScrollPos();
596 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
599 ScrollTo(topLineNew
);
602 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
603 int linesPerAction
, int ctrlDown
,
604 bool isPageScroll
) {
605 int topLineNew
= topLine
;
608 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
610 KeyCommand(SCI_ZOOMIN
);
613 KeyCommand(SCI_ZOOMOUT
);
616 else { // otherwise just scroll the window
619 wheelRotation
+= rotation
;
620 lines
= wheelRotation
/ delta
;
621 wheelRotation
-= lines
* delta
;
624 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
626 lines
*= linesPerAction
;
628 ScrollTo(topLineNew
);
634 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
635 // PRectangle rcClient(0,0,width,height);
636 // SetScrollBarsTo(rcClient);
641 void ScintillaWX::DoLoseFocus(){
643 SetFocusState(false);
647 void ScintillaWX::DoGainFocus(){
653 void ScintillaWX::DoSysColourChange() {
654 InvalidateStyleData();
657 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
658 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
661 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
662 ButtonUp(pt
, curTime
, ctrl
);
665 void ScintillaWX::DoLeftButtonMove(Point pt
) {
670 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
671 // Set the current position to the mouse click point and
672 // then paste in the PRIMARY selection, if any. wxGTK only.
673 int newPos
= PositionFromLocation(pt
);
674 MovePositionTo(newPos
, noSel
, true);
676 pdoc
->BeginUndoAction();
677 wxTextDataObject data
;
678 bool gotData
= FALSE
;
679 if (wxTheClipboard
->Open()) {
680 wxTheClipboard
->UsePrimarySelection(TRUE
);
681 gotData
= wxTheClipboard
->GetData(data
);
682 wxTheClipboard
->UsePrimarySelection(FALSE
);
683 wxTheClipboard
->Close();
686 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
687 int len
= strlen(buf
);
688 pdoc
->InsertString(currentPos
, buf
, len
);
689 SetEmptySelection(currentPos
+ len
);
691 pdoc
->EndUndoAction();
695 ShowCaretAtCurrentPosition();
696 EnsureCaretVisible();
699 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
704 void ScintillaWX::DoAddChar(int key
) {
709 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
710 AddCharUTF((char*)buf
.data(), strlen(buf
));
718 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
720 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
722 #if defined(__WXGTK__) || defined(__WXMAC__)
723 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
724 // TODO: Check this, it shouldn't be true any longer.
725 if (ctrl
&& key
>= 1 && key
<= 26)
730 case WXK_DOWN
: key
= SCK_DOWN
; break;
731 case WXK_UP
: key
= SCK_UP
; break;
732 case WXK_LEFT
: key
= SCK_LEFT
; break;
733 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
734 case WXK_HOME
: key
= SCK_HOME
; break;
735 case WXK_END
: key
= SCK_END
; break;
736 case WXK_PAGEUP
: // fall through
737 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
738 case WXK_PAGEDOWN
: // fall through
739 case WXK_NEXT
: key
= SCK_NEXT
; break;
740 case WXK_DELETE
: key
= SCK_DELETE
; break;
741 case WXK_INSERT
: key
= SCK_INSERT
; break;
742 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
743 case WXK_BACK
: key
= SCK_BACK
; break;
744 case WXK_TAB
: key
= SCK_TAB
; break;
745 case WXK_RETURN
: key
= SCK_RETURN
; break;
746 case WXK_ADD
: // fall through
747 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
748 case WXK_SUBTRACT
: // fall through
749 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
750 case WXK_DIVIDE
: // fall through
751 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
752 case WXK_CONTROL
: key
= 0; break;
753 case WXK_ALT
: key
= 0; break;
754 case WXK_SHIFT
: key
= 0; break;
755 case WXK_MENU
: key
= 0; break;
760 // check for a few common Mac Meta-key combos and remap them to Ctrl
767 case 'A': // Select All
774 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
783 void ScintillaWX::DoCommand(int ID
) {
788 void ScintillaWX::DoContextMenu(Point pt
) {
789 if (displayPopupMenu
)
793 void ScintillaWX::DoOnListBox() {
794 AutoCompleteCompleted();
798 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
806 //----------------------------------------------------------------------
808 #if wxUSE_DRAG_AND_DROP
809 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
810 SetDragPosition(invalidPosition
);
812 // Send an event to allow the drag details to be changed
813 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
814 evt
.SetEventObject(stc
);
815 evt
.SetDragResult(dragResult
);
818 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
819 evt
.SetDragText(data
);
820 stc
->GetEventHandler()->ProcessEvent(evt
);
822 dragResult
= evt
.GetDragResult();
823 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
824 DropAt(evt
.GetPosition(),
825 wx2stc(evt
.GetDragText()),
826 dragResult
== wxDragMove
,
827 FALSE
); // TODO: rectangular?
834 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
840 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
841 SetDragPosition(PositionFromLocation(Point(x
, y
)));
843 // Send an event to allow the drag result to be changed
844 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
845 evt
.SetEventObject(stc
);
846 evt
.SetDragResult(def
);
849 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
850 stc
->GetEventHandler()->ProcessEvent(evt
);
852 dragResult
= evt
.GetDragResult();
857 void ScintillaWX::DoDragLeave() {
858 SetDragPosition(invalidPosition
);
861 //----------------------------------------------------------------------
863 // Redraw all of text area. This paint will not be abandoned.
864 void ScintillaWX::FullPaint(wxDC
*dc
) {
865 wxCHECK_RET(dc
!= NULL
, wxT("Invalid wxDC in ScintillaWX::FillPaint"));
866 paintState
= painting
;
867 rcPaint
= GetClientRectangle();
868 paintingAllText
= true;
869 Surface
* surfaceWindow
= Surface::Allocate();
870 surfaceWindow
->Init(dc
, wMain
.GetID());
873 ClipChildren(*dc
, rcPaint
);
874 Paint(surfaceWindow
, rcPaint
);
877 delete surfaceWindow
;
878 paintState
= notPainting
;
882 void ScintillaWX::DoScrollToLine(int line
) {
887 void ScintillaWX::DoScrollToColumn(int column
) {
888 HorizontalScrollTo(column
* vs
.spaceWidth
);
892 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
893 wxRegion
rgn(wxRectFromPRectangle(rect
));
895 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
896 rgn
.Subtract(childRect
);
898 if (ct
.inCallTipMode
) {
899 wxRect childRect
= ((wxWindow
*)ct
.wCallTip
.GetID())->GetRect();
900 rgn
.Subtract(childRect
);
903 dc
.SetClippingRegion(rgn
);
906 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
911 void ScintillaWX::SetUseAntiAliasing(bool useAA
) {
912 vs
.extraFontFlag
= useAA
;
913 InvalidateStyleRedraw();
916 bool ScintillaWX::GetUseAntiAliasing() {
917 return vs
.extraFontFlag
;
920 //----------------------------------------------------------------------
921 //----------------------------------------------------------------------