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 	public static GType getType()
82 	{
83 		return gtk_gesture_long_press_get_type();
84 	}
85 
86 	/**
87 	 * Returns a newly created #GtkGesture that recognizes long presses.
88 	 *
89 	 * Params:
90 	 *     widget = a #GtkWidget
91 	 *
92 	 * Return: a newly created #GtkGestureLongPress
93 	 *
94 	 * Since: 3.14
95 	 *
96 	 * Throws: ConstructionException GTK+ fails to create the object.
97 	 */
98 	public this(Widget widget)
99 	{
100 		auto p = gtk_gesture_long_press_new((widget is null) ? null : widget.getWidgetStruct());
101 		
102 		if(p is null)
103 		{
104 			throw new ConstructionException("null returned by new");
105 		}
106 		
107 		this(cast(GtkGestureLongPress*) p, true);
108 	}
109 
110 	int[string] connectedSignals;
111 
112 	void delegate(GestureLongPress)[] onCancelledListeners;
113 	/**
114 	 * This signal is emitted whenever a press moved too far, or was released
115 	 * before #GtkGestureLongPress::pressed happened.
116 	 *
117 	 * Since: 3.14
118 	 */
119 	void addOnCancelled(void delegate(GestureLongPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
120 	{
121 		if ( "cancelled" !in connectedSignals )
122 		{
123 			Signals.connectData(
124 				this,
125 				"cancelled",
126 				cast(GCallback)&callBackCancelled,
127 				cast(void*)this,
128 				null,
129 				connectFlags);
130 			connectedSignals["cancelled"] = 1;
131 		}
132 		onCancelledListeners ~= dlg;
133 	}
134 	extern(C) static void callBackCancelled(GtkGestureLongPress* gesturelongpressStruct, GestureLongPress _gesturelongpress)
135 	{
136 		foreach ( void delegate(GestureLongPress) dlg; _gesturelongpress.onCancelledListeners )
137 		{
138 			dlg(_gesturelongpress);
139 		}
140 	}
141 
142 	void delegate(double, double, GestureLongPress)[] onPressedListeners;
143 	/**
144 	 * This signal is emitted whenever a press goes unmoved/unreleased longer than
145 	 * what the GTK+ defaults tell.
146 	 *
147 	 * Params:
148 	 *     x = the X coordinate where the press happened, relative to the widget allocation
149 	 *     y = the Y coordinate where the press happened, relative to the widget allocation
150 	 *
151 	 * Since: 3.14
152 	 */
153 	void addOnPressed(void delegate(double, double, GestureLongPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
154 	{
155 		if ( "pressed" !in connectedSignals )
156 		{
157 			Signals.connectData(
158 				this,
159 				"pressed",
160 				cast(GCallback)&callBackPressed,
161 				cast(void*)this,
162 				null,
163 				connectFlags);
164 			connectedSignals["pressed"] = 1;
165 		}
166 		onPressedListeners ~= dlg;
167 	}
168 	extern(C) static void callBackPressed(GtkGestureLongPress* gesturelongpressStruct, double x, double y, GestureLongPress _gesturelongpress)
169 	{
170 		foreach ( void delegate(double, double, GestureLongPress) dlg; _gesturelongpress.onPressedListeners )
171 		{
172 			dlg(x, y, _gesturelongpress);
173 		}
174 	}
175 }