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
),
81 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP && defined(__WXGTK__)
82 wxRect rect
= GetRect();
83 GetParent()->ScreenToClient(&rect
.x
, &rect
.y
);
84 GetParent()->Refresh(false, &rect
);
88 bool AcceptsFocus() const { return FALSE
; }
90 void OnPaint(wxPaintEvent
& WXUNUSED(evt
)) {
91 wxBufferedPaintDC
dc(this);
92 Surface
* surfaceWindow
= Surface::Allocate();
93 surfaceWindow
->Init(&dc
, m_ct
->wDraw
.GetID());
94 m_ct
->PaintCT(surfaceWindow
);
95 surfaceWindow
->Release();
99 void OnFocus(wxFocusEvent
& event
) {
100 GetParent()->SetFocus();
104 void OnLeftDown(wxMouseEvent
& event
) {
105 wxPoint pt
= event
.GetPosition();
108 m_swx
->CallTipClick();
111 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
112 virtual void DoSetSize(int x
, int y
,
113 int width
, int height
,
114 int sizeFlags
= wxSIZE_AUTO
) {
116 GetParent()->ClientToScreen(&x
, NULL
);
118 GetParent()->ClientToScreen(NULL
, &y
);
119 wxSTCCallTipBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
126 DECLARE_EVENT_TABLE()
129 BEGIN_EVENT_TABLE(wxSTCCallTip
, wxSTCCallTipBase
)
130 EVT_PAINT(wxSTCCallTip::OnPaint
)
131 EVT_SET_FOCUS(wxSTCCallTip::OnFocus
)
132 EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown
)
136 //----------------------------------------------------------------------
137 // Constructor/Destructor
140 ScintillaWX::ScintillaWX(wxStyledTextCtrl
* win
) {
141 capturedMouse
= false;
150 ScintillaWX::~ScintillaWX() {
154 //----------------------------------------------------------------------
155 // base class virtuals
158 void ScintillaWX::Initialise() {
159 //ScintillaBase::Initialise();
160 #if wxUSE_DRAG_AND_DROP
161 dropTarget
= new wxSTCDropTarget
;
162 dropTarget
->SetScintilla(this);
163 stc
->SetDropTarget(dropTarget
);
166 vs
.extraFontFlag
= false; // UseAntiAliasing
168 vs
.extraFontFlag
= true; // UseAntiAliasing
173 void ScintillaWX::Finalise() {
174 ScintillaBase::Finalise();
180 void ScintillaWX::StartDrag() {
181 #if wxUSE_DRAG_AND_DROP
182 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
184 // Send an event to allow the drag text to be changed
185 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
186 evt
.SetEventObject(stc
);
187 evt
.SetDragText(dragText
);
188 evt
.SetDragAllowMove(TRUE
);
189 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
190 stc
->GetSelectionEnd()));
191 stc
->GetEventHandler()->ProcessEvent(evt
);
192 dragText
= evt
.GetDragText();
194 if (dragText
.Length()) {
195 wxDropSource
source(stc
);
196 wxTextDataObject
data(dragText
);
199 source
.SetData(data
);
200 dropWentOutside
= TRUE
;
201 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
202 if (result
== wxDragMove
&& dropWentOutside
)
205 SetDragPosition(invalidPosition
);
211 bool ScintillaWX::SetIdle(bool on
) {
212 if (idler
.state
!= on
) {
213 // connect or disconnect the EVT_IDLE handler
215 stc
->Connect(-1, wxEVT_IDLE
,
216 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
218 stc
->Disconnect(-1, wxEVT_IDLE
,
219 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
226 void ScintillaWX::SetTicking(bool on
) {
227 wxSTCTimer
* steTimer
;
228 if (timer
.ticking
!= on
) {
231 steTimer
= new wxSTCTimer(this);
232 steTimer
->Start(timer
.tickSize
);
233 timer
.tickerID
= steTimer
;
235 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
241 timer
.ticksToWait
= caret
.period
;
245 void ScintillaWX::SetMouseCapture(bool on
) {
246 if (mouseDownCaptures
) {
247 if (on
&& !capturedMouse
)
249 else if (!on
&& capturedMouse
&& stc
->HasCapture())
256 bool ScintillaWX::HaveMouseCapture() {
257 return capturedMouse
;
261 void ScintillaWX::ScrollText(int linesToMove
) {
262 int dy
= vs
.lineHeight
* (linesToMove
);
263 stc
->ScrollWindow(0, dy
);
267 void ScintillaWX::SetVerticalScrollPos() {
268 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
269 stc
->SetScrollPos(wxVERTICAL
, topLine
);
271 else { // otherwise use the one that's been given to us
272 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
276 void ScintillaWX::SetHorizontalScrollPos() {
277 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
278 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
280 else { // otherwise use the one that's been given to us
281 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
286 const int H_SCROLL_STEP
= 20;
288 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
289 bool modified
= false;
292 if (!verticalScrollBarVisible
)
295 // Check the vertical scrollbar
296 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
297 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
298 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
299 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
300 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
301 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
305 else { // otherwise use the one that's been given to us
306 int sbMax
= stc
->m_vScrollBar
->GetRange();
307 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
308 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
309 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
310 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
316 // Check the horizontal scrollbar
317 PRectangle rcText
= GetTextRectangle();
318 int horizEnd
= scrollWidth
;
321 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
323 int pageWidth
= rcText
.Width();
325 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
326 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
327 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
328 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
329 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
330 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
332 if (scrollWidth
< pageWidth
) {
333 HorizontalScrollTo(0);
337 else { // otherwise use the one that's been given to us
338 int sbMax
= stc
->m_hScrollBar
->GetRange();
339 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
340 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
341 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
342 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
344 if (scrollWidth
< pageWidth
) {
345 HorizontalScrollTo(0);
354 void ScintillaWX::NotifyChange() {
359 void ScintillaWX::NotifyParent(SCNotification scn
) {
360 stc
->NotifyParent(&scn
);
364 // This method is overloaded from ScintillaBase in order to prevent the
365 // AutoComplete window from being destroyed when it gets the focus. There is
366 // a side effect that the AutoComp will also not be destroyed when switching
367 // to another window, but I think that is okay.
368 void ScintillaWX::CancelModes() {
370 AutoCompleteCancel();
372 Editor::CancelModes();
377 void ScintillaWX::Copy() {
378 if (currentPos
!= anchor
) {
380 CopySelectionRange(&st
);
386 void ScintillaWX::Paste() {
387 pdoc
->BeginUndoAction();
390 wxTextDataObject data
;
391 bool gotData
= FALSE
;
393 if (wxTheClipboard
->Open()) {
394 wxTheClipboard
->UsePrimarySelection(FALSE
);
395 gotData
= wxTheClipboard
->GetData(data
);
396 wxTheClipboard
->Close();
399 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
400 int len
= strlen(buf
);
401 pdoc
->InsertString(currentPos
, buf
, len
);
402 SetEmptySelection(currentPos
+ len
);
405 pdoc
->EndUndoAction();
411 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
412 if (wxTheClipboard
->Open()) {
413 wxTheClipboard
->UsePrimarySelection(FALSE
);
414 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
415 wxTheClipboard
->SetData(new wxTextDataObject(text
));
416 wxTheClipboard
->Close();
421 bool ScintillaWX::CanPaste() {
422 bool canPaste
= FALSE
;
425 if (Editor::CanPaste()) {
426 didOpen
= !wxTheClipboard
->IsOpened();
428 wxTheClipboard
->Open();
430 if (wxTheClipboard
->IsOpened()) {
431 wxTheClipboard
->UsePrimarySelection(FALSE
);
432 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
434 wxTheClipboard
->Close();
440 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
441 if (! ct
.wCallTip
.Created() ) {
442 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
443 ct
.wDraw
= ct
.wCallTip
;
448 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
450 ((wxMenu
*)popup
.GetID())->AppendSeparator();
452 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
455 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
459 // This is called by the Editor base class whenever something is selected
460 void ScintillaWX::ClaimSelection() {
462 // Until wxGTK is able to support using both the primary selection and the
463 // clipboard at the same time I think it causes more problems than it is
464 // worth to implement this method. Selecting text should not clear the
465 // clipboard. --Robin
467 // Put the selected text in the PRIMARY selection
468 if (currentPos
!= anchor
) {
470 CopySelectionRange(&st
);
471 if (wxTheClipboard
->Open()) {
472 wxTheClipboard
->UsePrimarySelection(TRUE
);
473 wxString text
= stc2wx(st
.s
, st
.len
);
474 wxTheClipboard
->SetData(new wxTextDataObject(text
));
475 wxTheClipboard
->UsePrimarySelection(FALSE
);
476 wxTheClipboard
->Close();
484 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
488 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
490 case SCI_CALLTIPSHOW
: {
491 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
492 // because of the little tweak that needs done below for wxGTK.
493 // When updating new versions double check that this is still
494 // needed, and that any new code there is copied here too.
495 Point pt
= LocationFromPosition(wParam
);
496 char* defn
= reinterpret_cast<char *>(lParam
);
497 AutoCompleteCancel();
498 pt
.y
+= vs
.lineHeight
;
499 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
501 vs
.styles
[STYLE_DEFAULT
].fontName
,
502 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
505 // If the call-tip window would be out of the client
506 // space, adjust so it displays above the text.
507 PRectangle rcClient
= GetClientRectangle();
508 if (rc
.bottom
> rcClient
.bottom
) {
510 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
512 int offset
= vs
.lineHeight
+ rc
.Height();
517 // Now display the window.
518 CreateCallTipWindow(rc
);
519 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
525 case SCI_LOADLEXERLIBRARY
:
526 LexerManager::GetInstance()->Load((const char*)lParam
);
530 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
537 //----------------------------------------------------------------------
540 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
542 paintState
= painting
;
543 Surface
* surfaceWindow
= Surface::Allocate();
544 surfaceWindow
->Init(dc
, wMain
.GetID());
545 rcPaint
= PRectangleFromwxRect(rect
);
546 PRectangle rcClient
= GetClientRectangle();
547 paintingAllText
= rcPaint
.Contains(rcClient
);
550 ClipChildren(*dc
, rcPaint
);
551 Paint(surfaceWindow
, rcPaint
);
553 delete surfaceWindow
;
554 if (paintState
== paintAbandoned
) {
555 // Painting area was insufficient to cover new styling or brace
556 // highlight positions
559 paintState
= notPainting
;
564 void ScintillaWX::DoHScroll(int type
, int pos
) {
566 PRectangle rcText
= GetTextRectangle();
567 int pageWidth
= rcText
.Width() * 2 / 3;
568 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
569 xPos
-= H_SCROLL_STEP
;
570 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
571 xPos
+= H_SCROLL_STEP
;
572 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
574 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
576 if (xPos
> scrollWidth
- rcText
.Width()) {
577 xPos
= scrollWidth
- rcText
.Width();
580 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
582 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
584 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
587 HorizontalScrollTo(xPos
);
590 void ScintillaWX::DoVScroll(int type
, int pos
) {
591 int topLineNew
= topLine
;
592 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
594 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
596 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
597 topLineNew
-= LinesToScroll();
598 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
599 topLineNew
+= LinesToScroll();
600 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
602 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
603 topLineNew
= MaxScrollPos();
604 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
607 ScrollTo(topLineNew
);
610 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
611 int linesPerAction
, int ctrlDown
,
612 bool isPageScroll
) {
613 int topLineNew
= topLine
;
616 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
618 KeyCommand(SCI_ZOOMIN
);
621 KeyCommand(SCI_ZOOMOUT
);
624 else { // otherwise just scroll the window
627 wheelRotation
+= rotation
;
628 lines
= wheelRotation
/ delta
;
629 wheelRotation
-= lines
* delta
;
632 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
634 lines
*= linesPerAction
;
636 ScrollTo(topLineNew
);
642 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
643 // PRectangle rcClient(0,0,width,height);
644 // SetScrollBarsTo(rcClient);
649 void ScintillaWX::DoLoseFocus(){
651 SetFocusState(false);
655 void ScintillaWX::DoGainFocus(){
661 void ScintillaWX::DoSysColourChange() {
662 InvalidateStyleData();
665 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
666 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
669 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
670 ButtonUp(pt
, curTime
, ctrl
);
673 void ScintillaWX::DoLeftButtonMove(Point pt
) {
678 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
679 // Set the current position to the mouse click point and
680 // then paste in the PRIMARY selection, if any. wxGTK only.
681 int newPos
= PositionFromLocation(pt
);
682 MovePositionTo(newPos
, noSel
, true);
684 pdoc
->BeginUndoAction();
685 wxTextDataObject data
;
686 bool gotData
= FALSE
;
687 if (wxTheClipboard
->Open()) {
688 wxTheClipboard
->UsePrimarySelection(TRUE
);
689 gotData
= wxTheClipboard
->GetData(data
);
690 wxTheClipboard
->UsePrimarySelection(FALSE
);
691 wxTheClipboard
->Close();
694 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(data
.GetText());
695 int len
= strlen(buf
);
696 pdoc
->InsertString(currentPos
, buf
, len
);
697 SetEmptySelection(currentPos
+ len
);
699 pdoc
->EndUndoAction();
703 ShowCaretAtCurrentPosition();
704 EnsureCaretVisible();
707 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
712 void ScintillaWX::DoAddChar(int key
) {
717 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
718 AddCharUTF((char*)buf
.data(), strlen(buf
));
726 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
728 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
730 #if defined(__WXGTK__) || defined(__WXMAC__)
731 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
732 // TODO: Check this, it shouldn't be true any longer.
733 if (ctrl
&& key
>= 1 && key
<= 26)
738 case WXK_DOWN
: key
= SCK_DOWN
; break;
739 case WXK_UP
: key
= SCK_UP
; break;
740 case WXK_LEFT
: key
= SCK_LEFT
; break;
741 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
742 case WXK_HOME
: key
= SCK_HOME
; break;
743 case WXK_END
: key
= SCK_END
; break;
744 case WXK_PAGEUP
: // fall through
745 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
746 case WXK_PAGEDOWN
: // fall through
747 case WXK_NEXT
: key
= SCK_NEXT
; break;
748 case WXK_DELETE
: key
= SCK_DELETE
; break;
749 case WXK_INSERT
: key
= SCK_INSERT
; break;
750 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
751 case WXK_BACK
: key
= SCK_BACK
; break;
752 case WXK_TAB
: key
= SCK_TAB
; break;
753 case WXK_RETURN
: key
= SCK_RETURN
; break;
754 case WXK_ADD
: // fall through
755 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
756 case WXK_SUBTRACT
: // fall through
757 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
758 case WXK_DIVIDE
: // fall through
759 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
760 case WXK_CONTROL
: key
= 0; break;
761 case WXK_ALT
: key
= 0; break;
762 case WXK_SHIFT
: key
= 0; break;
763 case WXK_MENU
: key
= 0; break;
768 // check for a few common Mac Meta-key combos and remap them to Ctrl
775 case 'A': // Select All
782 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
791 void ScintillaWX::DoCommand(int ID
) {
796 void ScintillaWX::DoContextMenu(Point pt
) {
797 if (displayPopupMenu
)
801 void ScintillaWX::DoOnListBox() {
802 AutoCompleteCompleted();
806 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
814 //----------------------------------------------------------------------
816 #if wxUSE_DRAG_AND_DROP
817 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
818 SetDragPosition(invalidPosition
);
820 // Send an event to allow the drag details to be changed
821 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
822 evt
.SetEventObject(stc
);
823 evt
.SetDragResult(dragResult
);
826 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
827 evt
.SetDragText(data
);
828 stc
->GetEventHandler()->ProcessEvent(evt
);
830 dragResult
= evt
.GetDragResult();
831 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
832 DropAt(evt
.GetPosition(),
833 wx2stc(evt
.GetDragText()),
834 dragResult
== wxDragMove
,
835 FALSE
); // TODO: rectangular?
842 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
848 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
849 SetDragPosition(PositionFromLocation(Point(x
, y
)));
851 // Send an event to allow the drag result to be changed
852 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
853 evt
.SetEventObject(stc
);
854 evt
.SetDragResult(def
);
857 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
858 stc
->GetEventHandler()->ProcessEvent(evt
);
860 dragResult
= evt
.GetDragResult();
865 void ScintillaWX::DoDragLeave() {
866 SetDragPosition(invalidPosition
);
869 //----------------------------------------------------------------------
871 // Force the whole window to be repainted
872 void ScintillaWX::FullPaint() {
878 void ScintillaWX::DoScrollToLine(int line
) {
883 void ScintillaWX::DoScrollToColumn(int column
) {
884 HorizontalScrollTo(column
* vs
.spaceWidth
);
888 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
889 wxRegion
rgn(wxRectFromPRectangle(rect
));
891 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
892 rgn
.Subtract(childRect
);
894 if (ct
.inCallTipMode
) {
895 wxWindow
* tip
= (wxWindow
*)ct
.wCallTip
.GetID();
896 wxRect childRect
= tip
->GetRect();
897 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
898 tip
->GetParent()->ScreenToClient(&childRect
.x
, &childRect
.y
);
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 //----------------------------------------------------------------------