atktext: Fixing some typos on atk_text_get_text_at_offset deprecation
[atk.git] / atk / atkimage.c
blob00a18199d25da768ce1bc249b6fbc84504a10410
1 /* ATK - Accessibility Toolkit
2 * Copyright 2001 Sun Microsystems Inc.
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.
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.
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.
20 #include "atkimage.h"
22 /**
23 * SECTION:atkimage
24 * @Short_description: The ATK Interface implemented by components
25 * which expose image or pixmap content on-screen.
26 * @Title:AtkImage
28 * #AtkImage should be implemented by #AtkObject subtypes on behalf of
29 * components which display image/pixmap information onscreen, and
30 * which provide information (other than just widget borders, etc.)
31 * via that image content. For instance, icons, buttons with icons,
32 * toolbar elements, and image viewing panes typically should
33 * implement #AtkImage.
35 * #AtkImage primarily provides two types of information: coordinate
36 * information (useful for screen review mode of screenreaders, and
37 * for use by onscreen magnifiers), and descriptive information. The
38 * descriptive information is provided for alternative, text-only
39 * presentation of the most significant information present in the
40 * image.
43 GType
44 atk_image_get_type (void)
46 static GType type = 0;
48 if (!type) {
49 static const GTypeInfo tinfo =
51 sizeof (AtkImageIface),
52 (GBaseInitFunc) NULL,
53 (GBaseFinalizeFunc) NULL
56 type = g_type_register_static (G_TYPE_INTERFACE, "AtkImage", &tinfo, 0);
59 return type;
62 /**
63 * atk_image_get_image_description:
64 * @image: a #GObject instance that implements AtkImageIface
66 * Get a textual description of this image.
68 * Returns: a string representing the image description
69 **/
70 const gchar*
71 atk_image_get_image_description (AtkImage *image)
73 AtkImageIface *iface;
75 g_return_val_if_fail (ATK_IS_IMAGE (image), NULL);
77 iface = ATK_IMAGE_GET_IFACE (image);
79 if (iface->get_image_description)
81 return (iface->get_image_description) (image);
83 else
85 return NULL;
89 /**
90 * atk_image_get_image_size:
91 * @image: a #GObject instance that implements AtkImageIface
92 * @width: filled with the image width, or -1 if the value cannot be obtained.
93 * @height: filled with the image height, or -1 if the value cannot be obtained.
95 * Get the width and height in pixels for the specified image.
96 * The values of @width and @height are returned as -1 if the
97 * values cannot be obtained (for instance, if the object is not onscreen).
98 **/
99 void
100 atk_image_get_image_size (AtkImage *image,
101 int *width,
102 int *height)
104 AtkImageIface *iface;
105 gint local_width, local_height;
106 gint *real_width, *real_height;
108 g_return_if_fail (ATK_IS_IMAGE (image));
110 if (width)
111 real_width = width;
112 else
113 real_width = &local_width;
114 if (height)
115 real_height = height;
116 else
117 real_height = &local_height;
119 iface = ATK_IMAGE_GET_IFACE (image);
121 if (iface->get_image_size)
123 iface->get_image_size (image, real_width, real_height);
125 else
127 *real_width = -1;
128 *real_height = -1;
133 * atk_image_set_image_description:
134 * @image: a #GObject instance that implements AtkImageIface
135 * @description: a string description to set for @image
137 * Sets the textual description for this image.
139 * Returns: boolean TRUE, or FALSE if operation could
140 * not be completed.
142 gboolean
143 atk_image_set_image_description (AtkImage *image,
144 const gchar *description)
146 AtkImageIface *iface;
148 g_return_val_if_fail (ATK_IS_IMAGE (image), FALSE);
150 iface = ATK_IMAGE_GET_IFACE (image);
152 if (iface->set_image_description)
154 return (iface->set_image_description) (image, description);
156 else
158 return FALSE;
163 * atk_image_get_image_position:
164 * @image: a #GObject instance that implements AtkImageIface
165 * @x: address of #gint to put x coordinate position; otherwise, -1 if value cannot be obtained.
166 * @y: address of #gint to put y coordinate position; otherwise, -1 if value cannot be obtained.
167 * @coord_type: specifies whether the coordinates are relative to the screen
168 * or to the components top level window
170 * Gets the position of the image in the form of a point specifying the
171 * images top-left corner.
173 void
174 atk_image_get_image_position (AtkImage *image,
175 gint *x,
176 gint *y,
177 AtkCoordType coord_type)
179 AtkImageIface *iface;
180 gint local_x, local_y;
181 gint *real_x, *real_y;
183 g_return_if_fail (ATK_IS_IMAGE (image));
185 if (x)
186 real_x = x;
187 else
188 real_x = &local_x;
189 if (y)
190 real_y = y;
191 else
192 real_y = &local_y;
194 iface = ATK_IMAGE_GET_IFACE (image);
196 if (iface->get_image_position)
198 (iface->get_image_position) (image, real_x, real_y, coord_type);
200 else
202 *real_x = -1;
203 *real_y = -1;
208 * atk_image_get_image_locale:
209 * @image: An #AtkImage
211 * Since ATK 1.12
213 * Returns: a string corresponding to the POSIX LC_MESSAGES locale
214 * used by the image description, or NULL if the image does not
215 * specify a locale.
218 const gchar*
219 atk_image_get_image_locale (AtkImage *image)
222 AtkImageIface *iface;
224 g_return_val_if_fail (ATK_IS_IMAGE (image), NULL);
226 iface = ATK_IMAGE_GET_IFACE (image);
228 if (iface->get_image_locale)
230 return (iface->get_image_locale) (image);
232 else
234 return NULL;