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

libkdegames

Public Member Functions | Protected Member Functions | Properties | List of all members
KGameRenderedObjectItem Class Reference

#include <KGameRenderedObjectItem>

Inheritance diagram for KGameRenderedObjectItem:
Inheritance graph
[legend]

Public Member Functions

 KGameRenderedObjectItem (KGameRenderer *renderer, const QString &spriteKey, QGraphicsItem *parent=0)
 
virtual ~KGameRenderedObjectItem ()
 
virtual QRectF boundingRect () const
 
virtual bool contains (const QPointF &point) const
 
QSizeF fixedSize () const
 
virtual bool isObscuredBy (const QGraphicsItem *item) const
 
QPointF offset () const
 
virtual QPainterPath opaqueArea () const
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=0)
 
QGraphicsView * primaryView () const
 
void setFixedSize (const QSizeF &size)
 
void setOffset (const QPointF &offset)
 
void setOffset (qreal x, qreal y)
 
void setPrimaryView (QGraphicsView *view)
 
virtual QPainterPath shape () const
 
- Public Member Functions inherited from KGameRendererClient
 KGameRendererClient (KGameRenderer *renderer, const QString &spriteKey)
 
virtual ~KGameRendererClient ()
 
QHash< QColor, QColor > customColors () const
 
int frame () const
 
int frameCount () const
 
KGameRenderer * renderer () const
 
QSize renderSize () const
 
void setCustomColors (const QHash< QColor, QColor > &customColors)
 
void setFrame (int frame)
 
void setRenderSize (const QSize &renderSize)
 
void setSpriteKey (const QString &spriteKey)
 
QString spriteKey () const
 

Protected Member Functions

virtual void receivePixmap (const QPixmap &pixmap)
 

Properties

int frame
 

Detailed Description

A QGraphicsObject which displays pixmaps from a KGameRenderer.

Since
4.6 This item displays a pixmap which is retrieved from a KGameRenderer, and is updated automatically when the KGameRenderer changes the theme.

The item has built-in handling for animated sprites (i.e. those with multiple frames). It is a QGraphicsObject and exposes a "frame" property, so you can easily run the animation by plugging in a QPropertyAnimation.

Modes of operation

By default, this item behaves just like a QGraphicsPixmapItem. The size of its bounding rect is equal to the size of the pixmap, i.e. the renderSize().

However, the KGameRenderedObjectItem has a second mode of operation, which is enabled by setting a "primary view". (This can be done automatically via KGameRenderer::setDefaultPrimaryView.)

If such a primary view is set, the following happens:

  • The renderSize of the pixmap is automatically determined from the painting requests received from the primary view (manual calls to setRenderSize() are unnecessary and need to be avoided).
  • The size of the item's boundingRect() is independent of the renderSize(). The default fixedSize() is 1x1, which means that the item's bounding rect is the unit square (moved by the configured offset()).

Definition at line 60 of file kgamerenderedobjectitem.h.

Constructor & Destructor Documentation

KGameRenderedObjectItem::KGameRenderedObjectItem ( KGameRenderer *  renderer,
const QString &  spriteKey,
QGraphicsItem *  parent = 0 
)

Creates a new KGameRenderedObjectItem which renders the sprite with the given spriteKey as provided by the given renderer.

Definition at line 95 of file kgamerenderedobjectitem.cpp.

KGameRenderedObjectItem::~KGameRenderedObjectItem ( )
virtual

Definition at line 103 of file kgamerenderedobjectitem.cpp.

Member Function Documentation

QRectF KGameRenderedObjectItem::boundingRect ( ) const
virtual

Definition at line 194 of file kgamerenderedobjectitem.cpp.

bool KGameRenderedObjectItem::contains ( const QPointF &  point) const
virtual

Definition at line 199 of file kgamerenderedobjectitem.cpp.

QSizeF KGameRenderedObjectItem::fixedSize ( ) const
Returns
the fixed size of this item (or (-1, -1) if this item has no primary view)

Definition at line 128 of file kgamerenderedobjectitem.cpp.

bool KGameRenderedObjectItem::isObscuredBy ( const QGraphicsItem *  item) const
virtual

Definition at line 204 of file kgamerenderedobjectitem.cpp.

QPointF KGameRenderedObjectItem::offset ( ) const
Returns
the item's offset, which defines the point of the top-left corner of the bounding rect, in local coordinates.

Definition at line 108 of file kgamerenderedobjectitem.cpp.

QPainterPath KGameRenderedObjectItem::opaqueArea ( ) const
virtual

Definition at line 209 of file kgamerenderedobjectitem.cpp.

void KGameRenderedObjectItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget *  widget = 0 
)
virtual

Definition at line 214 of file kgamerenderedobjectitem.cpp.

QGraphicsView * KGameRenderedObjectItem::primaryView ( ) const

Returns a pointer to the current primary view, or 0 if no primary view has been set (which is the default).

See also
setPrimaryView()

Definition at line 142 of file kgamerenderedobjectitem.cpp.

void KGameRenderedObjectItem::receivePixmap ( const QPixmap &  pixmap)
protectedvirtual

This method is called when the KGameRenderer has provided a new pixmap for this client (esp.

after theme changes and after calls to setFrame(), setRenderSize() and setSpriteKey()).

Implements KGameRendererClient.

Definition at line 173 of file kgamerenderedobjectitem.cpp.

void KGameRenderedObjectItem::setFixedSize ( const QSizeF &  size)

Sets the fixed size of this item, i.e.

the guaranteed size of the item. This works only when a primary view has been set.

Definition at line 133 of file kgamerenderedobjectitem.cpp.

void KGameRenderedObjectItem::setOffset ( const QPointF &  offset)

Sets the item's offset, which defines the point of the top-left corner of the bounding rect, in local coordinates.

Definition at line 113 of file kgamerenderedobjectitem.cpp.

void KGameRenderedObjectItem::setOffset ( qreal  x,
qreal  y 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 123 of file kgamerenderedobjectitem.cpp.

void KGameRenderedObjectItem::setPrimaryView ( QGraphicsView *  view)

Sets the primary view of this item.

(See class documentation for what the primary view does.) Pass a null pointer to just disconnect from the current primary view. The fixed size is then reset to (-1, -1). If a primary view is set, the fixed size is initialized to (1, 1).

Warning
While a primary view is set, avoid any manual calls to setRenderSize().
See also
{Modes of operation}

Definition at line 147 of file kgamerenderedobjectitem.cpp.

QPainterPath KGameRenderedObjectItem::shape ( ) const
virtual

Definition at line 219 of file kgamerenderedobjectitem.cpp.

Property Documentation

int KGameRenderedObjectItem::frame
readwrite

Definition at line 63 of file kgamerenderedobjectitem.h.


The documentation for this class was generated from the following files:
  • kgamerenderedobjectitem.h
  • kgamerenderedobjectitem.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:44:35 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