Implement cursor overriding for DnD on wxQt.
This uses the cursor variant (as opposed to the icon one) since these actually are cursors, the base class looks like cursors are meant to be used, and the icon thing looks like a hack.
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
#ifndef _WX_QT_DND_H_
|
#ifndef _WX_QT_DND_H_
|
||||||
#define _WX_QT_DND_H_
|
#define _WX_QT_DND_H_
|
||||||
|
|
||||||
#define wxDROP_ICON(name) wxICON(name)
|
#define wxDROP_ICON(name) wxCursor(name##_xpm)
|
||||||
|
|
||||||
class WXDLLIMPEXP_CORE wxDropTarget : public wxDropTargetBase
|
class WXDLLIMPEXP_CORE wxDropTarget : public wxDropTargetBase
|
||||||
{
|
{
|
||||||
@@ -34,15 +34,15 @@ class WXDLLIMPEXP_CORE wxDropSource: public wxDropSourceBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxDropSource( wxWindow *win = NULL,
|
wxDropSource( wxWindow *win = NULL,
|
||||||
const wxIcon © = wxNullIcon,
|
const wxCursor © = wxNullCursor,
|
||||||
const wxIcon &move = wxNullIcon,
|
const wxCursor &move = wxNullCursor,
|
||||||
const wxIcon &none = wxNullIcon);
|
const wxCursor &none = wxNullCursor);
|
||||||
|
|
||||||
wxDropSource( wxDataObject& data,
|
wxDropSource( wxDataObject& data,
|
||||||
wxWindow *win,
|
wxWindow *win,
|
||||||
const wxIcon © = wxNullIcon,
|
const wxCursor © = wxNullCursor,
|
||||||
const wxIcon &move = wxNullIcon,
|
const wxCursor &move = wxNullCursor,
|
||||||
const wxIcon &none = wxNullIcon);
|
const wxCursor &none = wxNullCursor);
|
||||||
|
|
||||||
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly);
|
||||||
|
|
||||||
|
@@ -81,6 +81,12 @@ namespace
|
|||||||
|
|
||||||
return mimeData;
|
return mimeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetDragCursor(QDrag& drag, const wxCursor& cursor, Qt::DropAction action)
|
||||||
|
{
|
||||||
|
if ( cursor.IsOk() )
|
||||||
|
drag.setDragCursor(cursor.GetHandle().pixmap(), action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -310,19 +316,21 @@ void wxDropTarget::Disconnect()
|
|||||||
//##############################################################################
|
//##############################################################################
|
||||||
|
|
||||||
wxDropSource::wxDropSource(wxWindow *win,
|
wxDropSource::wxDropSource(wxWindow *win,
|
||||||
const wxIcon &WXUNUSED(copy),
|
const wxCursor ©,
|
||||||
const wxIcon &WXUNUSED(move),
|
const wxCursor &move,
|
||||||
const wxIcon &WXUNUSED(none))
|
const wxCursor &none)
|
||||||
: m_parentWindow(win)
|
: wxDropSourceBase(copy, move, none),
|
||||||
|
m_parentWindow(win)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxDropSource::wxDropSource(wxDataObject& data,
|
wxDropSource::wxDropSource(wxDataObject& data,
|
||||||
wxWindow *win,
|
wxWindow *win,
|
||||||
const wxIcon &WXUNUSED(copy),
|
const wxCursor ©,
|
||||||
const wxIcon &WXUNUSED(move),
|
const wxCursor &move,
|
||||||
const wxIcon &WXUNUSED(none))
|
const wxCursor &none)
|
||||||
: m_parentWindow(win)
|
: wxDropSourceBase(copy, move, none),
|
||||||
|
m_parentWindow(win)
|
||||||
{
|
{
|
||||||
SetData(data);
|
SetData(data);
|
||||||
}
|
}
|
||||||
@@ -335,6 +343,10 @@ wxDragResult wxDropSource::DoDragDrop(int flags /*=wxDrag_CopyOnly*/)
|
|||||||
QDrag drag(m_parentWindow->GetHandle());
|
QDrag drag(m_parentWindow->GetHandle());
|
||||||
drag.setMimeData(CreateMimeData(m_data));
|
drag.setMimeData(CreateMimeData(m_data));
|
||||||
|
|
||||||
|
SetDragCursor(drag, m_cursorCopy, Qt::CopyAction);
|
||||||
|
SetDragCursor(drag, m_cursorMove, Qt::MoveAction);
|
||||||
|
SetDragCursor(drag, m_cursorStop, Qt::IgnoreAction);
|
||||||
|
|
||||||
Qt::DropActions actions = Qt::CopyAction | Qt::MoveAction;
|
Qt::DropActions actions = Qt::CopyAction | Qt::MoveAction;
|
||||||
Qt::DropAction defaultAction = Qt::CopyAction;
|
Qt::DropAction defaultAction = Qt::CopyAction;
|
||||||
switch ( flags )
|
switch ( flags )
|
||||||
|
Reference in New Issue
Block a user