Robert Bieber | ac9287b | 2010-06-22 07:55:50 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2010 Robert Bieber |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #ifndef RBIMAGE_H |
| 23 | #define RBIMAGE_H |
| 24 | |
| 25 | #include <QPixmap> |
Robert Bieber | d302705 | 2010-06-23 07:18:22 +0000 | [diff] [blame] | 26 | #include <QGraphicsItem> |
Robert Bieber | ac9287b | 2010-06-22 07:55:50 +0000 | [diff] [blame] | 27 | |
Robert Bieber | 83c60a1 | 2010-08-03 22:29:26 +0000 | [diff] [blame] | 28 | #include "rbmovable.h" |
| 29 | |
Robert Bieber | bfc2097 | 2010-08-05 07:28:01 +0000 | [diff] [blame] | 30 | class ParseTreeNode; |
| 31 | |
Robert Bieber | 83c60a1 | 2010-08-03 22:29:26 +0000 | [diff] [blame] | 32 | class RBImage: public RBMovable |
Robert Bieber | ac9287b | 2010-06-22 07:55:50 +0000 | [diff] [blame] | 33 | { |
| 34 | public: |
Robert Bieber | bfc2097 | 2010-08-05 07:28:01 +0000 | [diff] [blame] | 35 | RBImage(QString file, int tiles, int x, int y, ParseTreeNode* node, |
| 36 | QGraphicsItem* parent = 0); |
Robert Bieber | 3313ab8 | 2010-06-29 07:15:41 +0000 | [diff] [blame] | 37 | RBImage(const RBImage& other, QGraphicsItem* parent); |
Robert Bieber | d302705 | 2010-06-23 07:18:22 +0000 | [diff] [blame] | 38 | virtual ~RBImage(); |
| 39 | |
Robert Bieber | d302705 | 2010-06-23 07:18:22 +0000 | [diff] [blame] | 40 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, |
| 41 | QWidget *widget); |
| 42 | |
| 43 | void setTile(int tile) |
| 44 | { |
| 45 | currentTile = tile; |
| 46 | if(currentTile > tiles - 1) |
| 47 | currentTile = tiles -1; |
| 48 | } |
| 49 | |
Robert Bieber | 5729be4 | 2011-01-22 08:45:59 +0000 | [diff] [blame] | 50 | int numTiles() |
| 51 | { |
| 52 | return tiles; |
| 53 | } |
| 54 | |
Robert Bieber | bfc2097 | 2010-08-05 07:28:01 +0000 | [diff] [blame] | 55 | void enableMovement() |
| 56 | { |
| 57 | setFlag(ItemSendsGeometryChanges, true); |
| 58 | } |
| 59 | |
Robert Bieber | ac9287b | 2010-06-22 07:55:50 +0000 | [diff] [blame] | 60 | |
Robert Bieber | 83c60a1 | 2010-08-03 22:29:26 +0000 | [diff] [blame] | 61 | protected: |
| 62 | void saveGeometry(); |
| 63 | |
Robert Bieber | ac9287b | 2010-06-22 07:55:50 +0000 | [diff] [blame] | 64 | private: |
Robert Bieber | d302705 | 2010-06-23 07:18:22 +0000 | [diff] [blame] | 65 | QPixmap* image; |
Robert Bieber | ac9287b | 2010-06-22 07:55:50 +0000 | [diff] [blame] | 66 | int tiles; |
Robert Bieber | d302705 | 2010-06-23 07:18:22 +0000 | [diff] [blame] | 67 | int currentTile; |
| 68 | |
Robert Bieber | bfc2097 | 2010-08-05 07:28:01 +0000 | [diff] [blame] | 69 | ParseTreeNode* node; |
| 70 | |
Robert Bieber | ac9287b | 2010-06-22 07:55:50 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | #endif // RBIMAGE_H |