File indexing completed on 2024-03-24 04:05:16
0001 /* 0002 SPDX-FileCopyrightText: 2019 Christian Krippendorf <Coding@Christian-Krippendorf.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 // own 0008 #include "gamebackground.h" 0009 0010 // Qt 0011 #include <QGraphicsSceneMouseEvent> 0012 #include <QPainter> 0013 0014 0015 GameBackground::GameBackground(QGraphicsObject * item) 0016 : QGraphicsObject(item) 0017 , m_width(100) 0018 , m_height(100) 0019 { 0020 } 0021 0022 GameBackground::~GameBackground() 0023 { 0024 } 0025 0026 void GameBackground::setSize(qreal width, qreal height) 0027 { 0028 m_width = width; 0029 m_height = height; 0030 } 0031 0032 void GameBackground::prepareForGeometryChange() 0033 { 0034 prepareGeometryChange(); 0035 } 0036 0037 void GameBackground::paint(QPainter *painter, const QStyleOptionGraphicsItem *, 0038 QWidget *) 0039 { 0040 painter->fillRect(QRectF(0, 0, m_width, m_height), m_background); 0041 } 0042 0043 void GameBackground::setBackground(const QBrush & background) 0044 { 0045 m_background = background; 0046 } 0047 0048 QRectF GameBackground::boundingRect() const 0049 { 0050 return QRectF(QPointF(0.0, 0.0), QSizeF(m_width, m_height)); 0051 } 0052 0053 QRectF GameBackground::rect() const 0054 { 0055 return boundingRect(); 0056 } 0057 0058 #include "moc_gamebackground.cpp"