~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/q3canvas.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/qt3support/canvas/q3canvas.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: Q3Canvas Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3Canvas Class Reference</h1>
 
21
<p>The Q3Canvas class provides a 2D area that can contain <a href="q3canvasitem.html">Q3CanvasItem</a> objects. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;Q3Canvas&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
 
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
 
24
<p>Inherits <a href="qobject.html">QObject</a>.</p>
 
25
<ul>
 
26
<li><a href="q3canvas-members.html">List of all members, including inherited members</a></li>
 
27
</ul>
 
28
<a name="public-functions"></a>
 
29
<h3>Public Functions</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="q3canvas.html#Q3Canvas">Q3Canvas</a></b> ( QObject * <i>parent</i> = 0, const char * <i>name</i> = 0 )</li>
 
32
<li><div class="fn"/><b><a href="q3canvas.html#Q3Canvas-2">Q3Canvas</a></b> ( int <i>w</i>, int <i>h</i> )</li>
 
33
<li><div class="fn"/><b><a href="q3canvas.html#Q3Canvas-3">Q3Canvas</a></b> ( QPixmap <i>p</i>, int <i>h</i>, int <i>v</i>, int <i>tilewidth</i>, int <i>tileheight</i> )</li>
 
34
<li><div class="fn"/>virtual <b><a href="q3canvas.html#dtor.Q3Canvas">~Q3Canvas</a></b> ()</li>
 
35
<li><div class="fn"/>Q3CanvasItemList <b><a href="q3canvas.html#allItems">allItems</a></b> ()</li>
 
36
<li><div class="fn"/>QColor <b><a href="q3canvas.html#backgroundColor">backgroundColor</a></b> () const</li>
 
37
<li><div class="fn"/>QPixmap <b><a href="q3canvas.html#backgroundPixmap">backgroundPixmap</a></b> () const</li>
 
38
<li><div class="fn"/>int <b><a href="q3canvas.html#chunkSize">chunkSize</a></b> () const</li>
 
39
<li><div class="fn"/>Q3CanvasItemList <b><a href="q3canvas.html#collisions">collisions</a></b> ( const QPoint &amp; <i>p</i> ) const</li>
 
40
<li><div class="fn"/>Q3CanvasItemList <b><a href="q3canvas.html#collisions-2">collisions</a></b> ( const QRect &amp; <i>r</i> ) const</li>
 
41
<li><div class="fn"/>Q3CanvasItemList <b><a href="q3canvas.html#collisions-3">collisions</a></b> ( const Q3PointArray &amp; <i>chunklist</i>, const Q3CanvasItem * <i>item</i>, bool <i>exact</i> ) const</li>
 
42
<li><div class="fn"/>void <b><a href="q3canvas.html#drawArea">drawArea</a></b> ( const QRect &amp; <i>clip</i>, QPainter * <i>painter</i>, bool <i>dbuf</i> = false )</li>
 
43
<li><div class="fn"/>int <b><a href="q3canvas.html#height">height</a></b> () const</li>
 
44
<li><div class="fn"/>bool <b><a href="q3canvas.html#onCanvas">onCanvas</a></b> ( int <i>x</i>, int <i>y</i> ) const</li>
 
45
<li><div class="fn"/>bool <b><a href="q3canvas.html#onCanvas-2">onCanvas</a></b> ( const QPoint &amp; <i>p</i> ) const</li>
 
46
<li><div class="fn"/>QRect <b><a href="q3canvas.html#rect">rect</a></b> () const</li>
 
47
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#resize">resize</a></b> ( int <i>w</i>, int <i>h</i> )</li>
 
48
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#retune">retune</a></b> ( int <i>chunksze</i>, int <i>mxclusters</i> = 100 )</li>
 
49
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setAdvancePeriod">setAdvancePeriod</a></b> ( int <i>ms</i> )</li>
 
50
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setAllChanged">setAllChanged</a></b> ()</li>
 
51
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setBackgroundColor">setBackgroundColor</a></b> ( const QColor &amp; <i>c</i> )</li>
 
52
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setBackgroundPixmap">setBackgroundPixmap</a></b> ( const QPixmap &amp; <i>p</i> )</li>
 
53
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setChanged">setChanged</a></b> ( const QRect &amp; <i>area</i> )</li>
 
54
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setDoubleBuffering">setDoubleBuffering</a></b> ( bool <i>y</i> )</li>
 
55
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setTile">setTile</a></b> ( int <i>x</i>, int <i>y</i>, int <i>tilenum</i> )</li>
 
56
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setTiles">setTiles</a></b> ( QPixmap <i>p</i>, int <i>h</i>, int <i>v</i>, int <i>tilewidth</i>, int <i>tileheight</i> )</li>
 
