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.c.functions; 33 public import gtk.c.types; 34 private import std.algorithm; 35 36 37 /** 38 * `GtkGestureLongPress` is a `GtkGesture` for long presses. 39 * 40 * This gesture is also known as “Press and Hold”. 41 * 42 * When the timeout is exceeded, the gesture is triggering the 43 * [signal@Gtk.GestureLongPress::pressed] signal. 44 * 45 * If the touchpoint is lifted before the timeout passes, or if 46 * it drifts too far of the initial press point, the 47 * [signal@Gtk.GestureLongPress::cancelled] signal will be emitted. 48 * 49 * How long the timeout is before the ::pressed signal gets emitted is 50 * determined by the [property@Gtk.Settings:gtk-long-press-time] setting. 51 * It can be modified by the [property@Gtk.GestureLongPress:delay-factor] 52 * property. 53 */ 54 public class GestureLongPress : GestureSingle 55 { 56 /** the main Gtk struct */ 57 protected GtkGestureLongPress* gtkGestureLongPress; 58 59 /** Get the main Gtk struct */ 60 public GtkGestureLongPress* getGestureLongPressStruct(bool transferOwnership = false) 61 { 62 if (transferOwnership) 63 ownedRef = false; 64 return gtkGestureLongPress; 65 } 66 67 /** the main Gtk struct as a void* */ 68 protected override void* getStruct() 69 { 70 return cast(void*)gtkGestureLongPress; 71 } 72 73 /** 74 * Sets our main struct and passes it to the parent class. 75 */ 76 public this (GtkGestureLongPress* gtkGestureLongPress, bool ownedRef = false) 77 { 78 this.gtkGestureLongPress = gtkGestureLongPress; 79 super(cast(GtkGestureSingle*)gtkGestureLongPress, ownedRef); 80 } 81 82 83 /** */ 84 public static GType getType() 85 { 86 return gtk_gesture_long_press_get_type(); 87 } 88 89 /** 90 * Returns a newly created `GtkGesture` that recognizes long presses. 91 * 92 * Returns: a newly created `GtkGestureLongPress`. 93 * 94 * Throws: ConstructionException GTK+ fails to create the object. 95 */ 96 public this() 97 { 98 auto __p = gtk_gesture_long_press_new(); 99 100 if(__p is null) 101 { 102 throw new ConstructionException("null returned by new"); 103 } 104 105 this(cast(GtkGestureLongPress*) __p, true); 106 } 107 108 /** 109 * Returns the delay factor. 110 * 111 * Returns: the delay factor 112 */ 113 public double getDelayFactor() 114 { 115 return gtk_gesture_long_press_get_delay_factor(gtkGestureLongPress); 116 } 117 118 /** 119 * Applies the given delay factor. 120 * 121 * The default long press time will be multiplied by this value. 122 * Valid values are in the range [0.5..2.0]. 123 * 124 * Params: 125 * delayFactor = The delay factor to apply 126 */ 127 public void setDelayFactor(double delayFactor) 128 { 129 gtk_gesture_long_press_set_delay_factor(gtkGestureLongPress, delayFactor); 130 } 131 132 /** 133 * Emitted whenever a press moved too far, or was released 134 * before [signal@Gtk.GestureLongPress::pressed] happened. 135 */ 136 gulong addOnCancelled(void delegate(GestureLongPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 137 { 138 return Signals.connect(this, "cancelled", dlg, connectFlags ^ ConnectFlags.SWAPPED); 139 } 140 141 /** 142 * Emitted whenever a press goes unmoved/unreleased longer than 143 * what the GTK defaults tell. 144 * 145 * Params: 146 * x = the X coordinate where the press happened, relative to the widget allocation 147 * y = the Y coordinate where the press happened, relative to the widget allocation 148 */ 149 gulong addOnPressed(void delegate(double, double, GestureLongPress) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 150 { 151 return Signals.connect(this, "pressed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 152 } 153 }