blob: 6caddae399147bc0dfd5ad0803bce6a2fb9045f3 [file] [log] [blame]
Robert Bieberac9287b2010-06-22 07:55:50 +00001/***************************************************************************
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 Bieberd3027052010-06-23 07:18:22 +000026#include <QGraphicsItem>
Robert Bieberac9287b2010-06-22 07:55:50 +000027
Robert Bieber83c60a12010-08-03 22:29:26 +000028#include "rbmovable.h"
29
Robert Bieberbfc20972010-08-05 07:28:01 +000030class ParseTreeNode;
31
Robert Bieber83c60a12010-08-03 22:29:26 +000032class RBImage: public RBMovable
Robert Bieberac9287b2010-06-22 07:55:50 +000033{
34public:
Robert Bieberbfc20972010-08-05 07:28:01 +000035 RBImage(QString file, int tiles, int x, int y, ParseTreeNode* node,
36 QGraphicsItem* parent = 0);
Robert Bieber3313ab82010-06-29 07:15:41 +000037 RBImage(const RBImage& other, QGraphicsItem* parent);
Robert Bieberd3027052010-06-23 07:18:22 +000038 virtual ~RBImage();
39
Robert Bieberd3027052010-06-23 07:18:22 +000040 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 Bieber5729be42011-01-22 08:45:59 +000050 int numTiles()
51 {
52 return tiles;
53 }
54
Robert Bieberbfc20972010-08-05 07:28:01 +000055 void enableMovement()
56 {
57 setFlag(ItemSendsGeometryChanges, true);
58 }
59
Robert Bieberac9287b2010-06-22 07:55:50 +000060
Robert Bieber83c60a12010-08-03 22:29:26 +000061protected:
62 void saveGeometry();
63
Robert Bieberac9287b2010-06-22 07:55:50 +000064private:
Robert Bieberd3027052010-06-23 07:18:22 +000065 QPixmap* image;
Robert Bieberac9287b2010-06-22 07:55:50 +000066 int tiles;
Robert Bieberd3027052010-06-23 07:18:22 +000067 int currentTile;
68
Robert Bieberbfc20972010-08-05 07:28:01 +000069 ParseTreeNode* node;
70
Robert Bieberac9287b2010-06-22 07:55:50 +000071};
72
73#endif // RBIMAGE_H