Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: base/base_drop_target.h

Issue 3822007: Move BaseDropTarget and BaseDragSource from base to app/win. Remove the "Base... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/base_drag_source.cc ('k') | base/base_drop_target.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef BASE_BASE_DROP_TARGET_H_
6 #define BASE_BASE_DROP_TARGET_H_
7 #pragma once
8
9 #include <objidl.h>
10
11 #include "base/ref_counted.h"
12
13 struct IDropTargetHelper;
14
15 // A DropTarget implementation that takes care of the nitty gritty
16 // of dnd. While this class is concrete, subclasses will most likely
17 // want to override various OnXXX methods.
18 //
19 // Because BaseDropTarget is ref counted you shouldn't delete it directly,
20 // rather wrap it in a scoped_refptr. Be sure and invoke RevokeDragDrop(m_hWnd)
21 // before the HWND is deleted too.
22 //
23 // This class is meant to be used in a STA and is not multithread-safe.
24 class BaseDropTarget : public IDropTarget {
25 public:
26 // Create a new BaseDropTarget associating it with the given HWND.
27 explicit BaseDropTarget(HWND hwnd);
28 virtual ~BaseDropTarget();
29
30 // When suspended is set to |true|, the drop target does not receive drops
31 // from drags initiated within the owning HWND.
32 bool suspended() const { return suspended_; }
33 void set_suspended(bool suspended) { suspended_ = suspended; }
34
35 // IDropTarget implementation:
36 HRESULT __stdcall DragEnter(IDataObject* data_object,
37 DWORD key_state,
38 POINTL cursor_position,
39 DWORD* effect);
40 HRESULT __stdcall DragOver(DWORD key_state,
41 POINTL cursor_position,
42 DWORD* effect);
43 HRESULT __stdcall DragLeave();
44 HRESULT __stdcall Drop(IDataObject* data_object,
45 DWORD key_state,
46 POINTL cursor_position,
47 DWORD* effect);
48
49 // IUnknown implementation:
50 HRESULT __stdcall QueryInterface(const IID& iid, void** object);
51 ULONG __stdcall AddRef();
52 ULONG __stdcall Release();
53
54 protected:
55 // Returns the hosting HWND.
56 HWND GetHWND() { return hwnd_; }
57
58 // Invoked when the cursor first moves over the hwnd during a dnd session.
59 // This should return a bitmask of the supported drop operations:
60 // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
61 // DROPEFFECT_MOVE.
62 virtual DWORD OnDragEnter(IDataObject* data_object,
63 DWORD key_state,
64 POINT cursor_position,
65 DWORD effect);
66
67 // Invoked when the cursor moves over the window during a dnd session.
68 // This should return a bitmask of the supported drop operations:
69 // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
70 // DROPEFFECT_MOVE.
71 virtual DWORD OnDragOver(IDataObject* data_object,
72 DWORD key_state,
73 POINT cursor_position,
74 DWORD effect);
75
76 // Invoked when the cursor moves outside the bounds of the hwnd during a
77 // dnd session.
78 virtual void OnDragLeave(IDataObject* data_object);
79
80 // Invoked when the drop ends on the window. This should return the operation
81 // that was taken.
82 virtual DWORD OnDrop(IDataObject* data_object,
83 DWORD key_state,
84 POINT cursor_position,
85 DWORD effect);
86
87 // Return the drag identity.
88 static int32 GetDragIdentity() { return drag_identity_; }
89
90 private:
91 // Returns the cached drop helper, creating one if necessary. The returned
92 // object is not addrefed. May return NULL if the object couldn't be created.
93 static IDropTargetHelper* DropHelper();
94
95 // The data object currently being dragged over this drop target.
96 scoped_refptr<IDataObject> current_data_object_;
97
98 // A helper object that is used to provide drag image support while the mouse
99 // is dragging over the content area.
100 //
101 // DO NOT ACCESS DIRECTLY! Use DropHelper() instead, which will lazily create
102 // this if it doesn't exist yet. This object can take tens of milliseconds to
103 // create, and we don't want to block any window opening for this, especially
104 // since often, DnD will never be used. Instead, we force this penalty to the
105 // first time it is actually used.
106 static IDropTargetHelper* cached_drop_target_helper_;
107
108 // The drag identity (id). An up-counter that increases when the cursor first
109 // moves over the HWND in a DnD session (OnDragEnter). 0 is reserved to mean
110 // the "no/unknown" identity, and is used for initialization. The identity is
111 // sent to the renderer in drag enter notifications. Note: the identity value
112 // is passed over the renderer NPAPI interface to gears, so use int32 instead
113 // of int here.
114 static int32 drag_identity_;
115
116 // The HWND of the source. This HWND is used to determine coordinates for
117 // mouse events that are sent to the renderer notifying various drag states.
118 HWND hwnd_;
119
120 // Whether or not we are currently processing drag notifications for drags
121 // initiated in this window.
122 bool suspended_;
123
124 LONG ref_count_;
125
126 DISALLOW_COPY_AND_ASSIGN(BaseDropTarget);
127 };
128
129 #endif // BASE_BASE_DROP_TARGET_H_
OLDNEW
« no previous file with comments | « base/base_drag_source.cc ('k') | base/base_drop_target.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698