2 * AT-SPI - Assistive Technology Service Provider Interface
3 * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
5 * Copyright 2001, 2002 Sun Microsystems Inc.,
6 * Copyright 2001, 2002 Ximian, Inc.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 * AtspiComponent function implementations
30 #include "atspi-private.h"
33 atspi_rect_free (AtspiRect *rect)
39 atspi_rect_copy (AtspiRect *src)
41 AtspiRect *dst = g_new (AtspiRect, 1);
44 dst->height = src->height;
45 dst->width = src->width;
48 G_DEFINE_BOXED_TYPE (AtspiRect, atspi_rect, atspi_rect_copy, atspi_rect_free)
51 atspi_point_copy (AtspiPoint *src)
53 AtspiPoint *dst = g_new (AtspiPoint, 1);
58 G_DEFINE_BOXED_TYPE (AtspiPoint, atspi_point, atspi_point_copy, g_free)
61 * atspi_component_contains:
62 * @obj: a pointer to the #AtspiComponent to query.
63 * @x: a #long specifying the x coordinate in question.
64 * @y: a #long specifying the y coordinate in question.
65 * @ctype: the desired coordinate system of the point (@x, @y)
66 * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
68 * Query whether a given #AtspiComponent contains a particular point.
70 * Returns: a #TRUE if the specified component contains the point (@x, @y),
74 atspi_component_contains (AtspiComponent *obj,
77 AtspiCoordType ctype, GError **error)
79 dbus_bool_t retval = FALSE;
80 dbus_int32_t d_x = x, d_y = y;
81 dbus_uint32_t d_ctype = ctype;
83 g_return_val_if_fail (obj != NULL, FALSE);
85 _atspi_dbus_call (obj, atspi_interface_component, "Contains", error, "iin=>b", d_x, d_y, d_ctype, &retval);
91 * atspi_component_get_accessible_at_point:
92 * @obj: a pointer to the #AtspiComponent to query.
93 * @x: a #gint specifying the x coordinate of the point in question.
94 * @y: a #gint specifying the y coordinate of the point in question.
95 * @ctype: the coordinate system of the point (@x, @y)
96 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
98 * Get the accessible child at a given coordinate within an #AtspiComponent.
100 * Returns: (transfer full): a pointer to an #AtspiAccessible child of the
101 * specified component which contains the point (@x, @y), or NULL of
102 * no child contains the point.
105 atspi_component_get_accessible_at_point (AtspiComponent *obj,
108 AtspiCoordType ctype, GError **error)
110 dbus_int32_t d_x = x, d_y = y;
111 dbus_uint16_t d_ctype = ctype;
114 AtspiAccessible *retval = NULL;
116 g_return_val_if_fail (obj != NULL, FALSE);
118 reply = _atspi_dbus_call_partial (obj, atspi_interface_component, "GetAccessibleAtPoint", error, "iin", d_x, d_y, d_ctype);
120 return _atspi_dbus_return_accessible_from_message (reply);
124 * atspi_component_get_extents:
125 * @obj: a pointer to the #AtspiComponent to query.
126 * @ctype: the desired coordinate system into which to return the results,
127 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
129 * Returns: A #AtspiRect giving the accessible's extents.
131 * Get the bounding box of the specified #AtspiComponent.
135 atspi_component_get_extents (AtspiComponent *obj,
136 AtspiCoordType ctype, GError **error)
138 dbus_uint32_t d_ctype = ctype;
141 bbox.x = bbox.y = bbox.width = bbox.height = 0;
142 g_return_val_if_fail (obj != NULL, atspi_rect_copy (&bbox));
144 _atspi_dbus_call (obj, atspi_interface_component, "GetExtents", error, "u=>(iiii)", d_ctype, &bbox);
145 return atspi_rect_copy (&bbox);
149 * atspi_component_get_position:
150 * @obj: a pointer to the #AtspiComponent to query.
151 * @ctype: the desired coordinate system into which to return the results,
152 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
154 * returns: A #AtspiPoint giving the position.
155 * Get the minimum x and y coordinates of the specified #AtspiComponent.
159 atspi_component_get_position (AtspiComponent *obj,
160 AtspiCoordType ctype, GError **error)
162 dbus_int32_t d_x, d_y;
163 dbus_uint16_t d_ctype = ctype;
169 return atspi_point_copy (&ret);
171 _atspi_dbus_call (obj, atspi_interface_component, "GetPosition", error, "u=>ii", d_ctype, &d_x, &d_y);
175 return atspi_point_copy (&ret);
179 * atspi_component_get_size:
180 * @obj: a pointer to the #AtspiComponent to query.
181 * returns: A #AtspiPoint giving the size.
183 * Get the size of the specified #AtspiComponent.
187 atspi_component_get_size (AtspiComponent *obj, GError **error)
189 dbus_int32_t d_w, d_h;
194 return atspi_point_copy (&ret);
196 _atspi_dbus_call (obj, atspi_interface_component, "GetSize", error, "=>ii", &d_w, &d_h);
199 return atspi_point_copy (&ret);
203 * atspi_component_get_layer:
204 * @obj: a pointer to the #AtspiComponent to query.
206 * Query which layer the component is painted into, to help determine its
207 * visibility in terms of stacking order.
209 * Returns: the #AtspiComponentLayer into which this component is painted.
212 atspi_component_get_layer (AtspiComponent *obj, GError **error)
214 dbus_uint32_t zlayer = 0;
216 _atspi_dbus_call (obj, atspi_interface_component, "GetLayer", error, "=>u", &zlayer);
222 * atspi_component_get_mdi_z_order:
223 * @obj: a pointer to the #AtspiComponent to query.
225 * Query the z stacking order of a component which is in the MDI or window
226 * layer. (Bigger z-order numbers mean nearer the top)
228 * Returns: a short integer indicating the stacking order of the component
229 * in the MDI layer, or -1 if the component is not in the MDI layer.
232 atspi_component_get_mdi_z_order (AtspiComponent *obj, GError **error)
234 dbus_uint16_t retval = -1;
236 _atspi_dbus_call (obj, atspi_interface_component, "GetMDIZOrder", error, "=>n", &retval);
242 * atspi_component_grab_focus:
243 * @obj: a pointer to the #AtspiComponent on which to operate.
245 * Attempt to set the keyboard input focus to the specified
248 * Returns: #TRUE if successful, #FALSE otherwise.
252 atspi_component_grab_focus (AtspiComponent *obj, GError **error)
254 dbus_bool_t retval = FALSE;
256 _atspi_dbus_call (obj, atspi_interface_component, "GrabFocus", error, "=>b", &retval);
262 * atspi_component_get_alpha:
263 * @obj: The #AtspiComponent to be queried.
265 * Get the opacity/alpha value of a component, if alpha blending is in use.
267 * Returns: the opacity value of a component, as a double between 0.0 and 1.0.
270 atspi_component_get_alpha (AtspiComponent *obj, GError **error)
274 _atspi_dbus_call (obj, atspi_interface_component, "GetAlpha", error, "=>d", &retval);
280 atspi_component_base_init (AtspiComponent *klass)
285 atspi_component_get_type (void)
287 static GType type = 0;
290 static const GTypeInfo tinfo =
292 sizeof (AtspiComponent),
293 (GBaseInitFunc) atspi_component_base_init,
294 (GBaseFinalizeFunc) NULL,
297 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiComponent", &tinfo, 0);