alternative to assert
[gtkD.git] / gtkD / src / gdk / DragContext.d
blobb2b44d1bec502bbd692d6bac20361e669b2069ec
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gdk-Drag-and-Drop.html
26 * outPack = gdk
27 * outFile = DragContext
28 * strct = GdkDragContext
29 * realStrct=
30 * ctorStrct=
31 * clss = DragContext
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gdk-drag_context_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - gdk.DragContext
45 * - gdk.Window
46 * - gdk.Screen
47 * - glib.ListG
48 * - gdk.Display
49 * structWrap:
50 * - GList* -> ListG
51 * - GdkDisplay* -> Display
52 * - GdkDragContext* -> DragContext
53 * - GdkScreen* -> Screen
54 * - GdkWindow* -> Window
55 * module aliases:
56 * local aliases:
59 module gdk.DragContext;
61 version(noAssert)
63 version(Tango)
65 import tango.io.Stdout; // use the tango loging?
69 private import gtkc.gdktypes;
71 private import gtkc.gdk;
74 private import gdk.DragContext;
75 private import gdk.Window;
76 private import gdk.Screen;
77 private import glib.ListG;
78 private import gdk.Display;
83 /**
84 * Description
85 * These functions provide a low level interface for drag and drop.
86 * The X backend of GDK supports both the Xdnd and Motif drag and drop protocols
87 * transparently, the Win32 backend supports the WM_DROPFILES protocol.
88 * GTK+ provides a higher level abstraction based on top of these functions,
89 * and so they are not normally needed in GTK+ applications.
90 * See the Drag and Drop section of
91 * the GTK+ documentation for more information.
93 public class DragContext
96 /** the main Gtk struct */
97 protected GdkDragContext* gdkDragContext;
100 public GdkDragContext* getDragContextStruct()
102 return gdkDragContext;
106 /** the main Gtk struct as a void* */
107 protected void* getStruct()
109 return cast(void*)gdkDragContext;
113 * Sets our main struct and passes it to the parent class
115 public this (GdkDragContext* gdkDragContext)
117 version(noAssert)
119 if ( gdkDragContext is null )
121 int zero = 0;
122 version(Tango)
124 Stdout("struct gdkDragContext is null on constructor").newline;
126 else
128 printf("struct gdkDragContext is null on constructor");
130 zero = zero / zero;
133 else
135 assert(gdkDragContext !is null, "struct gdkDragContext is null on constructor");
137 this.gdkDragContext = gdkDragContext;
144 * Returns the selection atom for the current source window.
145 * context:
146 * a GdkDragContext.
147 * Returns:
148 * the selection atom.
150 public GdkAtom gdkDragGetSelection()
152 // GdkAtom gdk_drag_get_selection (GdkDragContext *context);
153 return gdk_drag_get_selection(gdkDragContext);
157 * Aborts a drag without dropping.
158 * This function is called by the drag source.
159 * context:
160 * a GdkDragContext.
161 * time_:
162 * the timestamp for this operation.
164 public void gdkDragAbort(uint time)
166 // void gdk_drag_abort (GdkDragContext *context, guint32 time_);
167 gdk_drag_abort(gdkDragContext, time);
171 * Accepts or rejects a drop.
172 * This function is called by the drag destination in response
173 * to a drop initiated by the drag source.
174 * context:
175 * a GdkDragContext.
176 * ok:
177 * TRUE if the drop is accepted.
178 * time_:
179 * the timestamp for this operation.
181 public void gdkDropReply(int ok, uint time)
183 // void gdk_drop_reply (GdkDragContext *context, gboolean ok, guint32 time_);
184 gdk_drop_reply(gdkDragContext, ok, time);
188 * Creates a new GdkDragContext.
189 * Returns:
190 * the newly created GdkDragContext.
192 public static DragContext gdkDragContextNew()
194 // GdkDragContext* gdk_drag_context_new (void);
195 return new DragContext( gdk_drag_context_new() );
199 * Drops on the current destination.
200 * This function is called by the drag source.
201 * context:
202 * a GdkDragContext.
203 * time_:
204 * the timestamp for this operation.
206 public void gdkDragDrop(uint time)
208 // void gdk_drag_drop (GdkDragContext *context, guint32 time_);
209 gdk_drag_drop(gdkDragContext, time);
213 * Finds the destination window and DND protocol to use at the
214 * given pointer position.
215 * This function is called by the drag source to obtain the
216 * dest_window and protocol parameters for gdk_drag_motion().
217 * context:
218 * a GdkDragContext.
219 * drag_window:
220 * a window which may be at the pointer position, but
221 * should be ignored, since it is put up by the drag source as an icon.
222 * x_root:
223 * the x position of the pointer in root coordinates.
224 * y_root:
225 * the y position of the pointer in root coordinates.
226 * dest_window:
227 * location to store the destination window in.
228 * protocol:
229 * location to store the DND protocol in.
231 public void gdkDragFindWindow(Window dragWindow, int xRoot, int yRoot, GdkWindow** destWindow, GdkDragProtocol* protocol)
233 // void gdk_drag_find_window (GdkDragContext *context, GdkWindow *drag_window, gint x_root, gint y_root, GdkWindow **dest_window, GdkDragProtocol *protocol);
234 gdk_drag_find_window(gdkDragContext, (dragWindow is null) ? null : dragWindow.getWindowStruct(), xRoot, yRoot, destWindow, protocol);
238 * Finds the destination window and DND protocol to use at the
239 * given pointer position.
240 * This function is called by the drag source to obtain the
241 * dest_window and protocol parameters for gdk_drag_motion().
242 * context:
243 * a GdkDragContext
244 * drag_window:
245 * a window which may be at the pointer position, but
246 * should be ignored, since it is put up by the drag source as an icon.
247 * screen:
248 * the screen where the destination window is sought.
249 * x_root:
250 * the x position of the pointer in root coordinates.
251 * y_root:
252 * the y position of the pointer in root coordinates.
253 * dest_window:
254 * location to store the destination window in.
255 * protocol:
256 * location to store the DND protocol in.
257 * Since 2.2
259 public void gdkDragFindWindowForScreen(Window dragWindow, Screen screen, int xRoot, int yRoot, GdkWindow** destWindow, GdkDragProtocol* protocol)
261 // void gdk_drag_find_window_for_screen (GdkDragContext *context, GdkWindow *drag_window, GdkScreen *screen, gint x_root, gint y_root, GdkWindow **dest_window, GdkDragProtocol *protocol);
262 gdk_drag_find_window_for_screen(gdkDragContext, (dragWindow is null) ? null : dragWindow.getWindowStruct(), (screen is null) ? null : screen.getScreenStruct(), xRoot, yRoot, destWindow, protocol);
266 * Warning
267 * gdk_drag_context_ref is deprecated and should not be used in newly-written code.
268 * Deprecated function; use g_object_ref() instead.
269 * context:
270 * a GdkDragContext.
272 public void gdkDragContextRef()
274 // void gdk_drag_context_ref (GdkDragContext *context);
275 gdk_drag_context_ref(gdkDragContext);
279 * Starts a drag and creates a new drag context for it.
280 * This function is called by the drag source.
281 * window:
282 * the source window for this drag.
283 * targets:
284 * the list of offered targets.
285 * Returns:
286 * a newly created GdkDragContext.
288 public static DragContext gdkDragBegin(Window window, ListG targets)
290 // GdkDragContext* gdk_drag_begin (GdkWindow *window, GList *targets);
291 return new DragContext( gdk_drag_begin((window is null) ? null : window.getWindowStruct(), (targets is null) ? null : targets.getListGStruct()) );
295 * Updates the drag context when the pointer moves or the
296 * set of actions changes.
297 * This function is called by the drag source.
298 * context:
299 * a GdkDragContext.
300 * dest_window:
301 * the new destination window, obtained by
302 * gdk_drag_find_window().
303 * protocol:
304 * the DND protocol in use, obtained by gdk_drag_find_window().
305 * x_root:
306 * the x position of the pointer in root coordinates.
307 * y_root:
308 * the y position of the pointer in root coordinates.
309 * suggested_action:
310 * the suggested action.
311 * possible_actions:
312 * the possible actions.
313 * time_:
314 * the timestamp for this operation.
315 * Returns:
316 * FIXME
318 public int gdkDragMotion(Window destWindow, GdkDragProtocol protocol, int xRoot, int yRoot, GdkDragAction suggestedAction, GdkDragAction possibleActions, uint time)
320 // gboolean gdk_drag_motion (GdkDragContext *context, GdkWindow *dest_window, GdkDragProtocol protocol, gint x_root, gint y_root, GdkDragAction suggested_action, GdkDragAction possible_actions, guint32 time_);
321 return gdk_drag_motion(gdkDragContext, (destWindow is null) ? null : destWindow.getWindowStruct(), protocol, xRoot, yRoot, suggestedAction, possibleActions, time);
325 * Ends the drag operation after a drop.
326 * This function is called by the drag destination.
327 * context:
328 * a GtkDragContext.
329 * success:
330 * TRUE if the data was successfully received.
331 * time_:
332 * the timestamp for this operation.
334 public void gdkDropFinish(int success, uint time)
336 // void gdk_drop_finish (GdkDragContext *context, gboolean success, guint32 time_);
337 gdk_drop_finish(gdkDragContext, success, time);
341 * Finds out the DND protocol supported by a window.
342 * xid:
343 * the X id of the destination window.
344 * protocol:
345 * location where the supported DND protocol is returned.
346 * Returns:
347 * the X id of the window where the drop should happen. This
348 * may be xid or the X id of a proxy window, or None if xid doesn't
349 * support Drag and Drop.
351 public static uint gdkDragGetProtocol(uint xid, GdkDragProtocol* protocol)
353 // guint32 gdk_drag_get_protocol (guint32 xid, GdkDragProtocol *protocol);
354 return gdk_drag_get_protocol(xid, protocol);
358 * Finds out the DND protocol supported by a window.
359 * display:
360 * the GdkDisplay where the destination window resides
361 * xid:
362 * the X id of the destination window.
363 * protocol:
364 * location where the supported DND protocol is returned.
365 * Returns:
366 * the X id of the window where the drop should happen. This
367 * may be xid or the X id of a proxy window, or None if xid doesn't
368 * support Drag and Drop.
369 * Since 2.2
371 public static uint gdkDragGetProtocolForDisplay(Display display, uint xid, GdkDragProtocol* protocol)
373 // guint32 gdk_drag_get_protocol_for_display (GdkDisplay *display, guint32 xid, GdkDragProtocol *protocol);
374 return gdk_drag_get_protocol_for_display((display is null) ? null : display.getDisplayStruct(), xid, protocol);
379 * Warning
380 * gdk_drag_context_unref is deprecated and should not be used in newly-written code.
381 * Deprecated function; use g_object_unref() instead.
382 * context:
383 * a GdkDragContext.
385 public void gdkDragContextUnref()
387 // void gdk_drag_context_unref (GdkDragContext *context);
388 gdk_drag_context_unref(gdkDragContext);
394 * Selects one of the actions offered by the drag source.
395 * This function is called by the drag destination in response to
396 * gdk_drag_motion() called by the drag source.
397 * context:
398 * a GdkDragContext.
399 * action:
400 * the selected action which will be taken when a drop happens,
401 * or 0 to indicate that a drop will not be accepted.
402 * time_:
403 * the timestamp for this operation.
405 public void gdkDragStatus(GdkDragAction action, uint time)
407 // void gdk_drag_status (GdkDragContext *context, GdkDragAction action, guint32 time_);
408 gdk_drag_status(gdkDragContext, action, time);
412 * Returns wether the dropped data has been successfully
413 * transferred. This function is intended to be used while
414 * handling a GDK_DROP_FINISHED event, its return value is
415 * meaningless at other times.
416 * context:
417 * a GdkDragContext
418 * Returns:
419 * TRUE if the drop was successful.
420 * Since 2.6
422 public int gdkDragDropSucceeded()
424 // gboolean gdk_drag_drop_succeeded (GdkDragContext *context);
425 return gdk_drag_drop_succeeded(gdkDragContext);