X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=cspi%2Fspi_component.c;h=93a30c5b6764607e0115417527d81dbb68d84c0f;hb=39ba4c94f2925b59df2931a02f7537a61a6690da;hp=c5f0aabd3af3583dfd39be078ebce3de81246867;hpb=408978dd34f3338e49b6ace5f60b7606579ce7a9;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/cspi/spi_component.c b/cspi/spi_component.c index c5f0aab..93a30c5 100644 --- a/cspi/spi_component.c +++ b/cspi/spi_component.c @@ -1,176 +1,346 @@ /* + * AT-SPI - Assistive Technology Service Provider Interface + * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap) * - * SpiAccessibleComponent function implementations + * Copyright 2001, 2002 Sun Microsystems Inc., + * Copyright 2001, 2002 Ximian, Inc. * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. */ -/** - * SpiAccessibleComponent_ref: - * @obj: a pointer to an object implementing #SpiAccessibleComponent on which to operate. +/* * - * Increment the reference count for an #SpiAccessibleComponent. + * AccessibleComponent function implementations * - * Returns: (no return code implemented yet). + */ + +#include + +/** + * AccessibleComponent_ref: + * @obj: a pointer to an object implementing #AccessibleComponent on which to operate. * + * Increment the reference count for an #AccessibleComponent. **/ -int -SpiAccessibleComponent_ref (SpiAccessibleComponent *obj) +void +AccessibleComponent_ref (AccessibleComponent *obj) { - Accessibility_SpiComponent_ref (*obj, &ev); - return 0; + cspi_object_ref (obj); } /** - * SpiAccessibleComponent_unref: - * @obj: a pointer to the object implementing #SpiAccessibleComponent on which to operate. - * - * Decrement the reference count for an #SpiAccessibleComponent. - * - * Returns: (no return code implemented yet). + * AccessibleComponent_unref: + * @obj: a pointer to the object implementing #AccessibleComponent on which to operate. * + * Decrement the reference count for an #AccessibleComponent. **/ -int -SpiAccessibleComponent_unref (SpiAccessibleComponent *obj) +void +AccessibleComponent_unref (AccessibleComponent *obj) { - Accessibility_SpiComponent_unref (*obj, &ev); - return 0; + cspi_object_unref (obj); } /** - * SpiAccessibleComponent_contains: - * @obj: a pointer to the #SpiAccessibleComponent to query. + * AccessibleComponent_contains: + * @obj: a pointer to the #AccessibleComponent to query. * @x: a #long specifying the x coordinate in question. * @y: a #long specifying the y coordinate in question. * @ctype: the desired coordinate system of the point (@x, @y) - * (e.g. COORD_TYPE_WINDOW, COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * - * Query whether a given #SpiAccessibleComponent contains a particular point. + * Query whether a given #AccessibleComponent contains a particular point. * + * Returns: a #TRUE if the specified component contains the point (@x, @y), + * otherwise #FALSE. **/ -boolean -SpiAccessibleComponent_contains (SpiAccessibleComponent *obj, - long x, - long y, - SpiAccessibleCoordType ctype) +SPIBoolean +AccessibleComponent_contains (AccessibleComponent *obj, + long int x, + long int y, + AccessibleCoordType ctype) { - return Accessibility_SpiComponent_contains (*obj, - (CORBA_long) x, - (CORBA_long) y, - ctype, - &ev); + dbus_bool_t retval; + dbus_int32_t d_x = x, d_y = y; + dbus_uint16_t d_ctype = ctype; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + cspi_dbus_call (obj, spi_interface_component, "contains", NULL, "iin=>b", d_x, d_y, d_ctype, &retval); + + cspi_return_val_if_ev ("contains", FALSE); + + return retval; } /** - * SpiAccessibleComponent_getAccessibleAtPoint: - * @obj: a pointer to the #SpiAccessibleComponent to query. + * AccessibleComponent_getAccessibleAtPoint: + * @obj: a pointer to the #AccessibleComponent to query. * @x: a #long specifying the x coordinate of the point in question. * @y: a #long specifying the y coordinate of the point in question. * @ctype: the coordinate system of the point (@x, @y) - * (e.g. COORD_TYPE_WINDOW, COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * - * Get the accessible child at a given coordinate within an #SpiAccessibleComponent. + * Get the accessible child at a given coordinate within an #AccessibleComponent. * - * Returns: a pointer to an #SpiAccessible child of the specified component which + * Returns: a pointer to an #Accessible child of the specified component which * contains the point (@x, @y), or NULL of no child contains the point. **/ -SpiAccessible * -SpiAccessibleComponent_getAccessibleAtPoint (SpiAccessibleComponent *obj, - long x, - long y, - SpiAccessibleCoordType ctype) +Accessible * +AccessibleComponent_getAccessibleAtPoint (AccessibleComponent *obj, + long int x, + long int y, + AccessibleCoordType ctype) { - SpiAccessible child; - child = Accessibility_SpiComponent_getAccessibleAtPoint(*obj, - (CORBA_long) x, - (CORBA_long) y, - ctype, - &ev); - return (child != NULL) ? Obj_Add (child) : NULL; + dbus_int32_t d_x = x, d_y = y; + dbus_uint16_t d_ctype = ctype; + char *path = NULL; + Accessible *retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + cspi_dbus_call (obj, spi_interface_component, "getAccessibleAtPoint", NULL, "iin=>o", d_x, d_y, d_ctype, &path); + + retval = cspi_ref_related_accessible (obj, path); + g_free (path); + return retval; } /** - * SpiAccessibleComponent_getExtents: - * @obj: a pointer to the #SpiAccessibleComponent to query. + * AccessibleComponent_getExtents: + * @obj: a pointer to the #AccessibleComponent to query. * @x: a pointer to a #long into which the minimum x coordinate will be returned. * @y: a pointer to a #long into which the minimum y coordinate will be returned. * @width: a pointer to a #long into which the x extents (width) will be returned. * @height: a pointer to a #long into which the y extents (height) will be returned. * @ctype: the desired coordinate system into which to return the results, - * (e.g. COORD_TYPE_WINDOW, COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * - * Get the bounding box of the specified #SpiAccessibleComponent. + * Get the bounding box of the specified #AccessibleComponent. * **/ void -SpiAccessibleComponent_getExtents (SpiAccessibleComponent *obj, - long *x, - long *y, - long *width, - long *height, - SpiAccessibleCoordType ctype) +AccessibleComponent_getExtents (AccessibleComponent *obj, + long int *x, + long int *y, + long int *width, + long int *height, + AccessibleCoordType ctype) { - CORBA_long cx, cy, cw, ch; - Accessibility_SpiComponent_getExtents (*obj, - &cx, - &cy, - &cw, - &ch, - ctype, - &ev); - spi_warn_ev (&ev, "SpiAccessibleComponent_getExtents"); - *x = (long) cx; - *y = (long) cy; - *width = (long) cw; - *height = (long) ch; + dbus_int16_t d_ctype = ctype; + Accessibility_BoundingBox bbox; + + cspi_return_if_fail (obj != NULL); + + cspi_dbus_call (obj, spi_interface_component, "getExtents", NULL, "n=>(iiii)", d_ctype, &bbox); + if (!cspi_check_ev ("getExtents")) + { + *x = *y = *width = *height = 0; + } + else + { + *x = bbox.x; + *y = bbox.y; + *width = bbox.width; + *height = bbox.height; + } } /** - * SpiAccessibleComponent_getPosition: - * @obj: a pointer to the #SpiAccessibleComponent to query. + * AccessibleComponent_getPosition: + * @obj: a pointer to the #AccessibleComponent to query. * @x: a pointer to a #long into which the minimum x coordinate will be returned. * @y: a pointer to a #long into which the minimum y coordinate will be returned. * @ctype: the desired coordinate system into which to return the results, - * (e.g. COORD_TYPE_WINDOW, COORD_TYPE_SCREEN). + * (e.g. CSPI_COORD_TYPE_WINDOW, CSPI_COORD_TYPE_SCREEN). * - * Get the minimum x and y coordinates of the specified #SpiAccessibleComponent. + * Get the minimum x and y coordinates of the specified #AccessibleComponent. * **/ void -SpiAccessibleComponent_getPosition (SpiAccessibleComponent *obj, - long *x, - long *y, - SpiAccessibleCoordType ctype) +AccessibleComponent_getPosition (AccessibleComponent *obj, + long int *x, + long int *y, + AccessibleCoordType ctype) { - Accessibility_SpiComponent_getPosition (*obj, - (CORBA_long *) x, - (CORBA_long *) y, - ctype, - &ev); + dbus_int32_t d_x, d_y; + dbus_uint16_t d_ctype = ctype; + + cspi_return_if_fail (obj != NULL); + + cspi_dbus_call (obj, spi_interface_component, "getPosition", NULL, "n=>ii", d_ctype, &d_x, &d_y); + + if (!cspi_check_ev ("getPosition")) + { + *x = *y = 0; + } + else + { + *x = d_x; + *y = d_y; + } } /** - * SpiAccessibleComponent_getSize: - * @obj: a pointer to the #SpiAccessibleComponent to query. + * AccessibleComponent_getSize: + * @obj: a pointer to the #AccessibleComponent to query. * @width: a pointer to a #long into which the x extents (width) will be returned. * @height: a pointer to a #long into which the y extents (height) will be returned. * - * Get the size of the specified #SpiAccessibleComponent. + * Get the size of the specified #AccessibleComponent. * **/ void -SpiAccessibleComponent_getSize (SpiAccessibleComponent *obj, - long *width, - long *height) +AccessibleComponent_getSize (AccessibleComponent *obj, + long int *width, + long int *height) { - Accessibility_SpiComponent_getSize (*obj, - (CORBA_long *) width, - (CORBA_long *) height, - &ev); + dbus_int32_t d_w, d_h; + + cspi_return_if_fail (obj != NULL); + + cspi_dbus_call (obj, spi_interface_component, "getSize", NULL, "=>ii", &d_w, &d_h); + if (cspi_check_ev ("getSize")) + { + *width = *height = 0; + } + else + { + *width = d_w; + *height = d_h; + } } -/* Not Yet Implemented */ -void -SpiAccessibleComponent_grabFocus (SpiAccessibleComponent *obj) +/** + * AccessibleComponent_getLayer: + * @obj: a pointer to the #AccessibleComponent to query. + * + * Query which layer the component is painted into, to help determine its + * visibility in terms of stacking order. + * + * Returns: the #AccessibleComponentLayer into which this component is painted. + **/ +AccessibleComponentLayer +AccessibleComponent_getLayer (AccessibleComponent *obj) +{ + AccessibleComponentLayer retval; + dbus_uint32_t zlayer; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + cspi_dbus_call (obj, spi_interface_component, "getLayer", NULL, "=>u", &zlayer); + + cspi_return_val_if_ev ("getLayer", SPI_LAYER_INVALID); + + switch (zlayer) + { + case Accessibility_LAYER_BACKGROUND: + retval = SPI_LAYER_BACKGROUND; + break; + case Accessibility_LAYER_CANVAS: + retval = SPI_LAYER_CANVAS; + break; + case Accessibility_LAYER_WIDGET: + retval = SPI_LAYER_WIDGET; + break; + case Accessibility_LAYER_MDI: + retval = SPI_LAYER_MDI; + break; + case Accessibility_LAYER_POPUP: + retval = SPI_LAYER_POPUP; + break; + case Accessibility_LAYER_OVERLAY: + retval = SPI_LAYER_OVERLAY; + break; + case Accessibility_LAYER_WINDOW: + retval = SPI_LAYER_WINDOW; + break; + default: + retval = SPI_LAYER_INVALID; + break; + } + + return retval; +} + +/** + * AccessibleComponent_getMDIZOrder: + * @obj: a pointer to the #AccessibleComponent to query. + * + * Query the z stacking order of a component which is in the MDI or window + * layer. (Bigger z-order numbers mean nearer the top) + * + * Returns: a short integer indicating the stacking order of the component + * in the MDI layer, or -1 if the component is not in the MDI layer. + **/ +short +AccessibleComponent_getMDIZOrder (AccessibleComponent *obj) { - ; + dbus_uint16_t retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + cspi_dbus_call (obj, spi_interface_component, "getMDIZOrder", NULL, "=>n", &retval); + + cspi_return_val_if_ev ("getMDIZOrder", FALSE); + + return retval; +} + +/** + * AccessibleComponent_grabFocus: + * @obj: a pointer to the #AccessibleComponent on which to operate. + * + * Attempt to set the keyboard input focus to the specified + * #AccessibleComponent. + * + * Returns: #TRUE if successful, #FALSE otherwise. + * + **/ +SPIBoolean +AccessibleComponent_grabFocus (AccessibleComponent *obj) +{ + dbus_bool_t retval; + + cspi_return_val_if_fail (obj != NULL, FALSE); + + cspi_dbus_call (obj, spi_interface_component, "grabFocus", NULL, "=>b", &retval); + + cspi_return_val_if_ev ("grabFocus", FALSE); + + return retval; +} + +/** + * AccessibleComponent_getAlpha: + * @obj: The #AccessibleComponent to be queried. + * + * Get the opacity/alpha value of a component, if alpha blending is in use. + * + * Returns: the opacity value of a component, as a double between 0.0 and 1.0. + **/ +double +AccessibleComponent_getAlpha (AccessibleComponent *obj) +{ + double retval; + + cspi_return_val_if_fail (obj != NULL, 1.0); + + cspi_dbus_call (obj, spi_interface_component, "getAlpha", NULL, "=>d", &retval); + + cspi_return_val_if_ev ("getAlpha", 1.0); + + return retval; }