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 public  import gtkc.gdktypes;
34 private import gtkc.gtk;
35 public  import gtkc.gtktypes;
36 
37 
38 /**
39  * #GtkGestureMultiPress is a #GtkGesture implementation able to recognize
40  * multiple clicks on a nearby zone, which can be listened for through the
41  * #GtkGestureMultiPress::pressed signal. Whenever time or distance between
42  * clicks exceed the GTK+ defaults, #GtkGestureMultiPress::stopped is emitted,
43  * and the click counter is reset.
44  * 
45  * Callers may also restrict the area that is considered valid for a >1
46  * touch/button press through gtk_gesture_multi_press_set_area(), so any
47  * click happening outside that area is considered to be a first click of
48  * its own.
49  */
50 public class GestureMultiPress : GestureSingle
51 {
52 	/** the main Gtk struct */
53 	protected GtkGestureMultiPress* gtkGestureMultiPress;
54 
55 	/** Get the main Gtk struct */
56 	public GtkGestureMultiPress* getGestureMultiPressStruct()
57 	{
58 		return gtkGestureMultiPress;
59 	}
60 
61 	/** the main Gtk struct as a void* */
62 	protected override void* getStruct()
63 	{
64 		return cast(void*)gtkGestureMultiPress;
65 	}
66 
67 	protected override void setStruct(GObject* obj)
68 	{
69 		gtkGestureMultiPress = cast(GtkGestureMultiPress*)obj;
70 		super.setStruct(obj);
71 	}
72 
73 	/**
74 	 * Sets our main struct and passes it to the parent class.
75 	 */
76 	public this (GtkGestureMultiPress* gtkGestureMultiPress, bool ownedRef = false)
77 	{
78 		this.gtkGestureMultiPress = gtkGestureMultiPress;
79 		super(cast(GtkGestureSingle*)gtkGestureMultiPress, ownedRef);
80 	}
81 
82 
83 	/** */
84 	public static GType getType()
85 	{
86 		return gtk_gesture_multi_press_get_type();
87 	}
88 
89 	/**
90 	 * Returns a newly created #GtkGesture that recognizes single and multiple
91 	 * presses.
92 	 *
93 	 * Params:
94 	 *     widget = a #GtkWidget
95 	 *
96 	 * Return: a newly created #GtkGestureMultiPress
97 	 *
98 	 * Since: 3.14
99 	 *
100 	 * Throws: ConstructionException GTK+ fails to create the object.
101 	 */
102 	public this(Widget widget)
103 	{
104 		auto p = gtk_gesture_multi_press_new((widget is null) ? null : widget.getWidgetStruct());
105 		
106 		if(p is null)
107 		{
108 			throw new ConstructionException("null returned by new");
109 		}
110 		
111 		this(cast(GtkGestureMultiPress*) p, true);
112 	}
113 
114 	/**
115 	 * If an area was set through gtk_gesture_multi_press_set_area(),
116 	 * this function will return %TRUE and fill in @rect with the
117 	 * press area. See gtk_gesture_multi_press_set_area() for more
118 	 * details on what the press area represents.
119 	 *
120 	 * Params:
121 	 *     rect = return location for the press area
122 	 *
123 	 * Return: %TRUE if @rect was filled with the press area
124 	 *
125 	 * Since: 3.14
126 	 */
127 	public bool getArea(out GdkRectangle rect)
128 	{
129 		return gtk_gesture_multi_press_get_area(gtkGestureMultiPress, &rect) != 0;
130 	}
131 
132 	/**
133 	 * If @rect is non-%NULL, the press area will be checked to be
134 	 * confined within the rectangle, otherwise the button count
135 	 * will be reset so the press is seen as being the first one.
136 	 * If @rect is #NULL, the area will be reset to an unrestricted
137 	 * state.
138 	 *
139 	 * Note: The rectangle is only used to determine whether any
140 	 * non-first click falls within the expected area. This is not
141 	 * akin to an input shape.
142 	 *
143 	 * Params:
144 	 *     rect = rectangle to receive coordinates on
145 	 *
146 	 * Since: 3.14
147 	 */
148 	public void setArea(GdkRectangle* rect)
149 	{
150 		gtk_gesture_multi_press_set_area(gtkGestureMultiPress, rect);
151 	}
152 
153 	int[string] connectedSignals;
154 
155 	void delegate(int, double, double, GestureMultiPress)[] onPressedListeners;
156 	/**
157 	 * This signal is emitted whenever a button or touch press happens.
158 	 *
159 	 * Params:
160 	 *     nPress = how many touch/button presses happened with this one
161 	 *     x = The X coordinate, in widget allocation coordinates
162 	 *     y = The Y coordinate, in widget allocation coordinates
163 	 *
164 	 * Since: 3.14
165 	 */
166 	void addOnPressed(void delegate(int, double, double, GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
167 	{
168 		if ( "pressed" !in connectedSignals )
169 		{
170 			Signals.connectData(
171 				this,
172 				"pressed",
173 				cast(GCallback)&callBackPressed,
174 				cast(void*)this,
175 				null,
176 				connectFlags);
177 			connectedSignals["pressed"] = 1;
178 		}
179 		onPressedListeners ~= dlg;
180 	}
181 	extern(C) static void callBackPressed(GtkGestureMultiPress* gesturemultipressStruct, int nPress, double x, double y, GestureMultiPress _gesturemultipress)
182 	{
183 		foreach ( void delegate(int, double, double, GestureMultiPress) dlg; _gesturemultipress.onPressedListeners )
184 		{
185 			dlg(nPress, x, y, _gesturemultipress);
186 		}
187 	}
188 
189 	void delegate(int, double, double, GestureMultiPress)[] onReleasedListeners;
190 	/**
191 	 * This signal is emitted when a button or touch is released. @n_press
192 	 * will report the number of press that is paired to this event, note
193 	 * that #GtkGestureMultiPress::stopped may have been emitted between the
194 	 * press and its release, @n_press will only start over at the next press.
195 	 *
196 	 * Params:
197 	 *     nPress = number of press that is paired with this release
198 	 *     x = The X coordinate, in widget allocation coordinates
199 	 *     y = The Y coordinate, in widget allocation coordinates
200 	 *
201 	 * Since: 3.14
202 	 */
203 	void addOnReleased(void delegate(int, double, double, GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
204 	{
205 		if ( "released" !in connectedSignals )
206 		{
207 			Signals.connectData(
208 				this,
209 				"released",
210 				cast(GCallback)&callBackReleased,
211 				cast(void*)this,
212 				null,
213 				connectFlags);
214 			connectedSignals["released"] = 1;
215 		}
216 		onReleasedListeners ~= dlg;
217 	}
218 	extern(C) static void callBackReleased(GtkGestureMultiPress* gesturemultipressStruct, int nPress, double x, double y, GestureMultiPress _gesturemultipress)
219 	{
220 		foreach ( void delegate(int, double, double, GestureMultiPress) dlg; _gesturemultipress.onReleasedListeners )
221 		{
222 			dlg(nPress, x, y, _gesturemultipress);
223 		}
224 	}
225 
226 	void delegate(GestureMultiPress)[] onStoppedListeners;
227 	/**
228 	 * This signal is emitted whenever any time/distance threshold has
229 	 * been exceeded.
230 	 *
231 	 * Since: 3.14
232 	 */
233 	void addOnStopped(void delegate(GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
234 	{
235 		if ( "stopped" !in connectedSignals )
236 		{
237 			Signals.connectData(
238 				this,
239 				"stopped",
240 				cast(GCallback)&callBackStopped,
241 				cast(void*)this,
242 				null,
243 				connectFlags);
244 			connectedSignals["stopped"] = 1;
245 		}
246 		onStoppedListeners ~= dlg;
247 	}
248 	extern(C) static void callBackStopped(GtkGestureMultiPress* gesturemultipressStruct, GestureMultiPress _gesturemultipress)
249 	{
250 		foreach ( void delegate(GestureMultiPress) dlg; _gesturemultipress.onStoppedListeners )
251 		{
252 			dlg(_gesturemultipress);
253 		}
254 	}
255 }