1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
19 #pragma interface "droptgt.h"
22 #if !USE_DRAG_AND_DROP
23 #error "You should #define USE_DRAG_AND_DROP to 1 to compile this file!"
26 // ----------------------------------------------------------------------------
27 // forward declarations
28 // ----------------------------------------------------------------------------
32 typedef unsigned short wxDataFormat
;
34 // ----------------------------------------------------------------------------
35 // An instance of the class wxDropTarget may be associated with any wxWindow
36 // derived object via SetDropTarget() function. If this is done, the virtual
37 // methods of wxDropTarget are called when something is dropped on the window.
39 // Note that wxDropTarget is an abstract base class (ABC) and you should derive
40 // your own class from it implementing pure virtual function in order to use it
41 // (all of them, including protected ones which are called by the class itself)
42 // ----------------------------------------------------------------------------
43 class WXDLLEXPORT wxDropTarget
48 virtual ~wxDropTarget();
50 // normally called by wxWindow on window creation/destruction, but might be
51 // called `manually' as well. Register() returns true on success.
52 bool Register(WXHWND hwnd
);
53 void Revoke(WXHWND hwnd
);
55 // do we accept this kind of data?
56 virtual bool IsAcceptedData(IDataObject
*pIDataSource
) const;
58 // called when mouse enters/leaves the window: might be used to give
59 // some visual feedback to the user
60 virtual void OnEnter() { }
61 virtual void OnLeave() { }
63 // this function is called when data is dropped.
64 // (x, y) are the coordinates of the drop
65 virtual bool OnDrop(long x
, long y
, const void *pData
) = 0;
68 // Override these to indicate what kind of data you support: the first
69 // format to which data can be converted is used. The classes below show
70 // how it can be done in the simplest cases.
71 // how many different (clipboard) formats do you support?
72 virtual size_t GetFormatCount() const = 0;
73 // return the n-th supported format
74 virtual wxDataFormat
GetFormat(size_t n
) const = 0;
77 wxIDropTarget
*m_pIDropTarget
; // the pointer to COM interface
80 // ----------------------------------------------------------------------------
81 // A simple wxDropTarget derived class for text data: you only need to
82 // override OnDropText() to get something working
83 // ----------------------------------------------------------------------------
84 class WXDLLEXPORT wxTextDropTarget
: public wxDropTarget
87 virtual bool OnDrop(long x
, long y
, const void *pData
);
88 virtual bool OnDropText(long x
, long y
, const char *psz
) = 0;
91 virtual size_t GetFormatCount() const;
92 virtual wxDataFormat
GetFormat(size_t n
) const;
95 // ----------------------------------------------------------------------------
96 // A drop target which accepts files (dragged from File Manager or Explorer)
97 // ----------------------------------------------------------------------------
98 class WXDLLEXPORT wxFileDropTarget
: public wxDropTarget
101 virtual bool OnDrop(long x
, long y
, const void *pData
);
103 // params: the number of files and the array of file names
104 virtual bool OnDropFiles(long x
, long y
,
105 size_t nFiles
, const char * const aszFiles
[]) = 0;
108 virtual size_t GetFormatCount() const;
109 virtual wxDataFormat
GetFormat(size_t n
) const;
112 // ============================================================================
113 #endif //_OLEDROPTGT_H