1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* This file is part of the KDE libraries |
---|
3 | |
---|
4 | Copyright (C) 1997 Martin Jones (mjones@kde.org) |
---|
5 | Copyright (C) 1997 Torben Weis (weis@kde.org) |
---|
6 | Copyright (C) 1999, 2000 Helix Code, Inc. |
---|
7 | |
---|
8 | This library is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU Library General Public |
---|
10 | License as published by the Free Software Foundation; either |
---|
11 | version 2 of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | This library is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | Library General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU Library General Public License |
---|
19 | along with this library; see the file COPYING.LIB. If not, write to |
---|
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | */ |
---|
23 | #ifndef _HTMLIMAGE_H_ |
---|
24 | #define _HTMLIMAGE_H_ |
---|
25 | |
---|
26 | #include <gdk-pixbuf/gdk-pixbuf.h> |
---|
27 | #include <gdk-pixbuf/gdk-pixbuf-loader.h> |
---|
28 | #include "htmlobject.h" |
---|
29 | |
---|
30 | #define HTML_IMAGE_FACTORY(x) ((HTMLImageFactory *)(x)) |
---|
31 | #define HTML_IMAGE_POINTER(x) ((HTMLImagePointer *)(x)) |
---|
32 | #define HTML_IS_IMAGE(x) (HTML_CHECK_TYPE ((x), HTML_TYPE_IMAGE)) |
---|
33 | |
---|
34 | struct _HTMLImagePointer { |
---|
35 | gint refcount; |
---|
36 | gchar *url; |
---|
37 | GdkPixbufLoader *loader; |
---|
38 | GdkPixbuf *pixbuf; |
---|
39 | GdkPixbufAnimation *animation; |
---|
40 | GSList *interests; /* A list of HTMLImage's, or a NULL pointer for the background pixmap */ |
---|
41 | HTMLImageFactory *factory; |
---|
42 | gint stall; |
---|
43 | guint stall_timeout; |
---|
44 | }; |
---|
45 | |
---|
46 | struct _HTMLImageAnimation { |
---|
47 | /* stuff for animated image */ |
---|
48 | /* draw coordination */ |
---|
49 | gint x; |
---|
50 | gint y; |
---|
51 | |
---|
52 | /* remember engine offset */ |
---|
53 | gint ex, ey; |
---|
54 | |
---|
55 | /* current frame */ |
---|
56 | GList *cur_frame; |
---|
57 | gint cur_n; |
---|
58 | |
---|
59 | /* animation timeout function */ |
---|
60 | gint timeout; |
---|
61 | |
---|
62 | /* helper buffer */ |
---|
63 | GdkPixbuf *pixbuf; |
---|
64 | |
---|
65 | /* active draw flag */ |
---|
66 | gint active; |
---|
67 | }; |
---|
68 | |
---|
69 | #define HTML_IMAGE(x) ((HTMLImage *)(x)) |
---|
70 | #define HTML_IMAGE_POINTER(x) ((HTMLImagePointer *)(x)) |
---|
71 | |
---|
72 | struct _HTMLImage { |
---|
73 | HTMLObject object; |
---|
74 | HTMLImagePointer *image_ptr; |
---|
75 | HTMLImageAnimation *animation; |
---|
76 | |
---|
77 | HTMLColor *color; |
---|
78 | |
---|
79 | guint have_color: 1; |
---|
80 | |
---|
81 | gint8 border; |
---|
82 | |
---|
83 | gint16 specified_width; |
---|
84 | gint16 specified_height; |
---|
85 | gboolean percent_width : 1; |
---|
86 | gboolean percent_height : 1; |
---|
87 | gboolean ismap : 1; |
---|
88 | |
---|
89 | gint8 hspace; |
---|
90 | gint8 vspace; |
---|
91 | |
---|
92 | HTMLVAlignType valign; |
---|
93 | |
---|
94 | gchar *url; |
---|
95 | gchar *target; |
---|
96 | gchar *alt; |
---|
97 | gchar *usemap; |
---|
98 | gchar *final_url; |
---|
99 | }; |
---|
100 | |
---|
101 | struct _HTMLImageClass { |
---|
102 | HTMLObjectClass parent_class; |
---|
103 | }; |
---|
104 | |
---|
105 | |
---|
106 | extern HTMLImageClass image_class; |
---|
107 | |
---|
108 | |
---|
109 | void html_image_type_init (void); |
---|
110 | void html_image_class_init (HTMLImageClass *klass, |
---|
111 | HTMLType type, |
---|
112 | guint object_size); |
---|
113 | void html_image_init (HTMLImage *image, |
---|
114 | HTMLImageClass *klass, |
---|
115 | HTMLImageFactory *imf, |
---|
116 | const gchar *filename, |
---|
117 | const gchar *url, |
---|
118 | const gchar *target, |
---|
119 | gint16 width, |
---|
120 | gint16 height, |
---|
121 | gboolean percent_width, |
---|
122 | gboolean percent_height, |
---|
123 | gint8 border, |
---|
124 | HTMLColor *border_color, |
---|
125 | HTMLVAlignType valign, |
---|
126 | gboolean reload); |
---|
127 | HTMLObject *html_image_new (HTMLImageFactory *imf, |
---|
128 | const gchar *filename, |
---|
129 | const gchar *url, |
---|
130 | const gchar *target, |
---|
131 | gint16 width, |
---|
132 | gint16 height, |
---|
133 | gboolean percent_width, |
---|
134 | gboolean percent_height, |
---|
135 | gint8 border, |
---|
136 | HTMLColor *border_color, |
---|
137 | HTMLVAlignType valign, |
---|
138 | gboolean reload); |
---|
139 | void html_image_set_size (HTMLImage *image, |
---|
140 | gint w, |
---|
141 | gint h, |
---|
142 | gboolean pw, |
---|
143 | gboolean ph); |
---|
144 | void html_image_set_spacing (HTMLImage *image, |
---|
145 | gint hspace, |
---|
146 | gint vspace); |
---|
147 | void html_image_set_url (HTMLImage *image, |
---|
148 | const gchar *url); |
---|
149 | void html_image_set_valign (HTMLImage *image, |
---|
150 | HTMLVAlignType valign); |
---|
151 | void html_image_set_border (HTMLImage *image, |
---|
152 | gint border); |
---|
153 | void html_image_set_alt (HTMLImage *image, |
---|
154 | gchar *alt); |
---|
155 | void html_image_set_map (HTMLImage *image, |
---|
156 | gchar *mapuri, |
---|
157 | gboolean ismap); |
---|
158 | gchar *html_image_resolve_image_url (GtkHTML *html, |
---|
159 | gchar *image_url); |
---|
160 | |
---|
161 | void html_image_edit_set_url (HTMLImage *image, |
---|
162 | const gchar *url); |
---|
163 | guint html_image_get_actual_width (HTMLImage *image, |
---|
164 | HTMLPainter *painter); |
---|
165 | guint html_image_get_actual_height (HTMLImage *image, |
---|
166 | HTMLPainter *painter); |
---|
167 | /* FIXME move to htmlimagefactory.c */ |
---|
168 | HTMLImageFactory *html_image_factory_new (HTMLEngine *e); |
---|
169 | void html_image_factory_free (HTMLImageFactory *factory); |
---|
170 | void html_image_factory_cleanup (HTMLImageFactory *factory); /* Does gc etc. - removes unused image entries */ |
---|
171 | void html_image_factory_stop_animations (HTMLImageFactory *factory); |
---|
172 | void html_image_factory_deactivate_animations (HTMLImageFactory *factory); |
---|
173 | HTMLImagePointer *html_image_factory_register (HTMLImageFactory *factory, |
---|
174 | HTMLImage *i, |
---|
175 | const char *filename, |
---|
176 | gboolean reload); |
---|
177 | void html_image_factory_unregister (HTMLImageFactory *factory, |
---|
178 | HTMLImagePointer *pointer, |
---|
179 | HTMLImage *i); |
---|
180 | void html_image_factory_move_images (HTMLImageFactory *dst, |
---|
181 | HTMLImageFactory *src); |
---|
182 | void html_image_factory_ref_all_images (HTMLImageFactory *factory); |
---|
183 | void html_image_factory_unref_all_images (HTMLImageFactory *factory); |
---|
184 | void html_image_factory_ref_image_ptr (HTMLImageFactory *factory, |
---|
185 | const gchar *url); |
---|
186 | void html_image_factory_unref_image_ptr (HTMLImageFactory *factory, |
---|
187 | const gchar *url); |
---|
188 | #endif /* _HTMLIMAGE_H_ */ |
---|