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