File indexing completed on 2024-09-15 06:37:35
0001 /* 0002 SPDX-FileCopyrightText: 2007 Paolo Capriotti <p.capriotti@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "kbsrenderer.h" 0008 #include "coord.h" 0009 // KDEGames 0010 #include <KGameThemeProvider> 0011 #include <KGameRenderedItem> 0012 0013 static KGameThemeProvider *provider() 0014 { 0015 KGameThemeProvider *prov = new KGameThemeProvider; 0016 prov->discoverThemes(QStringLiteral("pictures")); 0017 return prov; 0018 } 0019 0020 KBSRenderer::KBSRenderer() 0021 : KGameRenderer(provider()) 0022 { 0023 } 0024 0025 KBSRenderer::~KBSRenderer() 0026 { 0027 } 0028 0029 void KBSRenderer::resize(int sz) 0030 { 0031 resize(QSize(sz, sz)); 0032 } 0033 0034 void KBSRenderer::resize(const QSize& sz) 0035 { 0036 if (m_size != sz) { 0037 m_size = sz; 0038 } 0039 } 0040 0041 QSize KBSRenderer::size() const 0042 { 0043 return m_size; 0044 } 0045 0046 Coord KBSRenderer::toLogical(const QPointF& p) const 0047 { 0048 int x = static_cast<int>(p.x() / m_size.width()); 0049 int y = static_cast<int>(p.y() / m_size.height()); 0050 0051 return Coord(x, y); 0052 } 0053 0054 QPointF KBSRenderer::toReal(const Coord& c) const 0055 { 0056 return QPointF(c.x * m_size.width(), c.y * m_size.height()); 0057 }