[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" | ||||
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 12 | #include "base/memory/ref_counted.h" |
[email protected] | ea47b6a | 2011-07-17 19:39:42 | [diff] [blame^] | 13 | #include "ui/ui_api.h" |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 14 | |
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame] | 15 | namespace ui { |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 16 | |
17 | // A base IDropSource implementation. Handles notifications sent by an active | ||||
18 | // drag-drop operation as the user mouses over other drop targets on their | ||||
19 | // system. This object tells Windows whether or not the drag should continue, | ||||
20 | // and supplies the appropriate cursors. | ||||
[email protected] | ea47b6a | 2011-07-17 19:39:42 | [diff] [blame^] | 21 | class UI_API DragSource : public IDropSource, |
22 | public base::RefCountedThreadSafe<DragSource> { | ||||
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 23 | public: |
24 | DragSource(); | ||||
25 | virtual ~DragSource() {} | ||||
26 | |||||
27 | // Stop the drag operation at the next chance we get. This doesn't | ||||
28 | // synchronously stop the drag (since Windows is controlling that), | ||||
29 | // but lets us tell Windows to cancel the drag the next chance we get. | ||||
30 | void CancelDrag() { | ||||
31 | cancel_drag_ = true; | ||||
32 | } | ||||
33 | |||||
34 | // IDropSource implementation: | ||||
35 | HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state); | ||||
36 | HRESULT __stdcall GiveFeedback(DWORD effect); | ||||
37 | |||||
38 | // IUnknown implementation: | ||||
39 | HRESULT __stdcall QueryInterface(const IID& iid, void** object); | ||||
40 | ULONG __stdcall AddRef(); | ||||
41 | ULONG __stdcall Release(); | ||||
42 | |||||
43 | protected: | ||||
44 | virtual void OnDragSourceCancel() {} | ||||
45 | virtual void OnDragSourceDrop() {} | ||||
46 | virtual void OnDragSourceMove() {} | ||||
47 | |||||
48 | private: | ||||
49 | // Set to true if we want to cancel the drag operation. | ||||
50 | bool cancel_drag_; | ||||
51 | |||||
52 | DISALLOW_COPY_AND_ASSIGN(DragSource); | ||||
53 | }; | ||||
54 | |||||
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame] | 55 | } // namespace ui |
[email protected] | 79a4c1e | 2010-10-17 20:44:38 | [diff] [blame] | 56 | |
[email protected] | 02bae0f | 2011-01-19 20:22:00 | [diff] [blame] | 57 | #endif // UI_BASE_DRAGDROP_DRAG_SOURCE_H_ |