refactor arg_dropfiles with std::filesystem::path
This commit is contained in:
parent
71f57bbf92
commit
f137f751c0
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Definition of General Events
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2018 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2019 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -17,6 +17,7 @@
|
||||
#include <nana/gui/basis.hpp>
|
||||
#include "event_code.hpp"
|
||||
#include "internal_scope_guard.hpp"
|
||||
#include "../../filesystem/filesystem.hpp"
|
||||
#include <type_traits>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
@ -470,9 +471,9 @@ namespace nana
|
||||
|
||||
struct arg_dropfiles : public event_arg
|
||||
{
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
::nana::point pos; ///< cursor position in the event window
|
||||
std::vector<std::string> files; ///< external filenames
|
||||
::nana::window window_handle; ///< A handle to the event window
|
||||
::nana::point pos; ///< cursor position in the event window
|
||||
std::vector<std::filesystem::path> files; ///< external filenames
|
||||
};
|
||||
|
||||
struct arg_expose : public event_arg
|
||||
|
@ -1238,7 +1238,7 @@ namespace detail
|
||||
0, AnyPropertyType, &type, &format, &len,
|
||||
&dummy_bytes_left, &data))
|
||||
{
|
||||
auto files = new std::vector<std::string>;
|
||||
auto files = new std::vector<std::filesystem::path>;
|
||||
std::stringstream ss(reinterpret_cast<char*>(data));
|
||||
|
||||
while(true)
|
||||
@ -1258,7 +1258,7 @@ namespace detail
|
||||
break;
|
||||
}
|
||||
|
||||
files->push_back(file);
|
||||
files->emplace_back(file);
|
||||
}
|
||||
|
||||
if(files->size())
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <vector>
|
||||
#include <nana/deploy.hpp>
|
||||
#include <nana/filesystem/filesystem.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
@ -29,7 +30,7 @@ namespace detail
|
||||
Window window;
|
||||
int x;
|
||||
int y;
|
||||
std::vector<std::string> * files;
|
||||
std::vector<std::filesystem::path> * files;
|
||||
}mouse_drop;
|
||||
}u;
|
||||
};
|
||||
|
@ -1149,10 +1149,10 @@ namespace detail
|
||||
std::unique_ptr<wchar_t[]> varbuf;
|
||||
std::size_t bufsize = 0;
|
||||
|
||||
unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, 0, 0);
|
||||
unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, nullptr, 0);
|
||||
for(unsigned i = 0; i < size; ++i)
|
||||
{
|
||||
unsigned reqlen = ::DragQueryFile(drop, i, 0, 0) + 1;
|
||||
unsigned reqlen = ::DragQueryFile(drop, i, nullptr, 0) + 1;
|
||||
if(bufsize < reqlen)
|
||||
{
|
||||
varbuf.reset(new wchar_t[reqlen]);
|
||||
@ -1160,8 +1160,7 @@ namespace detail
|
||||
}
|
||||
|
||||
::DragQueryFile(drop, i, varbuf.get(), reqlen);
|
||||
|
||||
dropfiles.files.emplace_back(to_utf8(varbuf.get()));
|
||||
dropfiles.files.emplace_back(varbuf.get());
|
||||
}
|
||||
|
||||
while(msgwnd && (msgwnd->flags.dropable == false))
|
||||
|
Loading…
x
Reference in New Issue
Block a user