Q3Canvas Class Reference |
0 | 1 | 2 | 3 |
4 | 5 | 6 | 7 |
The Q3Canvas 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.
See also setTiles().
Destroys the canvas and all the canvas's canvas items.
Moves all Q3CanvasItem::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 Q3CanvasItem::advance() function of each Q3CanvasItem::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 Q3CanvasItem subclasses supplied with Qt do anything interesting in phase 0.
The canvas can be configured to call this function periodically with setAdvancePeriod().
See also update().
Returns a list of all the items in the canvas.
Returns the color set by setBackgroundColor(). By default, this is white.
This function is not a reimplementation of QWidget::backgroundColor() (Q3Canvas is not a subclass of QWidget), but all Q3CanvasViews that are viewing the canvas will set their backgrounds to this color.
See also setBackgroundColor() and backgroundPixmap().
Returns the pixmap set by setBackgroundPixmap(). By default, this is a null pixmap.
See also setBackgroundPixmap() and backgroundColor().
Returns the chunk size of the canvas.
See also retune().
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).
This is an overloaded member function, provided for convenience.
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).
This is an overloaded member function, provided for convenience.
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 Q3CanvasItem::collisions() function.
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); }
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.
See also setBackgroundColor(), setBackgroundPixmap(), and setTiles().
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.
Returns the height of the canvas, in pixels.
Returns true if the pixel position (x, y) is on the canvas; otherwise returns false.
See also validChunk().
This is an overloaded member function, provided for convenience.
Returns true if the pixel position p is on the canvas; otherwise returns false.
See also validChunk().
Returns a rectangle the size of the canvas.
Changes the size of the canvas to have a width of w and a height of h. This is a slow operation.
This signal is emitted whenever the canvas is resized. Each Q3CanvasView connects to this signal to keep the scrollview's size correct.
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.
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.
Marks the whole canvas as changed. All views of the canvas will be entirely redrawn when update() is called next.
Sets the solid background to be the color c.
See also backgroundColor(), setBackgroundPixmap(), and setTiles().
Sets the solid background to be the pixmap p repeated as necessary to cover the entire canvas.
See also backgroundPixmap(), setBackgroundColor(), and setTiles().
Marks area as changed. This area will be redrawn in all views that are showing it when update() is called next.
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.
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 |
See also tile() and setTiles().
Sets the Q3Canvas 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.
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().
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.
Returns the size of the canvas, in pixels.
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().
See also setTile().
Returns the height of each tile.
Returns the width of each tile.
Returns the number of tiles horizontally.
Returns the number of tiles vertically.
Repaints changed areas in all views of the canvas.
See also advance().
Returns true if the chunk position (x, y) is on the canvas; otherwise returns false.
See also onCanvas().
This is an overloaded member function, provided for convenience.
Returns true if the chunk position p is on the canvas; otherwise returns false.
See also onCanvas().
Returns the width of the canvas, in pixels.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.1 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com