You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

275 lines
9.4 KiB

  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. * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
  21. * file for a list of people on the GTK+ Team. See the ChangeLog
  22. * files for a list of changes. These files are distributed with
  23. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
  24. */
  25. #if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
  26. #error "Only <gtk/gtk.h> can be included directly."
  27. #endif
  28. #ifndef __GTK_IMAGE_H__
  29. #define __GTK_IMAGE_H__
  30. #include <gio/gio.h>
  31. #include <gtk/gtkmisc.h>
  32. G_BEGIN_DECLS
  33. #define GTK_TYPE_IMAGE (gtk_image_get_type ())
  34. #define GTK_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IMAGE, GtkImage))
  35. #define GTK_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMAGE, GtkImageClass))
  36. #define GTK_IS_IMAGE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_IMAGE))
  37. #define GTK_IS_IMAGE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMAGE))
  38. #define GTK_IMAGE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_IMAGE, GtkImageClass))
  39. typedef struct _GtkImage GtkImage;
  40. typedef struct _GtkImageClass GtkImageClass;
  41. typedef struct _GtkImagePixmapData GtkImagePixmapData;
  42. typedef struct _GtkImageImageData GtkImageImageData;
  43. typedef struct _GtkImagePixbufData GtkImagePixbufData;
  44. typedef struct _GtkImageStockData GtkImageStockData;
  45. typedef struct _GtkImageIconSetData GtkImageIconSetData;
  46. typedef struct _GtkImageAnimationData GtkImageAnimationData;
  47. typedef struct _GtkImageIconNameData GtkImageIconNameData;
  48. typedef struct _GtkImageGIconData GtkImageGIconData;
  49. struct _GtkImagePixmapData
  50. {
  51. GdkPixmap *pixmap;
  52. };
  53. struct _GtkImageImageData
  54. {
  55. GdkImage *image;
  56. };
  57. struct _GtkImagePixbufData
  58. {
  59. GdkPixbuf *pixbuf;
  60. };
  61. struct _GtkImageStockData
  62. {
  63. gchar *stock_id;
  64. };
  65. struct _GtkImageIconSetData
  66. {
  67. GtkIconSet *icon_set;
  68. };
  69. struct _GtkImageAnimationData
  70. {
  71. GdkPixbufAnimation *anim;
  72. GdkPixbufAnimationIter *iter;
  73. guint frame_timeout;
  74. };
  75. struct _GtkImageIconNameData
  76. {
  77. gchar *icon_name;
  78. GdkPixbuf *pixbuf;
  79. guint theme_change_id;
  80. };
  81. struct _GtkImageGIconData
  82. {
  83. GIcon *icon;
  84. GdkPixbuf *pixbuf;
  85. guint theme_change_id;
  86. };
  87. /**
  88. * GtkImageType:
  89. * @GTK_IMAGE_EMPTY: there is no image displayed by the widget
  90. * @GTK_IMAGE_PIXMAP: the widget contains a #GdkPixmap
  91. * @GTK_IMAGE_IMAGE: the widget contains a #GdkImage
  92. * @GTK_IMAGE_PIXBUF: the widget contains a #GdkPixbuf
  93. * @GTK_IMAGE_STOCK: the widget contains a stock icon name (see <xref linkend="gtk-Stock-Items"/>)
  94. * @GTK_IMAGE_ICON_SET: the widget contains a #GtkIconSet
  95. * @GTK_IMAGE_ANIMATION: the widget contains a #GdkPixbufAnimation
  96. * @GTK_IMAGE_ICON_NAME: the widget contains a named icon.
  97. * This image type was added in GTK+ 2.6
  98. * @GTK_IMAGE_GICON: the widget contains a #GIcon.
  99. * This image type was added in GTK+ 2.14
  100. *
  101. * Describes the image data representation used by a #GtkImage. If you
  102. * want to get the image from the widget, you can only get the
  103. * currently-stored representation. e.g. if the
  104. * gtk_image_get_storage_type() returns #GTK_IMAGE_PIXBUF, then you can
  105. * call gtk_image_get_pixbuf() but not gtk_image_get_stock(). For empty
  106. * images, you can request any storage type (call any of the "get"
  107. * functions), but they will all return %NULL values.
  108. */
  109. typedef enum
  110. {
  111. GTK_IMAGE_EMPTY,
  112. GTK_IMAGE_PIXMAP,
  113. GTK_IMAGE_IMAGE,
  114. GTK_IMAGE_PIXBUF,
  115. GTK_IMAGE_STOCK,
  116. GTK_IMAGE_ICON_SET,
  117. GTK_IMAGE_ANIMATION,
  118. GTK_IMAGE_ICON_NAME,
  119. GTK_IMAGE_GICON
  120. } GtkImageType;
  121. /**
  122. * GtkImage:
  123. *
  124. * This struct contain private data only and should be accessed by the functions
  125. * below.
  126. */
  127. struct _GtkImage
  128. {
  129. GtkMisc misc;
  130. GtkImageType GSEAL (storage_type);
  131. union
  132. {
  133. GtkImagePixmapData pixmap;
  134. GtkImageImageData image;
  135. GtkImagePixbufData pixbuf;
  136. GtkImageStockData stock;
  137. GtkImageIconSetData icon_set;
  138. GtkImageAnimationData anim;
  139. GtkImageIconNameData name;
  140. GtkImageGIconData gicon;
  141. } GSEAL (data);
  142. /* Only used with GTK_IMAGE_PIXMAP, GTK_IMAGE_IMAGE */
  143. GdkBitmap *GSEAL (mask);
  144. /* Only used with GTK_IMAGE_STOCK, GTK_IMAGE_ICON_SET, GTK_IMAGE_ICON_NAME */
  145. GtkIconSize GSEAL (icon_size);
  146. };
  147. struct _GtkImageClass
  148. {
  149. GtkMiscClass parent_class;
  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. #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. GType gtk_image_get_type (void) G_GNUC_CONST;
  162. GtkWidget* gtk_image_new (void);
  163. GtkWidget* gtk_image_new_from_pixmap (GdkPixmap *pixmap,
  164. GdkBitmap *mask);
  165. GtkWidget* gtk_image_new_from_image (GdkImage *image,
  166. GdkBitmap *mask);
  167. GtkWidget* gtk_image_new_from_file (const gchar *filename);
  168. GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf);
  169. GtkWidget* gtk_image_new_from_stock (const gchar *stock_id,
  170. GtkIconSize size);
  171. GtkWidget* gtk_image_new_from_icon_set (GtkIconSet *icon_set,
  172. GtkIconSize size);
  173. GtkWidget* gtk_image_new_from_animation (GdkPixbufAnimation *animation);
  174. GtkWidget* gtk_image_new_from_icon_name (const gchar *icon_name,
  175. GtkIconSize size);
  176. GtkWidget* gtk_image_new_from_gicon (GIcon *icon,
  177. GtkIconSize size);
  178. void gtk_image_clear (GtkImage *image);
  179. void gtk_image_set_from_pixmap (GtkImage *image,
  180. GdkPixmap *pixmap,
  181. GdkBitmap *mask);
  182. void gtk_image_set_from_image (GtkImage *image,
  183. GdkImage *gdk_image,
  184. GdkBitmap *mask);
  185. void gtk_image_set_from_file (GtkImage *image,
  186. const gchar *filename);
  187. void gtk_image_set_from_pixbuf (GtkImage *image,
  188. GdkPixbuf *pixbuf);
  189. void gtk_image_set_from_stock (GtkImage *image,
  190. const gchar *stock_id,
  191. GtkIconSize size);
  192. void gtk_image_set_from_icon_set (GtkImage *image,
  193. GtkIconSet *icon_set,
  194. GtkIconSize size);
  195. void gtk_image_set_from_animation (GtkImage *image,
  196. GdkPixbufAnimation *animation);
  197. void gtk_image_set_from_icon_name (GtkImage *image,
  198. const gchar *icon_name,
  199. GtkIconSize size);
  200. void gtk_image_set_from_gicon (GtkImage *image,
  201. GIcon *icon,
  202. GtkIconSize size);
  203. void gtk_image_set_pixel_size (GtkImage *image,
  204. gint pixel_size);
  205. GtkImageType gtk_image_get_storage_type (GtkImage *image);
  206. void gtk_image_get_pixmap (GtkImage *image,
  207. GdkPixmap **pixmap,
  208. GdkBitmap **mask);
  209. void gtk_image_get_image (GtkImage *image,
  210. GdkImage **gdk_image,
  211. GdkBitmap **mask);
  212. GdkPixbuf* gtk_image_get_pixbuf (GtkImage *image);
  213. void gtk_image_get_stock (GtkImage *image,
  214. gchar **stock_id,
  215. GtkIconSize *size);
  216. void gtk_image_get_icon_set (GtkImage *image,
  217. GtkIconSet **icon_set,
  218. GtkIconSize *size);
  219. GdkPixbufAnimation* gtk_image_get_animation (GtkImage *image);
  220. void gtk_image_get_icon_name (GtkImage *image,
  221. G_CONST_RETURN gchar **icon_name,
  222. GtkIconSize *size);
  223. void gtk_image_get_gicon (GtkImage *image,
  224. GIcon **gicon,
  225. GtkIconSize *size);
  226. gint gtk_image_get_pixel_size (GtkImage *image);
  227. #ifndef GTK_DISABLE_DEPRECATED
  228. /* These three are deprecated */
  229. void gtk_image_set (GtkImage *image,
  230. GdkImage *val,
  231. GdkBitmap *mask);
  232. void gtk_image_get (GtkImage *image,
  233. GdkImage **val,
  234. GdkBitmap **mask);
  235. #endif /* GTK_DISABLE_DEPRECATED */
  236. G_END_DECLS
  237. #endif /* __GTK_IMAGE_H__ */