57
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setUnchanged">setUnchanged</a></b> ( const QRect &amp; <i>area</i> )</li>
 
58
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#setUpdatePeriod">setUpdatePeriod</a></b> ( int <i>ms</i> )</li>
 
59
<li><div class="fn"/>QSize <b><a href="q3canvas.html#size">size</a></b> () const</li>
 
60
<li><div class="fn"/>int <b><a href="q3canvas.html#tile">tile</a></b> ( int <i>x</i>, int <i>y</i> ) const</li>
 
61
<li><div class="fn"/>int <b><a href="q3canvas.html#tileHeight">tileHeight</a></b> () const</li>
 
62
<li><div class="fn"/>int <b><a href="q3canvas.html#tileWidth">tileWidth</a></b> () const</li>
 
63
<li><div class="fn"/>int <b><a href="q3canvas.html#tilesHorizontally">tilesHorizontally</a></b> () const</li>
 
64
<li><div class="fn"/>int <b><a href="q3canvas.html#tilesVertically">tilesVertically</a></b> () const</li>
 
65
<li><div class="fn"/>bool <b><a href="q3canvas.html#validChunk">validChunk</a></b> ( int <i>x</i>, int <i>y</i> ) const</li>
 
66
<li><div class="fn"/>bool <b><a href="q3canvas.html#validChunk-2">validChunk</a></b> ( const QPoint &amp; <i>p</i> ) const</li>
 
67
<li><div class="fn"/>int <b><a href="q3canvas.html#width">width</a></b> () const</li>
 
68
</ul>
 
69
<ul>
 
70
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
71
</ul>
 
72
<a name="public-slots"></a>
 
73
<h3>Public Slots</h3>
 
74
<ul>
 
75
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#advance">advance</a></b> ()</li>
 
76
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#update">update</a></b> ()</li>
 
77
</ul>
 
78
<ul>
 
79
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
80
</ul>
 
81
<a name="signals"></a>
 
82
<h3>Signals</h3>
 
83
<ul>
 
84
<li><div class="fn"/>void <b><a href="q3canvas.html#resized">resized</a></b> ()</li>
 
85
</ul>
 
86
<ul>
 
87
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
88
</ul>
 
89
<a name="protected-functions"></a>
 
90
<h3>Protected Functions</h3>
 
91
<ul>
 
92
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#drawBackground">drawBackground</a></b> ( QPainter &amp; <i>painter</i>, const QRect &amp; <i>clip</i> )</li>
 
93
<li><div class="fn"/>virtual void <b><a href="q3canvas.html#drawForeground">drawForeground</a></b> ( QPainter &amp; <i>painter</i>, const QRect &amp; <i>clip</i> )</li>
 
94
</ul>
 
95
<ul>
 
96
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
97
</ul>
 
98
<h3>Additional Inherited Members</h3>
 
99
<ul>
 
100
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
101
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
102
</ul>
 
103
<a name="details"></a>
 
104
<hr />
 
105
<h2>Detailed Description</h2>
 
106
<p>The Q3Canvas class provides a 2D area that can contain <a href="q3canvasitem.html">Q3CanvasItem</a> objects.</p>
 
107
<p>The Q3Canvas 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 <a href="q3canvasview.html">Q3CanvasView</a>. Multiple <a href="q3canvasview.html">Q3CanvasView</a> widgets may be associated with a canvas to provide multiple views of the same canvas.</p>
 
108
<p>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 <a href="q3scrollview.html">Q3ScrollView</a> subclass.</p>
 
109
<p>Qt provides a rich set of canvas item classes, e.g. <a href="q3canvasellipse.html">Q3CanvasEllipse</a>, <a href="q3canvasline.html">Q3CanvasLine</a>, <a href="q3canvaspolygon.html">Q3CanvasPolygon</a>, <a href="q3canvaspolygonalitem.html">Q3CanvasPolygonalItem</a>, <a href="q3canvasrectangle.html">Q3CanvasRectangle</a>, <a href="q3canvasspline.html">Q3CanvasSpline</a>, <a href="q3canvassprite.html">Q3CanvasSprite</a> and <a href="q3canvastext.html">Q3CanvasText</a>. You can subclass to create your own canvas items; <a href="q3canvaspolygonalitem.html">Q3CanvasPolygonalItem</a> is the most common base class used for this purpose.</p>
 
