home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qcanvas.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  19KB  |  784 lines

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