Eneboo - Documentación para desarrolladores
Slots públicos | Señales | Métodos públicos | Métodos protegidos | Amigas
Referencia de la Clase QCanvas

The QCanvas class provides a 2D area that can contain QCanvasItem objects.canvas. Más...

#include <qcanvas.h>

Diagrama de herencias de QCanvas
QObject QObject Qt Qt Qt Qt

Lista de todos los miembros.

Slots públicos

virtual void advance ()
virtual void update ()
virtual void advance ()
virtual void update ()

Señales

void resized ()
void resized ()

Métodos públicos

 QCanvas (QObject *parent=0, const char *name=0)
 QCanvas (int w, int h)
 QCanvas (QPixmap p, int h, int v, int tilewidth, int tileheight)
virtual ~QCanvas ()
virtual void setTiles (QPixmap tiles, int h, int v, int tilewidth, int tileheight)
virtual void setBackgroundPixmap (const QPixmap &p)
QPixmap backgroundPixmap () const
virtual void setBackgroundColor (const QColor &c)
QColor backgroundColor () const
virtual void setTile (int x, int y, int tilenum)
int tile (int x, int y) const
int tilesHorizontally () const
int tilesVertically () const
int tileWidth () const
int tileHeight () const
virtual void resize (int width, int height)
int width () const
int height () const
QSize size () const
QRect rect () const
bool onCanvas (int x, int y) const
bool onCanvas (const QPoint &p) const
bool validChunk (int x, int y) const
bool validChunk (const QPoint &p) const
int chunkSize () const
virtual void retune (int chunksize, int maxclusters=100)
bool sameChunk (int x1, int y1, int x2, int y2) const
virtual void setChangedChunk (int i, int j)
virtual void setChangedChunkContaining (int x, int y)
virtual void setAllChanged ()
virtual void setChanged (const QRect &area)
virtual void setUnchanged (const QRect &area)
void addItemToChunk (QCanvasItem *, int i, int j)
void removeItemFromChunk (QCanvasItem *, int i, int j)
void addItemToChunkContaining (QCanvasItem *, int x, int y)
void removeItemFromChunkContaining (QCanvasItem *, int x, int y)
QCanvasItemList allItems ()
QCanvasItemList collisions (const QPoint &) const
QCanvasItemList collisions (const QRect &) const
QCanvasItemList collisions (const QPointArray &pa, const QCanvasItem *item, bool exact) const
void drawArea (const QRect &, QPainter *p, bool double_buffer=FALSE)
virtual void addView (QCanvasView *)
virtual void removeView (QCanvasView *)
void drawCanvasArea (const QRect &, QPainter *p=0, bool double_buffer=TRUE)
void drawViewArea (QCanvasView *view, QPainter *p, const QRect &r, bool dbuf)
virtual void addItem (QCanvasItem *)
virtual void addAnimation (QCanvasItem *)
virtual void removeItem (QCanvasItem *)
virtual void removeAnimation (QCanvasItem *)
virtual void setAdvancePeriod (int ms)
virtual void setUpdatePeriod (int ms)
virtual void setDoubleBuffering (bool y)
 QCanvas (QObject *parent=0, const char *name=0)
 QCanvas (int w, int h)
 QCanvas (QPixmap p, int h, int v, int tilewidth, int tileheight)
