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