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