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 licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
15 #ifndef _WX_OLEDROPTGT_H
16 #define _WX_OLEDROPTGT_H
19 #pragma interface "droptgt.h"
22 #if !wxUSE_DRAG_AND_DROP
23 #error "You should #define wxUSE_DRAG_AND_DROP to 1 to compile this file!"
26 // ----------------------------------------------------------------------------
27 // forward declarations
28 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
33 // An instance of the class wxDropTarget may be associated with any wxWindow
34 // derived object via SetDropTarget() function. If this is done, the virtual
35 // methods of wxDropTarget are called when something is dropped on the window.
37 // Note that wxDropTarget is an abstract base class (ABC) and you should derive
38 // your own class from it implementing pure virtual function in order to use it
39 // (all of them, including protected ones which are called by the class itself)
40 // ----------------------------------------------------------------------------
41 class WXDLLEXPORT wxDropTarget
46 virtual ~wxDropTarget();
48 // normally called by wxWindow on window creation/destruction, but might be
49 // called `manually' as well. Register() returns true on success.
50 bool Register(WXHWND hwnd
);
51 void Revoke(WXHWND hwnd
);
53 // do we accept this kind of data?
54 virtual bool IsAcceptedData(IDataObject
*pIDataSource
) const;
56 // called when mouse enters/leaves the window: might be used to give
57 // some visual feedback to the user
58 virtual void OnEnter() { }
59 virtual void OnLeave() { }
61 // this function is called when data is dropped.
62 // (x, y) are the coordinates of the drop
63 virtual bool OnDrop(long x
, long y
, const void *pData
) = 0;
66 // Override these to indicate what kind of data you support: the first
67 // format to which data can be converted is used. The classes below show
68 // how it can be done in the simplest cases.
69 // how many different (clipboard) formats do you support?
70 virtual size_t GetFormatCount() const = 0;
71 // return the n-th supported format
72 virtual wxDataFormat
GetFormat(size_t n
) const = 0;
75 wxIDropTarget
*m_pIDropTarget
; // the pointer to COM interface
78 // ----------------------------------------------------------------------------
79 // A simple wxDropTarget derived class for text data: you only need to
80 // override OnDropText() to get something working
81 // ----------------------------------------------------------------------------
82 class WXDLLEXPORT wxTextDropTarget
: public wxDropTarget
85 virtual bool OnDrop(long x
, long y
, const void *pData
);
86 virtual bool OnDropText(long x
, long y
, const wxChar
*psz
) = 0;
89 virtual size_t GetFormatCount() const;
90 virtual wxDataFormat
GetFormat(size_t n
) const;
93 // ----------------------------------------------------------------------------
94 // A drop target which accepts files (dragged from File Manager or Explorer)
95 // ----------------------------------------------------------------------------
96 class WXDLLEXPORT wxFileDropTarget
: public wxDropTarget
99 virtual bool OnDrop(long x
, long y
, const void *pData
);
101 // params: the number of files and the array of file names
102 virtual bool OnDropFiles(long x
, long y
,
103 size_t nFiles
, const wxChar
* const aszFiles
[]) = 0;
106 virtual size_t GetFormatCount() const;
107 virtual wxDataFormat
GetFormat(size_t n
) const;
110 // ============================================================================
111 #endif //_WX_OLEDROPTGT_H