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

Side by Side Diff: app/win/drop_target.h

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

Powered by Google App Engine
This is Rietveld 408576698