You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
458 lines
25 KiB
458 lines
25 KiB
'\" t
|
|
.TH TQCanvas 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
TQCanvas \- 2D area that can contain TQCanvasItem objects
|
|
.SH SYNOPSIS
|
|
\fC#include <tqcanvas.h>\fR
|
|
.PP
|
|
Inherits TQObject.
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "\fBTQCanvas\fR ( TQObject * parent = 0, const char * name = 0 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQCanvas\fR ( int w, int h )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQCanvas\fR ( QPixmap p, int h, int v, int tilewidth, int tileheight )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual \fB~TQCanvas\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetTiles\fR ( QPixmap p, int h, int v, int tilewidth, int tileheight )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetBackgroundPixmap\fR ( const QPixmap & p )"
|
|
.br
|
|
.ti -1c
|
|
.BI "QPixmap \fBbackgroundPixmap\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetBackgroundColor\fR ( const TQColor & c )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQColor \fBbackgroundColor\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetTile\fR ( int x, int y, int tilenum )"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBtile\fR ( int x, int y ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBtilesHorizontally\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBtilesVertically\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBtileWidth\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBtileHeight\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBresize\fR ( int w, int h )"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBwidth\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBheight\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQSize \fBsize\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "QRect \fBrect\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBonCanvas\fR ( int x, int y ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBonCanvas\fR ( const QPoint & p ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBvalidChunk\fR ( int x, int y ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBvalidChunk\fR ( const QPoint & p ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "int \fBchunkSize\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBretune\fR ( int chunksze, int mxclusters = 100 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetAllChanged\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetChanged\fR ( const QRect & area )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetUnchanged\fR ( const QRect & area )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQCanvasItemList \fBallItems\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQCanvasItemList \fBcollisions\fR ( const QPoint & p ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQCanvasItemList \fBcollisions\fR ( const QRect & r ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQCanvasItemList \fBcollisions\fR ( const QPointArray & chunklist, const TQCanvasItem * item, bool exact ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBdrawArea\fR ( const QRect & clip, QPainter * painter, bool dbuf = FALSE )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetAdvancePeriod\fR ( int ms )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetUpdatePeriod\fR ( int ms )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetDoubleBuffering\fR ( bool y )"
|
|
.br
|
|
.in -1c
|
|
.SS "Public Slots"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "virtual void \fBadvance\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBupdate\fR ()"
|
|
.br
|
|
.in -1c
|
|
.SS "Signals"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "void \fBresized\fR ()"
|
|
.br
|
|
.in -1c
|
|
.SS "Protected Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "virtual void \fBdrawBackground\fR ( QPainter & painter, const QRect & clip )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBdrawForeground\fR ( QPainter & painter, const QRect & clip )"
|
|
.br
|
|
.in -1c
|
|
.SH DESCRIPTION
|
|
The TQCanvas class provides a 2D area that can contain TQCanvasItem objects.
|
|
.PP
|
|
The TQCanvas 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 TQCanvasView. Multiple TQCanvasView widgets may be associated with a canvas to provide multiple views of the same canvas.
|
|
.PP
|
|
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.
|
|
.PP
|
|
Qt provides a rich set of canvas item classes, e.g. TQCanvasEllipse, TQCanvasLine, TQCanvasPolygon, TQCanvasPolygonalItem, TQCanvasRectangle, TQCanvasSpline, TQCanvasSprite and TQCanvasText. You can subclass to create your own canvas items; TQCanvasPolygonalItem is the most common base class used for this purpose.
|
|
.PP
|
|
Items appear on the canvas after their show() function has been called (or setVisible(TRUE)), and \fIafter\fR 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.)
|
|
.PP
|
|
If you created the canvas without passing a width and height to the constructor you must also call resize().
|
|
.PP
|
|
Although a canvas may appear to be similar to a widget with child widgets, there are several notable differences:
|
|
.TP
|
|
Canvas items are usually much faster to manipulate and redraw than child widgets, with the speed advantage becoming especially great when there are \fImany\fR canvas items and non-rectangular items. In most situations canvas items are also a lot more memory efficient than child widgets.
|
|
.IP
|
|
.TP
|
|
It's easy to detect overlapping items (collision detection).
|
|
.IP
|
|
.TP
|
|
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 TQCanvas 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).
|
|
.IP
|
|
.TP
|
|
Two or more TQCanvasView objects can view the same canvas.
|
|
.IP
|
|
.TP
|
|
An arbitrary transformation matrix can be set on each TQCanvasView which makes it easy to zoom, rotate or shear the viewed canvas.
|
|
.IP
|
|
.TP
|
|
Widgets provide a lot more functionality, such as input (QKeyEvent, QMouseEvent etc.) and layout management (QGridLayout etc.).
|
|
.IP
|
|
.PP
|
|
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.
|
|
.PP
|
|
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().
|
|
.PP
|
|
Note that TQCanvas does not inherit from TQWidget, even though it has some functions which provide the same functionality as those in TQWidget. One of these is setBackgroundPixmap(); some others are resize(), size(), width() and height(). TQCanvasView is the widget used to display a canvas on the screen.
|
|
.PP
|
|
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 TQCanvasItem::setCanvas().
|
|
.PP
|
|
Canvas items are movable (and in the case of TQCanvasSprites, animated) objects that inherit TQCanvasItem. 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 TQCanvasItem::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.)
|
|
.PP
|
|
Canvas items can be moved with TQCanvasItem::move(). The advance() function moves all TQCanvasItem::animated() canvas items and setAdvancePeriod() makes TQCanvas move them automatically on a periodic basis. In the context of the TQCanvas classes, to `animate' a canvas item is to set it in motion, i.e. using TQCanvasItem::setVelocity(). Animation of a canvas item itself, i.e. items which change over time, is enabled by calling TQCanvasSprite::setFrameAnimation(), or more generally by subclassing and reimplementing TQCanvasItem::advance(). To detect collisions use one of the TQCanvasItem::collisions() functions.
|
|
.PP
|
|
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 TQCanvasItem::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.)
|
|
.PP
|
|
TQCanvas organizes its canvas items into \fIchunks\fR; 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.
|
|
.PP
|
|
The chunk size is a key factor to TQCanvas'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 TQCanvas 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.
|
|
.PP
|
|
The foreground is normally nothing, but if you reimplement drawForeground(), you can draw things in front of all the canvas items.
|
|
.PP
|
|
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().
|
|
.PP
|
|
An area can be copied (painted) to a QPainter with drawArea().
|
|
.PP
|
|
If the canvas is resized it emits the resized() signal.
|
|
.PP
|
|
The examples/canvas application and the 2D graphics page of the examples/demo application demonstrate many of TQCanvas's facilities.
|
|
.PP
|
|
See also TQCanvasView, TQCanvasItem, Abstract Widget Classes, Graphics Classes, and Image Processing Classes.
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "TQCanvas::TQCanvas ( TQObject * parent = 0, const char * name = 0 )"
|
|
Create a TQCanvas with no size. \fIparent\fR and \fIname\fR are passed to the TQObject superclass.
|
|
.PP
|
|
\fBWarning:\fR You \fImust\fR call resize() at some time after creation to be able to use the canvas.
|
|
.SH "TQCanvas::TQCanvas ( int w, int h )"
|
|
Constructs a TQCanvas that is \fIw\fR pixels wide and \fIh\fR pixels high.
|
|
.SH "TQCanvas::TQCanvas ( QPixmap p, int h, int v, int tilewidth, int tileheight )"
|
|
Constructs a TQCanvas which will be composed of \fIh\fR tiles horizontally and \fIv\fR tiles vertically. Each tile will be an image \fItilewidth\fR by \fItileheight\fR pixels taken from pixmap \fIp\fR.
|
|
.PP
|
|
The pixmap \fIp\fR 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.
|
|
.PP
|
|
<center>.nf
|
|
.TS
|
|
l - l. 0 1 2 3 4 5 6
|
|
.TE
|
|
.fi
|
|
</center>
|
|
.PP
|
|
The TQCanvas 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.
|
|
.PP
|
|
See also setTiles().
|
|
.SH "TQCanvas::~TQCanvas ()\fC [virtual]\fR"
|
|
Destroys the canvas and all the canvas's canvas items.
|
|
.SH "void TQCanvas::advance ()\fC [virtual slot]\fR"
|
|
Moves all TQCanvasItem::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().)
|
|
.PP
|
|
The advance takes place in two phases. In phase 0, the TQCanvasItem::advance() function of each TQCanvasItem::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 TQCanvasItem subclasses supplied with TQt do anything interesting in phase 0.
|
|
.PP
|
|
The canvas can be configured to call this function periodically with setAdvancePeriod().
|
|
.PP
|
|
See also update().
|
|
.SH "TQCanvasItemList TQCanvas::allItems ()"
|
|
Returns a list of all the items in the canvas.
|
|
.SH "TQColor TQCanvas::backgroundColor () const"
|
|
Returns the color set by setBackgroundColor(). By default, this is white.
|
|
.PP
|
|
This function is not a reimplementation of TQWidget::backgroundColor() (TQCanvas is not a subclass of TQWidget), but all TQCanvasViews that are viewing the canvas will set their backgrounds to this color.
|
|
.PP
|
|
See also setBackgroundColor() and backgroundPixmap().
|
|
.SH "QPixmap TQCanvas::backgroundPixmap () const"
|
|
Returns the pixmap set by setBackgroundPixmap(). By default, this is a null pixmap.
|
|
.PP
|
|
See also setBackgroundPixmap() and backgroundColor().
|
|
.SH "int TQCanvas::chunkSize () const"
|
|
Returns the chunk size of the canvas.
|
|
.PP
|
|
See also retune().
|
|
.SH "TQCanvasItemList TQCanvas::collisions ( const QPoint & p ) const"
|
|
Returns a list of canvas items that collide with the point \fIp\fR. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item).
|
|
.SH "TQCanvasItemList TQCanvas::collisions ( const QRect & r ) const"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Returns a list of items which collide with the rectangle \fIr\fR. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item).
|
|
.SH "TQCanvasItemList TQCanvas::collisions ( const QPointArray & chunklist, const TQCanvasItem * item, bool exact ) const"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Returns a list of canvas items which intersect with the chunks listed in \fIchunklist\fR, excluding \fIitem\fR. If \fIexact\fR is TRUE, only those which actually collide with \fIitem\fR are returned; otherwise canvas items are included just for being in the chunks.
|
|
.PP
|
|
This is a utility function mainly used to implement the simpler TQCanvasItem::collisions() function.
|
|
.SH "void TQCanvas::drawArea ( const QRect & clip, QPainter * painter, bool dbuf = FALSE )"
|
|
Paints all canvas items that are in the area \fIclip\fR to \fIpainter\fR, using double-buffering if \fIdbuf\fR is TRUE.
|
|
.PP
|
|
e.g. to print the canvas to a printer:
|
|
.PP
|
|
.nf
|
|
.br
|
|
QPrinter pr;
|
|
.br
|
|
if ( pr.setup() ) {
|
|
.br
|
|
QPainter p(&pr);
|
|
.br
|
|
canvas.drawArea( canvas.rect(), &p );
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
.PP
|
|
Example: canvas/canvas.cpp.
|
|
.SH "void TQCanvas::drawBackground ( QPainter & painter, const QRect & clip )\fC [virtual protected]\fR"
|
|
This virtual function is called for all updates of the canvas. It renders any background graphics using the painter \fIpainter\fR, in the area \fIclip\fR. If the canvas has a background pixmap or a tiled background, that graphic is used, otherwise the canvas is cleared using the background color.
|
|
.PP
|
|
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.
|
|
.PP
|
|
See also setBackgroundColor(), setBackgroundPixmap(), and setTiles().
|
|
.SH "void TQCanvas::drawForeground ( QPainter & painter, const QRect & clip )\fC [virtual protected]\fR"
|
|
This virtual function is called for all updates of the canvas. It renders any foreground graphics using the painter \fIpainter\fR, in the area \fIclip\fR.
|
|
.PP
|
|
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.
|
|
.PP
|
|
The default is to draw nothing.
|
|
.SH "int TQCanvas::height () const"
|
|
Returns the height of the canvas, in pixels.
|
|
.PP
|
|
Example: canvas/canvas.cpp.
|
|
.SH "bool TQCanvas::onCanvas ( int x, int y ) const"
|
|
Returns TRUE if the pixel position (\fIx\fR, \fIy\fR) is on the canvas; otherwise returns FALSE.
|
|
.PP
|
|
See also validChunk().
|
|
.SH "bool TQCanvas::onCanvas ( const QPoint & p ) const"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Returns TRUE if the pixel position \fIp\fR is on the canvas; otherwise returns FALSE.
|
|
.PP
|
|
See also validChunk().
|
|
.SH "QRect TQCanvas::rect () const"
|
|
Returns a rectangle the size of the canvas.
|
|
.SH "void TQCanvas::resize ( int w, int h )\fC [virtual]\fR"
|
|
Changes the size of the canvas to have a width of \fIw\fR and a height of \fIh\fR. This is a slow operation.
|
|
.PP
|
|
Examples:
|
|
.)l canvas/canvas.cpp and chart/chartform.cpp.
|
|
.SH "void TQCanvas::resized ()\fC [signal]\fR"
|
|
This signal is emitted whenever the canvas is resized. Each TQCanvasView connects to this signal to keep the scrollview's size correct.
|
|
.SH "void TQCanvas::retune ( int chunksze, int mxclusters = 100 )\fC [virtual]\fR"
|
|
Change the efficiency tuning parameters to \fImxclusters\fR clusters, each of size \fIchunksze\fR. This is a slow operation if there are many objects on the canvas.
|
|
.PP
|
|
The canvas is divided into chunks which are rectangular areas \fIchunksze\fR wide by \fIchunksze\fR 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.
|
|
.PP
|
|
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.
|
|
.PP
|
|
The \fImxclusters\fR 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.
|
|
.SH "void TQCanvas::setAdvancePeriod ( int ms )\fC [virtual]\fR"
|
|
Sets the canvas to call advance() every \fIms\fR milliseconds. Any previous setting by setAdvancePeriod() or setUpdatePeriod() is overridden.
|
|
.PP
|
|
If \fIms\fR is less than 0 advancing will be stopped.
|
|
.PP
|
|
Example: canvas/main.cpp.
|
|
.SH "void TQCanvas::setAllChanged ()\fC [virtual]\fR"
|
|
Marks the whole canvas as changed. All views of the canvas will be entirely redrawn when update() is called next.
|
|
.SH "void TQCanvas::setBackgroundColor ( const TQColor & c )\fC [virtual]\fR"
|
|
Sets the solid background to be the color \fIc\fR.
|
|
.PP
|
|
See also backgroundColor(), setBackgroundPixmap(), and setTiles().
|
|
.SH "void TQCanvas::setBackgroundPixmap ( const QPixmap & p )\fC [virtual]\fR"
|
|
Sets the solid background to be the pixmap \fIp\fR repeated as necessary to cover the entire canvas.
|
|
.PP
|
|
See also backgroundPixmap(), setBackgroundColor(), and setTiles().
|
|
.SH "void TQCanvas::setChanged ( const QRect & area )\fC [virtual]\fR"
|
|
Marks \fIarea\fR as changed. This \fIarea\fR will be redrawn in all views that are showing it when update() is called next.
|
|
.SH "void TQCanvas::setDoubleBuffering ( bool y )\fC [virtual]\fR"
|
|
If \fIy\fR is TRUE (the default) double-buffering is switched on; otherwise double-buffering is switched off.
|
|
.PP
|
|
Turning off double-buffering causes the redrawn areas to flicker a little and also gives a (usually small) performance improvement.
|
|
.PP
|
|
Example: canvas/canvas.cpp.
|
|
.SH "void TQCanvas::setTile ( int x, int y, int tilenum )\fC [virtual]\fR"
|
|
Sets the tile at (\fIx\fR, \fIy\fR) to use tile number \fItilenum\fR, which is an index into the tile pixmaps. The canvas will update appropriately when update() is next called.
|
|
.PP
|
|
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.
|
|
.PP
|
|
<center>.nf
|
|
.TS
|
|
l - l. 0 1 2 3 4 5 6
|
|
.TE
|
|
.fi
|
|
</center>
|
|
.PP
|
|
See also tile() and setTiles().
|
|
.SH "void TQCanvas::setTiles ( QPixmap p, int h, int v, int tilewidth, int tileheight )\fC [virtual]\fR"
|
|
Sets the TQCanvas to be composed of \fIh\fR tiles horizontally and \fIv\fR tiles vertically. Each tile will be an image \fItilewidth\fR by \fItileheight\fR pixels from pixmap \fIp\fR.
|
|
.PP
|
|
The pixmap \fIp\fR 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.
|
|
.PP
|
|
<center>.nf
|
|
.TS
|
|
l - l. 0 1 2 3 4 5 6
|
|
.TE
|
|
.fi
|
|
</center>
|
|
.PP
|
|
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.
|
|
.PP
|
|
The width and height of \fIp\fR must be a multiple of \fItilewidth\fR and \fItileheight\fR. If they are not the function will do nothing.
|
|
.PP
|
|
If you want to unset any tiling set, then just pass in a null pixmap and 0 for \fIh\fR, \fIv\fR, \fItilewidth\fR, and \fItileheight\fR.
|
|
.SH "void TQCanvas::setUnchanged ( const QRect & area )\fC [virtual]\fR"
|
|
Marks \fIarea\fR as \fIunchanged\fR. The area will \fInot\fR be redrawn in the views for the next update(), unless it is marked or changed again before the next call to update().
|
|
.SH "void TQCanvas::setUpdatePeriod ( int ms )\fC [virtual]\fR"
|
|
Sets the canvas to call update() every \fIms\fR milliseconds. Any previous setting by setAdvancePeriod() or setUpdatePeriod() is overridden.
|
|
.PP
|
|
If \fIms\fR is less than 0 automatic updating will be stopped.
|
|
.SH "TQSize TQCanvas::size () const"
|
|
Returns the size of the canvas, in pixels.
|
|
.SH "int TQCanvas::tile ( int x, int y ) const"
|
|
Returns the tile at position (\fIx\fR, \fIy\fR). Initially, all tiles are 0.
|
|
.PP
|
|
The parameters must be within range, i.e. 0 < \fIx\fR < tilesHorizontally() and 0 < \fIy\fR < tilesVertically().
|
|
.PP
|
|
See also setTile().
|
|
.SH "int TQCanvas::tileHeight () const"
|
|
Returns the height of each tile.
|
|
.SH "int TQCanvas::tileWidth () const"
|
|
Returns the width of each tile.
|
|
.SH "int TQCanvas::tilesHorizontally () const"
|
|
Returns the number of tiles horizontally.
|
|
.SH "int TQCanvas::tilesVertically () const"
|
|
Returns the number of tiles vertically.
|
|
.SH "void TQCanvas::update ()\fC [virtual slot]\fR"
|
|
Repaints changed areas in all views of the canvas.
|
|
.PP
|
|
See also advance().
|
|
.SH "bool TQCanvas::validChunk ( int x, int y ) const"
|
|
Returns TRUE if the chunk position (\fIx\fR, \fIy\fR) is on the canvas; otherwise returns FALSE.
|
|
.PP
|
|
See also onCanvas().
|
|
.SH "bool TQCanvas::validChunk ( const QPoint & p ) const"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Returns TRUE if the chunk position \fIp\fR is on the canvas; otherwise returns FALSE.
|
|
.PP
|
|
See also onCanvas().
|
|
.SH "int TQCanvas::width () const"
|
|
Returns the width of the canvas, in pixels.
|
|
.PP
|
|
Example: canvas/canvas.cpp.
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/tqcanvas.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqcanvas.3qt) and the Qt
|
|
version (3.3.8).
|