Crossfire Server, Branches 1.12  R18729
CREAnimationWidget.cpp
Go to the documentation of this file.
1 #include <Qt>
2 
3 #include "CREAnimationWidget.h"
4 #include "CREPixmap.h"
5 
6 CREAnimationWidget::CREAnimationWidget(QWidget* parent) : QWidget(parent)
7 {
8  myStep = 0;
9  setMinimumWidth(32);
10  setMinimumHeight(32);
11 }
12 
13 void CREAnimationWidget::setAnimation(QList<int> faces)
14 {
15  myFaces = faces;
16  myStep = 0;
17 }
18 
20 {
21  if (myFaces.size() == 0)
22  return;
23 
24  myStep++;
25  if (myStep == myFaces.size())
26  myStep = 0;
27 
28  repaint();
29 }
30 
31 void CREAnimationWidget::paintEvent(QPaintEvent* /*event*/)
32 {
33  if (myStep >= myFaces.size())
34  return;
35 
36  QPainter painter(this);
37  CREPixmap::getIcon(myFaces[myStep]).paint(&painter, 0, 0, 32, 32);
38 }
void setAnimation(QList< int > faces)
virtual void paintEvent(QPaintEvent *event)
CREAnimationWidget(QWidget *parent)
static QIcon getIcon(int faceNumber)
Definition: CREPixmap.cpp:27