Add AT-SPI mapping for ATK_RELATION_NODE_PARENT_OF
[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, 2002 Sun Microsystems Inc.,
6  * Copyright 2001, 2002 Ximian, Inc.
7  *
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.
12  *
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.
17  *
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.
22  */
23
24 #include <cspi/spi-private.h>
25
26 /**
27  * AccessibleImage_ref:
28  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
29  *
30  * Increment the reference count for an #AccessibleImage object.
31  **/
32 void
33 AccessibleImage_ref (AccessibleImage *obj)
34 {
35   cspi_object_ref (obj);
36 }
37
38 /**
39  * AccessibleImage_unref:
40  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
41  *
42  * Decrement the reference count for an #AccessibleImage object.
43  **/
44 void
45 AccessibleImage_unref (AccessibleImage *obj)
46 {
47   cspi_object_unref (obj);
48 }
49
50 /**
51  * AccessibleImage_getImageDescription:
52  * @obj: a pointer to the #AccessibleImage implementor on which to operate.
53  *
54  * Get the description of the image displayed in an #AccessibleImage object.
55  *
56  * Returns: a UTF-8 string describing the image.
57  **/
58 char *
59 AccessibleImage_getImageDescription (AccessibleImage *obj)
60 {
61   char *retval;
62
63   cspi_return_val_if_fail (obj != NULL, NULL);
64
65   cspi_dbus_get_property (obj, spi_interface_image, "description", NULL, "s", &retval);
66
67   cspi_return_val_if_ev ("getImageDescription", NULL);
68
69   return retval;
70 }
71
72 /**
73  * AccessibleImage_getImageSize:
74  * @obj: a pointer to the #AccessibleImage to query.
75  * @width: a pointer to a #long into which the x extents (width) will be returned.
76  * @height: a pointer to a #long into which the y extents (height) will be returned.
77  *
78  * Get the size of the image displayed in a specified #AccessibleImage object.
79  **/
80 void
81 AccessibleImage_getImageSize (AccessibleImage *obj,
82                               long int *width,
83                               long int *height)
84 {
85   dbus_int32_t w, h;
86
87   cspi_return_if_fail (obj != NULL);
88
89   cspi_dbus_call (obj, spi_interface_image, "getImageSize", NULL, "=>ii", &w, &h);
90
91   if (!cspi_check_ev ("getImageSize"))
92     {
93       *width = 0;
94       *height = 0;
95     }
96   else
97     {
98       *width = w;
99       *height = h;
100     }
101 }
102
103 /**
104  * AccessibleImage_getImagePosition:
105  * @obj: a pointer to the #AccessibleImage implementor to query.
106  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
107  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
108  * @ctype: the desired coordinate system into which to return the results,
109  *         (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
110  *
111  * Get the minimum x and y coordinates of the image displayed in a
112  *         specified #AccessibleImage implementor.
113  **/
114 void
115 AccessibleImage_getImagePosition (AccessibleImage *obj,
116                                   long *x,
117                                   long *y,
118                                   AccessibleCoordType ctype)
119 {
120   dbus_int32_t dx, dy;
121
122   cspi_return_if_fail (obj != NULL);
123
124   cspi_dbus_call (obj, spi_interface_image, "getImagePosition", NULL, "=>ii", &dx, &dy);
125
126   if (!cspi_check_ev ("getImagePosition"))
127     {
128       *x = 0;
129       *y = 0;
130     }
131   else
132     {
133       *x = dx;
134       *y = dy;
135     }
136 }
137
138 /**
139  * AccessibleImage_getImageExtents:
140  * @obj: a pointer to the #AccessibleImage implementor to query.
141  * @x: a pointer to a #long into which the minimum x coordinate will be returned.
142  * @y: a pointer to a #long into which the minimum y coordinate will be returned.
143  * @width: a pointer to a #long into which the image x extent will be returned.
144  * @height: a pointer to a #long into which the image y extent will be returned.
145  * @ctype: the desired coordinate system into which to return the results,
146  *         (e.g. SPI_COORD_TYPE_WINDOW, SPI_COORD_TYPE_SCREEN).
147  *
148  * Get the bounding box of the image displayed in a
149  *         specified #AccessibleImage implementor.
150  **/
151 void
152 AccessibleImage_getImageExtents (AccessibleImage *obj,
153                                  long *x,
154                                  long *y,
155                                  long *width,
156                                  long *height,
157                                  AccessibleCoordType ctype)
158 {
159   Accessibility_BoundingBox bbox;
160
161   cspi_return_if_fail (obj != NULL);
162
163   cspi_dbus_call (obj, spi_interface_image, "getImageExtents", NULL, "=>(iiii)", &bbox);
164
165   if (!cspi_check_ev ("getImageExtents"))
166     {
167       *x = *y = *width = *height = 0;
168     }
169   else
170     {
171       *x = bbox.x;
172       *y = bbox.y;
173       *width = bbox.width;
174       *height = bbox.height;
175     }
176 }
177
178 /**
179  * AccessibleImage_getImageLocale:
180  * @obj: The #AccessibleImage being queried.
181  *
182  * Get the locale associated with an image and its textual representation.
183  *
184  * Returns: A POSIX LC_MESSAGES-style Locale value for image description and text.
185  **/
186 char *
187 AccessibleImage_getImageLocale  (AccessibleImage *obj)
188 {
189     char *retval = "C";
190
191     cspi_return_val_if_fail (obj != NULL, "C");
192
193   cspi_dbus_get_property (obj, spi_interface_image, "imageLocale", NULL, "=>s", &retval);
194
195     cspi_return_val_if_ev ("getImageLocale", NULL);
196
197     return retval;
198 }
199