110
<p>Items appear on the canvas after their <a href="q3canvasitem.html#show">show()</a> function has been called (or <a href="q3canvasitem.html#setVisible">setVisible(true)</a>), and <i>after</i> <a href="q3canvas.html#update">update</a>() has been called. The canvas only shows items that are <a href="q3canvasitem.html#setVisible">visible</a>, and then only if <a href="q3canvas.html#update">update</a>() is called. (By default the canvas is white and so are canvas items, so if nothing appears try changing colors.)</p>
 
111
<p>If you created the canvas without passing a width and height to the constructor you must also call <a href="q3canvas.html#resize">resize</a>().</p>
 
112
<p>Although a canvas may appear to be similar to a widget with child widgets, there are several notable differences:</p>
 
113
<ul>
 
114
<li>Canvas items are usually much faster to manipulate and redraw than child widgets, with the speed advantage becoming especially great when there are <i>many</i> canvas items and non-rectangular items. In most situations canvas items are also a lot more memory efficient than child widgets.</li>
 
115
<li>It's easy to detect overlapping items (collision detection).</li>
 
116
<li>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 Q3Canvas 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).</li>
 
117
<li>Two or more <a href="q3canvasview.html">Q3CanvasView</a> objects can view the same canvas.</li>
 
118
<li>An arbitrary transformation matrix can be set on each <a href="q3canvasview.html">Q3CanvasView</a> which makes it easy to zoom, rotate or shear the viewed canvas.</li>
 
119
<li>Widgets provide a lot more functionality, such as input (<a href="qkeyevent.html">QKeyEvent</a>, <a href="qmouseevent.html">QMouseEvent</a> etc.) and layout management (<a href="qgridlayout.html">QGridLayout</a> etc.).</li>
 
120
</ul>
 
121
<p>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.</p>
 
122
<p>The background is white by default, but can be set to a different color using <a href="q3canvas.html#setBackgroundColor">setBackgroundColor</a>(), or to a repeated pixmap using <a href="q3canvas.html#setBackgroundPixmap">setBackgroundPixmap</a>() or to a mosaic of smaller pixmaps using <a href="q3canvas.html#setTiles">setTiles</a>(). Individual tiles can be set with <a href="q3canvas.html#setTile">setTile</a>(). There are corresponding get functions, e.g. <a href="q3canvas.html#backgroundColor">backgroundColor</a>() and <a href="q3canvas.html#backgroundPixmap">backgroundPixmap</a>().</p>
 
123
<p>Note that Q3Canvas does not inherit from <a href="qwidget.html">QWidget</a>, even though it has some functions which provide the same functionality as those in <a href="qwidget.html">QWidget</a>. One of these is <a href="q3canvas.html#setBackgroundPixmap">setBackgroundPixmap</a>(); some others are <a href="q3canvas.html#resize">resize</a>(), <a href="q3canvas.html#size">size</a>(), <a href="q3canvas.html#width">width</a>() and <a href="q3canvas.html#height">height</a>(). <a href="q3canvasview.html">Q3CanvasView</a> is the widget used to display a canvas on the screen.</p>
 
124
<p>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 <a href="q3canvasitem.html#setCanvas">Q3CanvasItem::setCanvas</a>().</p>
 
125
<p>Canvas items are movable (and in the case of Q3CanvasSprites, animated) objects that inherit <a href="q3canvasitem.html">Q3CanvasItem</a>. 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 <a href="q3canvasitem.html#x">Q3CanvasItem::x</a>() is greater than <a href="q3canvas.html#width">width</a>()). When a canvas item is off the canvas, <a href="q3canvas.html#onCanvas">onCanvas</a>() 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.)</p>
 
126
<p>Canvas items can be moved with <a href="q3canvasitem.html#move">Q3CanvasItem::move</a>(). The <a href="q3canvas.html#advance">advance</a>() function moves all <a href="q3canvasitem.html#animated">Q3CanvasItem::animated</a>() canvas items and <a href="q3canvas.html#setAdvancePeriod">setAdvancePeriod</a>() makes Q3Canvas move them automatically on a periodic basis. In the context of the Q3Canvas classes, to `animate' a canvas item is to set it in motion, i.e. using <a href="q3canvasitem.html#setVelocity">Q3CanvasItem::setVelocity</a>(). Animation of a canvas item itself, i.e. items which change over time, is enabled by calling <a href="q3canvassprite.html#setFrameAnimation">Q3CanvasSprite::setFrameAnimation</a>(), or more generally by subclassing and reimplementing <a href="q3canvasitem.html#advance">Q3CanvasItem::advance</a>(). To detect collisions use one of the <a href="q3canvasitem.html#collisions">Q3CanvasItem::collisions</a>() functions.</p>
 
127
<p>The changed parts of the canvas are redrawn (if they are visible in a canvas view) whenever <a href="q3canvas.html#update">update</a>() is called. You can either call <a href="q3canvas.html#update">update</a>() manually after having changed the contents of the canvas, or force periodic updates using <a href="q3canvas.html#setUpdatePeriod">setUpdatePeriod</a>(). If you have moving objects on the canvas, you must call <a href="q3canvas.html#advance">advance</a>() every time the objects should move one step further. Periodic calls to <a href="q3canvas.html#advance">advance</a>() can be forced using <a href="q3canvas.html#setAdvancePeriod">setAdvancePeriod</a>(). The <a href="q3canvas.html#advance">advance</a>() function will call <a href="q3canvasitem.html#advance">Q3CanvasItem::advance</a>() on every item that is <a href="q3canvasitem.html#animated">animated</a> and trigger an update of the affected areas afterwards. (A canvas item that is `animated' is simply a canvas item that is in motion.)</p>
 
