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.GestureMultiPress;
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  * #GtkGestureMultiPress is a #GtkGesture implementation able to recognize
41  * multiple clicks on a nearby zone, which can be listened for through the
42  * #GtkGestureMultiPress::pressed signal. Whenever time or distance between
43  * clicks exceed the GTK+ defaults, #GtkGestureMultiPress::stopped is emitted,
44  * and the click counter is reset.
45  * 
46  * Callers may also restrict the area that is considered valid for a >1
47  * touch/button press through gtk_gesture_multi_press_set_area(), so any
48  * click happening outside that area is considered to be a first click of
49  * its own.
50  */
51 public class GestureMultiPress : GestureSingle
52 {
53 	/** the main Gtk struct */
54 	protected GtkGestureMultiPress* gtkGestureMultiPress;
55 
56 	/** Get the main Gtk struct */
57 	public GtkGestureMultiPress* getGestureMultiPressStruct(bool transferOwnership = false)
58 	{
59 		if (transferOwnership)
60 			ownedRef = false;
61 		return gtkGestureMultiPress;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected override void* getStruct()
66 	{
67 		return cast(void*)gtkGestureMultiPress;
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GtkGestureMultiPress* gtkGestureMultiPress, bool ownedRef = false)
74 	{
75 		this.gtkGestureMultiPress = gtkGestureMultiPress;
76 		super(cast(GtkGestureSingle*)gtkGestureMultiPress, ownedRef);
77 	}
78 
79 
80 	/** */
81 	public static GType getType()
82 	{
83 		return gtk_gesture_multi_press_get_type();
84 	}
85 
86 	/**
87 	 * Returns a newly created #GtkGesture that recognizes single and multiple
88 	 * presses.
89 	 *
90 	 * Params:
91 	 *     widget = a #GtkWidget
92 	 *
93 	 * Returns: a newly created #GtkGestureMultiPress
94 	 *
95 	 * Since: 3.14
96 	 *
97 	 * Throws: ConstructionException GTK+ fails to create the object.
98 	 */
99 	public this(Widget widget)
100 	{
101 		auto p = gtk_gesture_multi_press_new((widget is null) ? null : widget.getWidgetStruct());
102 
103 		if(p is null)
104 		{
105 			throw new ConstructionException("null returned by new");
106 		}
107 
108 		this(cast(GtkGestureMultiPress*) p, true);
109 	}
110 
111 	/**
112 	 * If an area was set through gtk_gesture_multi_press_set_area(),
113 	 * this function will return %TRUE and fill in @rect with the
114 	 * press area. See gtk_gesture_multi_press_set_area() for more
115 	 * details on what the press area represents.
116 	 *
117 	 * Params:
118 	 *     rect = return location for the press area
119 	 *
120 	 * Returns: %TRUE if @rect was filled with the press area
121 	 *
122 	 * Since: 3.14
123 	 */
124 	public bool getArea(out GdkRectangle rect)
125 	{
126 		return gtk_gesture_multi_press_get_area(gtkGestureMultiPress, &rect) != 0;
127 	}
128 
129 	/**
130 	 * If @rect is non-%NULL, the press area will be checked to be
131 	 * confined within the rectangle, otherwise the button count
132 	 * will be reset so the press is seen as being the first one.
133 	 * If @rect is %NULL, the area will be reset to an unrestricted
134 	 * state.
135 	 *
136 	 * Note: The rectangle is only used to determine whether any
137 	 * non-first click falls within the expected area. This is not
138 	 * akin to an input shape.
139 	 *
140 	 * Params:
141 	 *     rect = rectangle to receive coordinates on
142 	 *
143 	 * Since: 3.14
144 	 */
145 	public void setArea(GdkRectangle* rect)
146 	{
147 		gtk_gesture_multi_press_set_area(gtkGestureMultiPress, rect);
148 	}
149 
150 	/**
151 	 * This signal is emitted whenever a button or touch press happens.
152 	 *
153 	 * Params:
154 	 *     nPress = how many touch/button presses happened with this one
155 	 *     x = The X coordinate, in widget allocation coordinates
156 	 *     y = The Y coordinate, in widget allocation coordinates
157 	 *
158 	 * Since: 3.14
159 	 */
160 	gulong addOnPressed(void delegate(int, double, double, GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
161 	{
162 		return Signals.connect(this, "pressed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
163 	}
164 
165 	/**
166 	 * This signal is emitted when a button or touch is released. @n_press
167 	 * will report the number of press that is paired to this event, note
168 	 * that #GtkGestureMultiPress::stopped may have been emitted between the
169 	 * press and its release, @n_press will only start over at the next press.
170 	 *
171 	 * Params:
172 	 *     nPress = number of press that is paired with this release
173 	 *     x = The X coordinate, in widget allocation coordinates
174 	 *     y = The Y coordinate, in widget allocation coordinates
175 	 *
176 	 * Since: 3.14
177 	 */
178 	gulong addOnReleased(void delegate(int, double, double, GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
179 	{
180 		return Signals.connect(this, "released", dlg, connectFlags ^ ConnectFlags.SWAPPED);
181 	}
182 
183 	/**
184 	 * This signal is emitted whenever any time/distance threshold has
185 	 * been exceeded.
186 	 *
187 	 * Since: 3.14
188 	 */
189 	gulong addOnStopped(void delegate(GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
190 	{
191 		return Signals.connect(this, "stopped", dlg, connectFlags ^ ConnectFlags.SWAPPED);
192 	}
193 }