diff options
Diffstat (limited to 'pacman-c++/pixmapitem.cpp')
| -rw-r--r-- | pacman-c++/pixmapitem.cpp | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/pacman-c++/pixmapitem.cpp b/pacman-c++/pixmapitem.cpp index 9c2f941..a977a9e 100644 --- a/pacman-c++/pixmapitem.cpp +++ b/pacman-c++/pixmapitem.cpp | |||
| @@ -1,10 +1,16 @@ | |||
| 1 | #include "pixmapitem.h" | 1 | #include "pixmapitem.h" |
| 2 | #include <QPainter> | 2 | #include <QPainter> |
| 3 | #include <QDebug> | ||
| 4 | |||
| 5 | PixmapItem::PixmapItem(QGraphicsItem *parent) | ||
| 6 | : QGraphicsObject(parent), m_x(0), m_y(0) | ||
| 7 | { | ||
| 8 | } | ||
| 3 | 9 | ||
| 4 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsItem *parent) | 10 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsItem *parent) |
| 5 | : QGraphicsObject(parent), m_x(0), m_y(0) | 11 | : QGraphicsObject(parent), m_x(0), m_y(0) |
| 6 | { | 12 | { |
| 7 | m_pix = ":/" + fileName; | 13 | m_pix = ":/" + fileName; |
| 8 | m_width = m_pix.width(); | 14 | m_width = m_pix.width(); |
| 9 | m_height = m_pix.height(); | 15 | m_height = m_pix.height(); |
| 10 | } | 16 | } |
| @@ -12,12 +18,34 @@ PixmapItem::PixmapItem(const QString &fileName, QGraphicsItem *parent) | |||
| 12 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) | 18 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) |
| 13 | : QGraphicsObject(), m_x(0), m_y(0) | 19 | : QGraphicsObject(), m_x(0), m_y(0) |
| 14 | { | 20 | { |
| 15 | m_pix = ":/" + fileName; | 21 | m_pix = ":/" + fileName; |
| 16 | m_width = m_pix.width(); | 22 | m_width = m_pix.width(); |
| 17 | m_height = m_pix.height(); | 23 | m_height = m_pix.height(); |
| 18 | scene->addItem(this); | 24 | scene->addItem(this); |
| 19 | } | 25 | } |
| 20 | 26 | ||
| 27 | PixmapItem::PixmapItem(const QPixmap &pix, QGraphicsItem *parent) | ||
| 28 | : QGraphicsObject(parent), m_pix(pix), m_x(0), m_y(0) | ||
| 29 | { | ||
| 30 | m_width = m_pix.width(); | ||
| 31 | m_height = m_pix.height(); | ||
| 32 | } | ||
| 33 | |||
| 34 | PixmapItem::PixmapItem(const QPixmap &pix, QGraphicsScene *scene) | ||
| 35 | : QGraphicsObject(), m_pix(pix), m_x(0), m_y(0) | ||
| 36 | { | ||
| 37 | m_width = m_pix.width(); | ||
| 38 | m_height = m_pix.height(); | ||
| 39 | scene->addItem(this); | ||
| 40 | } | ||
| 41 | |||
| 42 | void PixmapItem::setPixmap(const QPixmap &pix) | ||
| 43 | { | ||
| 44 | m_pix = pix; | ||
| 45 | m_width = m_pix.width(); | ||
| 46 | m_height = m_pix.height(); | ||
| 47 | } | ||
| 48 | |||
| 21 | void PixmapItem::setSprite(int x, int y, int width, int height) | 49 | void PixmapItem::setSprite(int x, int y, int width, int height) |
| 22 | { | 50 | { |
| 23 | m_x = x; | 51 | m_x = x; |
| @@ -41,4 +69,16 @@ void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWid | |||
| 41 | painter->drawPixmap(0, 0, m_pix, m_x, m_y, m_width, m_height); | 69 | painter->drawPixmap(0, 0, m_pix, m_x, m_y, m_width, m_height); |
| 42 | } | 70 | } |
| 43 | 71 | ||
| 72 | #if 0 | ||
| 73 | bool PixmapItem::isVisible() const | ||
| 74 | { | ||
| 75 | qDebug() << "isVisible()"; | ||
| 76 | return true; | ||
| 77 | } | ||
| 78 | |||
| 79 | void PixmapItem::setVisible(bool v) | ||
| 80 | { | ||
| 81 | qDebug() << "setVisible(" << v << ")"; | ||
| 82 | } | ||
| 83 | #endif | ||
| 44 | 84 | ||
