]> Pileus Git - ~andy/gtk/blob - gtk/gtkimage.h
42b0475a0729f9c49902d8bc30daef925e35437c
[~andy/gtk] / gtk / gtkimage.h
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 #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
28 #error "Only <gtk/gtk.h> can be included directly."
29 #endif
30
31 #ifndef __GTK_IMAGE_H__
32 #define __GTK_IMAGE_H__
33
34
35 #include <gdk/gdk.h>
36 #include <gio/gio.h>
37 #include <gtk/gtkmisc.h>
38
39
40 G_BEGIN_DECLS
41
42 #define GTK_TYPE_IMAGE                  (gtk_image_get_type ())
43 #define GTK_IMAGE(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE, GtkImage))
44 #define GTK_IMAGE_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE, GtkImageClass))
45 #define GTK_IS_IMAGE(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE))
46 #define GTK_IS_IMAGE_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE))
47 #define GTK_IMAGE_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE, GtkImageClass))
48
49
50 typedef struct _GtkImage       GtkImage;
51 typedef struct _GtkImageClass  GtkImageClass;
52
53 typedef struct _GtkImagePixmapData  GtkImagePixmapData;
54 typedef struct _GtkImageImageData   GtkImageImageData;
55 typedef struct _GtkImagePixbufData  GtkImagePixbufData;
56 typedef struct _GtkImageStockData   GtkImageStockData;
57 typedef struct _GtkImageIconSetData GtkImageIconSetData;
58 typedef struct _GtkImageAnimationData GtkImageAnimationData;
59 typedef struct _GtkImageIconNameData  GtkImageIconNameData;
60 typedef struct _GtkImageGIconData     GtkImageGIconData;
61
62 struct _GtkImagePixmapData
63 {
64   GdkPixmap *pixmap;
65 };
66
67 struct _GtkImageImageData
68 {
69   GdkImage *image;
70 };
71
72 struct _GtkImagePixbufData
73 {
74   GdkPixbuf *pixbuf;
75 };
76
77 struct _GtkImageStockData
78 {
79   gchar *stock_id;
80 };
81
82 struct _GtkImageIconSetData
83 {
84   GtkIconSet *icon_set;
85 };
86
87 struct _GtkImageAnimationData
88 {
89   GdkPixbufAnimation *anim;
90   GdkPixbufAnimationIter *iter;
91   guint frame_timeout;
92 };
93
94 struct _GtkImageIconNameData
95 {
96   gchar *icon_name;
97   GdkPixbuf *pixbuf;
98   guint theme_change_id;
99 };
100
101 struct _GtkImageGIconData
102 {
103   GIcon *icon;
104   GdkPixbuf *pixbuf;
105   guint theme_change_id;
106 };
107
108 typedef enum
109 {
110   GTK_IMAGE_EMPTY,
111   GTK_IMAGE_PIXMAP,
112   GTK_IMAGE_IMAGE,
113   GTK_IMAGE_PIXBUF,
114   GTK_IMAGE_STOCK,
115   GTK_IMAGE_ICON_SET,
116   GTK_IMAGE_ANIMATION,
117   GTK_IMAGE_ICON_NAME,
118   GTK_IMAGE_GICON
119 } GtkImageType;
120
121 struct _GtkImage
122 {
123   GtkMisc misc;
124
125   GtkImageType GSEAL (storage_type);
126   
127   union
128   {
129     GtkImagePixmapData pixmap;
130     GtkImageImageData image;
131     GtkImagePixbufData pixbuf;
132     GtkImageStockData stock;
133     GtkImageIconSetData icon_set;
134     GtkImageAnimationData anim;
135     GtkImageIconNameData name;
136     GtkImageGIconData gicon;
137   } GSEAL (data);
138
139   /* Only used with GTK_IMAGE_PIXMAP, GTK_IMAGE_IMAGE */
140   GdkBitmap *GSEAL (mask);
141
142   /* Only used with GTK_IMAGE_STOCK, GTK_IMAGE_ICON_SET, GTK_IMAGE_ICON_NAME */
143   GtkIconSize GSEAL (icon_size);
144 };
145
146 struct _GtkImageClass
147 {
148   GtkMiscClass parent_class;
149
150   /* Padding for future expansion */
151   void (*_gtk_reserved1) (void);
152   void (*_gtk_reserved2) (void);
153   void (*_gtk_reserved3) (void);
154   void (*_gtk_reserved4) (void);
155 };
156
157 #ifdef G_OS_WIN32
158 /* Reserve old names for DLL ABI backward compatibility */
159 #define gtk_image_new_from_file gtk_image_new_from_file_utf8
160 #define gtk_image_set_from_file gtk_image_set_from_file_utf8
161 #endif
162
163 GType      gtk_image_get_type (void) G_GNUC_CONST;
164
165 GtkWidget* gtk_image_new                (void);
166 GtkWidget* gtk_image_new_from_pixmap    (GdkPixmap       *pixmap,
167                                          GdkBitmap       *mask);
168 GtkWidget* gtk_image_new_from_image     (GdkImage        *image,
169                                          GdkBitmap       *mask);
170 GtkWidget* gtk_image_new_from_file      (const gchar     *filename);
171 GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
172 GtkWidget* gtk_image_new_from_stock     (const gchar     *stock_id,
173                                          GtkIconSize      size);
174 GtkWidget* gtk_image_new_from_icon_set  (GtkIconSet      *icon_set,
175                                          GtkIconSize      size);
176 GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
177 GtkWidget* gtk_image_new_from_icon_name (const gchar     *icon_name,
178                                          GtkIconSize      size);
179 GtkWidget* gtk_image_new_from_gicon     (GIcon           *icon,
180                                          GtkIconSize      size);
181
182 void gtk_image_clear              (GtkImage        *image);
183 void gtk_image_set_from_pixmap    (GtkImage        *image,
184                                    GdkPixmap       *pixmap,
185                                    GdkBitmap       *mask);
186 void gtk_image_set_from_image     (GtkImage        *image,
187                                    GdkImage        *gdk_image,
188                                    GdkBitmap       *mask);
189 void gtk_image_set_from_file      (GtkImage        *image,
190                                    const gchar     *filename);
191 void gtk_image_set_from_pixbuf    (GtkImage        *image,
192                                    GdkPixbuf       *pixbuf);
193 void gtk_image_set_from_stock     (GtkImage        *image,
194                                    const gchar     *stock_id,
195                                    GtkIconSize      size);
196 void gtk_image_set_from_icon_set  (GtkImage        *image,
197                                    GtkIconSet      *icon_set,
198                                    GtkIconSize      size);
199 void gtk_image_set_from_animation (GtkImage           *image,
200                                    GdkPixbufAnimation *animation);
201 void gtk_image_set_from_icon_name (GtkImage        *image,
202                                    const gchar     *icon_name,
203                                    GtkIconSize      size);
204 void gtk_image_set_from_gicon     (GtkImage        *image,
205                                    GIcon           *icon,
206                                    GtkIconSize      size);
207 void gtk_image_set_pixel_size     (GtkImage        *image,
208                                    gint             pixel_size);
209
210 GtkImageType gtk_image_get_storage_type (GtkImage   *image);
211
212 void       gtk_image_get_pixmap   (GtkImage         *image,
213                                    GdkPixmap       **pixmap,
214                                    GdkBitmap       **mask);
215 void       gtk_image_get_image    (GtkImage         *image,
216                                    GdkImage        **gdk_image,
217                                    GdkBitmap       **mask);
218 GdkPixbuf* gtk_image_get_pixbuf   (GtkImage         *image);
219 void       gtk_image_get_stock    (GtkImage         *image,
220                                    gchar           **stock_id,
221                                    GtkIconSize      *size);
222 void       gtk_image_get_icon_set (GtkImage         *image,
223                                    GtkIconSet      **icon_set,
224                                    GtkIconSize      *size);
225 GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
226 void       gtk_image_get_icon_name (GtkImage              *image,
227                                     G_CONST_RETURN gchar **icon_name,
228                                     GtkIconSize           *size);
229 void       gtk_image_get_gicon     (GtkImage              *image,
230                                     GIcon                **gicon,
231                                     GtkIconSize           *size);
232 gint       gtk_image_get_pixel_size (GtkImage             *image);
233
234 #ifndef GTK_DISABLE_DEPRECATED
235 /* These three are deprecated */
236
237 void       gtk_image_set      (GtkImage   *image,
238                                GdkImage   *val,
239                                GdkBitmap  *mask);
240 void       gtk_image_get      (GtkImage   *image,
241                                GdkImage  **val,
242                                GdkBitmap **mask);
243 #endif /* GTK_DISABLE_DEPRECATED */
244
245 G_END_DECLS
246
247 #endif /* __GTK_IMAGE_H__ */