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_
9 #include "nsIDragSession.h"
13 #ifndef IDropTargetHelper
14 #include <shobjidl.h> // Vista drag image interfaces
15 #undef LogSeverity // SetupAPI.h #defines this as DWORD
18 #include "mozilla/Attributes.h"
26 * nsNativeDragTarget implements the IDropTarget interface and gets most of its
27 * behavior from the associated adapter (m_dragDrop).
30 class nsNativeDragTarget MOZ_FINAL
: public IDropTarget
33 nsNativeDragTarget(nsIWidget
* aWidget
);
34 ~nsNativeDragTarget();
36 // IUnknown members - see iunknown.h for documentation
37 STDMETHODIMP
QueryInterface(REFIID
, void**);
38 STDMETHODIMP_(ULONG
) AddRef();
39 STDMETHODIMP_(ULONG
) Release();
41 // IDataTarget members
43 // Set pEffect based on whether this object can support a drop based on
44 // the data available from pSource, the key and mouse states specified
45 // in grfKeyState, and the coordinates specified by point. This is
46 // called by OLE when a drag enters this object's window (as registered
48 STDMETHODIMP
DragEnter(LPDATAOBJECT pSource
, DWORD grfKeyState
,
49 POINTL point
, DWORD
* pEffect
);
51 // Similar to DragEnter except it is called frequently while the drag
52 // is over this object's window.
53 STDMETHODIMP
DragOver(DWORD grfKeyState
, POINTL point
, DWORD
* pEffect
);
55 // Release the drag-drop source and put internal state back to the point
56 // before the call to DragEnter. This is called when the drag leaves
57 // without a drop occurring.
58 STDMETHODIMP
DragLeave();
60 // If point is within our region of interest and pSource's data supports
61 // one of our formats, get the data and set pEffect according to
62 // grfKeyState (DROPEFFECT_MOVE if the control key was not pressed,
63 // DROPEFFECT_COPY if the control key was pressed). Otherwise return
65 STDMETHODIMP
Drop(LPDATAOBJECT pSource
, DWORD grfKeyState
,
66 POINTL point
, DWORD
* pEffect
);
68 * Cancel the current drag session, if any.
74 void GetGeckoDragAction(DWORD grfKeyState
, LPDWORD pdwEffect
,
75 uint32_t * aGeckoAction
);
76 void ProcessDrag(uint32_t aEventType
, DWORD grfKeyState
,
77 POINTL pt
, DWORD
* pdwEffect
);
78 void DispatchDragDropEvent(uint32_t aType
, POINTL pt
);
79 void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource
);
82 ULONG m_cRef
; // reference count
84 DWORD mEffectsAllowed
;
85 DWORD mEffectsPreferred
;
90 nsIDragService
* mDragService
;
92 IDropTargetHelper
* GetDropTargetHelper();
97 IDropTargetHelper
* mDropTargetHelper
;
100 #endif // _nsNativeDragTarget_h_