1 /***********************************************************************
2  *
3  * Copyright (C) 2007, 2008, 2009, 2015 Graeme Gott <graeme@gottcode.org>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  ***********************************************************************/
19 
20 #ifndef THEME_H
21 #define THEME_H
22 
23 #include <QPixmap>
24 #include <QString>
25 class QPainter;
26 class QSvgRenderer;
27 
28 class Theme
29 {
30 public:
31 	Theme();
32 	~Theme();
33 
34 	QStringList available() const;
35 	void load(const QString& name);
36 	void scale(int unit);
37 	void setDevicePixelRatio(int ratio);
38 
39 	enum Element {
40 		Background,
41 		Flag,
42 		Start,
43 		Target,
44 		TotalElements
45 	};
46 	enum RotatedElement {
47 		Hint,
48 		Marker,
49 		Player,
50 		TotalRotatedElements
51 	};
52 	void draw(QPainter& painter, int column, int row, enum Element element) const;
53 	void draw(QPainter& painter, int column, int row, enum RotatedElement element, int angle) const;
54 	void drawBackground(QPainter& painter) const;
55 	void drawCorner(QPainter& painter, int column, int row, unsigned char walls) const;
56 	void drawWall(QPainter& painter, int column, int row, bool vertical = false) const;
57 
58 private:
59 	void cache(const QString& element, QPixmap& pixmap, const QRect& bounds, int angle = 0) const;
60 	QString findFile(const QString& theme, const QString& file) const;
61 
62 	QStringList m_locations;
63 	QSvgRenderer* m_renderer;
64 	QPixmap m_pixmap[TotalElements];
65 	QPixmap m_pixmap_rotated[TotalRotatedElements][4];
66 	QPixmap m_pixmap_corner[15];
67 	QPixmap m_pixmap_wall[2];
68 	int m_unit;
69 	int m_ratio;
70 };
71 
72 #endif // THEME_H
73