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_copy (AtspiRect *src)
35 AtspiRect *dst = g_new (AtspiRect, 1);
38 dst->height = src->height;
39 dst->width = src->width;
42 G_DEFINE_BOXED_TYPE (AtspiRect, atspi_rect, atspi_rect_copy, g_free)
45 atspi_point_copy (AtspiPoint *src)
47 AtspiPoint *dst = g_new (AtspiPoint, 1);
52 G_DEFINE_BOXED_TYPE (AtspiPoint, atspi_point, atspi_point_copy, g_free)
55 * atspi_component_contains:
56 * @obj: a pointer to the #AtspiComponent to query.
57 * @x: a #long specifying the x coordinate in question.
58 * @y: a #long specifying the y coordinate in question.
59 * @ctype: the desired coordinate system of the point (@x, @y)
60 * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN).
62 * Query whether a given #AtspiComponent contains a particular point.
64 * Returns: a #TRUE if the specified component contains the point (@x, @y),
68 atspi_component_contains (AtspiComponent *obj,
71 AtspiCoordType ctype, GError **error)
73 dbus_bool_t retval = FALSE;
74 dbus_int32_t d_x = x, d_y = y;
75 dbus_uint16_t d_ctype = ctype;
77 g_return_val_if_fail (obj != NULL, FALSE);
79 _atspi_dbus_call (obj, atspi_interface_component, "Contains", error, "iin=>b", d_x, d_y, d_ctype, &retval);
85 * atspi_component_ref_accessible_at_point:
86 * @obj: a pointer to the #AtspiComponent to query.
87 * @x: a #gint specifying the x coordinate of the point in question.
88 * @y: a #gint specifying the y coordinate of the point in question.
89 * @ctype: the coordinate system of the point (@x, @y)
90 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
92 * Get the accessible child at a given coordinate within an #AtspiComponent.
94 * Returns: a pointer to an #AtspiAccessible child of the specified component
95 * which contains the point (@x, @y), or NULL of no child contains
99 atspi_component_ref_accessible_at_point (AtspiComponent *obj,
102 AtspiCoordType ctype, GError **error)
104 dbus_int32_t d_x = x, d_y = y;
105 dbus_uint16_t d_ctype = ctype;
108 AtspiAccessible *retval = NULL;
110 g_return_val_if_fail (obj != NULL, FALSE);
112 reply = _atspi_dbus_call_partial (obj, atspi_interface_component, "GetAccessibleAtPoint", error, "iin", d_x, d_y, d_ctype);
114 return _atspi_dbus_return_accessible_from_message (reply);
118 * atspi_component_get_extents:
119 * @obj: a pointer to the #AtspiComponent to query.
120 * @x: a pointer to a #int into which the minimum x coordinate will be returned.
121 * @y: a pointer to a #int into which the minimum y coordinate will be returned.
122 * @width: a pointer to a #int into which the x extents (width) will be returned.
123 * @height: a pointer to a #int into which the y extents (height) will be returned.
124 * @ctype: the desired coordinate system into which to return the results,
125 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
127 * Get the bounding box of the specified #AtspiComponent.
131 atspi_component_get_extents (AtspiComponent *obj,
136 AtspiCoordType ctype, GError **error)
138 dbus_int16_t d_ctype = ctype;
141 g_return_if_fail (obj != NULL);
143 _atspi_dbus_call (obj, atspi_interface_component, "GetExtents", error, "n=>(iiii)", d_ctype, &bbox);
148 * atspi_component_get_position:
149 * @obj: a pointer to the #AtspiComponent to query.
150 * @ctype: the desired coordinate system into which to return the results,
151 * (e.g. ATSPI_COORD_TYPE_WINDOW, ATSPI_COORD_TYPE_SCREEN).
153 * returns: A #AtspiPoint giving the position.
154 * Get the minimum x and y coordinates of the specified #AtspiComponent.
158 atspi_component_get_position (AtspiComponent *obj,
159 AtspiCoordType ctype, GError **error)
161 dbus_int32_t d_x, d_y;
162 dbus_uint16_t d_ctype = ctype;
170 _atspi_dbus_call (obj, atspi_interface_component, "GetPosition", error, "n=>ii", d_ctype, &d_x, &d_y);
178 * atspi_component_get_size:
179 * @obj: a pointer to the #AtspiComponent to query.
180 * returns: A #AtspiPoint giving the siize.
182 * Get the size of the specified #AtspiComponent.
186 atspi_component_get_size (AtspiComponent *obj, GError **error)
188 dbus_int32_t d_w, d_h;
195 _atspi_dbus_call (obj, atspi_interface_component, "GetSize", error, "=>ii", &d_w, &d_h);
202 * atspi_component_get_layer:
203 * @obj: a pointer to the #AtspiComponent to query.
205 * Query which layer the component is painted into, to help determine its
206 * visibility in terms of stacking order.
208 * Returns: the #AtspiComponentLayer into which this component is painted.
211 atspi_component_get_layer (AtspiComponent *obj, GError **error)
213 dbus_uint32_t zlayer = 0;
215 _atspi_dbus_call (obj, atspi_interface_component, "GetLayer", error, "=>u", &zlayer);
221 * atspi_component_get_mdi_z_order:
222 * @obj: a pointer to the #AtspiComponent to query.
224 * Query the z stacking order of a component which is in the MDI or window
225 * layer. (Bigger z-order numbers mean nearer the top)
227 * Returns: a short integer indicating the stacking order of the component
228 * in the MDI layer, or -1 if the component is not in the MDI layer.
231 atspi_component_get_mdi_z_order (AtspiComponent *obj, GError **error)
233 dbus_uint16_t retval = -1;
235 _atspi_dbus_call (obj, atspi_interface_component, "GetMDIZOrder", error, "=>n", &retval);
241 * atspi_component_grab_focus:
242 * @obj: a pointer to the #AtspiComponent on which to operate.
244 * Attempt to set the keyboard input focus to the specified
247 * Returns: #TRUE if successful, #FALSE otherwise.
251 atspi_component_grab_focus (AtspiComponent *obj, GError **error)
253 dbus_bool_t retval = FALSE;
255 _atspi_dbus_call (obj, atspi_interface_component, "GrabFocus", error, "=>b", &retval);
261 * atspi_component_get_alpha:
262 * @obj: The #AtspiComponent to be queried.
264 * Get the opacity/alpha value of a component, if alpha blending is in use.
266 * Returns: the opacity value of a component, as a double between 0.0 and 1.0.
269 atspi_component_get_alpha (AtspiComponent *obj, GError **error)
273 _atspi_dbus_call (obj, atspi_interface_component, "GetAlpha", error, "=>d", &retval);
279 atspi_component_base_init (AtspiComponent *klass)
281 static gboolean initialized = FALSE;
285 klass->contains = atspi_component_contains;
286 klass->ref_accessible_at_point = atspi_component_ref_accessible_at_point;
287 klass->get_extents = atspi_component_get_extents;
288 klass->get_position = atspi_component_get_position;
289 klass->get_size = atspi_component_get_size;
290 klass->get_layer = atspi_component_get_layer;
291 klass->get_mdi_z_order = atspi_component_get_mdi_z_order;
292 klass->grab_focus = atspi_component_grab_focus;
293 klass->get_alpha = atspi_component_get_alpha;
300 atspi_component_get_type (void)
302 static GType type = 0;
305 static const GTypeInfo tinfo =
307 sizeof (AtspiComponent),
308 (GBaseInitFunc) atspi_component_base_init,
309 (GBaseFinalizeFunc) NULL,
313 type = g_type_register_static (G_TYPE_INTERFACE, "AtspiComponent", &tinfo, 0);