// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
-#include <wx/wx.h>
-#include <wx/textbuf.h>
-#include <wx/dataobj.h>
-#include <wx/clipbrd.h>
-#include <wx/dnd.h>
+#include "wx/wx.h"
+#include "wx/textbuf.h"
+#include "wx/dataobj.h"
+#include "wx/clipbrd.h"
+#include "wx/dnd.h"
#include "ScintillaWX.h"
#include "ExternalLexer.h"
#ifdef __WXMSW__
// GetHwndOf()
- #include <wx/msw/private.h>
+ #include "wx/msw/private.h"
#endif
//----------------------------------------------------------------------
#if wxUSE_DRAG_AND_DROP
+class wxStartDragTimer : public wxTimer {
+public:
+ wxStartDragTimer(ScintillaWX* swx) {
+ this->swx = swx;
+ }
+
+ void Notify() {
+ swx->DoStartDrag();
+ }
+
+private:
+ ScintillaWX* swx;
+};
+
+
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
return swx->DoDropText(x, y, data);
}
void wxSTCDropTarget::OnLeave() {
swx->DoDragLeave();
}
-#endif
+#endif // wxUSE_DRAG_AND_DROP
#if wxUSE_POPUPWIN && wxSTC_USE_POPUP
//----------------------------------------------------------------------
+#if wxUSE_DATAOBJ
static wxTextFileType wxConvertEOLMode(int scintillaMode)
{
wxTextFileType type;
}
return type;
}
+#endif // wxUSE_DATAOBJ
//----------------------------------------------------------------------
sysCaretWidth = 0;
sysCaretHeight = 0;
#endif
+#if wxUSE_DRAG_AND_DROP
+ startDragTimer = new wxStartDragTimer(this);
+#endif // wxUSE_DRAG_AND_DROP
}
ScintillaWX::~ScintillaWX() {
+#if wxUSE_DRAG_AND_DROP
+ delete startDragTimer;
+#endif // wxUSE_DRAG_AND_DROP
Finalise();
}
dropTarget = new wxSTCDropTarget;
dropTarget->SetScintilla(this);
stc->SetDropTarget(dropTarget);
-#endif
+#endif // wxUSE_DRAG_AND_DROP
#ifdef __WXMAC__
vs.extraFontFlag = false; // UseAntiAliasing
#else
void ScintillaWX::StartDrag() {
+#if wxUSE_DRAG_AND_DROP
+ // We defer the starting of the DnD, otherwise the LeftUp of a normal
+ // click could be lost and the STC will think it is doing a DnD when the
+ // user just wanted a normal click.
+ startDragTimer->Start(200, true);
+#endif // wxUSE_DRAG_AND_DROP
+}
+
+void ScintillaWX::DoStartDrag() {
#if wxUSE_DRAG_AND_DROP
wxString dragText = stc2wx(drag.s, drag.len);
stc->GetEventHandler()->ProcessEvent(evt);
dragText = evt.GetDragText();
- if (dragText.Length()) {
+ if (dragText.length()) {
wxDropSource source(stc);
wxTextDataObject data(dragText);
wxDragResult result;
inDragDrop = false;
SetDragPosition(invalidPosition);
}
-#endif
+#endif // wxUSE_DRAG_AND_DROP
}
pdoc->BeginUndoAction();
ClearSelection();
+#if wxUSE_DATAOBJ
wxTextDataObject data;
bool gotData = false;
wxString text = wxTextBuffer::Translate(data.GetText(),
wxConvertEOLMode(pdoc->eolMode));
wxWX2MBbuf buf = (wxWX2MBbuf)wx2stc(text);
- int len = strlen(buf);
+
+#if wxUSE_UNICODE
+ // free up the old character buffer in case the text is real big
+ data.SetText(wxEmptyString);
+ text = wxEmptyString;
+#endif
+ int len = strlen(buf);
pdoc->InsertString(currentPos, buf, len);
SetEmptySelection(currentPos + len);
}
+#endif // wxUSE_DATAOBJ
pdoc->EndUndoAction();
NotifyChange();
void ScintillaWX::CopyToClipboard(const SelectionText& st) {
+#if wxUSE_CLIPBOARD
if (wxTheClipboard->Open()) {
wxTheClipboard->UsePrimarySelection(false);
wxString text = wxTextBuffer::Translate(stc2wx(st.s, st.len-1));
wxTheClipboard->SetData(new wxTextDataObject(text));
wxTheClipboard->Close();
}
+#else
+ wxUnusedVar(st);
+#endif // wxUSE_CLIPBOARD
}
bool ScintillaWX::CanPaste() {
+#if wxUSE_CLIPBOARD
bool canPaste = false;
bool didOpen;
}
}
return canPaste;
+#else
+ return false;
+#endif // wxUSE_CLIPBOARD
}
void ScintillaWX::CreateCallTipWindow(PRectangle) {
PRectangle rcClient = GetClientRectangle();
paintingAllText = rcPaint.Contains(rcClient);
- dc->BeginDrawing();
ClipChildren(*dc, rcPaint);
Paint(surfaceWindow, rcPaint);
FullPaint();
}
paintState = notPainting;
- dc->EndDrawing();
}
void ScintillaWX::DoLeftButtonUp(Point pt, unsigned int curTime, bool ctrl) {
ButtonUp(pt, curTime, ctrl);
+#if wxUSE_DRAG_AND_DROP
+ if (startDragTimer->IsRunning()) {
+ startDragTimer->Stop();
+ SetDragPosition(invalidPosition);
+ SetEmptySelection(PositionFromLocation(pt));
+ ShowCaretAtCurrentPosition();
+ }
+#endif // wxUSE_DRAG_AND_DROP
}
void ScintillaWX::DoLeftButtonMove(Point pt) {
case WXK_RIGHT: key = SCK_RIGHT; break;
case WXK_HOME: key = SCK_HOME; break;
case WXK_END: key = SCK_END; break;
- case WXK_PAGEUP: // fall through
- case WXK_PRIOR: key = SCK_PRIOR; break;
- case WXK_PAGEDOWN: // fall through
- case WXK_NEXT: key = SCK_NEXT; break;
+ case WXK_PAGEUP: key = SCK_PRIOR; break;
+ case WXK_PAGEDOWN: key = SCK_NEXT; break;
+ case WXK_NUMPAD_DOWN: key = SCK_DOWN; break;
+ case WXK_NUMPAD_UP: key = SCK_UP; break;
+ case WXK_NUMPAD_LEFT: key = SCK_LEFT; break;
+ case WXK_NUMPAD_RIGHT: key = SCK_RIGHT; break;
+ case WXK_NUMPAD_HOME: key = SCK_HOME; break;
+ case WXK_NUMPAD_END: key = SCK_END; break;
+ case WXK_NUMPAD_PAGEUP: key = SCK_PRIOR; break;
+ case WXK_NUMPAD_PAGEDOWN: key = SCK_NEXT; break;
+ case WXK_NUMPAD_DELETE: key = SCK_DELETE; break;
+ case WXK_NUMPAD_INSERT: key = SCK_INSERT; break;
case WXK_DELETE: key = SCK_DELETE; break;
case WXK_INSERT: key = SCK_INSERT; break;
case WXK_ESCAPE: key = SCK_ESCAPE; break;
void ScintillaWX::DoDragLeave() {
SetDragPosition(invalidPosition);
}
-#endif
+#endif // wxUSE_DRAG_AND_DROP
//----------------------------------------------------------------------
// Force the whole window to be repainted