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