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.GestureDrag;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.Gesture;
31 private import gtk.GestureSingle;
32 private import gtk.Widget;
33 public  import gtkc.gdktypes;
34 private import gtkc.gtk;
35 public  import gtkc.gtktypes;
36 
37 
38 /**
39  * #GtkGestureDrag is a #GtkGesture implementation that recognizes drag
40  * operations. The drag operation itself can be tracked throught the
41  * #GtkGestureDrag:drag-begin, #GtkGestureDrag:drag-update and
42  * #GtkGestureDrag:drag-end signals, or the relevant coordinates be
43  * extracted through gtk_gesture_drag_get_offset() and
44  * gtk_gesture_drag_get_start_point().
45  */
46 public class GestureDrag : GestureSingle
47 {
48 	/** the main Gtk struct */
49 	protected GtkGestureDrag* gtkGestureDrag;
50 
51 	/** Get the main Gtk struct */
52 	public GtkGestureDrag* getGestureDragStruct()
53 	{
54 		return gtkGestureDrag;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gtkGestureDrag;
61 	}
62 
63 	protected override void setStruct(GObject* obj)
64 	{
65 		gtkGestureDrag = cast(GtkGestureDrag*)obj;
66 		super.setStruct(obj);
67 	}
68 
69 	/**
70 	 * Sets our main struct and passes it to the parent class.
71 	 */
72 	public this (GtkGestureDrag* gtkGestureDrag, bool ownedRef = false)
73 	{
74 		this.gtkGestureDrag = gtkGestureDrag;
75 		super(cast(GtkGestureSingle*)gtkGestureDrag, ownedRef);
76 	}
77 
78 	/**
79 	 */
80 
81 	public static GType getType()
82 	{
83 		return gtk_gesture_drag_get_type();
84 	}
85 
86 	/**
87 	 * Returns a newly created #GtkGesture that recognizes drags.
88 	 *
89 	 * Params:
90 	 *     widget = a #GtkWidget
91 	 *
92 	 * Return: a newly created #GtkGestureDrag
93 	 *
94 	 * Since: 3.14
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this(Widget widget)
99 	{
100 		auto p = gtk_gesture_drag_new((widget is null) ? null : widget.getWidgetStruct());
101 		
102 		if(p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 		
107 		this(cast(GtkGestureDrag*) p, true);
108 	}
109 
110 	/**
111 	 * If the @gesture is active, this function returns %TRUE and
112 	 * fills in @x and @y with the coordinates of the current point,
113 	 * as an offset to the starting drag point.
114 	 *
115 	 * Params:
116 	 *     x = X offset for the current point
117 	 *     y = Y offset for the current point
118 	 *
119 	 * Return: %TRUE if the gesture is active
120 	 *
121 	 * Since: 3.14
122 	 */
123 	public bool getOffset(out double x, out double y)
124 	{
125 		return gtk_gesture_drag_get_offset(gtkGestureDrag, &x, &y) != 0;
126 	}
127 
128 	/**
129 	 * If the @gesture is active, this function returns %TRUE
130 	 * and fills in @x and @y with the drag start coordinates,
131 	 * in window-relative coordinates.
132 	 *
133 	 * Params:
134 	 *     x = X coordinate for the drag start point
135 	 *     y = Y coordinate for the drag start point
136 	 *
137 	 * Return: %TRUE if the gesture is active
138 	 *
139 	 * Since: 3.14
140 	 */
141 	public bool getStartPoint(out double x, out double y)
142 	{
143 		return gtk_gesture_drag_get_start_point(gtkGestureDrag, &x, &y) != 0;
144 	}
145 
146 	int[string] connectedSignals;
147 
148 	void delegate(double, double, GestureDrag)[] onDragBeginListeners;
149 	/**
150 	 * This signal is emitted whenever dragging starts.
151 	 *
152 	 * Params:
153 	 *     startX = X coordinate, relative to the widget allocation
154 	 *     startY = Y coordinate, relative to the widget allocation
155 	 *
156 	 * Since: 3.14
157 	 */
158 	void addOnDragBegin(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
159 	{
160 		if ( "drag-begin" !in connectedSignals )
161 		{
162 			Signals.connectData(
163 				this,
164 				"drag-begin",
165 				cast(GCallback)&callBackDragBegin,
166 				cast(void*)this,
167 				null,
168 				connectFlags);
169 			connectedSignals["drag-begin"] = 1;
170 		}
171 		onDragBeginListeners ~= dlg;
172 	}
173 	extern(C) static void callBackDragBegin(GtkGestureDrag* gesturedragStruct, double startX, double startY, GestureDrag _gesturedrag)
174 	{
175 		foreach ( void delegate(double, double, GestureDrag) dlg; _gesturedrag.onDragBeginListeners )
176 		{
177 			dlg(startX, startY, _gesturedrag);
178 		}
179 	}
180 
181 	void delegate(double, double, GestureDrag)[] onDragEndListeners;
182 	/**
183 	 * This signal is emitted whenever the dragging is finished.
184 	 *
185 	 * Params:
186 	 *     offsetX = X offset, relative to the start point
187 	 *     offsetY = Y offset, relative to the start point
188 	 *
189 	 * Since: 3.14
190 	 */
191 	void addOnDragEnd(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
192 	{
193 		if ( "drag-end" !in connectedSignals )
194 		{
195 			Signals.connectData(
196 				this,
197 				"drag-end",
198 				cast(GCallback)&callBackDragEnd,
199 				cast(void*)this,
200 				null,
201 				connectFlags);
202 			connectedSignals["drag-end"] = 1;
203 		}
204 		onDragEndListeners ~= dlg;
205 	}
206 	extern(C) static void callBackDragEnd(GtkGestureDrag* gesturedragStruct, double offsetX, double offsetY, GestureDrag _gesturedrag)
207 	{
208 		foreach ( void delegate(double, double, GestureDrag) dlg; _gesturedrag.onDragEndListeners )
209 		{
210 			dlg(offsetX, offsetY, _gesturedrag);
211 		}
212 	}
213 
214 	void delegate(double, double, GestureDrag)[] onDragUpdateListeners;
215 	/**
216 	 * This signal is emitted whenever the dragging point moves.
217 	 *
218 	 * Params:
219 	 *     offsetX = X offset, relative to the start point
220 	 *     offsetY = Y offset, relative to the start point
221 	 *
222 	 * Since: 3.14
223 	 */
224 	void addOnDragUpdate(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
225 	{
226 		if ( "drag-update" !in connectedSignals )
227 		{
228 			Signals.connectData(
229 				this,
230 				"drag-update",
231 				cast(GCallback)&callBackDragUpdate,
232 				cast(void*)this,
233 				null,
234 				connectFlags);
235 			connectedSignals["drag-update"] = 1;
236 		}
237 		onDragUpdateListeners ~= dlg;
238 	}
239 	extern(C) static void callBackDragUpdate(GtkGestureDrag* gesturedragStruct, double offsetX, double offsetY, GestureDrag _gesturedrag)
240 	{
241 		foreach ( void delegate(double, double, GestureDrag) dlg; _gesturedrag.onDragUpdateListeners )
242 		{
243 			dlg(offsetX, offsetY, _gesturedrag);
244 		}
245 	}
246 }