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