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.EventController; 26 27 private import gdk.Device; 28 private import gdk.Event; 29 private import glib.Str; 30 private import glib.c.functions; 31 private import gobject.ObjectG; 32 private import gtk.Widget; 33 private import gtk.c.functions; 34 public import gtk.c.types; 35 36 37 /** 38 * `GtkEventController` is the base class for event controllers. 39 * 40 * These are ancillary objects associated to widgets, which react 41 * to `GdkEvents`, and possibly trigger actions as a consequence. 42 * 43 * Event controllers are added to a widget with 44 * [method@Gtk.Widget.add_controller]. It is rarely necessary to 45 * explicitly remove a controller with [method@Gtk.Widget.remove_controller]. 46 * 47 * See the chapter of [input handling](input-handling.html) for 48 * an overview of the basic concepts, such as the capture and bubble 49 * phases of even propagation. 50 */ 51 public class EventController : ObjectG 52 { 53 /** the main Gtk struct */ 54 protected GtkEventController* gtkEventController; 55 56 /** Get the main Gtk struct */ 57 public GtkEventController* getEventControllerStruct(bool transferOwnership = false) 58 { 59 if (transferOwnership) 60 ownedRef = false; 61 return gtkEventController; 62 } 63 64 /** the main Gtk struct as a void* */ 65 protected override void* getStruct() 66 { 67 return cast(void*)gtkEventController; 68 } 69 70 /** 71 * Sets our main struct and passes it to the parent class. 72 */ 73 public this (GtkEventController* gtkEventController, bool ownedRef = false) 74 { 75 this.gtkEventController = gtkEventController; 76 super(cast(GObject*)gtkEventController, ownedRef); 77 } 78 79 80 /** */ 81 public static GType getType() 82 { 83 return gtk_event_controller_get_type(); 84 } 85 86 /** 87 * Returns the event that is currently being handled by the 88 * controller, and %NULL at other times. 89 * 90 * Returns: the event that is currently 91 * handled by @controller 92 */ 93 public Event getCurrentEvent() 94 { 95 auto __p = gtk_event_controller_get_current_event(gtkEventController); 96 97 if(__p is null) 98 { 99 return null; 100 } 101 102 return ObjectG.getDObject!(Event)(cast(GdkEvent*) __p); 103 } 104 105 /** 106 * Returns the device of the event that is currently being 107 * handled by the controller, and %NULL otherwise. 108 * 109 * Returns: device of the event is 110 * currently handled by @controller 111 */ 112 public Device getCurrentEventDevice() 113 { 114 auto __p = gtk_event_controller_get_current_event_device(gtkEventController); 115 116 if(__p is null) 117 { 118 return null; 119 } 120 121 return ObjectG.getDObject!(Device)(cast(GdkDevice*) __p); 122 } 123 124 /** 125 * Returns the modifier state of the event that is currently being 126 * handled by the controller, and 0 otherwise. 127 * 128 * Returns: modifier state of the event is currently handled by @controller 129 */ 130 public GdkModifierType getCurrentEventState() 131 { 132 return gtk_event_controller_get_current_event_state(gtkEventController); 133 } 134 135 /** 136 * Returns the timestamp of the event that is currently being 137 * handled by the controller, and 0 otherwise. 138 * 139 * Returns: timestamp of the event is currently handled by @controller 140 */ 141 public uint getCurrentEventTime() 142 { 143 return gtk_event_controller_get_current_event_time(gtkEventController); 144 } 145 146 /** 147 * Gets the name of @controller. 148 */ 149 public string getName() 150 { 151 return Str.toString(gtk_event_controller_get_name(gtkEventController)); 152 } 153 154 /** 155 * Gets the propagation limit of the event controller. 156 * 157 * Returns: the propagation limit 158 */ 159 public GtkPropagationLimit getPropagationLimit() 160 { 161 return gtk_event_controller_get_propagation_limit(gtkEventController); 162 } 163 164 /** 165 * Gets the propagation phase at which @controller handles events. 166 * 167 * Returns: the propagation phase 168 */ 169 public GtkPropagationPhase getPropagationPhase() 170 { 171 return gtk_event_controller_get_propagation_phase(gtkEventController); 172 } 173 174 /** 175 * Returns the #GtkWidget this controller relates to. 176 * 177 * Returns: a `GtkWidget` 178 */ 179 public Widget getWidget() 180 { 181 auto __p = gtk_event_controller_get_widget(gtkEventController); 182 183 if(__p is null) 184 { 185 return null; 186 } 187 188 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) __p); 189 } 190 191 /** 192 * Resets the @controller to a clean state. 193 */ 194 public void reset() 195 { 196 gtk_event_controller_reset(gtkEventController); 197 } 198 199 /** 200 * Sets a name on the controller that can be used for debugging. 201 * 202 * Params: 203 * name = a name for @controller 204 */ 205 public void setName(string name) 206 { 207 gtk_event_controller_set_name(gtkEventController, Str.toStringz(name)); 208 } 209 210 /** 211 * Sets the event propagation limit on the event controller. 212 * 213 * If the limit is set to %GTK_LIMIT_SAME_NATIVE, the controller 214 * won't handle events that are targeted at widgets on a different 215 * surface, such as popovers. 216 * 217 * Params: 218 * limit = the propagation limit 219 */ 220 public void setPropagationLimit(GtkPropagationLimit limit) 221 { 222 gtk_event_controller_set_propagation_limit(gtkEventController, limit); 223 } 224 225 /** 226 * Sets the propagation phase at which a controller handles events. 227 * 228 * If @phase is %GTK_PHASE_NONE, no automatic event handling will be 229 * performed, but other additional gesture maintenance will. 230 * 231 * Params: 232 * phase = a propagation phase 233 */ 234 public void setPropagationPhase(GtkPropagationPhase phase) 235 { 236 gtk_event_controller_set_propagation_phase(gtkEventController, phase); 237 } 238 }