Eneboo - Documentación para desarrolladores
|
00001 /********************************************************************** 00002 ** $Id: qt/qcanvas.h 3.3.8 edited Jan 11 14:46 $ 00003 ** 00004 ** Definition of QCanvas classes 00005 ** 00006 ** Created : 991211 00007 ** 00008 ** Copyright (C) 1999-2007 Trolltech ASA. All rights reserved. 00009 ** 00010 ** This file is part of the canvas module of the Qt GUI Toolkit. 00011 ** 00012 ** This file may be distributed under the terms of the Q Public License 00013 ** as defined by Trolltech ASA of Norway and appearing in the file 00014 ** LICENSE.QPL included in the packaging of this file. 00015 ** 00016 ** This file may be distributed and/or modified under the terms of the 00017 ** GNU General Public License version 2 as published by the Free Software 00018 ** Foundation and appearing in the file LICENSE.GPL included in the 00019 ** packaging of this file. 00020 ** 00021 ** Licensees holding valid Qt Enterprise Edition licenses may use this 00022 ** file in accordance with the Qt Commercial License Agreement provided 00023 ** with the Software. 00024 ** 00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00027 ** 00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00029 ** information about Qt Commercial License Agreements. 00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information. 00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00032 ** 00033 ** Contact info@trolltech.com if any conditions of this licensing are 00034 ** not clear to you. 00035 ** 00036 **********************************************************************/ 00037 00038 #ifndef QCANVAS_H 00039 #define QCANVAS_H 00040 00041 #ifndef QT_H 00042 #include "qscrollview.h" 00043 #include "qpixmap.h" 00044 #include "qptrlist.h" 00045 #include "qbrush.h" 00046 #include "qpen.h" 00047 #include "qvaluelist.h" 00048 #include "qpointarray.h" 00049 #endif // QT_H 00050 00051 #if !defined( QT_MODULE_CANVAS ) || defined( QT_LICENSE_PROFESSIONAL ) || defined( QT_INTERNAL_CANVAS ) 00052 #define QM_EXPORT_CANVAS 00053 #define QM_TEMPLATE_EXTERN_CANVAS 00054 #else 00055 #define QM_EXPORT_CANVAS Q_EXPORT 00056 #define QM_TEMPLATE_EXTERN_CANVAS Q_TEMPLATE_EXTERN 00057 #endif 00058 00059 #ifndef QT_NO_CANVAS 00060 00061 00062 class QCanvasSprite; 00063 class QCanvasPolygonalItem; 00064 class QCanvasRectangle; 00065 class QCanvasPolygon; 00066 class QCanvasEllipse; 00067 class QCanvasText; 00068 class QCanvasLine; 00069 class QCanvasChunk; 00070 class QCanvas; 00071 class QCanvasItem; 00072 class QCanvasView; 00073 class QCanvasPixmap; 00074 00075 #if defined(Q_TEMPLATEDLL) && ( !defined(Q_CC_BOR) || !defined(QT_MAKEDLL) || defined(Q_EXPORT_TEMPLATES) ) 00076 // MOC_SKIP_BEGIN 00077 QM_TEMPLATE_EXTERN_CANVAS template class QM_EXPORT_CANVAS QValueListIterator< QCanvasItem* >; 00078 QM_TEMPLATE_EXTERN_CANVAS template class QM_EXPORT_CANVAS QValueList< QCanvasItem* >; 00079 // MOC_SKIP_END 00080 #endif 00081 00082 class QM_EXPORT_CANVAS QCanvasItemList : public QValueList<QCanvasItem*> { 00083 public: 00084 void sort(); 00085 void drawUnique( QPainter& painter ); 00086 QCanvasItemList operator+(const QCanvasItemList &l) const; 00087 }; 00088 00089 00090 class QCanvasItemExtra; 00091 00092 class QM_EXPORT_CANVAS QCanvasItem : public Qt 00093 { 00094 public: 00095 QCanvasItem(QCanvas* canvas); 00096 virtual ~QCanvasItem(); 00097 00098 double x() const 00099 { return myx; } 00100 double y() const 00101 { return myy; } 00102 double z() const 00103 { return myz; } // (depth) 00104 00105 virtual void moveBy(double dx, double dy); 00106 void move(double x, double y); 00107 void setX(double a) { move(a,y()); } 00108 void setY(double a) { move(x(),a); } 00109 void setZ(double a) { myz=a; changeChunks(); } 00110 00111 bool animated() const; 00112 virtual void setAnimated(bool y); 00113 virtual void setVelocity( double vx, double vy); 00114 void setXVelocity( double vx ) { setVelocity(vx,yVelocity()); } 00115 void setYVelocity( double vy ) { setVelocity(xVelocity(),vy); } 00116 double xVelocity() const; 00117 double yVelocity() const; 00118 virtual void advance(int stage); 00119 00120 virtual bool collidesWith( const QCanvasItem* ) const=0; 00121 00122 QCanvasItemList collisions(bool exact /* NO DEFAULT */ ) const; 00123 00124 virtual void setCanvas(QCanvas*); 00125 00126 virtual void draw(QPainter&)=0; 00127 00128 void show(); 00129 void hide(); 00130 00131 virtual void setVisible(bool yes); 00132 bool isVisible() const 00133 { return (bool)vis; } 00134 virtual void setSelected(bool yes); 00135 bool isSelected() const 00136 { return (bool)sel; } 00137 virtual void setEnabled(bool yes); 00138 bool isEnabled() const 00139 { return (bool)ena; } 00140 virtual void setActive(bool yes); 00141 bool isActive() const 00142 { return (bool)act; } 00143 #ifndef QT_NO_COMPAT 00144 bool visible() const 00145 { return (bool)vis; } 00146 bool selected() const 00147 { return (bool)sel; } 00148 bool enabled() const 00149 { return (bool)ena; } 00150 bool active() const 00151 { return (bool)act; } 00152 #endif 00153 00154 enum RttiValues { 00155 Rtti_Item = 0, 00156 Rtti_Sprite = 1, 00157 Rtti_PolygonalItem = 2, 00158 Rtti_Text = 3, 00159 Rtti_Polygon = 4, 00160 Rtti_Rectangle = 5, 00161 Rtti_Ellipse = 6, 00162 Rtti_Line = 7, 00163 Rtti_Spline = 8 00164 }; 00165 00166 virtual int rtti() const; 00167 static int RTTI; 00168 00169 virtual QRect boundingRect() const=0; 00170 virtual QRect boundingRectAdvanced() const; 00171 00172 QCanvas* canvas() const 00173 { return cnv; } 00174 00175 protected: 00176 void update() { changeChunks(); } 00177 00178 private: 00179 // For friendly subclasses... 00180 00181 friend class QCanvasPolygonalItem; 00182 friend class QCanvasSprite; 00183 friend class QCanvasRectangle; 00184 friend class QCanvasPolygon; 00185 friend class QCanvasEllipse; 00186 friend class QCanvasText; 00187 friend class QCanvasLine; 00188 00189 virtual QPointArray chunks() const; 00190 virtual void addToChunks(); 00191 virtual void removeFromChunks(); 00192 virtual void changeChunks(); 00193 virtual bool collidesWith( const QCanvasSprite*, 00194 const QCanvasPolygonalItem*, 00195 const QCanvasRectangle*, 00196 const QCanvasEllipse*, 00197 const QCanvasText* ) const = 0; 00198 // End of friend stuff 00199 00200 QCanvas* cnv; 00201 static QCanvas* current_canvas; 00202 double myx,myy,myz; 00203 QCanvasItemExtra *ext; 00204 QCanvasItemExtra& extra(); 00205 uint ani:1; 00206 uint vis:1; 00207 uint val:1; 00208 uint sel:1; 00209 uint ena:1; 00210 uint act:1; 00211 }; 00212 00213 00214 class QCanvasData; 00215 00216 class QM_EXPORT_CANVAS QCanvas : public QObject 00217 { 00218 Q_OBJECT 00219 public: 00220 QCanvas( QObject* parent = 0, const char* name = 0 ); 00221 QCanvas(int w, int h); 00222 QCanvas( QPixmap p, int h, int v, int tilewidth, int tileheight ); 00223 00224 virtual ~QCanvas(); 00225 00226 virtual void setTiles( QPixmap tiles, int h, int v, 00227 int tilewidth, int tileheight ); 00228 virtual void setBackgroundPixmap( const QPixmap& p ); 00229 QPixmap backgroundPixmap() const; 00230 00231 virtual void setBackgroundColor( const QColor& c ); 00232 QColor backgroundColor() const; 00233 00234 virtual void setTile( int x, int y, int tilenum ); 00235 int tile( int x, int y ) const 00236 { return grid[x+y*htiles]; } 00237 00238 int tilesHorizontally() const 00239 { return htiles; } 00240 int tilesVertically() const 00241 { return vtiles; } 00242 00243 int tileWidth() const 00244 { return tilew; } 00245 int tileHeight() const 00246 { return tileh; } 00247 00248 virtual void resize(int width, int height); 00249 int width() const 00250 { return awidth; } 00251 int height() const 00252 { return aheight; } 00253 QSize size() const 00254 { return QSize(awidth,aheight); } 00255 QRect rect() const 00256 { return QRect( 0, 0, awidth, aheight ); } 00257 bool onCanvas( int x, int y ) const 00258 { return x>=0 && y>=0 && x<awidth && y<aheight; } 00259 bool onCanvas( const QPoint& p ) const 00260 { return onCanvas(p.x(),p.y()); } 00261 bool validChunk( int x, int y ) const 00262 { return x>=0 && y>=0 && x<chwidth && y<chheight; } 00263 bool validChunk( const QPoint& p ) const 00264 { return validChunk(p.x(),p.y()); } 00265 00266 int chunkSize() const 00267 { return chunksize; } 00268 virtual void retune(int chunksize, int maxclusters=100); 00269 00270 bool sameChunk(int x1, int y1, int x2, int y2) const 00271 { return x1/chunksize==x2/chunksize && y1/chunksize==y2/chunksize; } 00272 virtual void setChangedChunk(int i, int j); 00273 virtual void setChangedChunkContaining(int x, int y); 00274 virtual void setAllChanged(); 00275 virtual void setChanged(const QRect& area); 00276 virtual void setUnchanged(const QRect& area); 00277 00278 // These call setChangedChunk. 00279 void addItemToChunk(QCanvasItem*, int i, int j); 00280 void removeItemFromChunk(QCanvasItem*, int i, int j); 00281 void addItemToChunkContaining(QCanvasItem*, int x, int y); 00282 void removeItemFromChunkContaining(QCanvasItem*, int x, int y); 00283 00284 QCanvasItemList allItems(); 00285 QCanvasItemList collisions( const QPoint&) const; 00286 QCanvasItemList collisions( const QRect&) const; 00287 QCanvasItemList collisions( const QPointArray& pa, const QCanvasItem* item, 00288 bool exact) const; 00289 00290 void drawArea(const QRect&, QPainter* p, bool double_buffer=FALSE); 00291 00292 // These are for QCanvasView to call 00293 virtual void addView(QCanvasView*); 00294 virtual void removeView(QCanvasView*); 00295 void drawCanvasArea(const QRect&, QPainter* p=0, bool double_buffer=TRUE); 00296 void drawViewArea( QCanvasView* view, QPainter* p, const QRect& r, bool dbuf ); 00297 00298 // These are for QCanvasItem to call 00299 virtual void addItem(QCanvasItem*); 00300 virtual void addAnimation(QCanvasItem*); 00301 virtual void removeItem(QCanvasItem*); 00302 virtual void removeAnimation(QCanvasItem*); 00303 00304 virtual void setAdvancePeriod(int ms); 00305 virtual void setUpdatePeriod(int ms); 00306 00307 virtual void setDoubleBuffering(bool y); 00308 00309 signals: 00310 void resized(); 00311 00312 public slots: 00313 virtual void advance(); 00314 virtual void update(); 00315 00316 protected: 00317 virtual void drawBackground(QPainter&, const QRect& area); 00318 virtual void drawForeground(QPainter&, const QRect& area); 00319 00320 private: 00321 void init(int w, int h, int chunksze=16, int maxclust=100); 00322 00323 QCanvasChunk& chunk(int i, int j) const; 00324 QCanvasChunk& chunkContaining(int x, int y) const; 00325 00326 QRect changeBounds(const QRect& inarea); 00327 void drawChanges(const QRect& inarea); 00328 00329 QPixmap offscr; 00330 int awidth,aheight; 00331 int chunksize; 00332 int maxclusters; 00333 int chwidth,chheight; 00334 QCanvasChunk* chunks; 00335 00336 QCanvasData* d; 00337 00338 void initTiles(QPixmap p, int h, int v, int tilewidth, int tileheight); 00339 ushort *grid; 00340 ushort htiles; 00341 ushort vtiles; 00342 ushort tilew; 00343 ushort tileh; 00344 bool oneone; 00345 QPixmap pm; 00346 QTimer* update_timer; 00347 QColor bgcolor; 00348 bool debug_redraw_areas; 00349 bool dblbuf; 00350 00351 friend void qt_unview(QCanvas* c); 00352 00353 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00354 QCanvas( const QCanvas & ); 00355 QCanvas &operator=( const QCanvas & ); 00356 #endif 00357 }; 00358 00359 class QCanvasViewData; 00360 00361 class QM_EXPORT_CANVAS QCanvasView : public QScrollView 00362 { 00363 Q_OBJECT 00364 public: 00365 00366 QCanvasView(QWidget* parent=0, const char* name=0, WFlags f=0); 00367 QCanvasView(QCanvas* viewing, QWidget* parent=0, const char* name=0, WFlags f=0); 00368 ~QCanvasView(); 00369 00370 QCanvas* canvas() const 00371 { return viewing; } 00372 void setCanvas(QCanvas* v); 00373 00374 const QWMatrix &worldMatrix() const; 00375 const QWMatrix &inverseWorldMatrix() const; 00376 bool setWorldMatrix( const QWMatrix & ); 00377 00378 protected: 00379 void drawContents( QPainter*, int cx, int cy, int cw, int ch ); 00380 QSize sizeHint() const; 00381 00382 private: 00383 void drawContents( QPainter* ); 00384 QCanvas* viewing; 00385 QCanvasViewData* d; 00386 friend void qt_unview(QCanvas* c); 00387 00388 private slots: 00389 void cMoving(int,int); 00390 void updateContentsSize(); 00391 00392 private: 00393 #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator= 00394 QCanvasView( const QCanvasView & ); 00395 QCanvasView &operator=( const QCanvasView & ); 00396 #endif 00397 }; 00398 00399 00400 class QM_EXPORT_CANVAS QCanvasPixmap : public QPixmap 00401 { 00402 public: 00403 #ifndef QT_NO_IMAGEIO 00404 QCanvasPixmap(const QString& datafilename); 00405 #endif 00406 QCanvasPixmap(const QImage& image); 00407 QCanvasPixmap(const QPixmap&, const QPoint& hotspot); 00408 ~QCanvasPixmap(); 00409 00410 int offsetX() const 00411 { return hotx; } 00412 int offsetY() const 00413 { return hoty; } 00414 void setOffset(int x, int y) { hotx = x; hoty = y; } 00415 00416 private: 00417 #if defined(Q_DISABLE_COPY) 00418 QCanvasPixmap( const QCanvasPixmap & ); 00419 QCanvasPixmap &operator=( const QCanvasPixmap & ); 00420 #endif 00421 void init(const QImage&); 00422 void init(const QPixmap& pixmap, int hx, int hy); 00423 00424 friend class QCanvasSprite; 00425 friend class QCanvasPixmapArray; 00426 friend bool qt_testCollision(const QCanvasSprite* s1, const QCanvasSprite* s2); 00427 00428 int hotx,hoty; 00429 00430 QImage* collision_mask; 00431 }; 00432 00433 00434 class QM_EXPORT_CANVAS QCanvasPixmapArray 00435 { 00436 public: 00437 QCanvasPixmapArray(); 00438 #ifndef QT_NO_IMAGEIO 00439 QCanvasPixmapArray(const QString& datafilenamepattern, int framecount=0); 00440 #endif 00441 // this form is deprecated 00442 QCanvasPixmapArray(QPtrList<QPixmap>, QPtrList<QPoint> hotspots); 00443 00444 QCanvasPixmapArray(QValueList<QPixmap>, QPointArray hotspots = QPointArray() ); 00445 ~QCanvasPixmapArray(); 00446 00447 #ifndef QT_NO_IMAGEIO 00448 bool readPixmaps(const QString& datafilenamepattern, int framecount=0); 00449 bool readCollisionMasks(const QString& filenamepattern); 00450 #endif 00451 00452 // deprecated 00453 bool operator!(); // Failure check. 00454 bool isValid() const; 00455 00456 QCanvasPixmap* image(int i) const 00457 { return img ? img[i] : 0; } 00458 void setImage(int i, QCanvasPixmap* p); 00459 uint count() const 00460 { return (uint)framecount; } 00461 00462 private: 00463 #if defined(Q_DISABLE_COPY) 00464 QCanvasPixmapArray( const QCanvasPixmapArray & ); 00465 QCanvasPixmapArray &operator=( const QCanvasPixmapArray & ); 00466 #endif 00467 #ifndef QT_NO_IMAGEIO 00468 bool readPixmaps(const QString& datafilenamepattern, int framecount, bool maskonly); 00469 #endif 00470 00471 void reset(); 00472 int framecount; 00473 QCanvasPixmap** img; 00474 }; 00475 00476 00477 class QM_EXPORT_CANVAS QCanvasSprite : public QCanvasItem 00478 { 00479 public: 00480 QCanvasSprite(QCanvasPixmapArray* array, QCanvas* canvas); 00481 00482 void setSequence(QCanvasPixmapArray* seq); 00483 00484 virtual ~QCanvasSprite(); 00485 00486 void move(double x, double y); 00487 virtual void move(double x, double y, int frame); 00488 void setFrame(int); 00489 enum FrameAnimationType { Cycle, Oscillate }; 00490 virtual void setFrameAnimation(FrameAnimationType=Cycle, int step=1, int state=0); 00491 int frame() const 00492 { return frm; } 00493 int frameCount() const 00494 { return images->count(); } 00495 00496 int rtti() const; 00497 static int RTTI; 00498 00499 bool collidesWith( const QCanvasItem* ) const; 00500 00501 QRect boundingRect() const; 00502 00503 // is there a reason for these to be protected? Lars 00504 //protected: 00505 00506 int width() const; 00507 int height() const; 00508 00509 int leftEdge() const; 00510 int topEdge() const; 00511 int rightEdge() const; 00512 int bottomEdge() const; 00513 00514 int leftEdge(int nx) const; 00515 int topEdge(int ny) const; 00516 int rightEdge(int nx) const; 00517 int bottomEdge(int ny) const; 00518 QCanvasPixmap* image() const 00519 { return images->image(frm); } 00520 virtual QCanvasPixmap* imageAdvanced() const; 00521 QCanvasPixmap* image(int f) const 00522 { return images->image(f); } 00523 virtual void advance(int stage); 00524 00525 public: 00526 void draw(QPainter& painter); 00527 00528 private: 00529 #if defined(Q_DISABLE_COPY) 00530 QCanvasSprite( const QCanvasSprite & ); 00531 QCanvasSprite &operator=( const QCanvasSprite & ); 00532 #endif 00533 void addToChunks(); 00534 void removeFromChunks(); 00535 void changeChunks(); 00536 00537 int frm; 00538 ushort anim_val; 00539 uint anim_state:2; 00540 uint anim_type:14; 00541 bool collidesWith( const QCanvasSprite*, 00542 const QCanvasPolygonalItem*, 00543 const QCanvasRectangle*, 00544 const QCanvasEllipse*, 00545 const QCanvasText* ) const; 00546 00547 friend bool qt_testCollision( const QCanvasSprite* s1, 00548 const QCanvasSprite* s2 ); 00549 00550 QCanvasPixmapArray* images; 00551 }; 00552 00553 class QPolygonalProcessor; 00554 00555 class QM_EXPORT_CANVAS QCanvasPolygonalItem : public QCanvasItem 00556 { 00557 public: 00558 QCanvasPolygonalItem(QCanvas* canvas); 00559 virtual ~QCanvasPolygonalItem(); 00560 00561 bool collidesWith( const QCanvasItem* ) const; 00562 00563 virtual void setPen(QPen p); 00564 virtual void setBrush(QBrush b); 00565 00566 QPen pen() const 00567 { return pn; } 00568 QBrush brush() const 00569 { return br; } 00570 00571 virtual QPointArray areaPoints() const=0; 00572 virtual QPointArray areaPointsAdvanced() const; 00573 QRect boundingRect() const; 00574 00575 int rtti() const; 00576 static int RTTI; 00577 00578 protected: 00579 void draw(QPainter &); 00580 virtual void drawShape(QPainter &) = 0; 00581 00582 bool winding() const; 00583 void setWinding(bool); 00584 00585 void invalidate(); 00586 bool isValid() const 00587 { return (bool)val; } 00588 00589 private: 00590 void scanPolygon( const QPointArray& pa, int winding, 00591 QPolygonalProcessor& process ) const; 00592 QPointArray chunks() const; 00593 00594 bool collidesWith( const QCanvasSprite*, 00595 const QCanvasPolygonalItem*, 00596 const QCanvasRectangle*, 00597 const QCanvasEllipse*, 00598 const QCanvasText* ) const; 00599 00600 QBrush br; 00601 QPen pn; 00602 uint wind:1; 00603 }; 00604 00605 00606 class QM_EXPORT_CANVAS QCanvasRectangle : public QCanvasPolygonalItem 00607 { 00608 public: 00609 QCanvasRectangle(QCanvas* canvas); 00610 QCanvasRectangle(const QRect&, QCanvas* canvas); 00611 QCanvasRectangle(int x, int y, int width, int height, QCanvas* canvas); 00612 00613 ~QCanvasRectangle(); 00614 00615 int width() const; 00616 int height() const; 00617 void setSize(int w, int h); 00618 QSize size() const 00619 { return QSize(w,h); } 00620 QPointArray areaPoints() const; 00621 QRect rect() const 00622 { return QRect(int(x()),int(y()),w,h); } 00623 00624 bool collidesWith( const QCanvasItem* ) const; 00625 00626 int rtti() const; 00627 static int RTTI; 00628 00629 protected: 00630 void drawShape(QPainter &); 00631 QPointArray chunks() const; 00632 00633 private: 00634 bool collidesWith( const QCanvasSprite*, 00635 const QCanvasPolygonalItem*, 00636 const QCanvasRectangle*, 00637 const QCanvasEllipse*, 00638 const QCanvasText* ) const; 00639 00640 int w, h; 00641 }; 00642 00643 00644 class QM_EXPORT_CANVAS QCanvasPolygon : public QCanvasPolygonalItem 00645 { 00646 public: 00647 QCanvasPolygon(QCanvas* canvas); 00648 ~QCanvasPolygon(); 00649 void setPoints(QPointArray); 00650 QPointArray points() const; 00651 void moveBy(double dx, double dy); 00652 00653 QPointArray areaPoints() const; 00654 00655 int rtti() const; 00656 static int RTTI; 00657 00658 protected: 00659 void drawShape(QPainter &); 00660 QPointArray poly; 00661 }; 00662 00663 00664 class QM_EXPORT_CANVAS QCanvasSpline : public QCanvasPolygon 00665 { 00666 public: 00667 QCanvasSpline(QCanvas* canvas); 00668 ~QCanvasSpline(); 00669 00670 void setControlPoints(QPointArray, bool closed=TRUE); 00671 QPointArray controlPoints() const; 00672 bool closed() const; 00673 00674 int rtti() const; 00675 static int RTTI; 00676 00677 private: 00678 void recalcPoly(); 00679 QPointArray bez; 00680 bool cl; 00681 }; 00682 00683 00684 class QM_EXPORT_CANVAS QCanvasLine : public QCanvasPolygonalItem 00685 { 00686 public: 00687 QCanvasLine(QCanvas* canvas); 00688 ~QCanvasLine(); 00689 void setPoints(int x1, int y1, int x2, int y2); 00690 00691 QPoint startPoint() const 00692 { return QPoint(x1,y1); } 00693 QPoint endPoint() const 00694 { return QPoint(x2,y2); } 00695 00696 int rtti() const; 00697 static int RTTI; 00698 00699 void setPen(QPen p); 00700 void moveBy(double dx, double dy); 00701 00702 protected: 00703 void drawShape(QPainter &); 00704 QPointArray areaPoints() const; 00705 00706 private: 00707 int x1,y1,x2,y2; 00708 }; 00709 00710 00711 class QM_EXPORT_CANVAS QCanvasEllipse : public QCanvasPolygonalItem 00712 { 00713 00714 public: 00715 QCanvasEllipse( QCanvas* canvas ); 00716 QCanvasEllipse( int width, int height, QCanvas* canvas ); 00717 QCanvasEllipse( int width, int height, int startangle, int angle, 00718 QCanvas* canvas ); 00719 00720 ~QCanvasEllipse(); 00721 00722 int width() const; 00723 int height() const; 00724 void setSize(int w, int h); 00725 void setAngles(int start, int length); 00726 int angleStart() const 00727 { return a1; } 00728 int angleLength() const 00729 { return a2; } 00730 QPointArray areaPoints() const; 00731 00732 bool collidesWith( const QCanvasItem* ) const; 00733 00734 int rtti() const; 00735 static int RTTI; 00736 00737 protected: 00738 void drawShape(QPainter &); 00739 00740 private: 00741 bool collidesWith( const QCanvasSprite*, 00742 const QCanvasPolygonalItem*, 00743 const QCanvasRectangle*, 00744 const QCanvasEllipse*, 00745 const QCanvasText* ) const; 00746 int w, h; 00747 int a1, a2; 00748 }; 00749 00750 00751 class QCanvasTextExtra; 00752 00753 class QM_EXPORT_CANVAS QCanvasText : public QCanvasItem 00754 { 00755 public: 00756 QCanvasText(QCanvas* canvas); 00757 QCanvasText(const QString&, QCanvas* canvas); 00758 QCanvasText(const QString&, QFont, QCanvas* canvas); 00759 00760 virtual ~QCanvasText(); 00761 00762 void setText( const QString& ); 00763 void setFont( const QFont& ); 00764 void setColor( const QColor& ); 00765 QString text() const; 00766 QFont font() const; 00767 QColor color() const; 00768 00769 void moveBy(double dx, double dy); 00770 00771 int textFlags() const 00772 { return flags; } 00773 void setTextFlags(int); 00774 00775 QRect boundingRect() const; 00776 00777 bool collidesWith( const QCanvasItem* ) const; 00778 00779 int rtti() const; 00780 static int RTTI; 00781 00782 protected: 00783 virtual void draw(QPainter&); 00784 00785 private: 00786 #if defined(Q_DISABLE_COPY) 00787 QCanvasText( const QCanvasText & ); 00788 QCanvasText &operator=( const QCanvasText & ); 00789 #endif 00790 void addToChunks(); 00791 void removeFromChunks(); 00792 void changeChunks(); 00793 00794 void setRect(); 00795 QRect brect; 00796 QString txt; 00797 int flags; 00798 QFont fnt; 00799 QColor col; 00800 QCanvasTextExtra* extra; 00801 00802 bool collidesWith( const QCanvasSprite*, 00803 const QCanvasPolygonalItem*, 00804 const QCanvasRectangle*, 00805 const QCanvasEllipse*, 00806 const QCanvasText* ) const; 00807 }; 00808 00809 #define Q_DEFINED_QCANVAS 00810 #include "qwinexport.h" 00811 #endif // QT_NO_CANVAS 00812 00813 #endif // QCANVAS_H