Backed out changeset 8517afe50156 (bug 540456) for reftest failures.
[gecko.git] / widget / windows / nsNativeDragTarget.h
blob15a8ff1c4224dab5fb83a15d27a9cd878a7120d3
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 #endif
17 #include "mozilla/Attributes.h"
19 class nsIDragService;
20 class nsIWidget;
22 struct IDataObject;
25 * nsNativeDragTarget implements the IDropTarget interface and gets most of its
26 * behavior from the associated adapter (m_dragDrop).
29 class nsNativeDragTarget MOZ_FINAL : public IDropTarget
31 public:
32 nsNativeDragTarget(nsIWidget * aWidget);
33 ~nsNativeDragTarget();
35 // IUnknown members - see iunknown.h for documentation
36 STDMETHODIMP QueryInterface(REFIID, void**);
37 STDMETHODIMP_(ULONG) AddRef();
38 STDMETHODIMP_(ULONG) Release();
40 // IDataTarget members
42 // Set pEffect based on whether this object can support a drop based on
43 // the data available from pSource, the key and mouse states specified
44 // in grfKeyState, and the coordinates specified by point. This is
45 // called by OLE when a drag enters this object's window (as registered
46 // by Initialize).
47 STDMETHODIMP DragEnter(LPDATAOBJECT pSource, DWORD grfKeyState,
48 POINTL point, DWORD* pEffect);
50 // Similar to DragEnter except it is called frequently while the drag
51 // is over this object's window.
52 STDMETHODIMP DragOver(DWORD grfKeyState, POINTL point, DWORD* pEffect);
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 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
63 // E_FAIL.
64 STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState,
65 POINTL point, DWORD* pEffect);
66 /**
67 * Cancel the current drag session, if any.
69 void DragCancel();
71 protected:
73 void GetGeckoDragAction(DWORD grfKeyState, LPDWORD pdwEffect,
74 uint32_t * aGeckoAction);
75 void ProcessDrag(uint32_t aEventType, DWORD grfKeyState,
76 POINTL pt, DWORD* pdwEffect);
77 void DispatchDragDropEvent(uint32_t aType, POINTL pt);
78 void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource);
80 // Native Stuff
81 ULONG m_cRef; // reference count
82 HWND mHWnd;
83 DWORD mEffectsAllowed;
84 DWORD mEffectsPreferred;
85 bool mTookOwnRef;
87 // Gecko Stuff
88 nsIWidget * mWidget;
89 nsIDragService * mDragService;
90 // Drag target helper
91 IDropTargetHelper * GetDropTargetHelper();
94 private:
95 // Drag target helper
96 IDropTargetHelper * mDropTargetHelper;
99 #endif // _nsNativeDragTarget_h_