droptgt.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/ole/droptgt.h
  3. // Purpose: declaration of the wxDropTarget class
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 06.03.98
  7. // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_OLEDROPTGT_H
  11. #define _WX_OLEDROPTGT_H
  12. #if wxUSE_DRAG_AND_DROP
  13. // ----------------------------------------------------------------------------
  14. // forward declarations
  15. // ----------------------------------------------------------------------------
  16. class wxIDropTarget;
  17. struct wxIDropTargetHelper;
  18. struct IDataObject;
  19. // ----------------------------------------------------------------------------
  20. // An instance of the class wxDropTarget may be associated with any wxWindow
  21. // derived object via SetDropTarget() function. If this is done, the virtual
  22. // methods of wxDropTarget are called when something is dropped on the window.
  23. //
  24. // Note that wxDropTarget is an abstract base class (ABC) and you should derive
  25. // your own class from it implementing pure virtual function in order to use it
  26. // (all of them, including protected ones which are called by the class itself)
  27. // ----------------------------------------------------------------------------
  28. class WXDLLIMPEXP_CORE wxDropTarget : public wxDropTargetBase
  29. {
  30. public:
  31. // ctor & dtor
  32. wxDropTarget(wxDataObject *dataObject = NULL);
  33. virtual ~wxDropTarget();
  34. // normally called by wxWindow on window creation/destruction, but might be
  35. // called `manually' as well. Register() returns true on success.
  36. bool Register(WXHWND hwnd);
  37. void Revoke(WXHWND hwnd);
  38. // provide default implementation for base class pure virtuals
  39. virtual bool OnDrop(wxCoord x, wxCoord y);
  40. virtual bool GetData();
  41. // Can only be called during OnXXX methods.
  42. wxDataFormat GetMatchingPair();
  43. // implementation only from now on
  44. // -------------------------------
  45. // do we accept this kind of data?
  46. bool MSWIsAcceptedData(IDataObject *pIDataSource) const;
  47. // give us the data source from IDropTarget::Drop() - this is later used by
  48. // GetData() when it's called from inside OnData()
  49. void MSWSetDataSource(IDataObject *pIDataSource);
  50. // These functions take care of all things necessary to support native drag
  51. // images.
  52. //
  53. // {Init,End}DragImageSupport() are called during Register/Revoke,
  54. // UpdateDragImageOnXXX() functions are called on the corresponding drop
  55. // target events.
  56. void MSWInitDragImageSupport();
  57. void MSWEndDragImageSupport();
  58. void MSWUpdateDragImageOnData(wxCoord x, wxCoord y, wxDragResult res);
  59. void MSWUpdateDragImageOnDragOver(wxCoord x, wxCoord y, wxDragResult res);
  60. void MSWUpdateDragImageOnEnter(wxCoord x, wxCoord y, wxDragResult res);
  61. void MSWUpdateDragImageOnLeave();
  62. private:
  63. // helper used by IsAcceptedData() and GetData()
  64. wxDataFormat MSWGetSupportedFormat(IDataObject *pIDataSource) const;
  65. wxIDropTarget *m_pIDropTarget; // the pointer to our COM interface
  66. IDataObject *m_pIDataSource; // the pointer to the source data object
  67. wxIDropTargetHelper *m_dropTargetHelper; // the drop target helper
  68. wxDECLARE_NO_COPY_CLASS(wxDropTarget);
  69. };
  70. #endif //wxUSE_DRAG_AND_DROP
  71. #endif //_WX_OLEDROPTGT_H