128
<p>Q3Canvas organizes its canvas items into <i>chunks</i>; 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, <a href="q3canvas.html#validChunk">validChunk</a>(), is one which is on the canvas.</p>
 
129
<p>The chunk size is a key factor to Q3Canvas'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 Q3Canvas constructor tries to pick a suitable size, but you can call <a href="q3canvas.html#retune">retune</a>() to change it at any time. The <a href="q3canvas.html#chunkSize">chunkSize</a>() 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.</p>
 
130
<p>The foreground is normally nothing, but if you reimplement <a href="q3canvas.html#drawForeground">drawForeground</a>(), you can draw things in front of all the canvas items.</p>
 
131
<p>Areas can be set as changed with <a href="q3canvas.html#setChanged">setChanged</a>() and set unchanged with <a href="q3canvas.html#setUnchanged">setUnchanged</a>(). The entire canvas can be set as changed with <a href="q3canvas.html#setAllChanged">setAllChanged</a>(). A list of all the items on the canvas is returned by <a href="q3canvas.html#allItems">allItems</a>().</p>
 
132
<p>An area can be copied (painted) to a <a href="qpainter.html">QPainter</a> with <a href="q3canvas.html#drawArea">drawArea</a>().</p>
 
133
<p>If the canvas is resized it emits the <a href="q3canvas.html#resized">resized</a>() signal.</p>
 
134
<p>The examples/canvas application and the 2D graphics page of the examples/demo application demonstrate many of Q3Canvas's facilities.</p>
 
135
<p>See also <a href="q3canvasview.html">Q3CanvasView</a> and <a href="q3canvasitem.html">Q3CanvasItem</a>.</p>
 
136
<hr />
 
137
<h2>Member Function Documentation</h2>
 
138
<h3 class="fn"><a name="Q3Canvas"></a>Q3Canvas::Q3Canvas ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0, const char * <i>name</i> = 0 )</h3>
 
139
<p>Create a <a href="q3canvas.html">Q3Canvas</a> with no size. <i>parent</i> and <i>name</i> are passed to the <a href="qobject.html">QObject</a> superclass.</p>
 
140
<p><b>Warning:</b> You <i>must</i> call <a href="q3canvas.html#resize">resize</a>() at some time after creation to be able to use the canvas.</p>
 
141
<h3 class="fn"><a name="Q3Canvas-2"></a>Q3Canvas::Q3Canvas ( int <i>w</i>, int <i>h</i> )</h3>
 
142
<p>Constructs a <a href="q3canvas.html">Q3Canvas</a> that is <i>w</i> pixels wide and <i>h</i> pixels high.</p>
 
143
<h3 class="fn"><a name="Q3Canvas-3"></a>Q3Canvas::Q3Canvas ( <a href="qpixmap.html">QPixmap</a> <i>p</i>, int <i>h</i>, int <i>v</i>, int <i>tilewidth</i>, int <i>tileheight</i> )</h3>
 
144
<p>Constructs a <a href="q3canvas.html">Q3Canvas</a> which will be composed of <i>h</i> tiles horizontally and <i>v</i> tiles vertically. Each tile will be an image <i>tilewidth</i> by <i>tileheight</i> pixels taken from pixmap <i>p</i>.</p>
 
145
<p>The pixmap <i>p</i> 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.</p>
 
146
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
147
<tr valign="top" bgcolor="#f0f0f0"><td>0</td><td>1</td><td>2</td><td>3</td></tr>
 
148
<tr valign="top" bgcolor="#e0e0e0"><td>4</td><td>5</td><td>6</td><td>7</td></tr>
 
149
</table>
 
150
<p>The <a href="q3canvas.html">Q3Canvas</a> 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.</p>
 
151
<p>See also <a href="q3canvas.html#setTiles">setTiles</a>().</p>
 
