1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gdk-Drag-and-Drop.html
27  * outPack = gdk
28  * outFile = DragContext
29  * strct   = GdkDragContext
30  * realStrct=
31  * ctorStrct=
32  * clss    = DragContext
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_drag_context_
41  * 	- gdk_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gdk.Window
48  * 	- gdk.Screen
49  * 	- glib.ListG
50  * 	- gdk.Display
51  * structWrap:
52  * 	- GList* -> ListG
53  * 	- GdkDisplay* -> Display
54  * 	- GdkDragContext* -> DragContext
55  * 	- GdkScreen* -> Screen
56  * 	- GdkWindow* -> Window
57  * module aliases:
58  * local aliases:
59  * overrides:
60  */
61 
62 module gdk.DragContext;
63 
64 public  import gtkc.gdktypes;
65 
66 private import gtkc.gdk;
67 private import glib.ConstructionException;
68 private import gobject.ObjectG;
69 
70 
71 private import gdk.Window;
72 private import gdk.Screen;
73 private import glib.ListG;
74 private import gdk.Display;
75 
76 
77 
78 
79 /**
80  * Description
81  * These functions provide a low level interface for drag and drop.
82  * The X backend of GDK supports both the Xdnd and Motif drag and drop protocols
83  * transparently, the Win32 backend supports the WM_DROPFILES protocol.
84  * GTK+ provides a higher level abstraction based on top of these functions,
85  * and so they are not normally needed in GTK+ applications.
86  * See the Drag and Drop section of
87  * the GTK+ documentation for more information.
88  */
89 public class DragContext
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GdkDragContext* gdkDragContext;
94 	
95 	
96 	public GdkDragContext* getDragContextStruct()
97 	{
98 		return gdkDragContext;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected void* getStruct()
104 	{
105 		return cast(void*)gdkDragContext;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GdkDragContext* gdkDragContext)
112 	{
113 		this.gdkDragContext = gdkDragContext;
114 	}
115 	
116 	/**
117 	 */
118 	
119 	/**
120 	 * Returns the selection atom for the current source window.
121 	 * Returns: the selection atom.
122 	 */
123 	public GdkAtom dragGetSelection()
124 	{
125 		// GdkAtom gdk_drag_get_selection (GdkDragContext *context);
126 		return gdk_drag_get_selection(gdkDragContext);
127 	}
128 	
129 	/**
130 	 * Aborts a drag without dropping.
131 	 * This function is called by the drag source.
132 	 * Params:
133 	 * time = the timestamp for this operation.
134 	 */
135 	public void dragAbort(uint time)
136 	{
137 		// void gdk_drag_abort (GdkDragContext *context,  guint32 time_);
138 		gdk_drag_abort(gdkDragContext, time);
139 	}
140 	
141 	/**
142 	 * Accepts or rejects a drop.
143 	 * This function is called by the drag destination in response
144 	 * to a drop initiated by the drag source.
145 	 * Params:
146 	 * ok = TRUE if the drop is accepted.
147 	 * time = the timestamp for this operation.
148 	 */
149 	public void dropReply(int ok, uint time)
150 	{
151 		// void gdk_drop_reply (GdkDragContext *context,  gboolean ok,  guint32 time_);
152 		gdk_drop_reply(gdkDragContext, ok, time);
153 	}
154 	
155 	/**
156 	 * Warning
157 	 * gdk_drag_context_new has been deprecated since version 2.24 and should not be used in newly-written code. This function is not useful, you always
158 	 *  obtain drag contexts by gdk_drag_begin() or similar.
159 	 * Creates a new GdkDragContext.
160 	 * Throws: ConstructionException GTK+ fails to create the object.
161 	 */
162 	public this ()
163 	{
164 		// GdkDragContext * gdk_drag_context_new (void);
165 		auto p = gdk_drag_context_new();
166 		if(p is null)
167 		{
168 			throw new ConstructionException("null returned by gdk_drag_context_new()");
169 		}
170 		this(cast(GdkDragContext*) p);
171 	}
172 	
173 	/**
174 	 * Drops on the current destination.
175 	 * This function is called by the drag source.
176 	 * Params:
177 	 * time = the timestamp for this operation.
178 	 */
179 	public void dragDrop(uint time)
180 	{
181 		// void gdk_drag_drop (GdkDragContext *context,  guint32 time_);
182 		gdk_drag_drop(gdkDragContext, time);
183 	}
184 	
185 	/**
186 	 * Warning
187 	 * gdk_drag_find_window has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_drag_find_window_for_screen() instead.
188 	 * Finds the destination window and DND protocol to use at the
189 	 * given pointer position.
190 	 * This function is called by the drag source to obtain the
191 	 * dest_window and protocol parameters for gdk_drag_motion().
192 	 * Params:
193 	 * dragWindow = a window which may be at the pointer position, but
194 	 * should be ignored, since it is put up by the drag source as an icon.
195 	 * xRoot = the x position of the pointer in root coordinates.
196 	 * yRoot = the y position of the pointer in root coordinates.
197 	 * destWindow = location to store the destination window in. [out]
198 	 * protocol = location to store the DND protocol in. [out]
199 	 */
200 	public void dragFindWindow(Window dragWindow, int xRoot, int yRoot, out Window destWindow, out GdkDragProtocol protocol)
201 	{
202 		// void gdk_drag_find_window (GdkDragContext *context,  GdkWindow *drag_window,  gint x_root,  gint y_root,  GdkWindow **dest_window,  GdkDragProtocol *protocol);
203 		GdkWindow* outdestWindow = null;
204 		
205 		gdk_drag_find_window(gdkDragContext, (dragWindow is null) ? null : dragWindow.getWindowStruct(), xRoot, yRoot, &outdestWindow, &protocol);
206 		
207 		destWindow = ObjectG.getDObject!(Window)(outdestWindow);
208 	}
209 	
210 	/**
211 	 * Finds the destination window and DND protocol to use at the
212 	 * given pointer position.
213 	 * This function is called by the drag source to obtain the
214 	 * dest_window and protocol parameters for gdk_drag_motion().
215 	 * Since 2.2
216 	 * Params:
217 	 * dragWindow = a window which may be at the pointer position, but
218 	 * should be ignored, since it is put up by the drag source as an icon.
219 	 * screen = the screen where the destination window is sought.
220 	 * xRoot = the x position of the pointer in root coordinates.
221 	 * yRoot = the y position of the pointer in root coordinates.
222 	 * destWindow = location to store the destination window in. [out]
223 	 * protocol = location to store the DND protocol in. [out]
224 	 */
225 	public void dragFindWindowForScreen(Window dragWindow, Screen screen, int xRoot, int yRoot, out Window destWindow, out GdkDragProtocol protocol)
226 	{
227 		// 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);
228 		GdkWindow* outdestWindow = null;
229 		
230 		gdk_drag_find_window_for_screen(gdkDragContext, (dragWindow is null) ? null : dragWindow.getWindowStruct(), (screen is null) ? null : screen.getScreenStruct(), xRoot, yRoot, &outdestWindow, &protocol);
231 		
232 		destWindow = ObjectG.getDObject!(Window)(outdestWindow);
233 	}
234 	
235 	/**
236 	 * Warning
237 	 * gdk_drag_context_ref has been deprecated since version 2.2 and should not be used in newly-written code. Use g_object_ref() instead.
238 	 * Deprecated function; use g_object_ref() instead.
239 	 */
240 	public void doref()
241 	{
242 		// void gdk_drag_context_ref (GdkDragContext *context);
243 		gdk_drag_context_ref(gdkDragContext);
244 	}
245 	
246 	/**
247 	 * Determines the bitmask of actions proposed by the source if
248 	 * gdk_drag_context_suggested_action() returns GDK_ACTION_ASK.
249 	 * Since 2.22
250 	 * Returns: the GdkDragAction flags
251 	 */
252 	public GdkDragAction getActions()
253 	{
254 		// GdkDragAction gdk_drag_context_get_actions (GdkDragContext *context);
255 		return gdk_drag_context_get_actions(gdkDragContext);
256 	}
257 	
258 	/**
259 	 * Determines the action chosen by the drag destination.
260 	 * Since 2.22
261 	 * Returns: a GdkDragAction value
262 	 */
263 	public GdkDragAction getSelectedAction()
264 	{
265 		// GdkDragAction gdk_drag_context_get_selected_action  (GdkDragContext *context);
266 		return gdk_drag_context_get_selected_action(gdkDragContext);
267 	}
268 	
269 	/**
270 	 * Determines the suggested drag action of the context.
271 	 * Since 2.22
272 	 * Returns: a GdkDragAction value
273 	 */
274 	public GdkDragAction getSuggestedAction()
275 	{
276 		// GdkDragAction gdk_drag_context_get_suggested_action  (GdkDragContext *context);
277 		return gdk_drag_context_get_suggested_action(gdkDragContext);
278 	}
279 	
280 	/**
281 	 * Retrieves the list of targets of the context.
282 	 * Since 2.22
283 	 * Returns: a GList of targets. [transfer none][element-type GdkAtom]
284 	 */
285 	public ListG listTargets()
286 	{
287 		// GList * gdk_drag_context_list_targets (GdkDragContext *context);
288 		auto p = gdk_drag_context_list_targets(gdkDragContext);
289 		
290 		if(p is null)
291 		{
292 			return null;
293 		}
294 		
295 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
296 	}
297 	
298 	/**
299 	 * Returns the GdkWindow where the DND operation started.
300 	 * Since 2.22
301 	 * Returns: a GdkWindow. [transfer none]
302 	 */
303 	public Window getSourceWindow()
304 	{
305 		// GdkWindow * gdk_drag_context_get_source_window (GdkDragContext *context);
306 		auto p = gdk_drag_context_get_source_window(gdkDragContext);
307 		
308 		if(p is null)
309 		{
310 			return null;
311 		}
312 		
313 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
314 	}
315 	
316 	/**
317 	 * Starts a drag and creates a new drag context for it.
318 	 * This function is called by the drag source.
319 	 * Params:
320 	 * window = the source window for this drag.
321 	 * targets = the offered targets,
322 	 * as list of GdkAtoms. [transfer none][element-type GdkAtom]
323 	 * Returns: a newly created GdkDragContext.
324 	 */
325 	public static DragContext dragBegin(Window window, ListG targets)
326 	{
327 		// GdkDragContext * gdk_drag_begin (GdkWindow *window,  GList *targets);
328 		auto p = gdk_drag_begin((window is null) ? null : window.getWindowStruct(), (targets is null) ? null : targets.getListGStruct());
329 		
330 		if(p is null)
331 		{
332 			return null;
333 		}
334 		
335 		return ObjectG.getDObject!(DragContext)(cast(GdkDragContext*) p);
336 	}
337 	
338 	/**
339 	 * Updates the drag context when the pointer moves or the
340 	 * set of actions changes.
341 	 * This function is called by the drag source.
342 	 * Params:
343 	 * destWindow = the new destination window, obtained by
344 	 * gdk_drag_find_window().
345 	 * protocol = the DND protocol in use, obtained by gdk_drag_find_window().
346 	 * xRoot = the x position of the pointer in root coordinates.
347 	 * yRoot = the y position of the pointer in root coordinates.
348 	 * suggestedAction = the suggested action.
349 	 * possibleActions = the possible actions.
350 	 * time = the timestamp for this operation.
351 	 * Returns: FIXME
352 	 */
353 	public int dragMotion(Window destWindow, GdkDragProtocol protocol, int xRoot, int yRoot, GdkDragAction suggestedAction, GdkDragAction possibleActions, uint time)
354 	{
355 		// 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_);
356 		return gdk_drag_motion(gdkDragContext, (destWindow is null) ? null : destWindow.getWindowStruct(), protocol, xRoot, yRoot, suggestedAction, possibleActions, time);
357 	}
358 	
359 	/**
360 	 * Ends the drag operation after a drop.
361 	 * This function is called by the drag destination.
362 	 * Params:
363 	 * success = TRUE if the data was successfully received.
364 	 * time = the timestamp for this operation.
365 	 */
366 	public void dropFinish(int success, uint time)
367 	{
368 		// void gdk_drop_finish (GdkDragContext *context,  gboolean success,  guint32 time_);
369 		gdk_drop_finish(gdkDragContext, success, time);
370 	}
371 	
372 	/**
373 	 * Warning
374 	 * gdk_drag_get_protocol has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_drag_get_protocol_for_display() instead
375 	 * Finds out the DND protocol supported by a window.
376 	 * Params:
377 	 * xid = the windowing system id of the destination window.
378 	 * protocol = location where the supported DND protocol is returned.
379 	 * Returns: the windowing system specific id for the window where the drop should happen. This may be xid or the id of a proxy window, or zero if xid doesn't support Drag and Drop.
380 	 */
381 	public static GdkNativeWindow dragGetProtocol(GdkNativeWindow xid, out GdkDragProtocol protocol)
382 	{
383 		// GdkNativeWindow gdk_drag_get_protocol (GdkNativeWindow xid,  GdkDragProtocol *protocol);
384 		return gdk_drag_get_protocol(xid, &protocol);
385 	}
386 	
387 	/**
388 	 * Finds out the DND protocol supported by a window.
389 	 * Since 2.2
390 	 * Params:
391 	 * display = the GdkDisplay where the destination window resides
392 	 * xid = the windowing system id of the destination window.
393 	 * protocol = location where the supported DND protocol is returned.
394 	 * Returns: the windowing system id of the window where the drop should happen. This may be xid or the id of a proxy window, or zero if xid doesn't support Drag and Drop.
395 	 */
396 	public static GdkNativeWindow dragGetProtocolForDisplay(Display display, GdkNativeWindow xid, out GdkDragProtocol protocol)
397 	{
398 		// GdkNativeWindow gdk_drag_get_protocol_for_display (GdkDisplay *display,  GdkNativeWindow xid,  GdkDragProtocol *protocol);
399 		return gdk_drag_get_protocol_for_display((display is null) ? null : display.getDisplayStruct(), xid, &protocol);
400 	}
401 	
402 	/**
403 	 * Warning
404 	 * gdk_drag_context_unref has been deprecated since version 2.2 and should not be used in newly-written code. Use g_object_unref() instead.
405 	 * Deprecated function; use g_object_unref() instead.
406 	 */
407 	public void unref()
408 	{
409 		// void gdk_drag_context_unref (GdkDragContext *context);
410 		gdk_drag_context_unref(gdkDragContext);
411 	}
412 	
413 	/**
414 	 * Selects one of the actions offered by the drag source.
415 	 * This function is called by the drag destination in response to
416 	 * gdk_drag_motion() called by the drag source.
417 	 * Params:
418 	 * action = the selected action which will be taken when a drop happens,
419 	 * or 0 to indicate that a drop will not be accepted.
420 	 * time = the timestamp for this operation.
421 	 */
422 	public void dragStatus(GdkDragAction action, uint time)
423 	{
424 		// void gdk_drag_status (GdkDragContext *context,  GdkDragAction action,  guint32 time_);
425 		gdk_drag_status(gdkDragContext, action, time);
426 	}
427 	
428 	/**
429 	 * Returns whether the dropped data has been successfully
430 	 * transferred. This function is intended to be used while
431 	 * handling a GDK_DROP_FINISHED event, its return value is
432 	 * meaningless at other times.
433 	 * Since 2.6
434 	 * Returns: TRUE if the drop was successful.
435 	 */
436 	public int dragDropSucceeded()
437 	{
438 		// gboolean gdk_drag_drop_succeeded (GdkDragContext *context);
439 		return gdk_drag_drop_succeeded(gdkDragContext);
440 	}
441 }