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 private import gtk.c.functions;
34 public  import gtk.c.types;
35 public  import gtkc.gtktypes;
36 private import std.algorithm;
37 
38 
39 /**
40  * #GtkGestureDrag is a #GtkGesture implementation that recognizes drag
41  * operations. The drag operation itself can be tracked throught the
42  * #GtkGestureDrag::drag-begin, #GtkGestureDrag::drag-update and
43  * #GtkGestureDrag::drag-end signals, or the relevant coordinates be
44  * extracted through gtk_gesture_drag_get_offset() and
45  * gtk_gesture_drag_get_start_point().
46  */
47 public class GestureDrag : GestureSingle
48 {
49 	/** the main Gtk struct */
50 	protected GtkGestureDrag* gtkGestureDrag;
51 
52 	/** Get the main Gtk struct */
53 	public GtkGestureDrag* getGestureDragStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gtkGestureDrag;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gtkGestureDrag;
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GtkGestureDrag* gtkGestureDrag, bool ownedRef = false)
70 	{
71 		this.gtkGestureDrag = gtkGestureDrag;
72 		super(cast(GtkGestureSingle*)gtkGestureDrag, ownedRef);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return gtk_gesture_drag_get_type();
80 	}
81 
82 	/**
83 	 * Returns a newly created #GtkGesture that recognizes drags.
84 	 *
85 	 * Params:
86 	 *     widget = a #GtkWidget
87 	 *
88 	 * Returns: a newly created #GtkGestureDrag
89 	 *
90 	 * Since: 3.14
91 	 *
92 	 * Throws: ConstructionException GTK+ fails to create the object.
93 	 */
94 	public this(Widget widget)
95 	{
96 		auto p = gtk_gesture_drag_new((widget is null) ? null : widget.getWidgetStruct());
97 
98 		if(p is null)
99 		{
100 			throw new ConstructionException("null returned by new");
101 		}
102 
103 		this(cast(GtkGestureDrag*) p, true);
104 	}
105 
106 	/**
107 	 * If the @gesture is active, this function returns %TRUE and
108 	 * fills in @x and @y with the coordinates of the current point,
109 	 * as an offset to the starting drag point.
110 	 *
111 	 * Params:
112 	 *     x = X offset for the current point
113 	 *     y = Y offset for the current point
114 	 *
115 	 * Returns: %TRUE if the gesture is active
116 	 *
117 	 * Since: 3.14
118 	 */
119 	public bool getOffset(out double x, out double y)
120 	{
121 		return gtk_gesture_drag_get_offset(gtkGestureDrag, &x, &y) != 0;
122 	}
123 
124 	/**
125 	 * If the @gesture is active, this function returns %TRUE
126 	 * and fills in @x and @y with the drag start coordinates,
127 	 * in window-relative coordinates.
128 	 *
129 	 * Params:
130 	 *     x = X coordinate for the drag start point
131 	 *     y = Y coordinate for the drag start point
132 	 *
133 	 * Returns: %TRUE if the gesture is active
134 	 *
135 	 * Since: 3.14
136 	 */
137 	public bool getStartPoint(out double x, out double y)
138 	{
139 		return gtk_gesture_drag_get_start_point(gtkGestureDrag, &x, &y) != 0;
140 	}
141 
142 	/**
143 	 * This signal is emitted whenever dragging starts.
144 	 *
145 	 * Params:
146 	 *     startX = X coordinate, relative to the widget allocation
147 	 *     startY = Y coordinate, relative to the widget allocation
148 	 *
149 	 * Since: 3.14
150 	 */
151 	gulong addOnDragBegin(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
152 	{
153 		return Signals.connect(this, "drag-begin", dlg, connectFlags ^ ConnectFlags.SWAPPED);
154 	}
155 
156 	/**
157 	 * This signal is emitted whenever the dragging is finished.
158 	 *
159 	 * Params:
160 	 *     offsetX = X offset, relative to the start point
161 	 *     offsetY = Y offset, relative to the start point
162 	 *
163 	 * Since: 3.14
164 	 */
165 	gulong addOnDragEnd(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
166 	{
167 		return Signals.connect(this, "drag-end", dlg, connectFlags ^ ConnectFlags.SWAPPED);
168 	}
169 
170 	/**
171 	 * This signal is emitted whenever the dragging point moves.
172 	 *
173 	 * Params:
174 	 *     offsetX = X offset, relative to the start point
175 	 *     offsetY = Y offset, relative to the start point
176 	 *
177 	 * Since: 3.14
178 	 */
179 	gulong addOnDragUpdate(void delegate(double, double, GestureDrag) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
180 	{
181 		return Signals.connect(this, "drag-update", dlg, connectFlags ^ ConnectFlags.SWAPPED);
182 	}
183 }