diff options
Diffstat (limited to 'pacman-c++/pixmapitem.cpp')
| -rw-r--r-- | pacman-c++/pixmapitem.cpp | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/pacman-c++/pixmapitem.cpp b/pacman-c++/pixmapitem.cpp deleted file mode 100644 index 1ceeec1..0000000 --- a/pacman-c++/pixmapitem.cpp +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | #include "pixmapitem.h" | ||
| 2 | #include <QPainter> | ||
| 3 | |||
| 4 | PixmapItem::PixmapItem(QGraphicsItem *parent) | ||
| 5 | : QGraphicsObject(parent), m_x(0), m_y(0) | ||
| 6 | { | ||
| 7 | } | ||
| 8 | |||
| 9 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsItem *parent) | ||
| 10 | : QGraphicsObject(parent), m_x(0), m_y(0) | ||
| 11 | { | ||
| 12 | m_pix = ":/" + fileName; | ||
| 13 | m_width = m_pix.width(); | ||
| 14 | m_height = m_pix.height(); | ||
| 15 | } | ||
| 16 | |||
| 17 | PixmapItem::PixmapItem(const QString &fileName, QGraphicsScene *scene) | ||
| 18 | : QGraphicsObject(), m_x(0), m_y(0) | ||
| 19 | { | ||
| 20 | m_pix = ":/" + fileName; | ||
| 21 | m_width = m_pix.width(); | ||
| 22 | m_height = m_pix.height(); | ||
| 23 | scene->addItem(this); | ||
| 24 | } | ||
| 25 | |||
| 26 | PixmapItem::PixmapItem(const QPixmap &pix, QGraphicsItem *parent) | ||
| 27 | : QGraphicsObject(parent), m_pix(pix), m_x(0), m_y(0) | ||
| 28 | { | ||
| 29 | m_width = m_pix.width(); | ||
| 30 | m_height = m_pix.height(); | ||
| 31 | } | ||
| 32 | |||
| 33 | PixmapItem::PixmapItem(const QPixmap &pix, QGraphicsScene *scene) | ||
| 34 | : QGraphicsObject(), m_pix(pix), m_x(0), m_y(0) | ||
| 35 | { | ||
| 36 | m_width = m_pix.width(); | ||
| 37 | m_height = m_pix.height(); | ||
| 38 | scene->addItem(this); | ||
| 39 | } | ||
| 40 | |||
| 41 | void PixmapItem::setPixmap(const QPixmap &pix) | ||
| 42 | { | ||
| 43 | m_pix = pix; | ||
| 44 | m_width = m_pix.width(); | ||
| 45 | m_height = m_pix.height(); | ||
| 46 | } | ||
| 47 | |||
| 48 | void PixmapItem::setSprite(int x, int y, int width, int height) | ||
| 49 | { | ||
| 50 | m_x = x; | ||
| 51 | m_y = y; | ||
| 52 | m_width = width; | ||
| 53 | m_height = height; | ||
| 54 | } | ||
| 55 | |||
| 56 | QSizeF PixmapItem::size() const | ||
| 57 | { | ||
| 58 | return QSizeF(m_width, m_height); | ||
| 59 | } | ||
| 60 | |||
| 61 | QRectF PixmapItem::boundingRect() const | ||
| 62 | { | ||
| 63 | return QRectF(QPointF(0, 0), size()); | ||
| 64 | } | ||
| 65 | |||
| 66 | QPainterPath PixmapItem::shape() const | ||
| 67 | { | ||
| 68 | QPainterPath path; | ||
| 69 | path.addRect(boundingRect()); | ||
| 70 | return path; | ||
| 71 | } | ||
| 72 | |||
| 73 | void PixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) | ||
| 74 | { | ||
| 75 | painter->drawPixmap(QPoint(0, 0), m_pix, QRect(m_x, m_y, m_width, m_height)); | ||
| 76 | } | ||
| 77 | |||
