File indexing completed on 2024-04-28 04:04:39

0001 /*
0002     This file is part of the game 'KTron'
0003 
0004     SPDX-FileCopyrightText: 1998-2000 Matthias Kiefer <matthias.kiefer@gmx.de>
0005     SPDX-FileCopyrightText: 2005 Benjamin C. Meyer <ben at meyerhome dot net>
0006     SPDX-FileCopyrightText: 2008-2009 Stas Verberkt <legolas at legolasweb dot nl>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 
0010 */
0011 
0012 #ifndef RENDERER_H
0013 #define RENDERER_H
0014 
0015 #include "playfield.h"
0016 // KDEGames
0017 #include <KGameRenderer>
0018 // Qt
0019 #include <QPixmap>
0020 #include <QPainter>
0021 #include <QString>
0022 #include <QSize>
0023 
0024 class Renderer : public KGameRenderer
0025 {
0026     private:
0027         Renderer();
0028 
0029     public:
0030         static Renderer *self();
0031 
0032         bool loadTheme(const QString &);
0033         void boardResized(int width, int height, int partWidth, int partHeight);
0034 
0035         int calculateOffsetX(int x);
0036         int calculateOffsetY(int y);
0037 
0038         QPixmap getPart(const QString &partName);
0039         QPixmap getPartOfSize(const QString &partName, const QSize &partSize);
0040         QPixmap background();
0041         QPixmap messageBox(const QString &message);
0042 
0043         void drawPart(QPainter & painter, int x, int y, const QString &svgName);
0044         void updatePlayField(PlayField &playfield);
0045         QPixmap *getPlayField();
0046         void clearPixmapCache();
0047 
0048     private:
0049         QSize m_sceneSize;
0050         QSize m_partSize;
0051 
0052         QPixmap m_playField;
0053         QPixmap m_background;
0054 };
0055 
0056 #endif // RENDERER_H