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