KGameCanvasItem

Search for usage in LXR

KGameCanvasItem Class Referenceabstract

#include <KGameCanvas>

Inheritance diagram for KGameCanvasItem:

Public Member Functions

 KGameCanvasItem (KGameCanvasAbstract *canvas=nullptr)
 
QPoint absolutePosition () const
 
virtual void advance (int msecs)
 
bool animated () const
 
KGameCanvasAbstractcanvas () const
 
virtual void changed ()
 
void hide ()
 
virtual bool layered () const
 
void lower ()
 
void moveTo (const QPoint &newpos)
 
void moveTo (int x, int y)
 
int opacity () const
 
virtual void paint (QPainter *p)=0
 
QPoint pos () const
 
void putInCanvas (KGameCanvasAbstract *canvas)
 
void raise ()
 
virtual QRect rect () const =0
 
void setAnimated (bool a)
 
void setOpacity (int o)
 
void setVisible (bool v)
 
void show ()
 
void stackOver (KGameCanvasItem *ref)
 
void stackUnder (KGameCanvasItem *ref)
 
KGameCanvasWidgettopLevelCanvas () const
 
bool visible () const
 

Detailed Description

An abstract item.

A KGameCanvasItem is an abstract class to represent a generic item that can be put in a canvas.

Deprecated:
For new applications, use Qt's Graphics View framework or Qt Quick.

Definition at line 104 of file kgamecanvas.h.

Constructor & Destructor Documentation

◆ KGameCanvasItem()

KGameCanvasItem::KGameCanvasItem ( KGameCanvasAbstract canvas = nullptr)
explicit

Constructor, it allows you to specify the reference canvas or to create an orphan item that will be put into a canvas in a second moment.

The item is always hidden after being created. Note that the restacking functions are quite intelligent and will only repaint if there is an actual need of doing it. So if you call raise on an item that is already (locally) on the top, no redraw will take place

Definition at line 231 of file kgamecanvas.cpp.

Member Function Documentation

◆ absolutePosition()

QPoint KGameCanvasItem::absolutePosition ( ) const
Returns
Position of the item relative to the top level canvas.

Definition at line 513 of file kgamecanvas.cpp.

◆ advance()

void KGameCanvasItem::advance ( int  msecs)
virtual

Override this function to handle animations, the default function does nothing.

The argument is the number of milliseconds from the creation of the canvas, so that you use it to handle the animation.

Reimplemented in KGameCanvasGroup.

Definition at line 410 of file kgamecanvas.cpp.

◆ animated()

bool KGameCanvasItem::animated ( ) const
inline

Returns true if the item is animated.

Definition at line 154 of file kgamecanvas.h.

◆ canvas()

KGameCanvasAbstract* KGameCanvasItem::canvas ( ) const
inline

Returns the canvas that is actually "owning" the item.

Definition at line 196 of file kgamecanvas.h.

◆ changed()

void KGameCanvasItem::changed ( )
virtual

schedule an update if the item

Definition at line 254 of file kgamecanvas.cpp.

◆ hide()

void KGameCanvasItem::hide ( )
inline

Hides the item.

Definition at line 172 of file kgamecanvas.h.

◆ layered()

bool KGameCanvasItem::layered ( ) const
virtual

Override this function to specify if the painting operations will paint over each other.

If not, the item will be drawn more quickly when opacity is != 255, because it does not have to be painted onto a pixmap first. If you don't care about the item's opacity, don't care about this function as well.

Reimplemented in KGameCanvasText, KGameCanvasRectangle, KGameCanvasTiledPixmap, and KGameCanvasPixmap.

Definition at line 405 of file kgamecanvas.cpp.

◆ lower()

void KGameCanvasItem::lower ( )

Restacks the item on the bottom of the canvas.

Definition at line 445 of file kgamecanvas.cpp.

◆ moveTo() [1/2]

void KGameCanvasItem::moveTo ( const QPoint newpos)

Sets a new position.

Note that an update will be posted to the parent canvas, and if you move an item twice in very little time, a region bigger than needed will be updated, causing a possible inefficiency

Definition at line 504 of file kgamecanvas.cpp.

◆ moveTo() [2/2]

void KGameCanvasItem::moveTo ( int  x,
int  y 
)
inline

Overload, same as above.

Definition at line 226 of file kgamecanvas.h.

◆ opacity()

int KGameCanvasItem::opacity ( ) const
inline

Returns the opacity of the item.

Definition at line 163 of file kgamecanvas.h.

◆ paint()

virtual void KGameCanvasItem::paint ( QPainter p)
pure virtual

Override this function to draw the item with the painter.

Implemented in KGameCanvasText, KGameCanvasRectangle, KGameCanvasTiledPixmap, KGameCanvasPixmap, KGameCanvasPicture, KGameCanvasGroup, and KGameCanvasDummy.

◆ pos()

QPoint KGameCanvasItem::pos ( ) const
inline

Returns the position of the item.

Definition at line 212 of file kgamecanvas.h.

◆ putInCanvas()

void KGameCanvasItem::putInCanvas ( KGameCanvasAbstract canvas)

Lets you specify the owning canvas.

Call this function with canvas set to NULL to remove the item from the current canvas.

Definition at line 336 of file kgamecanvas.cpp.

◆ raise()

void KGameCanvasItem::raise ( )

Restacks the item on the top of the canvas.

Definition at line 433 of file kgamecanvas.cpp.

◆ rect()

virtual QRect KGameCanvasItem::rect ( ) const
pure virtual

Override this function to return the rect the item will be drawn into.

Implemented in KGameCanvasText, KGameCanvasRectangle, KGameCanvasTiledPixmap, KGameCanvasPixmap, KGameCanvasPicture, KGameCanvasGroup, and KGameCanvasDummy.

◆ setAnimated()

void KGameCanvasItem::setAnimated ( bool  a)

Set the item as animated or not.

Definition at line 378 of file kgamecanvas.cpp.

◆ setOpacity()

void KGameCanvasItem::setOpacity ( int  o)

Set the item's opacity value (int the 0-255 range)

Definition at line 393 of file kgamecanvas.cpp.

◆ setVisible()

void KGameCanvasItem::setVisible ( bool  v)

Set the item as visible or hidden.

Definition at line 362 of file kgamecanvas.cpp.

◆ show()

void KGameCanvasItem::show ( )
inline

Shows the item.

Definition at line 178 of file kgamecanvas.h.

◆ stackOver()

void KGameCanvasItem::stackOver ( KGameCanvasItem ref)

Restacks the item immediately over ref.

Definition at line 458 of file kgamecanvas.cpp.

◆ stackUnder()

void KGameCanvasItem::stackUnder ( KGameCanvasItem ref)

Restacks the item immediately under ref.

Definition at line 481 of file kgamecanvas.cpp.

◆ topLevelCanvas()

KGameCanvasWidget* KGameCanvasItem::topLevelCanvas ( ) const
inline

Returns the toplevel canvas widget, or NULL.

Definition at line 202 of file kgamecanvas.h.

◆ visible()

bool KGameCanvasItem::visible ( ) const
inline

Returns true if the item is visible.

Definition at line 145 of file kgamecanvas.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Fri Sep 29 2023 03:48:36 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.