• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

libkdegames

KGameCanvasAdapter Class Reference

#include <kgamecanvas.h>

Inheritance diagram for KGameCanvasAdapter:

Inheritance graph
[legend]

List of all members.


Detailed Description

A generic adapter for KGameCanvas.

KGameCanvasAdapter can be used to draw content managed by KGameCanvas inside systems which do not use KGameCanvas internally for their rendering.

For example, suppose you have a widget CustomDisplay which paints itself with direct QPainter calls in its paintEvent, and you want to add a complex element to its rendering, which is best implemented via the KGameCanvas abstractions. What you can do is to create a KGameCanvasAdapter subclass, use it just like a KGameCanvasGroup, then call its render member function to have a QPainter object draw it.

A KGameCanvas adapter notifies its parent using the pure virtual function updateParent, which is called when the adapter content is invalidated.

Todo:
Support animations

Definition at line 593 of file kgamecanvas.h.


Public Member Functions

 KGameCanvasAdapter ()
virtual class KGameCanvasWidget * topLevelCanvas ()
virtual QPoint canvasPosition () const
virtual void render (QPainter *p)
virtual void updateParent (const QRect &rect)=0

Constructor & Destructor Documentation

KGameCanvasAdapter::KGameCanvasAdapter (  ) 

Constructor.

Definition at line 966 of file kgamecanvas.cpp.


Member Function Documentation

virtual class KGameCanvasWidget* KGameCanvasAdapter::topLevelCanvas (  )  [inline, virtual]

An adapter is not associated to any canvas, so this function simply returns 0.

Implements KGameCanvasAbstract.

Definition at line 613 of file kgamecanvas.h.

virtual QPoint KGameCanvasAdapter::canvasPosition (  )  const [inline, virtual]

The absolute position of the rendered content is not well defined for KGameCanvasAdapter.

We assume that the adapter will be rendered at (0,0), and leave it to the user to perform the necessary adjustments, which will depend on the chosen rendering method.

Returns:
The point (0, 0).

Implements KGameCanvasAbstract.

Definition at line 624 of file kgamecanvas.h.

void KGameCanvasAdapter::render ( QPainter *  p  )  [virtual]

Draw the items of the adapter using the specified painter.

Parameters:
p The QPainter object to be used for rendering.

Definition at line 984 of file kgamecanvas.cpp.

virtual void KGameCanvasAdapter::updateParent ( const QRect &  rect  )  [pure virtual]

Notify the parent that the adapter content inside rect needs to be redrawn.

rect The bounding rectangle of the region that needs repainting.


The documentation for this class was generated from the following files:
  • kgamecanvas.h
  • kgamecanvas.cpp

libkdegames

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

API Reference

Skip menu "API Reference"
  • kblackbox
  • kgoldrunner
  • kmahjongg
  • ksquares
  • libkdegames
  •   highscore
  •   kgame
  •   kggzgames
  •   kggzmod
  •   kggznet
  • libkmahjongg
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal