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 	public static GType getType()
74 	{
75 		return gtk_event_controller_get_type();
76 	}
77 
78 	/**
79 	 * Gets the propagation phase at which @controller handles events.
80 	 *
81 	 * Return: the propagation phase
82 	 *
83 	 * Since: 3.14
84 	 */
85 	public GtkPropagationPhase getPropagationPhase()
86 	{
87 		return gtk_event_controller_get_propagation_phase(gtkEventController);
88 	}
89 
90 	/**
91 	 * Returns the #GtkWidget this controller relates to.
92 	 *
93 	 * Return: a #GtkWidget
94 	 *
95 	 * Since: 3.14
96 	 */
97 	public Widget getWidget()
98 	{
99 		auto p = gtk_event_controller_get_widget(gtkEventController);
100 		
101 		if(p is null)
102 		{
103 			return null;
104 		}
105 		
106 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
107 	}
108 
109 	/**
110 	 * Feeds an events into @controller, so it can be interpreted
111 	 * and the controller actions triggered.
112 	 *
113 	 * Params:
114 	 *     event = a #GdkEvent
115 	 *
116 	 * Return: %TRUE if the event was potentially useful to trigger the
117 	 *     controller action
118 	 *
119 	 * Since: 3.14
120 	 */
121 	public bool handleEvent(Event event)
122 	{
123 		return gtk_event_controller_handle_event(gtkEventController, (event is null) ? null : event.getEventStruct()) != 0;
124 	}
125 
126 	/**
127 	 * Resets the @controller to a clean state. Every interaction
128 	 * the controller did through #GtkEventController::handle-event
129 	 * will be dropped at this point.
130 	 *
131 	 * Since: 3.14
132 	 */
133 	public void reset()
134 	{
135 		gtk_event_controller_reset(gtkEventController);
136 	}
137 
138 	/**
139 	 * Sets the propagation phase at which a controller handles events.
140 	 *
141 	 * If @phase is %GTK_PHASE_NONE, no automatic event handling will be
142 	 * performed, but other additional gesture maintenance will. In that phase,
143 	 * the events can be managed by calling gtk_event_controller_handle_event().
144 	 *
145 	 * Params:
146 	 *     phase = a propagation phase
147 	 *
148 	 * Since: 3.14
149 	 */
150 	public void setPropagationPhase(GtkPropagationPhase phase)
151 	{
152 		gtk_event_controller_set_propagation_phase(gtkEventController, phase);
153 	}
154 }