• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames

  • sources
  • kde-4.14
  • kdegames
  • libkdegames
kgamerenderer.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright 2010-2012 Stefan Majewsky <majewsky@gmx.net> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU Library General Public License *
6  * version 2 as published by the Free Software Foundation *
7  * *
8  * This program is distributed in the hope that it will be useful, *
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11  * GNU Library General Public License for more details. *
12  * *
13  * You should have received a copy of the GNU Library General Public *
14  * License along with this program; if not, write to the *
15  * Free Software Foundation, Inc., *
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
17  ***************************************************************************/
18 
19 #ifndef KGAMERENDERER_H
20 #define KGAMERENDERER_H
21 
22 class QGraphicsView;
23 #include <QtCore/QHash>
24 #include <QtCore/QObject>
25 #include <QtGui/QPixmap>
26 
27 #include <libkdegames_export.h>
28 
29 class KGameRendererPrivate;
30 class KGameRendererClient;
31 class KGameRendererClientPrivate;
32 class KgTheme;
33 class KgThemeProvider;
34 
35 #ifndef KDEGAMES_QCOLOR_QHASH
36 # define KDEGAMES_QCOLOR_QHASH
37  inline uint qHash(const QColor& color)
38  {
39  return color.rgba();
40  }
41 #endif // KDEGAMES_QCOLOR_QHASH
42 
94 class KDEGAMES_EXPORT KGameRenderer : public QObject
95 {
96  Q_OBJECT
97  Q_PROPERTY(const KgTheme* theme READ theme NOTIFY themeChanged)
98  Q_PROPERTY(KgThemeProvider* themeProvider READ themeProvider NOTIFY readOnlyProperty)
99  public:
103  enum Strategy
104  {
109  UseDiskCache = 1 << 0,
113  UseRenderingThreads = 1 << 1
114  };
115  Q_DECLARE_FLAGS(Strategies, Strategy)
116 
117 
118  explicit KGameRenderer(KgThemeProvider* prov, unsigned cacheSize = 0);
125  explicit KGameRenderer(KgTheme* theme, unsigned cacheSize = 0);
127  virtual ~KGameRenderer();
128 
132  QGraphicsView* defaultPrimaryView() const;
137  void setDefaultPrimaryView(QGraphicsView* view);
139  int frameBaseIndex() const;
149  void setFrameBaseIndex(int frameBaseIndex);
151  QString frameSuffix() const;
161  void setFrameSuffix(const QString& suffix);
164  Strategies strategies() const;
173  void setStrategyEnabled(Strategy strategy, bool enabled = true);
174 
176  const KgTheme* theme() const;
179  KgThemeProvider* themeProvider() const;
180 
184  QRectF boundsOnSprite(const QString& key, int frame = -1) const;
197  int frameCount(const QString& key) const;
200  bool spriteExists(const QString& key) const;
211 
212  // The parentheses around QHash<QColor, QColor>() avoid compile
213  // errors on platforms with older gcc versions, e.g. OS X 10.6.
214  QPixmap spritePixmap(const QString& key, const QSize& size, int frame = -1, const QHash<QColor, QColor>& customColors = (QHash<QColor, QColor>())) const;
215  Q_SIGNALS:
216  void themeChanged(const KgTheme* theme);
219  void readOnlyProperty();
220  private:
221  friend class KGameRendererPrivate;
222  friend class KGameRendererClient;
223  friend class KGameRendererClientPrivate;
224  KGameRendererPrivate* const d;
225  Q_PRIVATE_SLOT(d, void _k_setTheme(const KgTheme*));
226 };
227 
228 Q_DECLARE_OPERATORS_FOR_FLAGS(KGameRenderer::Strategies)
229 
230 #endif // KGAMERENDERER_H
KGameRendererPrivate
Definition: kgamerenderer_p.h:107
libkdegames_export.h
KgThemeProvider
A theme provider manages KgTheme instances, and maintains a selection of the currentTheme().
Definition: kgthemeprovider.h:39
KDEGAMES_EXPORT
#define KDEGAMES_EXPORT
Definition: libkdegames_export.h:32
QHash
QObject
KGameRenderer
Cache-enabled rendering of SVG themes.
Definition: kgamerenderer.h:94
qHash
uint qHash(const QColor &color)
Definition: kgamerenderer.h:37
QString
QColor
QPixmap
QSize
KGameRendererClient
An object that receives pixmaps from a KGameRenderer.
Definition: kgamerendererclient.h:50
KGameRenderer::Strategy
Strategy
Describes the various strategies which KGameRenderer can use to speed up rendering.
Definition: kgamerenderer.h:103
QRectF
KGameRendererClientPrivate
Definition: kgamerenderer_p.h:163
KgTheme
A theme describes the visual appearance of a game.
Definition: kgtheme.h:68
QGraphicsView
QColor::rgba
QRgb rgba() const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:18:42 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames

Skip menu "libkdegames"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal