1/* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
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/*
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
25 */
26
27#ifndef __GTK_IMAGE_H__
28#define __GTK_IMAGE_H__
29
30
31#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
32#error "Only <gtk/gtk.h> can be included directly."
33#endif
34
35#include <gio/gio.h>
36#include <gtk/gtkmisc.h>
37
38
39G_BEGIN_DECLS
40
41#define GTK_TYPE_IMAGE (gtk_image_get_type ())
42#define GTK_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE, GtkImage))
43#define GTK_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE, GtkImageClass))
44#define GTK_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE))
45#define GTK_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE))
46#define GTK_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE, GtkImageClass))
47
48
49typedef struct _GtkImage GtkImage;
50typedef struct _GtkImageClass GtkImageClass;
51
52typedef struct _GtkImagePixmapData GtkImagePixmapData;
53typedef struct _GtkImageImageData GtkImageImageData;
54typedef struct _GtkImagePixbufData GtkImagePixbufData;
55typedef struct _GtkImageStockData GtkImageStockData;
56typedef struct _GtkImageIconSetData GtkImageIconSetData;
57typedef struct _GtkImageAnimationData GtkImageAnimationData;
58typedef struct _GtkImageIconNameData GtkImageIconNameData;
59typedef struct _GtkImageGIconData GtkImageGIconData;
60
61struct _GtkImagePixmapData
62{
63 GdkPixmap *pixmap;
64};
65
66struct _GtkImageImageData
67{
68 GdkImage *image;
69};
70
71struct _GtkImagePixbufData
72{
73 GdkPixbuf *pixbuf;
74};
75
76struct _GtkImageStockData
77{
78 gchar *stock_id;
79};
80
81struct _GtkImageIconSetData
82{
83 GtkIconSet *icon_set;
84};
85
86struct _GtkImageAnimationData
87{
88 GdkPixbufAnimation *anim;
89 GdkPixbufAnimationIter *iter;
90 guint frame_timeout;
91};
92
93struct _GtkImageIconNameData
94{
95 gchar *icon_name;
96 GdkPixbuf *pixbuf;
97 guint theme_change_id;
98};
99
100struct _GtkImageGIconData
101{
102 GIcon *icon;
103 GdkPixbuf *pixbuf;
104 guint theme_change_id;
105};
106
107/**
108 * GtkImageType:
109 * @GTK_IMAGE_EMPTY: there is no image displayed by the widget
110 * @GTK_IMAGE_PIXMAP: the widget contains a #GdkPixmap
111 * @GTK_IMAGE_IMAGE: the widget contains a #GdkImage
112 * @GTK_IMAGE_PIXBUF: the widget contains a #GdkPixbuf
113 * @GTK_IMAGE_STOCK: the widget contains a stock icon name (see <xref linkend="gtk-Stock-Items"/>)
114 * @GTK_IMAGE_ICON_SET: the widget contains a #GtkIconSet
115 * @GTK_IMAGE_ANIMATION: the widget contains a #GdkPixbufAnimation
116 * @GTK_IMAGE_ICON_NAME: the widget contains a named icon.
117 * This image type was added in GTK+ 2.6
118 * @GTK_IMAGE_GICON: the widget contains a #GIcon.
119 * This image type was added in GTK+ 2.14
120 *
121 * Describes the image data representation used by a #GtkImage. If you
122 * want to get the image from the widget, you can only get the
123 * currently-stored representation. e.g. if the
124 * gtk_image_get_storage_type() returns #GTK_IMAGE_PIXBUF, then you can
125 * call gtk_image_get_pixbuf() but not gtk_image_get_stock(). For empty
126 * images, you can request any storage type (call any of the "get"
127 * functions), but they will all return %NULL values.
128 */
129typedef enum
130{
131 GTK_IMAGE_EMPTY,
132 GTK_IMAGE_PIXMAP,
133 GTK_IMAGE_IMAGE,
134 GTK_IMAGE_PIXBUF,
135 GTK_IMAGE_STOCK,
136 GTK_IMAGE_ICON_SET,
137 GTK_IMAGE_ANIMATION,
138 GTK_IMAGE_ICON_NAME,
139 GTK_IMAGE_GICON
140} GtkImageType;
141
142/**
143 * GtkImage:
144 *
145 * This struct contain private data only and should be accessed by the functions
146 * below.
147 */
148struct _GtkImage
149{
150 GtkMisc misc;
151
152 GtkImageType GSEAL (storage_type);
153
154 union
155 {
156 GtkImagePixmapData pixmap;
157 GtkImageImageData image;
158 GtkImagePixbufData pixbuf;
159 GtkImageStockData stock;
160 GtkImageIconSetData icon_set;
161 GtkImageAnimationData anim;
162 GtkImageIconNameData name;
163 GtkImageGIconData gicon;
164 } GSEAL (data);
165
166 /* Only used with GTK_IMAGE_PIXMAP, GTK_IMAGE_IMAGE */
167 GdkBitmap *GSEAL (mask);
168
169 /* Only used with GTK_IMAGE_STOCK, GTK_IMAGE_ICON_SET, GTK_IMAGE_ICON_NAME */
170 GtkIconSize GSEAL (icon_size);
171};
172
173struct _GtkImageClass
174{
175 GtkMiscClass parent_class;
176
177 /* Padding for future expansion */
178 void (*_gtk_reserved1) (void);
179 void (*_gtk_reserved2) (void);
180 void (*_gtk_reserved3) (void);
181 void (*_gtk_reserved4) (void);
182};
183
184#ifdef G_OS_WIN32
185/* Reserve old names for DLL ABI backward compatibility */
186#define gtk_image_new_from_file gtk_image_new_from_file_utf8
187#define gtk_image_set_from_file gtk_image_set_from_file_utf8
188#endif
189
190GType gtk_image_get_type (void) G_GNUC_CONST;
191
192GtkWidget* gtk_image_new (void);
193GtkWidget* gtk_image_new_from_pixmap (GdkPixmap *pixmap,
194 GdkBitmap *mask);
195GtkWidget* gtk_image_new_from_image (GdkImage *image,
196 GdkBitmap *mask);
197GtkWidget* gtk_image_new_from_file (const gchar *filename);
198GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf);
199GtkWidget* gtk_image_new_from_stock (const gchar *stock_id,
200 GtkIconSize size);
201GtkWidget* gtk_image_new_from_icon_set (GtkIconSet *icon_set,
202 GtkIconSize size);
203GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
204GtkWidget* gtk_image_new_from_icon_name (const gchar *icon_name,
205 GtkIconSize size);
206GtkWidget* gtk_image_new_from_gicon (GIcon *icon,
207 GtkIconSize size);
208
209void gtk_image_clear (GtkImage *image);
210void gtk_image_set_from_pixmap (GtkImage *image,
211 GdkPixmap *pixmap,
212 GdkBitmap *mask);
213void gtk_image_set_from_image (GtkImage *image,
214 GdkImage *gdk_image,
215 GdkBitmap *mask);
216void gtk_image_set_from_file (GtkImage *image,
217 const gchar *filename);
218void gtk_image_set_from_pixbuf (GtkImage *image,
219 GdkPixbuf *pixbuf);
220void gtk_image_set_from_stock (GtkImage *image,
221 const gchar *stock_id,
222 GtkIconSize size);
223void gtk_image_set_from_icon_set (GtkImage *image,
224 GtkIconSet *icon_set,
225 GtkIconSize size);
226void gtk_image_set_from_animation (GtkImage *image,
227 GdkPixbufAnimation *animation);
228void gtk_image_set_from_icon_name (GtkImage *image,
229 const gchar *icon_name,
230 GtkIconSize size);
231void gtk_image_set_from_gicon (GtkImage *image,
232 GIcon *icon,
233 GtkIconSize size);
234void gtk_image_set_pixel_size (GtkImage *image,
235 gint pixel_size);
236
237GtkImageType gtk_image_get_storage_type (GtkImage *image);
238
239void gtk_image_get_pixmap (GtkImage *image,
240 GdkPixmap **pixmap,
241 GdkBitmap **mask);
242void gtk_image_get_image (GtkImage *image,
243 GdkImage **gdk_image,
244 GdkBitmap **mask);
245GdkPixbuf* gtk_image_get_pixbuf (GtkImage *image);
246void gtk_image_get_stock (GtkImage *image,
247 gchar **stock_id,
248 GtkIconSize *size);
249void gtk_image_get_icon_set (GtkImage *image,
250 GtkIconSet **icon_set,
251 GtkIconSize *size);
252GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
253void gtk_image_get_icon_name (GtkImage *image,
254 const gchar **icon_name,
255 GtkIconSize *size);
256void gtk_image_get_gicon (GtkImage *image,
257 GIcon **gicon,
258 GtkIconSize *size);
259gint gtk_image_get_pixel_size (GtkImage *image);
260
261#ifndef GTK_DISABLE_DEPRECATED
262/* These three are deprecated */
263
264void gtk_image_set (GtkImage *image,
265 GdkImage *val,
266 GdkBitmap *mask);
267void gtk_image_get (GtkImage *image,
268 GdkImage **val,
269 GdkBitmap **mask);
270#endif /* GTK_DISABLE_DEPRECATED */
271
272G_END_DECLS
273
274#endif /* __GTK_IMAGE_H__ */
275