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.EventControllerMotion;
26 
27 private import glib.ConstructionException;
28 private import gobject.ObjectG;
29 private import gobject.Signals;
30 private import gtk.EventController;
31 private import gtk.c.functions;
32 public  import gtk.c.types;
33 private import std.algorithm;
34 
35 
36 /**
37  * `GtkEventControllerMotion` is an event controller tracking the pointer
38  * position.
39  * 
40  * The event controller offers [signal@Gtk.EventControllerMotion::enter]
41  * and [signal@Gtk.EventControllerMotion::leave] signals, as well as
42  * [property@Gtk.EventControllerMotion:is-pointer] and
43  * [property@Gtk.EventControllerMotion:contains-pointer] properties
44  * which are updated to reflect changes in the pointer position as it
45  * moves over the widget.
46  */
47 public class EventControllerMotion : EventController
48 {
49 	/** the main Gtk struct */
50 	protected GtkEventControllerMotion* gtkEventControllerMotion;
51 
52 	/** Get the main Gtk struct */
53 	public GtkEventControllerMotion* getEventControllerMotionStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gtkEventControllerMotion;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gtkEventControllerMotion;
64 	}
65 
66 	/**
67 	 * Sets our main struct and passes it to the parent class.
68 	 */
69 	public this (GtkEventControllerMotion* gtkEventControllerMotion, bool ownedRef = false)
70 	{
71 		this.gtkEventControllerMotion = gtkEventControllerMotion;
72 		super(cast(GtkEventController*)gtkEventControllerMotion, ownedRef);
73 	}
74 
75 
76 	/** */
77 	public static GType getType()
78 	{
79 		return gtk_event_controller_motion_get_type();
80 	}
81 
82 	/**
83 	 * Creates a new event controller that will handle motion events.
84 	 *
85 	 * Returns: a new `GtkEventControllerMotion`
86 	 *
87 	 * Throws: ConstructionException GTK+ fails to create the object.
88 	 */
89 	public this()
90 	{
91 		auto __p = gtk_event_controller_motion_new();
92 
93 		if(__p is null)
94 		{
95 			throw new ConstructionException("null returned by new");
96 		}
97 
98 		this(cast(GtkEventControllerMotion*) __p, true);
99 	}
100 
101 	/**
102 	 * Returns if a pointer is within @self or one of its children.
103 	 *
104 	 * Returns: %TRUE if a pointer is within @self or one of its children
105 	 */
106 	public bool containsPointer()
107 	{
108 		return gtk_event_controller_motion_contains_pointer(gtkEventControllerMotion) != 0;
109 	}
110 
111 	/**
112 	 * Returns if a pointer is within @self, but not one of its children.
113 	 *
114 	 * Returns: %TRUE if a pointer is within @self but not one of its children
115 	 */
116 	public bool isPointer()
117 	{
118 		return gtk_event_controller_motion_is_pointer(gtkEventControllerMotion) != 0;
119 	}
120 
121 	/**
122 	 * Signals that the pointer has entered the widget.
123 	 *
124 	 * Params:
125 	 *     x = coordinates of pointer location
126 	 *     y = coordinates of pointer location
127 	 */
128 	gulong addOnEnter(void delegate(double, double, EventControllerMotion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
129 	{
130 		return Signals.connect(this, "enter", dlg, connectFlags ^ ConnectFlags.SWAPPED);
131 	}
132 
133 	/**
134 	 * Signals that the pointer has left the widget.
135 	 */
136 	gulong addOnLeave(void delegate(EventControllerMotion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
137 	{
138 		return Signals.connect(this, "leave", dlg, connectFlags ^ ConnectFlags.SWAPPED);
139 	}
140 
141 	/**
142 	 * Emitted when the pointer moves inside the widget.
143 	 *
144 	 * Params:
145 	 *     x = the x coordinate
146 	 *     y = the y coordinate
147 	 */
148 	gulong addOnMotion(void delegate(double, double, EventControllerMotion) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
149 	{
150 		return Signals.connect(this, "motion", dlg, connectFlags ^ ConnectFlags.SWAPPED);
151 	}
152 }