2002-05-09 Marc Mulcahy <marc.mulcahy@sun.com>
[platform/core/uifw/at-spi2-atk.git] / cspi / spi_image.c
1 /*
2  * AT-SPI - Assistive Technology Service Provider Interface
3  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
4  *
5  * Copyright 2001 Sun Microsystems Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22
23 #include <cspi/spi-private.h>
24
25 /**
26  * AccessibleImage_ref:
27  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
28  *
29  * Increment the reference count for an #AccessibleImage object.
30  **/
31 void
32 AccessibleImage_ref (AccessibleImage *obj)
33 {
34   cspi_object_ref (obj);
35 }
36
37 /**
38  * AccessibleImage_unref:
39  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
40  *
41  * Decrement the reference count for an #AccessibleImage object.
42  **/
43 void
44 AccessibleImage_unref (AccessibleImage *obj)
45 {
46   cspi_object_unref (obj);
47 }
48
49 /**
50  * AccessibleImage_getImageDescription:
51  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
52  *
53  * Get the description of the image displayed in an #AccessibleImage object.
54  *
55  * Returns: a UTF-8 string describing the image.
56  **/
57 char *
58 AccessibleImage_getImageDescription (AccessibleImage *obj)
59 {
60   char *retval;
61
62   cspi_return_val_if_fail (obj != NULL, NULL);
63
64   retval = 
65     Accessibility_Image__get_imageDescription (CSPI_OBJREF (obj),
66                                                cspi_ev ());
67
68   cspi_return_val_if_ev ("getImageDescription", NULL);
69
70   return retval;
71 }
72
73 /**
74  * AccessibleImage_getImageSize:
75  * @obj: a pointer to the #AccessibleImage to query.
76  * @width: a pointer to a #long into which the x extents (width) will be returned.
77  * @height: a pointer to a #long into which the y extents (height) will be returned.
78  *
79  * Get the size of the image displayed in a specified #AccessibleImage object.
80  **/
81 void
82 AccessibleImage_getImageSize (AccessibleImage *obj,
83                               long int *width,
84                               long int *height)
85 {
86   CORBA_long w, h;
87
88   cspi_return_if_fail (obj != NULL);
89
90   Accessibility_Image_getImageSize (CSPI_OBJREF (obj),
91                                     &w, &h, cspi_ev ());
92
93   if (!cspi_check_ev ("getImageSize"))
94     {
95       *width = 0;
96       *height = 0;
97     }
98   else
99     {
100       *width = w;
101       *height = h;
102     }
103 }
104
105 /**
106  * AccessibleImage_getImagePosition:
107  * @obj: a pointer to the #AccessibleImage implementor to query.
108  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
109  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
110  * @ctype: the desired coordinate system into which to return the results,
111  *         (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
112  *
113  * Get the minimum x and y coordinates of the image displayed in a
114  *         specified #AccessibleImage implementor.
115  **/
116 void
117 AccessibleImage_getImagePosition (AccessibleImage *obj,
118                                   long *x,
119                                   long *y,
120                                   AccessibleCoordType ctype)
121 {
122   CORBA_long cx, cy;
123
124   cspi_return_if_fail (obj != NULL);
125
126   Accessibility_Image_getImagePosition (CSPI_OBJREF (obj),
127                                         &cx, &cy, ctype, cspi_ev ());
128
129   if (!cspi_check_ev ("getImagePosition"))
130     {
131       *x = 0;
132       *y = 0;
133     }
134   else
135     {
136       *x = cx;
137       *y = cy;
138     }
139 }
140
141 /**
142  * AccessibleImage_getImageExtents:
143  * @obj: a pointer to the #AccessibleImage implementor to query.
144  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
145  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
146  * @width: a pointer to a #long into which the image x extent will be returned.
147  * @height: a pointer to a #long into which the image y extent will be returned.
148  * @ctype: the desired coordinate system into which to return the results,
149  *         (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
150  *
151  * Get the bounding box of the image displayed in a
152  *         specified #AccessibleImage implementor.
153  **/
154 void
155 AccessibleImage_getImageExtents (AccessibleImage *obj,
156                                  long *x,
157                                  long *y,
158                                  long *width,
159                                  long *height,
160                                  AccessibleCoordType ctype)
161 {
162   Accessibility_BoundingBox bbox;
163
164   cspi_return_if_fail (obj != NULL);
165
166   bbox = Accessibility_Image_getImageExtents (CSPI_OBJREF (obj),
167                                               ctype,
168                                               cspi_ev ());
169
170   if (!cspi_check_ev ("getImageExtents"))
171     {
172       *x = *y = *width = *height = 0;
173     }
174   else
175     {
176       *x = bbox.x;
177       *y = bbox.y;
178       *width = bbox.width;
179       *height = bbox.height;
180     }
181 }