};
-
+#if wxUSE_DRAG_AND_DROP
bool wxSTCDropTarget::OnDropText(wxCoord x, wxCoord y, const wxString& data) {
return swx->DoDropText(x, y, data);
}
void wxSTCDropTarget::OnLeave() {
swx->DoDragLeave();
}
+#endif
class wxSTCCallTip : public wxWindow {
void ScintillaWX::Initialise() {
//ScintillaBase::Initialise();
+#if wxUSE_DRAG_AND_DROP
dropTarget = new wxSTCDropTarget;
dropTarget->SetScintilla(this);
stc->SetDropTarget(dropTarget);
+#endif
}
void ScintillaWX::StartDrag() {
- wxDropSource source(wMain.GetID());
- wxTextDataObject data(dragChars);
- wxDragResult result;
-
- source.SetData(data);
- result = source.DoDragDrop(TRUE);
- if (result == wxDragMove && dropWentOutside)
- ClearSelection();
- inDragDrop = FALSE;
- SetDragPosition(invalidPosition);
+#if wxUSE_DRAG_AND_DROP
+ wxString dragText(drag.s, drag.len);
+
+ // Send an event to allow the drag text to be changed
+ wxStyledTextEvent evt(wxEVT_STC_START_DRAG, stc->GetId());
+ evt.SetEventObject(stc);
+ evt.SetDragText(dragText);
+ evt.SetDragAllowMove(TRUE);
+ evt.SetPosition(wxMin(stc->GetSelectionStart(),
+ stc->GetSelectionEnd()));
+ stc->GetEventHandler()->ProcessEvent(evt);
+ dragText = evt.GetDragText();
+
+ if (dragText.Length()) {
+ wxDropSource source(wMain.GetID());
+ wxTextDataObject data(dragText);
+ wxDragResult result;
+
+ source.SetData(data);
+ dropWentOutside = TRUE;
+ result = source.DoDragDrop(evt.GetDragAllowMove());
+ if (result == wxDragMove && dropWentOutside)
+ ClearSelection();
+ inDragDrop = FALSE;
+ SetDragPosition(invalidPosition);
+ }
+#endif
}
void ScintillaWX::Copy() {
if (currentPos != anchor) {
- char* text = CopySelectionRange();
+ SelectionText st;
+ CopySelectionRange(&st);
wxTheClipboard->Open();
- wxTheClipboard->SetData(new wxTextDataObject(text));
+ wxTheClipboard->SetData(new wxTextDataObject(wxString(st.s, st.len)));
wxTheClipboard->Close();
}
}
ClearSelection();
wxTextDataObject data;
- bool canPaste;
+ bool gotData;
wxTheClipboard->Open();
- canPaste = wxTheClipboard->GetData(data);
+ gotData = wxTheClipboard->GetData(data);
wxTheClipboard->Close();
- if (canPaste) {
+ if (gotData) {
wxString str = data.GetText();
int len = str.Length();
pdoc->InsertString(currentPos, str.c_str(), len);
bool ScintillaWX::CanPaste() {
- wxTextDataObject data;
bool canPaste;
wxTheClipboard->Open();
- canPaste = wxTheClipboard->GetData(data);
+ canPaste = wxTheClipboard->IsSupported( wxDF_TEXT );
wxTheClipboard->Close();
return canPaste;
void ScintillaWX::DoAddChar(char ch) {
- //bool acActiveBeforeCharAdded = ac.Active();
AddChar(ch);
- //if (acActiveBeforeCharAdded)
- // AutoCompleteChanged(ch);
}
int ScintillaWX::DoKeyDown(int key, bool shift, bool ctrl, bool alt, bool* consumed) {
int rv = KeyDown(key, shift, ctrl, alt, consumed);
-// printf("key: %d shift: %d ctrl: %d alt: %d rv: %d consumed: %d\n",
-// key, shift, ctrl, alt, rv, *consumed);
-
if (key)
return rv;
else
//----------------------------------------------------------------------
+#if wxUSE_DRAG_AND_DROP
bool ScintillaWX::DoDropText(long x, long y, const wxString& data) {
SetDragPosition(invalidPosition);
- int movePos = PositionFromLocation(Point(x,y));
- DropAt(movePos, data, dragResult == wxDragMove, FALSE); // TODO: rectangular?
- return TRUE;
+
+ // Send an event to allow the drag details to be changed
+ wxStyledTextEvent evt(wxEVT_STC_DO_DROP, stc->GetId());
+ evt.SetEventObject(stc);
+ evt.SetDragResult(dragResult);
+ evt.SetX(x);
+ evt.SetY(y);
+ evt.SetPosition(PositionFromLocation(Point(x,y)));
+ evt.SetDragText(data);
+ stc->GetEventHandler()->ProcessEvent(evt);
+
+ dragResult = evt.GetDragResult();
+ if (dragResult == wxDragMove || dragResult == wxDragCopy) {
+ DropAt(evt.GetPosition(),
+ evt.GetDragText(),
+ dragResult == wxDragMove,
+ FALSE); // TODO: rectangular?
+ return TRUE;
+ }
+ return FALSE;
}
wxDragResult ScintillaWX::DoDragEnter(wxCoord x, wxCoord y, wxDragResult def) {
- return def;
+ dragResult = def;
+ return dragResult;
}
wxDragResult ScintillaWX::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
SetDragPosition(PositionFromLocation(Point(x, y)));
- dragResult = def;
- return def;
+
+ // Send an event to allow the drag result to be changed
+ wxStyledTextEvent evt(wxEVT_STC_DRAG_OVER, stc->GetId());
+ evt.SetEventObject(stc);
+ evt.SetDragResult(def);
+ evt.SetX(x);
+ evt.SetY(y);
+ evt.SetPosition(PositionFromLocation(Point(x,y)));
+ stc->GetEventHandler()->ProcessEvent(evt);
+
+ dragResult = evt.GetDragResult();
+ return dragResult;
}
void ScintillaWX::DoDragLeave() {
SetDragPosition(invalidPosition);
}
-
+#endif
//----------------------------------------------------------------------
// Redraw all of text area. This paint will not be abandoned.