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.c.functions; 34 public import gtk.c.types; 35 private import std.algorithm; 36 37 38 /** 39 * `GtkGestureStylus` is a `GtkGesture` specific to stylus input. 40 * 41 * The provided signals just relay the basic information of the 42 * stylus events. 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 * Returns: a newly created stylus gesture 83 * 84 * Throws: ConstructionException GTK+ fails to create the object. 85 */ 86 public this() 87 { 88 auto __p = gtk_gesture_stylus_new(); 89 90 if(__p is null) 91 { 92 throw new ConstructionException("null returned by new"); 93 } 94 95 this(cast(GtkGestureStylus*) __p, true); 96 } 97 98 /** 99 * Returns the current values for the requested @axes. 100 * 101 * This function must be called from the handler of one of the 102 * [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion], 103 * [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity] 104 * signals. 105 * 106 * Params: 107 * axes = array of requested axes, terminated with %GDK_AXIS_IGNORE 108 * values = return location for the axis values 109 * 110 * Returns: %TRUE if there is a current value for the axes 111 */ 112 public bool getAxes(GdkAxisUse[] axes, out double[] values) 113 { 114 double* outvalues; 115 116 auto __p = gtk_gesture_stylus_get_axes(gtkGestureStylus, axes.ptr, &outvalues) != 0; 117 118 values = outvalues[0 .. getArrayLength(outvalues)]; 119 120 return __p; 121 } 122 123 /** 124 * Returns the current value for the requested @axis. 125 * 126 * This function must be called from the handler of one of the 127 * [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion], 128 * [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity] 129 * signals. 130 * 131 * Params: 132 * axis = requested device axis 133 * value = return location for the axis value 134 * 135 * Returns: %TRUE if there is a current value for the axis 136 */ 137 public bool getAxis(GdkAxisUse axis, out double value) 138 { 139 return gtk_gesture_stylus_get_axis(gtkGestureStylus, axis, &value) != 0; 140 } 141 142 /** 143 * Returns the accumulated backlog of tracking information. 144 * 145 * By default, GTK will limit rate of input events. On stylus input 146 * where accuracy of strokes is paramount, this function returns the 147 * accumulated coordinate/timing state before the emission of the 148 * current [Gtk.GestureStylus::motion] signal. 149 * 150 * This function may only be called within a [signal@Gtk.GestureStylus::motion] 151 * signal handler, the state given in this signal and obtainable through 152 * [method@Gtk.GestureStylus.get_axis] express the latest (most up-to-date) 153 * state in motion history. 154 * 155 * The @backlog is provided in chronological order. 156 * 157 * Params: 158 * backlog = coordinates and times for the backlog events 159 * 160 * Returns: %TRUE if there is a backlog to unfold in the current state. 161 */ 162 public bool getBacklog(out GdkTimeCoord[] backlog) 163 { 164 GdkTimeCoord* outbacklog; 165 uint nElems; 166 167 auto __p = gtk_gesture_stylus_get_backlog(gtkGestureStylus, &outbacklog, &nElems) != 0; 168 169 backlog = outbacklog[0 .. nElems]; 170 171 return __p; 172 } 173 174 /** 175 * Returns the `GdkDeviceTool` currently driving input through this gesture. 176 * 177 * This function must be called from the handler of one of the 178 * [signal@Gtk.GestureStylus::down], [signal@Gtk.GestureStylus::motion], 179 * [signal@Gtk.GestureStylus::up] or [signal@Gtk.GestureStylus::proximity] 180 * signals. 181 * 182 * Returns: The current stylus tool 183 */ 184 public DeviceTool getDeviceTool() 185 { 186 auto __p = gtk_gesture_stylus_get_device_tool(gtkGestureStylus); 187 188 if(__p is null) 189 { 190 return null; 191 } 192 193 return ObjectG.getDObject!(DeviceTool)(cast(GdkDeviceTool*) __p); 194 } 195 196 /** 197 * Emitted when the stylus touches the device. 198 * 199 * Params: 200 * x = the X coordinate of the stylus event 201 * y = the Y coordinate of the stylus event 202 */ 203 gulong addOnDown(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 204 { 205 return Signals.connect(this, "down", dlg, connectFlags ^ ConnectFlags.SWAPPED); 206 } 207 208 /** 209 * Emitted when the stylus moves while touching the device. 210 * 211 * Params: 212 * x = the X coordinate of the stylus event 213 * y = the Y coordinate of the stylus event 214 */ 215 gulong addOnMotion(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 216 { 217 return Signals.connect(this, "motion", dlg, connectFlags ^ ConnectFlags.SWAPPED); 218 } 219 220 /** 221 * Emitted when the stylus is in proximity of the device. 222 * 223 * Params: 224 * x = the X coordinate of the stylus event 225 * y = the Y coordinate of the stylus event 226 */ 227 gulong addOnProximity(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 228 { 229 return Signals.connect(this, "proximity", dlg, connectFlags ^ ConnectFlags.SWAPPED); 230 } 231 232 /** 233 * Emitted when the stylus no longer touches the device. 234 * 235 * Params: 236 * x = the X coordinate of the stylus event 237 * y = the Y coordinate of the stylus event 238 */ 239 gulong addOnUp(void delegate(double, double, GestureStylus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 240 { 241 return Signals.connect(this, "up", dlg, connectFlags ^ ConnectFlags.SWAPPED); 242 } 243 }