1 /**********************************************************************
2 ** $Id: qt/qcanvas.h   3.3.8   edited Jan 11 14:46 $
3 **
4 ** Definition of QCanvas classes
5 **
6 ** Created : 991211
7 **
8 ** Copyright (C) 1999-2007 Trolltech ASA.  All rights reserved.
9 **
10 ** This file is part of the canvas module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech ASA of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition licenses may use this
22 ** file in accordance with the Qt Commercial License Agreement provided
23 ** with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 **   information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 #ifndef QCANVAS_H
39 #define QCANVAS_H
40 
41 #ifndef QT_H
42 #include "qscrollview.h"
43 #include "qpixmap.h"
44 #include "qptrlist.h"
45 #include "qbrush.h"
46 #include "qpen.h"
47 #include "qvaluelist.h"
48 #include "qpointarray.h"
49 #endif // QT_H
50 
51 #if !defined( QT_MODULE_CANVAS ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_CANVAS )
52 #define QM_EXPORT_CANVAS
53 #define QM_TEMPLATE_EXTERN_CANVAS
54 #else
55 #define QM_EXPORT_CANVAS Q_EXPORT
56 #define QM_TEMPLATE_EXTERN_CANVAS Q_TEMPLATE_EXTERN
57 #endif
58 
59 #ifndef QT_NO_CANVAS
60 
61 
62 class QCanvasSprite;
63 class QCanvasPolygonalItem;
64 class QCanvasRectangle;
65 class QCanvasPolygon;
66 class QCanvasEllipse;
67 class QCanvasText;
68 class QCanvasLine;
69 class QCanvasChunk;
70 class QCanvas;
71 class QCanvasItem;
72 class QCanvasView;
73 class QCanvasPixmap;
74 
75 #if defined(Q_TEMPLATEDLL) && ( !defined(Q_CC_BOR) || !defined(QT_MAKEDLL) || defined(Q_EXPORT_TEMPLATES) )
76 // MOC_SKIP_BEGIN
77 QM_TEMPLATE_EXTERN_CANVAS template class QM_EXPORT_CANVAS QValueListIterator< QCanvasItem* >;
78 QM_TEMPLATE_EXTERN_CANVAS template class QM_EXPORT_CANVAS QValueList< QCanvasItem* >;
79 // MOC_SKIP_END
80 #endif
81 
82 class QM_EXPORT_CANVAS QCanvasItemList : public QValueList<QCanvasItem*> {
83 public:
84     void sort();
85     void drawUnique( QPainter& painter );
86     QCanvasItemList operator+(const QCanvasItemList &l) const;
87 };
88 
89 
90 class QCanvasItemExtra;
91 
92 class QM_EXPORT_CANVAS QCanvasItem : public Qt
93 {
94 public:
95     QCanvasItem(QCanvas* canvas);
96     virtual ~QCanvasItem();
97 
x()98     double x() const
99 	{ return myx; }
y()100     double y() const
101 	{ return myy; }
z()102     double z() const
103 	{ return myz; } // (depth)
104 
105     virtual void moveBy(double dx, double dy);
106     void move(double x, double y);
setX(double a)107     void setX(double a) { move(a,y()); }
setY(double a)108     void setY(double a) { move(x(),a); }
setZ(double a)109     void setZ(double a) { myz=a; changeChunks(); }
110 
111     bool animated() const;
112     virtual void setAnimated(bool y);
113     virtual void setVelocity( double vx, double vy);
setXVelocity(double vx)114     void setXVelocity( double vx ) { setVelocity(vx,yVelocity()); }
setYVelocity(double vy)115     void setYVelocity( double vy ) { setVelocity(xVelocity(),vy); }
116     double xVelocity() const;
117     double yVelocity() const;
118     virtual void advance(int stage);
119 
120     virtual bool collidesWith( const QCanvasItem* ) const=0;
121 
122     QCanvasItemList collisions(bool exact /* NO DEFAULT */ ) const;
123 
124     virtual void setCanvas(QCanvas*);
125 
126     virtual void draw(QPainter&)=0;
127 
128     void show();
129     void hide();
130 
131     virtual void setVisible(bool yes);
isVisible()132     bool isVisible() const
133 	{ return (bool)vis; }
134     virtual void setSelected(bool yes);
isSelected()135     bool isSelected() const
136 	{ return (bool)sel; }
137     virtual void setEnabled(bool yes);
isEnabled()138     bool isEnabled() const
139 	{ return (bool)ena; }
140     virtual void setActive(bool yes);
isActive()141     bool isActive() const
142 	{ return (bool)act; }
143 #ifndef QT_NO_COMPAT
visible()144     bool visible() const
145 	{ return (bool)vis; }
selected()146     bool selected() const
147 	{ return (bool)sel; }
enabled()148     bool enabled() const
149 	{ return (bool)ena; }
active()150     bool active() const
151 	{ return (bool)act; }
152 #endif
153 
154     enum RttiValues {
155 	Rtti_Item = 0,
156 	Rtti_Sprite = 1,
157 	Rtti_PolygonalItem = 2,
158 	Rtti_Text = 3,
159 	Rtti_Polygon = 4,
160 	Rtti_Rectangle = 5,
161 	Rtti_Ellipse = 6,
162 	Rtti_Line = 7,
163 	Rtti_Spline = 8
164     };
165 
166     virtual int rtti() const;
167     static int RTTI;
168 
169     virtual QRect boundingRect() const=0;
170     virtual QRect boundingRectAdvanced() const;
171 
canvas()172     QCanvas* canvas() const
173 	{ return cnv; }
174 
175 protected:
update()176     void update() { changeChunks(); }
177 
178 private:
179     // For friendly subclasses...
180 
181     friend class QCanvasPolygonalItem;
182     friend class QCanvasSprite;
183     friend class QCanvasRectangle;
184     friend class QCanvasPolygon;
185     friend class QCanvasEllipse;
186     friend class QCanvasText;
187     friend class QCanvasLine;
188 
189     virtual QPointArray chunks() const;
190     virtual void addToChunks();
191     virtual void removeFromChunks();
192     virtual void changeChunks();
193     virtual bool collidesWith( const QCanvasSprite*,
194 			       const QCanvasPolygonalItem*,
195 			       const QCanvasRectangle*,
196 			       const QCanvasEllipse*,
197 			       const QCanvasText* ) const = 0;
198     // End of friend stuff
199 
200     QCanvas* cnv;
201     static QCanvas* current_canvas;
202     double myx,myy,myz;
203     QCanvasItemExtra *ext;
204     QCanvasItemExtra& extra();
205     uint ani:1;
206     uint vis:1;
207     uint val:1;
208     uint sel:1;
209     uint ena:1;
210     uint act:1;
211 };
212 
213 
214 class QCanvasData;
215 
216 class QM_EXPORT_CANVAS QCanvas : public QObject
217 {
218     Q_OBJECT
219 public:
220     QCanvas( QObject* parent = 0, const char* name = 0 );
221     QCanvas(int w, int h);
222     QCanvas( QPixmap p, int h, int v, int tilewidth, int tileheight );
223 
224     virtual ~QCanvas();
225 
226     virtual void setTiles( QPixmap tiles, int h, int v,
227 			   int tilewidth, int tileheight );
228     virtual void setBackgroundPixmap( const QPixmap& p );
229     QPixmap backgroundPixmap() const;
230 
231     virtual void setBackgroundColor( const QColor& c );
232     QColor backgroundColor() const;
233 
234     virtual void setTile( int x, int y, int tilenum );
tile(int x,int y)235     int tile( int x, int y ) const
236 	{ return grid[x+y*htiles]; }
237 
tilesHorizontally()238     int tilesHorizontally() const
239 	{ return htiles; }
tilesVertically()240     int tilesVertically() const
241 	{ return vtiles; }
242 
tileWidth()243     int tileWidth() const
244 	{ return tilew; }
tileHeight()245     int tileHeight() const
246 	{ return tileh; }
247 
248     virtual void resize(int width, int height);
width()249     int width() const
250 	{ return awidth; }
height()251     int height() const
252 	{ return aheight; }
size()253     QSize size() const
254 	{ return QSize(awidth,aheight); }
rect()255     QRect rect() const
256 	{ return QRect( 0, 0, awidth, aheight ); }
onCanvas(int x,int y)257     bool onCanvas( int x, int y ) const
258 	{ return x>=0 && y>=0 && x<awidth && y<aheight; }
onCanvas(const QPoint & p)259     bool onCanvas( const QPoint& p ) const
260 	{ return onCanvas(p.x(),p.y()); }
validChunk(int x,int y)261     bool validChunk( int x, int y ) const
262 	{ return x>=0 && y>=0 && x<chwidth && y<chheight; }
validChunk(const QPoint & p)263     bool validChunk( const QPoint& p ) const
264 	{ return validChunk(p.x(),p.y()); }
265 
chunkSize()266     int chunkSize() const
267 	{ return chunksize; }
268     virtual void retune(int chunksize, int maxclusters=100);
269 
sameChunk(int x1,int y1,int x2,int y2)270     bool sameChunk(int x1, int y1, int x2, int y2) const
271 	{ return x1/chunksize==x2/chunksize && y1/chunksize==y2/chunksize; }
272     virtual void setChangedChunk(int i, int j);
273     virtual void setChangedChunkContaining(int x, int y);
274     virtual void setAllChanged();
275     virtual void setChanged(const QRect& area);
276     virtual void setUnchanged(const QRect& area);
277 
278     // These call setChangedChunk.
279     void addItemToChunk(QCanvasItem*, int i, int j);
280     void removeItemFromChunk(QCanvasItem*, int i, int j);
281     void addItemToChunkContaining(QCanvasItem*, int x, int y);
282     void removeItemFromChunkContaining(QCanvasItem*, int x, int y);
283 
284     QCanvasItemList allItems();
285     QCanvasItemList collisions( const QPoint&) const;
286     QCanvasItemList collisions( const QRect&) const;
287     QCanvasItemList collisions( const QPointArray& pa, const QCanvasItem* item,
288 				bool exact) const;
289 
290     void drawArea(const QRect&, QPainter* p, bool double_buffer=FALSE);
291 
292     // These are for QCanvasView to call
293     virtual void addView(QCanvasView*);
294     virtual void removeView(QCanvasView*);
295     void drawCanvasArea(const QRect&, QPainter* p=0, bool double_buffer=TRUE);
296     void drawViewArea( QCanvasView* view, QPainter* p, const QRect& r, bool dbuf );
297 
298     // These are for QCanvasItem to call
299     virtual void addItem(QCanvasItem*);
300     virtual void addAnimation(QCanvasItem*);
301     virtual void removeItem(QCanvasItem*);
302     virtual void removeAnimation(QCanvasItem*);
303 
304     virtual void setAdvancePeriod(int ms);
305     virtual void setUpdatePeriod(int ms);
306 
307     virtual void setDoubleBuffering(bool y);
308 
309 signals:
310     void resized();
311 
312 public slots:
313     virtual void advance();
314     virtual void update();
315 
316 protected:
317     virtual void drawBackground(QPainter&, const QRect& area);
318     virtual void drawForeground(QPainter&, const QRect& area);
319 
320 private:
321     void init(int w, int h, int chunksze=16, int maxclust=100);
322 
323     QCanvasChunk& chunk(int i, int j) const;
324     QCanvasChunk& chunkContaining(int x, int y) const;
325 
326     QRect changeBounds(const QRect& inarea);
327     void drawChanges(const QRect& inarea);
328 
329     QPixmap offscr;
330     int awidth,aheight;
331     int chunksize;
332     int maxclusters;
333     int chwidth,chheight;
334     QCanvasChunk* chunks;
335 
336     QCanvasData* d;
337 
338     void initTiles(QPixmap p, int h, int v, int tilewidth, int tileheight);
339     ushort *grid;
340     ushort htiles;
341     ushort vtiles;
342     ushort tilew;
343     ushort tileh;
344     bool oneone;
345     QPixmap pm;
346     QTimer* update_timer;
347     QColor bgcolor;
348     bool debug_redraw_areas;
349     bool dblbuf;
350 
351     friend void qt_unview(QCanvas* c);
352 
353 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
354     QCanvas( const QCanvas & );
355     QCanvas &operator=( const QCanvas & );
356 #endif
357 };
358 
359 class QCanvasViewData;
360 
361 class QM_EXPORT_CANVAS QCanvasView : public QScrollView
362 {
363     Q_OBJECT
364 public:
365 
366     QCanvasView(QWidget* parent=0, const char* name=0, WFlags f=0);
367     QCanvasView(QCanvas* viewing, QWidget* parent=0, const char* name=0, WFlags f=0);
368     ~QCanvasView();
369 
canvas()370     QCanvas* canvas() const
371 	{ return viewing; }
372     void setCanvas(QCanvas* v);
373 
374     const QWMatrix &worldMatrix() const;
375     const QWMatrix &inverseWorldMatrix() const;
376     bool setWorldMatrix( const QWMatrix & );
377 
378 protected:
379     void drawContents( QPainter*, int cx, int cy, int cw, int ch );
380     QSize sizeHint() const;
381 
382 private:
383     void drawContents( QPainter* );
384     QCanvas* viewing;
385     QCanvasViewData* d;
386     friend void qt_unview(QCanvas* c);
387 
388 private slots:
389     void cMoving(int,int);
390     void updateContentsSize();
391 
392 private:
393 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
394     QCanvasView( const QCanvasView & );
395     QCanvasView &operator=( const QCanvasView & );
396 #endif
397 };
398 
399 
400 class QM_EXPORT_CANVAS QCanvasPixmap : public QPixmap
401 {
402 public:
403 #ifndef QT_NO_IMAGEIO
404     QCanvasPixmap(const QString& datafilename);
405 #endif
406     QCanvasPixmap(const QImage& image);
407     QCanvasPixmap(const QPixmap&, const QPoint& hotspot);
408     ~QCanvasPixmap();
409 
offsetX()410     int offsetX() const
411 	{ return hotx; }
offsetY()412     int offsetY() const
413 	{ return hoty; }
setOffset(int x,int y)414     void setOffset(int x, int y) { hotx = x; hoty = y; }
415 
416 private:
417 #if defined(Q_DISABLE_COPY)
418     QCanvasPixmap( const QCanvasPixmap & );
419     QCanvasPixmap &operator=( const QCanvasPixmap & );
420 #endif
421     void init(const QImage&);
422     void init(const QPixmap& pixmap, int hx, int hy);
423 
424     friend class QCanvasSprite;
425     friend class QCanvasPixmapArray;
426     friend bool qt_testCollision(const QCanvasSprite* s1, const QCanvasSprite* s2);
427 
428     int hotx,hoty;
429 
430     QImage* collision_mask;
431 };
432 
433 
434 class QM_EXPORT_CANVAS QCanvasPixmapArray
435 {
436 public:
437     QCanvasPixmapArray();
438 #ifndef QT_NO_IMAGEIO
439     QCanvasPixmapArray(const QString& datafilenamepattern, int framecount=0);
440 #endif
441     // this form is deprecated
442     QCanvasPixmapArray(QPtrList<QPixmap>, QPtrList<QPoint> hotspots);
443 
444     QCanvasPixmapArray(QValueList<QPixmap>, QPointArray hotspots = QPointArray() );
445     ~QCanvasPixmapArray();
446 
447 #ifndef QT_NO_IMAGEIO
448     bool readPixmaps(const QString& datafilenamepattern, int framecount=0);
449     bool readCollisionMasks(const QString& filenamepattern);
450 #endif
451 
452     // deprecated
453     bool operator!(); // Failure check.
454     bool isValid() const;
455 
image(int i)456     QCanvasPixmap* image(int i) const
457 	{ return img ? img[i] : 0; }
458     void setImage(int i, QCanvasPixmap* p);
count()459     uint count() const
460 	{ return (uint)framecount; }
461 
462 private:
463 #if defined(Q_DISABLE_COPY)
464     QCanvasPixmapArray( const QCanvasPixmapArray & );
465     QCanvasPixmapArray &operator=( const QCanvasPixmapArray & );
466 #endif
467 #ifndef QT_NO_IMAGEIO
468     bool readPixmaps(const QString& datafilenamepattern, int framecount, bool maskonly);
469 #endif
470 
471     void reset();
472     int framecount;
473     QCanvasPixmap** img;
474 };
475 
476 
477 class QM_EXPORT_CANVAS QCanvasSprite : public QCanvasItem
478 {
479 public:
480     QCanvasSprite(QCanvasPixmapArray* array, QCanvas* canvas);
481 
482     void setSequence(QCanvasPixmapArray* seq);
483 
484     virtual ~QCanvasSprite();
485 
486     void move(double x, double y);
487     virtual void move(double x, double y, int frame);
488     void setFrame(int);
489     enum FrameAnimationType { Cycle, Oscillate };
490     virtual void setFrameAnimation(FrameAnimationType=Cycle, int step=1, int state=0);
frame()491     int frame() const
492 	{ return frm; }
frameCount()493     int frameCount() const
494 	{ return images->count(); }
495 
496     int rtti() const;
497     static int RTTI;
498 
499     bool collidesWith( const QCanvasItem* ) const;
500 
501     QRect boundingRect() const;
502 
503     // is there a reason for these to be protected? Lars
504 //protected:
505 
506     int width() const;
507     int height() const;
508 
509     int leftEdge() const;
510     int topEdge() const;
511     int rightEdge() const;
512     int bottomEdge() const;
513 
514     int leftEdge(int nx) const;
515     int topEdge(int ny) const;
516     int rightEdge(int nx) const;
517     int bottomEdge(int ny) const;
image()518     QCanvasPixmap* image() const
519 	{ return images->image(frm); }
520     virtual QCanvasPixmap* imageAdvanced() const;
image(int f)521     QCanvasPixmap* image(int f) const
522 	{ return images->image(f); }
523     virtual void advance(int stage);
524 
525 public:
526     void draw(QPainter& painter);
527 
528 private:
529 #if defined(Q_DISABLE_COPY)
530     QCanvasSprite( const QCanvasSprite & );
531     QCanvasSprite &operator=( const QCanvasSprite & );
532 #endif
533     void addToChunks();
534     void removeFromChunks();
535     void changeChunks();
536 
537     int frm;
538     ushort anim_val;
539     uint anim_state:2;
540     uint anim_type:14;
541     bool collidesWith( const QCanvasSprite*,
542 		       const QCanvasPolygonalItem*,
543 		       const QCanvasRectangle*,
544 		       const QCanvasEllipse*,
545 		       const QCanvasText* ) const;
546 
547     friend bool qt_testCollision( const QCanvasSprite* s1,
548 				  const QCanvasSprite* s2 );
549 
550     QCanvasPixmapArray* images;
551 };
552 
553 class QPolygonalProcessor;
554 
555 class QM_EXPORT_CANVAS QCanvasPolygonalItem : public QCanvasItem
556 {
557 public:
558     QCanvasPolygonalItem(QCanvas* canvas);
559     virtual ~QCanvasPolygonalItem();
560 
561     bool collidesWith( const QCanvasItem* ) const;
562 
563     virtual void setPen(QPen p);
564     virtual void setBrush(QBrush b);
565 
pen()566     QPen pen() const
567 	{ return pn; }
brush()568     QBrush brush() const
569 	{ return br; }
570 
571     virtual QPointArray areaPoints() const=0;
572     virtual QPointArray areaPointsAdvanced() const;
573     QRect boundingRect() const;
574 
575     int rtti() const;
576     static int RTTI;
577 
578 protected:
579     void draw(QPainter &);
580     virtual void drawShape(QPainter &) = 0;
581 
582     bool winding() const;
583     void setWinding(bool);
584 
585     void invalidate();
isValid()586     bool isValid() const
587 	{ return (bool)val; }
588 
589 private:
590     void scanPolygon( const QPointArray& pa, int winding,
591 		      QPolygonalProcessor& process ) const;
592     QPointArray chunks() const;
593 
594     bool collidesWith( const QCanvasSprite*,
595 		       const QCanvasPolygonalItem*,
596 		       const QCanvasRectangle*,
597 		       const QCanvasEllipse*,
598 		       const QCanvasText* ) const;
599 
600     QBrush br;
601     QPen pn;
602     uint wind:1;
603 };
604 
605 
606 class QM_EXPORT_CANVAS QCanvasRectangle : public QCanvasPolygonalItem
607 {
608 public:
609     QCanvasRectangle(QCanvas* canvas);
610     QCanvasRectangle(const QRect&, QCanvas* canvas);
611     QCanvasRectangle(int x, int y, int width, int height, QCanvas* canvas);
612 
613     ~QCanvasRectangle();
614 
615     int width() const;
616     int height() const;
617     void setSize(int w, int h);
size()618     QSize size() const
619 	{ return QSize(w,h); }
620     QPointArray areaPoints() const;
rect()621     QRect rect() const
622 	{ return QRect(int(x()),int(y()),w,h); }
623 
624     bool collidesWith( const QCanvasItem* ) const;
625 
626     int rtti() const;
627     static int RTTI;
628 
629 protected:
630     void drawShape(QPainter &);
631     QPointArray chunks() const;
632 
633 private:
634     bool collidesWith(   const QCanvasSprite*,
635 			 const QCanvasPolygonalItem*,
636 			 const QCanvasRectangle*,
637 			 const QCanvasEllipse*,
638 			 const QCanvasText* ) const;
639 
640     int w, h;
641 };
642 
643 
644 class QM_EXPORT_CANVAS QCanvasPolygon : public QCanvasPolygonalItem
645 {
646 public:
647     QCanvasPolygon(QCanvas* canvas);
648     ~QCanvasPolygon();
649     void setPoints(QPointArray);
650     QPointArray points() const;
651     void moveBy(double dx, double dy);
652 
653     QPointArray areaPoints() const;
654 
655     int rtti() const;
656     static int RTTI;
657 
658 protected:
659     void drawShape(QPainter &);
660     QPointArray poly;
661 };
662 
663 
664 class QM_EXPORT_CANVAS QCanvasSpline : public QCanvasPolygon
665 {
666 public:
667     QCanvasSpline(QCanvas* canvas);
668     ~QCanvasSpline();
669 
670     void setControlPoints(QPointArray, bool closed=TRUE);
671     QPointArray controlPoints() const;
672     bool closed() const;
673 
674     int rtti() const;
675     static int RTTI;
676 
677 private:
678     void recalcPoly();
679     QPointArray bez;
680     bool cl;
681 };
682 
683 
684 class QM_EXPORT_CANVAS QCanvasLine : public QCanvasPolygonalItem
685 {
686 public:
687     QCanvasLine(QCanvas* canvas);
688     ~QCanvasLine();
689     void setPoints(int x1, int y1, int x2, int y2);
690 
startPoint()691     QPoint startPoint() const
692 	{ return QPoint(x1,y1); }
endPoint()693     QPoint endPoint() const
694 	{ return QPoint(x2,y2); }
695 
696     int rtti() const;
697     static int RTTI;
698 
699     void setPen(QPen p);
700     void moveBy(double dx, double dy);
701 
702 protected:
703     void drawShape(QPainter &);
704     QPointArray areaPoints() const;
705 
706 private:
707     int x1,y1,x2,y2;
708 };
709 
710 
711 class QM_EXPORT_CANVAS QCanvasEllipse : public QCanvasPolygonalItem
712 {
713 
714 public:
715     QCanvasEllipse( QCanvas* canvas );
716     QCanvasEllipse( int width, int height, QCanvas* canvas );
717     QCanvasEllipse( int width, int height, int startangle, int angle,
718 		    QCanvas* canvas );
719 
720     ~QCanvasEllipse();
721 
722     int width() const;
723     int height() const;
724     void setSize(int w, int h);
725     void setAngles(int start, int length);
angleStart()726     int angleStart() const
727 	{ return a1; }
angleLength()728     int angleLength() const
729 	{ return a2; }
730     QPointArray areaPoints() const;
731 
732     bool collidesWith( const QCanvasItem* ) const;
733 
734     int rtti() const;
735     static int RTTI;
736 
737 protected:
738     void drawShape(QPainter &);
739 
740 private:
741     bool collidesWith( const QCanvasSprite*,
742 		       const QCanvasPolygonalItem*,
743 		       const QCanvasRectangle*,
744 		       const QCanvasEllipse*,
745 		       const QCanvasText* ) const;
746     int w, h;
747     int a1, a2;
748 };
749 
750 
751 class QCanvasTextExtra;
752 
753 class QM_EXPORT_CANVAS QCanvasText : public QCanvasItem
754 {
755 public:
756     QCanvasText(QCanvas* canvas);
757     QCanvasText(const QString&, QCanvas* canvas);
758     QCanvasText(const QString&, QFont, QCanvas* canvas);
759 
760     virtual ~QCanvasText();
761 
762     void setText( const QString& );
763     void setFont( const QFont& );
764     void setColor( const QColor& );
765     QString text() const;
766     QFont font() const;
767     QColor color() const;
768 
769     void moveBy(double dx, double dy);
770 
textFlags()771     int textFlags() const
772 	{ return flags; }
773     void setTextFlags(int);
774 
775     QRect boundingRect() const;
776 
777     bool collidesWith( const QCanvasItem* ) const;
778 
779     int rtti() const;
780     static int RTTI;
781 
782 protected:
783     virtual void draw(QPainter&);
784 
785 private:
786 #if defined(Q_DISABLE_COPY)
787     QCanvasText( const QCanvasText & );
788     QCanvasText &operator=( const QCanvasText & );
789 #endif
790     void addToChunks();
791     void removeFromChunks();
792     void changeChunks();
793 
794     void setRect();
795     QRect brect;
796     QString txt;
797     int flags;
798     QFont fnt;
799     QColor col;
800     QCanvasTextExtra* extra;
801 
802     bool collidesWith(   const QCanvasSprite*,
803 			 const QCanvasPolygonalItem*,
804 			 const QCanvasRectangle*,
805 			 const QCanvasEllipse*,
806 			 const QCanvasText* ) const;
807 };
808 
809 #define Q_DEFINED_QCANVAS
810 #include "qwinexport.h"
811 #endif // QT_NO_CANVAS
812 
813 #endif // QCANVAS_H
814