virtual ~QCanvas ()
virtual void setTiles (QPixmap tiles, int h, int v, int tilewidth, int tileheight)
virtual void setBackgroundPixmap (const QPixmap &p)
QPixmap backgroundPixmap () const
virtual void setBackgroundColor (const QColor &c)
QColor backgroundColor () const
virtual void setTile (int x, int y, int tilenum)
int tile (int x, int y) const
int tilesHorizontally () const
int tilesVertically () const
int tileWidth () const
int tileHeight () const
virtual void resize (int width, int height)
int width () const
int height () const
QSize size () const
QRect rect () const
bool onCanvas (int x, int y) const
bool onCanvas (const QPoint &p) const
bool validChunk (int x, int y) const
bool validChunk (const QPoint &p) const
int chunkSize () const
virtual void retune (int chunksize, int maxclusters=100)
bool sameChunk (int x1, int y1, int x2, int y2) const
virtual void setChangedChunk (int i, int j)
virtual void setChangedChunkContaining (int x, int y)
virtual void setAllChanged ()
virtual void setChanged (const QRect &area)
virtual void setUnchanged (const QRect &area)
void addItemToChunk (QCanvasItem *, int i, int j)
void removeItemFromChunk (QCanvasItem *, int i, int j)
void addItemToChunkContaining (QCanvasItem *, int x, int y)
void removeItemFromChunkContaining (QCanvasItem *, int x, int y)
QCanvasItemList allItems ()
QCanvasItemList collisions (const QPoint &) const
QCanvasItemList collisions (const QRect &) const
QCanvasItemList collisions (const QPointArray &pa, const QCanvasItem *item, bool exact) const
void drawArea (const QRect &, QPainter *p, bool double_buffer=FALSE)
virtual void addView (QCanvasView *)
virtual void removeView (QCanvasView *)
void drawCanvasArea (const QRect &, QPainter *p=0, bool double_buffer=TRUE)
void drawViewArea (QCanvasView *view, QPainter *p, const QRect &r, bool dbuf)
virtual void addItem (QCanvasItem *)
virtual void addAnimation (QCanvasItem *)
virtual void removeItem (QCanvasItem *)
virtual void removeAnimation (QCanvasItem *)
virtual void setAdvancePeriod (int ms)
virtual void setUpdatePeriod (int ms)
virtual void setDoubleBuffering (bool y)

Métodos protegidos

virtual void drawBackground (QPainter &, const QRect &area)
virtual void drawForeground (QPainter &, const QRect &area)
virtual void drawBackground (QPainter &, const QRect &area)
virtual void drawForeground (QPainter &, const QRect &area)

Amigas

void qt_unview (QCanvas *c)
void qt_unview (QCanvas *c)

Descripción detallada

The QCanvas class provides a 2D area that can contain QCanvasItem objects.

canvas.

The QCanvas class manages its 2D graphic area and all the canvas items the area contains. The canvas has no visual appearance of its own. Instead, it is displayed on screen using a QCanvasView. Multiple QCanvasView widgets may be associated with a canvas to provide multiple views of the same canvas.

The canvas is optimized for large numbers of items, particularly where only a small percentage of the items change at any one time. If the entire display changes very frequently, you should consider using your own custom QScrollView subclass.

Qt provides a rich set of canvas item classes, e.g. QCanvasEllipse, QCanvasLine, QCanvasPolygon, QCanvasPolygonalItem, QCanvasRectangle, QCanvasSpline, QCanvasSprite and QCanvasText. You can subclass to create your own canvas items; QCanvasPolygonalItem is the most common base class used for this purpose.

Items appear on the canvas after their show() function has been called (or setVisible(TRUE)), and after update() has been called. The canvas only shows items that are visible, and then only if update() is called. (By default the canvas is white and so are canvas items, so if nothing appears try changing colors.)

If you created the canvas without passing a width and height to the constructor you must also call resize().

Although a canvas may appear to be similar to a widget with child widgets, there are several notable differences:

Canvas items are usually much faster to manipulate and redraw than child widgets, with the speed advantage becoming especially great when there are many canvas items and non-rectangular items. In most situations canvas items are also a lot more memory efficient than child widgets.

It's easy to detect overlapping items (collision detection).

The canvas can be larger than a widget. A million-by-million canvas is perfectly possible. At such a size a widget might be very inefficient, and some window systems might not support it at all, whereas QCanvas scales well. Even with a billion pixels and a million items, finding a particular canvas item, detecting collisions, etc., is still fast (though the memory consumption may be prohibitive at such extremes).

Two or more QCanvasView objects can view the same canvas.

An arbitrary transformation matrix can be set on each QCanvasView which makes it easy to zoom, rotate or shear the viewed canvas.

Widgets provide a lot more functionality, such as input (QKeyEvent, QMouseEvent etc.) and layout management (QGridLayout etc.).

A canvas consists of a background, a number of canvas items organized by x, y and z coordinates, and a foreground. A canvas item's z coordinate can be treated as a layer number -- canvas items with a higher z coordinate appear in front of canvas items with a lower z coordinate.

