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 	public static GType getType()
81 	{
82 		return gtk_gesture_drag_get_type();
83 	}
84 
85 	/**
86 	 * Returns a newly created #GtkGesture that recognizes drags.
87 	 *
88 	 * Params:
89 	 *     widget = a #GtkWidget
90 	 *
91 	 * Return: a newly created #GtkGestureDrag
92 	 *
93 	 * Since: 3.14
94 	 *
95 	 * Throws: ConstructionException GTK+ fails to create the object.
96 	 */
97 	public this(Widget widget)
98 	{
99 		auto p = gtk_gesture_drag_new((widget is null) ? null : widget.getWidgetStruct());
100 		
101 		if(p is null)
102 		{
103 			throw new ConstructionException("null returned by new");
104 		}
105 		
106 		this(cast(GtkGestureDrag*) p, true);
107 	}
108 
109 	/**
110 	 * If the @gesture is active, this function returns %TRUE and
111 	 * fills in @x and @y with the coordinates of the current point,
112 	 * as an offset to the starting drag point.
113 	 *
114 	 * Params:
115 	 *     x = X offset for the current point
116 	 *     y = Y offset for the current point
117 	 *
118 	 * Return: %TRUE if the gesture is active
119 	 *
120 	 * Since: 3.14
121 	 */
122 	public bool getOffset(out double x, out double y)
123 	{
124 		return gtk_gesture_drag_get_offset(gtkGestureDrag, &x, &y) != 0;
125 	}
126 
127 	/**
128 	 * If the @gesture is active, this function returns %TRUE
129 	 * and fills in @x and @y with the drag start coordinates,
130 	 * in window-relative coordinates.
131 	 *
132 	 * Params:
133 	 *     x = X coordinate for the drag start point
134 	 *     y = Y coordinate for the drag start point
135 	 *
136 	 * Return: %TRUE if the gesture is active
137 	 *
138 	 * Since: 3.14
139 	 */
140 	public bool getStartPoint(out double x, out double y)
141 	{
142 		return gtk_gesture_drag_get_start_point(gtkGestureDrag, &x, &y) != 0;
143 	}
144 
145 	int[string] connectedSignals;
146 
147 	void delegate(double, double, GestureDrag)[] onDragBeginListeners;
148 	/**
149 	 * This signal is emitted whenever dragging starts.
150 	 *
151 	 * Params:
152 	 *     startX = X coordinate, relative to the widget allocation
153 	 *     startY = Y coordinate, relative to the widget allocation
154 	 *
155 	 * Since: 3.14
156 	 */
157 	void addOnDragBegin(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
158 	{
159 		if ( "drag-begin" !in connectedSignals )
160 		{
161 			Signals.connectData(
162 				this,
163 				"drag-begin",
164 				cast(GCallback)&callBackDragBegin,
165 				cast(void*)this,
166 				null,
167 				connectFlags);
168 			connectedSignals["drag-begin"] = 1;
169 		}
170 		onDragBeginListeners ~= dlg;
171 	}
172 	extern(C) static void callBackDragBegin(GtkGestureDrag* gesturedragStruct, double startX, double startY, GestureDrag _gesturedrag)
173 	{
174 		foreach ( void delegate(double, double, GestureDrag) dlg; _gesturedrag.onDragBeginListeners )
175 		{
176 			dlg(startX, startY, _gesturedrag);
177 		}
178 	}
179 
180 	void delegate(double, double, GestureDrag)[] onDragEndListeners;
181 	/**
182 	 * This signal is emitted whenever the dragging is finished.
183 	 *
184 	 * Params:
185 	 *     offsetX = X offset, relative to the start point
186 	 *     offsetY = Y offset, relative to the start point
187 	 *
188 	 * Since: 3.14
189 	 */
190 	void addOnDragEnd(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
191 	{
192 		if ( "drag-end" !in connectedSignals )
193 		{
194 			Signals.connectData(
195 				this,
196 				"drag-end",
197 				cast(GCallback)&callBackDragEnd,
198 				cast(void*)this,
199 				null,
200 				connectFlags);
201 			connectedSignals["drag-end"] = 1;
202 		}
203 		onDragEndListeners ~= dlg;
204 	}
205 	extern(C) static void callBackDragEnd(GtkGestureDrag* gesturedragStruct, double offsetX, double offsetY, GestureDrag _gesturedrag)
206 	{
207 		foreach ( void delegate(double, double, GestureDrag) dlg; _gesturedrag.onDragEndListeners )
208 		{
209 			dlg(offsetX, offsetY, _gesturedrag);
210 		}
211 	}
212 
213 	void delegate(double, double, GestureDrag)[] onDragUpdateListeners;
214 	/**
215 	 * This signal is emitted whenever the dragging point moves.
216 	 *
217 	 * Params:
218 	 *     offsetX = X offset, relative to the start point
219 	 *     offsetY = Y offset, relative to the start point
220 	 *
221 	 * Since: 3.14
222 	 */
223 	void addOnDragUpdate(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
224 	{
225 		if ( "drag-update" !in connectedSignals )
226 		{
227 			Signals.connectData(
228 				this,
229 				"drag-update",
230 				cast(GCallback)&callBackDragUpdate,
231 				cast(void*)this,
232 				null,
233 				connectFlags);
234 			connectedSignals["drag-update"] = 1;
235 		}
236 		onDragUpdateListeners ~= dlg;
237 	}
238 	extern(C) static void callBackDragUpdate(GtkGestureDrag* gesturedragStruct, double offsetX, double offsetY, GestureDrag _gesturedrag)
239 	{
240 		foreach ( void delegate(double, double, GestureDrag) dlg; _gesturedrag.onDragUpdateListeners )
241 		{
242 			dlg(offsetX, offsetY, _gesturedrag);
243 		}
244 	}
245 }