diff options
Diffstat (limited to 'pacman-c++/pixmapitem.cpp')
| -rw-r--r-- | pacman-c++/pixmapitem.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/pacman-c++/pixmapitem.cpp b/pacman-c++/pixmapitem.cpp index 9c2f941..64ac594 100644 --- a/pacman-c++/pixmapitem.cpp +++ b/pacman-c++/pixmapitem.cpp | |||
| @@ -2,43 +2,43 @@ | |||
| 2 | #include <QPainter> | 2 | #include <QPainter> |
| 3 | 3 | ||
| 4 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsItem *parent) | 4 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsItem *parent) |
| 5 | : QGraphicsObject(parent), m_x(0), m_y(0) | 5 | : QGraphicsObject(parent), m_x(0), m_y(0) |
| 6 | { | 6 | { |
| 7 | m_pix = ":/" + fileName; | 7 | m_pix = ":/" + fileName; |
| 8 | m_width = m_pix.width(); | 8 | m_width = m_pix.width(); |
| 9 | m_height = m_pix.height(); | 9 | m_height = m_pix.height(); |
| 10 | } | 10 | } |
| 11 | 11 | ||
| 12 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) | 12 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) |
| 13 | : QGraphicsObject(), m_x(0), m_y(0) | 13 | : QGraphicsObject(), m_x(0), m_y(0) |
| 14 | { | 14 | { |
| 15 | m_pix = ":/" + fileName; | 15 | m_pix = ":/" + fileName; |
| 16 | m_width = m_pix.width(); | 16 | m_width = m_pix.width(); |
| 17 | m_height = m_pix.height(); | 17 | m_height = m_pix.height(); |
| 18 | scene->addItem(this); | 18 | scene->addItem(this); |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | void PixmapItem::setSprite(int x, int y, int width, int height) | 21 | void PixmapItem::setSprite(int x, int y, int width, int height) |
| 22 | { | 22 | { |
| 23 | m_x = x; | 23 | m_x = x; |
| 24 | m_y = y; | 24 | m_y = y; |
| 25 | m_width = width; | 25 | m_width = width; |
| 26 | m_height = height; | 26 | m_height = height; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | QSizeF PixmapItem::size() const | 29 | QSizeF PixmapItem::size() const |
| 30 | { | 30 | { |
| 31 | return QSizeF(m_width, m_height); | 31 | return QSizeF(m_width, m_height); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | QRectF PixmapItem::boundingRect() const | 34 | QRectF PixmapItem::boundingRect() const |
| 35 | { | 35 | { |
| 36 | return QRectF(QPointF(0, 0), size()); | 36 | return QRectF(QPointF(0, 0), size()); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) | 39 | void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) |
| 40 | { | 40 | { |
| 41 | painter->drawPixmap(0, 0, m_pix, m_x, m_y, m_width, m_height); | 41 | painter->drawPixmap(0, 0, m_pix, m_x, m_y, m_width, m_height); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | 44 | ||
