summaryrefslogtreecommitdiffstats
path: root/app/win
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-19 20:22:00 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-19 20:22:00 +0000
commit02bae0f37e6b09992f3b81792735010f28b9542e (patch)
treeb33485cba2d3f3049d7e801957759b268aa9257e /app/win
parentcfe1d619ca7f651c509ce4a4b52540fd573fbcd3 (diff)
downloadchromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.zip
chromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.tar.gz
chromium_src-02bae0f37e6b09992f3b81792735010f28b9542e.tar.bz2
Move more dnd related files to ui/base
BUG=none TEST=none TBR=brettw Review URL: http://codereview.chromium.org/6250014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/win')
-rw-r--r--app/win/drag_source.cc57
-rw-r--r--app/win/drag_source.h58
-rw-r--r--app/win/drop_target.cc174
-rw-r--r--app/win/drop_target.h136
4 files changed, 0 insertions, 425 deletions
diff --git a/app/win/drag_source.cc b/app/win/drag_source.cc
deleted file mode 100644
index a695a33..0000000
--- a/app/win/drag_source.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/win/drag_source.h"
-
-namespace app {
-namespace win {
-
-DragSource::DragSource() : cancel_drag_(false) {
-}
-
-HRESULT DragSource::QueryContinueDrag(BOOL escape_pressed, DWORD key_state) {
- if (cancel_drag_)
- return DRAGDROP_S_CANCEL;
-
- if (escape_pressed) {
- OnDragSourceCancel();
- return DRAGDROP_S_CANCEL;
- }
-
- if (!(key_state & MK_LBUTTON)) {
- OnDragSourceDrop();
- return DRAGDROP_S_DROP;
- }
-
- OnDragSourceMove();
- return S_OK;
-}
-
-HRESULT DragSource::GiveFeedback(DWORD effect) {
- return DRAGDROP_S_USEDEFAULTCURSORS;
-}
-
-HRESULT DragSource::QueryInterface(const IID& iid, void** object) {
- *object = NULL;
- if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropSource)) {
- *object = this;
- } else {
- return E_NOINTERFACE;
- }
- AddRef();
- return S_OK;
-}
-
-ULONG DragSource::AddRef() {
- base::RefCountedThreadSafe<DragSource>::AddRef();
- return 0;
-}
-
-ULONG DragSource::Release() {
- base::RefCountedThreadSafe<DragSource>::Release();
- return 0;
-}
-
-} // namespace win
-} // namespace app
diff --git a/app/win/drag_source.h b/app/win/drag_source.h
deleted file mode 100644
index 75bee86..0000000
--- a/app/win/drag_source.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APP_WIN_DRAG_SOURCE_H_
-#define APP_WIN_DRAG_SOURCE_H_
-#pragma once
-
-#include <objidl.h>
-
-#include "base/basictypes.h"
-#include "base/ref_counted.h"
-
-namespace app {
-namespace win {
-
-// A base IDropSource implementation. Handles notifications sent by an active
-// drag-drop operation as the user mouses over other drop targets on their
-// system. This object tells Windows whether or not the drag should continue,
-// and supplies the appropriate cursors.
-class DragSource : public IDropSource,
- public base::RefCountedThreadSafe<DragSource> {
- public:
- DragSource();
- virtual ~DragSource() {}
-
- // Stop the drag operation at the next chance we get. This doesn't
- // synchronously stop the drag (since Windows is controlling that),
- // but lets us tell Windows to cancel the drag the next chance we get.
- void CancelDrag() {
- cancel_drag_ = true;
- }
-
- // IDropSource implementation:
- HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state);
- HRESULT __stdcall GiveFeedback(DWORD effect);
-
- // IUnknown implementation:
- HRESULT __stdcall QueryInterface(const IID& iid, void** object);
- ULONG __stdcall AddRef();
- ULONG __stdcall Release();
-
- protected:
- virtual void OnDragSourceCancel() {}
- virtual void OnDragSourceDrop() {}
- virtual void OnDragSourceMove() {}
-
- private:
- // Set to true if we want to cancel the drag operation.
- bool cancel_drag_;
-
- DISALLOW_COPY_AND_ASSIGN(DragSource);
-};
-
-} // namespace win
-} // namespace app
-
-#endif // APP_WIN_DRAG_SOURCE_H_
diff --git a/app/win/drop_target.cc b/app/win/drop_target.cc
deleted file mode 100644
index 6742e19..0000000
--- a/app/win/drop_target.cc
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "app/win/drop_target.h"
-
-#include <shlobj.h>
-
-#include "base/logging.h"
-
-namespace app {
-namespace win {
-
-IDropTargetHelper* DropTarget::cached_drop_target_helper_ = NULL;
-int32 DropTarget::drag_identity_ = 0;
-
-DropTarget::DropTarget(HWND hwnd)
- : hwnd_(hwnd),
- suspended_(false),
- ref_count_(0) {
- DCHECK(hwnd);
- HRESULT result = RegisterDragDrop(hwnd, this);
- DCHECK(SUCCEEDED(result));
-}
-
-DropTarget::~DropTarget() {
-}
-
-// static
-IDropTargetHelper* DropTarget::DropHelper() {
- if (!cached_drop_target_helper_) {
- CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
- IID_IDropTargetHelper,
- reinterpret_cast<void**>(&cached_drop_target_helper_));
- }
- return cached_drop_target_helper_;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// DropTarget, IDropTarget implementation:
-
-HRESULT DropTarget::DragEnter(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect) {
- // Tell the helper that we entered so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper) {
- drop_helper->DragEnter(GetHWND(), data_object,
- reinterpret_cast<POINT*>(&cursor_position), *effect);
- }
-
- // You can't drag and drop within the same HWND.
- if (suspended_) {
- *effect = DROPEFFECT_NONE;
- return S_OK;
- }
-
- // Update the drag identity, skipping 0.
- if (++drag_identity_ == 0)
- ++drag_identity_;
-
- current_data_object_ = data_object;
- POINT screen_pt = { cursor_position.x, cursor_position.y };
- *effect = OnDragEnter(current_data_object_, key_state, screen_pt, *effect);
- return S_OK;
-}
-
-HRESULT DropTarget::DragOver(DWORD key_state,
- POINTL cursor_position,
- DWORD* effect) {
- // Tell the helper that we moved over it so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper)
- drop_helper->DragOver(reinterpret_cast<POINT*>(&cursor_position), *effect);
-
- if (suspended_) {
- *effect = DROPEFFECT_NONE;
- return S_OK;
- }
-
- POINT screen_pt = { cursor_position.x, cursor_position.y };
- *effect = OnDragOver(current_data_object_, key_state, screen_pt, *effect);
- return S_OK;
-}
-
-HRESULT DropTarget::DragLeave() {
- // Tell the helper that we moved out of it so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper)
- drop_helper->DragLeave();
-
- if (suspended_)
- return S_OK;
-
- OnDragLeave(current_data_object_);
-
- current_data_object_ = NULL;
- return S_OK;
-}
-
-HRESULT DropTarget::Drop(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect) {
- // Tell the helper that we dropped onto it so it can update the drag image.
- IDropTargetHelper* drop_helper = DropHelper();
- if (drop_helper) {
- drop_helper->Drop(current_data_object_,
- reinterpret_cast<POINT*>(&cursor_position), *effect);
- }
-
- if (suspended_) {
- *effect = DROPEFFECT_NONE;
- return S_OK;
- }
-
- POINT screen_pt = { cursor_position.x, cursor_position.y };
- *effect = OnDrop(current_data_object_, key_state, screen_pt, *effect);
- return S_OK;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// DropTarget, IUnknown implementation:
-
-HRESULT DropTarget::QueryInterface(const IID& iid, void** object) {
- *object = NULL;
- if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDropTarget)) {
- *object = this;
- } else {
- return E_NOINTERFACE;
- }
- AddRef();
- return S_OK;
-}
-
-ULONG DropTarget::AddRef() {
- return ++ref_count_;
-}
-
-ULONG DropTarget::Release() {
- if (--ref_count_ == 0) {
- delete this;
- return 0U;
- }
- return ref_count_;
-}
-
-DWORD DropTarget::OnDragEnter(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect) {
- return DROPEFFECT_NONE;
-}
-
-DWORD DropTarget::OnDragOver(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect) {
- return DROPEFFECT_NONE;
-}
-
-void DropTarget::OnDragLeave(IDataObject* data_object) {
-}
-
-DWORD DropTarget::OnDrop(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect) {
- return DROPEFFECT_NONE;
-}
-
-} // namespace win
-} // namespace app
diff --git a/app/win/drop_target.h b/app/win/drop_target.h
deleted file mode 100644
index e7dc1ec..0000000
--- a/app/win/drop_target.h
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef APP_WIN_DROP_TARGET_H_
-#define APP_WIN_DROP_TARGET_H_
-#pragma once
-
-#include <objidl.h>
-
-#include "base/ref_counted.h"
-
-// Windows interface.
-struct IDropTargetHelper;
-
-namespace app {
-namespace win {
-
-// A DropTarget implementation that takes care of the nitty gritty
-// of dnd. While this class is concrete, subclasses will most likely
-// want to override various OnXXX methods.
-//
-// Because DropTarget is ref counted you shouldn't delete it directly,
-// rather wrap it in a scoped_refptr. Be sure and invoke RevokeDragDrop(m_hWnd)
-// before the HWND is deleted too.
-//
-// This class is meant to be used in a STA and is not multithread-safe.
-class DropTarget : public IDropTarget {
- public:
- // Create a new DropTarget associating it with the given HWND.
- explicit DropTarget(HWND hwnd);
- virtual ~DropTarget();
-
- // When suspended is set to |true|, the drop target does not receive drops
- // from drags initiated within the owning HWND.
- bool suspended() const { return suspended_; }
- void set_suspended(bool suspended) { suspended_ = suspended; }
-
- // IDropTarget implementation:
- HRESULT __stdcall DragEnter(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect);
- HRESULT __stdcall DragOver(DWORD key_state,
- POINTL cursor_position,
- DWORD* effect);
- HRESULT __stdcall DragLeave();
- HRESULT __stdcall Drop(IDataObject* data_object,
- DWORD key_state,
- POINTL cursor_position,
- DWORD* effect);
-
- // IUnknown implementation:
- HRESULT __stdcall QueryInterface(const IID& iid, void** object);
- ULONG __stdcall AddRef();
- ULONG __stdcall Release();
-
- protected:
- // Returns the hosting HWND.
- HWND GetHWND() { return hwnd_; }
-
- // Invoked when the cursor first moves over the hwnd during a dnd session.
- // This should return a bitmask of the supported drop operations:
- // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
- // DROPEFFECT_MOVE.
- virtual DWORD OnDragEnter(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect);
-
- // Invoked when the cursor moves over the window during a dnd session.
- // This should return a bitmask of the supported drop operations:
- // DROPEFFECT_NONE, DROPEFFECT_COPY, DROPEFFECT_LINK and/or
- // DROPEFFECT_MOVE.
- virtual DWORD OnDragOver(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect);
-
- // Invoked when the cursor moves outside the bounds of the hwnd during a
- // dnd session.
- virtual void OnDragLeave(IDataObject* data_object);
-
- // Invoked when the drop ends on the window. This should return the operation
- // that was taken.
- virtual DWORD OnDrop(IDataObject* data_object,
- DWORD key_state,
- POINT cursor_position,
- DWORD effect);
-
- // Return the drag identity.
- static int32 GetDragIdentity() { return drag_identity_; }
-
- private:
- // Returns the cached drop helper, creating one if necessary. The returned
- // object is not addrefed. May return NULL if the object couldn't be created.
- static IDropTargetHelper* DropHelper();
-
- // The data object currently being dragged over this drop target.
- scoped_refptr<IDataObject> current_data_object_;
-
- // A helper object that is used to provide drag image support while the mouse
- // is dragging over the content area.
- //
- // DO NOT ACCESS DIRECTLY! Use DropHelper() instead, which will lazily create
- // this if it doesn't exist yet. This object can take tens of milliseconds to
- // create, and we don't want to block any window opening for this, especially
- // since often, DnD will never be used. Instead, we force this penalty to the
- // first time it is actually used.
- static IDropTargetHelper* cached_drop_target_helper_;
-
- // The drag identity (id). An up-counter that increases when the cursor first
- // moves over the HWND in a DnD session (OnDragEnter). 0 is reserved to mean
- // the "no/unknown" identity, and is used for initialization. The identity is
- // sent to the renderer in drag enter notifications. Note: the identity value
- // is passed over the renderer NPAPI interface to gears, so use int32 instead
- // of int here.
- static int32 drag_identity_;
-
- // The HWND of the source. This HWND is used to determine coordinates for
- // mouse events that are sent to the renderer notifying various drag states.
- HWND hwnd_;
-
- // Whether or not we are currently processing drag notifications for drags
- // initiated in this window.
- bool suspended_;
-
- LONG ref_count_;
-
- DISALLOW_COPY_AND_ASSIGN(DropTarget);
-};
-
-} // namespace win
-} // namespace app
-
-#endif // APP_WIN_DROP_TARGET_H_