Bumping manifests a=b2g-bump
[gecko.git] / widget / windows / nsNativeDragTarget.h
blob431127e91891344dc72c1f690fb3c9503e38de9e
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_
8 #include "nsCOMPtr.h"
9 #include "nsIDragSession.h"
10 #include <ole2.h>
11 #include <shlobj.h>
13 #ifndef IDropTargetHelper
14 #include <shobjidl.h> // Vista drag image interfaces
15 #undef LogSeverity // SetupAPI.h #defines this as DWORD
16 #endif
18 #include "mozilla/Attributes.h"
20 class nsIDragService;
21 class nsIWidget;
23 struct IDataObject;
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
32 public:
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
47 // by Initialize).
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
64 // E_FAIL.
65 STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState,
66 POINTL point, DWORD* pEffect);
67 /**
68 * Cancel the current drag session, if any.
70 void DragCancel();
72 protected:
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);
81 // Native Stuff
82 ULONG m_cRef; // reference count
83 HWND mHWnd;
84 DWORD mEffectsAllowed;
85 DWORD mEffectsPreferred;
86 bool mTookOwnRef;
88 // Gecko Stuff
89 nsIWidget * mWidget;
90 nsIDragService * mDragService;
91 // Drag target helper
92 IDropTargetHelper * GetDropTargetHelper();
95 private:
96 // Drag target helper
97 IDropTargetHelper * mDropTargetHelper;
100 #endif // _nsNativeDragTarget_h_