]> Pileus Git - ~andy/gtk/blob - gtk/gtkimage.h
add default icon
[~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 #ifndef __GTK_IMAGE_H__
28 #define __GTK_IMAGE_H__
29
30
31 #include <gdk/gdk.h>
32 #include <gtk/gtkmisc.h>
33
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif /* __cplusplus */
38
39 #define GTK_TYPE_IMAGE                  (gtk_image_get_type ())
40 #define GTK_IMAGE(obj)                  (GTK_CHECK_CAST ((obj), GTK_TYPE_IMAGE, GtkImage))
41 #define GTK_IMAGE_CLASS(klass)          (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE, GtkImageClass))
42 #define GTK_IS_IMAGE(obj)               (GTK_CHECK_TYPE ((obj), GTK_TYPE_IMAGE))
43 #define GTK_IS_IMAGE_CLASS(klass)       (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE))
44 #define GTK_IMAGE_GET_CLASS(obj)        (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_IMAGE, GtkImageClass))
45
46
47 typedef struct _GtkImage       GtkImage;
48 typedef struct _GtkImageClass  GtkImageClass;
49
50 typedef struct _GtkImagePixmapData  GtkImagePixmapData;
51 typedef struct _GtkImageImageData   GtkImageImageData;
52 typedef struct _GtkImagePixbufData  GtkImagePixbufData;
53 typedef struct _GtkImageStockData   GtkImageStockData;
54 typedef struct _GtkImageIconSetData GtkImageIconSetData;
55 typedef struct _GtkImageAnimationData GtkImageAnimationData;
56
57 struct _GtkImagePixmapData
58 {
59   GdkPixmap *pixmap;
60 };
61
62 struct _GtkImageImageData
63 {
64   GdkImage *image;
65 };
66
67 struct _GtkImagePixbufData
68 {
69   GdkPixbuf *pixbuf;
70 };
71
72 struct _GtkImageStockData
73 {
74   gchar *stock_id;
75 };
76
77 struct _GtkImageIconSetData
78 {
79   GtkIconSet *icon_set;
80 };
81
82 struct _GtkImageAnimationData
83 {
84   GdkPixbufAnimation *anim;
85   GdkPixbufAnimationIter *iter;
86   guint frame_timeout;
87 };
88
89 typedef enum
90 {
91   GTK_IMAGE_EMPTY,
92   GTK_IMAGE_PIXMAP,
93   GTK_IMAGE_IMAGE,
94   GTK_IMAGE_PIXBUF,
95   GTK_IMAGE_STOCK,
96   GTK_IMAGE_ICON_SET,
97   GTK_IMAGE_ANIMATION
98 } GtkImageType;
99
100 struct _GtkImage
101 {
102   GtkMisc misc;
103
104   GtkImageType storage_type;
105   
106   union
107   {
108     GtkImagePixmapData pixmap;
109     GtkImageImageData image;
110     GtkImagePixbufData pixbuf;
111     GtkImageStockData stock;
112     GtkImageIconSetData icon_set;
113     GtkImageAnimationData anim;
114   } data;
115
116   /* Only used with GTK_IMAGE_PIXMAP, GTK_IMAGE_IMAGE */
117   GdkBitmap *mask;
118
119   /* Only used with GTK_IMAGE_STOCK, GTK_IMAGE_ICON_SET */
120   GtkIconSize icon_size;
121 };
122
123 struct _GtkImageClass
124 {
125   GtkMiscClass parent_class;
126 };
127
128 GtkType    gtk_image_get_type (void) G_GNUC_CONST;
129
130 GtkWidget* gtk_image_new                (void);
131 GtkWidget* gtk_image_new_from_pixmap    (GdkPixmap       *pixmap,
132                                          GdkBitmap       *mask);
133 GtkWidget* gtk_image_new_from_image     (GdkImage        *image,
134                                          GdkBitmap       *mask);
135 GtkWidget* gtk_image_new_from_file      (const gchar     *filename);
136 GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
137 GtkWidget* gtk_image_new_from_stock     (const gchar     *stock_id,
138                                          GtkIconSize      size);
139 GtkWidget* gtk_image_new_from_icon_set  (GtkIconSet      *icon_set,
140                                          GtkIconSize      size);
141 GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
142
143 void gtk_image_set_from_pixmap    (GtkImage        *image,
144                                    GdkPixmap       *pixmap,
145                                    GdkBitmap       *mask);
146 void gtk_image_set_from_image     (GtkImage        *image,
147                                    GdkImage        *gdk_image,
148                                    GdkBitmap       *mask);
149 void gtk_image_set_from_file      (GtkImage        *image,
150                                    const gchar     *filename);
151 void gtk_image_set_from_pixbuf    (GtkImage        *image,
152                                    GdkPixbuf       *pixbuf);
153 void gtk_image_set_from_stock     (GtkImage        *image,
154                                    const gchar     *stock_id,
155                                    GtkIconSize      size);
156 void gtk_image_set_from_icon_set  (GtkImage        *image,
157                                    GtkIconSet      *icon_set,
158                                    GtkIconSize      size);
159 void gtk_image_set_from_animation (GtkImage           *image,
160                                    GdkPixbufAnimation *animation);
161
162 GtkImageType gtk_image_get_storage_type (GtkImage   *image);
163
164 void       gtk_image_get_pixmap   (GtkImage         *image,
165                                    GdkPixmap       **pixmap,
166                                    GdkBitmap       **mask);
167 void       gtk_image_get_image    (GtkImage         *image,
168                                    GdkImage        **gdk_image,
169                                    GdkBitmap       **mask);
170 GdkPixbuf* gtk_image_get_pixbuf   (GtkImage         *image);
171 void       gtk_image_get_stock    (GtkImage         *image,
172                                    gchar           **stock_id,
173                                    GtkIconSize      *size);
174 void       gtk_image_get_icon_set (GtkImage         *image,
175                                    GtkIconSet      **icon_set,
176                                    GtkIconSize      *size);
177 GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
178
179
180 #ifndef GTK_DISABLE_DEPRECATED
181 /* These three are deprecated */
182
183 void       gtk_image_set      (GtkImage   *image,
184                                GdkImage   *val,
185                                GdkBitmap  *mask);
186 void       gtk_image_get      (GtkImage   *image,
187                                GdkImage  **val,
188                                GdkBitmap **mask);
189 #endif /* GTK_DISABLE_DEPRECATED */
190
191 #ifdef __cplusplus
192 }
193 #endif /* __cplusplus */
194
195
196 #endif /* __GTK_IMAGE_H__ */