|
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_ |
|
7 |
|
8 #include "nsCOMPtr.h" |
|
9 #include "nsIDragSession.h" |
|
10 #include <ole2.h> |
|
11 #include <shlobj.h> |
|
12 |
|
13 #ifndef IDropTargetHelper |
|
14 #include <shobjidl.h> // Vista drag image interfaces |
|
15 #undef LogSeverity // SetupAPI.h #defines this as DWORD |
|
16 #endif |
|
17 |
|
18 #include "mozilla/Attributes.h" |
|
19 |
|
20 class nsIDragService; |
|
21 class nsIWidget; |
|
22 |
|
23 struct IDataObject; |
|
24 |
|
25 /* |
|
26 * nsNativeDragTarget implements the IDropTarget interface and gets most of its |
|
27 * behavior from the associated adapter (m_dragDrop). |
|
28 */ |
|
29 |
|
30 class nsNativeDragTarget MOZ_FINAL : public IDropTarget |
|
31 { |
|
32 public: |
|
33 nsNativeDragTarget(nsIWidget * aWidget); |
|
34 ~nsNativeDragTarget(); |
|
35 |
|
36 // IUnknown members - see iunknown.h for documentation |
|
37 STDMETHODIMP QueryInterface(REFIID, void**); |
|
38 STDMETHODIMP_(ULONG) AddRef(); |
|
39 STDMETHODIMP_(ULONG) Release(); |
|
40 |
|
41 // IDataTarget members |
|
42 |
|
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); |
|
50 |
|
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); |
|
54 |
|
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(); |
|
59 |
|
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. |
|
69 */ |
|
70 void DragCancel(); |
|
71 |
|
72 protected: |
|
73 |
|
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); |
|
80 |
|
81 // Native Stuff |
|
82 ULONG m_cRef; // reference count |
|
83 HWND mHWnd; |
|
84 DWORD mEffectsAllowed; |
|
85 DWORD mEffectsPreferred; |
|
86 bool mTookOwnRef; |
|
87 |
|
88 // Gecko Stuff |
|
89 nsIWidget * mWidget; |
|
90 nsIDragService * mDragService; |
|
91 // Drag target helper |
|
92 IDropTargetHelper * GetDropTargetHelper(); |
|
93 |
|
94 |
|
95 private: |
|
96 // Drag target helper |
|
97 IDropTargetHelper * mDropTargetHelper; |
|
98 }; |
|
99 |
|
100 #endif // _nsNativeDragTarget_h_ |
|
101 |
|
102 |