1/*
2 * Copyright (C) 2006 Dmitry Suzdalev <dimsuz@gmail.com>
3 * Copyright (C) 2007 Tomasz Boczkowski <tboczkowski@onet.pl>
4 *
5 * This file is part of the KDE project "KBounce"
6 *
7 * KBounce is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * KBounce is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public
18 * License along with KBounce; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 */
21
22#ifndef RENDERER_H
23#define RENDERER_H
24
25#include <QSvgRenderer>
26#include <KPixmapCache>
27#include <KGameRenderer>
28
29#include <QSize>
30#include <QHash>
31#include <QPixmap>
32
33
34/**
35 * Class for rendering elements of game SVG to QPixmap
36 */
37
38class KBounceRenderer : public KGameRenderer
39{
40 public:
41 /**
42 * Constructor.
43 * @param fileName path to SVG containing game graphics
44 */
45 explicit KBounceRenderer();
46 /**
47 * Destructor.
48 */
49 ~KBounceRenderer();
50 /**
51 * Sets Background size and invalidates background cache
52 */
53 void setBackgroundSize( const QSize& size);
54 /**
55 * Renders background to QPixmap of size set by setBachgroundSize
56 * Background pixmap is cached (setBackgroundSize() invalidates the cache)
57 */
58 QPixmap renderBackground();
59 /**
60 * Set s the path were custom background pictures are located.
61 */
62 void setCustomBackgroundPath(const QString &path);
63 /**
64 * Returns a random pixmap from the custom background path.
65 * If no picture is located in this path the pixmap is null.
66 */
67 QPixmap getRandomBackgroundPixmap(const QString& path);
68 bool loadNewBackgroundPixmap();
69
70 private:
71 QSvgRenderer m_svgRenderer;
72 QSize m_backgroundSize;
73 QPixmap m_cachedBackground;
74 QPixmap m_randomBackground;
75
76 QString m_customBackgroundPath;
77 bool m_useRandomBackgrounds;
78};
79
80#endif //RENDERER_H
81
82