Add atk-bridge
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_image.c
index 7b4d6a4..94d78ad 100644 (file)
@@ -1,3 +1,26 @@
+/*
+ * 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.
+ */
+
 #include <cspi/spi-private.h>
 
 /**
  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
  *
  * Increment the reference count for an #AccessibleImage object.
- *
- * Returns: (no return code implemented yet).
- *
  **/
-int
+void
 AccessibleImage_ref (AccessibleImage *obj)
 {
   cspi_object_ref (obj);
-  return 0;
 }
 
-
-
 /**
  * AccessibleImage_unref:
  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
  *
  * Decrement the reference count for an #AccessibleImage object.
- *
- * Returns: (no return code implemented yet).
- *
  **/
-int
+void
 AccessibleImage_unref (AccessibleImage *obj)
 {
   cspi_object_unref (obj);
-  return 0;
 }
 
-
 /**
  * AccessibleImage_getImageDescription:
  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
@@ -42,16 +54,22 @@ AccessibleImage_unref (AccessibleImage *obj)
  * Get the description of the image displayed in an #AccessibleImage object.
  *
  * Returns: a UTF-8 string describing the image.
- *
  **/
 char *
 AccessibleImage_getImageDescription (AccessibleImage *obj)
 {
-  return (char *)
-    Accessibility_Image__get_imageDescription (CSPI_OBJREF (obj), cspi_ev ());
-}
+  char *retval;
+
+  cspi_return_val_if_fail (obj != NULL, NULL);
 
+  retval = 
+    Accessibility_Image__get_imageDescription (CSPI_OBJREF (obj),
+                                              cspi_ev ());
 
+  cspi_return_val_if_ev ("getImageDescription", NULL);
+
+  return retval;
+}
 
 /**
  * AccessibleImage_getImageSize:
@@ -60,18 +78,30 @@ AccessibleImage_getImageDescription (AccessibleImage *obj)
  * @height: a pointer to a #long into which the y extents (height) will be returned.
  *
  * Get the size of the image displayed in a specified #AccessibleImage object.
- *
  **/
 void
 AccessibleImage_getImageSize (AccessibleImage *obj,
                               long int *width,
                               long int *height)
 {
-  Accessibility_Image_getImageSize (CSPI_OBJREF (obj),
-                                   (CORBA_long *) width, (CORBA_long *) height, cspi_ev ());
-}
+  CORBA_long w, h;
+
+  cspi_return_if_fail (obj != NULL);
 
+  Accessibility_Image_getImageSize (CSPI_OBJREF (obj),
+                                   &w, &h, cspi_ev ());
 
+  if (!cspi_check_ev ("getImageSize"))
+    {
+      *width = 0;
+      *height = 0;
+    }
+  else
+    {
+      *width = w;
+      *height = h;
+    }
+}
 
 /**
  * AccessibleImage_getImagePosition:
@@ -83,7 +113,6 @@ AccessibleImage_getImageSize (AccessibleImage *obj,
  *
  * Get the minimum x and y coordinates of the image displayed in a
  *         specified #AccessibleImage implementor.
- *
  **/
 void
 AccessibleImage_getImagePosition (AccessibleImage *obj,
@@ -91,9 +120,23 @@ AccessibleImage_getImagePosition (AccessibleImage *obj,
                                   long *y,
                                   AccessibleCoordType ctype)
 {
+  CORBA_long cx, cy;
+
+  cspi_return_if_fail (obj != NULL);
+
   Accessibility_Image_getImagePosition (CSPI_OBJREF (obj),
-                                       (CORBA_long *) x, (CORBA_long *) y, (CORBA_short) ctype,
-                                       cspi_ev ());
+                                       &cx, &cy, ctype, cspi_ev ());
+
+  if (!cspi_check_ev ("getImagePosition"))
+    {
+      *x = 0;
+      *y = 0;
+    }
+  else
+    {
+      *x = cx;
+      *y = cy;
+    }
 }
 
 /**
@@ -108,7 +151,6 @@ AccessibleImage_getImagePosition (AccessibleImage *obj,
  *
  * Get the bounding box of the image displayed in a
  *         specified #AccessibleImage implementor.
- *
  **/
 void
 AccessibleImage_getImageExtents (AccessibleImage *obj,
@@ -118,12 +160,46 @@ AccessibleImage_getImageExtents (AccessibleImage *obj,
                                 long *height,
                                 AccessibleCoordType ctype)
 {
-  Accessibility_BoundingBox bbox;      
+  Accessibility_BoundingBox bbox;
+
+  cspi_return_if_fail (obj != NULL);
+
   bbox = Accessibility_Image_getImageExtents (CSPI_OBJREF (obj),
-                                             (CORBA_short) ctype,
+                                             ctype,
                                              cspi_ev ());
-  *x = bbox.x;
-  *y = bbox.y;
-  *width = bbox.width;
-  *height = bbox.height;
+
+  if (!cspi_check_ev ("getImageExtents"))
+    {
+      *x = *y = *width = *height = 0;
+    }
+  else
+    {
+      *x = bbox.x;
+      *y = bbox.y;
+      *width = bbox.width;
+      *height = bbox.height;
+    }
 }
+
+/**
+ * AccessibleImage_getImageLocale:
+ * @obj: The #AccessibleImage being queried.
+ *
+ * Get the locale associated with an image and its textual representation.
+ *
+ * Returns: A POSIX LC_MESSAGES-style Locale value for image description and text.
+ **/
+char *
+AccessibleImage_getImageLocale  (AccessibleImage *obj)
+{
+    char *retval = "C";
+
+    cspi_return_val_if_fail (obj != NULL, "C");
+
+    retval = Accessibility_Image__get_imageLocale (CSPI_OBJREF (obj), cspi_ev ());
+
+    cspi_return_val_if_ev ("getImageLocale", NULL);
+
+    return retval;
+}
+