]>
Commit | Line | Data |
---|---|---|
bbf1f0e5 KB |
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 license | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | // ============================================================================ | |
13 | // prolog | |
14 | // ============================================================================ | |
15 | #ifndef _OLEDROPTGT_H | |
16 | #define _OLEDROPTGT_H | |
17 | ||
18 | #ifdef __GNUG__ | |
19 | #pragma interface "droptgt.h" | |
20 | #endif | |
21 | ||
22 | #if !USE_DRAG_AND_DROP | |
23 | #error "You should #define USE_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 | typedef unsigned short wxDataFormat; | |
33 | ||
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. | |
38 | // | |
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 | |
44 | { | |
45 | public: | |
46 | // ctor & dtor | |
47 | wxDropTarget(); | |
48 | virtual ~wxDropTarget(); | |
49 | ||
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); | |
54 | ||
55 | // do we accept this kind of data? | |
56 | virtual bool IsAcceptedData(IDataObject *pIDataSource) const; | |
57 | ||
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() { } | |
62 | ||
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; | |
66 | ||
67 | protected: | |
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; | |
75 | ||
76 | private: | |
77 | wxIDropTarget *m_pIDropTarget; // the pointer to COM interface | |
78 | }; | |
79 | ||
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 | |
85 | { | |
86 | public: | |
87 | virtual bool OnDrop(long x, long y, const void *pData); | |
88 | virtual bool OnDropText(long x, long y, const char *psz) = 0; | |
89 | ||
90 | protected: | |
91 | virtual size_t GetFormatCount() const; | |
92 | virtual wxDataFormat GetFormat(size_t n) const; | |
93 | }; | |
94 | ||
95 | // ---------------------------------------------------------------------------- | |
96 | // A drop target which accepts files (dragged from File Manager or Explorer) | |
97 | // ---------------------------------------------------------------------------- | |
98 | class WXDLLEXPORT wxFileDropTarget : public wxDropTarget | |
99 | { | |
100 | public: | |
101 | virtual bool OnDrop(long x, long y, const void *pData); | |
102 | ||
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; | |
106 | ||
107 | protected: | |
108 | virtual size_t GetFormatCount() const; | |
109 | virtual wxDataFormat GetFormat(size_t n) const; | |
110 | }; | |
111 | ||
112 | // ============================================================================ | |
113 | #endif //_OLEDROPTGT_H |