Swap height and width arguments to atk_image_get_image_size Swap height
[platform/upstream/atk.git] / atk / atkimage.c
1 /* ATK -  Accessibility Toolkit
2  * Copyright 2001 Sun Microsystems Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "atkimage.h"
21
22 GType
23 atk_image_get_type ()
24 {
25   static GType type = 0;
26
27   if (!type) {
28     static const GTypeInfo tinfo =
29     {
30       sizeof (AtkImageIface),
31       (GBaseInitFunc) NULL,
32       (GBaseFinalizeFunc) NULL,
33
34     };
35
36     type = g_type_register_static (G_TYPE_INTERFACE, "AtkImage", &tinfo, 0);
37   }
38
39   return type;
40 }
41
42 /**
43  * atk_image_get_image_description:
44  * @image: a #GObject instance that implements AtkImageIface
45  *
46  * Get a textual description of this image.
47  *
48  * Returns: a string representing the image description
49  **/
50 G_CONST_RETURN gchar*
51 atk_image_get_image_description (AtkImage *image)
52 {
53   AtkImageIface *iface;
54
55   g_return_val_if_fail (ATK_IS_IMAGE (image), NULL);
56
57   iface = ATK_IMAGE_GET_IFACE (image);
58
59   if (iface->get_image_description)
60     {
61       return (iface->get_image_description) (image);
62     }
63   else
64     {
65       return NULL;
66     }
67 }
68
69 /**
70  * atk_image_get_image_size:
71  * @image: a #GObject instance that implements AtkImageIface
72  * @width: filled with the image width
73  * @height: filled with the image height
74  *
75  * Get the wdith and height in pixels for the specified image.
76  * The values of @width and @height are returned as -1 if the
77  * values cannot be obtained.
78  **/
79 void
80 atk_image_get_image_size (AtkImage *image, 
81                           int      *width,
82                           int      *height)
83 {
84   AtkImageIface *iface;
85   gint local_width, local_height;
86   gint *real_width, *real_height;
87
88   g_return_if_fail (ATK_IS_IMAGE (image));
89
90   if (width)
91     real_width = width;
92   else
93     real_width = &local_width;
94   if (height)
95     real_height = height;
96   else
97     real_height = &local_height;
98   
99   iface = ATK_IMAGE_GET_IFACE (image);
100
101   if (iface->get_image_size)
102   {
103     iface->get_image_size (image, real_width, real_height);
104   }
105   else
106   {
107     *width = -1;
108     *height = -1;
109   }
110 }
111
112 /**
113  * atk_image_set_image_description:
114  * @image: a #GObject instance that implements AtkImageIface
115  * @description: a string description to set for @image
116  *
117  * Sets the textual description for this image.
118  *
119  * Returns: boolean TRUE, or FALSE if operation could
120  * not be completed.
121  **/
122 gboolean
123 atk_image_set_image_description (AtkImage        *image,
124                                  const gchar     *description)
125 {
126   AtkImageIface *iface;
127
128   g_return_val_if_fail (ATK_IS_IMAGE (image), FALSE);
129
130   iface = ATK_IMAGE_GET_IFACE (image);
131
132   if (iface->set_image_description)
133     {
134       return (iface->set_image_description) (image, description);
135     }
136   else
137     {
138       return FALSE;
139     }
140 }
141
142 /**
143  * atk_image_get_image_position:
144  * @image: a #GObject instance that implements AtkImageIface
145  * @x: address of #gint to put x coordinate position
146  * @y: address of #gint to put y coordinate position
147  * @coord_type: specifies whether the coordinates are relative to the screen
148  * or to the components top level window
149  * 
150  * Gets the position of the image in the form of a point specifying the
151  * images top-left corner.  The values of @x and @y are returned as -1
152  * if the values cannot be obtained.
153  **/
154 void     
155 atk_image_get_image_position (AtkImage *image,
156                         gint *x,
157                         gint *y,
158                         AtkCoordType coord_type)
159 {
160   AtkImageIface *iface;
161   gint local_x, local_y;
162   gint *real_x, *real_y;
163
164   g_return_if_fail (ATK_IS_IMAGE (image));
165
166   if (x)
167     real_x = x;
168   else
169     real_x = &local_x;
170   if (y)
171     real_y = y;
172   else
173     real_y = &local_y;
174   
175   iface = ATK_IMAGE_GET_IFACE (image);
176
177   g_return_if_fail (ATK_IS_IMAGE (image));
178
179   iface = ATK_IMAGE_GET_IFACE (image);
180
181   if (iface->get_image_position)
182   {
183     (iface->get_image_position) (image, real_x, real_y, coord_type);
184   }
185   else
186   {
187     *x = -1;
188     *y = -1;
189   }
190 }