widget/windows/nsNativeDragTarget.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/windows/nsNativeDragTarget.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,102 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +#ifndef _nsNativeDragTarget_h_
     1.9 +#define _nsNativeDragTarget_h_
    1.10 +
    1.11 +#include "nsCOMPtr.h"
    1.12 +#include "nsIDragSession.h"
    1.13 +#include <ole2.h>
    1.14 +#include <shlobj.h>
    1.15 +
    1.16 +#ifndef IDropTargetHelper
    1.17 +#include <shobjidl.h> // Vista drag image interfaces
    1.18 +#undef LogSeverity // SetupAPI.h #defines this as DWORD
    1.19 +#endif
    1.20 +
    1.21 +#include "mozilla/Attributes.h"
    1.22 +
    1.23 +class nsIDragService;
    1.24 +class nsIWidget;
    1.25 +
    1.26 +struct IDataObject;
    1.27 +
    1.28 +/*
    1.29 + * nsNativeDragTarget implements the IDropTarget interface and gets most of its
    1.30 + * behavior from the associated adapter (m_dragDrop).
    1.31 + */
    1.32 +
    1.33 +class nsNativeDragTarget MOZ_FINAL : public IDropTarget
    1.34 +{
    1.35 +public:
    1.36 +  nsNativeDragTarget(nsIWidget * aWidget);
    1.37 +  ~nsNativeDragTarget();
    1.38 +
    1.39 +  // IUnknown members - see iunknown.h for documentation
    1.40 +  STDMETHODIMP QueryInterface(REFIID, void**);
    1.41 +  STDMETHODIMP_(ULONG) AddRef();
    1.42 +  STDMETHODIMP_(ULONG) Release();
    1.43 +
    1.44 +  // IDataTarget members
    1.45 +
    1.46 +  // Set pEffect based on whether this object can support a drop based on
    1.47 +  // the data available from pSource, the key and mouse states specified
    1.48 +  // in grfKeyState, and the coordinates specified by point. This is
    1.49 +  // called by OLE when a drag enters this object's window (as registered
    1.50 +  // by Initialize).
    1.51 +  STDMETHODIMP DragEnter(LPDATAOBJECT pSource, DWORD grfKeyState,
    1.52 +                         POINTL point, DWORD* pEffect);
    1.53 +
    1.54 +  // Similar to DragEnter except it is called frequently while the drag
    1.55 +  // is over this object's window.
    1.56 +  STDMETHODIMP DragOver(DWORD grfKeyState, POINTL point, DWORD* pEffect);
    1.57 +
    1.58 +  // Release the drag-drop source and put internal state back to the point
    1.59 +  // before the call to DragEnter. This is called when the drag leaves
    1.60 +  // without a drop occurring.
    1.61 +  STDMETHODIMP DragLeave();
    1.62 +
    1.63 +  // If point is within our region of interest and pSource's data supports
    1.64 +  // one of our formats, get the data and set pEffect according to
    1.65 +  // grfKeyState (DROPEFFECT_MOVE if the control key was not pressed,
    1.66 +  // DROPEFFECT_COPY if the control key was pressed). Otherwise return
    1.67 +  // E_FAIL.
    1.68 +  STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState,
    1.69 +                    POINTL point, DWORD* pEffect);
    1.70 +  /**
    1.71 +   * Cancel the current drag session, if any.
    1.72 +   */
    1.73 +  void DragCancel();
    1.74 +
    1.75 +protected:
    1.76 +
    1.77 +  void GetGeckoDragAction(DWORD grfKeyState, LPDWORD pdwEffect, 
    1.78 +                          uint32_t * aGeckoAction);
    1.79 +  void ProcessDrag(uint32_t aEventType, DWORD grfKeyState,
    1.80 +                   POINTL pt, DWORD* pdwEffect);
    1.81 +  void DispatchDragDropEvent(uint32_t aType, POINTL pt);
    1.82 +  void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource);
    1.83 +
    1.84 +  // Native Stuff
    1.85 +  ULONG            m_cRef;      // reference count
    1.86 +  HWND             mHWnd;
    1.87 +  DWORD            mEffectsAllowed;
    1.88 +  DWORD            mEffectsPreferred;
    1.89 +  bool             mTookOwnRef;
    1.90 +
    1.91 +  // Gecko Stuff
    1.92 +  nsIWidget      * mWidget;
    1.93 +  nsIDragService * mDragService;
    1.94 +  // Drag target helper 
    1.95 +  IDropTargetHelper * GetDropTargetHelper();
    1.96 +
    1.97 +
    1.98 +private:
    1.99 +  // Drag target helper 
   1.100 +  IDropTargetHelper * mDropTargetHelper;
   1.101 +};
   1.102 +
   1.103 +#endif // _nsNativeDragTarget_h_
   1.104 +
   1.105 +

mercurial