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  = gdk3-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  * 	- glib.ListG
48  * 	- gdk.Device
49  * 	- gdk.Screen
50  * 	- gdk.Window
51  * structWrap:
52  * 	- GList* -> ListG
53  * 	- GdkDevice* -> Device
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 glib.ListG;
72 private import gdk.Device;
73 private import gdk.Screen;
74 private import gdk.Window;
75 
76 
77 
78 private import gobject.ObjectG;
79 
80 /**
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
83  * protocols transparently, the Win32 backend supports the WM_DROPFILES
84  * protocol.
85  *
86  * GTK+ provides a higher level abstraction based on top of these functions,
87  * and so they are not normally needed in GTK+ applications.
88  * See the Drag and Drop section of
89  * the GTK+ documentation for more information.
90  */
91 public class DragContext : ObjectG
92 {
93 	
94 	/** the main Gtk struct */
95 	protected GdkDragContext* gdkDragContext;
96 	
97 	
98 	public GdkDragContext* getDragContextStruct()
99 	{
100 		return gdkDragContext;
101 	}
102 	
103 	
104 	/** the main Gtk struct as a void* */
105 	protected override void* getStruct()
106 	{
107 		return cast(void*)gdkDragContext;
108 	}
109 	
110 	/**
111 	 * Sets our main struct and passes it to the parent class
112 	 */
113 	public this (GdkDragContext* gdkDragContext)
114 	{
115 		super(cast(GObject*)gdkDragContext);
116 		this.gdkDragContext = gdkDragContext;
117 	}
118 	
119 	protected override void setStruct(GObject* obj)
120 	{
121 		super.setStruct(obj);
122 		gdkDragContext = cast(GdkDragContext*)obj;
123 	}
124 	
125 	/**
126 	 */
127 	
128 	/**
129 	 * Returns the selection atom for the current source window.
130 	 * Returns: the selection atom, or GDK_NONE. [transfer none]
131 	 */
132 	public GdkAtom dragGetSelection()
133 	{
134 		// GdkAtom gdk_drag_get_selection (GdkDragContext *context);
135 		return gdk_drag_get_selection(gdkDragContext);
136 	}
137 	
138 	/**
139 	 * Aborts a drag without dropping.
140 	 * This function is called by the drag source.
141 	 * Params:
142 	 * time = the timestamp for this operation
143 	 */
144 	public void dragAbort(uint time)
145 	{
146 		// void gdk_drag_abort (GdkDragContext *context,  guint32 time_);
147 		gdk_drag_abort(gdkDragContext, time);
148 	}
149 	
150 	/**
151 	 * Accepts or rejects a drop.
152 	 * This function is called by the drag destination in response
153 	 * to a drop initiated by the drag source.
154 	 * Params:
155 	 * accepted = TRUE if the drop is accepted
156 	 * time = the timestamp for this operation
157 	 */
158 	public void dropReply(int accepted, uint time)
159 	{
160 		// void gdk_drop_reply (GdkDragContext *context,  gboolean accepted,  guint32 time_);
161 		gdk_drop_reply(gdkDragContext, accepted, time);
162 	}
163 	
164 	/**
165 	 * Drops on the current destination.
166 	 * This function is called by the drag source.
167 	 * Params:
168 	 * time = the timestamp for this operation
169 	 */
170 	public void dragDrop(uint time)
171 	{
172 		// void gdk_drag_drop (GdkDragContext *context,  guint32 time_);
173 		gdk_drag_drop(gdkDragContext, time);
174 	}
175 	
176 	/**
177 	 * Finds the destination window and DND protocol to use at the
178 	 * given pointer position.
179 	 * This function is called by the drag source to obtain the
180 	 * dest_window and protocol parameters for gdk_drag_motion().
181 	 * Since 2.2
182 	 * Params:
183 	 * dragWindow = a window which may be at the pointer position, but
184 	 * should be ignored, since it is put up by the drag source as an icon
185 	 * screen = the screen where the destination window is sought
186 	 * xRoot = the x position of the pointer in root coordinates
187 	 * yRoot = the y position of the pointer in root coordinates
188 	 * destWindow = location to store the destination window in. [out]
189 	 * protocol = location to store the DND protocol in. [out]
190 	 */
191 	public void dragFindWindowForScreen(Window dragWindow, Screen screen, int xRoot, int yRoot, out Window destWindow, out GdkDragProtocol protocol)
192 	{
193 		// 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);
194 		GdkWindow* outdestWindow = null;
195 		
196 		gdk_drag_find_window_for_screen(gdkDragContext, (dragWindow is null) ? null : dragWindow.getWindowStruct(), (screen is null) ? null : screen.getScreenStruct(), xRoot, yRoot, &outdestWindow, &protocol);
197 		
198 		destWindow = ObjectG.getDObject!(Window)(outdestWindow);
199 	}
200 	
201 	/**
202 	 * Starts a drag and creates a new drag context for it.
203 	 * This function assumes that the drag is controlled by the
204 	 * client pointer device, use gdk_drag_begin_for_device() to
205 	 * begin a drag with a different device.
206 	 * This function is called by the drag source.
207 	 * Params:
208 	 * window = the source window for this drag.
209 	 * targets = the offered targets,
210 	 * as list of GdkAtoms. [transfer none][element-type GdkAtom]
211 	 * Returns: a newly created GdkDragContext. [transfer full]
212 	 */
213 	public static DragContext dragBegin(Window window, ListG targets)
214 	{
215 		// GdkDragContext * gdk_drag_begin (GdkWindow *window,  GList *targets);
216 		auto p = gdk_drag_begin((window is null) ? null : window.getWindowStruct(), (targets is null) ? null : targets.getListGStruct());
217 		
218 		if(p is null)
219 		{
220 			return null;
221 		}
222 		
223 		return ObjectG.getDObject!(DragContext)(cast(GdkDragContext*) p);
224 	}
225 	
226 	/**
227 	 * Starts a drag and creates a new drag context for it.
228 	 * This function is called by the drag source.
229 	 * Params:
230 	 * window = the source window for this drag
231 	 * device = the device that controls this drag
232 	 * targets = the offered targets,
233 	 * as list of GdkAtoms. [transfer none][element-type GdkAtom]
234 	 * Returns: a newly created GdkDragContext. [transfer full]
235 	 */
236 	public static DragContext dragBeginForDevice(Window window, Device device, ListG targets)
237 	{
238 		// GdkDragContext * gdk_drag_begin_for_device (GdkWindow *window,  GdkDevice *device,  GList *targets);
239 		auto p = gdk_drag_begin_for_device((window is null) ? null : window.getWindowStruct(), (device is null) ? null : device.getDeviceStruct(), (targets is null) ? null : targets.getListGStruct());
240 		
241 		if(p is null)
242 		{
243 			return null;
244 		}
245 		
246 		return ObjectG.getDObject!(DragContext)(cast(GdkDragContext*) p);
247 	}
248 	
249 	/**
250 	 * Updates the drag context when the pointer moves or the
251 	 * set of actions changes.
252 	 * This function is called by the drag source.
253 	 * Params:
254 	 * destWindow = the new destination window, obtained by
255 	 * gdk_drag_find_window()
256 	 * protocol = the DND protocol in use, obtained by gdk_drag_find_window()
257 	 * xRoot = the x position of the pointer in root coordinates
258 	 * yRoot = the y position of the pointer in root coordinates
259 	 * suggestedAction = the suggested action
260 	 * possibleActions = the possible actions
261 	 * time = the timestamp for this operation
262 	 */
263 	public int dragMotion(Window destWindow, GdkDragProtocol protocol, int xRoot, int yRoot, GdkDragAction suggestedAction, GdkDragAction possibleActions, uint time)
264 	{
265 		// 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_);
266 		return gdk_drag_motion(gdkDragContext, (destWindow is null) ? null : destWindow.getWindowStruct(), protocol, xRoot, yRoot, suggestedAction, possibleActions, time);
267 	}
268 	
269 	/**
270 	 * Ends the drag operation after a drop.
271 	 * This function is called by the drag destination.
272 	 * Params:
273 	 * success = TRUE if the data was successfully received
274 	 * time = the timestamp for this operation
275 	 */
276 	public void dropFinish(int success, uint time)
277 	{
278 		// void gdk_drop_finish (GdkDragContext *context,  gboolean success,  guint32 time_);
279 		gdk_drop_finish(gdkDragContext, success, time);
280 	}
281 	
282 	/**
283 	 * Selects one of the actions offered by the drag source.
284 	 * This function is called by the drag destination in response to
285 	 * gdk_drag_motion() called by the drag source.
286 	 * Params:
287 	 * action = the selected action which will be taken when a drop happens,
288 	 * or 0 to indicate that a drop will not be accepted
289 	 * time = the timestamp for this operation
290 	 */
291 	public void dragStatus(GdkDragAction action, uint time)
292 	{
293 		// void gdk_drag_status (GdkDragContext *context,  GdkDragAction action,  guint32 time_);
294 		gdk_drag_status(gdkDragContext, action, time);
295 	}
296 	
297 	/**
298 	 * Returns whether the dropped data has been successfully
299 	 * transferred. This function is intended to be used while
300 	 * handling a GDK_DROP_FINISHED event, its return value is
301 	 * meaningless at other times.
302 	 * Since 2.6
303 	 * Returns: TRUE if the drop was successful.
304 	 */
305 	public int dragDropSucceeded()
306 	{
307 		// gboolean gdk_drag_drop_succeeded (GdkDragContext *context);
308 		return gdk_drag_drop_succeeded(gdkDragContext);
309 	}
310 	
311 	/**
312 	 * Finds out the DND protocol supported by a window.
313 	 * Params:
314 	 * window = the destination window
315 	 * target = location of the window
316 	 * where the drop should happen. This may be window or a proxy window,
317 	 * or NULL if window does not support Drag and Drop. [out][allow-none][transfer full]
318 	 * Returns: the supported DND protocol. Since 3.0
319 	 */
320 	public static GdkDragProtocol windowGetDragProtocol(Window window, out Window target)
321 	{
322 		// GdkDragProtocol gdk_window_get_drag_protocol (GdkWindow *window,  GdkWindow **target);
323 		GdkWindow* outtarget = null;
324 		
325 		auto p = gdk_window_get_drag_protocol((window is null) ? null : window.getWindowStruct(), &outtarget);
326 		
327 		target = ObjectG.getDObject!(Window)(outtarget);
328 		return p;
329 	}
330 	
331 	/**
332 	 * Determines the bitmask of actions proposed by the source if
333 	 * gdk_drag_context_get_suggested_action() returns GDK_ACTION_ASK.
334 	 * Since 2.22
335 	 * Returns: the GdkDragAction flags
336 	 */
337 	public GdkDragAction getActions()
338 	{
339 		// GdkDragAction gdk_drag_context_get_actions (GdkDragContext *context);
340 		return gdk_drag_context_get_actions(gdkDragContext);
341 	}
342 	
343 	/**
344 	 * Determines the suggested drag action of the context.
345 	 * Since 2.22
346 	 * Returns: a GdkDragAction value
347 	 */
348 	public GdkDragAction getSuggestedAction()
349 	{
350 		// GdkDragAction gdk_drag_context_get_suggested_action  (GdkDragContext *context);
351 		return gdk_drag_context_get_suggested_action(gdkDragContext);
352 	}
353 	
354 	/**
355 	 * Determines the action chosen by the drag destination.
356 	 * Since 2.22
357 	 * Returns: a GdkDragAction value
358 	 */
359 	public GdkDragAction getSelectedAction()
360 	{
361 		// GdkDragAction gdk_drag_context_get_selected_action  (GdkDragContext *context);
362 		return gdk_drag_context_get_selected_action(gdkDragContext);
363 	}
364 	
365 	/**
366 	 * Retrieves the list of targets of the context.
367 	 * Since 2.22
368 	 * Returns: a GList of targets. [transfer none][element-type GdkAtom]
369 	 */
370 	public ListG listTargets()
371 	{
372 		// GList * gdk_drag_context_list_targets (GdkDragContext *context);
373 		auto p = gdk_drag_context_list_targets(gdkDragContext);
374 		
375 		if(p is null)
376 		{
377 			return null;
378 		}
379 		
380 		return ObjectG.getDObject!(ListG)(cast(GList*) p);
381 	}
382 	
383 	/**
384 	 * Returns the GdkDevice associated to the drag context.
385 	 * Returns: The GdkDevice associated to context. [transfer none]
386 	 */
387 	public Device getDevice()
388 	{
389 		// GdkDevice * gdk_drag_context_get_device (GdkDragContext *context);
390 		auto p = gdk_drag_context_get_device(gdkDragContext);
391 		
392 		if(p is null)
393 		{
394 			return null;
395 		}
396 		
397 		return ObjectG.getDObject!(Device)(cast(GdkDevice*) p);
398 	}
399 	
400 	/**
401 	 * Associates a GdkDevice to context, so all Drag and Drop events
402 	 * for context are emitted as if they came from this device.
403 	 * Params:
404 	 * device = a GdkDevice
405 	 */
406 	public void setDevice(Device device)
407 	{
408 		// void gdk_drag_context_set_device (GdkDragContext *context,  GdkDevice *device);
409 		gdk_drag_context_set_device(gdkDragContext, (device is null) ? null : device.getDeviceStruct());
410 	}
411 	
412 	/**
413 	 * Returns the GdkWindow where the DND operation started.
414 	 * Since 2.22
415 	 * Returns: a GdkWindow. [transfer none]
416 	 */
417 	public Window getSourceWindow()
418 	{
419 		// GdkWindow * gdk_drag_context_get_source_window (GdkDragContext *context);
420 		auto p = gdk_drag_context_get_source_window(gdkDragContext);
421 		
422 		if(p is null)
423 		{
424 			return null;
425 		}
426 		
427 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
428 	}
429 	
430 	/**
431 	 * Returns the destination windw for the DND operation.
432 	 * Returns: a GdkWindow. [transfer none] Since 3.0
433 	 */
434 	public Window getDestWindow()
435 	{
436 		// GdkWindow * gdk_drag_context_get_dest_window (GdkDragContext *context);
437 		auto p = gdk_drag_context_get_dest_window(gdkDragContext);
438 		
439 		if(p is null)
440 		{
441 			return null;
442 		}
443 		
444 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
445 	}
446 	
447 	/**
448 	 * Returns the drag protocol thats used by this context.
449 	 * Returns: the drag protocol Since 3.0
450 	 */
451 	public GdkDragProtocol getProtocol()
452 	{
453 		// GdkDragProtocol gdk_drag_context_get_protocol (GdkDragContext *context);
454 		return gdk_drag_context_get_protocol(gdkDragContext);
455 	}
456 }