[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame^] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame^] | 5 | #ifndef UI_BASE_DRAGDROP_DRAG_SOURCE_H_ |
| 6 | #define UI_BASE_DRAGDROP_DRAG_SOURCE_H_ |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 7 | #pragma once |
| 8 | |
| 9 | #include <objidl.h> |
| 10 | |
| 11 | #include "base/basictypes.h" |
| 12 | #include "base/ref_counted.h" |
| 13 | |
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame^] | 14 | namespace ui { |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 15 | |
| 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 |
| 18 | // system. This object tells Windows whether or not the drag should continue, |
| 19 | // and supplies the appropriate cursors. |
| 20 | class DragSource : public IDropSource, |
| 21 | public base::RefCountedThreadSafe<DragSource> { |
| 22 | public: |
| 23 | DragSource(); |
| 24 | virtual ~DragSource() {} |
| 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 | |
| 33 | // IDropSource implementation: |
| 34 | HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state); |
| 35 | HRESULT __stdcall GiveFeedback(DWORD effect); |
| 36 | |
| 37 | // IUnknown implementation: |
| 38 | HRESULT __stdcall QueryInterface(const IID& iid, void** object); |
| 39 | ULONG __stdcall AddRef(); |
| 40 | ULONG __stdcall Release(); |
| 41 | |
| 42 | protected: |
| 43 | virtual void OnDragSourceCancel() {} |
| 44 | virtual void OnDragSourceDrop() {} |
| 45 | virtual void OnDragSourceMove() {} |
| 46 | |
| 47 | private: |
| 48 | // Set to true if we want to cancel the drag operation. |
| 49 | bool cancel_drag_; |
| 50 | |
| 51 | DISALLOW_COPY_AND_ASSIGN(DragSource); |
| 52 | }; |
| 53 | |
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame^] | 54 | } // namespace ui |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 55 | |
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame^] | 56 | #endif // UI_BASE_DRAGDROP_DRAG_SOURCE_H_ |