|
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 _nsNativeDragSource_h_ |
|
6 #define _nsNativeDragSource_h_ |
|
7 |
|
8 #include "nscore.h" |
|
9 #include "nsIDOMDataTransfer.h" |
|
10 #include "nsCOMPtr.h" |
|
11 #include <ole2.h> |
|
12 #include <oleidl.h> |
|
13 #include "mozilla/Attributes.h" |
|
14 |
|
15 //class nsIDragSource; |
|
16 |
|
17 /* |
|
18 * nsNativeDragSource implements the IDropSource interface and gets |
|
19 * most of its behavior from the associated adapter (m_dragDrop). |
|
20 */ |
|
21 class nsNativeDragSource MOZ_FINAL : public IDropSource |
|
22 { |
|
23 public: |
|
24 |
|
25 // construct an nsNativeDragSource referencing adapter |
|
26 // nsNativeDragSource(nsIDragSource * adapter); |
|
27 nsNativeDragSource(nsIDOMDataTransfer* aDataTransfer); |
|
28 ~nsNativeDragSource(); |
|
29 |
|
30 // IUnknown methods - see iunknown.h for documentation |
|
31 |
|
32 STDMETHODIMP QueryInterface(REFIID, void**); |
|
33 STDMETHODIMP_(ULONG) AddRef(); |
|
34 STDMETHODIMP_(ULONG) Release(); |
|
35 |
|
36 // IDropSource methods - see idropsrc.h for documentation |
|
37 |
|
38 // Return DRAGDROP_S_USEDEFAULTCURSORS if this object lets OLE provide |
|
39 // default cursors, otherwise return NOERROR. This method gets called in |
|
40 // response to changes that the target makes to dEffect (DragEnter, |
|
41 // DragOver). |
|
42 STDMETHODIMP GiveFeedback(DWORD dEffect); |
|
43 |
|
44 // This method gets called if there is any change in the mouse or key |
|
45 // state. Return DRAGDROP_S_CANCEL to stop the drag, DRAGDROP_S_DROP |
|
46 // to execute the drop, otherwise NOERROR. |
|
47 STDMETHODIMP QueryContinueDrag(BOOL fESC, DWORD grfKeyState); |
|
48 |
|
49 bool UserCancelled() { return mUserCancelled; } |
|
50 |
|
51 protected: |
|
52 // Reference count |
|
53 ULONG m_cRef; |
|
54 |
|
55 // Data object, hold information about cursor state |
|
56 nsCOMPtr<nsIDOMDataTransfer> mDataTransfer; |
|
57 |
|
58 // Custom drag cursor |
|
59 HCURSOR m_hCursor; |
|
60 |
|
61 // true if the user cancelled the drag by pressing escape |
|
62 bool mUserCancelled; |
|
63 }; |
|
64 |
|
65 #endif // _nsNativeDragSource_h_ |
|
66 |