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.GestureStylus;
26 
27 private import gdk.DeviceTool;
28 private import glib.ConstructionException;
29 private import gobject.ObjectG;
30 private import gobject.Signals;
31 private import gtk.Gesture;
32 private import gtk.GestureSingle;
33 private import gtk.Widget;
34 private import gtk.c.functions;
35 public  import gtk.c.types;
36 public  import gtkc.gtktypes;
37 private import std.algorithm;
38 
39 
40 /**
41  * #GtkGestureStylus is a #GtkGesture implementation specific to stylus
42  * input. The provided signals just provide the basic information
43  */
44 public class GestureStylus : GestureSingle
45 {
46 	/** the main Gtk struct */
47 	protected GtkGestureStylus* gtkGestureStylus;
48 
49 	/** Get the main Gtk struct */
50 	public GtkGestureStylus* getGestureStylusStruct(bool transferOwnership = false)
51 	{
52 		if (transferOwnership)
53 			ownedRef = false;
54 		return gtkGestureStylus;
55 	}
56 
57 	/** the main Gtk struct as a void* */
58 	protected override void* getStruct()
59 	{
60 		return cast(void*)gtkGestureStylus;
61 	}
62 
63 	/**
64 	 * Sets our main struct and passes it to the parent class.
65 	 */
66 	public this (GtkGestureStylus* gtkGestureStylus, bool ownedRef = false)
67 	{
68 		this.gtkGestureStylus = gtkGestureStylus;
69 		super(cast(GtkGestureSingle*)gtkGestureStylus, ownedRef);
70 	}
71 
72 
73 	/** */
74 	public static GType getType()
75 	{
76 		return gtk_gesture_stylus_get_type();
77 	}
78 
79 	/**
80 	 * Creates a new #GtkGestureStylus.
81 	 *
82 	 * Params:
83 	 *     widget = a #GtkWidget
84 	 *
85 	 * Returns: a newly created stylus gesture
86 	 *
87 	 * Since: 3.24
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this(Widget widget)
92 	{
93 		auto p = gtk_gesture_stylus_new((widget is null) ? null : widget.getWidgetStruct());
94 
95 		if(p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 
100 		this(cast(GtkGestureStylus*) p, true);
101 	}
102 
103 	/**
104 	 * Returns the current values for the requested @axes. This function
105 	 * must be called from either the #GtkGestureStylus:down,
106 	 * #GtkGestureStylus:motion, #GtkGestureStylus:up or #GtkGestureStylus:proximity
107 	 * signals.
108 	 *
109 	 * Params:
110 	 *     axes = array of requested axes, terminated with #GDK_AXIS_IGNORE
111 	 *     values = return location for the axis values
112 	 *
113 	 * Returns: #TRUE if there is a current value for the axes
114 	 *
115 	 * Since: 3.24
116 	 */
117 	public bool getAxes(GdkAxisUse[] axes, out double[] values)
118 	{
119 		double* outvalues = null;
120 
121 		auto p = gtk_gesture_stylus_get_axes(gtkGestureStylus, axes.ptr, &outvalues) != 0;
122 
123 		values = outvalues[0 .. getArrayLength(outvalues)];
124 
125 		return p;
126 	}
127 
128 	/**
129 	 * Returns the current value for the requested @axis. This function
130 	 * must be called from either the #GtkGestureStylus:down,
131 	 * #GtkGestureStylus:motion, #GtkGestureStylus:up or #GtkGestureStylus:proximity
132 	 * signals.
133 	 *
134 	 * Params:
135 	 *     axis = requested device axis
136 	 *     value = return location for the axis value
137 	 *
138 	 * Returns: #TRUE if there is a current value for the axis
139 	 *
140 	 * Since: 3.24
141 	 */
142 	public bool getAxis(GdkAxisUse axis, out double value)
143 	{
144 		return gtk_gesture_stylus_get_axis(gtkGestureStylus, axis, &value) != 0;
145 	}
146 
147 	/**
148 	 * Returns the #GdkDeviceTool currently driving input through this gesture.
149 	 * This function must be called from either the #GtkGestureStylus::down,
150 	 * #GtkGestureStylus::motion, #GtkGestureStylus::up or #GtkGestureStylus::proximity
151 	 * signal handlers.
152 	 *
153 	 * Returns: The current stylus tool
154 	 *
155 	 * Since: 3.24
156 	 */
157 	public DeviceTool getDeviceTool()
158 	{
159 		auto p = gtk_gesture_stylus_get_device_tool(gtkGestureStylus);
160 
161 		if(p is null)
162 		{
163 			return null;
164 		}
165 
166 		return ObjectG.getDObject!(DeviceTool)(cast(GdkDeviceTool*) p);
167 	}
168 
169 	/** */
170 	gulong addOnDown(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
171 	{
172 		return Signals.connect(this, "down", dlg, connectFlags ^ ConnectFlags.SWAPPED);
173 	}
174 
175 	/** */
176 	gulong addOnMotion(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
177 	{
178 		return Signals.connect(this, "motion", dlg, connectFlags ^ ConnectFlags.SWAPPED);
179 	}
180 
181 	/** */
182 	gulong addOnProximity(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
183 	{
184 		return Signals.connect(this, "proximity", dlg, connectFlags ^ ConnectFlags.SWAPPED);
185 	}
186 
187 	/** */
188 	gulong addOnUp(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
189 	{
190 		return Signals.connect(this, "up", dlg, connectFlags ^ ConnectFlags.SWAPPED);
191 	}
192 }