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.GesturePan; 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.GestureDrag; 32 private import gtk.Widget; 33 public import gtkc.gdktypes; 34 private import gtkc.gtk; 35 public import gtkc.gtktypes; 36 37 38 /** 39 * #GtkGesturePan is a #GtkGesture implementation able to recognize 40 * pan gestures, those are drags that are locked to happen along one 41 * axis. The axis that a #GtkGesturePan handles is defined at 42 * construct time, and can be changed through 43 * gtk_gesture_pan_set_orientation(). 44 * 45 * When the gesture starts to be recognized, #GtkGesturePan will 46 * attempt to determine as early as possible whether the sequence 47 * is moving in the expected direction, and denying the sequence if 48 * this does not happen. 49 * 50 * Once a panning gesture along the expected axis is recognized, 51 * the #GtkGesturePan::pan signal will be emitted as input events 52 * are received, containing the offset in the given axis. 53 */ 54 public class GesturePan : GestureDrag 55 { 56 /** the main Gtk struct */ 57 protected GtkGesturePan* gtkGesturePan; 58 59 /** Get the main Gtk struct */ 60 public GtkGesturePan* getGesturePanStruct() 61 { 62 return gtkGesturePan; 63 } 64 65 /** the main Gtk struct as a void* */ 66 protected override void* getStruct() 67 { 68 return cast(void*)gtkGesturePan; 69 } 70 71 protected override void setStruct(GObject* obj) 72 { 73 gtkGesturePan = cast(GtkGesturePan*)obj; 74 super.setStruct(obj); 75 } 76 77 /** 78 * Sets our main struct and passes it to the parent class. 79 */ 80 public this (GtkGesturePan* gtkGesturePan, bool ownedRef = false) 81 { 82 this.gtkGesturePan = gtkGesturePan; 83 super(cast(GtkGestureDrag*)gtkGesturePan, ownedRef); 84 } 85 86 87 /** */ 88 public static GType getType() 89 { 90 return gtk_gesture_pan_get_type(); 91 } 92 93 /** 94 * Returns a newly created #GtkGesture that recognizes pan gestures. 95 * 96 * Params: 97 * widget = a #GtkWidget 98 * orientation = expected orientation 99 * 100 * Return: a newly created #GtkGesturePan 101 * 102 * Since: 3.14 103 * 104 * Throws: ConstructionException GTK+ fails to create the object. 105 */ 106 public this(Widget widget, GtkOrientation orientation) 107 { 108 auto p = gtk_gesture_pan_new((widget is null) ? null : widget.getWidgetStruct(), orientation); 109 110 if(p is null) 111 { 112 throw new ConstructionException("null returned by new"); 113 } 114 115 this(cast(GtkGesturePan*) p, true); 116 } 117 118 /** 119 * Returns the orientation of the pan gestures that this @gesture expects. 120 * 121 * Return: the expected orientation for pan gestures 122 * 123 * Since: 3.14 124 */ 125 public GtkOrientation getOrientation() 126 { 127 return gtk_gesture_pan_get_orientation(gtkGesturePan); 128 } 129 130 /** 131 * Sets the orientation to be expected on pan gestures. 132 * 133 * Params: 134 * orientation = expected orientation 135 * 136 * Since: 3.14 137 */ 138 public void setOrientation(GtkOrientation orientation) 139 { 140 gtk_gesture_pan_set_orientation(gtkGesturePan, orientation); 141 } 142 143 int[string] connectedSignals; 144 145 void delegate(GtkPanDirection, double, GesturePan)[] onPanListeners; 146 /** 147 * This signal is emitted once a panning gesture along the 148 * expected axis is detected. 149 * 150 * Params: 151 * direction = current direction of the pan gesture 152 * offset = Offset along the gesture orientation 153 * 154 * Since: 3.14 155 */ 156 void addOnPan(void delegate(GtkPanDirection, double, GesturePan) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 157 { 158 if ( "pan" !in connectedSignals ) 159 { 160 Signals.connectData( 161 this, 162 "pan", 163 cast(GCallback)&callBackPan, 164 cast(void*)this, 165 null, 166 connectFlags); 167 connectedSignals["pan"] = 1; 168 } 169 onPanListeners ~= dlg; 170 } 171 extern(C) static void callBackPan(GtkGesturePan* gesturepanStruct, GtkPanDirection direction, double offset, GesturePan _gesturepan) 172 { 173 foreach ( void delegate(GtkPanDirection, double, GesturePan) dlg; _gesturepan.onPanListeners ) 174 { 175 dlg(direction, offset, _gesturepan); 176 } 177 } 178 }