KDEGames

kgamerenderedobjectitem.h
1 /***************************************************************************
2  * Copyright 2010 Stefan Majewsky <[email protected]> *
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 KGAMERENDEREDOBJECTITEM_H
20 #define KGAMERENDEREDOBJECTITEM_H
21 
22 #include <QObject>
23 #include <QGraphicsItem>
24 class QGraphicsView;
25 
26 #include <kgamerendererclient.h>
27 #include <libkdegames_export.h>
28 
29 class KGameRenderedObjectItemPrivate;
30 
60 class KDEGAMES_EXPORT KGameRenderedObjectItem : public QGraphicsObject, public KGameRendererClient
61 {
62  Q_OBJECT
63  Q_PROPERTY(int frame READ frame WRITE setFrame)
64  public:
67  KGameRenderedObjectItem(KGameRenderer* renderer, const QString& spriteKey, QGraphicsItem* parent = nullptr);
68  virtual ~KGameRenderedObjectItem();
69 
72  QPointF offset() const;
75  void setOffset(const QPointF& offset);
77  void setOffset(qreal x, qreal y);
80  QSizeF fixedSize() const;
83  void setFixedSize(const QSizeF& size);
84 
88  QGraphicsView* primaryView() const;
96  void setPrimaryView(QGraphicsView* view);
97 
98  //QGraphicsItem reimplementations (see comment in source file for why we need all of this)
99  QRectF boundingRect() const override;
100  bool contains(const QPointF& point) const override;
101  bool isObscuredBy(const QGraphicsItem* item) const override;
102  QPainterPath opaqueArea() const override;
103  void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
104  QPainterPath shape() const override;
105  protected:
106  void receivePixmap(const QPixmap& pixmap) override;
107  private:
108  friend class KGameRenderedObjectItemPrivate;
109  KGameRenderedObjectItemPrivate* const d;
110 };
111 
112 #endif // KGAMERENDEREDOBJECTITEM_H
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
A QGraphicsObject which displays pixmaps from a KGameRenderer.
virtual QPainterPath opaqueArea() const const
virtual void receivePixmap(const QPixmap &pixmap)=0
This method is called when the KGameRenderer has provided a new pixmap for this client (esp...
Cache-enabled rendering of SVG themes.
Definition: kgamerenderer.h:94
Q_PROPERTY(...)
An object that receives pixmaps from a KGameRenderer.
virtual bool isObscuredBy(const QGraphicsItem *item) const const
virtual QRectF boundingRect() const const =0
virtual QPainterPath shape() const const
virtual bool contains(const QPointF &point) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Nov 30 2020 22:37:54 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.