The background is white by default, but can be set to a different color using setBackgroundColor(), or to a repeated pixmap using setBackgroundPixmap() or to a mosaic of smaller pixmaps using setTiles(). Individual tiles can be set with setTile(). There are corresponding get functions, e.g. backgroundColor() and backgroundPixmap().

Note that QCanvas does not inherit from QWidget, even though it has some functions which provide the same functionality as those in QWidget. One of these is setBackgroundPixmap(); some others are resize(), size(), width() and height(). QCanvasView is the widget used to display a canvas on the screen.

Canvas items are added to a canvas by constructing them and passing the canvas to the canvas item's constructor. An item can be moved to a different canvas using QCanvasItem::setCanvas().

Canvas items are movable (and in the case of QCanvasSprites, animated) objects that inherit QCanvasItem. Each canvas item has a position on the canvas (x, y coordinates) and a height (z coordinate), all of which are held as floating-point numbers. Moving canvas items also have x and y velocities. It's possible for a canvas item to be outside the canvas (for example QCanvasItem::x() is greater than width()). When a canvas item is off the canvas, onCanvas() returns FALSE and the canvas disregards the item. (Canvas items off the canvas do not slow down any of the common operations on the canvas.)

Canvas items can be moved with QCanvasItem::move(). The advance() function moves all QCanvasItem::animated() canvas items and setAdvancePeriod() makes QCanvas move them automatically on a periodic basis. In the context of the QCanvas classes, to `animate' a canvas item is to set it in motion, i.e. using QCanvasItem::setVelocity(). Animation of a canvas item itself, i.e. items which change over time, is enabled by calling QCanvasSprite::setFrameAnimation(), or more generally by subclassing and reimplementing QCanvasItem::advance(). To detect collisions use one of the QCanvasItem::collisions() functions.

The changed parts of the canvas are redrawn (if they are visible in a canvas view) whenever update() is called. You can either call update() manually after having changed the contents of the canvas, or force periodic updates using setUpdatePeriod(). If you have moving objects on the canvas, you must call advance() every time the objects should move one step further. Periodic calls to advance() can be forced using setAdvancePeriod(). The advance() function will call QCanvasItem::advance() on every item that is animated and trigger an update of the affected areas afterwards. (A canvas item that is `animated' is simply a canvas item that is in motion.)

