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 (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
102 * @coord_type: specifies whether the coordinates are relative to the screen
103 * or to the components top level window
105 * Checks whether the specified point is within the extent 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,
114 AtkCoordType coord_type)
116 AtkComponentIface *iface = NULL;
117 g_return_val_if_fail (component != NULL, FALSE);
118 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
120 iface = ATK_COMPONENT_GET_IFACE (component);
123 return (iface->contains) (component, x, y, coord_type);
129 * atk_component_get_accessible_at_point:
130 * @component: the #AtkComponent
133 * @coord_type: specifies whether the coordinates are relative to the screen
134 * or to the components top level window
136 * Gets the accessible child, if one exists, contained at the
137 * coordinate point specified by @x and @y.
139 * Returns: the accessible child, if one exists
142 atk_component_get_accessible_at_point (AtkComponent *component,
145 AtkCoordType coord_type)
147 AtkComponentIface *iface = NULL;
148 g_return_val_if_fail (component != NULL, NULL);
149 g_return_val_if_fail (ATK_IS_COMPONENT (component), NULL);
151 iface = ATK_COMPONENT_GET_IFACE (component);
153 if (iface->get_accessible_at_point)
154 return (iface->get_accessible_at_point) (component, x, y, coord_type);
158 * if this method is not overridden use the default implementation.
160 return atk_component_real_get_accessible_at_point (component, x, y, coord_type);
165 * atk_component_get_extents:
166 * @component: an #AtkComponent
167 * @x: address of #gint to put x coordinate
168 * @y: address of #gint to put y coordinate
169 * @width: address of #gint to put width
170 * @height: address of #gint to put height
171 * @coord_type: specifies whether the coordinates are relative to the screen
172 * or to the components top level window
174 * Gets the rectangle which gives the extent of the @component.
178 atk_component_get_extents (AtkComponent *component,
183 AtkCoordType coord_type)
185 AtkComponentIface *iface = NULL;
186 g_return_if_fail (ATK_IS_COMPONENT (component));
188 iface = ATK_COMPONENT_GET_IFACE (component);
190 if (iface->get_extents)
191 (iface->get_extents) (component, x, y, width, height, coord_type);
195 * atk_component_get_position:
196 * @component: an #AtkComponent
197 * @x: address of #gint to put x coordinate position
198 * @y: address of #gint to put y coordinate position
199 * @coord_type: specifies whether the coordinates are relative to the screen
200 * or to the components top level window
202 * Gets the position of @component in the form of
203 * a point specifying @component's top-left corner.
206 atk_component_get_position (AtkComponent *component,
209 AtkCoordType coord_type)
211 AtkComponentIface *iface = NULL;
212 g_return_if_fail (ATK_IS_COMPONENT (component));
214 iface = ATK_COMPONENT_GET_IFACE (component);
216 if (iface->get_position)
217 (iface->get_position) (component, x, y, coord_type);
221 * atk_component_get_size:
222 * @component: an #AtkComponent
223 * @width: address of #gint to put width of @component
224 * @height: address of #gint to put height of @component
226 * Gets the size of the @component in terms of width and height.
229 atk_component_get_size (AtkComponent *component,
233 AtkComponentIface *iface = NULL;
234 g_return_if_fail (ATK_IS_COMPONENT (component));
236 iface = ATK_COMPONENT_GET_IFACE (component);
239 (iface->get_size) (component, x, y);
243 * atk_component_grab_focus:
244 * @component: an #AtkComponent
246 * Grabs focus for this @component.
248 * Returns: %TRUE if successful, %FALSE otherwise.
251 atk_component_grab_focus (AtkComponent *component)
253 AtkComponentIface *iface = NULL;
254 g_return_val_if_fail (component != NULL, FALSE);
255 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
257 iface = ATK_COMPONENT_GET_IFACE (component);
259 if (iface->grab_focus)
260 return (iface->grab_focus) (component);
266 * atk_component_set_extents:
267 * @component: an #AtkComponent
270 * @width: width to set for @component
271 * @height: height to set for @component
272 * @coord_type: specifies whether the coordinates are relative to the screen
273 * or to the components top level window
275 * Sets the extents of @component.
277 * Returns: %TRUE or %FALSE whether the extents were set or not
280 atk_component_set_extents (AtkComponent *component,
285 AtkCoordType coord_type)
287 AtkComponentIface *iface = NULL;
288 g_return_val_if_fail (component != NULL, FALSE);
289 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
291 iface = ATK_COMPONENT_GET_IFACE (component);
293 if (iface->set_extents)
294 return (iface->set_extents) (component, x, y, width, height, coord_type);
300 * atk_component_set_position:
301 * @component: an #AtkComponent
304 * @coord_type: specifies whether the coordinates are relative to the screen
305 * or to the components top level window
307 * Sets the postition of @component.
309 * Returns: %TRUE or %FALSE whether or not the position was set or not
312 atk_component_set_position (AtkComponent *component,
315 AtkCoordType coord_type)
317 AtkComponentIface *iface = NULL;
318 g_return_val_if_fail (component != NULL, FALSE);
319 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
321 iface = ATK_COMPONENT_GET_IFACE (component);
323 if (iface->set_position)
324 return (iface->set_position) (component, x, y, coord_type);
330 * atk_component_set_size:
331 * @component: an #AtkComponent
332 * @width: width to set for @component
333 * @height: height to set for @component
335 * Set the size of the @component in terms of width and height.
337 * Returns: %TRUE or %FALSE whether the size was set or not
340 atk_component_set_size (AtkComponent *component,
344 AtkComponentIface *iface = NULL;
345 g_return_val_if_fail (component != NULL, FALSE);
346 g_return_val_if_fail (ATK_IS_COMPONENT (component), FALSE);
348 iface = ATK_COMPONENT_GET_IFACE (component);
351 return (iface->set_size) (component, x, y);
357 atk_component_real_get_accessible_at_point (AtkComponent *component,
360 AtkCoordType coord_type)
364 count = atk_object_get_n_accessible_children (ATK_OBJECT (component));
366 g_return_val_if_fail (count != 0, NULL);
368 for (i = 0; i < count; i++)
372 obj = atk_object_ref_accessible_child (ATK_OBJECT (component), i);
376 if (atk_component_contains (ATK_COMPONENT (obj), x, y, coord_type))
378 g_object_unref (obj);
383 g_object_unref (obj);