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.GestureLongPress;
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  * #GtkGestureLongPress is a #GtkGesture implementation able to recognize
40  * long presses, triggering the #GtkGestureLongPress::pressed after the
41  * timeout is exceeded.
42  * 
43  * If the touchpoint is lifted before the timeout passes, or if it drifts
44  * too far of the initial press point, the #GtkGestureLongPress::cancelled
45  * signal will be emitted.
46  */
47 public class GestureLongPress : GestureSingle
48 {
49 	/** the main Gtk struct */
50 	protected GtkGestureLongPress* gtkGestureLongPress;
51 
52 	/** Get the main Gtk struct */
53 	public GtkGestureLongPress* getGestureLongPressStruct()
54 	{
55 		return gtkGestureLongPress;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gtkGestureLongPress;
62 	}
63 
64 	protected override void setStruct(GObject* obj)
65 	{
66 		gtkGestureLongPress = cast(GtkGestureLongPress*)obj;
67 		super.setStruct(obj);
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GtkGestureLongPress* gtkGestureLongPress, bool ownedRef = false)
74 	{
75 		this.gtkGestureLongPress = gtkGestureLongPress;
76 		super(cast(GtkGestureSingle*)gtkGestureLongPress, ownedRef);
77 	}
78 
79 	/**
80 	 */
81 
82 	public static GType getType()
83 	{
84 		return gtk_gesture_long_press_get_type();
85 	}
86 
87 	/**
88 	 * Returns a newly created #GtkGesture that recognizes long presses.
89 	 *
90 	 * Params:
91 	 *     widget = a #GtkWidget
92 	 *
93 	 * Return: a newly created #GtkGestureLongPress
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_long_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(GtkGestureLongPress*) p, true);
109 	}
110 
111 	int[string] connectedSignals;
112 
113 	void delegate(GestureLongPress)[] onCancelledListeners;
114 	/**
115 	 * This signal is emitted whenever a press moved too far, or was released
116 	 * before #GtkGestureLongPress:pressed happened.
117 	 *
118 	 * Since: 3.14
119 	 */
120 	void addOnCancelled(void delegate(GestureLongPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
121 	{
122 		if ( "cancelled" !in connectedSignals )
123 		{
124 			Signals.connectData(
125 				this,
126 				"cancelled",
127 				cast(GCallback)&callBackCancelled,
128 				cast(void*)this,
129 				null,
130 				connectFlags);
131 			connectedSignals["cancelled"] = 1;
132 		}
133 		onCancelledListeners ~= dlg;
134 	}
135 	extern(C) static void callBackCancelled(GtkGestureLongPress* gesturelongpressStruct, GestureLongPress _gesturelongpress)
136 	{
137 		foreach ( void delegate(GestureLongPress) dlg; _gesturelongpress.onCancelledListeners )
138 		{
139 			dlg(_gesturelongpress);
140 		}
141 	}
142 
143 	void delegate(double, double, GestureLongPress)[] onPressedListeners;
144 	/**
145 	 * This signal is emitted whenever a press goes unmoved/unreleased longer than
146 	 * what the GTK+ defaults tell.
147 	 *
148 	 * Params:
149 	 *     x = the X coordinate where the press happened, relative to the widget allocation
150 	 *     y = the Y coordinate where the press happened, relative to the widget allocation
151 	 *
152 	 * Since: 3.14
153 	 */
154 	void addOnPressed(void delegate(double, double, GestureLongPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
155 	{
156 		if ( "pressed" !in connectedSignals )
157 		{
158 			Signals.connectData(
159 				this,
160 				"pressed",
161 				cast(GCallback)&callBackPressed,
162 				cast(void*)this,
163 				null,
164 				connectFlags);
165 			connectedSignals["pressed"] = 1;
166 		}
167 		onPressedListeners ~= dlg;
168 	}
169 	extern(C) static void callBackPressed(GtkGestureLongPress* gesturelongpressStruct, double x, double y, GestureLongPress _gesturelongpress)
170 	{
171 		foreach ( void delegate(double, double, GestureLongPress) dlg; _gesturelongpress.onPressedListeners )
172 		{
173 			dlg(x, y, _gesturelongpress);
174 		}
175 	}
176 }