animatedpixmap.h

Go to the documentation of this file.
00001 /*
00002 **  This file is part of Vidalia, and is subject to the license terms in the
00003 **  LICENSE file, found in the top level directory of this distribution. If you
00004 **  did not receive the LICENSE file with this file, you may obtain it from the
00005 **  Vidalia source package distributed by the Vidalia Project at
00006 **  http://www.vidalia-project.net/. No part of Vidalia, including this file,
00007 **  may be copied, modified, propagated, or distributed except according to the
00008 **  terms described in the LICENSE file.
00009 */
00010 
00011 /*
00012 ** \file animatedpixmap.h
00013 ** \version $Id: animatedpixmap.h 2362 2008-02-29 04:30:11Z edmanm $
00014 */
00015 
00016 #ifndef _ANIMATEDPIXMAP_H
00017 #define _ANIMATEDPIXMAP_H
00018 
00019 #include <QTimer>
00020 #include <QPixmap>
00021 
00022 
00023 /** Provides an animated pixmap that can be used even if Qt was compiled 
00024  * without GIF support (which it is, by default) or the system doesn't have a 
00025  * libmng available by default (OS X, for example, usually doesn't). Animated 
00026  * pixmaps should have a series of square frames adjoined horizontally in a 
00027  * single image file. */
00028 class AnimatedPixmap : public QObject
00029 {
00030   Q_OBJECT
00031 
00032 public:
00033   /** Default constructor. */
00034   AnimatedPixmap();
00035   /** Creates an animated pixmap from the specified file. */
00036   AnimatedPixmap(const QString &fileName);
00037 
00038   /** Starts the animation. */
00039   void start();
00040   /** Stops the animated image. */
00041   void stop();
00042   /** Returns the number of frames in the animation. */
00043   int frameCount() const;
00044   /** Returns the current animation frame. */
00045   QPixmap currentFrame() const;
00046   /** Sets the duration of each animation frame to <b>frameDelay</b>. */
00047   void setFrameDelay(int frameDelay);
00048   /** Sets the source image for the animation to <b>pixmap</b>. */
00049   void setPixmap(const QPixmap &pixmap);
00050 
00051 signals:
00052   /** Emitted when the current frame has changed. <b>frameNumber</b> contains
00053    * the current frame number. */
00054   void frameChanged(int frameNumber);
00055 
00056 private slots:
00057   /** Called when the current animation frame should be changed. */
00058   void frameTimeout();
00059 
00060 private:
00061   QPixmap _pixmap;    /**< Source image for the animation frames. */
00062   int _frameNumber;   /**< Current animation frame number. */
00063   QTimer _frameTimer; /**< Timer to control the delay between frames. */
00064 };
00065 
00066 #endif
00067 

Generated on Sat Aug 16 17:38:35 2008 for Vidalia by  doxygen 1.5.6