OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_BASE_DRAG_SOURCE_H_ | 5 #ifndef BASE_BASE_DRAG_SOURCE_H_ |
6 #define BASE_BASE_DRAG_SOURCE_H_ | 6 #define BASE_BASE_DRAG_SOURCE_H_ |
7 | 7 |
8 #include <objidl.h> | 8 #include <objidl.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 | 11 |
12 /////////////////////////////////////////////////////////////////////////////// | 12 /////////////////////////////////////////////////////////////////////////////// |
13 // | 13 // |
14 // BaseDragSource | 14 // BaseDragSource |
15 // | 15 // |
16 // A base IDropSource implementation. Handles notifications sent by an active | 16 // A base IDropSource implementation. Handles notifications sent by an active |
17 // drag-drop operation as the user mouses over other drop targets on their | 17 // drag-drop operation as the user mouses over other drop targets on their |
18 // system. This object tells Windows whether or not the drag should continue, | 18 // system. This object tells Windows whether or not the drag should continue, |
19 // and supplies the appropriate cursors. | 19 // and supplies the appropriate cursors. |
20 // | 20 // |
21 class BaseDragSource : public IDropSource { | 21 class BaseDragSource : public IDropSource { |
22 public: | 22 public: |
23 BaseDragSource(); | 23 BaseDragSource(); |
24 virtual ~BaseDragSource() { } | 24 virtual ~BaseDragSource() { } |
25 | 25 |
| 26 // Stop the drag operation at the next chance we get. This doesn't |
| 27 // synchronously stop the drag (since Windows is controlling that), |
| 28 // but lets us tell Windows to cancel the drag the next chance we get. |
| 29 void CancelDrag() { |
| 30 cancel_drag_ = true; |
| 31 } |
| 32 |
26 // IDropSource implementation: | 33 // IDropSource implementation: |
27 HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state); | 34 HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state); |
28 HRESULT __stdcall GiveFeedback(DWORD effect); | 35 HRESULT __stdcall GiveFeedback(DWORD effect); |
29 | 36 |
30 // IUnknown implementation: | 37 // IUnknown implementation: |
31 HRESULT __stdcall QueryInterface(const IID& iid, void** object); | 38 HRESULT __stdcall QueryInterface(const IID& iid, void** object); |
32 ULONG __stdcall AddRef(); | 39 ULONG __stdcall AddRef(); |
33 ULONG __stdcall Release(); | 40 ULONG __stdcall Release(); |
34 | 41 |
35 protected: | 42 protected: |
36 virtual void OnDragSourceCancel() { } | 43 virtual void OnDragSourceCancel() { } |
37 virtual void OnDragSourceDrop() { } | 44 virtual void OnDragSourceDrop() { } |
38 virtual void OnDragSourceMove() { } | 45 virtual void OnDragSourceMove() { } |
39 | 46 |
40 private: | 47 private: |
41 LONG ref_count_; | 48 LONG ref_count_; |
42 | 49 |
| 50 // Set to true if we want to cancel the drag operation. |
| 51 bool cancel_drag_; |
| 52 |
43 DISALLOW_EVIL_CONSTRUCTORS(BaseDragSource); | 53 DISALLOW_EVIL_CONSTRUCTORS(BaseDragSource); |
44 }; | 54 }; |
45 | 55 |
46 #endif // BASE_BASE_DRAG_SOURCE_H_ | 56 #endif // BASE_BASE_DRAG_SOURCE_H_ |
OLD | NEW |