Updated so that functions that take screen coords as
[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 *obj)
52 {
53   AtkImageIface *iface;
54
55   g_return_val_if_fail (obj != NULL, NULL);
56   g_return_val_if_fail (ATK_IS_IMAGE (obj), NULL);
57
58   iface = ATK_IMAGE_GET_IFACE (obj);
59
60   if (iface->get_image_description)
61     {
62       return (iface->get_image_description) (obj);
63     }
64   else
65     {
66       return NULL;
67     }
68 }
69
70 /**
71  * atk_image_get_image_size:
72  * @image: a #GObject instance that implements AtkImageIface
73  * @height: filled with the image height
74  * @width: filled with the image width
75  *
76  * Get the height, in pixels/screen coords, of this image.
77  *
78  * Returns: an integer representing the image height in pixel coords
79  **/
80 void
81 atk_image_get_image_size (AtkImage *obj, int *height, int *width)
82 {
83   AtkImageIface *iface;
84
85   g_return_if_fail (obj != NULL);
86   g_return_if_fail (ATK_IS_IMAGE (obj));
87
88   iface = ATK_IMAGE_GET_IFACE (obj);
89
90   if (iface->get_image_size)
91     {
92       return (iface->get_image_size) (obj, height, width);
93     }
94   else
95     {
96       return;
97     }
98 }
99
100 /**
101  * atk_image_set_image_description:
102  * @image: a #GObject instance that implements AtkImageIface
103  * @description: a string description to set for @image
104  *
105  * Sets the textual description for this image.
106  *
107  * Returns: boolean TRUE, or FALSE if operation could
108  * not be completed.
109  **/
110 gboolean
111 atk_image_set_image_description (AtkImage        *obj,
112                               const gchar     *description)
113 {
114   AtkImageIface *iface;
115
116   g_return_val_if_fail (obj != NULL, FALSE);
117   g_return_val_if_fail (ATK_IS_IMAGE (obj), FALSE);
118
119   iface = ATK_IMAGE_GET_IFACE (obj);
120
121   if (iface->set_image_description)
122     {
123       return (iface->set_image_description) (obj, description);
124     }
125   else
126     {
127       return FALSE;
128     }
129 }
130
131 /**
132  * atk_image_get_position:
133  * @image: a #GObject instance that implements AtkImageIface
134  * @x: address of #gint to put x coordinate position
135  * @y: address of #gint to put y coordinate position
136  * @coord_type: specifies whether the coordinates are relative to the screen
137  * or to the components top level window
138  * 
139  * Gets the position of the image in the form of a point specifying the
140  * images top-left corner
141  **/
142 void     
143 atk_image_get_position (AtkImage *image,
144                         gint *x,
145                         gint *y,
146                         AtkCoordType coord_type)
147 {
148   AtkImageIface *iface;
149
150   g_return_if_fail (image != NULL);
151   g_return_if_fail (ATK_IS_IMAGE (image));
152
153   iface = ATK_IMAGE_GET_IFACE (image);
154
155   if (iface->get_position)
156     (iface->get_position) (image, x, y, coord_type);
157 }
158
159
160
161
162
163