KVIrc  4.9.2
DeveloperAPIs
KviAnimatedPixmap.h
Go to the documentation of this file.
1 #ifndef KVI_ANIMATEDPIXMAP_H_
2 #define KVI_ANIMATEDPIXMAP_H_
3 //=============================================================================
4 //
5 // File : KviAnimatedPixmap.h
6 // Creation date : Wed Jul 30 2008 01:45:21 CEST by Alexey Uzhva
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2008 Alexey Uzhva (wizard at opendoor dot ru)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include <QObject>
28 #include <QPixmap>
29 #include <QList>
30 #include <QTimer>
31 #include "kvi_settings.h"
32 #include "KviAnimatedPixmapCache.h"
33 
68 {
69  Q_OBJECT
70 
71 protected:
72  QString m_szFileName;
74 
77 
78 public:
79  /*
80  * Creates KviAnimatedPixmap, and loads data from "fileName".
81  */
82  KviAnimatedPixmap(QString fileName, int iWidth = 0, int iHeight = 0);
83 
84  virtual ~KviAnimatedPixmap();
85 
86  /*
87  * Creates new pixmap using "source" as source of images.
88  */
89  KviAnimatedPixmap(const KviAnimatedPixmap & source);
90 
91  /*
92  * Returns true if animation is started.
93  * Returns false otherways.
94  */
95  inline bool isStarted()
96  {
97  return m_iStarted > 0;
98  }
99 
100  /*
101  * Starts the animation
102  */
103  void start();
104 
105  /*
106  * Stops the animation
107  */
108  void stop();
109 
110  /*
111  * Returns true if animation has at least one loaded frame.
112  * Returns false otherways.
113  */
114  inline bool isValid()
115  {
116  return (m_pFrameData->count() > 0);
117  }
118 
119  /*
120  * Returns active frame's pixmap.
121  * Never fails.
122  */
123 
124  inline QPixmap * pixmap()
125  {
126  if(m_pFrameData->count() > 0)
127  return m_pFrameData->at(m_uCurrentFrameNumber).pixmap;
128  else
130  }
131 
132  /*
133  * Returns active frame number
134  */
135  inline uint activeFrameNumber()
136  {
137  return m_uCurrentFrameNumber;
138  }
139 
140  /*
141  * Returns animation frame count
142  */
143  inline uint framesCount()
144  {
145  return m_pFrameData->count();
146  }
147 
148  /*
149  * Returns current image size
150  */
151  inline const QSize & size()
152  {
153  return m_pFrameData->size;
154  }
155 
156  /*
157  * Resizes all frames to the newSize size, using "ratioMode"
158  * ratio.
159  */
160  void resize(QSize newSize, Qt::AspectRatioMode ratioMode);
161 
162  /*
163  * Called when the frame changes
164  */
165  void nextFrame(bool bEmitSignalAndScheduleNext);
166 
167 signals:
168 
169  /*
170  * Slot, to be connected to m_animationTimer, to receive animation
171  * frame changes.
172  */
173  void frameChanged();
174 };
175 
176 #endif /* KVI_ANIMATEDPIXMAP_H_ */
Definition: KviAnimatedPixmap.h:67
Definition: KviAnimatedPixmapInterface.h:30
int m_iStarted
Definition: KviAnimatedPixmap.h:76
QString m_szFileName
Definition: KviAnimatedPixmap.h:72
uint activeFrameNumber()
Definition: KviAnimatedPixmap.h:135
uint framesCount()
Definition: KviAnimatedPixmap.h:143
bool isStarted()
Definition: KviAnimatedPixmap.h:95
uint m_uCurrentFrameNumber
Definition: KviAnimatedPixmap.h:75
KviAnimatedPixmapCache::Data * m_pFrameData
Definition: KviAnimatedPixmap.h:73
static QPixmap * dummyPixmap()
Definition: KviAnimatedPixmapCache.cpp:244
Definition: KviAnimatedPixmapCache.h:80
bool isValid()
Definition: KviAnimatedPixmap.h:114
const QSize & size()
Definition: KviAnimatedPixmap.h:151
This file contains compile time settings.
QPixmap * pixmap()
Definition: KviAnimatedPixmap.h:124
#define KVILIB_API
Definition: kvi_settings.h:125
virtual void nextFrame(bool)=0