1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = gdk-pixbuf-Animations.html
27  * outPack = gdkpixbuf
28  * outFile = PixbufAnimation
29  * strct   = GdkPixbufAnimation
30  * realStrct=
31  * ctorStrct=
32  * clss    = PixbufAnimation
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_pixbuf_animation_
41  * omit structs:
42  * omit prefixes:
43  * 	- gdk_pixbuf_animation_iter_
44  * 	- gdk_pixbuf_simple_anim_
45  * omit code:
46  * 	- gdk_pixbuf_animation_ref
47  * 	- gdk_pixbuf_animation_unref
48  * omit signals:
49  * imports:
50  * 	- glib.ErrorG
51  * 	- glib.GException
52  * 	- gdkpixbuf.PixbufAnimationIter
53  * 	- glib.TimeVal
54  * 	- gdk.Pixbuf
55  * 	- glib.Str
56  * structWrap:
57  * 	- GTimeVal* -> TimeVal
58  * 	- GdkPixbuf* -> Pixbuf
59  * 	- GdkPixbufAnimation* -> PixbufAnimation
60  * 	- GdkPixbufAnimationIter* -> PixbufAnimationIter
61  * module aliases:
62  * local aliases:
63  * overrides:
64  */
65 
66 module gdkpixbuf.PixbufAnimation;
67 
68 public  import gtkc.gdkpixbuftypes;
69 
70 private import gtkc.gdkpixbuf;
71 private import glib.ConstructionException;
72 private import gobject.ObjectG;
73 
74 
75 private import glib.ErrorG;
76 private import glib.GException;
77 private import gdkpixbuf.PixbufAnimationIter;
78 private import glib.TimeVal;
79 private import gdk.Pixbuf;
80 private import glib.Str;
81 
82 
83 
84 private import gobject.ObjectG;
85 
86 /**
87  * Description
88  * The gdk-pixbuf; library provides a simple mechanism to load and represent
89  * animations. An animation is conceptually a series of frames to be displayed
90  * over time. Each frame is the same size. The animation may not be represented
91  * as a series of frames internally; for example, it may be stored as a
92  * sprite and instructions for moving the sprite around a background. To display
93  * an animation you don't need to understand its representation, however; you just
94  * ask gdk-pixbuf; what should be displayed at a given point in time.
95  */
96 public class PixbufAnimation : ObjectG
97 {
98 	
99 	/** the main Gtk struct */
100 	protected GdkPixbufAnimation* gdkPixbufAnimation;
101 	
102 	
103 	public GdkPixbufAnimation* getPixbufAnimationStruct()
104 	{
105 		return gdkPixbufAnimation;
106 	}
107 	
108 	
109 	/** the main Gtk struct as a void* */
110 	protected override void* getStruct()
111 	{
112 		return cast(void*)gdkPixbufAnimation;
113 	}
114 	
115 	/**
116 	 * Sets our main struct and passes it to the parent class
117 	 */
118 	public this (GdkPixbufAnimation* gdkPixbufAnimation)
119 	{
120 		super(cast(GObject*)gdkPixbufAnimation);
121 		this.gdkPixbufAnimation = gdkPixbufAnimation;
122 	}
123 	
124 	protected override void setStruct(GObject* obj)
125 	{
126 		super.setStruct(obj);
127 		gdkPixbufAnimation = cast(GdkPixbufAnimation*)obj;
128 	}
129 	
130 	/**
131 	 */
132 	
133 	/**
134 	 * Creates a new animation by loading it from a file. The file format is
135 	 * detected automatically. If the file's format does not support multi-frame
136 	 * images, then an animation with a single frame will be created. Possible errors
137 	 * are in the GDK_PIXBUF_ERROR and G_FILE_ERROR domains.
138 	 * Params:
139 	 * filename = Name of file to load, in the GLib file name encoding
140 	 * Throws: GException on failure.
141 	 * Throws: ConstructionException GTK+ fails to create the object.
142 	 */
143 	public this (string filename)
144 	{
145 		// GdkPixbufAnimation * gdk_pixbuf_animation_new_from_file (const char *filename,  GError **error);
146 		GError* err = null;
147 		
148 		auto p = gdk_pixbuf_animation_new_from_file(Str.toStringz(filename), &err);
149 		
150 		if (err !is null)
151 		{
152 			throw new GException( new ErrorG(err) );
153 		}
154 		
155 		if(p is null)
156 		{
157 			throw new ConstructionException("null returned by gdk_pixbuf_animation_new_from_file(Str.toStringz(filename), &err)");
158 		}
159 		this(cast(GdkPixbufAnimation*) p);
160 	}
161 	
162 	/**
163 	 * Queries the width of the bounding box of a pixbuf animation.
164 	 * Returns: Width of the bounding box of the animation.
165 	 */
166 	public int getWidth()
167 	{
168 		// int gdk_pixbuf_animation_get_width (GdkPixbufAnimation *animation);
169 		return gdk_pixbuf_animation_get_width(gdkPixbufAnimation);
170 	}
171 	
172 	/**
173 	 * Queries the height of the bounding box of a pixbuf animation.
174 	 * Returns: Height of the bounding box of the animation.
175 	 */
176 	public int getHeight()
177 	{
178 		// int gdk_pixbuf_animation_get_height (GdkPixbufAnimation *animation);
179 		return gdk_pixbuf_animation_get_height(gdkPixbufAnimation);
180 	}
181 	
182 	/**
183 	 * Get an iterator for displaying an animation. The iterator provides
184 	 * the frames that should be displayed at a given time.
185 	 * It should be freed after use with g_object_unref().
186 	 * start_time would normally come from g_get_current_time(), and
187 	 * marks the beginning of animation playback. After creating an
188 	 * iterator, you should immediately display the pixbuf returned by
189 	 * gdk_pixbuf_animation_iter_get_pixbuf(). Then, you should install a
190 	 * timeout (with g_timeout_add()) or by some other mechanism ensure
191 	 * that you'll update the image after
192 	 * gdk_pixbuf_animation_iter_get_delay_time() milliseconds. Each time
193 	 * the image is updated, you should reinstall the timeout with the new,
194 	 * possibly-changed delay time.
195 	 * As a shortcut, if start_time is NULL, the result of
196 	 * g_get_current_time() will be used automatically.
197 	 * To update the image (i.e. possibly change the result of
198 	 * gdk_pixbuf_animation_iter_get_pixbuf() to a new frame of the animation),
199 	 * call gdk_pixbuf_animation_iter_advance().
200 	 * If you're using GdkPixbufLoader, in addition to updating the image
201 	 * after the delay time, you should also update it whenever you
202 	 * receive the area_updated signal and
203 	 * gdk_pixbuf_animation_iter_on_currently_loading_frame() returns
204 	 * TRUE. In this case, the frame currently being fed into the loader
205 	 * has received new data, so needs to be refreshed. The delay time for
206 	 * a frame may also be modified after an area_updated signal, for
207 	 * example if the delay time for a frame is encoded in the data after
208 	 * the frame itself. So your timeout should be reinstalled after any
209 	 * area_updated signal.
210 	 * A delay time of -1 is possible, indicating "infinite."
211 	 * Params:
212 	 * startTime = time when the animation starts playing
213 	 * Returns: an iterator to move over the animation. [transfer full]
214 	 */
215 	public PixbufAnimationIter getIter(TimeVal startTime)
216 	{
217 		// GdkPixbufAnimationIter * gdk_pixbuf_animation_get_iter (GdkPixbufAnimation *animation,  const GTimeVal *start_time);
218 		auto p = gdk_pixbuf_animation_get_iter(gdkPixbufAnimation, (startTime is null) ? null : startTime.getTimeValStruct());
219 		
220 		if(p is null)
221 		{
222 			return null;
223 		}
224 		
225 		return ObjectG.getDObject!(PixbufAnimationIter)(cast(GdkPixbufAnimationIter*) p);
226 	}
227 	
228 	/**
229 	 * If you load a file with gdk_pixbuf_animation_new_from_file() and it turns
230 	 * out to be a plain, unanimated image, then this function will return
231 	 * TRUE. Use gdk_pixbuf_animation_get_static_image() to retrieve
232 	 * the image.
233 	 * Returns: TRUE if the "animation" was really just an image
234 	 */
235 	public int isStaticImage()
236 	{
237 		// gboolean gdk_pixbuf_animation_is_static_image  (GdkPixbufAnimation *animation);
238 		return gdk_pixbuf_animation_is_static_image(gdkPixbufAnimation);
239 	}
240 	
241 	/**
242 	 * If an animation is really just a plain image (has only one frame),
243 	 * this function returns that image. If the animation is an animation,
244 	 * this function returns a reasonable thing to display as a static
245 	 * unanimated image, which might be the first frame, or something more
246 	 * sophisticated. If an animation hasn't loaded any frames yet, this
247 	 * function will return NULL.
248 	 * Returns: unanimated image representing the animation. [transfer none]
249 	 */
250 	public Pixbuf getStaticImage()
251 	{
252 		// GdkPixbuf * gdk_pixbuf_animation_get_static_image  (GdkPixbufAnimation *animation);
253 		auto p = gdk_pixbuf_animation_get_static_image(gdkPixbufAnimation);
254 		
255 		if(p is null)
256 		{
257 			return null;
258 		}
259 		
260 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
261 	}
262 }