1 ////////////////////////////////////////////////////////////////////////////
2 // Name: ScintillaWX.cxx
3 // Purpose: A wxWidgets 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 #include <wx/dcbuffer.h>
72 class wxSTCCallTip
: public wxSTCCallTipBase
{
74 wxSTCCallTip(wxWindow
* parent
, CallTip
* ct
, ScintillaWX
* swx
)
75 : wxSTCCallTipBase(parent
, param2
),
76 m_ct(ct
), m_swx(swx
), m_cx(-1), m_cy(-1)
81 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP && defined(__WXGTK__)
82 wxRect rect
= GetRect();
85 GetParent()->Refresh(false, &rect
);
89 bool AcceptsFocus() const { return FALSE
; }
91 void OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
92 wxBufferedPaintDC
dc(this);
93 Surface
* surfaceWindow
= Surface::Allocate();
94 surfaceWindow
->Init(&dc
, m_ct
->wDraw
.GetID());
95 m_ct
->PaintCT(surfaceWindow
);
96 surfaceWindow
->Release();
100 void OnFocus(wxFocusEvent
& event
) {
101 GetParent()->SetFocus();
105 void OnLeftDown(wxMouseEvent
& event
) {
106 wxPoint pt
= event
.GetPosition();
109 m_swx
->CallTipClick();
112 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
113 virtual void DoSetSize(int x
, int y
,
114 int width
, int height
,
115 int sizeFlags
= wxSIZE_AUTO
) {
118 GetParent()->ClientToScreen(&x
, NULL
);
122 GetParent()->ClientToScreen(NULL
, &y
);
124 wxSTCCallTipBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
128 wxPoint
GetMyPosition() {
129 return wxPoint(m_cx
, m_cy
);
136 DECLARE_EVENT_TABLE()
139 BEGIN_EVENT_TABLE(wxSTCCallTip
, wxSTCCallTipBase
)
140 EVT_PAINT(wxSTCCallTip::OnPaint
)
141 EVT_SET_FOCUS(wxSTCCallTip::OnFocus
)
142 EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown
)
146 //----------------------------------------------------------------------
148 static wxTextFileType
wxConvertEOLMode(int scintillaMode
)
152 switch (scintillaMode
) {
154 type
= wxTextFileType_Dos
;
158 type
= wxTextFileType_Mac
;
162 type
= wxTextFileType_Unix
;
166 type
= wxTextBuffer::typeDefault
;
173 //----------------------------------------------------------------------
174 // Constructor/Destructor
177 ScintillaWX::ScintillaWX(wxStyledTextCtrl
* win
) {
178 capturedMouse
= false;
187 ScintillaWX::~ScintillaWX() {
191 //----------------------------------------------------------------------
192 // base class virtuals
195 void ScintillaWX::Initialise() {
196 //ScintillaBase::Initialise();
197 #if wxUSE_DRAG_AND_DROP
198 dropTarget
= new wxSTCDropTarget
;
199 dropTarget
->SetScintilla(this);
200 stc
->SetDropTarget(dropTarget
);
203 vs
.extraFontFlag
= false; // UseAntiAliasing
205 vs
.extraFontFlag
= true; // UseAntiAliasing
210 void ScintillaWX::Finalise() {
211 ScintillaBase::Finalise();
217 void ScintillaWX::StartDrag() {
218 #if wxUSE_DRAG_AND_DROP
219 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
221 // Send an event to allow the drag text to be changed
222 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
223 evt
.SetEventObject(stc
);
224 evt
.SetDragText(dragText
);
225 evt
.SetDragAllowMove(TRUE
);
226 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
227 stc
->GetSelectionEnd()));
228 stc
->GetEventHandler()->ProcessEvent(evt
);
229 dragText
= evt
.GetDragText();
231 if (dragText
.Length()) {
232 wxDropSource
source(stc
);
233 wxTextDataObject
data(dragText
);
236 source
.SetData(data
);
237 dropWentOutside
= TRUE
;
238 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
239 if (result
== wxDragMove
&& dropWentOutside
)
242 SetDragPosition(invalidPosition
);
248 bool ScintillaWX::SetIdle(bool on
) {
249 if (idler
.state
!= on
) {
250 // connect or disconnect the EVT_IDLE handler
252 stc
->Connect(-1, wxEVT_IDLE
,
253 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
255 stc
->Disconnect(-1, wxEVT_IDLE
,
256 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
263 void ScintillaWX::SetTicking(bool on
) {
264 wxSTCTimer
* steTimer
;
265 if (timer
.ticking
!= on
) {
268 steTimer
= new wxSTCTimer(this);
269 steTimer
->Start(timer
.tickSize
);
270 timer
.tickerID
= steTimer
;
272 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
278 timer
.ticksToWait
= caret
.period
;
282 void ScintillaWX::SetMouseCapture(bool on
) {
283 if (mouseDownCaptures
) {
284 if (on
&& !capturedMouse
)
286 else if (!on
&& capturedMouse
&& stc
->HasCapture())
293 bool ScintillaWX::HaveMouseCapture() {
294 return capturedMouse
;
298 void ScintillaWX::ScrollText(int linesToMove
) {
299 int dy
= vs
.lineHeight
* (linesToMove
);
300 stc
->ScrollWindow(0, dy
);
304 void ScintillaWX::SetVerticalScrollPos() {
305 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
306 stc
->SetScrollPos(wxVERTICAL
, topLine
);
308 else { // otherwise use the one that's been given to us
309 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
313 void ScintillaWX::SetHorizontalScrollPos() {
314 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
315 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
317 else { // otherwise use the one that's been given to us
318 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
323 const int H_SCROLL_STEP
= 20;
325 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
326 bool modified
= false;
329 if (!verticalScrollBarVisible
)
332 // Check the vertical scrollbar
333 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
334 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
335 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
336 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
337 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
338 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
342 else { // otherwise use the one that's been given to us
343 int sbMax
= stc
->m_vScrollBar
->GetRange();
344 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
345 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
346 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
347 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
353 // Check the horizontal scrollbar
354 PRectangle rcText
= GetTextRectangle();
355 int horizEnd
= scrollWidth
;
358 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
360 int pageWidth
= rcText
.Width();
362 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
363 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
364 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
365 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
366 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
367 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
369 if (scrollWidth
< pageWidth
) {
370 HorizontalScrollTo(0);
374 else { // otherwise use the one that's been given to us
375 int sbMax
= stc
->m_hScrollBar
->GetRange();
376 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
377 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
378 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
379 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
381 if (scrollWidth
< pageWidth
) {
382 HorizontalScrollTo(0);
391 void ScintillaWX::NotifyChange() {
396 void ScintillaWX::NotifyParent(SCNotification scn
) {
397 stc
->NotifyParent(&scn
);
401 // This method is overloaded from ScintillaBase in order to prevent the
402 // AutoComplete window from being destroyed when it gets the focus. There is
403 // a side effect that the AutoComp will also not be destroyed when switching
404 // to another window, but I think that is okay.
405 void ScintillaWX::CancelModes() {
407 AutoCompleteCancel();
409 Editor::CancelModes();
414 void ScintillaWX::Copy() {
415 if (currentPos
!= anchor
) {
417 CopySelectionRange(&st
);
423 void ScintillaWX::Paste() {
424 pdoc
->BeginUndoAction();
427 wxTextDataObject data
;
428 bool gotData
= FALSE
;
430 if (wxTheClipboard
->Open()) {
431 wxTheClipboard
->UsePrimarySelection(FALSE
);
432 gotData
= wxTheClipboard
->GetData(data
);
433 wxTheClipboard
->Close();
436 wxString text
= wxTextBuffer::Translate(data
.GetText(),
437 wxConvertEOLMode(pdoc
->eolMode
));
438 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
439 int len
= strlen(buf
);
440 pdoc
->InsertString(currentPos
, buf
, len
);
441 SetEmptySelection(currentPos
+ len
);
444 pdoc
->EndUndoAction();
450 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
451 if (wxTheClipboard
->Open()) {
452 wxTheClipboard
->UsePrimarySelection(FALSE
);
453 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
454 wxTheClipboard
->SetData(new wxTextDataObject(text
));
455 wxTheClipboard
->Close();
460 bool ScintillaWX::CanPaste() {
461 bool canPaste
= FALSE
;
464 if (Editor::CanPaste()) {
465 didOpen
= !wxTheClipboard
->IsOpened();
467 wxTheClipboard
->Open();
469 if (wxTheClipboard
->IsOpened()) {
470 wxTheClipboard
->UsePrimarySelection(FALSE
);
471 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
473 wxTheClipboard
->Close();
479 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
480 if (! ct
.wCallTip
.Created() ) {
481 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
482 ct
.wDraw
= ct
.wCallTip
;
487 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
489 ((wxMenu
*)popup
.GetID())->AppendSeparator();
491 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
494 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
498 // This is called by the Editor base class whenever something is selected
499 void ScintillaWX::ClaimSelection() {
501 // Until wxGTK is able to support using both the primary selection and the
502 // clipboard at the same time I think it causes more problems than it is
503 // worth to implement this method. Selecting text should not clear the
504 // clipboard. --Robin
506 // Put the selected text in the PRIMARY selection
507 if (currentPos
!= anchor
) {
509 CopySelectionRange(&st
);
510 if (wxTheClipboard
->Open()) {
511 wxTheClipboard
->UsePrimarySelection(TRUE
);
512 wxString text
= stc2wx(st
.s
, st
.len
);
513 wxTheClipboard
->SetData(new wxTextDataObject(text
));
514 wxTheClipboard
->UsePrimarySelection(FALSE
);
515 wxTheClipboard
->Close();
523 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
527 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
529 case SCI_CALLTIPSHOW
: {
530 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
531 // because of the little tweak that needs done below for wxGTK.
532 // When updating new versions double check that this is still
533 // needed, and that any new code there is copied here too.
534 Point pt
= LocationFromPosition(wParam
);
535 char* defn
= reinterpret_cast<char *>(lParam
);
536 AutoCompleteCancel();
537 pt
.y
+= vs
.lineHeight
;
538 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
540 vs
.styles
[STYLE_DEFAULT
].fontName
,
541 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
544 // If the call-tip window would be out of the client
545 // space, adjust so it displays above the text.
546 PRectangle rcClient
= GetClientRectangle();
547 if (rc
.bottom
> rcClient
.bottom
) {
549 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
551 int offset
= vs
.lineHeight
+ rc
.Height();
556 // Now display the window.
557 CreateCallTipWindow(rc
);
558 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
564 case SCI_LOADLEXERLIBRARY
:
565 LexerManager::GetInstance()->Load((const char*)lParam
);
569 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
576 //----------------------------------------------------------------------
579 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
581 paintState
= painting
;
582 Surface
* surfaceWindow
= Surface::Allocate();
583 surfaceWindow
->Init(dc
, wMain
.GetID());
584 rcPaint
= PRectangleFromwxRect(rect
);
585 PRectangle rcClient
= GetClientRectangle();
586 paintingAllText
= rcPaint
.Contains(rcClient
);
589 ClipChildren(*dc
, rcPaint
);
590 Paint(surfaceWindow
, rcPaint
);
592 delete surfaceWindow
;
593 if (paintState
== paintAbandoned
) {
594 // Painting area was insufficient to cover new styling or brace
595 // highlight positions
598 paintState
= notPainting
;
603 void ScintillaWX::DoHScroll(int type
, int pos
) {
605 PRectangle rcText
= GetTextRectangle();
606 int pageWidth
= rcText
.Width() * 2 / 3;
607 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
608 xPos
-= H_SCROLL_STEP
;
609 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
610 xPos
+= H_SCROLL_STEP
;
611 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
613 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
615 if (xPos
> scrollWidth
- rcText
.Width()) {
616 xPos
= scrollWidth
- rcText
.Width();
619 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
621 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
623 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
626 HorizontalScrollTo(xPos
);
629 void ScintillaWX::DoVScroll(int type
, int pos
) {
630 int topLineNew
= topLine
;
631 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
633 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
635 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
636 topLineNew
-= LinesToScroll();
637 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
638 topLineNew
+= LinesToScroll();
639 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
641 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
642 topLineNew
= MaxScrollPos();
643 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
646 ScrollTo(topLineNew
);
649 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
650 int linesPerAction
, int ctrlDown
,
651 bool isPageScroll
) {
652 int topLineNew
= topLine
;
655 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
657 KeyCommand(SCI_ZOOMIN
);
660 KeyCommand(SCI_ZOOMOUT
);
663 else { // otherwise just scroll the window
666 wheelRotation
+= rotation
;
667 lines
= wheelRotation
/ delta
;
668 wheelRotation
-= lines
* delta
;
671 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
673 lines
*= linesPerAction
;
675 ScrollTo(topLineNew
);
681 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
682 // PRectangle rcClient(0,0,width,height);
683 // SetScrollBarsTo(rcClient);
688 void ScintillaWX::DoLoseFocus(){
690 SetFocusState(false);
694 void ScintillaWX::DoGainFocus(){
700 void ScintillaWX::DoSysColourChange() {
701 InvalidateStyleData();
704 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
705 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
708 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
709 ButtonUp(pt
, curTime
, ctrl
);
712 void ScintillaWX::DoLeftButtonMove(Point pt
) {
717 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
718 // Set the current position to the mouse click point and
719 // then paste in the PRIMARY selection, if any. wxGTK only.
720 int newPos
= PositionFromLocation(pt
);
721 MovePositionTo(newPos
, noSel
, true);
723 pdoc
->BeginUndoAction();
724 wxTextDataObject data
;
725 bool gotData
= FALSE
;
726 if (wxTheClipboard
->Open()) {
727 wxTheClipboard
->UsePrimarySelection(TRUE
);
728 gotData
= wxTheClipboard
->GetData(data
);
729 wxTheClipboard
->UsePrimarySelection(FALSE
);
730 wxTheClipboard
->Close();
733 wxString text
= wxTextBuffer::Translate(data
.GetText(),
734 wxConvertEOLMode(pdoc
->eolMode
));
735 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
736 int len
= strlen(buf
);
737 pdoc
->InsertString(currentPos
, buf
, len
);
738 SetEmptySelection(currentPos
+ len
);
740 pdoc
->EndUndoAction();
744 ShowCaretAtCurrentPosition();
745 EnsureCaretVisible();
748 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
753 void ScintillaWX::DoAddChar(int key
) {
758 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
759 AddCharUTF((char*)buf
.data(), strlen(buf
));
767 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
769 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
771 #if defined(__WXGTK__) || defined(__WXMAC__)
772 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
773 // TODO: Check this, it shouldn't be true any longer.
774 if (ctrl
&& key
>= 1 && key
<= 26)
779 case WXK_DOWN
: key
= SCK_DOWN
; break;
780 case WXK_UP
: key
= SCK_UP
; break;
781 case WXK_LEFT
: key
= SCK_LEFT
; break;
782 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
783 case WXK_HOME
: key
= SCK_HOME
; break;
784 case WXK_END
: key
= SCK_END
; break;
785 case WXK_PAGEUP
: // fall through
786 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
787 case WXK_PAGEDOWN
: // fall through
788 case WXK_NEXT
: key
= SCK_NEXT
; break;
789 case WXK_DELETE
: key
= SCK_DELETE
; break;
790 case WXK_INSERT
: key
= SCK_INSERT
; break;
791 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
792 case WXK_BACK
: key
= SCK_BACK
; break;
793 case WXK_TAB
: key
= SCK_TAB
; break;
794 case WXK_RETURN
: key
= SCK_RETURN
; break;
795 case WXK_ADD
: // fall through
796 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
797 case WXK_SUBTRACT
: // fall through
798 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
799 case WXK_DIVIDE
: // fall through
800 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
801 case WXK_CONTROL
: key
= 0; break;
802 case WXK_ALT
: key
= 0; break;
803 case WXK_SHIFT
: key
= 0; break;
804 case WXK_MENU
: key
= 0; break;
809 // check for a few common Mac Meta-key combos and remap them to Ctrl
816 case 'A': // Select All
823 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
832 void ScintillaWX::DoCommand(int ID
) {
837 void ScintillaWX::DoContextMenu(Point pt
) {
838 if (displayPopupMenu
)
842 void ScintillaWX::DoOnListBox() {
843 AutoCompleteCompleted();
847 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
855 //----------------------------------------------------------------------
857 #if wxUSE_DRAG_AND_DROP
858 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
859 SetDragPosition(invalidPosition
);
861 wxString text
= wxTextBuffer::Translate(data
,
862 wxConvertEOLMode(pdoc
->eolMode
));
864 // Send an event to allow the drag details to be changed
865 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
866 evt
.SetEventObject(stc
);
867 evt
.SetDragResult(dragResult
);
870 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
871 evt
.SetDragText(text
);
872 stc
->GetEventHandler()->ProcessEvent(evt
);
874 dragResult
= evt
.GetDragResult();
875 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
876 DropAt(evt
.GetPosition(),
877 wx2stc(evt
.GetDragText()),
878 dragResult
== wxDragMove
,
879 FALSE
); // TODO: rectangular?
886 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
892 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
893 SetDragPosition(PositionFromLocation(Point(x
, y
)));
895 // Send an event to allow the drag result to be changed
896 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
897 evt
.SetEventObject(stc
);
898 evt
.SetDragResult(def
);
901 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
902 stc
->GetEventHandler()->ProcessEvent(evt
);
904 dragResult
= evt
.GetDragResult();
909 void ScintillaWX::DoDragLeave() {
910 SetDragPosition(invalidPosition
);
913 //----------------------------------------------------------------------
915 // Force the whole window to be repainted
916 void ScintillaWX::FullPaint() {
922 void ScintillaWX::DoScrollToLine(int line
) {
927 void ScintillaWX::DoScrollToColumn(int column
) {
928 HorizontalScrollTo(column
* vs
.spaceWidth
);
932 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
933 wxRegion
rgn(wxRectFromPRectangle(rect
));
935 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
936 rgn
.Subtract(childRect
);
938 if (ct
.inCallTipMode
) {
939 wxSTCCallTip
* tip
= (wxSTCCallTip
*)ct
.wCallTip
.GetID();
940 wxRect childRect
= tip
->GetRect();
941 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
942 childRect
.SetPosition(tip
->GetMyPosition());
944 rgn
.Subtract(childRect
);
947 dc
.SetClippingRegion(rgn
);
950 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
955 void ScintillaWX::SetUseAntiAliasing(bool useAA
) {
956 vs
.extraFontFlag
= useAA
;
957 InvalidateStyleRedraw();
960 bool ScintillaWX::GetUseAntiAliasing() {
961 return vs
.extraFontFlag
;
964 //----------------------------------------------------------------------
965 //----------------------------------------------------------------------