]> Pileus Git - ~andy/gtk/blob - gtk/gtkimage.h
GtkImage: move public members to private structure
[~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_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 _GtkImagePriv   GtkImagePriv;
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 /**
109  * GtkImageType:
110  * @GTK_IMAGE_EMPTY: there is no image displayed by the widget
111  * @GTK_IMAGE_PIXMAP: the widget contains a #GdkPixmap
112  * @GTK_IMAGE_IMAGE: the widget contains a #GdkImage
113  * @GTK_IMAGE_PIXBUF: the widget contains a #GdkPixbuf
114  * @GTK_IMAGE_STOCK: the widget contains a stock icon name (see
115  *  <xref linkend="gtk3-Stock-Items"/>)
116  * @GTK_IMAGE_ICON_SET: the widget contains a #GtkIconSet
117  * @GTK_IMAGE_ANIMATION: the widget contains a #GdkPixbufAnimation
118  * @GTK_IMAGE_ICON_NAME: the widget contains a named icon.
119  *  This image type was added in GTK+ 2.6
120  * @GTK_IMAGE_GICON: the widget contains a #GIcon.
121  *  This image type was added in GTK+ 2.14
122  *
123  * Describes the image data representation used by a #GtkImage. If you
124  * want to get the image from the widget, you can only get the
125  * currently-stored representation. e.g.  if the
126  * gtk_image_get_storage_type() returns #GTK_IMAGE_PIXBUF, then you can
127  * call gtk_image_get_pixbuf() but not gtk_image_get_stock().  For empty
128  * images, you can request any storage type (call any of the "get"
129  * functions), but they will all return %NULL values.
130  */
131 typedef enum
132 {
133   GTK_IMAGE_EMPTY,
134   GTK_IMAGE_PIXMAP,
135   GTK_IMAGE_IMAGE,
136   GTK_IMAGE_PIXBUF,
137   GTK_IMAGE_STOCK,
138   GTK_IMAGE_ICON_SET,
139   GTK_IMAGE_ANIMATION,
140   GTK_IMAGE_ICON_NAME,
141   GTK_IMAGE_GICON
142 } GtkImageType;
143
144 /**
145  * GtkImage:
146  *
147  * This struct contain private data only and should be accessed by the functions
148  * below.
149  */
150 struct _GtkImage
151 {
152   GtkMisc misc;
153
154   /* <private> */
155   GtkImagePriv *priv;
156 };
157
158 struct _GtkImageClass
159 {
160   GtkMiscClass parent_class;
161
162   /* Padding for future expansion */
163   void (*_gtk_reserved1) (void);
164   void (*_gtk_reserved2) (void);
165   void (*_gtk_reserved3) (void);
166   void (*_gtk_reserved4) (void);
167 };
168
169 #ifdef G_OS_WIN32
170 /* Reserve old names for DLL ABI backward compatibility */
171 #define gtk_image_new_from_file gtk_image_new_from_file_utf8
172 #define gtk_image_set_from_file gtk_image_set_from_file_utf8
173 #endif
174
175 GType      gtk_image_get_type (void) G_GNUC_CONST;
176
177 GtkWidget* gtk_image_new                (void);
178 GtkWidget* gtk_image_new_from_pixmap    (GdkPixmap       *pixmap,
179                                          GdkBitmap       *mask);
180 GtkWidget* gtk_image_new_from_image     (GdkImage        *image,
181                                          GdkBitmap       *mask);
182 GtkWidget* gtk_image_new_from_file      (const gchar     *filename);
183 GtkWidget* gtk_image_new_from_pixbuf    (GdkPixbuf       *pixbuf);
184 GtkWidget* gtk_image_new_from_stock     (const gchar     *stock_id,
185                                          GtkIconSize      size);
186 GtkWidget* gtk_image_new_from_icon_set  (GtkIconSet      *icon_set,
187                                          GtkIconSize      size);
188 GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
189 GtkWidget* gtk_image_new_from_icon_name (const gchar     *icon_name,
190                                          GtkIconSize      size);
191 GtkWidget* gtk_image_new_from_gicon     (GIcon           *icon,
192                                          GtkIconSize      size);
193
194 void gtk_image_clear              (GtkImage        *image);
195 void gtk_image_set_from_pixmap    (GtkImage        *image,
196                                    GdkPixmap       *pixmap,
197                                    GdkBitmap       *mask);
198 void gtk_image_set_from_image     (GtkImage        *image,
199                                    GdkImage        *gdk_image,
200                                    GdkBitmap       *mask);
201 void gtk_image_set_from_file      (GtkImage        *image,
202                                    const gchar     *filename);
203 void gtk_image_set_from_pixbuf    (GtkImage        *image,
204                                    GdkPixbuf       *pixbuf);
205 void gtk_image_set_from_stock     (GtkImage        *image,
206                                    const gchar     *stock_id,
207                                    GtkIconSize      size);
208 void gtk_image_set_from_icon_set  (GtkImage        *image,
209                                    GtkIconSet      *icon_set,
210                                    GtkIconSize      size);
211 void gtk_image_set_from_animation (GtkImage           *image,
212                                    GdkPixbufAnimation *animation);
213 void gtk_image_set_from_icon_name (GtkImage        *image,
214                                    const gchar     *icon_name,
215                                    GtkIconSize      size);
216 void gtk_image_set_from_gicon     (GtkImage        *image,
217                                    GIcon           *icon,
218                                    GtkIconSize      size);
219 void gtk_image_set_pixel_size     (GtkImage        *image,
220                                    gint             pixel_size);
221
222 GtkImageType gtk_image_get_storage_type (GtkImage   *image);
223
224 void       gtk_image_get_pixmap   (GtkImage         *image,
225                                    GdkPixmap       **pixmap,
226                                    GdkBitmap       **mask);
227 void       gtk_image_get_image    (GtkImage         *image,
228                                    GdkImage        **gdk_image,
229                                    GdkBitmap       **mask);
230 GdkPixbuf* gtk_image_get_pixbuf   (GtkImage         *image);
231 void       gtk_image_get_stock    (GtkImage         *image,
232                                    gchar           **stock_id,
233                                    GtkIconSize      *size);
234 void       gtk_image_get_icon_set (GtkImage         *image,
235                                    GtkIconSet      **icon_set,
236                                    GtkIconSize      *size);
237 GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
238 void       gtk_image_get_icon_name (GtkImage              *image,
239                                     G_CONST_RETURN gchar **icon_name,
240                                     GtkIconSize           *size);
241 void       gtk_image_get_gicon     (GtkImage              *image,
242                                     GIcon                **gicon,
243                                     GtkIconSize           *size);
244 gint       gtk_image_get_pixel_size (GtkImage             *image);
245
246 G_END_DECLS
247
248 #endif /* __GTK_IMAGE_H__ */