]> git.saurik.com Git - wxWidgets.git/blame - src/stc/ScintillaWX.cpp
Fix Doxygen warnings due to documenting overloaded functions together.
[wxWidgets.git] / src / stc / ScintillaWX.cpp
CommitLineData
9ce192d4 1////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/stc/ScintillaWX.cpp
be5a51fb 3// Purpose: A wxWidgets implementation of Scintilla. A class derived
9ce192d4
RD
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.
8//
9// Author: Robin Dunn
10//
11// Created: 13-Jan-2000
9ce192d4 12// Copyright: (c) 2000 by Total Control Software
526954c5 13// Licence: wxWindows licence
9ce192d4
RD
14/////////////////////////////////////////////////////////////////////////////
15
54429bb3
RD
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
29825f5f 23#if wxUSE_STC
54429bb3
RD
24
25#ifndef WX_PRECOMP
29825f5f
PC
26 #include "wx/scrolbar.h"
27 #include "wx/menu.h"
6420b4c5 28 #include "wx/timer.h"
54429bb3
RD
29#endif // WX_PRECOMP
30
d6655166
WS
31#include "wx/textbuf.h"
32#include "wx/dataobj.h"
33#include "wx/clipbrd.h"
34#include "wx/dnd.h"
f9ee2e27 35
f32204b0
DS
36#if !wxUSE_STD_CONTAINERS && !wxUSE_STD_IOSTREAM && !wxUSE_STD_STRING
37 #include "wx/beforestd.h"
38 #include <string>
39 #include "wx/afterstd.h"
40#endif
41
9ce192d4 42#include "ScintillaWX.h"
e14d10b0 43#include "ExternalLexer.h"
9ce192d4 44#include "wx/stc/stc.h"
ea88e9bc 45#include "wx/stc/private.h"
1a2fb4cd 46#include "PlatWX.h"
9ce192d4 47
249b31b5
WS
48#ifdef __WXMSW__
49 // GetHwndOf()
d6655166 50 #include "wx/msw/private.h"
249b31b5
WS
51#endif
52
9ce192d4
RD
53//----------------------------------------------------------------------
54// Helper classes
55
56class wxSTCTimer : public wxTimer {
57public:
58 wxSTCTimer(ScintillaWX* swx) {
291b0f5b 59 m_swx = swx;
9ce192d4
RD
60 }
61
62 void Notify() {
291b0f5b 63 m_swx->DoTick();
9ce192d4
RD
64 }
65
66private:
291b0f5b 67 ScintillaWX* m_swx;
9ce192d4
RD
68};
69
70
1bc32508 71#if wxUSE_DRAG_AND_DROP
9ce192d4 72bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
291b0f5b 73 return m_swx->DoDropText(x, y, data);
9ce192d4
RD
74}
75
76wxDragResult wxSTCDropTarget::OnEnter(wxCoord x, wxCoord y, wxDragResult def) {
291b0f5b 77 return m_swx->DoDragEnter(x, y, def);
9ce192d4
RD
78}
79
80wxDragResult wxSTCDropTarget::OnDragOver(wxCoord x, wxCoord y, wxDragResult def) {
291b0f5b 81 return m_swx->DoDragOver(x, y, def);
9ce192d4
RD
82}
83
84void wxSTCDropTarget::OnLeave() {
291b0f5b 85 m_swx->DoDragLeave();
9ce192d4 86}
f402150f 87#endif // wxUSE_DRAG_AND_DROP
9ce192d4
RD
88
89
c0a4c58a 90#if wxUSE_POPUPWIN
819850ff 91#include "wx/popupwin.h"
769a9cb2 92#define wxSTCCallTipBase wxPopupWindow
769a9cb2 93#else
819850ff 94#include "wx/frame.h"
67879c5b 95#define wxSTCCallTipBase wxFrame
769a9cb2
RD
96#endif
97
819850ff 98#include "wx/dcbuffer.h"
8a793194 99
769a9cb2 100class wxSTCCallTip : public wxSTCCallTipBase {
f6bcfd97 101public:
67879c5b 102 wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) :
c0a4c58a 103#if wxUSE_POPUPWIN
67879c5b
RD
104 wxSTCCallTipBase(parent, wxBORDER_NONE),
105#else
106 wxSTCCallTipBase(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize,
107 wxFRAME_NO_TASKBAR
108 | wxFRAME_FLOAT_ON_PARENT
109 | wxBORDER_NONE
110#ifdef __WXMAC__
2d512c47 111 | wxPOPUP_WINDOW
67879c5b 112#endif
2d512c47 113 ),
67879c5b 114#endif
7e126a07 115 m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord)
f6bcfd97 116 {
c0a4c58a 117 SetBackgroundStyle(wxBG_STYLE_CUSTOM);
f6bcfd97
BP
118 }
119
ef08ab52 120 ~wxSTCCallTip() {
c0a4c58a 121#if wxUSE_POPUPWIN && defined(__WXGTK__)
8a793194 122 wxRect rect = GetRect();
ee8bee6c
RD
123 rect.x = m_cx;
124 rect.y = m_cy;
8a793194
RD
125 GetParent()->Refresh(false, &rect);
126#endif
ef08ab52
RD
127 }
128
7e126a07 129 bool AcceptsFocus() const { return false; }
9e730a78 130
67879c5b
RD
131 void OnPaint(wxPaintEvent& WXUNUSED(evt))
132 {
c0a4c58a 133 wxAutoBufferedPaintDC dc(this);
9b01abb8 134 Surface* surfaceWindow = Surface::Allocate(0);
9e730a78 135 surfaceWindow->Init(&dc, m_ct->wDraw.GetID());
1a2fb4cd 136 m_ct->PaintCT(surfaceWindow);
9e730a78 137 surfaceWindow->Release();
1a2fb4cd 138 delete surfaceWindow;
f6bcfd97
BP
139 }
140
67879c5b
RD
141 void OnFocus(wxFocusEvent& event)
142 {
267484bc
RD
143 GetParent()->SetFocus();
144 event.Skip();
145 }
146
67879c5b
RD
147 void OnLeftDown(wxMouseEvent& event)
148 {
9e730a78
RD
149 wxPoint pt = event.GetPosition();
150 Point p(pt.x, pt.y);
151 m_ct->MouseClick(p);
152 m_swx->CallTipClick();
153 }
154
769a9cb2
RD
155 virtual void DoSetSize(int x, int y,
156 int width, int height,
67879c5b
RD
157 int sizeFlags = wxSIZE_AUTO)
158 {
159 // convert coords to screen coords since we're a top-level window
7e126a07 160 if (x != wxDefaultCoord) {
ee8bee6c 161 m_cx = x;
769a9cb2 162 GetParent()->ClientToScreen(&x, NULL);
ee8bee6c 163 }
7e126a07 164 if (y != wxDefaultCoord) {
ee8bee6c 165 m_cy = y;
769a9cb2 166 GetParent()->ClientToScreen(NULL, &y);
ee8bee6c 167 }
769a9cb2
RD
168 wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags);
169 }
769a9cb2 170
c0a4c58a 171#if wxUSE_POPUPWIN
67879c5b
RD
172#else
173 virtual bool Show( bool show = true )
174 {
175 // Although we're a frame, we always want the parent to be active, so
176 // raise it whenever we get shown.
177 bool rv = wxSTCCallTipBase::Show(show);
178 if (rv && show)
179 {
180 wxTopLevelWindow *frame = wxDynamicCast(
181 wxGetTopLevelParent(GetParent()), wxTopLevelWindow);
182 if (frame)
183 frame->Raise();
184 }
185 return rv;
186 }
187#endif
2d512c47 188
67879c5b
RD
189 wxPoint GetMyPosition()
190 {
ee8bee6c
RD
191 return wxPoint(m_cx, m_cy);
192 }
7e126a07 193
769a9cb2 194private:
9e730a78
RD
195 CallTip* m_ct;
196 ScintillaWX* m_swx;
ee8bee6c 197 int m_cx, m_cy;
f6bcfd97
BP
198 DECLARE_EVENT_TABLE()
199};
200
769a9cb2 201BEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase)
f6bcfd97 202 EVT_PAINT(wxSTCCallTip::OnPaint)
267484bc 203 EVT_SET_FOCUS(wxSTCCallTip::OnFocus)
9c46ea66 204 EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown)
f6bcfd97 205END_EVENT_TABLE()
9ce192d4 206
769a9cb2 207
610c50a2
RD
208//----------------------------------------------------------------------
209
c54e5eb0 210#if wxUSE_DATAOBJ
610c50a2
RD
211static wxTextFileType wxConvertEOLMode(int scintillaMode)
212{
213 wxTextFileType type;
7e126a07 214
610c50a2
RD
215 switch (scintillaMode) {
216 case wxSTC_EOL_CRLF:
217 type = wxTextFileType_Dos;
218 break;
7e126a07 219
610c50a2
RD
220 case wxSTC_EOL_CR:
221 type = wxTextFileType_Mac;
222 break;
7e126a07 223
610c50a2
RD
224 case wxSTC_EOL_LF:
225 type = wxTextFileType_Unix;
226 break;
7e126a07 227
610c50a2
RD
228 default:
229 type = wxTextBuffer::typeDefault;
230 break;
231 }
232 return type;
233}
c54e5eb0 234#endif // wxUSE_DATAOBJ
7e126a07 235
610c50a2 236
9ce192d4
RD
237//----------------------------------------------------------------------
238// Constructor/Destructor
239
240
241ScintillaWX::ScintillaWX(wxStyledTextCtrl* win) {
9e730a78 242 capturedMouse = false;
b0d0494f 243 focusEvent = false;
9ce192d4 244 wMain = win;
9ce192d4 245 stc = win;
1d84348c
VZ
246 wheelVRotation = 0;
247 wheelHRotation = 0;
9ce192d4 248 Initialise();
68985f0e
RD
249#ifdef __WXMSW__
250 sysCaretBitmap = 0;
251 sysCaretWidth = 0;
252 sysCaretHeight = 0;
253#endif
9ce192d4
RD
254}
255
256
257ScintillaWX::~ScintillaWX() {
f402150f 258 Finalise();
9ce192d4
RD
259}
260
261//----------------------------------------------------------------------
262// base class virtuals
263
264
265void ScintillaWX::Initialise() {
266 //ScintillaBase::Initialise();
1bc32508 267#if wxUSE_DRAG_AND_DROP
9eb662e9
RD
268 dropTarget = new wxSTCDropTarget;
269 dropTarget->SetScintilla(this);
270 stc->SetDropTarget(dropTarget);
f402150f 271#endif // wxUSE_DRAG_AND_DROP
0eaf23ed 272 vs.extraFontFlag = true; // UseAntiAliasing
9ce192d4
RD
273}
274
275
276void ScintillaWX::Finalise() {
277 ScintillaBase::Finalise();
8e54aaed
RD
278 SetTicking(false);
279 SetIdle(false);
d429e187 280 DestroySystemCaret();
9ce192d4
RD
281}
282
283
284void ScintillaWX::StartDrag() {
f402150f 285#if wxUSE_DRAG_AND_DROP
0c5b83b0 286 wxString dragText = stc2wx(drag.s, drag.len);
a29a241f
RD
287
288 // Send an event to allow the drag text to be changed
289 wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
290 evt.SetEventObject(stc);
291 evt.SetDragText(dragText);
35f8d83d 292 evt.SetDragFlags(wxDrag_DefaultMove);
a29a241f
RD
293 evt.SetPosition(wxMin(stc->GetSelectionStart(),
294 stc->GetSelectionEnd()));
295 stc->GetEventHandler()->ProcessEvent(evt);
296 dragText = evt.GetDragText();
297
6636ef8d 298 if ( !dragText.empty() ) {
5fa4613c 299 wxDropSource source(stc);
a29a241f
RD
300 wxTextDataObject data(dragText);
301 wxDragResult result;
302
303 source.SetData(data);
7e126a07 304 dropWentOutside = true;
17e05a8e 305 inDragDrop = ddDragging;
35f8d83d 306 result = source.DoDragDrop(evt.GetDragFlags());
a29a241f
RD
307 if (result == wxDragMove && dropWentOutside)
308 ClearSelection();
7e0c58e9 309 inDragDrop = ddNone;
9e96e16f 310 SetDragPosition(SelectionPosition(invalidPosition));
a29a241f 311 }
f402150f 312#endif // wxUSE_DRAG_AND_DROP
9ce192d4
RD
313}
314
315
8e54aaed
RD
316bool ScintillaWX::SetIdle(bool on) {
317 if (idler.state != on) {
318 // connect or disconnect the EVT_IDLE handler
7e126a07 319 if (on)
3c778901 320 stc->Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(wxStyledTextCtrl::OnIdle));
8e54aaed 321 else
3c778901 322 stc->Disconnect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(wxStyledTextCtrl::OnIdle));
8e54aaed
RD
323 idler.state = on;
324 }
325 return idler.state;
326}
327
7e126a07 328
9ce192d4
RD
329void ScintillaWX::SetTicking(bool on) {
330 wxSTCTimer* steTimer;
331 if (timer.ticking != on) {
332 timer.ticking = on;
333 if (timer.ticking) {
334 steTimer = new wxSTCTimer(this);
335 steTimer->Start(timer.tickSize);
1a2fb4cd 336 timer.tickerID = steTimer;
9ce192d4
RD
337 } else {
338 steTimer = (wxSTCTimer*)timer.tickerID;
339 steTimer->Stop();
340 delete steTimer;
341 timer.tickerID = 0;
342 }
343 }
344 timer.ticksToWait = caret.period;
345}
346
347
348void ScintillaWX::SetMouseCapture(bool on) {
8e54aaed 349 if (mouseDownCaptures) {
134d7051 350 if (on && !capturedMouse)
8e54aaed 351 stc->CaptureMouse();
134d7051 352 else if (!on && capturedMouse && stc->HasCapture())
8e54aaed 353 stc->ReleaseMouse();
134d7051 354 capturedMouse = on;
8e54aaed 355 }
9ce192d4
RD
356}
357
358
359bool ScintillaWX::HaveMouseCapture() {
9e730a78 360 return capturedMouse;
9ce192d4
RD
361}
362
363
364void ScintillaWX::ScrollText(int linesToMove) {
365 int dy = vs.lineHeight * (linesToMove);
5fa4613c 366 stc->ScrollWindow(0, dy);
9ce192d4
RD
367}
368
369void ScintillaWX::SetVerticalScrollPos() {
5fa4613c
RD
370 if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar
371 stc->SetScrollPos(wxVERTICAL, topLine);
372 }
373 else { // otherwise use the one that's been given to us
374 stc->m_vScrollBar->SetThumbPosition(topLine);
375 }
9ce192d4
RD
376}
377
378void ScintillaWX::SetHorizontalScrollPos() {
5fa4613c
RD
379 if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar
380 stc->SetScrollPos(wxHORIZONTAL, xOffset);
381 }
382 else { // otherwise use the one that's been given to us
383 stc->m_hScrollBar->SetThumbPosition(xOffset);
384 }
9ce192d4
RD
385}
386
1bc54e32 387
a834585d 388const int H_SCROLL_STEP = 20;
9ce192d4
RD
389
390bool ScintillaWX::ModifyScrollBars(int nMax, int nPage) {
391 bool modified = false;
9ce192d4 392
1bc54e32
RD
393 int vertEnd = nMax;
394 if (!verticalScrollBarVisible)
395 vertEnd = 0;
396
a834585d 397 // Check the vertical scrollbar
5fa4613c
RD
398 if (stc->m_vScrollBar == NULL) { // Use built-in scrollbar
399 int sbMax = stc->GetScrollRange(wxVERTICAL);
400 int sbThumb = stc->GetScrollThumb(wxVERTICAL);
401 int sbPos = stc->GetScrollPos(wxVERTICAL);
1bc54e32
RD
402 if (sbMax != vertEnd || sbThumb != nPage) {
403 stc->SetScrollbar(wxVERTICAL, sbPos, nPage, vertEnd+1);
5fa4613c
RD
404 modified = true;
405 }
406 }
407 else { // otherwise use the one that's been given to us
408 int sbMax = stc->m_vScrollBar->GetRange();
409 int sbPage = stc->m_vScrollBar->GetPageSize();
410 int sbPos = stc->m_vScrollBar->GetThumbPosition();
1bc54e32
RD
411 if (sbMax != vertEnd || sbPage != nPage) {
412 stc->m_vScrollBar->SetScrollbar(sbPos, nPage, vertEnd+1, nPage);
5fa4613c
RD
413 modified = true;
414 }
9ce192d4
RD
415 }
416
5fa4613c 417
a834585d
RD
418 // Check the horizontal scrollbar
419 PRectangle rcText = GetTextRectangle();
420 int horizEnd = scrollWidth;
421 if (horizEnd < 0)
422 horizEnd = 0;
423 if (!horizontalScrollBarVisible || (wrapState != eWrapNone))
424 horizEnd = 0;
425 int pageWidth = rcText.Width();
426
427 if (stc->m_hScrollBar == NULL) { // Use built-in scrollbar
428 int sbMax = stc->GetScrollRange(wxHORIZONTAL);
429 int sbThumb = stc->GetScrollThumb(wxHORIZONTAL);
430 int sbPos = stc->GetScrollPos(wxHORIZONTAL);
431 if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) {
1bc54e32 432 stc->SetScrollbar(wxHORIZONTAL, sbPos, pageWidth, horizEnd);
a834585d
RD
433 modified = true;
434 if (scrollWidth < pageWidth) {
435 HorizontalScrollTo(0);
5fa4613c
RD
436 }
437 }
a834585d
RD
438 }
439 else { // otherwise use the one that's been given to us
440 int sbMax = stc->m_hScrollBar->GetRange();
441 int sbThumb = stc->m_hScrollBar->GetPageSize();
442 int sbPos = stc->m_hScrollBar->GetThumbPosition();
443 if ((sbMax != horizEnd) || (sbThumb != pageWidth) || (sbPos != 0)) {
1bc54e32 444 stc->m_hScrollBar->SetScrollbar(sbPos, pageWidth, horizEnd, pageWidth);
a834585d
RD
445 modified = true;
446 if (scrollWidth < pageWidth) {
447 HorizontalScrollTo(0);
5fa4613c 448 }
3928c4fd 449 }
9ce192d4 450 }
a834585d 451
9ce192d4
RD
452 return modified;
453}
454
455
456void ScintillaWX::NotifyChange() {
457 stc->NotifyChange();
458}
459
460
461void ScintillaWX::NotifyParent(SCNotification scn) {
462 stc->NotifyParent(&scn);
463}
464
465
b0d0494f
RD
466// This method is overloaded from ScintillaBase in order to prevent the
467// AutoComplete window from being destroyed when it gets the focus. There is
468// a side effect that the AutoComp will also not be destroyed when switching
469// to another window, but I think that is okay.
470void ScintillaWX::CancelModes() {
471 if (! focusEvent)
472 AutoCompleteCancel();
473 ct.CallTipCancel();
474 Editor::CancelModes();
475}
476
477
9ce192d4
RD
478
479void ScintillaWX::Copy() {
9e96e16f 480 if (!sel.Empty()) {
b8b0e402
RD
481 SelectionText st;
482 CopySelectionRange(&st);
e14d10b0 483 CopyToClipboard(st);
9ce192d4
RD
484 }
485}
486
487
488void ScintillaWX::Paste() {
489 pdoc->BeginUndoAction();
490 ClearSelection();
491
c54e5eb0 492#if wxUSE_DATAOBJ
9ce192d4 493 wxTextDataObject data;
7e126a07 494 bool gotData = false;
9ce192d4 495
e5abfc48 496 wxTheClipboard->UsePrimarySelection(false);
45c6a927 497 if (wxTheClipboard->Open()) {
45c6a927
RD
498 gotData = wxTheClipboard->GetData(data);
499 wxTheClipboard->Close();
500 }
e26c0634 501 if (gotData) {
610c50a2
RD
502 wxString text = wxTextBuffer::Translate(data.GetText(),
503 wxConvertEOLMode(pdoc->eolMode));
504 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
1c930beb 505
e968f108
RD
506#if wxUSE_UNICODE
507 // free up the old character buffer in case the text is real big
2d512c47 508 data.SetText(wxEmptyString);
e968f108
RD
509 text = wxEmptyString;
510#endif
511 int len = strlen(buf);
9e96e16f
RD
512 int caretMain = sel.MainCaret();
513 pdoc->InsertString(caretMain, buf, len);
514 SetEmptySelection(caretMain + len);
9ce192d4 515 }
c54e5eb0 516#endif // wxUSE_DATAOBJ
9ce192d4
RD
517
518 pdoc->EndUndoAction();
519 NotifyChange();
520 Redraw();
521}
522
523
e14d10b0 524void ScintillaWX::CopyToClipboard(const SelectionText& st) {
c54e5eb0 525#if wxUSE_CLIPBOARD
0c9a7985
VZ
526 if ( !st.len )
527 return;
528
e5abfc48 529 wxTheClipboard->UsePrimarySelection(false);
e14d10b0 530 if (wxTheClipboard->Open()) {
98719eab 531 wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1));
e14d10b0
RD
532 wxTheClipboard->SetData(new wxTextDataObject(text));
533 wxTheClipboard->Close();
534 }
c54e5eb0
WS
535#else
536 wxUnusedVar(st);
537#endif // wxUSE_CLIPBOARD
e14d10b0
RD
538}
539
540
9ce192d4 541bool ScintillaWX::CanPaste() {
c54e5eb0 542#if wxUSE_CLIPBOARD
7e126a07 543 bool canPaste = false;
45c6a927 544 bool didOpen;
9ce192d4 545
0b887a21 546 if (Editor::CanPaste()) {
e5abfc48 547 wxTheClipboard->UsePrimarySelection(false);
88a8b04e
RD
548 didOpen = !wxTheClipboard->IsOpened();
549 if ( didOpen )
0b887a21 550 wxTheClipboard->Open();
45c6a927 551
0b887a21 552 if (wxTheClipboard->IsOpened()) {
0b887a21
RD
553 canPaste = wxTheClipboard->IsSupported(wxUSE_UNICODE ? wxDF_UNICODETEXT : wxDF_TEXT);
554 if (didOpen)
555 wxTheClipboard->Close();
556 }
6ba338ec 557 }
9ce192d4 558 return canPaste;
c54e5eb0
WS
559#else
560 return false;
561#endif // wxUSE_CLIPBOARD
9ce192d4
RD
562}
563
564void ScintillaWX::CreateCallTipWindow(PRectangle) {
9e730a78
RD
565 if (! ct.wCallTip.Created() ) {
566 ct.wCallTip = new wxSTCCallTip(stc, &ct, this);
567 ct.wDraw = ct.wCallTip;
568 }
9ce192d4
RD
569}
570
571
572void ScintillaWX::AddToPopUp(const char *label, int cmd, bool enabled) {
573 if (!label[0])
1a2fb4cd 574 ((wxMenu*)popup.GetID())->AppendSeparator();
9ce192d4 575 else
1e545382 576 ((wxMenu*)popup.GetID())->Append(cmd, wxGetTranslation(stc2wx(label)));
9ce192d4
RD
577
578 if (!enabled)
1a2fb4cd 579 ((wxMenu*)popup.GetID())->Enable(cmd, enabled);
9ce192d4
RD
580}
581
582
e5abfc48
RD
583// This is called by the Editor base class whenever something is selected.
584// For wxGTK we can put this text in the primary selection and then other apps
585// can paste with the middle button.
9ce192d4 586void ScintillaWX::ClaimSelection() {
2b5f62a0
VZ
587#ifdef __WXGTK__
588 // Put the selected text in the PRIMARY selection
9e96e16f 589 if (!sel.Empty()) {
2b5f62a0
VZ
590 SelectionText st;
591 CopySelectionRange(&st);
e5abfc48 592 wxTheClipboard->UsePrimarySelection(true);
2b5f62a0 593 if (wxTheClipboard->Open()) {
2b5f62a0
VZ
594 wxString text = stc2wx(st.s, st.len);
595 wxTheClipboard->SetData(new wxTextDataObject(text));
2b5f62a0
VZ
596 wxTheClipboard->Close();
597 }
e5abfc48 598 wxTheClipboard->UsePrimarySelection(false);
2b5f62a0
VZ
599 }
600#endif
9ce192d4
RD
601}
602
603
d429e187
RD
604void ScintillaWX::UpdateSystemCaret() {
605#ifdef __WXMSW__
606 if (hasFocus) {
607 if (HasCaretSizeChanged()) {
608 DestroySystemCaret();
609 CreateSystemCaret();
610 }
9e96e16f 611 Point pos = PointMainCaret();
d429e187
RD
612 ::SetCaretPos(pos.x, pos.y);
613 }
614#endif
615}
616
617
618bool ScintillaWX::HasCaretSizeChanged() {
619#ifdef __WXMSW__
d3acc83a
VZ
620 if ( (vs.caretWidth && (sysCaretWidth != vs.caretWidth))
621 || (vs.lineHeight && (sysCaretHeight != vs.lineHeight)) ) {
d429e187
RD
622 return true;
623 }
624#endif
625 return false;
626}
627
628bool ScintillaWX::CreateSystemCaret() {
629#ifdef __WXMSW__
630 sysCaretWidth = vs.caretWidth;
631 if (0 == sysCaretWidth) {
632 sysCaretWidth = 1;
633 }
634 sysCaretHeight = vs.lineHeight;
635 int bitmapSize = (((sysCaretWidth + 15) & ~15) >> 3) * sysCaretHeight;
636 char *bits = new char[bitmapSize];
637 memset(bits, 0, bitmapSize);
638 sysCaretBitmap = ::CreateBitmap(sysCaretWidth, sysCaretHeight, 1,
639 1, reinterpret_cast<BYTE *>(bits));
640 delete [] bits;
641 BOOL retval = ::CreateCaret(GetHwndOf(stc), sysCaretBitmap,
642 sysCaretWidth, sysCaretHeight);
643 ::ShowCaret(GetHwndOf(stc));
644 return retval != 0;
645#else
646 return false;
647#endif
648}
649
650bool ScintillaWX::DestroySystemCaret() {
651#ifdef __WXMSW__
652 ::HideCaret(GetHwndOf(stc));
653 BOOL retval = ::DestroyCaret();
654 if (sysCaretBitmap) {
655 ::DeleteObject(sysCaretBitmap);
656 sysCaretBitmap = 0;
657 }
658 return retval != 0;
659#else
660 return false;
661#endif
662}
663
664
665//----------------------------------------------------------------------
666
667
80dc1dd3 668sptr_t ScintillaWX::DefWndProc(unsigned int /*iMessage*/, uptr_t /*wParam*/, sptr_t /*lParam*/) {
9ce192d4
RD
669 return 0;
670}
671
80dc1dd3 672sptr_t ScintillaWX::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) {
fdec65df 673 switch (iMessage) {
9b01abb8
RD
674#if 0 // TODO: check this
675
fdec65df
RD
676 case SCI_CALLTIPSHOW: {
677 // NOTE: This is copied here from scintilla/src/ScintillaBase.cxx
9e730a78
RD
678 // because of the little tweak that needs done below for wxGTK.
679 // When updating new versions double check that this is still
680 // needed, and that any new code there is copied here too.
681 Point pt = LocationFromPosition(wParam);
682 char* defn = reinterpret_cast<char *>(lParam);
fdec65df 683 AutoCompleteCancel();
9e730a78 684 pt.y += vs.lineHeight;
2d512c47
JS
685 int ctStyle = ct.UseStyleCallTip() ? STYLE_CALLTIP : STYLE_DEFAULT;
686 if (ct.UseStyleCallTip())
687 {
688 ct.SetForeBack(vs.styles[STYLE_CALLTIP].fore, vs.styles[STYLE_CALLTIP].back);
689 }
9e96e16f
RD
690 int caretMain = sel.MainCaret();
691 PRectangle rc = ct.CallTipStart(caretMain, pt,
9e730a78 692 defn,
2d512c47
JS
693 vs.styles[ctStyle].fontName,
694 vs.styles[ctStyle].sizeZoomed,
a33203cb 695 CodePage(),
2d512c47 696 vs.styles[ctStyle].characterSet,
9e730a78
RD
697 wMain);
698 // If the call-tip window would be out of the client
699 // space, adjust so it displays above the text.
700 PRectangle rcClient = GetClientRectangle();
701 if (rc.bottom > rcClient.bottom) {
fdec65df 702#ifdef __WXGTK__
9e730a78 703 int offset = int(vs.lineHeight * 1.25) + rc.Height();
fdec65df 704#else
9e730a78 705 int offset = vs.lineHeight + rc.Height();
fdec65df 706#endif
9e730a78
RD
707 rc.top -= offset;
708 rc.bottom -= offset;
fdec65df 709 }
9e730a78
RD
710 // Now display the window.
711 CreateCallTipWindow(rc);
712 ct.wCallTip.SetPositionRelative(rc, wMain);
713 ct.wCallTip.Show();
fdec65df 714 break;
9e730a78 715 }
9b01abb8 716#endif
fdec65df 717
e14d10b0 718#ifdef SCI_LEXER
7e126a07 719 case SCI_LOADLEXERLIBRARY:
e14d10b0
RD
720 LexerManager::GetInstance()->Load((const char*)lParam);
721 break;
722#endif
719493e1 723
fdec65df
RD
724 default:
725 return ScintillaBase::WndProc(iMessage, wParam, lParam);
726 }
727 return 0;
9ce192d4
RD
728}
729
730
731
732//----------------------------------------------------------------------
733// Event delegates
734
735void ScintillaWX::DoPaint(wxDC* dc, wxRect rect) {
736
737 paintState = painting;
c3e0999b
RD
738 AutoSurface surfaceWindow(dc, this);
739 if (surfaceWindow) {
740 rcPaint = PRectangleFromwxRect(rect);
741 PRectangle rcClient = GetClientRectangle();
742 paintingAllText = rcPaint.Contains(rcClient);
743
744 ClipChildren(*dc, rcPaint);
745 Paint(surfaceWindow, rcPaint);
746 surfaceWindow->Release();
747 }
9e730a78 748
9ce192d4 749 if (paintState == paintAbandoned) {
cadea444 750 // Painting area was insufficient to cover new styling or brace
337c5edd
RD
751 // highlight positions. So trigger a new paint event that will
752 // repaint the whole window.
753 stc->Refresh(false);
754
755#if defined(__WXOSX__)
756 // On Mac we also need to finish the current paint to make sure that
757 // everything is on the screen that needs to be there between now and
758 // when the next paint event arrives.
c3e0999b 759 FullPaintDC(dc);
337c5edd 760#endif
c3e0999b
RD
761 }
762 paintState = notPainting;
763}
764
765
766// Force the whole window to be repainted
767void ScintillaWX::FullPaint() {
337c5edd
RD
768 stc->Refresh(false);
769 stc->Update();
c3e0999b
RD
770}
771
772
773void ScintillaWX::FullPaintDC(wxDC* dc) {
774 paintState = painting;
775 rcPaint = GetClientRectangle();
776 paintingAllText = true;
777 AutoSurface surfaceWindow(dc, this);
778 if (surfaceWindow) {
779 Paint(surfaceWindow, rcPaint);
780 surfaceWindow->Release();
9ce192d4
RD
781 }
782 paintState = notPainting;
783}
784
785
c3e0999b 786
9ce192d4
RD
787void ScintillaWX::DoHScroll(int type, int pos) {
788 int xPos = xOffset;
a834585d
RD
789 PRectangle rcText = GetTextRectangle();
790 int pageWidth = rcText.Width() * 2 / 3;
5fa4613c 791 if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP)
9ce192d4 792 xPos -= H_SCROLL_STEP;
5fa4613c 793 else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN)
9ce192d4 794 xPos += H_SCROLL_STEP;
5fa4613c 795 else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP)
a834585d
RD
796 xPos -= pageWidth;
797 else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN) {
798 xPos += pageWidth;
799 if (xPos > scrollWidth - rcText.Width()) {
800 xPos = scrollWidth - rcText.Width();
801 }
802 }
5fa4613c 803 else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP)
9ce192d4 804 xPos = 0;
5fa4613c 805 else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM)
a834585d 806 xPos = scrollWidth;
5fa4613c 807 else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK)
9ce192d4 808 xPos = pos;
ce1ecc6d 809
9ce192d4
RD
810 HorizontalScrollTo(xPos);
811}
812
813void ScintillaWX::DoVScroll(int type, int pos) {
814 int topLineNew = topLine;
5fa4613c 815 if (type == wxEVT_SCROLLWIN_LINEUP || type == wxEVT_SCROLL_LINEUP)
9ce192d4 816 topLineNew -= 1;
5fa4613c 817 else if (type == wxEVT_SCROLLWIN_LINEDOWN || type == wxEVT_SCROLL_LINEDOWN)
9ce192d4 818 topLineNew += 1;
5fa4613c 819 else if (type == wxEVT_SCROLLWIN_PAGEUP || type == wxEVT_SCROLL_PAGEUP)
9ce192d4 820 topLineNew -= LinesToScroll();
5fa4613c 821 else if (type == wxEVT_SCROLLWIN_PAGEDOWN || type == wxEVT_SCROLL_PAGEDOWN)
9ce192d4 822 topLineNew += LinesToScroll();
5fa4613c 823 else if (type == wxEVT_SCROLLWIN_TOP || type == wxEVT_SCROLL_TOP)
9ce192d4 824 topLineNew = 0;
5fa4613c 825 else if (type == wxEVT_SCROLLWIN_BOTTOM || type == wxEVT_SCROLL_BOTTOM)
9ce192d4 826 topLineNew = MaxScrollPos();
5fa4613c 827 else if (type == wxEVT_SCROLLWIN_THUMBTRACK || type == wxEVT_SCROLL_THUMBTRACK)
9ce192d4 828 topLineNew = pos;
ce1ecc6d 829
9ce192d4
RD
830 ScrollTo(topLineNew);
831}
832
1d84348c
VZ
833void ScintillaWX::DoMouseWheel(wxMouseWheelAxis axis, int rotation, int delta,
834 int linesPerAction, int columnsPerAction,
835 bool ctrlDown, bool isPageScroll) {
37d62433
RD
836 int topLineNew = topLine;
837 int lines;
1d84348c
VZ
838 int xPos = xOffset;
839 int pixels;
840
841 if (axis == wxMOUSE_WHEEL_HORIZONTAL) {
842 wheelHRotation += rotation * (columnsPerAction * vs.spaceWidth);
843 pixels = wheelHRotation / delta;
844 wheelHRotation -= pixels * delta;
845 if (pixels != 0) {
846 xPos += pixels;
847 PRectangle rcText = GetTextRectangle();
848 if (xPos > scrollWidth - rcText.Width()) {
849 xPos = scrollWidth - rcText.Width();
850 }
851 HorizontalScrollTo(xPos);
852 }
853 }
854 else if (ctrlDown) { // Zoom the fonts if Ctrl key down
81f2b2ee 855 if (rotation > 0) {
65ec6247
RD
856 KeyCommand(SCI_ZOOMIN);
857 }
858 else {
859 KeyCommand(SCI_ZOOMOUT);
860 }
861 }
862 else { // otherwise just scroll the window
91f580b2
RD
863 if ( !delta )
864 delta = 120;
1d84348c
VZ
865 wheelVRotation += rotation;
866 lines = wheelVRotation / delta;
867 wheelVRotation -= lines * delta;
65ec6247 868 if (lines != 0) {
9b9337da
RD
869 if (isPageScroll)
870 lines = lines * LinesOnScreen(); // lines is either +1 or -1
871 else
872 lines *= linesPerAction;
65ec6247
RD
873 topLineNew -= lines;
874 ScrollTo(topLineNew);
875 }
37d62433
RD
876 }
877}
878
879
88a8b04e 880void ScintillaWX::DoSize(int WXUNUSED(width), int WXUNUSED(height)) {
1a2fb4cd 881 ChangeSize();
9ce192d4
RD
882}
883
884void ScintillaWX::DoLoseFocus(){
b0d0494f 885 focusEvent = true;
65ec6247 886 SetFocusState(false);
b0d0494f 887 focusEvent = false;
d429e187 888 DestroySystemCaret();
9ce192d4
RD
889}
890
891void ScintillaWX::DoGainFocus(){
b0d0494f 892 focusEvent = true;
65ec6247 893 SetFocusState(true);
b0d0494f 894 focusEvent = false;
d429e187
RD
895 DestroySystemCaret();
896 CreateSystemCaret();
9ce192d4
RD
897}
898
899void ScintillaWX::DoSysColourChange() {
900 InvalidateStyleData();
901}
902
2b5f62a0 903void ScintillaWX::DoLeftButtonDown(Point pt, unsigned int curTime, bool shift, bool ctrl, bool alt) {
9ce192d4
RD
904 ButtonDown(pt, curTime, shift, ctrl, alt);
905}
906
2b5f62a0 907void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
4d02625c 908 ButtonUp(pt, curTime, ctrl);
9ce192d4
RD
909}
910
2b5f62a0 911void ScintillaWX::DoLeftButtonMove(Point pt) {
9ce192d4
RD
912 ButtonMove(pt);
913}
914
2b5f62a0 915#ifdef __WXGTK__
88a8b04e 916void ScintillaWX::DoMiddleButtonUp(Point pt) {
2b5f62a0
VZ
917 // Set the current position to the mouse click point and
918 // then paste in the PRIMARY selection, if any. wxGTK only.
919 int newPos = PositionFromLocation(pt);
9e96e16f 920 MovePositionTo(newPos, Selection::noSel, true);
2b5f62a0
VZ
921
922 pdoc->BeginUndoAction();
923 wxTextDataObject data;
7e126a07 924 bool gotData = false;
e5abfc48 925 wxTheClipboard->UsePrimarySelection(true);
2b5f62a0 926 if (wxTheClipboard->Open()) {
2b5f62a0 927 gotData = wxTheClipboard->GetData(data);
2b5f62a0
VZ
928 wxTheClipboard->Close();
929 }
e5abfc48 930 wxTheClipboard->UsePrimarySelection(false);
2b5f62a0 931 if (gotData) {
610c50a2
RD
932 wxString text = wxTextBuffer::Translate(data.GetText(),
933 wxConvertEOLMode(pdoc->eolMode));
934 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
2b5f62a0 935 int len = strlen(buf);
9e96e16f
RD
936 int caretMain = sel.MainCaret();
937 pdoc->InsertString(caretMain, buf, len);
938 SetEmptySelection(caretMain + len);
2b5f62a0
VZ
939 }
940 pdoc->EndUndoAction();
941 NotifyChange();
942 Redraw();
943
944 ShowCaretAtCurrentPosition();
945 EnsureCaretVisible();
2b5f62a0 946}
88a8b04e
RD
947#else
948void ScintillaWX::DoMiddleButtonUp(Point WXUNUSED(pt)) {
949}
950#endif
2b5f62a0 951
9ce192d4 952
10ef30eb 953void ScintillaWX::DoAddChar(int key) {
2b5f62a0 954#if wxUSE_UNICODE
fdec65df 955 wxChar wszChars[2];
c8b75e94 956 wszChars[0] = (wxChar)key;
fdec65df
RD
957 wszChars[1] = 0;
958 wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(wszChars);
2b5f62a0
VZ
959 AddCharUTF((char*)buf.data(), strlen(buf));
960#else
c8b75e94 961 AddChar((char)key);
2b5f62a0 962#endif
9ce192d4
RD
963}
964
2b5f62a0 965
5fd656d5
RD
966int ScintillaWX::DoKeyDown(const wxKeyEvent& evt, bool* consumed)
967{
968 int key = evt.GetKeyCode();
83649911
VZ
969 if (key == WXK_NONE) {
970 // This is a Unicode character not representable in Latin-1 or some key
971 // without key code at all (e.g. dead key or VK_PROCESSKEY under MSW).
972 if ( consumed )
973 *consumed = false;
974 return 0;
975 }
976
5fd656d5
RD
977 bool shift = evt.ShiftDown(),
978 ctrl = evt.ControlDown(),
979 alt = evt.AltDown();
249b31b5 980
443eb93a 981 if (ctrl && key >= 1 && key <= 26 && key != WXK_BACK)
39178e3b 982 key += 'A' - 1;
39178e3b 983
d134f170 984 switch (key) {
0b9dfbc0
RD
985 case WXK_DOWN: key = SCK_DOWN; break;
986 case WXK_UP: key = SCK_UP; break;
987 case WXK_LEFT: key = SCK_LEFT; break;
988 case WXK_RIGHT: key = SCK_RIGHT; break;
989 case WXK_HOME: key = SCK_HOME; break;
990 case WXK_END: key = SCK_END; break;
5bd24f72
RD
991 case WXK_PAGEUP: key = SCK_PRIOR; break;
992 case WXK_PAGEDOWN: key = SCK_NEXT; break;
340515d3
RD
993 case WXK_NUMPAD_DOWN: key = SCK_DOWN; break;
994 case WXK_NUMPAD_UP: key = SCK_UP; break;
995 case WXK_NUMPAD_LEFT: key = SCK_LEFT; break;
996 case WXK_NUMPAD_RIGHT: key = SCK_RIGHT; break;
997 case WXK_NUMPAD_HOME: key = SCK_HOME; break;
998 case WXK_NUMPAD_END: key = SCK_END; break;
5bd24f72
RD
999 case WXK_NUMPAD_PAGEUP: key = SCK_PRIOR; break;
1000 case WXK_NUMPAD_PAGEDOWN: key = SCK_NEXT; break;
e64481bf
RD
1001 case WXK_NUMPAD_DELETE: key = SCK_DELETE; break;
1002 case WXK_NUMPAD_INSERT: key = SCK_INSERT; break;
0b9dfbc0
RD
1003 case WXK_DELETE: key = SCK_DELETE; break;
1004 case WXK_INSERT: key = SCK_INSERT; break;
1005 case WXK_ESCAPE: key = SCK_ESCAPE; break;
1006 case WXK_BACK: key = SCK_BACK; break;
1007 case WXK_TAB: key = SCK_TAB; break;
21334a46 1008 case WXK_NUMPAD_ENTER: // fall through
0b9dfbc0
RD
1009 case WXK_RETURN: key = SCK_RETURN; break;
1010 case WXK_ADD: // fall through
1011 case WXK_NUMPAD_ADD: key = SCK_ADD; break;
1012 case WXK_SUBTRACT: // fall through
1013 case WXK_NUMPAD_SUBTRACT: key = SCK_SUBTRACT; break;
1014 case WXK_DIVIDE: // fall through
1015 case WXK_NUMPAD_DIVIDE: key = SCK_DIVIDE; break;
1016 case WXK_CONTROL: key = 0; break;
1017 case WXK_ALT: key = 0; break;
1018 case WXK_SHIFT: key = 0; break;
23b9814f 1019 case WXK_MENU: key = SCK_MENU; break;
d134f170
RD
1020 }
1021
88a8b04e 1022#ifdef __WXMAC__
5fd656d5 1023 if ( evt.MetaDown() ) {
88a8b04e
RD
1024 // check for a few common Mac Meta-key combos and remap them to Ctrl
1025 // for Scintilla
1026 switch ( key ) {
1027 case 'Z': // Undo
1028 case 'X': // Cut
1029 case 'C': // Copy
1030 case 'V': // Paste
1031 case 'A': // Select All
1032 ctrl = true;
1033 break;
dd9b0a54
RD
1034 }
1035 }
88a8b04e 1036#endif
7e126a07 1037
d6582821 1038 int rv = KeyDown(key, shift, ctrl, alt, consumed);
0122b7e3 1039
d6582821
RD
1040 if (key)
1041 return rv;
1042 else
1043 return 1;
9ce192d4
RD
1044}
1045
1046
1047void ScintillaWX::DoCommand(int ID) {
1048 Command(ID);
1049}
1050
1051
1052void ScintillaWX::DoContextMenu(Point pt) {
752cd08c
RD
1053 if (displayPopupMenu)
1054 ContextMenu(pt);
9ce192d4
RD
1055}
1056
f6bcfd97
BP
1057void ScintillaWX::DoOnListBox() {
1058 AutoCompleteCompleted();
1059}
9ce192d4 1060
7e126a07 1061
8e54aaed
RD
1062void ScintillaWX::DoOnIdle(wxIdleEvent& evt) {
1063
1064 if ( Idle() )
1065 evt.RequestMore();
1066 else
1067 SetIdle(false);
1068}
7e126a07 1069
9ce192d4
RD
1070//----------------------------------------------------------------------
1071
1bc32508 1072#if wxUSE_DRAG_AND_DROP
9ce192d4 1073bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
9e96e16f 1074 SetDragPosition(SelectionPosition(invalidPosition));
a29a241f 1075
610c50a2
RD
1076 wxString text = wxTextBuffer::Translate(data,
1077 wxConvertEOLMode(pdoc->eolMode));
7e126a07 1078
a29a241f
RD
1079 // Send an event to allow the drag details to be changed
1080 wxStyledTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId());
1081 evt.SetEventObject(stc);
1082 evt.SetDragResult(dragResult);
1083 evt.SetX(x);
1084 evt.SetY(y);
1085 evt.SetPosition(PositionFromLocation(Point(x,y)));
610c50a2 1086 evt.SetDragText(text);
a29a241f
RD
1087 stc->GetEventHandler()->ProcessEvent(evt);
1088
1089 dragResult = evt.GetDragResult();
1090 if (dragResult == wxDragMove || dragResult == wxDragCopy) {
9e96e16f 1091 DropAt(SelectionPosition(evt.GetPosition()),
0c5b83b0 1092 wx2stc(evt.GetDragText()),
a29a241f 1093 dragResult == wxDragMove,
7e126a07
WS
1094 false); // TODO: rectangular?
1095 return true;
a29a241f 1096 }
7e126a07 1097 return false;
9ce192d4
RD
1098}
1099
1100
88a8b04e 1101wxDragResult ScintillaWX::DoDragEnter(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), wxDragResult def) {
b8b0e402
RD
1102 dragResult = def;
1103 return dragResult;
9ce192d4
RD
1104}
1105
1106
1107wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
9e96e16f 1108 SetDragPosition(SelectionPosition(PositionFromLocation(Point(x, y))));
a29a241f
RD
1109
1110 // Send an event to allow the drag result to be changed
1111 wxStyledTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId());
1112 evt.SetEventObject(stc);
1113 evt.SetDragResult(def);
1114 evt.SetX(x);
1115 evt.SetY(y);
1116 evt.SetPosition(PositionFromLocation(Point(x,y)));
1117 stc->GetEventHandler()->ProcessEvent(evt);
1118
1119 dragResult = evt.GetDragResult();
b8b0e402 1120 return dragResult;
9ce192d4
RD
1121}
1122
1123
1124void ScintillaWX::DoDragLeave() {
9e96e16f 1125 SetDragPosition(SelectionPosition(invalidPosition));
9ce192d4 1126}
f402150f 1127#endif // wxUSE_DRAG_AND_DROP
9ce192d4
RD
1128//----------------------------------------------------------------------
1129
9ce192d4
RD
1130void ScintillaWX::DoScrollToLine(int line) {
1131 ScrollTo(line);
1132}
1133
1134
1135void ScintillaWX::DoScrollToColumn(int column) {
1136 HorizontalScrollTo(column * vs.spaceWidth);
1137}
1138
382fe640
RD
1139// wxGTK doesn't appear to need this explicit clipping code any longer, but I
1140// will leave it here commented out for a while just in case...
1141void ScintillaWX::ClipChildren(wxDC& WXUNUSED(dc), PRectangle WXUNUSED(rect))
1142{
1143// wxRegion rgn(wxRectFromPRectangle(rect));
1144// if (ac.Active()) {
1145// wxRect childRect = ((wxWindow*)ac.lb->GetID())->GetRect();
1146// rgn.Subtract(childRect);
1147// }
1148// if (ct.inCallTipMode) {
1149// wxSTCCallTip* tip = (wxSTCCallTip*)ct.wCallTip.GetID();
1150// wxRect childRect = tip->GetRect();
c0a4c58a 1151// #if wxUSE_POPUPWIN
382fe640
RD
1152// childRect.SetPosition(tip->GetMyPosition());
1153// #endif
1154// rgn.Subtract(childRect);
1155// }
1156// dc.SetClippingRegion(rgn);
88a8b04e 1157}
9ce192d4 1158
d1558f3d
RD
1159
1160void ScintillaWX::SetUseAntiAliasing(bool useAA) {
1161 vs.extraFontFlag = useAA;
1162 InvalidateStyleRedraw();
1163}
1164
1165bool ScintillaWX::GetUseAntiAliasing() {
c26400bd 1166 return vs.extraFontFlag != 0;
d1558f3d 1167}
7e126a07 1168
9ce192d4
RD
1169//----------------------------------------------------------------------
1170//----------------------------------------------------------------------
29825f5f
PC
1171
1172#endif // wxUSE_STC