43 #include <QtGui/qpixmap.h> 44 #include <QtGui/qbrush.h> 45 #include <QtGui/qpen.h> 46 #include <QtGui/qpolygon.h> 47 #include <QtGui/qscrollarea.h> 82 virtual void moveBy(
double dx,
double dy);
83 void move(
double x,
double y);
106 virtual void advance(
int stage);
114 virtual void draw(QPainter&) = 0;
160 virtual int rtti()
const;
186 virtual QPolygon
chunks()
const;
218 QtCanvas(QPixmap p,
int h,
int v,
int tilewidth,
int tileheight);
222 virtual void setTiles(QPixmap tiles,
int h,
int v,
223 int tilewidth,
int tileheight);
224 virtual void setBackgroundPixmap(
const QPixmap& p);
225 QPixmap backgroundPixmap()
const;
227 virtual void setBackgroundColor(
const QColor& c);
228 QColor backgroundColor()
const;
230 virtual void setTile(
int x,
int y,
int tilenum);
232 return grid[x + y * htiles];
249 virtual void resize(
int width,
int height);
257 return QSize(awidth, aheight);
260 return QRect(0, 0, awidth, aheight);
263 return x >= 0 && y >= 0 && x < awidth && y < aheight;
266 return onCanvas(p.x(), p.y());
269 return x >= 0 && y >= 0 && x < chwidth && y < chheight;
272 return validChunk(p.x(), p.y());
278 virtual void retune(
int chunksize,
int maxclusters = 100);
281 return x1 / chunksize == x2 / chunksize && y1 / chunksize == y2 / chunksize;
283 virtual void setChangedChunk(
int i,
int j);
284 virtual void setChangedChunkContaining(
int x,
int y);
285 virtual void setAllChanged();
286 virtual void setChanged(
const QRect& area);
287 virtual void setUnchanged(
const QRect& area);
292 void addItemToChunkContaining(
QtCanvasItem*,
int x,
int y);
293 void removeItemFromChunkContaining(
QtCanvasItem*,
int x,
int y);
301 void drawArea(
const QRect&, QPainter* p,
bool double_buffer =
false);
307 void drawCanvasArea(
const QRect&, QPainter* p = 0,
bool double_buffer =
true);
308 void drawViewArea(
QtCanvasView* view, QPainter* p,
const QRect& r,
bool dbuf);
316 virtual void setAdvancePeriod(
int ms);
317 virtual void setUpdatePeriod(
int ms);
327 virtual void drawBackground(QPainter&,
const QRect& area);
328 virtual void drawForeground(QPainter&,
const QRect& area);
331 void init(
int w,
int h,
int chunksze = 16,
int maxclust = 100);
336 QRect changeBounds();
341 int chwidth, chheight;
346 void initTiles(QPixmap p,
int h,
int v,
int tilewidth,
int tileheight);
354 QTimer* update_timer;
356 bool debug_redraw_areas;
367 Q_PROPERTY(
bool highQualityRendering READ highQualityRendering WRITE setHighQualityRendering)
379 const QMatrix& worldMatrix()
const;
380 const QMatrix& inverseWorldMatrix()
const;
381 bool setWorldMatrix(
const QMatrix&);
383 virtual QSize sizeHint()
const;
385 bool highQualityRendering()
const;
387 void setHighQualityRendering(
bool enable);
391 virtual void drawContents(QPainter* p,
int cx,
int cy,
int cw,
int ch);
393 virtual void contentsMousePressEvent(QMouseEvent*);
394 virtual void contentsMouseReleaseEvent(QMouseEvent*);
395 virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
396 virtual void contentsMouseMoveEvent(QMouseEvent*);
397 virtual void contentsDragEnterEvent(QDragEnterEvent*);
398 virtual void contentsDragMoveEvent(QDragMoveEvent*);
399 virtual void contentsDragLeaveEvent(QDragLeaveEvent*);
400 virtual void contentsDropEvent(QDropEvent*);
401 virtual void contentsWheelEvent(QWheelEvent*);
402 virtual void contentsContextMenuEvent(QContextMenuEvent*);
406 void drawContents(QPainter*);
411 void updateContentsSize();
420 #ifndef QT_NO_IMAGEIO 441 void init(
const QImage&);
442 void init(
const QPixmap& pixmap,
int hx,
int hy);
450 QImage* collision_mask;
457 #ifndef QT_NO_IMAGEIO 463 #ifndef QT_NO_IMAGEIO 464 bool readPixmaps(
const QString& datafilenamepattern,
int framecount = 0);
465 bool readCollisionMasks(
const QString& filenamepattern);
470 bool isValid()
const;
473 return img ? img[i] : 0;
477 return (uint)framecount;
483 #ifndef QT_NO_IMAGEIO 484 bool readPixmaps(
const QString& datafilenamepattern,
int framecount,
bool maskonly);
501 void move(
double x,
double y);
502 virtual void move(
double x,
double y,
int frame);
505 virtual void setFrameAnimation(
FrameAnimationType = Cycle,
int step = 1,
int state = 0);
510 return images->count();
526 int leftEdge()
const;
528 int rightEdge()
const;
529 int bottomEdge()
const;
531 int leftEdge(
int nx)
const;
532 int topEdge(
int ny)
const;
533 int rightEdge(
int nx)
const;
534 int bottomEdge(
int ny)
const;
536 return images->image(frm);
540 return images->image(f);
542 virtual void advance(
int stage);
545 void draw(QPainter& painter);
579 virtual void setPen(QPen p);
580 virtual void setBrush(QBrush b);
589 virtual QPolygon areaPoints()
const = 0;
590 virtual QPolygon areaPointsAdvanced()
const;
597 void draw(QPainter&);
598 virtual void drawShape(QPainter&) = 0;
600 bool winding()
const;
601 void setWinding(
bool);
609 void scanPolygon(
const QPolygon& pa,
int winding,
635 void setSize(
int w,
int h);
639 QPolygon areaPoints()
const;
641 return QRect(
int(
x()),
int(
y()), w, h);
650 void drawShape(QPainter&);
668 void setPoints(QPolygon);
669 QPolygon points()
const;
670 void moveBy(
double dx,
double dy);
672 QPolygon areaPoints()
const;
678 void drawShape(QPainter&);
688 void setControlPoints(QPolygon,
bool closed =
true);
689 QPolygon controlPoints()
const;
706 void setPoints(
int x1,
int y1,
int x2,
int y2);
709 return QPoint(x1, y1);
712 return QPoint(x2, y2);
719 void moveBy(
double dx,
double dy);
722 void drawShape(QPainter&);
723 QPolygon areaPoints()
const;
742 void setSize(
int w,
int h);
743 void setAngles(
int start,
int length);
750 QPolygon areaPoints()
const;
758 void drawShape(QPainter&);
771 class QtCanvasTextExtra;
781 void setText(
const QString&);
782 void setFont(
const QFont&);
783 void setColor(
const QColor&);
784 QString text()
const;
786 QColor color()
const;
788 void moveBy(
double dx,
double dy);
793 void setTextFlags(
int);
803 virtual void draw(QPainter&);
818 QtCanvasTextExtra*
extra;
RttiValues
Definition: canvas_typed/qtcanvas.h:148
friend class QtCanvasPolygonalItem
Definition: canvas_typed/qtcanvas.h:178
int width() const
Definition: canvas_variant/qtcanvas.h:250
Definition: canvas_typed/qtcanvas.h:664
Definition: canvas_typed/qtcanvas.h:730
void update()
Definition: canvas_variant/qtcanvas.h:171
bool sameChunk(int x1, int y1, int x2, int y2) const
Definition: canvas_variant/qtcanvas.h:280
Definition: canvas_typed/qtcanvas.h:773
Definition: canvas_typed/qtcanvas.h:683
double myy
Definition: canvas_typed/qtcanvas.h:199
virtual void moveBy(double dx, double dy)
Definition: canvas_typed/qtcanvas.cpp:1669
Definition: canvas_typed/qtcanvas.h:454
int tilesVertically() const
Definition: canvas_variant/qtcanvas.h:238
QPoint startPoint() const
Definition: canvas_variant/qtcanvas.h:708
int offsetY() const
Definition: canvas_variant/qtcanvas.h:430
int chunkSize() const
Definition: canvas_variant/qtcanvas.h:275
QtCanvasItemExtra * ext
Definition: canvas_typed/qtcanvas.h:200
QtCanvasItemExtra & extra()
Definition: canvas_typed/qtcanvas.cpp:1611
virtual QPolygon chunks() const
Definition: canvas_typed/qtcanvas.cpp:2918
virtual QRect boundingRectAdvanced() const
Definition: canvas_typed/qtcanvas.cpp:2409
QRect rect() const
Definition: canvas_variant/qtcanvas.h:640
Definition: canvas_typed/qtcanvas.h:213
bool qt_testCollision(const QtCanvasSprite *s1, const QtCanvasSprite *s2)
Definition: canvas_typed/qtcanvas.cpp:1950
Definition: canvas_typed/qtcanvas.h:151
bool visible() const
Definition: canvas_variant/qtcanvas.h:135
bool isEnabled() const
Definition: canvas_variant/qtcanvas.h:128
uint ena
Definition: canvas_typed/qtcanvas.h:206
Definition: canvas_typed/qtcanvas.cpp:56
bool isValid() const
Definition: canvas_variant/qtcanvas.h:604
friend class QtCanvasPolygon
Definition: canvas_typed/qtcanvas.h:181
int textFlags() const
Definition: canvas_variant/qtcanvas.h:790
Definition: canvas_typed/qtcanvas.h:154
FrameAnimationType
Definition: canvas_typed/qtcanvas.h:504
QList< QtCanvasItem * > QtCanvasItemList
Definition: canvas_variant/qtcanvas.h:60
Definition: canvas_typed/qtcanvas.h:156
QRect rect() const
Definition: canvas_variant/qtcanvas.h:259
virtual void setCanvas(QtCanvas *)
Definition: canvas_typed/qtcanvas.cpp:1790
virtual void changeChunks()
Definition: canvas_typed/qtcanvas.cpp:2383
bool selected() const
Definition: canvas_variant/qtcanvas.h:138
void setYVelocity(double vy)
Definition: canvas_variant/qtcanvas.h:101
QtCanvasItemList collisions(bool exact) const
Definition: canvas_typed/qtcanvas.cpp:2285
friend class QtCanvasRectangle
Definition: canvas_typed/qtcanvas.h:180
Definition: canvas_typed/qtcanvas.h:572
QSize size() const
Definition: canvas_variant/qtcanvas.h:636
double yVelocity() const
Definition: canvas_typed/qtcanvas.cpp:1758
Definition: canvas_typed/qtcanvas.h:702
Definition: canvas_typed/qtcanvas.h:418
int tile(int x, int y) const
Definition: canvas_variant/qtcanvas.h:231
Definition: canvas_typed/qtcanvas.cpp:284
virtual void addToChunks()
Definition: canvas_typed/qtcanvas.cpp:2355
QtCanvasData * d
Definition: canvas_typed/qtcanvas.h:344
friend class QtCanvasLine
Definition: canvas_typed/qtcanvas.h:184
QtCanvasPixmap * image(int f) const
Definition: canvas_variant/qtcanvas.h:539
virtual void draw(QPainter &)=0
virtual void removeFromChunks()
Definition: canvas_typed/qtcanvas.cpp:2369
void setOffset(int x, int y)
Definition: canvas_variant/qtcanvas.h:433
static int RTTI
Definition: canvas_typed/qtcanvas.h:161
Definition: canvas_typed/qtcanvas.h:493
double myz
Definition: canvas_typed/qtcanvas.h:199
double y() const
Definition: canvas_variant/qtcanvas.h:75
friend class QtCanvasSprite
Definition: canvas_typed/qtcanvas.h:179
Definition: canvas_typed/qtcanvas.h:149
uint vis
Definition: canvas_typed/qtcanvas.h:203
int tilesHorizontally() const
Definition: canvas_variant/qtcanvas.h:235
bool validChunk(int x, int y) const
Definition: canvas_variant/qtcanvas.h:268
Definition: canvas_typed/qtcanvas.h:153
int tileHeight() const
Definition: canvas_variant/qtcanvas.h:245
virtual void advance(int stage)
Definition: canvas_typed/qtcanvas.cpp:1773
bool isVisible() const
Definition: canvas_variant/qtcanvas.h:120
void setX(double a)
Definition: canvas_variant/qtcanvas.h:84
int angleStart() const
Definition: canvas_variant/qtcanvas.h:744
uint val
Definition: canvas_typed/qtcanvas.h:204
virtual void setVisible(bool yes)
Definition: canvas_typed/qtcanvas.cpp:1830
QtCanvas * canvas() const
Definition: canvas_typed/qtcanvas.h:166
bool active() const
Definition: canvas_variant/qtcanvas.h:144
virtual void setEnabled(bool yes)
Definition: canvas_typed/qtcanvas.cpp:1914
double xVelocity() const
Definition: canvas_typed/qtcanvas.cpp:1751
virtual ~QtCanvasItem()
Definition: canvas_typed/qtcanvas.cpp:1603
uint ani
Definition: canvas_typed/qtcanvas.h:202
int frame() const
Definition: canvas_variant/qtcanvas.h:506
bool isActive() const
Definition: canvas_variant/qtcanvas.h:132
QPen pen() const
Definition: canvas_variant/qtcanvas.h:582
int height() const
Definition: canvas_variant/qtcanvas.h:253
int frameCount() const
Definition: canvas_variant/qtcanvas.h:509
void hide()
Definition: canvas_typed/qtcanvas.cpp:1821
bool validChunk(const QPoint &p) const
Definition: canvas_variant/qtcanvas.h:271
void setXVelocity(double vx)
Definition: canvas_variant/qtcanvas.h:98
QList< QtCanvasItem * > QtCanvasItemList
Definition: canvas_typed/qtcanvas.h:60
virtual int rtti() const
Definition: canvas_typed/qtcanvas.cpp:4604
friend class QtCanvasEllipse
Definition: canvas_typed/qtcanvas.h:182
virtual void setAnimated(bool y)
Definition: canvas_typed/qtcanvas.cpp:1704
bool onCanvas(int x, int y) const
Definition: canvas_variant/qtcanvas.h:262
QtCanvasItem(QtCanvas *canvas)
Definition: canvas_typed/qtcanvas.cpp:1584
Definition: canvas_typed/qtcanvas.h:152
Definition: canvas_typed/qtcanvas.cpp:3477
virtual void setSelected(bool yes)
Definition: canvas_typed/qtcanvas.cpp:1885
virtual void setVelocity(double vx, double vy)
Definition: canvas_typed/qtcanvas.cpp:1738
Definition: canvas_typed/qtcanvas.h:365
uint sel
Definition: canvas_typed/qtcanvas.h:205
QtCanvas * canvas() const
Definition: canvas_variant/qtcanvas.h:374
double myx
Definition: canvas_typed/qtcanvas.h:199
Definition: canvas_typed/qtcanvas.h:157
void move(double x, double y)
Definition: canvas_typed/qtcanvas.cpp:1682
QBrush brush() const
Definition: canvas_variant/qtcanvas.h:585
double x() const
Definition: canvas_variant/qtcanvas.h:72
Definition: canvas_typed/qtcanvas.h:67
friend class QtCanvasText
Definition: canvas_typed/qtcanvas.h:183
bool enabled() const
Definition: canvas_variant/qtcanvas.h:141
Definition: canvas_typed/qtcanvas.h:150
bool onCanvas(const QPoint &p) const
Definition: canvas_variant/qtcanvas.h:265
Definition: canvas_typed/qtcanvas.cpp:66
QSize size() const
Definition: canvas_variant/qtcanvas.h:256
virtual bool collidesWith(const QtCanvasItem *) const =0
QtCanvasPixmap * image() const
Definition: canvas_variant/qtcanvas.h:535
QtCanvasPixmap * image(int i) const
Definition: canvas_variant/qtcanvas.h:472
int angleLength() const
Definition: canvas_variant/qtcanvas.h:747
QPoint endPoint() const
Definition: canvas_variant/qtcanvas.h:711
uint count() const
Definition: canvas_variant/qtcanvas.h:476
bool animated() const
Definition: canvas_typed/qtcanvas.cpp:1693
int offsetX() const
Definition: canvas_variant/qtcanvas.h:427
int tileWidth() const
Definition: canvas_variant/qtcanvas.h:242
virtual QRect boundingRect() const =0
static QtCanvas * current_canvas
Definition: canvas_typed/qtcanvas.h:198
void setZ(double a)
Definition: canvas_variant/qtcanvas.h:90
double z() const
Definition: canvas_variant/qtcanvas.h:78
uint act
Definition: canvas_typed/qtcanvas.h:207
virtual void setActive(bool yes)
Definition: canvas_typed/qtcanvas.cpp:1943
Definition: canvas_typed/qtcanvas.h:155
void show()
Definition: canvas_typed/qtcanvas.cpp:1816
bool isSelected() const
Definition: canvas_variant/qtcanvas.h:124
QtCanvas * cnv
Definition: canvas_typed/qtcanvas.h:197
void setY(double a)
Definition: canvas_variant/qtcanvas.h:87
Definition: canvas_typed/qtcanvas.h:625