]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/ole/droptgt.h
Unicode changes.
[wxWidgets.git] / include / wx / msw / ole / droptgt.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: ole/droptgt.h
3 // Purpose: declaration of the wxDropTarget class
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 06.03.98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // prolog
14 // ============================================================================
15 #ifndef _WX_OLEDROPTGT_H
16 #define _WX_OLEDROPTGT_H
17
18 #ifdef __GNUG__
19 #pragma interface "droptgt.h"
20 #endif
21
22 #if !wxUSE_DRAG_AND_DROP
23 #error "You should #define wxUSE_DRAG_AND_DROP to 1 to compile this file!"
24 #endif //WX_DRAG_DROP
25
26 // ----------------------------------------------------------------------------
27 // forward declarations
28 // ----------------------------------------------------------------------------
29 class wxIDropTarget;
30 struct IDataObject;
31
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.
36 //
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
42 {
43 public:
44 // ctor & dtor
45 wxDropTarget();
46 virtual ~wxDropTarget();
47
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);
52
53 // do we accept this kind of data?
54 virtual bool IsAcceptedData(IDataObject *pIDataSource) const;
55
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() { }
60
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;
64
65 protected:
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;
73
74 private:
75 wxIDropTarget *m_pIDropTarget; // the pointer to COM interface
76 };
77
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
83 {
84 public:
85 virtual bool OnDrop(long x, long y, const void *pData);
86 virtual bool OnDropText(long x, long y, const wxChar *psz) = 0;
87
88 protected:
89 virtual size_t GetFormatCount() const;
90 virtual wxDataFormat GetFormat(size_t n) const;
91 };
92
93 // ----------------------------------------------------------------------------
94 // A drop target which accepts files (dragged from File Manager or Explorer)
95 // ----------------------------------------------------------------------------
96 class WXDLLEXPORT wxFileDropTarget : public wxDropTarget
97 {
98 public:
99 virtual bool OnDrop(long x, long y, const void *pData);
100
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;
104
105 protected:
106 virtual size_t GetFormatCount() const;
107 virtual wxDataFormat GetFormat(size_t n) const;
108 };
109
110 // ============================================================================
111 #endif //_WX_OLEDROPTGT_H