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