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 //----------------------------------------------------------------------
138 static wxTextFileType
wxConvertEOLMode(int scintillaMode
)
142 switch (scintillaMode
) {
144 type
= wxTextFileType_Dos
;
148 type
= wxTextFileType_Mac
;
152 type
= wxTextFileType_Unix
;
156 type
= wxTextBuffer::typeDefault
;
163 //----------------------------------------------------------------------
164 // Constructor/Destructor
167 ScintillaWX::ScintillaWX(wxStyledTextCtrl
* win
) {
168 capturedMouse
= false;
177 ScintillaWX::~ScintillaWX() {
181 //----------------------------------------------------------------------
182 // base class virtuals
185 void ScintillaWX::Initialise() {
186 //ScintillaBase::Initialise();
187 #if wxUSE_DRAG_AND_DROP
188 dropTarget
= new wxSTCDropTarget
;
189 dropTarget
->SetScintilla(this);
190 stc
->SetDropTarget(dropTarget
);
193 vs
.extraFontFlag
= false; // UseAntiAliasing
195 vs
.extraFontFlag
= true; // UseAntiAliasing
200 void ScintillaWX::Finalise() {
201 ScintillaBase::Finalise();
207 void ScintillaWX::StartDrag() {
208 #if wxUSE_DRAG_AND_DROP
209 wxString dragText
= stc2wx(drag
.s
, drag
.len
);
211 // Send an event to allow the drag text to be changed
212 wxStyledTextEvent
evt(wxEVT_STC_START_DRAG
, stc
->GetId());
213 evt
.SetEventObject(stc
);
214 evt
.SetDragText(dragText
);
215 evt
.SetDragAllowMove(TRUE
);
216 evt
.SetPosition(wxMin(stc
->GetSelectionStart(),
217 stc
->GetSelectionEnd()));
218 stc
->GetEventHandler()->ProcessEvent(evt
);
219 dragText
= evt
.GetDragText();
221 if (dragText
.Length()) {
222 wxDropSource
source(stc
);
223 wxTextDataObject
data(dragText
);
226 source
.SetData(data
);
227 dropWentOutside
= TRUE
;
228 result
= source
.DoDragDrop(evt
.GetDragAllowMove());
229 if (result
== wxDragMove
&& dropWentOutside
)
232 SetDragPosition(invalidPosition
);
238 bool ScintillaWX::SetIdle(bool on
) {
239 if (idler
.state
!= on
) {
240 // connect or disconnect the EVT_IDLE handler
242 stc
->Connect(-1, wxEVT_IDLE
,
243 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
245 stc
->Disconnect(-1, wxEVT_IDLE
,
246 (wxObjectEventFunction
) (wxEventFunction
) (wxIdleEventFunction
) &wxStyledTextCtrl::OnIdle
);
253 void ScintillaWX::SetTicking(bool on
) {
254 wxSTCTimer
* steTimer
;
255 if (timer
.ticking
!= on
) {
258 steTimer
= new wxSTCTimer(this);
259 steTimer
->Start(timer
.tickSize
);
260 timer
.tickerID
= steTimer
;
262 steTimer
= (wxSTCTimer
*)timer
.tickerID
;
268 timer
.ticksToWait
= caret
.period
;
272 void ScintillaWX::SetMouseCapture(bool on
) {
273 if (mouseDownCaptures
) {
274 if (on
&& !capturedMouse
)
276 else if (!on
&& capturedMouse
&& stc
->HasCapture())
283 bool ScintillaWX::HaveMouseCapture() {
284 return capturedMouse
;
288 void ScintillaWX::ScrollText(int linesToMove
) {
289 int dy
= vs
.lineHeight
* (linesToMove
);
290 stc
->ScrollWindow(0, dy
);
294 void ScintillaWX::SetVerticalScrollPos() {
295 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
296 stc
->SetScrollPos(wxVERTICAL
, topLine
);
298 else { // otherwise use the one that's been given to us
299 stc
->m_vScrollBar
->SetThumbPosition(topLine
);
303 void ScintillaWX::SetHorizontalScrollPos() {
304 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
305 stc
->SetScrollPos(wxHORIZONTAL
, xOffset
);
307 else { // otherwise use the one that's been given to us
308 stc
->m_hScrollBar
->SetThumbPosition(xOffset
);
313 const int H_SCROLL_STEP
= 20;
315 bool ScintillaWX::ModifyScrollBars(int nMax
, int nPage
) {
316 bool modified
= false;
319 if (!verticalScrollBarVisible
)
322 // Check the vertical scrollbar
323 if (stc
->m_vScrollBar
== NULL
) { // Use built-in scrollbar
324 int sbMax
= stc
->GetScrollRange(wxVERTICAL
);
325 int sbThumb
= stc
->GetScrollThumb(wxVERTICAL
);
326 int sbPos
= stc
->GetScrollPos(wxVERTICAL
);
327 if (sbMax
!= vertEnd
|| sbThumb
!= nPage
) {
328 stc
->SetScrollbar(wxVERTICAL
, sbPos
, nPage
, vertEnd
+1);
332 else { // otherwise use the one that's been given to us
333 int sbMax
= stc
->m_vScrollBar
->GetRange();
334 int sbPage
= stc
->m_vScrollBar
->GetPageSize();
335 int sbPos
= stc
->m_vScrollBar
->GetThumbPosition();
336 if (sbMax
!= vertEnd
|| sbPage
!= nPage
) {
337 stc
->m_vScrollBar
->SetScrollbar(sbPos
, nPage
, vertEnd
+1, nPage
);
343 // Check the horizontal scrollbar
344 PRectangle rcText
= GetTextRectangle();
345 int horizEnd
= scrollWidth
;
348 if (!horizontalScrollBarVisible
|| (wrapState
!= eWrapNone
))
350 int pageWidth
= rcText
.Width();
352 if (stc
->m_hScrollBar
== NULL
) { // Use built-in scrollbar
353 int sbMax
= stc
->GetScrollRange(wxHORIZONTAL
);
354 int sbThumb
= stc
->GetScrollThumb(wxHORIZONTAL
);
355 int sbPos
= stc
->GetScrollPos(wxHORIZONTAL
);
356 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
357 stc
->SetScrollbar(wxHORIZONTAL
, sbPos
, pageWidth
, horizEnd
);
359 if (scrollWidth
< pageWidth
) {
360 HorizontalScrollTo(0);
364 else { // otherwise use the one that's been given to us
365 int sbMax
= stc
->m_hScrollBar
->GetRange();
366 int sbThumb
= stc
->m_hScrollBar
->GetPageSize();
367 int sbPos
= stc
->m_hScrollBar
->GetThumbPosition();
368 if ((sbMax
!= horizEnd
) || (sbThumb
!= pageWidth
) || (sbPos
!= 0)) {
369 stc
->m_hScrollBar
->SetScrollbar(sbPos
, pageWidth
, horizEnd
, pageWidth
);
371 if (scrollWidth
< pageWidth
) {
372 HorizontalScrollTo(0);
381 void ScintillaWX::NotifyChange() {
386 void ScintillaWX::NotifyParent(SCNotification scn
) {
387 stc
->NotifyParent(&scn
);
391 // This method is overloaded from ScintillaBase in order to prevent the
392 // AutoComplete window from being destroyed when it gets the focus. There is
393 // a side effect that the AutoComp will also not be destroyed when switching
394 // to another window, but I think that is okay.
395 void ScintillaWX::CancelModes() {
397 AutoCompleteCancel();
399 Editor::CancelModes();
404 void ScintillaWX::Copy() {
405 if (currentPos
!= anchor
) {
407 CopySelectionRange(&st
);
413 void ScintillaWX::Paste() {
414 pdoc
->BeginUndoAction();
417 wxTextDataObject data
;
418 bool gotData
= FALSE
;
420 if (wxTheClipboard
->Open()) {
421 wxTheClipboard
->UsePrimarySelection(FALSE
);
422 gotData
= wxTheClipboard
->GetData(data
);
423 wxTheClipboard
->Close();
426 wxString text
= wxTextBuffer::Translate(data
.GetText(),
427 wxConvertEOLMode(pdoc
->eolMode
));
428 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
429 int len
= strlen(buf
);
430 pdoc
->InsertString(currentPos
, buf
, len
);
431 SetEmptySelection(currentPos
+ len
);
434 pdoc
->EndUndoAction();
440 void ScintillaWX::CopyToClipboard(const SelectionText
& st
) {
441 if (wxTheClipboard
->Open()) {
442 wxTheClipboard
->UsePrimarySelection(FALSE
);
443 wxString text
= wxTextBuffer::Translate(stc2wx(st
.s
, st
.len
));
444 wxTheClipboard
->SetData(new wxTextDataObject(text
));
445 wxTheClipboard
->Close();
450 bool ScintillaWX::CanPaste() {
451 bool canPaste
= FALSE
;
454 if (Editor::CanPaste()) {
455 didOpen
= !wxTheClipboard
->IsOpened();
457 wxTheClipboard
->Open();
459 if (wxTheClipboard
->IsOpened()) {
460 wxTheClipboard
->UsePrimarySelection(FALSE
);
461 canPaste
= wxTheClipboard
->IsSupported(wxUSE_UNICODE
? wxDF_UNICODETEXT
: wxDF_TEXT
);
463 wxTheClipboard
->Close();
469 void ScintillaWX::CreateCallTipWindow(PRectangle
) {
470 if (! ct
.wCallTip
.Created() ) {
471 ct
.wCallTip
= new wxSTCCallTip(stc
, &ct
, this);
472 ct
.wDraw
= ct
.wCallTip
;
477 void ScintillaWX::AddToPopUp(const char *label
, int cmd
, bool enabled
) {
479 ((wxMenu
*)popup
.GetID())->AppendSeparator();
481 ((wxMenu
*)popup
.GetID())->Append(cmd
, wxGetTranslation(stc2wx(label
)));
484 ((wxMenu
*)popup
.GetID())->Enable(cmd
, enabled
);
488 // This is called by the Editor base class whenever something is selected
489 void ScintillaWX::ClaimSelection() {
491 // Until wxGTK is able to support using both the primary selection and the
492 // clipboard at the same time I think it causes more problems than it is
493 // worth to implement this method. Selecting text should not clear the
494 // clipboard. --Robin
496 // Put the selected text in the PRIMARY selection
497 if (currentPos
!= anchor
) {
499 CopySelectionRange(&st
);
500 if (wxTheClipboard
->Open()) {
501 wxTheClipboard
->UsePrimarySelection(TRUE
);
502 wxString text
= stc2wx(st
.s
, st
.len
);
503 wxTheClipboard
->SetData(new wxTextDataObject(text
));
504 wxTheClipboard
->UsePrimarySelection(FALSE
);
505 wxTheClipboard
->Close();
513 long ScintillaWX::DefWndProc(unsigned int /*iMessage*/, unsigned long /*wParam*/, long /*lParam*/) {
517 long ScintillaWX::WndProc(unsigned int iMessage
, unsigned long wParam
, long lParam
) {
519 case SCI_CALLTIPSHOW
: {
520 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
521 // because of the little tweak that needs done below for wxGTK.
522 // When updating new versions double check that this is still
523 // needed, and that any new code there is copied here too.
524 Point pt
= LocationFromPosition(wParam
);
525 char* defn
= reinterpret_cast<char *>(lParam
);
526 AutoCompleteCancel();
527 pt
.y
+= vs
.lineHeight
;
528 PRectangle rc
= ct
.CallTipStart(currentPos
, pt
,
530 vs
.styles
[STYLE_DEFAULT
].fontName
,
531 vs
.styles
[STYLE_DEFAULT
].sizeZoomed
,
534 // If the call-tip window would be out of the client
535 // space, adjust so it displays above the text.
536 PRectangle rcClient
= GetClientRectangle();
537 if (rc
.bottom
> rcClient
.bottom
) {
539 int offset
= int(vs
.lineHeight
* 1.25) + rc
.Height();
541 int offset
= vs
.lineHeight
+ rc
.Height();
546 // Now display the window.
547 CreateCallTipWindow(rc
);
548 ct
.wCallTip
.SetPositionRelative(rc
, wMain
);
554 case SCI_LOADLEXERLIBRARY
:
555 LexerManager::GetInstance()->Load((const char*)lParam
);
559 return ScintillaBase::WndProc(iMessage
, wParam
, lParam
);
566 //----------------------------------------------------------------------
569 void ScintillaWX::DoPaint(wxDC
* dc
, wxRect rect
) {
571 paintState
= painting
;
572 Surface
* surfaceWindow
= Surface::Allocate();
573 surfaceWindow
->Init(dc
, wMain
.GetID());
574 rcPaint
= PRectangleFromwxRect(rect
);
575 PRectangle rcClient
= GetClientRectangle();
576 paintingAllText
= rcPaint
.Contains(rcClient
);
579 ClipChildren(*dc
, rcPaint
);
580 Paint(surfaceWindow
, rcPaint
);
582 delete surfaceWindow
;
583 if (paintState
== paintAbandoned
) {
584 // Painting area was insufficient to cover new styling or brace
585 // highlight positions
588 paintState
= notPainting
;
593 void ScintillaWX::DoHScroll(int type
, int pos
) {
595 PRectangle rcText
= GetTextRectangle();
596 int pageWidth
= rcText
.Width() * 2 / 3;
597 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
598 xPos
-= H_SCROLL_STEP
;
599 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
600 xPos
+= H_SCROLL_STEP
;
601 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
603 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
) {
605 if (xPos
> scrollWidth
- rcText
.Width()) {
606 xPos
= scrollWidth
- rcText
.Width();
609 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
611 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
613 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
616 HorizontalScrollTo(xPos
);
619 void ScintillaWX::DoVScroll(int type
, int pos
) {
620 int topLineNew
= topLine
;
621 if (type
== wxEVT_SCROLLWIN_LINEUP
|| type
== wxEVT_SCROLL_LINEUP
)
623 else if (type
== wxEVT_SCROLLWIN_LINEDOWN
|| type
== wxEVT_SCROLL_LINEDOWN
)
625 else if (type
== wxEVT_SCROLLWIN_PAGEUP
|| type
== wxEVT_SCROLL_PAGEUP
)
626 topLineNew
-= LinesToScroll();
627 else if (type
== wxEVT_SCROLLWIN_PAGEDOWN
|| type
== wxEVT_SCROLL_PAGEDOWN
)
628 topLineNew
+= LinesToScroll();
629 else if (type
== wxEVT_SCROLLWIN_TOP
|| type
== wxEVT_SCROLL_TOP
)
631 else if (type
== wxEVT_SCROLLWIN_BOTTOM
|| type
== wxEVT_SCROLL_BOTTOM
)
632 topLineNew
= MaxScrollPos();
633 else if (type
== wxEVT_SCROLLWIN_THUMBTRACK
|| type
== wxEVT_SCROLL_THUMBTRACK
)
636 ScrollTo(topLineNew
);
639 void ScintillaWX::DoMouseWheel(int rotation
, int delta
,
640 int linesPerAction
, int ctrlDown
,
641 bool isPageScroll
) {
642 int topLineNew
= topLine
;
645 if (ctrlDown
) { // Zoom the fonts if Ctrl key down
647 KeyCommand(SCI_ZOOMIN
);
650 KeyCommand(SCI_ZOOMOUT
);
653 else { // otherwise just scroll the window
656 wheelRotation
+= rotation
;
657 lines
= wheelRotation
/ delta
;
658 wheelRotation
-= lines
* delta
;
661 lines
= lines
* LinesOnScreen(); // lines is either +1 or -1
663 lines
*= linesPerAction
;
665 ScrollTo(topLineNew
);
671 void ScintillaWX::DoSize(int WXUNUSED(width
), int WXUNUSED(height
)) {
672 // PRectangle rcClient(0,0,width,height);
673 // SetScrollBarsTo(rcClient);
678 void ScintillaWX::DoLoseFocus(){
680 SetFocusState(false);
684 void ScintillaWX::DoGainFocus(){
690 void ScintillaWX::DoSysColourChange() {
691 InvalidateStyleData();
694 void ScintillaWX::DoLeftButtonDown(Point pt
, unsigned int curTime
, bool shift
, bool ctrl
, bool alt
) {
695 ButtonDown(pt
, curTime
, shift
, ctrl
, alt
);
698 void ScintillaWX::DoLeftButtonUp(Point pt
, unsigned int curTime
, bool ctrl
) {
699 ButtonUp(pt
, curTime
, ctrl
);
702 void ScintillaWX::DoLeftButtonMove(Point pt
) {
707 void ScintillaWX::DoMiddleButtonUp(Point pt
) {
708 // Set the current position to the mouse click point and
709 // then paste in the PRIMARY selection, if any. wxGTK only.
710 int newPos
= PositionFromLocation(pt
);
711 MovePositionTo(newPos
, noSel
, true);
713 pdoc
->BeginUndoAction();
714 wxTextDataObject data
;
715 bool gotData
= FALSE
;
716 if (wxTheClipboard
->Open()) {
717 wxTheClipboard
->UsePrimarySelection(TRUE
);
718 gotData
= wxTheClipboard
->GetData(data
);
719 wxTheClipboard
->UsePrimarySelection(FALSE
);
720 wxTheClipboard
->Close();
723 wxString text
= wxTextBuffer::Translate(data
.GetText(),
724 wxConvertEOLMode(pdoc
->eolMode
));
725 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(text
);
726 int len
= strlen(buf
);
727 pdoc
->InsertString(currentPos
, buf
, len
);
728 SetEmptySelection(currentPos
+ len
);
730 pdoc
->EndUndoAction();
734 ShowCaretAtCurrentPosition();
735 EnsureCaretVisible();
738 void ScintillaWX::DoMiddleButtonUp(Point
WXUNUSED(pt
)) {
743 void ScintillaWX::DoAddChar(int key
) {
748 wxWX2MBbuf buf
= (wxWX2MBbuf
)wx2stc(wszChars
);
749 AddCharUTF((char*)buf
.data(), strlen(buf
));
757 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool meta
, bool* consumed
) {
759 int ScintillaWX::DoKeyDown(int key
, bool shift
, bool ctrl
, bool alt
, bool WXUNUSED(meta
), bool* consumed
) {
761 #if defined(__WXGTK__) || defined(__WXMAC__)
762 // Ctrl chars (A-Z) end up with the wrong keycode on wxGTK
763 // TODO: Check this, it shouldn't be true any longer.
764 if (ctrl
&& key
>= 1 && key
<= 26)
769 case WXK_DOWN
: key
= SCK_DOWN
; break;
770 case WXK_UP
: key
= SCK_UP
; break;
771 case WXK_LEFT
: key
= SCK_LEFT
; break;
772 case WXK_RIGHT
: key
= SCK_RIGHT
; break;
773 case WXK_HOME
: key
= SCK_HOME
; break;
774 case WXK_END
: key
= SCK_END
; break;
775 case WXK_PAGEUP
: // fall through
776 case WXK_PRIOR
: key
= SCK_PRIOR
; break;
777 case WXK_PAGEDOWN
: // fall through
778 case WXK_NEXT
: key
= SCK_NEXT
; break;
779 case WXK_DELETE
: key
= SCK_DELETE
; break;
780 case WXK_INSERT
: key
= SCK_INSERT
; break;
781 case WXK_ESCAPE
: key
= SCK_ESCAPE
; break;
782 case WXK_BACK
: key
= SCK_BACK
; break;
783 case WXK_TAB
: key
= SCK_TAB
; break;
784 case WXK_RETURN
: key
= SCK_RETURN
; break;
785 case WXK_ADD
: // fall through
786 case WXK_NUMPAD_ADD
: key
= SCK_ADD
; break;
787 case WXK_SUBTRACT
: // fall through
788 case WXK_NUMPAD_SUBTRACT
: key
= SCK_SUBTRACT
; break;
789 case WXK_DIVIDE
: // fall through
790 case WXK_NUMPAD_DIVIDE
: key
= SCK_DIVIDE
; break;
791 case WXK_CONTROL
: key
= 0; break;
792 case WXK_ALT
: key
= 0; break;
793 case WXK_SHIFT
: key
= 0; break;
794 case WXK_MENU
: key
= 0; break;
799 // check for a few common Mac Meta-key combos and remap them to Ctrl
806 case 'A': // Select All
813 int rv
= KeyDown(key
, shift
, ctrl
, alt
, consumed
);
822 void ScintillaWX::DoCommand(int ID
) {
827 void ScintillaWX::DoContextMenu(Point pt
) {
828 if (displayPopupMenu
)
832 void ScintillaWX::DoOnListBox() {
833 AutoCompleteCompleted();
837 void ScintillaWX::DoOnIdle(wxIdleEvent
& evt
) {
845 //----------------------------------------------------------------------
847 #if wxUSE_DRAG_AND_DROP
848 bool ScintillaWX::DoDropText(long x
, long y
, const wxString
& data
) {
849 SetDragPosition(invalidPosition
);
851 wxString text
= wxTextBuffer::Translate(data
,
852 wxConvertEOLMode(pdoc
->eolMode
));
854 // Send an event to allow the drag details to be changed
855 wxStyledTextEvent
evt(wxEVT_STC_DO_DROP
, stc
->GetId());
856 evt
.SetEventObject(stc
);
857 evt
.SetDragResult(dragResult
);
860 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
861 evt
.SetDragText(text
);
862 stc
->GetEventHandler()->ProcessEvent(evt
);
864 dragResult
= evt
.GetDragResult();
865 if (dragResult
== wxDragMove
|| dragResult
== wxDragCopy
) {
866 DropAt(evt
.GetPosition(),
867 wx2stc(evt
.GetDragText()),
868 dragResult
== wxDragMove
,
869 FALSE
); // TODO: rectangular?
876 wxDragResult
ScintillaWX::DoDragEnter(wxCoord
WXUNUSED(x
), wxCoord
WXUNUSED(y
), wxDragResult def
) {
882 wxDragResult
ScintillaWX::DoDragOver(wxCoord x
, wxCoord y
, wxDragResult def
) {
883 SetDragPosition(PositionFromLocation(Point(x
, y
)));
885 // Send an event to allow the drag result to be changed
886 wxStyledTextEvent
evt(wxEVT_STC_DRAG_OVER
, stc
->GetId());
887 evt
.SetEventObject(stc
);
888 evt
.SetDragResult(def
);
891 evt
.SetPosition(PositionFromLocation(Point(x
,y
)));
892 stc
->GetEventHandler()->ProcessEvent(evt
);
894 dragResult
= evt
.GetDragResult();
899 void ScintillaWX::DoDragLeave() {
900 SetDragPosition(invalidPosition
);
903 //----------------------------------------------------------------------
905 // Force the whole window to be repainted
906 void ScintillaWX::FullPaint() {
912 void ScintillaWX::DoScrollToLine(int line
) {
917 void ScintillaWX::DoScrollToColumn(int column
) {
918 HorizontalScrollTo(column
* vs
.spaceWidth
);
922 void ScintillaWX::ClipChildren(wxDC
& dc
, PRectangle rect
) {
923 wxRegion
rgn(wxRectFromPRectangle(rect
));
925 wxRect childRect
= ((wxWindow
*)ac
.lb
->GetID())->GetRect();
926 rgn
.Subtract(childRect
);
928 if (ct
.inCallTipMode
) {
929 wxWindow
* tip
= (wxWindow
*)ct
.wCallTip
.GetID();
930 wxRect childRect
= tip
->GetRect();
931 #if wxUSE_POPUPWIN && wxSTC_USE_POPUP
932 tip
->GetParent()->ScreenToClient(&childRect
.x
, &childRect
.y
);
934 rgn
.Subtract(childRect
);
937 dc
.SetClippingRegion(rgn
);
940 void ScintillaWX::ClipChildren(wxDC
& WXUNUSED(dc
), PRectangle
WXUNUSED(rect
)) {
945 void ScintillaWX::SetUseAntiAliasing(bool useAA
) {
946 vs
.extraFontFlag
= useAA
;
947 InvalidateStyleRedraw();
950 bool ScintillaWX::GetUseAntiAliasing() {
951 return vs
.extraFontFlag
;
954 //----------------------------------------------------------------------
955 //----------------------------------------------------------------------