QCanvas organizes its canvas items into chunks; these are areas on the canvas that are used to speed up most operations. Many operations start by eliminating most chunks (i.e. those which haven't changed) and then process only the canvas items that are in the few interesting (i.e. changed) chunks. A valid chunk, validChunk(), is one which is on the canvas.

The chunk size is a key factor to QCanvas's speed: if there are too many chunks, the speed benefit of grouping canvas items into chunks is reduced. If the chunks are too large, it takes too long to process each one. The QCanvas constructor tries to pick a suitable size, but you can call retune() to change it at any time. The chunkSize() function returns the current chunk size. The canvas items always make sure they're in the right chunks; all you need to make sure of is that the canvas uses the right chunk size. A good rule of thumb is that the size should be a bit smaller than the average canvas item size. If you have moving objects, the chunk size should be a bit smaller than the average size of the moving items.

The foreground is normally nothing, but if you reimplement drawForeground(), you can draw things in front of all the canvas items.

Areas can be set as changed with setChanged() and set unchanged with setUnchanged(). The entire canvas can be set as changed with setAllChanged(). A list of all the items on the canvas is returned by allItems().

An area can be copied (painted) to a QPainter with drawArea().

If the canvas is resized it emits the resized() signal.

The examples/canvas application and the 2D graphics page of the examples/demo application demonstrate many of QCanvas's facilities.

Ver también:
QCanvasView QCanvasItem

Documentación del constructor y destructor

QCanvas::QCanvas ( QObject parent = 0,
const char *  name = 0 
)

Create a QCanvas with no size. parent and name are passed to the QObject superclass.

Atención:
You must call resize() at some time after creation to be able to use the canvas.
QCanvas::QCanvas ( int  w,
int  h 
)

Constructs a QCanvas that is w pixels wide and h pixels high.

QCanvas::QCanvas ( QPixmap  p,
int  h,
int  v,
int  tilewidth,
int  tileheight 
)

Constructs a QCanvas which will be composed of h tiles horizontally and v tiles vertically. Each tile will be an image tilewidth by tileheight pixels taken from pixmap p.

The pixmap p is a list of tiles, arranged left to right, (and in the case of pixmaps that have multiple rows of tiles, top to bottom), with tile 0 in the top-left corner, tile 1 next to the right, and so on, e.g.

0 1 2 3 4 5 6 7

The QCanvas is initially sized to show exactly the given number of tiles horizontally and vertically. If it is resized to be larger, the entire matrix of tiles will be repeated as often as necessary to cover the area. If it is smaller, tiles to the right and bottom will not be visible.

Ver también:
setTiles()
QCanvas::~QCanvas ( ) [virtual]

Destroys the canvas and all the canvas's canvas items.

QCanvas::QCanvas ( QObject parent = 0,
const char *  name = 0 
)
QCanvas::QCanvas ( int  w,
int  h 
)
QCanvas::QCanvas ( QPixmap  p,
int  h,
int  v,
int  tilewidth,
int  tileheight 
)
virtual QCanvas::~QCanvas ( ) [virtual]

Documentación de las funciones miembro

void QCanvas::addAnimation ( QCanvasItem item) [virtual]
virtual void QCanvas::addAnimation ( QCanvasItem ) [virtual]
void QCanvas::addItem ( QCanvasItem item) [virtual]
virtual void QCanvas::addItem ( QCanvasItem ) [virtual]
void QCanvas::addItemToChunk ( QCanvasItem ,
int  i,
int  j 
)
void QCanvas::addItemToChunk ( QCanvasItem g,
int  i,
int  j 
)
void QCanvas::addItemToChunkContaining ( QCanvasItem ,
int  x,
int  y 
)
void QCanvas::addItemToChunkContaining ( QCanvasItem g,
int  x,
int  y 
)
void QCanvas::addView ( QCanvasView view) [virtual]
virtual void QCanvas::addView ( QCanvasView ) [virtual]
void QCanvas::advance ( ) [virtual, slot]

Moves all QCanvasItem::animated() canvas items on the canvas and refreshes all changes to all views of the canvas. (An `animated' item is an item that is in motion; see setVelocity().)

The advance takes place in two phases. In phase 0, the QCanvasItem::advance() function of each QCanvasItem::animated() canvas item is called with paramater 0. Then all these canvas items are called again, with parameter 1. In phase 0, the canvas items should not change position, merely examine other items on the canvas for which special processing is required, such as collisions between items. In phase 1, all canvas items should change positions, ignoring any other items on the canvas. This two-phase approach allows for considerations of "fairness", although no QCanvasItem subclasses supplied with Qt do anything interesting in phase 0.

The canvas can be configured to call this function periodically with setAdvancePeriod().

Ver también:
update()
virtual void QCanvas::advance ( ) [virtual, slot]
QCanvasItemList QCanvas::allItems ( )

Returns a list of all the items in the canvas.

QCanvasItemList QCanvas::allItems ( )
QColor QCanvas::backgroundColor ( ) const

Returns the color set by setBackgroundColor(). By default, this is white.

This function is not a reimplementation of QWidget::backgroundColor() (QCanvas is not a subclass of QWidget), but all QCanvasViews that are viewing the canvas will set their backgrounds to this color.

Ver también:
setBackgroundColor(), backgroundPixmap()
QColor QCanvas::backgroundColor ( ) const
QPixmap QCanvas::backgroundPixmap ( ) const

Returns the pixmap set by setBackgroundPixmap(). By default, this is a null pixmap.

Ver también:
setBackgroundPixmap(), backgroundColor()
QPixmap QCanvas::backgroundPixmap ( ) const
int QCanvas::chunkSize ( ) const [inline]
int QCanvas::chunkSize ( ) const [inline]

Returns the chunk size of the canvas.

Ver también:
retune()
QCanvasItemList QCanvas::collisions ( const QPoint p) const

Returns a list of canvas items that collide with the point p. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item).

QCanvasItemList QCanvas::collisions ( const QRect r) const

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns a list of items which collide with the rectangle r. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item).

QCanvasItemList QCanvas::collisions ( const QPointArray chunklist,
const QCanvasItem item,
bool  exact 
) const

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns a list of canvas items which intersect with the chunks listed in chunklist, excluding item. If exact is TRUE, only those which actually collide with item are returned; otherwise canvas items are included just for being in the chunks.

This is a utility function mainly used to implement the simpler QCanvasItem::collisions() function.

QCanvasItemList QCanvas::collisions ( const QPoint ) const
QCanvasItemList QCanvas::collisions ( const QRect ) const
QCanvasItemList QCanvas::collisions ( const QPointArray pa,
const QCanvasItem item,
bool  exact 
) const
void QCanvas::drawArea ( const QRect clip,
QPainter painter,
bool  dbuf = FALSE 
)

Paints all canvas items that are in the area clip to painter, using double-buffering if dbuf is TRUE.

e.g. to print the canvas to a printer:

    QPrinter pr;
    if ( pr.setup() ) {
        QPainter p(&pr);
        canvas.drawArea( canvas.rect(), &p );
    }
void QCanvas::drawArea ( const QRect ,
QPainter p,
bool  double_buffer = FALSE 
)
void QCanvas::drawBackground ( QPainter painter,
const QRect clip 
) [protected, virtual]

This virtual function is called for all updates of the canvas. It renders any background graphics using the painter painter, in the area clip. If the canvas has a background pixmap or a tiled background, that graphic is used, otherwise the canvas is cleared using the background color.

If the graphics for an area change, you must explicitly call setChanged(const QRect&) for the result to be visible when update() is next called.

Ver también:
setBackgroundColor(), setBackgroundPixmap(), setTiles()
virtual void QCanvas::drawBackground ( QPainter ,
const QRect area 
) [protected, virtual]
void QCanvas::drawCanvasArea ( const QRect inarea,
QPainter p = 0,
bool  double_buffer = TRUE 
)
void QCanvas::drawCanvasArea ( const QRect ,
QPainter p = 0,
bool  double_buffer = TRUE 
)
void QCanvas::drawForeground ( QPainter painter,
const QRect clip 
) [protected, virtual]

This virtual function is called for all updates of the canvas. It renders any foreground graphics using the painter painter, in the area clip.

If the graphics for an area change, you must explicitly call setChanged(const QRect&) for the result to be visible when update() is next called.

The default is to draw nothing.

virtual void QCanvas::drawForeground ( QPainter ,
const QRect area 
) [protected, virtual]
void QCanvas::drawViewArea ( QCanvasView view,
QPainter p,
const QRect r,
bool  dbuf 
)
void QCanvas::drawViewArea ( QCanvasView view,
QPainter p,
const QRect r,
bool  dbuf 
)
int QCanvas::height ( ) const [inline]
int QCanvas::height ( ) const [inline]

Returns the height of the canvas, in pixels.

bool QCanvas::onCanvas ( int  x,
int  y 
) const [inline]

Returns TRUE if the pixel position (x, y) is on the canvas; otherwise returns FALSE.

Ver también:
validChunk()
bool QCanvas::onCanvas ( int  x,
int  y 
) const [inline]
bool QCanvas::onCanvas ( const QPoint p) const [inline]
bool QCanvas::onCanvas ( const QPoint p) const [inline]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns TRUE if the pixel position p is on the canvas; otherwise returns FALSE.

Ver también:
validChunk()
QRect QCanvas::rect ( ) const [inline]

Returns a rectangle the size of the canvas.

QRect QCanvas::rect ( ) const [inline]
void QCanvas::removeAnimation ( QCanvasItem item) [virtual]
virtual void QCanvas::removeAnimation ( QCanvasItem ) [virtual]
void QCanvas::removeItem ( QCanvasItem item) [virtual]
virtual void QCanvas::removeItem ( QCanvasItem ) [virtual]
void QCanvas::removeItemFromChunk ( QCanvasItem ,
int  i,
int  j 
)
void QCanvas::removeItemFromChunk ( QCanvasItem g,
int  i,
int  j 
)
void QCanvas::removeItemFromChunkContaining ( QCanvasItem g,
int  x,
int  y 
)
void QCanvas::removeItemFromChunkContaining ( QCanvasItem ,
int  x,
int  y 
)
void QCanvas::removeView ( QCanvasView view) [virtual]
virtual void QCanvas::removeView ( QCanvasView ) [virtual]
virtual void QCanvas::resize ( int  width,
int  height 
) [virtual]
void QCanvas::resize ( int  w,
int  h 
) [virtual]

Changes the size of the canvas to have a width of w and a height of h. This is a slow operation.

void QCanvas::resized ( ) [signal]

This signal is emitted whenever the canvas is resized. Each QCanvasView connects to this signal to keep the scrollview's size correct.

void QCanvas::resized ( ) [signal]
virtual void QCanvas::retune ( int  chunksize,
int  maxclusters = 100 
) [virtual]
void QCanvas::retune ( int  chunksze,
int  mxclusters = 100 
) [virtual]

Change the efficiency tuning parameters to mxclusters clusters, each of size chunksze. This is a slow operation if there are many objects on the canvas.

The canvas is divided into chunks which are rectangular areas chunksze wide by chunksze high. Use a chunk size which is about the average size of the canvas items. If you choose a chunk size which is too small it will increase the amount of calculation required when drawing since each change will affect many chunks. If you choose a chunk size which is too large the amount of drawing required will increase because for each change, a lot of drawing will be required since there will be many (unchanged) canvas items which are in the same chunk as the changed canvas items.

Internally, a canvas uses a low-resolution "chunk matrix" to keep track of all the items in the canvas. A 64x64 chunk matrix is the default for a 1024x1024 pixel canvas, where each chunk collects canvas items in a 16x16 pixel square. This default is also affected by setTiles(). You can tune this default using this function. For example if you have a very large canvas and want to trade off speed for memory then you might set the chunk size to 32 or 64.

The mxclusters argument is the number of rectangular groups of chunks that will be separately drawn. If the canvas has a large number of small, dispersed items, this should be about that number. Our testing suggests that a large number of clusters is almost always best.

bool QCanvas::sameChunk ( int  x1,
int  y1,
int  x2,
int  y2 
) const [inline]
bool QCanvas::sameChunk ( int  x1,
int  y1,
int  x2,
int  y2 
) const [inline]
virtual void QCanvas::setAdvancePeriod ( int  ms) [virtual]
void QCanvas::setAdvancePeriod ( int  ms) [virtual]

Sets the canvas to call advance() every ms milliseconds. Any previous setting by setAdvancePeriod() or setUpdatePeriod() is overridden.

If ms is less than 0 advancing will be stopped.

virtual void QCanvas::setAllChanged ( ) [virtual]
void QCanvas::setAllChanged ( ) [virtual]

Marks the whole canvas as changed. All views of the canvas will be entirely redrawn when update() is called next.

void QCanvas::setBackgroundColor ( const QColor c) [virtual]

Sets the solid background to be the color c.

Ver también:
backgroundColor(), setBackgroundPixmap(), setTiles()
virtual void QCanvas::setBackgroundColor ( const QColor c) [virtual]
void QCanvas::setBackgroundPixmap ( const QPixmap p) [virtual]

Sets the solid background to be the pixmap p repeated as necessary to cover the entire canvas.

Ver también:
backgroundPixmap(), setBackgroundColor(), setTiles()
virtual void QCanvas::setBackgroundPixmap ( const QPixmap p) [virtual]
virtual void QCanvas::setChanged ( const QRect area) [virtual]
void QCanvas::setChanged ( const QRect area) [virtual]

Marks area as changed. This area will be redrawn in all views that are showing it when update() is called next.

virtual void QCanvas::setChangedChunk ( int  i,
int  j 
) [virtual]
void QCanvas::setChangedChunk ( int  i,
int  j 
) [virtual]
virtual void QCanvas::setChangedChunkContaining ( int  x,
int  y 
) [virtual]
void QCanvas::setChangedChunkContaining ( int  x,
int  y 
) [virtual]
virtual void QCanvas::setDoubleBuffering ( bool  y) [virtual]
void QCanvas::setDoubleBuffering ( bool  y) [virtual]

If y is TRUE (the default) double-buffering is switched on; otherwise double-buffering is switched off.

Turning off double-buffering causes the redrawn areas to flicker a little and also gives a (usually small) performance improvement.

virtual void QCanvas::setTile ( int  x,
int  y,
int  tilenum 
) [virtual]
void QCanvas::setTile ( int  x,
int  y,
int  tilenum 
) [virtual]

Sets the tile at (x, y) to use tile number tilenum, which is an index into the tile pixmaps. The canvas will update appropriately when update() is next called.

The images are taken from the pixmap set by setTiles() and are arranged left to right, (and in the case of pixmaps that have multiple rows of tiles, top to bottom), with tile 0 in the top-left corner, tile 1 next to the right, and so on, e.g.

0 1 2 3 4 5 6 7

Ver también:
tile() setTiles()
void QCanvas::setTiles ( QPixmap  p,
int  h,
int  v,
int  tilewidth,
int  tileheight 
) [virtual]

Sets the QCanvas to be composed of h tiles horizontally and v tiles vertically. Each tile will be an image tilewidth by tileheight pixels from pixmap p.

The pixmap p is a list of tiles, arranged left to right, (and in the case of pixmaps that have multiple rows of tiles, top to bottom), with tile 0 in the top-left corner, tile 1 next to the right, and so on, e.g.

0 1 2 3 4 5 6 7

If the canvas is larger than the matrix of tiles, the entire matrix is repeated as necessary to cover the whole canvas. If it is smaller, tiles to the right and bottom are not visible.

The width and height of p must be a multiple of tilewidth and tileheight. If they are not the function will do nothing.

If you want to unset any tiling set, then just pass in a null pixmap and 0 for h, v, tilewidth, and tileheight.

virtual void QCanvas::setTiles ( QPixmap  tiles,
int  h,
int  v,
int  tilewidth,
int  tileheight 
) [virtual]
virtual void QCanvas::setUnchanged ( const QRect area) [virtual]
void QCanvas::setUnchanged ( const QRect area) [virtual]

Marks area as unchanged. The area will not be redrawn in the views for the next update(), unless it is marked or changed again before the next call to update().

virtual void QCanvas::setUpdatePeriod ( int  ms) [virtual]
void QCanvas::setUpdatePeriod ( int  ms) [virtual]

Sets the canvas to call update() every ms milliseconds. Any previous setting by setAdvancePeriod() or setUpdatePeriod() is overridden.

If ms is less than 0 automatic updating will be stopped.

QSize QCanvas::size ( ) const [inline]
QSize QCanvas::size ( ) const [inline]

Returns the size of the canvas, in pixels.

int QCanvas::tile ( int  x,
int  y 
) const [inline]

Returns the tile at position (x, y). Initially, all tiles are 0.

The parameters must be within range, i.e. 0 < x < tilesHorizontally() and 0 < y < tilesVertically().

Ver también:
setTile()
int QCanvas::tile ( int  x,
int  y 
) const [inline]
int QCanvas::tileHeight ( ) const [inline]
int QCanvas::tileHeight ( ) const [inline]

Returns the height of each tile.

int QCanvas::tilesHorizontally ( ) const [inline]
int QCanvas::tilesHorizontally ( ) const [inline]

Returns the number of tiles horizontally.

int QCanvas::tilesVertically ( ) const [inline]
int QCanvas::tilesVertically ( ) const [inline]

Returns the number of tiles vertically.

int QCanvas::tileWidth ( ) const [inline]

Returns the width of each tile.

int QCanvas::tileWidth ( ) const [inline]
virtual void QCanvas::update ( ) [virtual, slot]
void QCanvas::update ( ) [virtual, slot]

Repaints changed areas in all views of the canvas.

Ver también:
advance()
bool QCanvas::validChunk ( const QPoint p) const [inline]
bool QCanvas::validChunk ( const QPoint p) const [inline]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Returns TRUE if the chunk position p is on the canvas; otherwise returns FALSE.

Ver también:
onCanvas()
bool QCanvas::validChunk ( int  x,
int  y 
) const [inline]
bool QCanvas::validChunk ( int  x,
int  y 
) const [inline]

Returns TRUE if the chunk position (x, y) is on the canvas; otherwise returns FALSE.

Ver también:
onCanvas()
int QCanvas::width ( ) const [inline]

Returns the width of the canvas, in pixels.

int QCanvas::width ( ) const [inline]

Documentación de las funciones relacionadas y clases amigas

void qt_unview ( QCanvas c) [friend]
void qt_unview ( QCanvas c) [friend]

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'