]> git.saurik.com Git - wxWidgets.git/blame - interface/dragimag.h
Trying to make wxString readable again
[wxWidgets.git] / interface / dragimag.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: dragimag.h
e54c96f1 3// Purpose: interface of wxDragImage
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxDragImage
11 @wxheader{dragimag.h}
7c913512 12
0c1fe6e9
BP
13 This class is used when you wish to drag an object on the screen, and a
14 simple cursor is not enough.
7c913512 15
23324ae1 16 On Windows, the Win32 API is used to achieve smooth dragging. On other
0c1fe6e9 17 platforms, wxGenericDragImage is used. Applications may also prefer to use
23324ae1 18 wxGenericDragImage on Windows, too.
7c913512 19
0c1fe6e9
BP
20 @beginWxPythonOnly
21 wxPython uses wxGenericDragImage on all platforms, but uses the wxDragImage
22 name.
23 @endWxPythonOnly
7c913512 24
23324ae1 25 To use this class, when you wish to start dragging an image, create a
0c1fe6e9
BP
26 wxDragImage object and store it somewhere you can access it as the drag
27 progresses. Call BeginDrag() to start, and EndDrag() to stop the drag. To
28 move the image, initially call Show() and then Move(). If you wish to
29 update the screen contents during the drag (for example, highlight an item
30 as in the dragimag sample), first call Hide(), update the screen, call
31 Move(), and then call Show().
7c913512 32
0c1fe6e9
BP
33 You can drag within one window, or you can use full-screen dragging either
34 across the whole screen, or just restricted to one area of the screen to
35 save resources. If you want the user to drag between two windows, then you
36 will need to use full-screen dragging.
7c913512 37
0c1fe6e9
BP
38 If you wish to draw the image yourself, use wxGenericDragImage and override
39 DoDrawImage() and GetImageRect().
7c913512 40
23324ae1 41 @library{wxcore}
0c1fe6e9
BP
42 @category{dnd}
43
44 @see @ref page_samples_dragimag
23324ae1
FM
45*/
46class wxDragImage : public wxObject
47{
48public:
23324ae1 49 /**
0c1fe6e9
BP
50 Default constructor.
51 */
52 wxDragImage();
53 /**
54 Constructs a drag image from a bitmap and optional cursor.
55
56 @param image
57 Bitmap to be used as the drag image. The bitmap can have a mask.
58 @param cursor
59 Optional cursor to combine with the image.
60 @param cursorHotspot
61 This parameter is deprecated.
62 */
63 wxDragImage(const wxBitmap& image, const wxCursor& cursor = wxNullCursor,
64 const wxPoint& cursorHotspot = wxPoint(0, 0));
65 /**
66 Constructs a drag image from an icon and optional cursor.
3c4f71cc 67
7c913512 68 @param image
0c1fe6e9
BP
69 Icon to be used as the drag image.
70 @param cursor
71 Optional cursor to combine with the image.
72 @param cursorHotspot
73 This parameter is deprecated.
74
75 @beginWxPythonOnly
76 This constructor is called wxDragIcon in wxPython.
77 @endWxPythonOnly
78 */
79 wxDragImage(const wxIcon& image, const wxCursor& cursor = wxNullCursor,
80 const wxPoint& cursorHotspot = wxPoint(0, 0));
81 /**
82 Constructs a drag image from a text string and optional cursor.
83
7c913512 84 @param text
4cc4bfaf 85 Text used to construct a drag image.
7c913512 86 @param cursor
4cc4bfaf 87 Optional cursor to combine with the image.
0c1fe6e9 88 @param cursorHotspot
4cc4bfaf 89 This parameter is deprecated.
0c1fe6e9
BP
90
91 @beginWxPythonOnly
92 This constructor is called wxDragString in wxPython.
93 @endWxPythonOnly
94 */
95 wxDragImage(const wxString& text, const wxCursor& cursor = wxNullCursor,
96 const wxPoint& cursorHotspot = wxPoint(0, 0));
97 /**
98 Constructs a drag image from the text in the given tree control item,
99 and optional cursor.
100
7c913512 101 @param treeCtrl
4cc4bfaf 102 Tree control for constructing a tree drag image.
0c1fe6e9
BP
103 @param id
104 Tree control item id.
105
106 @beginWxPythonOnly
107 This constructor is called wxDragTreeItem in wxPython.
108 @endWxPythonOnly
109 */
110 wxDragImage(const wxTreeCtrl& treeCtrl, wxTreeItemId& id);
111 /**
112 Constructs a drag image from the text in the given list control item,
113 and optional cursor.
114
7c913512 115 @param listCtrl
4cc4bfaf 116 List control for constructing a list drag image.
7c913512 117 @param id
0c1fe6e9
BP
118 List control item id.
119
120 @beginWxPythonOnly
121 This constructor is called wxDragListItem in wxPython.
122 @endWxPythonOnly
23324ae1 123 */
0c1fe6e9
BP
124 wxDragImage(const wxListCtrl& listCtrl, long id);
125 /**
126 Constructs a drag image an optional cursor. This constructor is only
127 available for wxGenericDragImage, and can be used when the application
128 supplies DoDrawImage() and GetImageRect().
129
130 @param cursor
131 Optional cursor to combine with the image.
132 @param cursorHotspot
133 This parameter is deprecated.
134 */
135 wxDragImage(const wxCursor& cursor = wxNullCursor,
136 const wxPoint& cursorHotspot = wxPoint(0, 0));
23324ae1 137
23324ae1 138 /**
0c1fe6e9
BP
139 Start dragging the image, in a window or full screen.
140
141 You need to then call Show() and Move() to show the image on the
142 screen. Call EndDrag() when the drag has finished.
143
144 Note that this call automatically calls CaptureMouse().
3c4f71cc 145
7c913512 146 @param hotspot
4cc4bfaf
FM
147 The location of the drag position relative to the upper-left corner
148 of the image.
7c913512 149 @param window
4cc4bfaf
FM
150 The window that captures the mouse, and within which the dragging
151 is limited unless fullScreen is @true.
7c913512 152 @param fullScreen
4cc4bfaf 153 If @true, specifies that the drag will be visible over the full
0c1fe6e9
BP
154 screen, or over as much of the screen as is specified by rect. Note
155 that the mouse will still be captured in window.
7c913512 156 @param rect
4cc4bfaf 157 If non-@NULL, specifies the rectangle (in screen coordinates) that
0c1fe6e9
BP
158 bounds the dragging operation. Specifying this can make the
159 operation more efficient by cutting down on the area under
160 consideration, and it can also make a visual difference since the
161 drag is clipped to this area.
23324ae1
FM
162 */
163 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
0c1fe6e9
BP
164 bool fullScreen = false, wxRect* rect = NULL);
165 /**
166 Start dragging the image, using the first window to capture the mouse
167 and the second to specify the bounding area. This form is equivalent to
168 using the first form, but more convenient than working out the bounding
169 rectangle explicitly.
170
171 You need to then call Show() and Move() to show the image on the
172 screen. Call EndDrag() when the drag has finished.
173
174 Note that this call automatically calls CaptureMouse().
175
176 @param hotspot
177 The location of the drag position relative to the upper-left corner
178 of the image.
179 @param window
180 The window that captures the mouse, and within which the dragging
181 is limited.
182 @param boundingWindow
183 Specifies the area within which the drag occurs.
184 */
7c913512
FM
185 bool BeginDrag(const wxPoint& hotspot, wxWindow* window,
186 wxWindow* boundingWindow);
23324ae1
FM
187
188 /**
189 Draws the image on the device context with top-left corner at the given
190 position.
0c1fe6e9
BP
191
192 This function is only available with wxGenericDragImage, to allow
193 applications to draw their own image instead of using an actual bitmap.
194 If you override this function, you must also override GetImageRect().
23324ae1
FM
195 */
196 virtual bool DoDrawImage(wxDC& dc, const wxPoint& pos);
197
198 /**
199 Call this when the drag has finished.
0c1fe6e9
BP
200
201 @note This function automatically releases mouse capture.
23324ae1
FM
202 */
203 bool EndDrag();
204
205 /**
0c1fe6e9
BP
206 Returns the rectangle enclosing the image, assuming that the image is
207 drawn with its top-left corner at the given point.
208
209 This function is available in wxGenericDragImage only, and may be
210 overridden (together with DoDrawImage()) to provide a virtual drawing
211 capability.
23324ae1 212 */
328f5751 213 virtual wxRect GetImageRect(const wxPoint& pos) const;
23324ae1
FM
214
215 /**
216 Hides the image. You may wish to call this before updating the window
0c1fe6e9 217 contents (perhaps highlighting an item). Then call Move() and Show().
23324ae1
FM
218 */
219 bool Hide();
220
221 /**
0c1fe6e9
BP
222 Call this to move the image to a new position. The image will only be
223 shown if Show() has been called previously (for example at the start of
224 the drag).
225
226 @param pt
227 The position in client coordinates (relative to the window
228 specified in BeginDrag()).
229
230 You can move the image either when the image is hidden or shown, but in
231 general dragging will be smoother if you move the image when it is
232 shown.
23324ae1
FM
233 */
234 bool Move(const wxPoint& pt);
235
236 /**
237 Shows the image. Call this at least once when dragging.
238 */
239 bool Show();
240
241 /**
0c1fe6e9
BP
242 Override this if you wish to draw the window contents to the backing
243 bitmap yourself. This can be desirable if you wish to avoid flicker by
244 not having to redraw the updated window itself just before dragging,
245 which can cause a flicker just as the drag starts. Instead, paint the
246 drag image's backing bitmap to show the appropriate graphic @e minus
247 the objects to be dragged, and leave the window itself to be updated by
248 the drag image. This can provide eerily smooth, flicker-free drag
249 behaviour.
250
251 The default implementation copies the window contents to the backing
252 bitmap. A new implementation will normally copy information from
253 another source, such as from its own backing bitmap if it has one, or
254 directly from internal data structures.
255
23324ae1
FM
256 This function is available in wxGenericDragImage only.
257 */
258 bool UpdateBackingFromWindow(wxDC& windowDC, wxMemoryDC& destDC,
259 const wxRect& sourceRect,
328f5751 260 const wxRect& destRect) const;
23324ae1 261};
e54c96f1 262