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 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>
Qt Toolkit - qcanvas.h include file
</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>qcanvas.h</h1><br clear="all">
This is the verbatim text of the qcanvas.h include file. It is
provided only for illustration; the copyright
remains with Trolltech.
<hr>
<pre>
/**********************************************************************
** $Id: qt/src/canvas/qcanvas.h 2.3.1 edited 2001-01-26 $
**
** Definition of QCanvas classes
**
** Created : 991211
**
** Copyright (C) 1999-2000 Trolltech AS. All rights reserved.
**
** This file is part of the canvas module of the Qt GUI Toolkit.
**
** This file may be distributed under the terms of the Q Public License
** as defined by Trolltech AS of Norway and appearing in the file
** LICENSE.QPL included in the packaging of this file.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** Licensees holding valid Qt Enterprise Edition licenses may use this
** file in accordance with the Qt Commercial License Agreement provided
** with the Software.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
** information about Qt Commercial License Agreements.
** See http://www.trolltech.com/qpl/ for QPL licensing information.
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef QCANVAS_H
#define QCANVAS_H
#ifndef QT_H
#include <qbitmap.h>
#include <qwidget.h>
#include <qscrollview.h>
#include <qlist.h>
#include <qptrdict.h>
#endif // QT_H
#ifndef QT_NO_CANVAS
class <a href="qcanvassprite.html">QCanvasSprite</a>;
class <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a>;
class <a href="qcanvasrectangle.html">QCanvasRectangle</a>;
class <a href="qcanvaspolygon.html">QCanvasPolygon</a>;
class <a href="qcanvasellipse.html">QCanvasEllipse</a>;
class <a href="qcanvastext.html">QCanvasText</a>;
class <a href="qcanvasline.html">QCanvasLine</a>;
class QCanvasChunk;
class <a href="qcanvas.html">QCanvas</a>;
class QCanvasData;
class <a href="qcanvasitem.html">QCanvasItem</a>;
class <a href="qcanvasview.html">QCanvasView</a>;
class <a href="qcanvaspixmap.html">QCanvasPixmap</a>;
#if defined(Q_TEMPLATEDLL)
// MOC_SKIP_BEGIN
template class Q_EXPORT QList< QCanvasItem >;
template class Q_EXPORT QList< QCanvasView >;
template class Q_EXPORT QValueList< QCanvasItem* >;
// MOC_SKIP_END
#endif
class QCanvasItemList : public QValueList<QCanvasItem*> {
public:
void sort();
void drawUnique( QPainter& painter );
};
class QCanvasItemExtra;
class Q_EXPORT <a href="qcanvasitem.html">QCanvasItem</a> : public <a href="qt.html">Qt</a>
{
public:
QCanvasItem(QCanvas* canvas);
virtual ~QCanvasItem();
double x() const
{ return myx; }
double y() const
{ return myy; }
double z() const
{ return myz; } // (depth)
virtual void moveBy(double dx, double dy);
void move(double x, double y);
void setX(double a) { move(a,y()); }
void setY(double a) { move(x(),a); }
void setZ(double a) { myz=a; changeChunks(); }
bool animated() const;
virtual void setAnimated(bool y);
virtual void setVelocity( double vx, double vy);
void setXVelocity( double vx ) { setVelocity(vx,yVelocity()); }
void setYVelocity( double vy ) { setVelocity(xVelocity(),vy); }
double xVelocity() const;
double yVelocity() const;
virtual void advance(int stage);
virtual bool collidesWith( const QCanvasItem* ) const=0;
QCanvasItemList collisions(bool exact /* NO DEFAULT */ ) const;
virtual void setCanvas(QCanvas*);
virtual void draw(QPainter&)=0;
void show();
void hide();
virtual void setVisible(bool yes);
bool visible() const
{ return (bool)vis; }
virtual void setSelected(bool yes);
bool selected() const
{ return (bool)sel; }
virtual void setEnabled(bool yes);
bool enabled() const
{ return (bool)ena; }
virtual void setActive(bool yes);
bool active() const
{ return (bool)act; }
virtual int rtti() const;
virtual QRect boundingRect() const=0;
virtual QRect boundingRectAdvanced() const;
QCanvas* canvas() const
{ return cnv; }
private:
// For friendly sublasses...
friend class QCanvasPolygonalItem;
friend class QCanvasSprite;
friend class QCanvasRectangle;
friend class QCanvasPolygon;
friend class QCanvasEllipse;
friend class QCanvasText;
friend class QCanvasLine;
virtual QPointArray chunks() const;
virtual void addToChunks();
virtual void removeFromChunks();
virtual void changeChunks();
virtual bool collidesWith( const QCanvasSprite*,
const QCanvasPolygonalItem*,
const QCanvasRectangle*,
const QCanvasEllipse*,
const QCanvasText* ) const=0;
// End of friend stuff
QCanvas* cnv;
static QCanvas* current_canvas;
double myx,myy,myz;
QCanvasItemExtra *ext;
QCanvasItemExtra& extra();
uint ani:1;
uint vis:1;
uint sel:1;
uint ena:1;
uint act:1;
};
class Q_EXPORT <a href="qcanvas.html">QCanvas</a> : public <a href="qobject.html">QObject</a>
{
Q_OBJECT
public:
QCanvas( QObject* parent = 0, const char* name = 0 );
QCanvas(int w, int h);
QCanvas( QPixmap p, int h, int v, int tilewidth, int tileheight );
virtual ~QCanvas();
virtual void setTiles( QPixmap tiles, int h, int v,
int tilewidth, int tileheight );
virtual void setBackgroundPixmap( const QPixmap& p );
QPixmap backgroundPixmap() const;
virtual void setBackgroundColor( const QColor& c );
QColor backgroundColor() const;
virtual void setTile( int x, int y, int tilenum );
int tile( int x, int y ) const
{ return grid[x+y*htiles]; }
int tilesHorizontally() const
{ return htiles; }
int tilesVertically() const
{ return vtiles; }
int tileWidth() const
{ return tilew; }
int tileHeight() const
{ return tileh; }
virtual void resize(int width, int height);
int width() const
{ return awidth; }
int height() const
{ return aheight; }
QSize size() const
{ return QSize(awidth,aheight); }
bool onCanvas( int x, int y ) const
{ return x>=0 && y>=0 && x<awidth && y<aheight; }
bool onCanvas( const QPoint& p ) const
{ return onCanvas(p.x(),p.y()); }
bool validChunk( int x, int y ) const
{ return x>=0 && y>=0 && x<chwidth && y<chheight; }
bool validChunk( const QPoint& p ) const
{ return validChunk(p.x(),p.y()); }
int chunkSize() const
{ return chunksize; }
virtual void retune(int chunksize, int maxclusters=100);
bool sameChunk(int x1, int y1, int x2, int y2) const
{ return x1/chunksize==x2/chunksize && y1/chunksize==y2/chunksize; }
virtual void setChangedChunk(int i, int j);
virtual void setChangedChunkContaining(int x, int y);
virtual void setAllChanged();
virtual void setChanged(const QRect& inarea);
// These call setChangedChunk.
void addItemToChunk(QCanvasItem*, int i, int j);
void removeItemFromChunk(QCanvasItem*, int i, int j);
void addItemToChunkContaining(QCanvasItem*, int x, int y);
void removeItemFromChunkContaining(QCanvasItem*, int x, int y);
QCanvasItemList allItems();
QCanvasItemList collisions( const QPoint&) const;
QCanvasItemList collisions( const QRect&) const;
QCanvasItemList collisions( const QPointArray& pa, const QCanvasItem* item,
bool exact) const;
// These are for QCanvasView to call
virtual void addView(QCanvasView*);
virtual void removeView(QCanvasView*);
void drawArea(const QRect&, QPainter* p=0, bool double_buffer=TRUE);
// These are for QCanvasItem to call
virtual void addItem(QCanvasItem*);
virtual void addAnimation(QCanvasItem*);
virtual void removeItem(QCanvasItem*);
virtual void removeAnimation(QCanvasItem*);
virtual void setAdvancePeriod(int ms);
virtual void setUpdatePeriod(int ms);
virtual void setDoubleBuffering(bool y);
signals:
void resized();
public slots:
virtual void advance();
virtual void update();
protected:
virtual void drawBackground(QPainter&, const QRect& area);
virtual void drawForeground(QPainter&, const QRect& area);
private:
void init(int w, int h, int chunksze=16, int maxclust=100);
QCanvasChunk& chunk(int i, int j) const;
QCanvasChunk& chunkContaining(int x, int y) const;
void drawChanges(const QRect& inarea);
QPixmap offscr;
int awidth,aheight;
int chunksize;
int maxclusters;
int chwidth,chheight;
QCanvasChunk* chunks;
QCanvasData* d;
void initTiles(QPixmap p, int h, int v, int tilewidth, int tileheight);
ushort *grid;
ushort htiles;
ushort vtiles;
ushort tilew;
ushort tileh;
bool oneone;
QPixmap pm;
QTimer* update_timer;
QColor bgcolor;
bool debug_redraw_areas;
bool dblbuf;
friend void qt_unview(QCanvas* c);
};
class Q_EXPORT <a href="qcanvasview.html">QCanvasView</a> : public <a href="qscrollview.html">QScrollView</a>
{
Q_OBJECT
public:
QCanvasView(QCanvas* viewing=0, QWidget* parent=0, const char* name=0, WFlags f=0);
~QCanvasView();
QCanvas* canvas() const
{ return viewing; }
void setCanvas(QCanvas* v);
protected:
void drawContents( QPainter*, int cx, int cy, int cw, int ch );
QSize sizeHint() const;
private:
QCanvas* viewing;
friend void qt_unview(QCanvas* c);
private slots:
void cMoving(int,int);
void updateContentsSize();
};
class Q_EXPORT <a href="qcanvaspixmap.html">QCanvasPixmap</a> : public <a href="qpixmap.html">QPixmap</a>
{
public:
QCanvasPixmap(const QString& datafilename);
QCanvasPixmap(const QImage& image);
QCanvasPixmap(const QPixmap&, QPoint hotspot);
~QCanvasPixmap();
int offsetX() const
{ return hotx; }
int offsetY() const
{ return hoty; }
void setOffset(int x, int y) { hotx = x; hoty = y; }
private:
void init(const QImage&);
void init(const QPixmap& pixmap, int hx, int hy);
friend class QCanvasSprite;
friend class QCanvasPixmapArray;
friend bool qt_testCollision(const QCanvasSprite* s1, const QCanvasSprite* s2);
int hotx,hoty;
QImage* collision_mask;
};
class Q_EXPORT <a href="qcanvaspixmaparray.html">QCanvasPixmapArray</a>
{
public:
QCanvasPixmapArray();
QCanvasPixmapArray(const QString& datafilenamepattern, int framecount=0);
QCanvasPixmapArray(QList<QPixmap>, QList<QPoint> hotspots);
~QCanvasPixmapArray();
bool readPixmaps(const QString& datafilenamepattern, int framecount=0);
bool readCollisionMasks(const QString& filenamepattern);
int operator!(); // Failure check.
QCanvasPixmap* image(int i) const
{ return img[i]; }
void setImage(int i, QCanvasPixmap* p);
uint count() const
{ return (uint)framecount; }
private:
bool readPixmaps(const QString& datafilenamepattern, int framecount, bool maskonly);
void reset();
int framecount;
QCanvasPixmap** img;
};
class Q_EXPORT <a href="qcanvassprite.html">QCanvasSprite</a> : public <a href="qcanvasitem.html">QCanvasItem</a>
{
public:
QCanvasSprite(QCanvasPixmapArray* array, QCanvas* canvas);
void setSequence(QCanvasPixmapArray* seq);
virtual ~QCanvasSprite();
void move(double x, double y);
virtual void move(double x, double y, int frame);
void setFrame(int);
int frame() const
{ return frm; }
int frameCount() const
{ return images->count(); }
virtual int rtti() const;
bool collidesWith( const QCanvasItem* ) const;
QRect boundingRect() const;
protected:
void draw(QPainter& painter);
int width() const;
int height() const;
int absX() const;
int absY() const;
int absX2() const;
int absY2() const;
int absX(int nx) const;
int absY(int ny) const;
int absX2(int nx) const;
int absY2(int ny) const;
QCanvasPixmap* image() const
{ return images->image(frm); }
virtual QCanvasPixmap* imageAdvanced() const;
QCanvasPixmap* image(int f) const
{ return images->image(f); }
private:
void addToChunks();
void removeFromChunks();
void changeChunks();
int frm;
bool collidesWith( const QCanvasSprite*,
const QCanvasPolygonalItem*,
const QCanvasRectangle*,
const QCanvasEllipse*,
const QCanvasText* ) const;
friend bool qt_testCollision( const QCanvasSprite* s1,
const QCanvasSprite* s2 );
QCanvasPixmapArray* images;
};
class QPolygonalProcessor;
class Q_EXPORT <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a> : public <a href="qcanvasitem.html">QCanvasItem</a>
{
public:
QCanvasPolygonalItem(QCanvas* canvas);
virtual ~QCanvasPolygonalItem();
bool collidesWith( const QCanvasItem* ) const;
virtual void setPen(QPen p);
virtual void setBrush(QBrush b);
QPen pen() const
{ return pn; }
QBrush brush() const
{ return br; }
virtual QPointArray areaPoints() const=0;
virtual QPointArray areaPointsAdvanced() const;
QRect boundingRect() const;
int rtti() const;
protected:
void draw(QPainter &);
virtual void drawShape(QPainter &) = 0;
bool winding() const;
void setWinding(bool);
private:
void scanPolygon( const QPointArray& pa, int winding,
QPolygonalProcessor& process ) const;
QPointArray chunks() const;
bool collidesWith( const QCanvasSprite*,
const QCanvasPolygonalItem*,
const QCanvasRectangle*,
const QCanvasEllipse*,
const QCanvasText* ) const;
QBrush br;
QPen pn;
uint wind:1;
};
class Q_EXPORT <a href="qcanvasrectangle.html">QCanvasRectangle</a> : public <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a>
{
public:
QCanvasRectangle(QCanvas* canvas);
QCanvasRectangle(const QRect&, QCanvas* canvas);
QCanvasRectangle(int x, int y, int width, int height, QCanvas* canvas);
~QCanvasRectangle();
int width() const;
int height() const;
void setSize(int w, int h);
QSize size() const
{ return QSize(w,h); }
QPointArray areaPoints() const;
QRect rect() const
{ return QRect(int(x()),int(y()),w,h); }
bool collidesWith( const QCanvasItem* ) const;
int rtti() const;
protected:
void drawShape(QPainter &);
QPointArray chunks() const;
private:
bool collidesWith( const QCanvasSprite*,
const QCanvasPolygonalItem*,
const QCanvasRectangle*,
const QCanvasEllipse*,
const QCanvasText* ) const;
int w, h;
};
class Q_EXPORT <a href="qcanvaspolygon.html">QCanvasPolygon</a> : public <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a>
{
public:
QCanvasPolygon(QCanvas* canvas);
~QCanvasPolygon();
void setPoints(QPointArray);
QPointArray points() const;
void moveBy(double dx, double dy);
QPointArray areaPoints() const;
int rtti() const;
protected:
void drawShape(QPainter &);
QPointArray poly;
};
class Q_EXPORT <a href="qcanvasline.html">QCanvasLine</a> : public <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a>
{
public:
QCanvasLine(QCanvas* canvas);
~QCanvasLine();
void setPoints(int x1, int y1, int x2, int y2);
QPoint startPoint() const
{ return QPoint(x1,y1); }
QPoint endPoint() const
{ return QPoint(x2,y2); }
int rtti() const;
void setPen(QPen p);
protected:
void drawShape(QPainter &);
QPointArray areaPoints() const;
private:
int x1,y1,x2,y2;
};
class Q_EXPORT <a href="qcanvasellipse.html">QCanvasEllipse</a> : public <a href="qcanvaspolygonalitem.html">QCanvasPolygonalItem</a>
{
public:
QCanvasEllipse( QCanvas* canvas );
QCanvasEllipse( int width, int height, QCanvas* canvas );
QCanvasEllipse( int width, int height, int startangle, int angle,
QCanvas* canvas );
~QCanvasEllipse();
int width() const;
int height() const;
void setSize(int w, int h);
void setAngles(int start, int length);
int angleStart() const
{ return a1; }
int angleLength() const
{ return a2; }
QPointArray areaPoints() const;
bool collidesWith( const QCanvasItem* ) const;
int rtti() const;
protected:
void drawShape(QPainter &);
private:
bool collidesWith( const QCanvasSprite*,
const QCanvasPolygonalItem*,
const QCanvasRectangle*,
const QCanvasEllipse*,
const QCanvasText* ) const;
int w, h;
int a1, a2;
};
class QCanvasTextExtra;
class Q_EXPORT <a href="qcanvastext.html">QCanvasText</a> : public <a href="qcanvasitem.html">QCanvasItem</a>
{
public:
QCanvasText(QCanvas* canvas);
QCanvasText(const QString&, QCanvas* canvas);
QCanvasText(const QString&, QFont, QCanvas* canvas);
virtual ~QCanvasText();
void setText( const QString& );
void setFont( const QFont& );
void setColor( const QColor& );
QString text() const;
QFont font() const;
QColor color() const;
void moveBy(double dx, double dy);
int textFlags() const
{ return flags; }
void setTextFlags(int);
QRect boundingRect() const;
bool collidesWith( const QCanvasItem* ) const;
virtual int rtti() const;
protected:
virtual void draw(QPainter&);
private:
void addToChunks();
void removeFromChunks();
void changeChunks();
void setRect();
QRect brect;
QString txt;
int flags;
QFont fnt;
QColor col;
QCanvasTextExtra* extra;
bool collidesWith( const QCanvasSprite*,
const QCanvasPolygonalItem*,
const QCanvasRectangle*,
const QCanvasEllipse*,
const QCanvasText* ) const;
};
#endif // QT_NO_CANVAS
#endif // QCANVAS_H
</pre>
<p><address><hr><div align="center">
<table width="100%" cellspacing="0" border="0"><tr>
<td>Copyright 2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.1</div>
</table></div></address></body></html>
|