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),
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.
172 atk_component_get_extents (AtkComponent *component,
178 AtkComponentIface *iface = NULL;
179 g_return_if_fail (component != NULL);
180 g_return_if_fail (ATK_IS_COMPONENT (component));
182 iface = ATK_COMPONENT_GET_IFACE (component);
184 if (iface->get_extents)
185 (iface->get_extents) (component, x, y, width, height);
189 * atk_component_get_position:
190 * @component: an #AtkComponent
191 * @x: address of #gint to put x coordinate position
192 * @y: address of #gint to put y coordinate position
194 * Gets the position of @component relative to the parent in the form of
195 * a point specifying @component's top-left corner in the screen's
199 atk_component_get_position (AtkComponent *component,
203 AtkComponentIface *iface = NULL;
204 g_return_if_fail (component != NULL);
205 g_return_if_fail (ATK_IS_COMPONENT (component));
207 iface = ATK_COMPONENT_GET_IFACE (component);
209 if (iface->get_position)
210 (iface->get_position) (component, x, y);
214 * atk_component_get_position_on_screen:
215 * @component: an #AtkComponent
216 * @x: address of #gint to put x coordinate position
217 * @y: address of #gint to put y coordinate position
219 * Gets the position of the @component on the screen
222 atk_component_get_position_on_screen (AtkComponent *component,
226 AtkComponentIface *iface = NULL;
227 g_return_if_fail (component != NULL);
228 g_return_if_fail (ATK_IS_COMPONENT (component));
230 iface = ATK_COMPONENT_GET_IFACE (component);
232 if (iface->get_position_on_screen)
233 (iface->get_position_on_screen) (component, x, y);
237 * atk_component_get_size:
238 * @component: an #AtkComponent
239 * @width: address of #gint to put width of @component
240 * @height: address of #gint to put height of @component
242 * Gets the size of the @component in terms of width and height.
245 atk_component_get_size (AtkComponent *component,
249 AtkComponentIface *iface = NULL;
250 g_return_if_fail (component != NULL);
251 g_return_if_fail (ATK_IS_COMPONENT (component));
253 iface = ATK_COMPONENT_GET_IFACE (component);
256 (iface->get_size) (component, x, y);
260 * atk_component_grab_focus:
261 * @component: an #AtkComponent
263 * Grabs focus for this @component
266 atk_component_grab_focus (AtkComponent *component)
268 AtkComponentIface *iface = NULL;
269 g_return_if_fail (component != NULL);
270 g_return_if_fail (ATK_IS_COMPONENT (component));
272 iface = ATK_COMPONENT_GET_IFACE (component);
274 if (iface->grab_focus)
275 (iface->grab_focus) (component);
279 * atk_component_set_extents:
280 * @component: an #AtkComponent
283 * @width: width to set for @component
284 * @height: height to set for @component
286 * Sets the extents of @component
289 atk_component_set_extents (AtkComponent *component,
295 AtkComponentIface *iface = NULL;
296 g_return_if_fail (component != NULL);
297 g_return_if_fail (ATK_IS_COMPONENT (component));
299 iface = ATK_COMPONENT_GET_IFACE (component);
301 if (iface->set_extents)
302 (iface->set_extents) (component, x, y, width, height);
306 * atk_component_set_position:
307 * @component: an #AtkComponent
311 * Sets the postition of @component
314 atk_component_set_position (AtkComponent *component,
318 AtkComponentIface *iface = NULL;
319 g_return_if_fail (component != NULL);
320 g_return_if_fail (ATK_IS_COMPONENT (component));
322 iface = ATK_COMPONENT_GET_IFACE (component);
324 if (iface->set_position)
325 (iface->set_position) (component, x, y);
329 * atk_component_set_size:
330 * @component: an #AtkComponent
331 * @width: width to set for @component
332 * @height: height to set for @component
334 * Set the size of the @component in terms of width and height
337 atk_component_set_size (AtkComponent *component,
341 AtkComponentIface *iface = NULL;
342 g_return_if_fail (component != NULL);
343 g_return_if_fail (ATK_IS_COMPONENT (component));
345 iface = ATK_COMPONENT_GET_IFACE (component);
348 (iface->set_size) (component, x, y);
352 atk_component_real_get_accessible_at_point (AtkComponent *component,
358 count = atk_object_get_n_accessible_children (ATK_OBJECT (component));
360 g_return_val_if_fail (count != 0, NULL);
362 for (i = 0; i < count; i++)
366 obj = atk_object_ref_accessible_child (ATK_OBJECT (component), i);
370 if (atk_component_contains (ATK_COMPONENT (obj), x, y))
372 g_object_unref (obj);
377 g_object_unref (obj);