diff options
| author | Samu Laaksonen <laaksonen.sj@gmail.com> | 2012-09-25 20:00:41 +0300 |
|---|---|---|
| committer | Samu Laaksonen <laaksonen.sj@gmail.com> | 2012-09-25 20:00:41 +0300 |
| commit | 685fe05def77b039221edf06c74af74915d536c5 (patch) | |
| tree | 9c1a14b8f68bc0f801bdec3edc447d04fdbf7a4c /src/GraphicsButtonObject.h | |
| parent | 29eabac0670574efd384182c065f53d08c42a483 (diff) | |
| download | prism-685fe05def77b039221edf06c74af74915d536c5.tar.gz prism-685fe05def77b039221edf06c74af74915d536c5.zip | |
Initial code commit
Added some stuff for project base
- tiled sources
- few Qt based classes for gfx
Diffstat (limited to 'src/GraphicsButtonObject.h')
| -rw-r--r-- | src/GraphicsButtonObject.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/GraphicsButtonObject.h b/src/GraphicsButtonObject.h new file mode 100644 index 0000000..dbbcaa3 --- /dev/null +++ b/src/GraphicsButtonObject.h @@ -0,0 +1,59 @@ +#ifndef GraphicsButtonObject_h +#define GraphicsButtonObject_h + +#include <QObject> +#include <QGraphicsPixmapItem> +#include <QGraphicsLayoutItem> +#include <QPixmap> + +/** + * Used for creating nice buttons to menus. + */ +class GraphicsButtonObject : + public QObject, + public QGraphicsPixmapItem +{ + Q_OBJECT + +public: + explicit GraphicsButtonObject(const QPixmap &releasedPixmap, + QGraphicsPixmapItem *parent = 0, + QGraphicsScene *scene = 0); + + explicit GraphicsButtonObject(QGraphicsPixmapItem *parent = 0, + QGraphicsScene *scene = 0); + + GraphicsButtonObject(const QString &str, + QGraphicsPixmapItem *parent = 0, + QGraphicsScene *scene = 0); + + ~GraphicsButtonObject(); + + /** + * Sets gfx to indicate pressed-state on button. + * @param &pixmap The pixmap used as gfx + */ + void setPressedPixmap(const QPixmap &pixmap); + + /** + * Sets gfx to indicate released/normal-state on button. + * @param &pixmap The pixmap used as gfx + */ + void setReleasedPixmap(const QPixmap &pixmap); + +protected: + void mousePressEvent(QGraphicsSceneMouseEvent *event); + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); + +private: + QPixmap m_pressedGfx; + QPixmap m_releasedGfx; + + static QPixmap *s_tmpGfx; + static int s_ref; + +signals: + void clicked(); +}; + +#endif // GraphicsButtonObject_h |
