File indexing completed on 2024-04-28 04:02:10

0001 /*
0002     This file is part of the KDE games kwin4 program
0003     SPDX-FileCopyrightText: 2007 John Tapsel <tapsell@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef REFLECTION_GRAPHICS_SCENE_H
0009 #define REFLECTION_GRAPHICS_SCENE_H
0010 
0011 // Qt
0012 #include <QGraphicsPixmapItem>
0013 #include <QGraphicsScene>
0014 #include <QGraphicsTextItem>
0015 #include <QStyleOptionGraphicsItem>
0016 #include <QWidget>
0017 
0018 class QPainter;
0019 class QGraphicsItem;
0020 
0021 /**
0022  * A scene that reflects what is in it, to look pretty.
0023  */
0024 class ReflectionGraphicsScene : public QGraphicsScene
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     /**
0030      * Construct a new scene.
0031      * @param updateTime The update interval of the canvas (kind of debug parameter)
0032      * @param parent     The parent window.
0033      */
0034     explicit ReflectionGraphicsScene(int updateTime, QObject *parent = nullptr);
0035 
0036     /**
0037      * Destruct the scene.
0038      */
0039     ~ReflectionGraphicsScene() override;
0040 
0041     /**
0042      * Standard QGV command to draw all items of a scene.
0043      * @param painter    The painter
0044      * @param numItems   The amount of items
0045      * @param items      The items to draw
0046      * @param options    The draw options
0047      * @param  widget    The widget
0048      */
0049     void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], const QStyleOptionGraphicsItem options[], QWidget *widget = nullptr) override;
0050 
0051     /**
0052      * Should the background be drawn or not.
0053      * @param status True to draw the background.
0054      */
0055     void setBackground(bool status)
0056     {
0057         mBackground = status;
0058     }
0059 
0060 protected:
0061     /**
0062      * QGV background drawing.
0063      * @param painter The painter
0064      * @param rect    The clipping rect
0065      */
0066     void drawBackground(QPainter *painter, const QRectF &rect) override;
0067 
0068 private:
0069     // Draw background?
0070     bool mBackground;
0071 };
0072 
0073 #endif