michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #ifndef _nsNativeDragTarget_h_ michael@0: #define _nsNativeDragTarget_h_ michael@0: michael@0: #include "nsCOMPtr.h" michael@0: #include "nsIDragSession.h" michael@0: #include michael@0: #include michael@0: michael@0: #ifndef IDropTargetHelper michael@0: #include // Vista drag image interfaces michael@0: #undef LogSeverity // SetupAPI.h #defines this as DWORD michael@0: #endif michael@0: michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsIDragService; michael@0: class nsIWidget; michael@0: michael@0: struct IDataObject; michael@0: michael@0: /* michael@0: * nsNativeDragTarget implements the IDropTarget interface and gets most of its michael@0: * behavior from the associated adapter (m_dragDrop). michael@0: */ michael@0: michael@0: class nsNativeDragTarget MOZ_FINAL : public IDropTarget michael@0: { michael@0: public: michael@0: nsNativeDragTarget(nsIWidget * aWidget); michael@0: ~nsNativeDragTarget(); michael@0: michael@0: // IUnknown members - see iunknown.h for documentation michael@0: STDMETHODIMP QueryInterface(REFIID, void**); michael@0: STDMETHODIMP_(ULONG) AddRef(); michael@0: STDMETHODIMP_(ULONG) Release(); michael@0: michael@0: // IDataTarget members michael@0: michael@0: // Set pEffect based on whether this object can support a drop based on michael@0: // the data available from pSource, the key and mouse states specified michael@0: // in grfKeyState, and the coordinates specified by point. This is michael@0: // called by OLE when a drag enters this object's window (as registered michael@0: // by Initialize). michael@0: STDMETHODIMP DragEnter(LPDATAOBJECT pSource, DWORD grfKeyState, michael@0: POINTL point, DWORD* pEffect); michael@0: michael@0: // Similar to DragEnter except it is called frequently while the drag michael@0: // is over this object's window. michael@0: STDMETHODIMP DragOver(DWORD grfKeyState, POINTL point, DWORD* pEffect); michael@0: michael@0: // Release the drag-drop source and put internal state back to the point michael@0: // before the call to DragEnter. This is called when the drag leaves michael@0: // without a drop occurring. michael@0: STDMETHODIMP DragLeave(); michael@0: michael@0: // If point is within our region of interest and pSource's data supports michael@0: // one of our formats, get the data and set pEffect according to michael@0: // grfKeyState (DROPEFFECT_MOVE if the control key was not pressed, michael@0: // DROPEFFECT_COPY if the control key was pressed). Otherwise return michael@0: // E_FAIL. michael@0: STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState, michael@0: POINTL point, DWORD* pEffect); michael@0: /** michael@0: * Cancel the current drag session, if any. michael@0: */ michael@0: void DragCancel(); michael@0: michael@0: protected: michael@0: michael@0: void GetGeckoDragAction(DWORD grfKeyState, LPDWORD pdwEffect, michael@0: uint32_t * aGeckoAction); michael@0: void ProcessDrag(uint32_t aEventType, DWORD grfKeyState, michael@0: POINTL pt, DWORD* pdwEffect); michael@0: void DispatchDragDropEvent(uint32_t aType, POINTL pt); michael@0: void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource); michael@0: michael@0: // Native Stuff michael@0: ULONG m_cRef; // reference count michael@0: HWND mHWnd; michael@0: DWORD mEffectsAllowed; michael@0: DWORD mEffectsPreferred; michael@0: bool mTookOwnRef; michael@0: michael@0: // Gecko Stuff michael@0: nsIWidget * mWidget; michael@0: nsIDragService * mDragService; michael@0: // Drag target helper michael@0: IDropTargetHelper * GetDropTargetHelper(); michael@0: michael@0: michael@0: private: michael@0: // Drag target helper michael@0: IDropTargetHelper * mDropTargetHelper; michael@0: }; michael@0: michael@0: #endif // _nsNativeDragTarget_h_ michael@0: michael@0: