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,
28 atk_component_get_type ()
30 static GType type = 0;
33 static const GTypeInfo tinfo =
35 sizeof (AtkComponentIface),
37 (GBaseFinalizeFunc) NULL,
41 type = g_type_register_static (G_TYPE_INTERFACE, "AtkComponent", &tinfo, 0);
48 * atk_component_add_focus_handler:
49 * @component: The #AtkComponent to attach the @handler to
50 * @handler: The #AtkFocusHandler to be attached to @component
52 * Add the specified handler to the set of functions to be called
53 * when this object receives focus events (in or out).
58 atk_component_add_focus_handler (AtkComponent *component,
59 AtkFocusHandler handler)
61 AtkComponentIface *iface = NULL;
62 g_return_val_if_fail (component != NULL, 0);
63 g_return_val_if_fail (ATK_IS_COMPONENT (component), 0);
65 iface = ATK_COMPONENT_GET_IFACE (component);
67 if (iface->add_focus_handler)
68 return (iface->add_focus_handler) (component, handler);
74 * atk_component_remove_focus_handler:
75 * @component: the #AtkComponent to remove the focus handler from
76 * @handler_id: the handler id of the focus handler to be removed
79 * Remove the handler specified by @handler_id from the list of
80 * functions to be executed when this object receives focus events
84 atk_component_remove_focus_handler (AtkComponent *component,
87 AtkComponentIface *iface = NULL;
88 g_return_if_fail (component != NULL);
89 g_return_if_fail (ATK_IS_COMPONENT (component));
91 iface = ATK_COMPONENT_GET_IFACE (component);
93 if (iface->remove_focus_handler)
94 (iface->remove_focus_handler) (component, handler_id);
98 * atk_component_contains:
99 * @component: the #AtkComponent
100 * @x: x coordinate relative to the coordinate system of @component
101 * @y: y coordinate relative to the coordinate system of @component
103 * Checks whether the specified point is within the extent of the @component,
104 * the x and y coordinates are defined to be relative to the
105 * coordinate system of the @component.
107 * Returns: %TRUE or %FALSE indicating whether the specified point is within
108 * the extent of the @component or not
111 atk_component_contains (AtkComponent *component,
115 AtkComponentIface *iface = NULL;
116 g_return_val_if_fail (component != NULL, FALSE);
117 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
119 iface = ATK_COMPONENT_GET_IFACE (component);
122 return (iface->contains) (component, x, y);
128 * atk_component_get_accessible_at_point:
129 * @component: the #AtkComponent
130 * @x: local x coordinate
131 * @y: local y coordinate
133 * Gets the accessible child, if one exists, contained at the local
134 * coordinate point specified by @x and @y.
136 * Returns: the accessible child, if one exists
139 atk_component_get_accessible_at_point (AtkComponent *component,
143 AtkComponentIface *iface = NULL;
144 g_return_val_if_fail (component != NULL, NULL);
145 g_return_val_if_fail (ATK_IS_COMPONENT (component), NULL);
147 iface = ATK_COMPONENT_GET_IFACE (component);
149 if (iface->get_accessible_at_point)
150 return (iface->get_accessible_at_point) (component, x, y);
154 * if this method is not overridden use the default implementation.
156 return atk_component_real_get_accessible_at_point (component, x, y);
161 * atk_component_get_extents:
162 * @component: an #AtkComponent
163 * @x: address of #gint to put x coordinate
164 * @y: address of #gint to put y coordinate
165 * @width: address of #gint to put width
166 * @height: address of #gint to put height
168 * Gets the rectangle which gives the extent of the @component.
171 atk_component_get_extents (AtkComponent *component,
177 AtkComponentIface *iface = NULL;
178 g_return_if_fail (component != NULL);
179 g_return_if_fail (ATK_IS_COMPONENT (component));
181 iface = ATK_COMPONENT_GET_IFACE (component);
183 if (iface->get_extents)
184 (iface->get_extents) (component, x, y, width, height);
188 * atk_component_get_position:
189 * @component: an #AtkComponent
190 * @x: address of #gint to put x coordinate position
191 * @y: address of #gint to put y coordinate position
193 * Gets the position of @component relative to the parent in the form of
194 * a point specifying @component's top-left corner in the screen's
198 atk_component_get_position (AtkComponent *component,
202 AtkComponentIface *iface = NULL;
203 g_return_if_fail (component != NULL);
204 g_return_if_fail (ATK_IS_COMPONENT (component));
206 iface = ATK_COMPONENT_GET_IFACE (component);
208 if (iface->get_position)
209 (iface->get_position) (component, x, y);
213 * atk_component_get_position_on_screen:
214 * @component: an #AtkComponent
215 * @x: address of #gint to put x coordinate position
216 * @y: address of #gint to put y coordinate position
218 * Gets the position of the @component on the screen.
221 atk_component_get_position_on_screen (AtkComponent *component,
225 AtkComponentIface *iface = NULL;
226 g_return_if_fail (component != NULL);
227 g_return_if_fail (ATK_IS_COMPONENT (component));
229 iface = ATK_COMPONENT_GET_IFACE (component);
231 if (iface->get_position_on_screen)
232 (iface->get_position_on_screen) (component, x, y);
236 * atk_component_get_size:
237 * @component: an #AtkComponent
238 * @width: address of #gint to put width of @component
239 * @height: address of #gint to put height of @component
241 * Gets the size of the @component in terms of width and height.
244 atk_component_get_size (AtkComponent *component,
248 AtkComponentIface *iface = NULL;
249 g_return_if_fail (component != NULL);
250 g_return_if_fail (ATK_IS_COMPONENT (component));
252 iface = ATK_COMPONENT_GET_IFACE (component);
255 (iface->get_size) (component, x, y);
259 * atk_component_grab_focus:
260 * @component: an #AtkComponent
262 * Grabs focus for this @component.
265 atk_component_grab_focus (AtkComponent *component)
267 AtkComponentIface *iface = NULL;
268 g_return_if_fail (component != NULL);
269 g_return_if_fail (ATK_IS_COMPONENT (component));
271 iface = ATK_COMPONENT_GET_IFACE (component);
273 if (iface->grab_focus)
274 (iface->grab_focus) (component);
278 * atk_component_set_extents:
279 * @component: an #AtkComponent
282 * @width: width to set for @component
283 * @height: height to set for @component
285 * Sets the extents of @component.
288 atk_component_set_extents (AtkComponent *component,
294 AtkComponentIface *iface = NULL;
295 g_return_if_fail (component != NULL);
296 g_return_if_fail (ATK_IS_COMPONENT (component));
298 iface = ATK_COMPONENT_GET_IFACE (component);
300 if (iface->set_extents)
301 (iface->set_extents) (component, x, y, width, height);
305 * atk_component_set_position:
306 * @component: an #AtkComponent
310 * Sets the position of @component.
313 atk_component_set_position (AtkComponent *component,
317 AtkComponentIface *iface = NULL;
318 g_return_if_fail (component != NULL);
319 g_return_if_fail (ATK_IS_COMPONENT (component));
321 iface = ATK_COMPONENT_GET_IFACE (component);
323 if (iface->set_position)
324 (iface->set_position) (component, x, y);
328 * atk_component_set_size:
329 * @component: an #AtkComponent
330 * @width: width to set for @component
331 * @height: height to set for @component
333 * Set the size of the @component in terms of width and height.
336 atk_component_set_size (AtkComponent *component,
340 AtkComponentIface *iface = NULL;
341 g_return_if_fail (component != NULL);
342 g_return_if_fail (ATK_IS_COMPONENT (component));
344 iface = ATK_COMPONENT_GET_IFACE (component);
347 (iface->set_size) (component, x, y);
351 atk_component_real_get_accessible_at_point (AtkComponent *component,
357 count = atk_object_get_n_accessible_children (ATK_OBJECT (component));
359 g_return_val_if_fail (count != 0, NULL);
361 for (i = 0; i < count; i++)
365 obj = atk_object_ref_accessible_child (ATK_OBJECT (component), i);
369 if (atk_component_contains (ATK_COMPONENT (obj), x, y))
371 g_object_unref (obj);
376 g_object_unref (obj);