152
<h3 class="fn"><a name="dtor.Q3Canvas"></a>Q3Canvas::~Q3Canvas ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
153
<p>Destroys the canvas and all the canvas's canvas items.</p>
 
154
<h3 class="fn"><a name="advance"></a>void Q3Canvas::advance ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
155
<p>Moves all <a href="q3canvasitem.html#animated">Q3CanvasItem::animated</a>() 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().)</p>
 
156
<p>The advance takes place in two phases. In phase 0, the <a href="q3canvasitem.html#advance">Q3CanvasItem::advance</a>() function of each <a href="q3canvasitem.html#animated">Q3CanvasItem::animated</a>() 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 &quot;fairness&quot;, although no <a href="q3canvasitem.html">Q3CanvasItem</a> subclasses supplied with Qt do anything interesting in phase 0.</p>
 
157
<p>The canvas can be configured to call this function periodically with <a href="q3canvas.html#setAdvancePeriod">setAdvancePeriod</a>().</p>
 
158
<p>See also <a href="q3canvas.html#update">update</a>().</p>
 
159
<h3 class="fn"><a name="allItems"></a><a href="q3canvasitemlist.html">Q3CanvasItemList</a> Q3Canvas::allItems ()</h3>
 
160
<p>Returns a list of all the items in the canvas.</p>
 
161
<h3 class="fn"><a name="backgroundColor"></a><a href="qcolor.html">QColor</a> Q3Canvas::backgroundColor () const</h3>
 
162
<p>Returns the color set by <a href="q3canvas.html#setBackgroundColor">setBackgroundColor</a>(). By default, this is white.</p>
 
163
<p>This function is not a reimplementation of QWidget::backgroundColor() (<a href="q3canvas.html">Q3Canvas</a> is not a subclass of <a href="qwidget.html">QWidget</a>), but all Q3CanvasViews that are viewing the canvas will set their backgrounds to this color.</p>
 
164
<p>See also <a href="q3canvas.html#setBackgroundColor">setBackgroundColor</a>() and <a href="q3canvas.html#backgroundPixmap">backgroundPixmap</a>().</p>
 
165
<h3 class="fn"><a name="backgroundPixmap"></a><a href="qpixmap.html">QPixmap</a> Q3Canvas::backgroundPixmap () const</h3>
 
166
<p>Returns the pixmap set by <a href="q3canvas.html#setBackgroundPixmap">setBackgroundPixmap</a>(). By default, this is a null pixmap.</p>
 
167
<p>See also <a href="q3canvas.html#setBackgroundPixmap">setBackgroundPixmap</a>() and <a href="q3canvas.html#backgroundColor">backgroundColor</a>().</p>
 
168
<h3 class="fn"><a name="chunkSize"></a>int Q3Canvas::chunkSize () const</h3>
 
169
<p>Returns the chunk size of the canvas.</p>
 
170
<p>See also <a href="q3canvas.html#retune">retune</a>().</p>
 
171
<h3 class="fn"><a name="collisions"></a><a href="q3canvasitemlist.html">Q3CanvasItemList</a> Q3Canvas::collisions ( const <a href="qpoint.html">QPoint</a> &amp; <i>p</i> ) const</h3>
 
172
<p>Returns a list of canvas items that collide with the point <i>p</i>. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item).</p>
 
173
<h3 class="fn"><a name="collisions-2"></a><a href="q3canvasitemlist.html">Q3CanvasItemList</a> Q3Canvas::collisions ( const <a href="qrect.html">QRect</a> &amp; <i>r</i> ) const</h3>
 
174
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
175
<p>Returns a list of items which collide with the rectangle <i>r</i>. The list is ordered by z coordinates, from highest z coordinate (front-most item) to lowest z coordinate (rear-most item).</p>
 
176
<h3 class="fn"><a name="collisions-3"></a><a href="q3canvasitemlist.html">Q3CanvasItemList</a> Q3Canvas::collisions ( const <a href="q3pointarray.html">Q3PointArray</a> &amp; <i>chunklist</i>, const <a href="q3canvasitem.html">Q3CanvasItem</a> * <i>item</i>, bool <i>exact</i> ) const</h3>
 
177
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
178
<p>Returns a list of canvas items which intersect with the chunks listed in <i>chunklist</i>, excluding <i>item</i>. If <i>exact</i> is true, only those which actually <a href="q3canvasitem.html#collidesWith">collide with</a> <i>item</i> are returned; otherwise canvas items are included just for being in the chunks.</p>
 
179
<p>This is a utility function mainly used to implement the simpler <a href="q3canvasitem.html#collisions">Q3CanvasItem::collisions</a>() function.</p>
 
