Add .po and .pc files from cspi
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_component.c
index 2d25593..93a30c5 100644 (file)
@@ -1,4 +1,27 @@
 /*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * 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.
+ */
+
+/*
  *
  * AccessibleComponent function implementations
  *
@@ -11,9 +34,6 @@
  * @obj: a pointer to an object implementing #AccessibleComponent on which to operate.
  *
  * Increment the reference count for an #AccessibleComponent.
- *
- * Returns: (no return code implemented yet).
- *
  **/
 void
 AccessibleComponent_ref (AccessibleComponent *obj)
@@ -26,9 +46,6 @@ AccessibleComponent_ref (AccessibleComponent *obj)
  * @obj: a pointer to the object implementing #AccessibleComponent on which to operate.
  *
  * Decrement the reference count for an #AccessibleComponent.
- *
- * Returns: (no return code implemented yet).
- *
  **/
 void
 AccessibleComponent_unref (AccessibleComponent *obj)
@@ -55,15 +72,14 @@ AccessibleComponent_contains (AccessibleComponent *obj,
                               long int y,
                               AccessibleCoordType ctype)
 {
-  SPIBoolean retval;
+  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);
 
-  retval = Accessibility_Component_contains (CSPI_OBJREF (obj),
-                                            (CORBA_long) x,
-                                            (CORBA_long) y,
-                                            ctype,
-                                            cspi_ev ());
+  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;
@@ -88,16 +104,18 @@ AccessibleComponent_getAccessibleAtPoint (AccessibleComponent *obj,
                                           long int y,
                                           AccessibleCoordType ctype)
 {
-  Accessibility_Accessible child;
+  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, NULL);
+  cspi_return_val_if_fail (obj != NULL, FALSE);
 
-  child = Accessibility_Component_getAccessibleAtPoint (CSPI_OBJREF (obj),
-                                                       (CORBA_long) x,
-                                                       (CORBA_long) y,
-                                                       ctype,
-                                                       cspi_ev ());
-  return cspi_object_add (child);
+  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;
 }
 
 /**
@@ -121,14 +139,13 @@ AccessibleComponent_getExtents (AccessibleComponent *obj,
                                 long int *height,
                                 AccessibleCoordType ctype)
 {
+  dbus_int16_t d_ctype = ctype;
   Accessibility_BoundingBox bbox;
 
   cspi_return_if_fail (obj != NULL);
 
-  bbox = Accessibility_Component_getExtents (CSPI_OBJREF (obj),
-                                            ctype,
-                                            cspi_ev ());
-  if (!cspi_check_ev ("AccessibleComponent_getExtents"))
+  cspi_dbus_call (obj, spi_interface_component, "getExtents", NULL, "n=>(iiii)", d_ctype, &bbox);
+  if (!cspi_check_ev ("getExtents"))
     {
       *x = *y = *width = *height = 0;    
     }
@@ -158,12 +175,12 @@ AccessibleComponent_getPosition (AccessibleComponent *obj,
                                  long int *y,
                                  AccessibleCoordType ctype)
 {
-  CORBA_long cx, cy;
+  dbus_int32_t d_x, d_y;
+  dbus_uint16_t d_ctype = ctype;
 
   cspi_return_if_fail (obj != NULL);
 
-  Accessibility_Component_getPosition (CSPI_OBJREF (obj),
-                                      &cx, &cy, ctype, cspi_ev ());
+  cspi_dbus_call (obj, spi_interface_component, "getPosition", NULL, "n=>ii", d_ctype, &d_x, &d_y);
 
   if (!cspi_check_ev ("getPosition"))
     {
@@ -171,8 +188,8 @@ AccessibleComponent_getPosition (AccessibleComponent *obj,
     }
   else
     {
-      *x = cx;
-      *y = cy;
+      *x = d_x;
+      *y = d_y;
     }
 }
 
@@ -190,12 +207,20 @@ AccessibleComponent_getSize (AccessibleComponent *obj,
                              long int *width,
                              long int *height)
 {
+  dbus_int32_t d_w, d_h;
+
   cspi_return_if_fail (obj != NULL);
 
-  Accessibility_Component_getSize (CSPI_OBJREF (obj),
-                                   (CORBA_long *) width,
-                                   (CORBA_long *) height,
-                                   cspi_ev ());
+  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;
+  }
 }
 
 /**
@@ -211,12 +236,11 @@ AccessibleComponentLayer
 AccessibleComponent_getLayer (AccessibleComponent *obj)
 {
   AccessibleComponentLayer     retval;
-  Accessibility_ComponentLayer zlayer;
+  dbus_uint32_t zlayer;
 
   cspi_return_val_if_fail (obj != NULL, FALSE);
 
-  zlayer = Accessibility_Component_getLayer (CSPI_OBJREF (obj),
-                                            cspi_ev ());
+  cspi_dbus_call (obj, spi_interface_component, "getLayer", NULL, "=>u", &zlayer);
 
   cspi_return_val_if_ev ("getLayer", SPI_LAYER_INVALID);
 
@@ -240,6 +264,9 @@ AccessibleComponent_getLayer (AccessibleComponent *obj)
     case Accessibility_LAYER_OVERLAY:    
       retval = SPI_LAYER_OVERLAY;
       break;
+    case Accessibility_LAYER_WINDOW:     
+      retval = SPI_LAYER_WINDOW;
+      break;
     default:
       retval = SPI_LAYER_INVALID;
       break;
@@ -252,8 +279,8 @@ AccessibleComponent_getLayer (AccessibleComponent *obj)
  * AccessibleComponent_getMDIZOrder:
  * @obj: a pointer to the #AccessibleComponent to query.
  *
- * Query the z stacking order of a component which is in the MDI layer.
- *       (Bigger z-order numbers mean nearer the top)
+ * 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.
@@ -261,12 +288,11 @@ AccessibleComponent_getLayer (AccessibleComponent *obj)
 short
 AccessibleComponent_getMDIZOrder (AccessibleComponent *obj)
 {
-  short retval;
+  dbus_uint16_t retval;
 
   cspi_return_val_if_fail (obj != NULL, FALSE);
 
-  retval = Accessibility_Component_getMDIZOrder (CSPI_OBJREF (obj),
-                                                cspi_ev ());
+  cspi_dbus_call (obj, spi_interface_component, "getMDIZOrder", NULL, "=>n", &retval);
 
   cspi_return_val_if_ev ("getMDIZOrder", FALSE);
 
@@ -279,8 +305,42 @@ AccessibleComponent_getMDIZOrder (AccessibleComponent *obj)
  *
  * Attempt to set the keyboard input focus to the specified
  *         #AccessibleComponent.
+ *
+ * Returns: #TRUE if successful, #FALSE otherwise.
+ *
  **/
-void
+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;
 }