1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef _nsNativeDragTarget_h_
6 #define _nsNativeDragTarget_h_
12 #ifndef IDropTargetHelper
13 # include <shobjidl.h> // Vista drag image interfaces
14 # undef LogSeverity // SetupAPI.h #defines this as DWORD
17 #include "mozilla/Attributes.h"
18 #include "mozilla/EventForwards.h"
24 * nsNativeDragTarget implements the IDropTarget interface and gets most of its
25 * behavior from the associated adapter (m_dragDrop).
28 class nsNativeDragTarget final
: public IDropTarget
{
30 explicit nsNativeDragTarget(nsIWidget
* aWidget
);
31 ~nsNativeDragTarget();
33 // IUnknown members - see iunknown.h for documentation
34 STDMETHODIMP
QueryInterface(REFIID
, void**);
35 STDMETHODIMP_(ULONG
) AddRef();
36 STDMETHODIMP_(ULONG
) Release();
38 // IDataTarget members
40 // Set pEffect based on whether this object can support a drop based on
41 // the data available from pSource, the key and mouse states specified
42 // in grfKeyState, and the coordinates specified by point. This is
43 // called by OLE when a drag enters this object's window (as registered
45 STDMETHODIMP
DragEnter(LPDATAOBJECT pSource
, DWORD grfKeyState
, POINTL point
,
48 // Similar to DragEnter except it is called frequently while the drag
49 // is over this object's window.
50 MOZ_CAN_RUN_SCRIPT_BOUNDARY STDMETHODIMP
DragOver(DWORD grfKeyState
,
54 // Release the drag-drop source and put internal state back to the point
55 // before the call to DragEnter. This is called when the drag leaves
56 // without a drop occurring.
57 MOZ_CAN_RUN_SCRIPT_BOUNDARY STDMETHODIMP
DragLeave();
59 // If point is within our region of interest and pSource's data supports
60 // one of our formats, get the data and set pEffect according to
61 // grfKeyState (DROPEFFECT_MOVE if the control key was not pressed,
62 // DROPEFFECT_COPY if the control key was pressed). Otherwise return
64 MOZ_CAN_RUN_SCRIPT_BOUNDARY STDMETHODIMP
Drop(LPDATAOBJECT pSource
,
65 DWORD grfKeyState
, POINTL point
,
68 * Cancel the current drag session, if any.
70 MOZ_CAN_RUN_SCRIPT_BOUNDARY
void DragCancel();
72 static void DragImageChanged() { gDragImageChanged
= true; }
75 void GetGeckoDragAction(DWORD grfKeyState
, LPDWORD pdwEffect
,
76 uint32_t* aGeckoAction
);
77 void ProcessDrag(mozilla::EventMessage aEventMessage
, DWORD grfKeyState
,
78 POINTL pt
, DWORD
* pdwEffect
);
79 void DispatchDragDropEvent(mozilla::EventMessage aEventMessage
,
81 void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource
);
84 ULONG m_cRef
; // reference count
86 DWORD mEffectsAllowed
;
87 DWORD mEffectsPreferred
;
92 nsCOMPtr
<nsIDragService
> mDragService
;
94 IDropTargetHelper
* GetDropTargetHelper();
98 IDropTargetHelper
* mDropTargetHelper
;
100 static bool gDragImageChanged
;
103 #endif // _nsNativeDragTarget_h_