fix MinGW warnings of compiling dragdrop.cpp

This commit is contained in:
Jinhao 2019-07-20 11:44:53 +08:00
parent 6ac558e1b7
commit 2e0f29564f

View File

@ -1,7 +1,7 @@
/** /**
* Drag and Drop Implementation * Drag and Drop Implementation
* Nana C++ Library(http://www.nanapro.org) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2018 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2019 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -157,10 +157,16 @@ namespace nana
}; };
#ifdef NANA_WINDOWS #ifdef NANA_WINDOWS
template<typename Interface, const IID& iid> template<typename Interface, const IID& iid>
class win32com_iunknown : public Interface class win32com_iunknown final: public Interface
{ {
public: public:
template<typename ...Args>
win32com_iunknown(Args&& ... args) :
Interface(std::forward<Args>(args)...)
{}
//Implements IUnknown //Implements IUnknown
STDMETHODIMP QueryInterface(REFIID riid, void **ppv) STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{ {
@ -188,6 +194,7 @@ namespace nana
LONG ref_count_{ 1 }; LONG ref_count_{ 1 };
}; };
class win32com_drop_target : public IDropTarget, public dragdrop_session class win32com_drop_target : public IDropTarget, public dragdrop_session
{ {
public: public:
@ -273,10 +280,10 @@ namespace nana
DWORD effect_{ DROPEFFECT_NONE }; DWORD effect_{ DROPEFFECT_NONE };
}; };
class drop_source : public win32com_iunknown<IDropSource, IID_IDropSource> class drop_source_impl : public IDropSource
{ {
public: public:
drop_source(window wd) : drop_source_impl(window wd) :
window_handle_(wd) window_handle_(wd)
{} {}
@ -305,8 +312,10 @@ namespace nana
private: private:
window const window_handle_; window const window_handle_;
}; };
using drop_source = win32com_iunknown<drop_source_impl, IID_IDropSource>;
class win32_dropdata : public win32com_iunknown<IDataObject, IID_IDataObject>
class win32_dropdata_impl: public IDataObject
{ {
public: public:
struct data_entry struct data_entry
@ -563,6 +572,8 @@ namespace nana
std::vector<std::unique_ptr<data_entry>> entries_; std::vector<std::unique_ptr<data_entry>> entries_;
}; };
using win32_dropdata = win32com_iunknown<win32_dropdata_impl, IID_IDataObject>;
#elif defined(NANA_X11) #elif defined(NANA_X11)
class x11_dropdata class x11_dropdata
@ -710,7 +721,7 @@ namespace nana
i->second->set_current_source(drag_wd); i->second->set_current_source(drag_wd);
DWORD result_effect{ DROPEFFECT_NONE }; DWORD result_effect{ DROPEFFECT_NONE };
auto status = ::DoDragDrop(dropdata, drop_src, DROPEFFECT_COPY, &result_effect); ::DoDragDrop(dropdata, drop_src, DROPEFFECT_COPY, &result_effect);
i->second->set_current_source(nullptr); i->second->set_current_source(nullptr);