HWND m_hwnd; // window we're associated with
// get default drop effect for given keyboard flags
- static DWORD GetDropEffect(DWORD flags, wxDragResult defaultAction);
+ static DWORD GetDropEffect(DWORD flags, wxDragResult defaultAction, DWORD pdwEffect);
DECLARE_NO_COPY_CLASS(wxIDropTarget)
};
// Notes : We do "move" normally and "copy" if <Ctrl> is pressed,
// which is the standard behaviour (currently there is no
// way to redefine it)
-DWORD wxIDropTarget::GetDropEffect(DWORD flags, wxDragResult defaultAction)
+DWORD wxIDropTarget::GetDropEffect(DWORD flags,
+ wxDragResult defaultAction,
+ DWORD pdwEffect)
{
- if (defaultAction == wxDragCopy)
- return flags & MK_SHIFT ? DROPEFFECT_MOVE : DROPEFFECT_COPY;
- return flags & MK_CONTROL ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
+ DWORD effectiveAction;
+ if ( defaultAction == wxDragCopy )
+ effectiveAction = flags & MK_SHIFT ? DROPEFFECT_MOVE : DROPEFFECT_COPY;
+ else
+ effectiveAction = flags & MK_CONTROL ? DROPEFFECT_COPY : DROPEFFECT_MOVE;
+
+ if ( !(effectiveAction & pdwEffect) )
+ {
+ // the action is not supported by drag source, fall back to something
+ // that it does support
+ if ( pdwEffect & DROPEFFECT_MOVE )
+ effectiveAction = DROPEFFECT_MOVE;
+ else if ( pdwEffect & DROPEFFECT_COPY )
+ effectiveAction = DROPEFFECT_COPY;
+ else if ( pdwEffect & DROPEFFECT_LINK )
+ effectiveAction = DROPEFFECT_LINK;
+ else
+ effectiveAction = DROPEFFECT_NONE;
+ }
+
+ return effectiveAction;
}
wxIDropTarget::wxIDropTarget(wxDropTarget *pTarget)
// give some visual feedback
*pdwEffect = ConvertDragResultToEffect(
m_pTarget->OnEnter(pt.x, pt.y, ConvertDragEffectToResult(
- GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction()))
+ GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction(), *pdwEffect))
)
);
wxDragResult result;
if ( m_pIDataObject ) {
result = ConvertDragEffectToResult(
- GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction()));
+ GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction(), *pdwEffect));
}
else {
// can't accept data anyhow normally
// that it's the same we've already got in DragEnter
wxASSERT( m_pIDataObject == pIDataSource );
- // by default, nothing happens
- *pdwEffect = DROPEFFECT_NONE;
-
// we need client coordinates to pass to wxWin functions
if ( !ScreenToClient(m_hwnd, (POINT *)&pt) )
{
// and now it has the data
wxDragResult rc = ConvertDragEffectToResult(
- GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction()));
+ GetDropEffect(grfKeyState, m_pTarget->GetDefaultAction(), *pdwEffect));
rc = m_pTarget->OnData(pt.x, pt.y, rc);
if ( wxIsDragResultOk(rc) ) {
// operation succeeded
*pdwEffect = ConvertDragResultToEffect(rc);
}
- //else: *pdwEffect is already DROPEFFECT_NONE
+ else {
+ *pdwEffect = DROPEFFECT_NONE;
+ }
+ }
+ else {
+ // OnDrop() returned false, no need to copy data
+ *pdwEffect = DROPEFFECT_NONE;
}
- //else: OnDrop() returned false, no need to copy data
// release the held object
RELEASE_AND_NULL(m_pIDataObject);