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 85 public static GType getType() 86 { 87 return gtk_gesture_multi_press_get_type(); 88 } 89 90 /** 91 * Returns a newly created #GtkGesture that recognizes single and multiple 92 * presses. 93 * 94 * Params: 95 * widget = a #GtkWidget 96 * 97 * Return: a newly created #GtkGestureMultiPress 98 * 99 * Since: 3.14 100 * 101 * Throws: ConstructionException GTK+ fails to create the object. 102 */ 103 public this(Widget widget) 104 { 105 auto p = gtk_gesture_multi_press_new((widget is null) ? null : widget.getWidgetStruct()); 106 107 if(p is null) 108 { 109 throw new ConstructionException("null returned by new"); 110 } 111 112 this(cast(GtkGestureMultiPress*) p, true); 113 } 114 115 /** 116 * If an area was set through gtk_gesture_multi_press_set_area(), 117 * this function will return %TRUE and fill in @rect with the 118 * press area. See gtk_gesture_multi_press_set_area() for more 119 * details on what the press area represents. 120 * 121 * Params: 122 * rect = return location for the press area 123 * 124 * Return: %TRUE if @rect was filled with the press area 125 * 126 * Since: 3.14 127 */ 128 public bool getArea(out GdkRectangle rect) 129 { 130 return gtk_gesture_multi_press_get_area(gtkGestureMultiPress, &rect) != 0; 131 } 132 133 /** 134 * If @rect is non-%NULL, the press area will be checked to be 135 * confined within the rectangle, otherwise the button count 136 * will be reset so the press is seen as being the first one. 137 * If @rect is #NULL, the area will be reset to an unrestricted 138 * state. 139 * 140 * Note: The rectangle is only used to determine whether any 141 * non-first click falls within the expected area. This is not 142 * akin to an input shape. 143 * 144 * Params: 145 * rect = rectangle to receive coordinates on 146 * 147 * Since: 3.14 148 */ 149 public void setArea(GdkRectangle* rect) 150 { 151 gtk_gesture_multi_press_set_area(gtkGestureMultiPress, rect); 152 } 153 154 int[string] connectedSignals; 155 156 void delegate(int, double, double, GestureMultiPress)[] onPressedListeners; 157 /** 158 * This signal is emitted whenever a button or touch press happens. 159 * 160 * Params: 161 * nPress = how many touch/button presses happened with this one 162 * x = The X coordinate, in widget allocation coordinates 163 * y = The Y coordinate, in widget allocation coordinates 164 * 165 * Since: 3.14 166 */ 167 void addOnPressed(void delegate(int, double, double, GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 168 { 169 if ( "pressed" !in connectedSignals ) 170 { 171 Signals.connectData( 172 this, 173 "pressed", 174 cast(GCallback)&callBackPressed, 175 cast(void*)this, 176 null, 177 connectFlags); 178 connectedSignals["pressed"] = 1; 179 } 180 onPressedListeners ~= dlg; 181 } 182 extern(C) static void callBackPressed(GtkGestureMultiPress* gesturemultipressStruct, int nPress, double x, double y, GestureMultiPress _gesturemultipress) 183 { 184 foreach ( void delegate(int, double, double, GestureMultiPress) dlg; _gesturemultipress.onPressedListeners ) 185 { 186 dlg(nPress, x, y, _gesturemultipress); 187 } 188 } 189 190 void delegate(int, double, double, GestureMultiPress)[] onReleasedListeners; 191 /** 192 * This signal is emitted when a button or touch is released. @n_press 193 * will report the number of press that is paired to this event, note 194 * that #GtkGestureMultiPress::stopped may have been emitted between the 195 * press and its release, @n_press will only start over at the next press. 196 * 197 * Params: 198 * nPress = number of press that is paired with this release 199 * x = The X coordinate, in widget allocation coordinates 200 * y = The Y coordinate, in widget allocation coordinates 201 * 202 * Since: 3.14 203 */ 204 void addOnReleased(void delegate(int, double, double, GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 205 { 206 if ( "released" !in connectedSignals ) 207 { 208 Signals.connectData( 209 this, 210 "released", 211 cast(GCallback)&callBackReleased, 212 cast(void*)this, 213 null, 214 connectFlags); 215 connectedSignals["released"] = 1; 216 } 217 onReleasedListeners ~= dlg; 218 } 219 extern(C) static void callBackReleased(GtkGestureMultiPress* gesturemultipressStruct, int nPress, double x, double y, GestureMultiPress _gesturemultipress) 220 { 221 foreach ( void delegate(int, double, double, GestureMultiPress) dlg; _gesturemultipress.onReleasedListeners ) 222 { 223 dlg(nPress, x, y, _gesturemultipress); 224 } 225 } 226 227 void delegate(GestureMultiPress)[] onStoppedListeners; 228 /** 229 * This signal is emitted whenever any time/distance threshold has 230 * been exceeded. 231 * 232 * Since: 3.14 233 */ 234 void addOnStopped(void delegate(GestureMultiPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 235 { 236 if ( "stopped" !in connectedSignals ) 237 { 238 Signals.connectData( 239 this, 240 "stopped", 241 cast(GCallback)&callBackStopped, 242 cast(void*)this, 243 null, 244 connectFlags); 245 connectedSignals["stopped"] = 1; 246 } 247 onStoppedListeners ~= dlg; 248 } 249 extern(C) static void callBackStopped(GtkGestureMultiPress* gesturemultipressStruct, GestureMultiPress _gesturemultipress) 250 { 251 foreach ( void delegate(GestureMultiPress) dlg; _gesturemultipress.onStoppedListeners ) 252 { 253 dlg(_gesturemultipress); 254 } 255 } 256 }