Home | History | Annotate | Download | only in base
      1 // Copyright (c) 2006-2008 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_DRAG_SOURCE_H_
      6 #define BASE_BASE_DRAG_SOURCE_H_
      7 
      8 #include <objidl.h>
      9 
     10 #include "base/basictypes.h"
     11 #include "base/ref_counted.h"
     12 
     13 ///////////////////////////////////////////////////////////////////////////////
     14 //
     15 // BaseDragSource
     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.
     21 //
     22 class BaseDragSource : public IDropSource,
     23                        public base::RefCountedThreadSafe<BaseDragSource> {
     24  public:
     25   BaseDragSource();
     26   virtual ~BaseDragSource() { }
     27 
     28   // Stop the drag operation at the next chance we get.  This doesn't
     29   // synchronously stop the drag (since Windows is controlling that),
     30   // but lets us tell Windows to cancel the drag the next chance we get.
     31   void CancelDrag() {
     32     cancel_drag_ = true;
     33   }
     34 
     35   // IDropSource implementation:
     36   HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state);
     37   HRESULT __stdcall GiveFeedback(DWORD effect);
     38 
     39   // IUnknown implementation:
     40   HRESULT __stdcall QueryInterface(const IID& iid, void** object);
     41   ULONG __stdcall AddRef();
     42   ULONG __stdcall Release();
     43 
     44  protected:
     45   virtual void OnDragSourceCancel() { }
     46   virtual void OnDragSourceDrop() { }
     47   virtual void OnDragSourceMove() { }
     48 
     49  private:
     50   // Set to true if we want to cancel the drag operation.
     51   bool cancel_drag_;
     52 
     53   DISALLOW_EVIL_CONSTRUCTORS(BaseDragSource);
     54 };
     55 
     56 #endif  // BASE_BASE_DRAG_SOURCE_H_
     57