]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dragimag.tex
typo
[wxWidgets.git] / docs / latex / wx / dragimag.tex
CommitLineData
68be9f09
JS
1\section{\class{wxDragImage}}\label{wxdragimage}
2
3This class is used when you wish to drag an object on the screen,
4and a simple cursor is not enough.
5
576b18f2 6On Windows, the Win32 API is used to achieve smooth dragging. On other platforms,
68be9f09
JS
7wxGenericDragImage is used. Applications may also prefer to use
8wxGenericDragImage on Windows, too.
9
f6bcfd97
BP
10\pythonnote{wxPython uses wxGenericDragImage on all platforms, but
11uses the wxDragImage name.}
12
68be9f09
JS
13To use this class, when you wish to start dragging an image, create a wxDragImage
14object and store it somewhere you can access it as the drag progresses.
15Call BeginDrag to start, and EndDrag to stop the drag. To move the image,
16initially call Show and then Move. If you wish to update the screen contents
17during the drag (for example, highlight an item as in the dragimag sample), first call Hide,
18update the screen, call Move, and then call Show.
19
66eca538
JS
20You can drag within one window, or you can use full-screen dragging
21either across the whole screen, or just restricted to one area
22of the screen to save resources. If you want the user to drag between
23two windows, then you will need to use full-screen dragging.
24
f6bcfd97
BP
25If you wish to draw the image yourself, use wxGenericDragImage and
26override \helpref{wxDragImage::DoDrawImage}{wxdragimagedodrawimage} and
27\helpref{wxDragImage::GetImageRect}{wxdragimagegetimagerect}.
28
68be9f09
JS
29Please see {\tt samples/dragimag} for an example.
30
2b5f62a0
VZ
31%\wxheading{Notes}
32%
33%Using the native Windows implementation, you must supply an image with a mask, or
34%the image will not show when dragged. It is not clear if this is a bug
35%in Windows or in the wxDragImage implementation. You can add a mask
36%with a call to wxImage::SetMaskColour, passing RGB values not likely
37%to be in the image. [CURED by creating the ImageList with ILC_MASK]
38
68be9f09
JS
39\wxheading{Derived from}
40
41\helpref{wxObject}{wxobject}
42
43\wxheading{Include files}
44
45<wx/dragimag.h>\\
46<wx/generic/dragimgg.h>
a7af285d
VZ
47\wxheading{Library}
48
49\helpref{wxCore}{librarieslist}
50
68be9f09
JS
51
52\latexignore{\rtfignore{\wxheading{Members}}}
53
54\membersection{wxDragImage::wxDragImage}\label{wxdragimageconstr}
55
56\func{}{wxDragImage}{\void}
57
58Default constructor.
59
60\func{}{wxDragImage}{\param{const wxBitmap\& }{image}, \param{const wxCursor\& }{cursor = wxNullCursor},
7af3ca16 61 \param{const wxPoint\& }{cursorHotspot = wxPoint(0, 0)}}
68be9f09
JS
62
63Constructs a drag image from a bitmap and optional cursor.
64
65\func{}{wxDragImage}{\param{const wxIcon\& }{image}, \param{const wxCursor\& }{cursor = wxNullCursor},
7af3ca16 66 \param{const wxPoint\& }{cursorHotspot = wxPoint(0, 0)}}
68be9f09
JS
67
68Constructs a drag image from an icon and optional cursor.
69
f6bcfd97
BP
70\pythonnote{This constructor is called wxDragIcon in wxPython.}
71
68be9f09 72\func{}{wxDragImage}{\param{const wxString\& }{text}, \param{const wxCursor\& }{cursor = wxNullCursor},
7af3ca16 73 \param{const wxPoint\& }{cursorHotspot = wxPoint(0, 0)}}
68be9f09
JS
74
75Constructs a drag image from a text string and optional cursor.
76
f6bcfd97
BP
77\pythonnote{This constructor is called wxDragString in wxPython.}
78
68be9f09
JS
79\func{}{wxDragImage}{\param{const wxTreeCtrl\& }{treeCtrl}, \param{wxTreeItemId\& }{id}}
80
81Constructs a drag image from the text in the given tree control item, and optional cursor.
82
f6bcfd97
BP
83\pythonnote{This constructor is called wxDragTreeItem in wxPython.}
84
68be9f09
JS
85\func{}{wxDragImage}{\param{const wxListCtrl\& }{treeCtrl}, \param{long }{id}}
86
87Constructs a drag image from the text in the given tree control item, and optional cursor.
88
f6bcfd97
BP
89\pythonnote{This constructor is called wxDragListItem in wxPython.}
90
91\func{}{wxDragImage}{\param{const wxCursor\& }{cursor = wxNullCursor},
7af3ca16 92 \param{const wxPoint\& }{cursorHotspot = wxPoint(0, 0)}}
f6bcfd97
BP
93
94Constructs a drag image an optional cursor. This constructor is only available for
95wxGenericDragImage, and can be used when the application
96supplies \helpref{wxDragImage::DoDrawImage}{wxdragimagedodrawimage} and \helpref{wxDragImage::GetImageRect}{wxdragimagegetimagerect}.
97
68be9f09
JS
98\wxheading{Parameters}
99
100\docparam{image}{Icon or bitmap to be used as the drag image. The bitmap can
101have a mask.}
102
103\docparam{text}{Text used to construct a drag image.}
104
105\docparam{cursor}{Optional cursor to combine with the image.}
106
aa2d25a5 107\docparam{hotspot}{This parameter is deprecated.}
68be9f09
JS
108
109\docparam{treeCtrl}{Tree control for constructing a tree drag image.}
110
111\docparam{listCtrl}{List control for constructing a list drag image.}
112
113\docparam{id}{Tree or list control item id.}
114
115\membersection{wxDragImage::BeginDrag}\label{wxdragimagebegindrag}
116
cc81d32f 117\func{bool}{BeginDrag}{\param{const wxPoint\& }{hotspot}, \param{wxWindow* }{window}, \param{bool}{ fullScreen = false}, \param{wxRect*}{ rect = NULL}}
68be9f09
JS
118
119Start dragging the image, in a window or full screen.
120
121\func{bool}{BeginDrag}{\param{const wxPoint\& }{hotspot}, \param{wxWindow* }{window}, \param{wxWindow*}{ boundingWindow}}
122
123Start dragging the image, using the first window to capture the mouse and the second
124to specify the bounding area. This form is equivalent to using the first form,
125but more convenient than working out the bounding rectangle explicitly.
126
127You need to then call \helpref{wxDragImage::Show}{wxdragimageshow}
128and \helpref{wxDragImage::Move}{wxdragimagemove} to show the image on the screen.
129
130Call \helpref{wxDragImage::EndDrag}{wxdragimageenddrag} when the drag has finished.
131
132Note that this call automatically calls CaptureMouse.
133
134\wxheading{Parameters}
135
136\docparam{hotspot}{The location of the drag position relative to the upper-left corner
137of the image.}
138
139\docparam{window}{The window that captures the mouse, and within which the dragging
cc81d32f 140is limited unless {\it fullScreen} is true.}
68be9f09
JS
141
142\docparam{boundingWindow}{In the second form of the function, specifies the
143area within which the drag occurs.}
144
cc81d32f 145\docparam{fullScreen}{If true, specifies that the drag will be visible over the full
68be9f09
JS
146screen, or over as much of the screen as is specified by {\it rect}. Note that the mouse will
147still be captured in {\it window}.}
148
149\docparam{rect}{If non-NULL, specifies the rectangle (in screen coordinates) that
150bounds the dragging operation. Specifying this can make the operation more efficient
151by cutting down on the area under consideration, and it can also make a visual difference
152since the drag is clipped to this area.}
153
f6bcfd97
BP
154\membersection{wxDragImage::DoDrawImage}\label{wxdragimagedodrawimage}
155
156\func{virtual bool}{DoDrawImage}{\param{wxDC\&}{ dc}, \param{const wxPoint\&}{ pos}}
157
158Draws the image on the device context with top-left corner at the given position.
159
160This function is only available with wxGenericDragImage, to allow applications to
161draw their own image instead of using an actual bitmap. If you override this function,
162you must also override \helpref{wxDragImage::GetImageRect}{wxdragimagegetimagerect}.
163
68be9f09
JS
164\membersection{wxDragImage::EndDrag}\label{wxdragimageenddrag}
165
166\func{bool}{EndDrag}{\void}
167
168Call this when the drag has finished.
169
170Note that this call automatically calls ReleaseMouse.
171
f6bcfd97
BP
172\membersection{wxDragImage::GetImageRect}\label{wxdragimagegetimagerect}
173
174\constfunc{virtual wxRect}{GetImageRect}{\param{const wxPoint\&}{ pos}}
175
176Returns the rectangle enclosing the image, assuming that the image is drawn with its
177top-left corner at the given point.
178
179This function is available in wxGenericDragImage only, and may be overridden (together with
180\helpref{wxDragImage::DoDrawImage}{wxdragimagedodrawimage}) to provide a virtual drawing capability.
181
68be9f09
JS
182\membersection{wxDragImage::Hide}\label{wxdragimagehide}
183
184\func{bool}{Hide}{\void}
185
186Hides the image. You may wish to call this before updating the window
187contents (perhaps highlighting an item). Then call \helpref{wxDragImage::Move}{wxdragimagemove}
188and \helpref{wxDragImage::Show}{wxdragimageshow}.
189
190\membersection{wxDragImage::Move}\label{wxdragimagemove}
191
192\func{bool}{Move}{\param{const wxPoint\& }{pt}}
193
194Call this to move the image to a new position. The image will only be shown if
195\helpref{wxDragImage::Show}{wxdragimageshow} has been called previously (for example
196at the start of the drag).
197
aa2d25a5 198{\it pt} is the position in client coordinates (relative to the window specified in BeginDrag).
68be9f09
JS
199
200You can move the image either when the image is hidden or shown, but in general dragging
201will be smoother if you move the image when it is shown.
202
203\membersection{wxDragImage::Show}\label{wxdragimageshow}
204
205\func{bool}{Show}{\void}
206
207Shows the image. Call this at least once when dragging.
208
f6bcfd97
BP
209\membersection{wxDragImage::UpdateBackingFromWindow}\label{wxdragimageupdatebackingfromwindow}
210
211\constfunc{bool}{UpdateBackingFromWindow}{\param{wxDC\&}{ windowDC}, \param{wxMemoryDC\&}{ destDC},
212 \param{const wxRect\&}{ sourceRect}, \param{const wxRect\&}{ destRect}}
213
214Override this if you wish to draw the window contents to the backing bitmap
215yourself. This can be desirable if you wish to avoid flicker by not having to
216redraw the updated window itself just before dragging, which can cause a flicker just
217as the drag starts. Instead, paint the drag image's backing bitmap to show the appropriate
218graphic {\it minus the objects to be dragged}, and leave the window itself to be updated
219by the drag image. This can provide eerily smooth, flicker-free drag behaviour.
220
221The default implementation copies the window contents to the backing bitmap. A new
222implementation will normally copy information from another source, such as from its
223own backing bitmap if it has one, or directly from internal data structures.
224
225This function is available in wxGenericDragImage only.
226