1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #include "atkcomponent.h"
23 static AtkObject* atk_component_real_get_accessible_at_point (AtkComponent *component,
26 AtkCoordType coord_type);
29 atk_component_get_type ()
31 static GType type = 0;
34 static const GTypeInfo tinfo =
36 sizeof (AtkComponentIface),
38 (GBaseFinalizeFunc) NULL,
42 type = g_type_register_static (G_TYPE_INTERFACE, "AtkComponent", &tinfo, 0);
49 * atk_component_add_focus_handler:
50 * @component: The #AtkComponent to attach the @handler to
51 * @handler: The #AtkFocusHandler to be attached to @component
53 * Add the specified handler to the set of functions to be called
54 * when this object receives focus events (in or out).
59 atk_component_add_focus_handler (AtkComponent *component,
60 AtkFocusHandler handler)
62 AtkComponentIface *iface = NULL;
63 g_return_val_if_fail (component != NULL, 0);
64 g_return_val_if_fail (ATK_IS_COMPONENT (component), 0);
66 iface = ATK_COMPONENT_GET_IFACE (component);
68 if (iface->add_focus_handler)
69 return (iface->add_focus_handler) (component, handler);
75 * atk_component_remove_focus_handler:
76 * @component: the #AtkComponent to remove the focus handler from
77 * @handler_id: the handler id of the focus handler to be removed
80 * Remove the handler specified by @handler_id from the list of
81 * functions to be executed when this object receives focus events
85 atk_component_remove_focus_handler (AtkComponent *component,
88 AtkComponentIface *iface = NULL;
89 g_return_if_fail (component != NULL);
90 g_return_if_fail (ATK_IS_COMPONENT (component));
92 iface = ATK_COMPONENT_GET_IFACE (component);
94 if (iface->remove_focus_handler)
95 (iface->remove_focus_handler) (component, handler_id);
99 * atk_component_contains:
100 * @component: the #AtkComponent
103 * @coord_type: specifies whether the coordinates are relative to the screen
104 * or to the components top level window
106 * Checks whether the specified point is within the extent of the @component.
108 * Returns: %TRUE or %FALSE indicating whether the specified point is within
109 * the extent of the @component or not
112 atk_component_contains (AtkComponent *component,
115 AtkCoordType coord_type)
117 AtkComponentIface *iface = NULL;
118 g_return_val_if_fail (component != NULL, FALSE);
119 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
121 iface = ATK_COMPONENT_GET_IFACE (component);
124 return (iface->contains) (component, x, y, coord_type);
130 * atk_component_get_accessible_at_point:
131 * @component: the #AtkComponent
134 * @coord_type: specifies whether the coordinates are relative to the screen
135 * or to the components top level window
137 * Gets the accessible child, if one exists, contained at the
138 * coordinate point specified by @x and @y.
140 * Returns: the accessible child, if one exists
143 atk_component_get_accessible_at_point (AtkComponent *component,
146 AtkCoordType coord_type)
148 AtkComponentIface *iface = NULL;
149 g_return_val_if_fail (component != NULL, NULL);
150 g_return_val_if_fail (ATK_IS_COMPONENT (component), NULL);
152 iface = ATK_COMPONENT_GET_IFACE (component);
154 if (iface->get_accessible_at_point)
155 return (iface->get_accessible_at_point) (component, x, y, coord_type);
159 * if this method is not overridden use the default implementation.
161 return atk_component_real_get_accessible_at_point (component, x, y, coord_type);
166 * atk_component_get_extents:
167 * @component: an #AtkComponent
168 * @x: address of #gint to put x coordinate
169 * @y: address of #gint to put y coordinate
170 * @width: address of #gint to put width
171 * @height: address of #gint to put height
172 * @coord_type: specifies whether the coordinates are relative to the screen
173 * or to the components top level window
175 * Gets the rectangle which gives the extent of the @component.
179 atk_component_get_extents (AtkComponent *component,
184 AtkCoordType coord_type)
186 AtkComponentIface *iface = NULL;
187 g_return_if_fail (component != NULL);
188 g_return_if_fail (ATK_IS_COMPONENT (component));
190 iface = ATK_COMPONENT_GET_IFACE (component);
192 if (iface->get_extents)
193 (iface->get_extents) (component, x, y, width, height, coord_type);
197 * atk_component_get_position:
198 * @component: an #AtkComponent
199 * @x: address of #gint to put x coordinate position
200 * @y: address of #gint to put y coordinate position
201 * @coord_type: specifies whether the coordinates are relative to the screen
202 * or to the components top level window
204 * Gets the position of @component in the form of
205 * a point specifying @component's top-left corner.
208 atk_component_get_position (AtkComponent *component,
211 AtkCoordType coord_type)
213 AtkComponentIface *iface = NULL;
214 g_return_if_fail (component != NULL);
215 g_return_if_fail (ATK_IS_COMPONENT (component));
217 iface = ATK_COMPONENT_GET_IFACE (component);
219 if (iface->get_position)
220 (iface->get_position) (component, x, y, coord_type);
224 * atk_component_get_size:
225 * @component: an #AtkComponent
226 * @width: address of #gint to put width of @component
227 * @height: address of #gint to put height of @component
229 * Gets the size of the @component in terms of width and height.
232 atk_component_get_size (AtkComponent *component,
236 AtkComponentIface *iface = NULL;
237 g_return_if_fail (component != NULL);
238 g_return_if_fail (ATK_IS_COMPONENT (component));
240 iface = ATK_COMPONENT_GET_IFACE (component);
243 (iface->get_size) (component, x, y);
247 * atk_component_grab_focus:
248 * @component: an #AtkComponent
250 * Grabs focus for this @component.
252 * Returns: %TRUE if successful, %FALSE otherwise.
255 atk_component_grab_focus (AtkComponent *component)
257 AtkComponentIface *iface = NULL;
258 g_return_val_if_fail (component != NULL, FALSE);
259 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
261 iface = ATK_COMPONENT_GET_IFACE (component);
263 if (iface->grab_focus)
264 return (iface->grab_focus) (component);
270 * atk_component_set_extents:
271 * @component: an #AtkComponent
274 * @width: width to set for @component
275 * @height: height to set for @component
276 * @coord_type: specifies whether the coordinates are relative to the screen
277 * or to the components top level window
279 * Sets the extents of @component.
281 * Returns: %TRUE or %FALSE whether the extents were set or not
284 atk_component_set_extents (AtkComponent *component,
289 AtkCoordType coord_type)
291 AtkComponentIface *iface = NULL;
292 g_return_val_if_fail (component != NULL, FALSE);
293 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
295 iface = ATK_COMPONENT_GET_IFACE (component);
297 if (iface->set_extents)
298 return (iface->set_extents) (component, x, y, width, height, coord_type);
304 * atk_component_set_position:
305 * @component: an #AtkComponent
308 * @coord_type: specifies whether the coordinates are relative to the screen
309 * or to the components top level window
311 * Sets the postition of @component.
313 * Returns: %TRUE or %FALSE whether or not the position was set or not
316 atk_component_set_position (AtkComponent *component,
319 AtkCoordType coord_type)
321 AtkComponentIface *iface = NULL;
322 g_return_val_if_fail (component != NULL, FALSE);
323 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
325 iface = ATK_COMPONENT_GET_IFACE (component);
327 if (iface->set_position)
328 return (iface->set_position) (component, x, y, coord_type);
334 * atk_component_set_size:
335 * @component: an #AtkComponent
336 * @width: width to set for @component
337 * @height: height to set for @component
339 * Set the size of the @component in terms of width and height.
341 * Returns: %TRUE or %FALSE whether the size was set or not
344 atk_component_set_size (AtkComponent *component,
348 AtkComponentIface *iface = NULL;
349 g_return_val_if_fail (component != NULL, FALSE);
350 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
352 iface = ATK_COMPONENT_GET_IFACE (component);
355 return (iface->set_size) (component, x, y);
361 atk_component_real_get_accessible_at_point (AtkComponent *component,
364 AtkCoordType coord_type)
368 count = atk_object_get_n_accessible_children (ATK_OBJECT (component));
370 g_return_val_if_fail (count != 0, NULL);
372 for (i = 0; i < count; i++)
376 obj = atk_object_ref_accessible_child (ATK_OBJECT (component), i);
380 if (atk_component_contains (ATK_COMPONENT (obj), x, y, coord_type))
382 g_object_unref (obj);
387 g_object_unref (obj);