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 gtk.DropControllerMotion;
26 
27 private import gdk.Drop;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtk.EventController;
32 private import gtk.c.functions;
33 public  import gtk.c.types;
34 private import std.algorithm;
35 
36 
37 /**
38  * `GtkDropControllerMotion` is an event controller tracking
39  * the pointer during Drag-and-Drop operations.
40  * 
41  * It is modeled after [class@Gtk.EventControllerMotion] so if you
42  * have used that, this should feel really familiar.
43  * 
44  * This controller is not able to accept drops, use [class@Gtk.DropTarget]
45  * for that purpose.
46  */
47 public class DropControllerMotion : EventController
48 {
49 	/** the main Gtk struct */
50 	protected GtkDropControllerMotion* gtkDropControllerMotion;
51 
52 	/** Get the main Gtk struct */
53 	public GtkDropControllerMotion* getDropControllerMotionStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gtkDropControllerMotion;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gtkDropControllerMotion;
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GtkDropControllerMotion* gtkDropControllerMotion, bool ownedRef = false)
70 	{
71 		this.gtkDropControllerMotion = gtkDropControllerMotion;
72 		super(cast(GtkEventController*)gtkDropControllerMotion, ownedRef);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return gtk_drop_controller_motion_get_type();
80 	}
81 
82 	/**
83 	 * Creates a new event controller that will handle pointer motion
84 	 * events during drag and drop.
85 	 *
86 	 * Returns: a new `GtkDropControllerMotion`
87 	 *
88 	 * Throws: ConstructionException GTK+ fails to create the object.
89 	 */
90 	public this()
91 	{
92 		auto __p = gtk_drop_controller_motion_new();
93 
94 		if(__p is null)
95 		{
96 			throw new ConstructionException("null returned by new");
97 		}
98 
99 		this(cast(GtkDropControllerMotion*) __p, true);
100 	}
101 
102 	/**
103 	 * Returns if a Drag-and-Drop operation is within the widget
104 	 * @self or one of its children.
105 	 *
106 	 * Returns: %TRUE if a dragging pointer is within @self or one of its children.
107 	 */
108 	public bool containsPointer()
109 	{
110 		return gtk_drop_controller_motion_contains_pointer(gtkDropControllerMotion) != 0;
111 	}
112 
113 	/**
114 	 * Returns the `GdkDrop` of a current Drag-and-Drop operation
115 	 * over the widget of @self.
116 	 *
117 	 * Returns: The `GdkDrop` currently
118 	 *     happening within @self or %NULL if none
119 	 */
120 	public Drop getDrop()
121 	{
122 		auto __p = gtk_drop_controller_motion_get_drop(gtkDropControllerMotion);
123 
124 		if(__p is null)
125 		{
126 			return null;
127 		}
128 
129 		return ObjectG.getDObject!(Drop)(cast(GdkDrop*) __p);
130 	}
131 
132 	/**
133 	 * Returns if a Drag-and-Drop operation is within the widget
134 	 * @self, not one of its children.
135 	 *
136 	 * Returns: %TRUE if a dragging pointer is within @self but
137 	 *     not one of its children
138 	 */
139 	public bool isPointer()
140 	{
141 		return gtk_drop_controller_motion_is_pointer(gtkDropControllerMotion) != 0;
142 	}
143 
144 	/**
145 	 * Signals that the pointer has entered the widget.
146 	 *
147 	 * Params:
148 	 *     x = coordinates of pointer location
149 	 *     y = coordinates of pointer location
150 	 */
151 	gulong addOnEnter(void delegate(double, double, DropControllerMotion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
152 	{
153 		return Signals.connect(this, "enter", dlg, connectFlags ^ ConnectFlags.SWAPPED);
154 	}
155 
156 	/**
157 	 * Signals that the pointer has left the widget.
158 	 */
159 	gulong addOnLeave(void delegate(DropControllerMotion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
160 	{
161 		return Signals.connect(this, "leave", dlg, connectFlags ^ ConnectFlags.SWAPPED);
162 	}
163 
164 	/**
165 	 * Emitted when the pointer moves inside the widget.
166 	 *
167 	 * Params:
168 	 *     x = the x coordinate
169 	 *     y = the y coordinate
170 	 */
171 	gulong addOnMotion(void delegate(double, double, DropControllerMotion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
172 	{
173 		return Signals.connect(this, "motion", dlg, connectFlags ^ ConnectFlags.SWAPPED);
174 	}
175 }