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 atk.ComponentT;
26 
27 public  import atk.ObjectAtk;
28 public  import gobject.ObjectG;
29 public  import gobject.Signals;
30 public  import gtkc.atk;
31 public  import gtkc.atktypes;
32 public  import gtkc.gdktypes;
33 
34 
35 /**
36  * #AtkComponent should be implemented by most if not all UI elements
37  * with an actual on-screen presence, i.e. components which can be
38  * said to have a screen-coordinate bounding box.  Virtually all
39  * widgets will need to have #AtkComponent implementations provided
40  * for their corresponding #AtkObject class.  In short, only UI
41  * elements which are *not* GUI elements will omit this ATK interface.
42  * 
43  * A possible exception might be textual information with a
44  * transparent background, in which case text glyph bounding box
45  * information is provided by #AtkText.
46  */
47 public template ComponentT(TStruct)
48 {
49 	/** Get the main Gtk struct */
50 	public AtkComponent* getComponentStruct()
51 	{
52 		return cast(AtkComponent*)getStruct();
53 	}
54 
55 	/**
56 	 */
57 
58 	/**
59 	 * Add the specified handler to the set of functions to be called
60 	 * when this object receives focus events (in or out). If the handler is
61 	 * already added it is not added again
62 	 *
63 	 * Deprecated: If you need to track when an object gains or
64 	 * lose the focus, use the #AtkObject::state-change "focused" notification instead.
65 	 *
66 	 * Params:
67 	 *     handler = The #AtkFocusHandler to be attached to @component
68 	 *
69 	 * Return: a handler id which can be used in atk_component_remove_focus_handler()
70 	 *     or zero if the handler was already added.
71 	 */
72 	public uint addFocusHandler(AtkFocusHandler handler)
73 	{
74 		return atk_component_add_focus_handler(getComponentStruct(), handler);
75 	}
76 
77 	/**
78 	 * Checks whether the specified point is within the extent of the @component.
79 	 *
80 	 * Toolkit implementor note: ATK provides a default implementation for
81 	 * this virtual method. In general there are little reason to
82 	 * re-implement it.
83 	 *
84 	 * Params:
85 	 *     x = x coordinate
86 	 *     y = y coordinate
87 	 *     coordType = specifies whether the coordinates are relative to the screen
88 	 *         or to the components top level window
89 	 *
90 	 * Return: %TRUE or %FALSE indicating whether the specified point is within
91 	 *     the extent of the @component or not
92 	 */
93 	public bool contains(int x, int y, AtkCoordType coordType)
94 	{
95 		return atk_component_contains(getComponentStruct(), x, y, coordType) != 0;
96 	}
97 
98 	/**
99 	 * Returns the alpha value (i.e. the opacity) for this
100 	 * @component, on a scale from 0 (fully transparent) to 1.0
101 	 * (fully opaque).
102 	 *
103 	 * Return: An alpha value from 0 to 1.0, inclusive.
104 	 *
105 	 * Since: 1.12
106 	 */
107 	public double getAlpha()
108 	{
109 		return atk_component_get_alpha(getComponentStruct());
110 	}
111 
112 	/**
113 	 * Gets the rectangle which gives the extent of the @component.
114 	 *
115 	 * Params:
116 	 *     x = address of #gint to put x coordinate
117 	 *     y = address of #gint to put y coordinate
118 	 *     width = address of #gint to put width
119 	 *     height = address of #gint to put height
120 	 *     coordType = specifies whether the coordinates are relative to the screen
121 	 *         or to the components top level window
122 	 */
123 	public void getExtents(int* x, int* y, int* width, int* height, AtkCoordType coordType)
124 	{
125 		atk_component_get_extents(getComponentStruct(), x, y, width, height, coordType);
126 	}
127 
128 	/**
129 	 * Gets the layer of the component.
130 	 *
131 	 * Return: an #AtkLayer which is the layer of the component
132 	 */
133 	public override AtkLayer getLayer()
134 	{
135 		return atk_component_get_layer(getComponentStruct());
136 	}
137 
138 	/**
139 	 * Gets the zorder of the component. The value G_MININT will be returned
140 	 * if the layer of the component is not ATK_LAYER_MDI or ATK_LAYER_WINDOW.
141 	 *
142 	 * Return: a gint which is the zorder of the component, i.e. the depth at
143 	 *     which the component is shown in relation to other components in the same
144 	 *     container.
145 	 */
146 	public override int getMdiZorder()
147 	{
148 		return atk_component_get_mdi_zorder(getComponentStruct());
149 	}
150 
151 	/**
152 	 * Gets the position of @component in the form of
153 	 * a point specifying @component's top-left corner.
154 	 *
155 	 * Deprecated: Since 2.12. Use atk_component_get_extents() instead.
156 	 *
157 	 * Params:
158 	 *     x = address of #gint to put x coordinate position
159 	 *     y = address of #gint to put y coordinate position
160 	 *     coordType = specifies whether the coordinates are relative to the screen
161 	 *         or to the components top level window
162 	 */
163 	public void getPosition(int* x, int* y, AtkCoordType coordType)
164 	{
165 		atk_component_get_position(getComponentStruct(), x, y, coordType);
166 	}
167 
168 	/**
169 	 * Gets the size of the @component in terms of width and height.
170 	 *
171 	 * Deprecated: Since 2.12. Use atk_component_get_extents() instead.
172 	 *
173 	 * Params:
174 	 *     width = address of #gint to put width of @component
175 	 *     height = address of #gint to put height of @component
176 	 */
177 	public void getSize(int* width, int* height)
178 	{
179 		atk_component_get_size(getComponentStruct(), width, height);
180 	}
181 
182 	/**
183 	 * Grabs focus for this @component.
184 	 *
185 	 * Return: %TRUE if successful, %FALSE otherwise.
186 	 */
187 	public bool grabFocus()
188 	{
189 		return atk_component_grab_focus(getComponentStruct()) != 0;
190 	}
191 
192 	/**
193 	 * Gets a reference to the accessible child, if one exists, at the
194 	 * coordinate point specified by @x and @y.
195 	 *
196 	 * Params:
197 	 *     x = x coordinate
198 	 *     y = y coordinate
199 	 *     coordType = specifies whether the coordinates are relative to the screen
200 	 *         or to the components top level window
201 	 *
202 	 * Return: a reference to the accessible
203 	 *     child, if one exists
204 	 */
205 	public ObjectAtk refAccessibleAtPoint(int x, int y, AtkCoordType coordType)
206 	{
207 		auto p = atk_component_ref_accessible_at_point(getComponentStruct(), x, y, coordType);
208 		
209 		if(p is null)
210 		{
211 			return null;
212 		}
213 		
214 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p, true);
215 	}
216 
217 	/**
218 	 * Remove the handler specified by @handler_id from the list of
219 	 * functions to be executed when this object receives focus events
220 	 * (in or out).
221 	 *
222 	 * Deprecated: If you need to track when an object gains or
223 	 * lose the focus, use the #AtkObject::state-change "focused" notification instead.
224 	 *
225 	 * Params:
226 	 *     handlerId = the handler id of the focus handler to be removed
227 	 *         from @component
228 	 */
229 	public void removeFocusHandler(uint handlerId)
230 	{
231 		atk_component_remove_focus_handler(getComponentStruct(), handlerId);
232 	}
233 
234 	/**
235 	 * Sets the extents of @component.
236 	 *
237 	 * Params:
238 	 *     x = x coordinate
239 	 *     y = y coordinate
240 	 *     width = width to set for @component
241 	 *     height = height to set for @component
242 	 *     coordType = specifies whether the coordinates are relative to the screen
243 	 *         or to the components top level window
244 	 *
245 	 * Return: %TRUE or %FALSE whether the extents were set or not
246 	 */
247 	public bool setExtents(int x, int y, int width, int height, AtkCoordType coordType)
248 	{
249 		return atk_component_set_extents(getComponentStruct(), x, y, width, height, coordType) != 0;
250 	}
251 
252 	/**
253 	 * Sets the postition of @component.
254 	 *
255 	 * Params:
256 	 *     x = x coordinate
257 	 *     y = y coordinate
258 	 *     coordType = specifies whether the coordinates are relative to the screen
259 	 *         or to the components top level window
260 	 *
261 	 * Return: %TRUE or %FALSE whether or not the position was set or not
262 	 */
263 	public bool setPosition(int x, int y, AtkCoordType coordType)
264 	{
265 		return atk_component_set_position(getComponentStruct(), x, y, coordType) != 0;
266 	}
267 
268 	/**
269 	 * Set the size of the @component in terms of width and height.
270 	 *
271 	 * Params:
272 	 *     width = width to set for @component
273 	 *     height = height to set for @component
274 	 *
275 	 * Return: %TRUE or %FALSE whether the size was set or not
276 	 */
277 	public bool setSize(int width, int height)
278 	{
279 		return atk_component_set_size(getComponentStruct(), width, height) != 0;
280 	}
281 
282 	int[string] connectedSignals;
283 
284 	void delegate(AtkRectangle*, ComponentIF)[] _onBoundsChangedListeners;
285 	@property void delegate(AtkRectangle*, ComponentIF)[] onBoundsChangedListeners()
286 	{
287 		return _onBoundsChangedListeners;
288 	}
289 	/**
290 	 * The 'bounds-changed" signal is emitted when the bposition or
291 	 * size of the component changes.
292 	 *
293 	 * Params:
294 	 *     arg1 = The AtkRectangle giving the new position and size.
295 	 */
296 	void addOnBoundsChanged(void delegate(AtkRectangle*, ComponentIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
297 	{
298 		if ( "bounds-changed" !in connectedSignals )
299 		{
300 			Signals.connectData(
301 				this,
302 				"bounds-changed",
303 				cast(GCallback)&callBackBoundsChanged,
304 				cast(void*)cast(ComponentIF)this,
305 				null,
306 				connectFlags);
307 			connectedSignals["bounds-changed"] = 1;
308 		}
309 		_onBoundsChangedListeners ~= dlg;
310 	}
311 	extern(C) static void callBackBoundsChanged(AtkComponent* componentStruct, AtkRectangle* arg1, ComponentIF _component)
312 	{
313 		foreach ( void delegate(AtkRectangle*, ComponentIF) dlg; _component.onBoundsChangedListeners )
314 		{
315 			dlg(arg1, _component);
316 		}
317 	}
318 }