Updated AtkImage get_position to get_image_position
[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  * @height: filled with the image height
73  * @width: filled with the image width
74  *
75  * Get the height and width in pixels for the specified image.
76  * The values of @height and @width are returned as -1 if the
77  * values cannot be obtained.
78  **/
79 void
80 atk_image_get_image_size (AtkImage *image, int *height, int *width)
81 {
82   AtkImageIface *iface;
83
84   g_return_if_fail (ATK_IS_IMAGE (image));
85
86   iface = ATK_IMAGE_GET_IFACE (image);
87
88   if (iface->get_image_size)
89   {
90     iface->get_image_size (image, height, width);
91   }
92   else
93   {
94     *height = -1;
95     *width = -1;
96   }
97 }
98
99 /**
100  * atk_image_set_image_description:
101  * @image: a #GObject instance that implements AtkImageIface
102  * @description: a string description to set for @image
103  *
104  * Sets the textual description for this image.
105  *
106  * Returns: boolean TRUE, or FALSE if operation could
107  * not be completed.
108  **/
109 gboolean
110 atk_image_set_image_description (AtkImage        *image,
111                               const gchar     *description)
112 {
113   AtkImageIface *iface;
114
115   g_return_val_if_fail (ATK_IS_IMAGE (image), FALSE);
116
117   iface = ATK_IMAGE_GET_IFACE (image);
118
119   if (iface->set_image_description)
120     {
121       return (iface->set_image_description) (image, description);
122     }
123   else
124     {
125       return FALSE;
126     }
127 }
128
129 /**
130  * atk_image_get_image_position:
131  * @image: a #GObject instance that implements AtkImageIface
132  * @x: address of #gint to put x coordinate position
133  * @y: address of #gint to put y coordinate position
134  * @coord_type: specifies whether the coordinates are relative to the screen
135  * or to the components top level window
136  * 
137  * Gets the position of the image in the form of a point specifying the
138  * images top-left corner.  The values of @x and @y are returned as -1
139  * if the values cannot be obtained.
140  **/
141 void     
142 atk_image_get_image_position (AtkImage *image,
143                         gint *x,
144                         gint *y,
145                         AtkCoordType coord_type)
146 {
147   AtkImageIface *iface;
148
149   g_return_if_fail (ATK_IS_IMAGE (image));
150
151   iface = ATK_IMAGE_GET_IFACE (image);
152
153   if (iface->get_image_position)
154   {
155     (iface->get_image_position) (image, x, y, coord_type);
156   }
157   else
158   {
159     *x = -1;
160     *y = -1;
161   }
162 }
163
164
165
166
167
168