KVIrc 5.2.4
Developer APIs
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 "kvi_settings.h"
29
30#include <QObject>
31#include <QString>
32#include <QTimer>
33
34class QPixmap;
35
70{
71 Q_OBJECT
72protected:
73 QString m_szFileName;
75
78
79public:
80 /*
81 * Creates KviAnimatedPixmap, and loads data from "fileName".
82 */
83 KviAnimatedPixmap(QString fileName, int iWidth = 0, int iHeight = 0);
84
85 virtual ~KviAnimatedPixmap();
86
87 /*
88 * Creates new pixmap using "source" as source of images.
89 */
91
92 /*
93 * Returns true if animation is started.
94 * Returns false otherways.
95 */
96 bool isStarted() const
97 {
98 return m_iStarted > 0;
99 }
100
101 /*
102 * Starts the animation
103 */
104 void start();
105
106 /*
107 * Stops the animation
108 */
109 void stop();
110
111 /*
112 * Returns true if animation has at least one loaded frame.
113 * Returns false otherways.
114 */
115 bool isValid() const
116 {
117 return (m_pFrameData->count() > 0);
118 }
119
120 /*
121 * Returns active frame's pixmap.
122 * Never fails.
123 */
124
125 QPixmap * pixmap()
126 {
127 if(m_pFrameData->count() > 0)
128 return m_pFrameData->at(m_uCurrentFrameNumber).pixmap;
129 else
131 }
132
133 /*
134 * Returns active frame number
135 */
136 uint activeFrameNumber() const
137 {
138 return m_uCurrentFrameNumber;
139 }
140
141 /*
142 * Returns animation frame count
143 */
144 uint framesCount() const
145 {
146 return m_pFrameData->count();
147 }
148
149 /*
150 * Returns current image size
151 */
152 const QSize & size() const
153 {
154 return m_pFrameData->size;
155 }
156
157 /*
158 * Resizes all frames to the newSize size, using "ratioMode"
159 * ratio.
160 */
161 void resize(QSize newSize, Qt::AspectRatioMode ratioMode);
162
163 /*
164 * Called when the frame changes
165 */
166 void nextFrame(bool bEmitSignalAndScheduleNext);
167
168signals:
169
170 /*
171 * Slot, to be connected to m_animationTimer, to receive animation
172 * frame changes.
173 */
175};
176
177#endif /* KVI_ANIMATEDPIXMAP_H_ */
Definition KviAnimatedPixmapCache.h:82
QSize size
Definition KviAnimatedPixmapCache.h:85
static QPixmap * dummyPixmap()
Definition KviAnimatedPixmapCache.cpp:244
Definition KviAnimatedPixmapInterface.h:30
virtual void nextFrame(bool)=0
Definition KviAnimatedPixmap.h:70
QPixmap * pixmap()
Definition KviAnimatedPixmap.h:125
const QSize & size() const
Definition KviAnimatedPixmap.h:152
bool isStarted() const
Definition KviAnimatedPixmap.h:96
QString m_szFileName
Definition KviAnimatedPixmap.h:73
uint framesCount() const
Definition KviAnimatedPixmap.h:144
uint m_uCurrentFrameNumber
Definition KviAnimatedPixmap.h:76
KviAnimatedPixmapCache::Data * m_pFrameData
Definition KviAnimatedPixmap.h:74
bool isValid() const
Definition KviAnimatedPixmap.h:115
int m_iStarted
Definition KviAnimatedPixmap.h:77
uint activeFrameNumber() const
Definition KviAnimatedPixmap.h:136
This file contains compile time settings.
#define KVILIB_API
Definition kvi_settings.h:124