From 9d071d2a2cec9a7662a02669488569a017f0ea35 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Mon, 13 Feb 2017 21:25:04 -0700 Subject: 8.9 --- wx+/file_drop.cpp | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 wx+/file_drop.cpp (limited to 'wx+/file_drop.cpp') diff --git a/wx+/file_drop.cpp b/wx+/file_drop.cpp new file mode 100755 index 00000000..cab848b9 --- /dev/null +++ b/wx+/file_drop.cpp @@ -0,0 +1,56 @@ +// ***************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl-3.0 * +// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved * +// ***************************************************************************** + +#include "file_drop.h" +#include +#include + + +using namespace zen; + + +const wxEventType zen::EVENT_DROP_FILE = wxNewEventType(); + + + + +namespace +{ +class WindowDropTarget : public wxFileDropTarget +{ +public: + WindowDropTarget(wxWindow& dropWindow) : dropWindow_(dropWindow) {} + +private: + bool OnDropFiles(wxCoord x, wxCoord y, const wxArrayString& fileArray) override + { + /*Linux, MTP: we get an empty file array + => switching to wxTextDropTarget won't help (much): we'd get the format + mtp://[usb:001,002]/Telefonspeicher/Folder/file.txt + instead of + /run/user/1000/gvfs/mtp:host=%5Busb%3A001%2C002%5D/Telefonspeicher/Folder/file.txt + */ + + //wxPoint clientDropPos(x, y) + std::vector filePaths; + for (const wxString& file : fileArray) + filePaths.push_back(utfCvrtTo(file)); + + //create a custom event on drop window: execute event after file dropping is completed! (after mouse is released) + if (wxEvtHandler* handler = dropWindow_.GetEventHandler()) + handler->AddPendingEvent(FileDropEvent(filePaths)); + return true; + } + + wxWindow& dropWindow_; +}; +} + + +void zen::setupFileDrop(wxWindow& wnd) +{ + wnd.SetDropTarget(new WindowDropTarget(wnd)); /*takes ownership*/ +} -- cgit