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