summaryrefslogtreecommitdiffstats
path: root/doc/html/tqcanvas.html
blob: cf1286a97e9fb644e6d62ecd72d8b15dd27e29b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/canvas/tqcanvas.cpp:435 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQCanvas Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>TQCanvas Class Reference<br><small>[<a href="canvas.html">canvas module</a>]</small></h1>

<p>The TQCanvas class provides a 2D area that can contain TQCanvasItem objects.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="tqcanvas-h.html">tqcanvas.h</a>&gt;</tt>
<p>Inherits <a href="tqobject.html">TQObject</a>.
<p><a href="tqcanvas-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQCanvas"><b>TQCanvas</b></a> ( TQObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn><a href="#TQCanvas-2"><b>TQCanvas</b></a> ( int&nbsp;w, int&nbsp;h )</li>
<li class=fn><a href="#TQCanvas-3"><b>TQCanvas</b></a> ( TQPixmap&nbsp;p, int&nbsp;h, int&nbsp;v, int&nbsp;tilewidth, int&nbsp;tileheight )</li>
<li class=fn>virtual <a href="#~TQCanvas"><b>~TQCanvas</b></a> ()</li>
<li class=fn>virtual void <a href="#setTiles"><b>setTiles</b></a> ( TQPixmap&nbsp;p, int&nbsp;h, int&nbsp;v, int&nbsp;tilewidth, int&nbsp;tileheight )</li>
<li class=fn>virtual void <a href="#setBackgroundPixmap"><b>setBackgroundPixmap</b></a> ( const&nbsp;TQPixmap&nbsp;&amp;&nbsp;p )</li>
<li class=fn>TQPixmap <a href="#backgroundPixmap"><b>backgroundPixmap</b></a> () const</li>
<li class=fn>virtual void <a href="#setBackgroundColor"><b>setBackgroundColor</b></a> ( const&nbsp;TQColor&nbsp;&amp;&nbsp;c )</li>
<li class=fn>TQColor <a href="#backgroundColor"><b>backgroundColor</b></a> () const</li>
<li class=fn>virtual void <a href="#setTile"><b>setTile</b></a> ( int&nbsp;x, int&nbsp;y, int&nbsp;tilenum )</li>
<li class=fn>int <a href="#tile"><b>tile</b></a> ( int&nbsp;x, int&nbsp;y ) const</li>
<li class=fn>int <a href="#tilesHorizontally"><b>tilesHorizontally</b></a> () const</li>
<li class=fn>int <a href="#tilesVertically"><b>tilesVertically</b></a> () const</li>
<li class=fn>int <a href="#tileWidth"><b>tileWidth</b></a> () const</li>
<li class=fn>int <a href="#tileHeight"><b>tileHeight</b></a> () const</li>
<li class=fn>virtual void <a href="#resize"><b>resize</b></a> ( int&nbsp;w, int&nbsp;h )</li>
<li class=fn>int <a href="#width"><b>width</b></a> () const</li>
<li class=fn>int <a href="#height"><b>height</b></a> () const</li>
<li class=fn>TQSize <a href="#size"><b>size</b></a> () const</li>
<li class=fn>TQRect <a href="#rect"><b>rect</b></a> () const</li>
<li class=fn>bool <a href="#onCanvas"><b>onCanvas</b></a> ( int&nbsp;x, int&nbsp;y ) const</li>
<li class=fn>bool <a href="#onCanvas-2"><b>onCanvas</b></a> ( const&nbsp;TQPoint&nbsp;&amp;&nbsp;p ) const</li>
<li class=fn>bool <a href="#validChunk"><b>validChunk</b></a> ( int&nbsp;x, int&nbsp;y ) const</li>
<li class=fn>bool <a href="#validChunk-2"><b>validChunk</b></a> ( const&nbsp;TQPoint&nbsp;&amp;&nbsp;p ) const</li>
<li class=fn>int <a href="#chunkSize"><b>chunkSize</b></a> () const</li>
<li class=fn>virtual void <a href="#retune"><b>retune</b></a> ( int&nbsp;chunksze, int&nbsp;mxclusters = 100 )</li>
<li class=fn>virtual void <a href="#setAllChanged"><b>setAllChanged</b></a> ()</li>
<li class=fn>virtual void <a href="#setChanged"><b>setChanged</b></a> ( const&nbsp;TQRect&nbsp;&amp;&nbsp;area )</li>
<li class=fn>virtual void <a href="#setUnchanged"><b>setUnchanged</b></a> ( const&nbsp;TQRect&nbsp;&amp;&nbsp;area )</li>
<li class=fn>TQCanvasItemList <a href="#allItems"><b>allItems</b></a> ()</li>
<li class=fn>TQCanvasItemList <a href="#collisions"><b>collisions</b></a> ( const&nbsp;TQPoint&nbsp;&amp;&nbsp;p ) const</li>
<li class=fn>TQCanvasItemList <a href="#collisions-2"><b>collisions</b></a> ( const&nbsp;TQRect&nbsp;&amp;&nbsp;r ) const</li>
<li class=fn>TQCanvasItemList <a href="#collisions-3"><b>collisions</b></a> ( const&nbsp;TQPointArray&nbsp;&amp;&nbsp;chunklist, const&nbsp;TQCanvasItem&nbsp;*&nbsp;item, bool&nbsp;exact ) const</li>
<li class=fn>void <a href="#drawArea"><b>drawArea</b></a> ( const&nbsp;TQRect&nbsp;&amp;&nbsp;clip, TQPainter&nbsp;*&nbsp;painter, bool&nbsp;dbuf = FALSE )</li>
<li class=fn>virtual void <a href="#setAdvancePeriod"><b>setAdvancePeriod</b></a> ( int&nbsp;ms )</li>
<li class=fn>virtual void <a href="#setUpdatePeriod"><b>setUpdatePeriod</b></a> ( int&nbsp;ms )</li>
<li class=fn>virtual void <a href="#setDoubleBuffering"><b>setDoubleBuffering</b></a> ( bool&nbsp;y )</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>virtual void <a href="#advance"><b>advance</b></a> ()</li>
<li class=fn>virtual void <a href="#update"><b>update</b></a> ()</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#resized"><b>resized</b></a> ()</li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#drawBackground"><b>drawBackground</b></a> ( TQPainter&nbsp;&amp;&nbsp;painter, const&nbsp;TQRect&nbsp;&amp;&nbsp;clip )</li>
<li class=fn>virtual void <a href="#drawForeground"><b>drawForeground</b></a> ( TQPainter&nbsp;&amp;&nbsp;painter, const&nbsp;TQRect&nbsp;&amp;&nbsp;clip )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


The TQCanvas class provides a 2D area that can contain <a href="tqcanvasitem.html">TQCanvasItem</a> objects.

<p> 




<p> 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 <a href="tqcanvasview.html">TQCanvasView</a>.
Multiple TQCanvasView widgets may be associated with a canvas to
provide multiple views of the same canvas.
<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="tqscrollview.html">TQScrollView</a> subclass.
<p> TQt provides a rich
set of canvas item classes, e.g. <a href="tqcanvasellipse.html">TQCanvasEllipse</a>, <a href="tqcanvasline.html">TQCanvasLine</a>,
<a href="tqcanvaspolygon.html">TQCanvasPolygon</a>, <a href="tqcanvaspolygonalitem.html">TQCanvasPolygonalItem</a>, <a href="tqcanvasrectangle.html">TQCanvasRectangle</a>, <a href="tqcanvasspline.html">TQCanvasSpline</a>,
<a href="tqcanvassprite.html">TQCanvasSprite</a> and <a href="tqcanvastext.html">TQCanvasText</a>. You can subclass to create your own
canvas items; TQCanvasPolygonalItem is the most common base class used
for this purpose.
<p> Items appear on the canvas after their <a href="tqcanvasitem.html#show">show()</a> function has been called (or <a href="tqcanvasitem.html#setVisible">setVisible(TRUE)</a>), and <em>after</em>
<a href="#update">update</a>() has been called. The canvas only shows items that are
<a href="tqcanvasitem.html#setVisible">visible</a>, and then only if
<a href="#update">update</a>() is called. (By default the canvas is white and so are
canvas items, so if nothing appears try changing colors.)
<p> If you created the canvas without passing a width and height to
the constructor you must also call <a href="#resize">resize</a>().
<p> Although a canvas may appear to be similar to a widget with child
widgets, there are several notable differences:
<p> <ul>
<li> Canvas items are usually much faster to manipulate and redraw than
child widgets, with the speed advantage becoming especially great when
there are <em>many</em> canvas items and non-rectangular items. In most
situations canvas items are also a lot more memory efficient than child
widgets.
<p> <li> It's easy to detect overlapping items (collision detection).
<p> <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 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).
<p> <li> Two or more <a href="tqcanvasview.html">TQCanvasView</a> objects can view the same canvas.
<p> <li> An arbitrary <a href="tqwmatrix.html#TransformationMode">transformation matrix</a> can be set on each TQCanvasView
which makes it easy to zoom, rotate or shear the viewed canvas.
<p> <li> Widgets provide a lot more functionality, such as input (<a href="tqkeyevent.html">TQKeyEvent</a>,
<a href="tqmouseevent.html">TQMouseEvent</a> etc.) and layout management (<a href="tqgridlayout.html">TQGridLayout</a> etc.).
<p> </ul>
<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> The background is white by default, but can be set to a different color
using <a href="#setBackgroundColor">setBackgroundColor</a>(), or to a repeated pixmap using
<a href="#setBackgroundPixmap">setBackgroundPixmap</a>() or to a mosaic of smaller pixmaps using
<a href="#setTiles">setTiles</a>(). Individual tiles can be set with <a href="#setTile">setTile</a>(). There
are corresponding get functions, e.g. <a href="#backgroundColor">backgroundColor</a>() and
<a href="#backgroundPixmap">backgroundPixmap</a>().
<p> Note that TQCanvas does not inherit from <a href="tqwidget.html">TQWidget</a>, even though it has some
functions which provide the same functionality as those in TQWidget. One
of these is setBackgroundPixmap(); some others are <a href="#resize">resize</a>(), <a href="#size">size</a>(),
<a href="#width">width</a>() and <a href="#height">height</a>(). <a href="tqcanvasview.html">TQCanvasView</a> is the widget used to display a
canvas on the screen.
<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="tqcanvasitem.html#setCanvas">TQCanvasItem::setCanvas</a>().
<p> Canvas items are movable (and in the case of TQCanvasSprites, animated)
objects that inherit <a href="tqcanvasitem.html">TQCanvasItem</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="tqcanvasitem.html#x">TQCanvasItem::x</a>() is greater than width()). When a canvas
item is off the canvas, <a href="#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> Canvas items can be moved with <a href="tqcanvasitem.html#move">TQCanvasItem::move</a>(). The <a href="#advance">advance</a>()
function moves all <a href="tqcanvasitem.html#animated">TQCanvasItem::animated</a>() canvas items and
<a href="#setAdvancePeriod">setAdvancePeriod</a>() 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 <a href="tqcanvasitem.html#setVelocity">TQCanvasItem::setVelocity</a>(). Animation
of a canvas item itself, i.e. items which change over time, is enabled
by calling <a href="tqcanvassprite.html#setFrameAnimation">TQCanvasSprite::setFrameAnimation</a>(), or more generally by
subclassing and reimplementing <a href="tqcanvasitem.html#advance">TQCanvasItem::advance</a>(). To detect collisions
use one of the <a href="tqcanvasitem.html#collisions">TQCanvasItem::collisions</a>() functions.
<p> The changed parts of the canvas are redrawn (if they are visible in a
canvas view) whenever <a href="#update">update</a>() is called. You can either call update()
manually after having changed the contents of the canvas, or force
periodic updates using <a href="#setUpdatePeriod">setUpdatePeriod</a>(). If you have moving objects on
the canvas, you must call <a href="#advance">advance</a>() every time the objects should
move one step further. Periodic calls to advance() can be forced using
<a href="#setAdvancePeriod">setAdvancePeriod</a>(). The advance() function will call
TQCanvasItem::advance() on every item that is <a href="tqcanvasitem.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> TQCanvas organizes its canvas items into <em>chunks</em>; 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="#validChunk">validChunk</a>(), is one which is on
the canvas.
<p> 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 <a href="#retune">retune</a>() to change it at any time. The <a href="#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> The foreground is normally nothing, but if you reimplement
<a href="#drawForeground">drawForeground</a>(), you can draw things in front of all the canvas
items.
<p> Areas can be set as changed with <a href="#setChanged">setChanged</a>() and set unchanged with
<a href="#setUnchanged">setUnchanged</a>(). The entire canvas can be set as changed with
<a href="#setAllChanged">setAllChanged</a>(). A list of all the items on the canvas is returned by
<a href="#allItems">allItems</a>().
<p> An area can be copied (painted) to a <a href="tqpainter.html">TQPainter</a> with <a href="#drawArea">drawArea</a>().
<p> If the canvas is resized it emits the <a href="#resized">resized</a>() signal.
<p> The examples/canvas application and the 2D graphics page of the
examples/demo application demonstrate many of TQCanvas's facilities.
<p> <p>See also <a href="tqcanvasview.html">TQCanvasView</a>, <a href="tqcanvasitem.html">TQCanvasItem</a>, <a href="abstractwidgets.html">Abstract Widget Classes</a>, <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="TQCanvas"></a>TQCanvas::TQCanvas ( <a href="tqobject.html">TQObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Create a TQCanvas with no size. <em>parent</em> and <em>name</em> are passed to
the <a href="tqobject.html">TQObject</a> superclass.
<p> <b>Warning:</b> You <em>must</em> call <a href="#resize">resize</a>() at some time after creation to
be able to use the canvas.

<h3 class=fn><a name="TQCanvas-2"></a>TQCanvas::TQCanvas ( int&nbsp;w, int&nbsp;h )
</h3>
Constructs a TQCanvas that is <em>w</em> pixels wide and <em>h</em> pixels high.

<h3 class=fn><a name="TQCanvas-3"></a>TQCanvas::TQCanvas ( <a href="tqpixmap.html">TQPixmap</a>&nbsp;p, int&nbsp;h, int&nbsp;v, int&nbsp;tilewidth, int&nbsp;tileheight )
</h3>
Constructs a TQCanvas which will be composed of <em>h</em> tiles
horizontally and <em>v</em> tiles vertically. Each tile will be an image
<em>tilewidth</em> by <em>tileheight</em> pixels taken from pixmap <em>p</em>.
<p> The pixmap <em>p</em> 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> <center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#f0f0f0"> <td valign="top">0 <td valign="top">1 <td valign="top">2 <td valign="top">3
<tr bgcolor="#d0d0d0"> <td valign="top">4 <td valign="top">5 <td valign="top">6 <td valign="top">7
</table></center>
<p> 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.
<p> <p>See also <a href="#setTiles">setTiles</a>().

<h3 class=fn><a name="~TQCanvas"></a>TQCanvas::~TQCanvas ()<tt> [virtual]</tt>
</h3>
Destroys the canvas and all the canvas's canvas items.

<h3 class=fn>void <a name="advance"></a>TQCanvas::advance ()<tt> [virtual slot]</tt>
</h3>
Moves all <a href="tqcanvasitem.html#animated">TQCanvasItem::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> The advance takes place in two phases. In phase 0, the
<a href="tqcanvasitem.html#advance">TQCanvasItem::advance</a>() 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 <a href="tqcanvasitem.html">TQCanvasItem</a> subclasses supplied with TQt do anything
interesting in phase 0.
<p> The canvas can be configured to call this function periodically
with <a href="#setAdvancePeriod">setAdvancePeriod</a>().
<p> <p>See also <a href="#update">update</a>().

<h3 class=fn><a href="tqcanvasitemlist.html">TQCanvasItemList</a> <a name="allItems"></a>TQCanvas::allItems ()
</h3>
Returns a list of all the items in the canvas.

<h3 class=fn><a href="tqcolor.html">TQColor</a> <a name="backgroundColor"></a>TQCanvas::backgroundColor () const
</h3>
Returns the color set by <a href="#setBackgroundColor">setBackgroundColor</a>(). By default, this is
white.
<p> This function is not a reimplementation of
<a href="tqwidget.html#backgroundColor">TQWidget::backgroundColor</a>() (TQCanvas is not a subclass of <a href="tqwidget.html">TQWidget</a>),
but all TQCanvasViews that are viewing the canvas will set their
backgrounds to this color.
<p> <p>See also <a href="#setBackgroundColor">setBackgroundColor</a>() and <a href="#backgroundPixmap">backgroundPixmap</a>().

<h3 class=fn><a href="tqpixmap.html">TQPixmap</a> <a name="backgroundPixmap"></a>TQCanvas::backgroundPixmap () const
</h3>
Returns the pixmap set by <a href="#setBackgroundPixmap">setBackgroundPixmap</a>(). By default,
this is a null pixmap.
<p> <p>See also <a href="#setBackgroundPixmap">setBackgroundPixmap</a>() and <a href="#backgroundColor">backgroundColor</a>().

<h3 class=fn>int <a name="chunkSize"></a>TQCanvas::chunkSize () const
</h3>

<p> Returns the chunk size of the canvas.
<p> <p>See also <a href="#retune">retune</a>().

<h3 class=fn><a href="tqcanvasitemlist.html">TQCanvasItemList</a> <a name="collisions"></a>TQCanvas::collisions ( const&nbsp;<a href="tqpoint.html">TQPoint</a>&nbsp;&amp;&nbsp;p ) const
</h3>
Returns a list of canvas items that collide with the point <em>p</em>.
The list is ordered by z coordinates, from highest z coordinate
(front-most item) to lowest z coordinate (rear-most item).

<h3 class=fn><a href="tqcanvasitemlist.html">TQCanvasItemList</a> <a name="collisions-2"></a>TQCanvas::collisions ( const&nbsp;<a href="tqrect.html">TQRect</a>&nbsp;&amp;&nbsp;r ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a list of items which collide with the rectangle <em>r</em>. The
list is ordered by z coordinates, from highest z coordinate
(front-most item) to lowest z coordinate (rear-most item).

<h3 class=fn><a href="tqcanvasitemlist.html">TQCanvasItemList</a> <a name="collisions-3"></a>TQCanvas::collisions ( const&nbsp;<a href="tqpointarray.html">TQPointArray</a>&nbsp;&amp;&nbsp;chunklist, const&nbsp;<a href="tqcanvasitem.html">TQCanvasItem</a>&nbsp;*&nbsp;item, bool&nbsp;exact ) const
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns a list of canvas items which intersect with the chunks
listed in <em>chunklist</em>, excluding <em>item</em>. If <em>exact</em> is TRUE,
only those which actually <a href="tqcanvasitem.html#collidesWith">collide with</a> <em>item</em> are returned; otherwise canvas items
are included just for being in the chunks.
<p> This is a utility function mainly used to implement the simpler
<a href="tqcanvasitem.html#collisions">TQCanvasItem::collisions</a>() function.

<h3 class=fn>void <a name="drawArea"></a>TQCanvas::drawArea ( const&nbsp;<a href="tqrect.html">TQRect</a>&nbsp;&amp;&nbsp;clip, <a href="tqpainter.html">TQPainter</a>&nbsp;*&nbsp;painter, bool&nbsp;dbuf = FALSE )
</h3>
Paints all canvas items that are in the area <em>clip</em> to <em>painter</em>, using double-buffering if <em>dbuf</em> is TRUE.
<p> e.g. to print the canvas to a printer:
<pre>
    <a href="tqprinter.html">TQPrinter</a> pr;
    if ( pr.<a href="tqprinter.html#setup">setup</a>() ) {
        <a href="tqpainter.html">TQPainter</a> p(&amp;pr);
        canvas.drawArea( canvas.rect(), &amp;p );
    }
    </pre>
 

<p>Example: <a href="canvas-example.html#x2908">canvas/canvas.cpp</a>.
<h3 class=fn>void <a name="drawBackground"></a>TQCanvas::drawBackground ( <a href="tqpainter.html">TQPainter</a>&nbsp;&amp;&nbsp;painter, const&nbsp;<a href="tqrect.html">TQRect</a>&nbsp;&amp;&nbsp;clip )<tt> [virtual protected]</tt>
</h3>
This virtual function is called for all updates of the canvas. It
renders any background graphics using the painter <em>painter</em>, in
the area <em>clip</em>. 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> If the graphics for an area change, you must explicitly call
<a href="#setChanged">setChanged</a>(const <a href="tqrect.html">TQRect</a>&) for the result to be visible when
<a href="#update">update</a>() is next called.
<p> <p>See also <a href="#setBackgroundColor">setBackgroundColor</a>(), <a href="#setBackgroundPixmap">setBackgroundPixmap</a>(), and <a href="#setTiles">setTiles</a>().

<h3 class=fn>void <a name="drawForeground"></a>TQCanvas::drawForeground ( <a href="tqpainter.html">TQPainter</a>&nbsp;&amp;&nbsp;painter, const&nbsp;<a href="tqrect.html">TQRect</a>&nbsp;&amp;&nbsp;clip )<tt> [virtual protected]</tt>
</h3>
This virtual function is called for all updates of the canvas. It
renders any foreground graphics using the painter <em>painter</em>, in
the area <em>clip</em>.
<p> If the graphics for an area change, you must explicitly call
<a href="#setChanged">setChanged</a>(const <a href="tqrect.html">TQRect</a>&) for the result to be visible when
<a href="#update">update</a>() is next called.
<p> The default is to draw nothing.

<h3 class=fn>int <a name="height"></a>TQCanvas::height () const
</h3>

<p> Returns the height of the canvas, in pixels.

<p>Example: <a href="canvas-example.html#x2909">canvas/canvas.cpp</a>.
<h3 class=fn>bool <a name="onCanvas"></a>TQCanvas::onCanvas ( int&nbsp;x, int&nbsp;y ) const
</h3>

<p> Returns TRUE if the pixel position (<em>x</em>, <em>y</em>) is on the canvas;
otherwise returns FALSE.
<p> <p>See also <a href="#validChunk">validChunk</a>().

<h3 class=fn>bool <a name="onCanvas-2"></a>TQCanvas::onCanvas ( const&nbsp;<a href="tqpoint.html">TQPoint</a>&nbsp;&amp;&nbsp;p ) const
</h3>

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if the pixel position <em>p</em> is on the canvas;
otherwise returns FALSE.
<p> <p>See also <a href="#validChunk">validChunk</a>().

<h3 class=fn><a href="tqrect.html">TQRect</a> <a name="rect"></a>TQCanvas::rect () const
</h3>

<p> Returns a rectangle the size of the canvas.

<h3 class=fn>void <a name="resize"></a>TQCanvas::resize ( int&nbsp;w, int&nbsp;h )<tt> [virtual]</tt>
</h3>
Changes the size of the canvas to have a width of <em>w</em> and a
height of <em>h</em>. This is a slow operation.

<p>Examples: <a href="canvas-example.html#x2910">canvas/canvas.cpp</a> and <a href="canvas-chart-example.html#x2876">chart/chartform.cpp</a>.
<h3 class=fn>void <a name="resized"></a>TQCanvas::resized ()<tt> [signal]</tt>
</h3>

<p> This signal is emitted whenever the canvas is resized. Each
<a href="tqcanvasview.html">TQCanvasView</a> connects to this signal to keep the scrollview's size
correct.

<h3 class=fn>void <a name="retune"></a>TQCanvas::retune ( int&nbsp;chunksze, int&nbsp;mxclusters = 100 )<tt> [virtual]</tt>
</h3>
Change the efficiency tuning parameters to <em>mxclusters</em> clusters,
each of size <em>chunksze</em>. This is a slow operation if there are
many objects on the canvas.
<p> The canvas is divided into chunks which are rectangular areas <em>chunksze</em> wide by <em>chunksze</em> 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> 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 <a href="#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> The <em>mxclusters</em> 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> 
<h3 class=fn>void <a name="setAdvancePeriod"></a>TQCanvas::setAdvancePeriod ( int&nbsp;ms )<tt> [virtual]</tt>
</h3>
Sets the canvas to call <a href="#advance">advance</a>() every <em>ms</em> milliseconds. Any
previous setting by <a href="#setAdvancePeriod">setAdvancePeriod</a>() or <a href="#setUpdatePeriod">setUpdatePeriod</a>() is
overridden.
<p> If <em>ms</em> is less than 0 advancing will be stopped.

<p>Example: <a href="canvas-example.html#x2962">canvas/main.cpp</a>.
<h3 class=fn>void <a name="setAllChanged"></a>TQCanvas::setAllChanged ()<tt> [virtual]</tt>
</h3>
Marks the whole canvas as changed.
All views of the canvas will be entirely redrawn when
<a href="#update">update</a>() is called next.

<h3 class=fn>void <a name="setBackgroundColor"></a>TQCanvas::setBackgroundColor ( const&nbsp;<a href="tqcolor.html">TQColor</a>&nbsp;&amp;&nbsp;c )<tt> [virtual]</tt>
</h3>
Sets the solid background to be the color <em>c</em>.
<p> <p>See also <a href="#backgroundColor">backgroundColor</a>(), <a href="#setBackgroundPixmap">setBackgroundPixmap</a>(), and <a href="#setTiles">setTiles</a>().

<h3 class=fn>void <a name="setBackgroundPixmap"></a>TQCanvas::setBackgroundPixmap ( const&nbsp;<a href="tqpixmap.html">TQPixmap</a>&nbsp;&amp;&nbsp;p )<tt> [virtual]</tt>
</h3>
Sets the solid background to be the pixmap <em>p</em> repeated as
necessary to cover the entire canvas.
<p> <p>See also <a href="#backgroundPixmap">backgroundPixmap</a>(), <a href="#setBackgroundColor">setBackgroundColor</a>(), and <a href="#setTiles">setTiles</a>().

<h3 class=fn>void <a name="setChanged"></a>TQCanvas::setChanged ( const&nbsp;<a href="tqrect.html">TQRect</a>&nbsp;&amp;&nbsp;area )<tt> [virtual]</tt>
</h3>
Marks <em>area</em> as changed. This <em>area</em> will be redrawn in all
views that are showing it when <a href="#update">update</a>() is called next.

<h3 class=fn>void <a name="setDoubleBuffering"></a>TQCanvas::setDoubleBuffering ( bool&nbsp;y )<tt> [virtual]</tt>
</h3>
If <em>y</em> is TRUE (the default) double-buffering is switched on;
otherwise double-buffering is switched off.
<p> Turning off double-buffering causes the redrawn areas to flicker a
little and also gives a (usually small) performance improvement.

<p>Example: <a href="canvas-example.html#x2911">canvas/canvas.cpp</a>.
<h3 class=fn>void <a name="setTile"></a>TQCanvas::setTile ( int&nbsp;x, int&nbsp;y, int&nbsp;tilenum )<tt> [virtual]</tt>
</h3>
Sets the tile at (<em>x</em>, <em>y</em>) to use tile number <em>tilenum</em>, which
is an index into the tile pixmaps. The canvas will update
appropriately when <a href="#update">update</a>() is next called.
<p> The images are taken from the pixmap set by <a href="#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> <center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#f0f0f0"> <td valign="top">0 <td valign="top">1 <td valign="top">2 <td valign="top">3
<tr bgcolor="#d0d0d0"> <td valign="top">4 <td valign="top">5 <td valign="top">6 <td valign="top">7
</table></center>
<p> <p>See also <a href="#tile">tile</a>() and <a href="#setTiles">setTiles</a>().

<h3 class=fn>void <a name="setTiles"></a>TQCanvas::setTiles ( <a href="tqpixmap.html">TQPixmap</a>&nbsp;p, int&nbsp;h, int&nbsp;v, int&nbsp;tilewidth, int&nbsp;tileheight )<tt> [virtual]</tt>
</h3>
Sets the TQCanvas to be composed of <em>h</em> tiles horizontally and <em>v</em> tiles vertically. Each tile will be an image <em>tilewidth</em> by <em>tileheight</em> pixels from pixmap <em>p</em>.
<p> The pixmap <em>p</em> 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> <center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#f0f0f0"> <td valign="top">0 <td valign="top">1 <td valign="top">2 <td valign="top">3
<tr bgcolor="#d0d0d0"> <td valign="top">4 <td valign="top">5 <td valign="top">6 <td valign="top">7
</table></center>
<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> The width and height of <em>p</em> must be a multiple of <em>tilewidth</em>
and <em>tileheight</em>. If they are not the function will do nothing.
<p> If you want to unset any tiling set, then just pass in a null
pixmap and 0 for <em>h</em>, <em>v</em>, <em>tilewidth</em>, and
<em>tileheight</em>.

<h3 class=fn>void <a name="setUnchanged"></a>TQCanvas::setUnchanged ( const&nbsp;<a href="tqrect.html">TQRect</a>&nbsp;&amp;&nbsp;area )<tt> [virtual]</tt>
</h3>
Marks <em>area</em> as <em>unchanged</em>. The area will <em>not</em> be redrawn in
the views for the next <a href="#update">update</a>(), unless it is marked or changed
again before the next call to update().

<h3 class=fn>void <a name="setUpdatePeriod"></a>TQCanvas::setUpdatePeriod ( int&nbsp;ms )<tt> [virtual]</tt>
</h3>
Sets the canvas to call <a href="#update">update</a>() every <em>ms</em> milliseconds. Any
previous setting by <a href="#setAdvancePeriod">setAdvancePeriod</a>() or <a href="#setUpdatePeriod">setUpdatePeriod</a>() is
overridden.
<p> If <em>ms</em> is less than 0 automatic updating will be stopped.

<h3 class=fn><a href="tqsize.html">TQSize</a> <a name="size"></a>TQCanvas::size () const
</h3>

<p> Returns the size of the canvas, in pixels.

<h3 class=fn>int <a name="tile"></a>TQCanvas::tile ( int&nbsp;x, int&nbsp;y ) const
</h3>

<p> Returns the tile at position (<em>x</em>, <em>y</em>). Initially, all tiles
are 0.
<p> The parameters must be within range, i.e.
0 &lt; <em>x</em> &lt; <a href="#tilesHorizontally">tilesHorizontally</a>() and
0 &lt; <em>y</em> &lt; <a href="#tilesVertically">tilesVertically</a>().
<p> <p>See also <a href="#setTile">setTile</a>().

<h3 class=fn>int <a name="tileHeight"></a>TQCanvas::tileHeight () const
</h3>

<p> Returns the height of each tile.

<h3 class=fn>int <a name="tileWidth"></a>TQCanvas::tileWidth () const
</h3>

<p> Returns the width of each tile.

<h3 class=fn>int <a name="tilesHorizontally"></a>TQCanvas::tilesHorizontally () const
</h3>

<p> Returns the number of tiles horizontally.

<h3 class=fn>int <a name="tilesVertically"></a>TQCanvas::tilesVertically () const
</h3>

<p> Returns the number of tiles vertically.

<h3 class=fn>void <a name="update"></a>TQCanvas::update ()<tt> [virtual slot]</tt>
</h3>
Repaints changed areas in all views of the canvas.
<p> <p>See also <a href="#advance">advance</a>().

<h3 class=fn>bool <a name="validChunk"></a>TQCanvas::validChunk ( int&nbsp;x, int&nbsp;y ) const
</h3>

<p> Returns TRUE if the chunk position (<em>x</em>, <em>y</em>) is on the canvas;
otherwise returns FALSE.
<p> <p>See also <a href="#onCanvas">onCanvas</a>().

<h3 class=fn>bool <a name="validChunk-2"></a>TQCanvas::validChunk ( const&nbsp;<a href="tqpoint.html">TQPoint</a>&nbsp;&amp;&nbsp;p ) const
</h3>

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Returns TRUE if the chunk position <em>p</em> is on the canvas; otherwise
returns FALSE.
<p> <p>See also <a href="#onCanvas">onCanvas</a>().

<h3 class=fn>int <a name="width"></a>TQCanvas::width () const
</h3>

<p> Returns the width of the canvas, in pixels.

<p>Example: <a href="canvas-example.html#x2912">canvas/canvas.cpp</a>.
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">TQt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>TQt 3.3.8</div>
</table></div></address></body>
</html>