]>
Commit | Line | Data |
---|---|---|
dface61c JS |
1 | \section{\class{wxDropTarget}}\label{wxdroptarget} |
2 | ||
3 | \overview{Overview}{wxdndoverview} | |
4 | ||
f59d80ca RR |
5 | This class represents a target for a drag and drop operation. A \helpref{wxDataObject}{wxdataobject} |
6 | can be associated with it and by default, this object will be filled with the data from the | |
7 | drag source, if the data formats supported by the data object match the drag source data | |
8 | format. | |
9 | ||
10 | There are various virtual handler functions defined in this class which may be overridden | |
11 | to give visual feedback or react in a more fine-tuned way, e.g. by not accepting data on | |
12 | the whole window area, but only a small portion of it. The normal sequence of calls is | |
13 | \helpref{OnEnter}{wxdroptargetonenter}, possibly many times \helpref{OnDragOver}{wxdroptargetondragover}, | |
14 | \helpref{OnDrop}{wxdroptargetondrop} and finally \helpref{OnData}{wxdroptargetondata}. | |
dface61c JS |
15 | |
16 | \wxheading{Derived from} | |
17 | ||
f59d80ca | 18 | None |
dface61c | 19 | |
954b8ae6 JS |
20 | \wxheading{Include files} |
21 | ||
22 | <wx/dnd.h> | |
23 | ||
f59d80ca RR |
24 | \wxheading{Types} |
25 | ||
26 | \index{wxDragResult}wxDragResult is defined as follows: | |
27 | ||
28 | {\small\begin{verbatim} | |
29 | enum wxDragResult | |
30 | { | |
31 | wxDragError, // error prevented the d&d operation from completing | |
32 | wxDragNone, // drag target didn't accept the data | |
33 | wxDragCopy, // the data was successfully copied | |
34 | wxDragMove, // the data was successfully moved | |
35 | wxDragCancel // the operation was cancelled by user (not an error) | |
36 | }; | |
37 | \end{verbatim} | |
38 | } | |
39 | ||
dface61c JS |
40 | \wxheading{See also} |
41 | ||
42 | \helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDropSource}{wxdropsource}, | |
f59d80ca RR |
43 | \helpref{wxTextDropTarget}{wxtextdroptarget}, \helpref{wxFileDropTarget}{wxfiledroptarget}, |
44 | \helpref{wxDataFormat}{wxdataformat}, \helpref{wxDataObject}{wxdataobject} | |
dface61c JS |
45 | |
46 | \latexignore{\rtfignore{\wxheading{Members}}} | |
47 | ||
48 | \membersection{wxDropTarget::wxDropTarget}\label{wxdroptargetwxdroptarget} | |
49 | ||
f59d80ca | 50 | \func{}{wxDropTarget}{\param{wxDataObject*}{ data = NULL}} |
dface61c | 51 | |
f59d80ca | 52 | Constructor. {\it data} is the data to be associated with the drop target. |
dface61c JS |
53 | |
54 | \membersection{wxDropTarget::\destruct{wxDropTarget}}\label{wxdroptargetdtor} | |
55 | ||
56 | \func{}{\destruct{wxDropTarget}}{\void} | |
57 | ||
f59d80ca | 58 | Destructor. Deletes the associated data object, if any. |
dface61c | 59 | |
f59d80ca | 60 | \membersection{wxDropTarget::GetData}\label{wxdroptargetgetdata} |
dface61c | 61 | |
f59d80ca | 62 | \func{virtual void}{GetData}{\void} |
dface61c | 63 | |
f59d80ca RR |
64 | This method may only be called from within \helpref{OnData}{wxdroptargetondata}. |
65 | By default, this method copies the data from the drop source to the | |
66 | \helpref{wxDataObject}{wxdataobject} associated with this drop target, | |
67 | calling its \helpref{wxDataObject::SetData}{wxdataobjectsetdata} method. | |
dface61c | 68 | |
1fb3eae5 | 69 | \membersection{wxDropTarget::OnData}\label{wxdroptargetondata} |
dface61c | 70 | |
1fb3eae5 | 71 | \func{virtual wxDragResult}{OnData}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxDragResult}{ def}} |
dface61c | 72 | |
f59d80ca RR |
73 | Called after \helpref{OnDrop}{wxdroptargetondrop} returns TRUE. By default this |
74 | will usually \helpref{GetData}{wxdroptargetgetdata} and will return the suggested | |
75 | default value {\it def}. | |
dface61c JS |
76 | |
77 | \membersection{wxDropTarget::OnDrop}\label{wxdroptargetondrop} | |
78 | ||
f59d80ca | 79 | \func{virtual bool}{OnDrop}{\param{wxCoord }{x}, \param{wxCoord }{y}} |
dface61c JS |
80 | |
81 | Called when the user drops a data object on the target. Return FALSE to veto the operation. | |
82 | ||
83 | \wxheading{Parameters} | |
84 | ||
85 | \docparam{x}{The x coordinate of the mouse.} | |
86 | ||
87 | \docparam{y}{The y coordinate of the mouse.} | |
88 | ||
dface61c JS |
89 | \wxheading{Return value} |
90 | ||
91 | Return TRUE to accept the data, FALSE to veto the operation. | |
92 | ||
1fb3eae5 JS |
93 | \membersection{wxDropTarget::OnEnter}\label{wxdroptargetonenter} |
94 | ||
f59d80ca RR |
95 | \func{virtual wxDragResult}{OnEnter}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxDragResult}{ def}} |
96 | ||
97 | Called when the mouse enters the drop target. By default, this calls \helpref{OnDragOver}{wxdroptargetondragover}. | |
98 | ||
99 | \wxheading{Parameters} | |
100 | ||
101 | \docparam{x}{The x coordinate of the mouse.} | |
102 | ||
103 | \docparam{y}{The y coordinate of the mouse.} | |
104 | ||
105 | \docparam{def}{Suggested default for return value. Determined by SHIFT or CONTROL key states.} | |
1fb3eae5 | 106 | |
f59d80ca RR |
107 | \wxheading{Return value} |
108 | ||
109 | Returns the desired operation or {\tt wxDragNone}. This is used for optical feedback | |
110 | from the side of the drop source, typically in form of changing the icon. | |
111 | ||
112 | \membersection{wxDropTarget::OnDragOver}\label{wxdroptargetondragover} | |
113 | ||
114 | \func{virtual wxDragResult}{OnDragOver}{\param{wxCoord}{ x}, \param{wxCoord}{ y}, \param{wxDragResult}{ def}} | |
115 | ||
116 | Called when the mouse is being dragged over the drop target. By default, | |
117 | this calls functions return the suggested return value {\it def}. | |
118 | ||
119 | \wxheading{Parameters} | |
120 | ||
121 | \docparam{x}{The x coordinate of the mouse.} | |
122 | ||
123 | \docparam{y}{The y coordinate of the mouse.} | |
124 | ||
125 | \docparam{def}{Suggested value for return value. Determined by SHIFT or CONTROL key states.} | |
126 | ||
127 | \wxheading{Return value} | |
128 | ||
129 | Returns the desired operation or {\tt wxDragNone}. This is used for optical feedback | |
130 | from the side of the drop source, typically in form of changing the icon. | |
1fb3eae5 | 131 | |
dface61c JS |
132 | \membersection{wxDropTarget::OnLeave}\label{wxdroptargetonleave} |
133 | ||
134 | \func{virtual void}{OnLeave}{\void} | |
135 | ||
136 | Called when the mouse leaves the drop target. | |
b82827dd | 137 | |
f59d80ca RR |
138 | \membersection{wxDropTarget::SetDataObject}\label{wxdroptargetsetdataobject} |
139 | ||
140 | \func{void}{SetDataObject}{\param{wxDataObject*}{ data}} | |
141 | ||
142 | Sets the data \helpref{wxDataObject}{wxdataobject} associated with the | |
143 | drop target and deletes any previously associated data object. |