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.EventControllerKey;
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.IMContext;
32 private import gtk.Widget;
33 private import gtk.c.functions;
34 public  import gtk.c.types;
35 public  import gtkc.gtktypes;
36 private import std.algorithm;
37 
38 
39 /**
40  * #GtkEventControllerKey is an event controller meant for situations
41  * where you need access to key events.
42  * 
43  * This object was added in 3.24.
44  */
45 public class EventControllerKey : EventController
46 {
47 	/** the main Gtk struct */
48 	protected GtkEventControllerKey* gtkEventControllerKey;
49 
50 	/** Get the main Gtk struct */
51 	public GtkEventControllerKey* getEventControllerKeyStruct(bool transferOwnership = false)
52 	{
53 		if (transferOwnership)
54 			ownedRef = false;
55 		return gtkEventControllerKey;
56 	}
57 
58 	/** the main Gtk struct as a void* */
59 	protected override void* getStruct()
60 	{
61 		return cast(void*)gtkEventControllerKey;
62 	}
63 
64 	/**
65 	 * Sets our main struct and passes it to the parent class.
66 	 */
67 	public this (GtkEventControllerKey* gtkEventControllerKey, bool ownedRef = false)
68 	{
69 		this.gtkEventControllerKey = gtkEventControllerKey;
70 		super(cast(GtkEventController*)gtkEventControllerKey, ownedRef);
71 	}
72 
73 
74 	/** */
75 	public static GType getType()
76 	{
77 		return gtk_event_controller_key_get_type();
78 	}
79 
80 	/** */
81 	public this(Widget widget)
82 	{
83 		auto p = gtk_event_controller_key_new((widget is null) ? null : widget.getWidgetStruct());
84 
85 		if(p is null)
86 		{
87 			throw new ConstructionException("null returned by new");
88 		}
89 
90 		this(cast(GtkEventControllerKey*) p, true);
91 	}
92 
93 	/** */
94 	public bool forward(Widget widget)
95 	{
96 		return gtk_event_controller_key_forward(gtkEventControllerKey, (widget is null) ? null : widget.getWidgetStruct()) != 0;
97 	}
98 
99 	/** */
100 	public uint getGroup()
101 	{
102 		return gtk_event_controller_key_get_group(gtkEventControllerKey);
103 	}
104 
105 	/**
106 	 * Gets the IM context of a key controller.
107 	 *
108 	 * Returns: the IM context
109 	 *
110 	 * Since: 3.24
111 	 */
112 	public IMContext getImContext()
113 	{
114 		auto p = gtk_event_controller_key_get_im_context(gtkEventControllerKey);
115 
116 		if(p is null)
117 		{
118 			return null;
119 		}
120 
121 		return ObjectG.getDObject!(IMContext)(cast(GtkIMContext*) p);
122 	}
123 
124 	/** */
125 	public void setImContext(IMContext imContext)
126 	{
127 		gtk_event_controller_key_set_im_context(gtkEventControllerKey, (imContext is null) ? null : imContext.getIMContextStruct());
128 	}
129 
130 	/** */
131 	gulong addOnFocusIn(void delegate(EventControllerKey) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
132 	{
133 		return Signals.connect(this, "focus-in", dlg, connectFlags ^ ConnectFlags.SWAPPED);
134 	}
135 
136 	/** */
137 	gulong addOnFocusOut(void delegate(EventControllerKey) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
138 	{
139 		return Signals.connect(this, "focus-out", dlg, connectFlags ^ ConnectFlags.SWAPPED);
140 	}
141 
142 	/** */
143 	gulong addOnImUpdate(void delegate(EventControllerKey) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
144 	{
145 		return Signals.connect(this, "im-update", dlg, connectFlags ^ ConnectFlags.SWAPPED);
146 	}
147 
148 	/**
149 	 * This signal is emitted whenever a key is pressed.
150 	 *
151 	 * Params:
152 	 *     keyval = the pressed key.
153 	 *     keycode = the raw code of the pressed key.
154 	 *     state = the bitmask, representing the state of modifier keys and pointer buttons. See #GdkModifierType.
155 	 *
156 	 * Returns: %TRUE if the key press was handled, %FALSE otherwise.
157 	 *
158 	 * Since: 3.24
159 	 */
160 	gulong addOnKeyPressed(bool delegate(uint, uint, GdkModifierType, EventControllerKey) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
161 	{
162 		return Signals.connect(this, "key-pressed", dlg, connectFlags ^ ConnectFlags.SWAPPED);
163 	}
164 
165 	/**
166 	 * This signal is emitted whenever a key is released.
167 	 *
168 	 * Params:
169 	 *     keyval = the released key.
170 	 *     keycode = the raw code of the released key.
171 	 *     state = the bitmask, representing the state of modifier keys and pointer buttons. See #GdkModifierType.
172 	 *
173 	 * Since: 3.24
174 	 */
175 	gulong addOnKeyReleased(void delegate(uint, uint, GdkModifierType, EventControllerKey) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
176 	{
177 		return Signals.connect(this, "key-released", dlg, connectFlags ^ ConnectFlags.SWAPPED);
178 	}
179 
180 	/** */
181 	gulong addOnModifiers(bool delegate(GdkModifierType, EventControllerKey) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
182 	{
183 		return Signals.connect(this, "modifiers", dlg, connectFlags ^ ConnectFlags.SWAPPED);
184 	}
185 }