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