180
<h3 class="fn"><a name="drawArea"></a>void Q3Canvas::drawArea ( const <a href="qrect.html">QRect</a> &amp; <i>clip</i>, <a href="qpainter.html">QPainter</a> * <i>painter</i>, bool <i>dbuf</i> = false )</h3>
 
181
<p>Paints all canvas items that are in the area <i>clip</i> to <i>painter</i>, using double-buffering if <i>dbuf</i> is true.</p>
 
182
<p>e.g. to print the canvas to a printer:</p>
 
183
<pre>&nbsp;   QPrinter pr;
 
184
    if (pr.setup()) {
 
185
        QPainter p(&amp;pr);
 
186
        canvas.drawArea(canvas.rect(), &amp;p);
 
187
    }</pre>
 
188
<h3 class="fn"><a name="drawBackground"></a>void Q3Canvas::drawBackground ( <a href="qpainter.html">QPainter</a> &amp; <i>painter</i>, const <a href="qrect.html">QRect</a> &amp; <i>clip</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
189
<p>This virtual function is called for all updates of the canvas. It renders any background graphics using the painter <i>painter</i>, in the area <i>clip</i>. If the canvas has a background pixmap or a tiled background, that graphic is used, otherwise the canvas is cleared using the background color.</p>
 
190
<p>If the graphics for an area change, you must explicitly call setChanged(const <a href="qrect.html">QRect</a>&amp;) for the result to be visible when <a href="q3canvas.html#update">update</a>() is next called.</p>
 
191
<p>See also <a href="q3canvas.html#setBackgroundColor">setBackgroundColor</a>(), <a href="q3canvas.html#setBackgroundPixmap">setBackgroundPixmap</a>(), and <a href="q3canvas.html#setTiles">setTiles</a>().</p>
 
192
<h3 class="fn"><a name="drawForeground"></a>void Q3Canvas::drawForeground ( <a href="qpainter.html">QPainter</a> &amp; <i>painter</i>, const <a href="qrect.html">QRect</a> &amp; <i>clip</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
193
<p>This virtual function is called for all updates of the canvas. It renders any foreground graphics using the painter <i>painter</i>, in the area <i>clip</i>.</p>
 
194
<p>If the graphics for an area change, you must explicitly call setChanged(const <a href="qrect.html">QRect</a>&amp;) for the result to be visible when <a href="q3canvas.html#update">update</a>() is next called.</p>
 
195
<p>The default is to draw nothing.</p>
 
196
<h3 class="fn"><a name="height"></a>int Q3Canvas::height () const</h3>
 
197
<p>Returns the height of the canvas, in pixels.</p>
 
198
<h3 class="fn"><a name="onCanvas"></a>bool Q3Canvas::onCanvas ( int <i>x</i>, int <i>y</i> ) const</h3>
 
199
<p>Returns true if the pixel position (<i>x</i>, <i>y</i>) is on the canvas; otherwise returns false.</p>
 
200
<p>See also <a href="q3canvas.html#validChunk">validChunk</a>().</p>
 
201
<h3 class="fn"><a name="onCanvas-2"></a>bool Q3Canvas::onCanvas ( const <a href="qpoint.html">QPoint</a> &amp; <i>p</i> ) const</h3>
 
202
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
203
<p>Returns true if the pixel position <i>p</i> is on the canvas; otherwise returns false.</p>
 
204
<p>See also <a href="q3canvas.html#validChunk">validChunk</a>().</p>
 
205
<h3 class="fn"><a name="rect"></a><a href="qrect.html">QRect</a> Q3Canvas::rect () const</h3>
 
206
<p>Returns a rectangle the size of the canvas.</p>
 
207
<h3 class="fn"><a name="resize"></a>void Q3Canvas::resize ( int <i>w</i>, int <i>h</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
208
<p>Changes the size of the canvas to have a width of <i>w</i> and a height of <i>h</i>. This is a slow operation.</p>
 
209
<h3 class="fn"><a name="resized"></a>void Q3Canvas::resized ()&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
210
<p>This signal is emitted whenever the canvas is resized. Each <a href="q3canvasview.html">Q3CanvasView</a> connects to this signal to keep the scrollview's size correct.</p>
 
211
<h3 class="fn"><a name="retune"></a>void Q3Canvas::retune ( int <i>chunksze</i>, int <i>mxclusters</i> = 100 )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
212
<p>Change the efficiency tuning parameters to <i>mxclusters</i> clusters, each of size <i>chunksze</i>. This is a slow operation if there are many objects on the canvas.</p>
 
213
<p>The canvas is divided into chunks which are rectangular areas <i>chunksze</i> wide by <i>chunksze</i> 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.</p>
 
214
<p>Internally, a canvas uses a low-resolution &quot;chunk matrix&quot; 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 <a href="q3canvas.html#setTiles">setTiles</a>(). 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.</p>
 
215
<p>The <i>mxclusters</i> 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.</p>
 
216
<h3 class="fn"><a name="setAdvancePeriod"></a>void Q3Canvas::setAdvancePeriod ( int <i>ms</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
217
<p>Sets the canvas to call <a href="q3canvas.html#advance">advance</a>() every <i>ms</i> milliseconds. Any previous setting by setAdvancePeriod() or <a href="q3canvas.html#setUpdatePeriod">setUpdatePeriod</a>() is overridden.</p>
 
218
<p>If <i>ms</i> is less than 0 advancing will be stopped.</p>
 
219
<h3 class="fn"><a name="setAllChanged"></a>void Q3Canvas::setAllChanged ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
220
<p>Marks the whole canvas as changed. All views of the canvas will be entirely redrawn when <a href="q3canvas.html#update">update</a>() is called next.</p>
 
221
<h3 class="fn"><a name="setBackgroundColor"></a>void Q3Canvas::setBackgroundColor ( const <a href="qcolor.html">QColor</a> &amp; <i>c</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
222
<p>Sets the solid background to be the color <i>c</i>.</p>
 
223
<p>See also <a href="q3canvas.html#backgroundColor">backgroundColor</a>(), <a href="q3canvas.html#setBackgroundPixmap">setBackgroundPixmap</a>(), and <a href="q3canvas.html#setTiles">setTiles</a>().</p>
 
224
<h3 class="fn"><a name="setBackgroundPixmap"></a>void Q3Canvas::setBackgroundPixmap ( const <a href="qpixmap.html">QPixmap</a> &amp; <i>p</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
225
<p>Sets the solid background to be the pixmap <i>p</i> repeated as necessary to cover the entire canvas.</p>
 
226
<p>See also <a href="q3canvas.html#backgroundPixmap">backgroundPixmap</a>(), <a href="q3canvas.html#setBackgroundColor">setBackgroundColor</a>(), and <a href="q3canvas.html#setTiles">setTiles</a>().</p>
 
227
<h3 class="fn"><a name="setChanged"></a>void Q3Canvas::setChanged ( const <a href="qrect.html">QRect</a> &amp; <i>area</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
228
<p>Marks <i>area</i> as changed. This <i>area</i> will be redrawn in all views that are showing it when <a href="q3canvas.html#update">update</a>() is called next.</p>
 
229
<h3 class="fn"><a name="setDoubleBuffering"></a>void Q3Canvas::setDoubleBuffering ( bool <i>y</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
230
<p>If <i>y</i> is true (the default) double-buffering is switched on; otherwise double-buffering is switched off.</p>
 
231
<p>Turning off double-buffering causes the redrawn areas to flicker a little and also gives a (usually small) performance improvement.</p>
 
232
<h3 class="fn"><a name="setTile"></a>void Q3Canvas::setTile ( int <i>x</i>, int <i>y</i>, int <i>tilenum</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
233
<p>Sets the tile at (<i>x</i>, <i>y</i>) to use tile number <i>tilenum</i>, which is an index into the tile pixmaps. The canvas will update appropriately when <a href="q3canvas.html#update">update</a>() is next called.</p>
 
234
<p>The images are taken from the pixmap set by <a href="q3canvas.html#setTiles">setTiles</a>() 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.</p>
 
235
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
236
<tr valign="top" bgcolor="#f0f0f0"><td>0</td><td>1</td><td>2</td><td>3</td></tr>
 
237
<tr valign="top" bgcolor="#e0e0e0"><td>4</td><td>5</td><td>6</td><td>7</td></tr>
 
238
</table>
 
239
<p>See also <a href="q3canvas.html#tile">tile</a>() and <a href="q3canvas.html#setTiles">setTiles</a>().</p>
 
240
<h3 class="fn"><a name="setTiles"></a>void Q3Canvas::setTiles ( <a href="qpixmap.html">QPixmap</a> <i>p</i>, int <i>h</i>, int <i>v</i>, int <i>tilewidth</i>, int <i>tileheight</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
241
<p>Sets the <a href="q3canvas.html">Q3Canvas</a> to be composed of <i>h</i> tiles horizontally and <i>v</i> tiles vertically. Each tile will be an image <i>tilewidth</i> by <i>tileheight</i> pixels from pixmap <i>p</i>.</p>
 
242
<p>The pixmap <i>p</i> 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.</p>
 
243
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
244
<tr valign="top" bgcolor="#f0f0f0"><td>0</td><td>1</td><td>2</td><td>3</td></tr>
 
245
<tr valign="top" bgcolor="#e0e0e0"><td>4</td><td>5</td><td>6</td><td>7</td></tr>
 
246
</table>
 
247
<p>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.</p>
 
248
<p>The width and height of <i>p</i> must be a multiple of <i>tilewidth</i> and <i>tileheight</i>. If they are not the function will do nothing.</p>
 
249
<p>If you want to unset any tiling set, then just pass in a null pixmap and 0 for <i>h</i>, <i>v</i>, <i>tilewidth</i>, and <i>tileheight</i>.</p>
 
250
<h3 class="fn"><a name="setUnchanged"></a>void Q3Canvas::setUnchanged ( const <a href="qrect.html">QRect</a> &amp; <i>area</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
251
<p>Marks <i>area</i> as <i>unchanged</i>. The area will <i>not</i> be redrawn in the views for the next <a href="q3canvas.html#update">update</a>(), unless it is marked or changed again before the next call to <a href="q3canvas.html#update">update</a>().</p>
 
252
<h3 class="fn"><a name="setUpdatePeriod"></a>void Q3Canvas::setUpdatePeriod ( int <i>ms</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
253
<p>Sets the canvas to call <a href="q3canvas.html#update">update</a>() every <i>ms</i> milliseconds. Any previous setting by <a href="q3canvas.html#setAdvancePeriod">setAdvancePeriod</a>() or setUpdatePeriod() is overridden.</p>
 
254
<p>If <i>ms</i> is less than 0 automatic updating will be stopped.</p>
 
255
<h3 class="fn"><a name="size"></a><a href="qsize.html">QSize</a> Q3Canvas::size () const</h3>
 
256
<p>Returns the size of the canvas, in pixels.</p>
 
257
<h3 class="fn"><a name="tile"></a>int Q3Canvas::tile ( int <i>x</i>, int <i>y</i> ) const</h3>
 
258
<p>Returns the tile at position (<i>x</i>, <i>y</i>). Initially, all tiles are 0.</p>
 
259
<p>The parameters must be within range, i.e. 0 &lt; <i>x</i> &lt; <a href="q3canvas.html#tilesHorizontally">tilesHorizontally</a>() and 0 &lt; <i>y</i> &lt; <a href="q3canvas.html#tilesVertically">tilesVertically</a>().</p>
 
260
<p>See also <a href="q3canvas.html#setTile">setTile</a>().</p>
 
261
<h3 class="fn"><a name="tileHeight"></a>int Q3Canvas::tileHeight () const</h3>
 
262
<p>Returns the height of each tile.</p>
 
263
<h3 class="fn"><a name="tileWidth"></a>int Q3Canvas::tileWidth () const</h3>
 
264
<p>Returns the width of each tile.</p>
 
265
<h3 class="fn"><a name="tilesHorizontally"></a>int Q3Canvas::tilesHorizontally () const</h3>
 
266
<p>Returns the number of tiles horizontally.</p>
 
267
<h3 class="fn"><a name="tilesVertically"></a>int Q3Canvas::tilesVertically () const</h3>
 
268
<p>Returns the number of tiles vertically.</p>
 
269
<h3 class="fn"><a name="update"></a>void Q3Canvas::update ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
270
<p>Repaints changed areas in all views of the canvas.</p>
 
271
<p>See also <a href="q3canvas.html#advance">advance</a>().</p>
 
272
<h3 class="fn"><a name="validChunk"></a>bool Q3Canvas::validChunk ( int <i>x</i>, int <i>y</i> ) const</h3>
 
273
<p>Returns true if the chunk position (<i>x</i>, <i>y</i>) is on the canvas; otherwise returns false.</p>
 
274
<p>See also <a href="q3canvas.html#onCanvas">onCanvas</a>().</p>
 
275
<h3 class="fn"><a name="validChunk-2"></a>bool Q3Canvas::validChunk ( const <a href="qpoint.html">QPoint</a> &amp; <i>p</i> ) const</h3>
 
276
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
277
<p>Returns true if the chunk position <i>p</i> is on the canvas; otherwise returns false.</p>
 
278
<p>See also <a href="q3canvas.html#onCanvas">onCanvas</a>().</p>
 
279
<h3 class="fn"><a name="width"></a>int Q3Canvas::width () const</h3>
 
280
<p>Returns the width of the canvas, in pixels.</p>
 
281
<p /><address><hr /><div align="center">
 
282
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
283
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
284
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
285
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
286
</tr></table></div></address></body>
 
287
</html>