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.Event;
28 private import gobject.ObjectG;
29 private import gtk.Widget;
30 private import gtkc.gtk;
31 public  import gtkc.gtktypes;
32 
33 
34 /**
35  * #GtkEventController is a base, low-level implementation for event
36  * controllers. Those react to a series of #GdkEvents, and possibly trigger
37  * actions as a consequence of those.
38  */
39 public class EventController : ObjectG
40 {
41 	/** the main Gtk struct */
42 	protected GtkEventController* gtkEventController;
43 
44 	/** Get the main Gtk struct */
45 	public GtkEventController* getEventControllerStruct()
46 	{
47 		return gtkEventController;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected override void* getStruct()
52 	{
53 		return cast(void*)gtkEventController;
54 	}
55 
56 	protected override void setStruct(GObject* obj)
57 	{
58 		gtkEventController = cast(GtkEventController*)obj;
59 		super.setStruct(obj);
60 	}
61 
62 	/**
63 	 * Sets our main struct and passes it to the parent class.
64 	 */
65 	public this (GtkEventController* gtkEventController, bool ownedRef = false)
66 	{
67 		this.gtkEventController = gtkEventController;
68 		super(cast(GObject*)gtkEventController, ownedRef);
69 	}
70 
71 	/**
72 	 */
73 
74 	public static GType getType()
75 	{
76 		return gtk_event_controller_get_type();
77 	}
78 
79 	/**
80 	 * Gets the propagation phase at which @controller handles events.
81 	 *
82 	 * Return: the propagation phase
83 	 *
84 	 * Since: 3.14
85 	 */
86 	public GtkPropagationPhase getPropagationPhase()
87 	{
88 		return gtk_event_controller_get_propagation_phase(gtkEventController);
89 	}
90 
91 	/**
92 	 * Returns the #GtkWidget this controller relates to.
93 	 *
94 	 * Return: a #GtkWidget
95 	 *
96 	 * Since: 3.14
97 	 */
98 	public Widget getWidget()
99 	{
100 		auto p = gtk_event_controller_get_widget(gtkEventController);
101 		
102 		if(p is null)
103 		{
104 			return null;
105 		}
106 		
107 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
108 	}
109 
110 	/**
111 	 * Feeds an events into @controller, so it can be interpreted
112 	 * and the controller actions triggered.
113 	 *
114 	 * Params:
115 	 *     event = a #GdkEvent
116 	 *
117 	 * Return: %TRUE if the event was potentially useful to trigger the
118 	 *     controller action
119 	 *
120 	 * Since: 3.14
121 	 */
122 	public bool handleEvent(Event event)
123 	{
124 		return gtk_event_controller_handle_event(gtkEventController, (event is null) ? null : event.getEventStruct()) != 0;
125 	}
126 
127 	/**
128 	 * Resets the @controller to a clean state. Every interaction
129 	 * the controller did through #GtkEventController::handle-event
130 	 * will be dropped at this point.
131 	 *
132 	 * Since: 3.14
133 	 */
134 	public void reset()
135 	{
136 		gtk_event_controller_reset(gtkEventController);
137 	}
138 
139 	/**
140 	 * Sets the propagation phase at which a controller handles events.
141 	 *
142 	 * If @phase is %GTK_PHASE_NONE, no automatic event handling will be
143 	 * performed, but other additional gesture maintenance will. In that phase,
144 	 * the events can be managed by calling gtk_event_controller_handle_event().
145 	 *
146 	 * Params:
147 	 *     phase = a propagation phase
148 	 *
149 	 * Since: 3.14
150 	 */
151 	public void setPropagationPhase(GtkPropagationPhase phase)
152 	{
153 		gtk_event_controller_set_propagation_phase(gtkEventController, phase);
154 	}
155 }