blob: 1ae16567a0954adbfc94667b6c0ef7245fff4d90 [file] [log] [blame]
[email protected]02bae0f2011-01-19 20:22:001// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]79a4c1e2010-10-17 20:44:382// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]02bae0f2011-01-19 20:22:005#ifndef UI_BASE_DRAGDROP_DRAG_SOURCE_H_
6#define UI_BASE_DRAGDROP_DRAG_SOURCE_H_
[email protected]79a4c1e2010-10-17 20:44:387#pragma once
8
9#include <objidl.h>
10
11#include "base/basictypes.h"
12#include "base/ref_counted.h"
13
[email protected]02bae0f2011-01-19 20:22:0014namespace ui {
[email protected]79a4c1e2010-10-17 20:44:3815
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.
20class 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]02bae0f2011-01-19 20:22:0054} // namespace ui
[email protected]79a4c1e2010-10-17 20:44:3855
[email protected]02bae0f2011-01-19 20:22:0056#endif // UI_BASE_DRAGDROP_DRAG_SOURCE_H_