qtcanvas.h
Go to the documentation of this file.
1/****************************************************************************
2**
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
5**
6** This file is part of the Qt Solutions component.
7**
8** $QT_BEGIN_LICENSE:BSD$
9** You may use this file under the terms of the BSD license as follows:
10**
11** "Redistribution and use in source and binary forms, with or without
12** modification, are permitted provided that the following conditions are
13** met:
14** * Redistributions of source code must retain the above copyright
15** notice, this list of conditions and the following disclaimer.
16** * Redistributions in binary form must reproduce the above copyright
17** notice, this list of conditions and the following disclaimer in
18** the documentation and/or other materials provided with the
19** distribution.
20** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21** of its contributors may be used to endorse or promote products derived
22** from this software without specific prior written permission.
23**
24**
25** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36**
37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41#pragma once
42
43#include <qbrush.h>
44#include <qpen.h>
45#include <qpixmap.h>
46#include <qpolygon.h>
47#include <qscrollarea.h>
48
49class QtCanvasSprite;
52class QtCanvasPolygon;
53class QtCanvasEllipse;
54class QtCanvasText;
55class QtCanvasLine;
56class QtCanvasChunk;
57class QtCanvas;
58class QtCanvasItem;
59class QtCanvasView;
60class QtCanvasPixmap;
61
62using QtCanvasItemList = QList<QtCanvasItem*>;
63
64
66
68{
69public:
71 virtual ~QtCanvasItem();
72
73 double
74 x() const
75 {
76 return myx;
77 }
78
79 double
80 y() const
81 {
82 return myy;
83 }
84
85 double
86 z() const
87 {
88 return myz; // (depth)
89 }
90
91 virtual void moveBy(double dx, double dy);
92 void move(double x, double y);
93
94 void
95 setX(double a)
96 {
97 move(a, y());
98 }
99
100 void
101 setY(double a)
102 {
103 move(x(), a);
104 }
105
106 void
107 setZ(double a)
108 {
109 myz = a;
110 changeChunks();
111 }
112
113 bool animated() const;
114 virtual void setAnimated(bool y);
115 virtual void setVelocity(double vx, double vy);
116
117 void
118 setXVelocity(double vx)
119 {
120 setVelocity(vx, yVelocity());
121 }
122
123 void
124 setYVelocity(double vy)
125 {
126 setVelocity(xVelocity(), vy);
127 }
128
129 double xVelocity() const;
130 double yVelocity() const;
131 virtual void advance(int stage);
132
133 virtual bool collidesWith(const QtCanvasItem*) const = 0;
134
135 QtCanvasItemList collisions(bool exact /* NO DEFAULT */) const;
136
137 virtual void setCanvas(QtCanvas*);
138
139 virtual void draw(QPainter&) = 0;
140
141 void show();
142 void hide();
143
144 virtual void setVisible(bool yes);
145
146 bool
147 isVisible() const
148 {
149 return (bool)vis;
150 }
151
152 virtual void setSelected(bool yes);
153
154 bool
156 {
157 return (bool)sel;
158 }
159
160 virtual void setEnabled(bool yes);
161
162 bool
163 isEnabled() const
164 {
165 return (bool)ena;
166 }
167
168 virtual void setActive(bool yes);
169
170 bool
171 isActive() const
172 {
173 return (bool)act;
174 }
175
176 bool
177 visible() const
178 {
179 return (bool)vis;
180 }
181
182 bool
183 selected() const
184 {
185 return (bool)sel;
186 }
187
188 bool
189 enabled() const
190 {
191 return (bool)ena;
192 }
193
194 bool
195 active() const
196 {
197 return (bool)act;
198 }
199
212
213 virtual int rtti() const;
214 static int RTTI;
215
216 virtual QRect boundingRect() const = 0;
217 virtual QRect boundingRectAdvanced() const;
218
219 QtCanvas*
220 canvas() const
221 {
222 return cnv;
223 }
224
225protected:
226 void
228 {
229 changeChunks();
230 }
231
232private:
233 // For friendly subclasses...
234
236 friend class QtCanvasSprite;
237 friend class QtCanvasRectangle;
238 friend class QtCanvasPolygon;
239 friend class QtCanvasEllipse;
240 friend class QtCanvasText;
241 friend class QtCanvasLine;
242
243 virtual QPolygon chunks() const;
244 virtual void addToChunks();
245 virtual void removeFromChunks();
246 virtual void changeChunks();
247 virtual bool collidesWith(const QtCanvasSprite*,
249 const QtCanvasRectangle*,
250 const QtCanvasEllipse*,
251 const QtCanvasText*) const = 0;
252 // End of friend stuff
253
254 QtCanvas* cnv;
255 static QtCanvas* current_canvas;
256 double myx, myy, myz;
258 QtCanvasItemExtra& extra();
259 uint ani : 1;
260 uint vis : 1;
261 uint val : 1;
262 uint sel : 1;
263 uint ena : 1;
264 uint act : 1;
265};
266
267
268class QtCanvasData;
269
270class QtCanvas : public QObject
271{
272 Q_OBJECT
273public:
274 QtCanvas(QObject* parent = 0);
275 QtCanvas(int w, int h);
276 QtCanvas(QPixmap p, int h, int v, int tilewidth, int tileheight);
277
278 virtual ~QtCanvas();
279
280 virtual void setTiles(QPixmap tiles, int h, int v, int tilewidth, int tileheight);
281 virtual void setBackgroundPixmap(const QPixmap& p);
282 QPixmap backgroundPixmap() const;
283
284 virtual void setBackgroundColor(const QColor& c);
285 QColor backgroundColor() const;
286
287 virtual void setTile(int x, int y, int tilenum);
288
289 int
290 tile(int x, int y) const
291 {
292 return grid[x + y * htiles];
293 }
294
295 int
297 {
298 return htiles;
299 }
300
301 int
303 {
304 return vtiles;
305 }
306
307 int
308 tileWidth() const
309 {
310 return tilew;
311 }
312
313 int
315 {
316 return tileh;
317 }
318
319 virtual void resize(int width, int height);
320
321 int
322 width() const
323 {
324 return awidth;
325 }
326
327 int
328 height() const
329 {
330 return aheight;
331 }
332
333 QSize
334 size() const
335 {
336 return QSize(awidth, aheight);
337 }
338
339 QRect
340 rect() const
341 {
342 return QRect(0, 0, awidth, aheight);
343 }
344
345 bool
346 onCanvas(int x, int y) const
347 {
348 return x >= 0 && y >= 0 && x < awidth && y < aheight;
349 }
350
351 bool
352 onCanvas(const QPoint& p) const
353 {
354 return onCanvas(p.x(), p.y());
355 }
356
357 bool
358 validChunk(int x, int y) const
359 {
360 return x >= 0 && y >= 0 && x < chwidth && y < chheight;
361 }
362
363 bool
364 validChunk(const QPoint& p) const
365 {
366 return validChunk(p.x(), p.y());
367 }
368
369 int
370 chunkSize() const
371 {
372 return chunksize;
373 }
374
375 virtual void retune(int chunksize, int maxclusters = 100);
376
377 bool
378 sameChunk(int x1, int y1, int x2, int y2) const
379 {
380 return x1 / chunksize == x2 / chunksize && y1 / chunksize == y2 / chunksize;
381 }
382
383 virtual void setChangedChunk(int i, int j);
384 virtual void setChangedChunkContaining(int x, int y);
385 virtual void setAllChanged();
386 virtual void setChanged(const QRect& area);
387 virtual void setUnchanged(const QRect& area);
388
389 // These call setChangedChunk.
390 void addItemToChunk(QtCanvasItem*, int i, int j);
391 void removeItemFromChunk(QtCanvasItem*, int i, int j);
392 void addItemToChunkContaining(QtCanvasItem*, int x, int y);
394
396 QtCanvasItemList collisions(const QPoint&) const;
397 QtCanvasItemList collisions(const QRect&) const;
398 QtCanvasItemList collisions(const QPolygon& pa, const QtCanvasItem* item, bool exact) const;
399
400 void drawArea(const QRect&, QPainter* p, bool double_buffer = false);
401
402 // These are for QtCanvasView to call
403 virtual void addView(QtCanvasView*);
404 virtual void removeView(QtCanvasView*);
405
406 void drawCanvasArea(const QRect&, QPainter* p = 0, bool double_buffer = true);
407 void drawViewArea(QtCanvasView* view, QPainter* p, const QRect& r, bool dbuf);
408
409 // These are for QtCanvasItem to call
410 virtual void addItem(QtCanvasItem*);
411 virtual void addAnimation(QtCanvasItem*);
412 virtual void removeItem(QtCanvasItem*);
413 virtual void removeAnimation(QtCanvasItem*);
414
415 virtual void setAdvancePeriod(int ms);
416 virtual void setUpdatePeriod(int ms);
417
418signals:
419 void resized();
420
421public slots:
422 virtual void advance();
423 virtual void update();
424
425protected:
426 virtual void drawBackground(QPainter&, const QRect& area);
427 virtual void drawForeground(QPainter&, const QRect& area);
428
429private:
430 void init(int w, int h, int chunksze = 16, int maxclust = 100);
431
432 QtCanvasChunk& chunk(int i, int j) const;
433 QtCanvasChunk& chunkContaining(int x, int y) const;
434
435 QRect changeBounds();
436
437 int awidth, aheight;
438 int chunksize;
439 int maxclusters;
440 int chwidth, chheight;
441 QtCanvasChunk* chunks;
442
443 QtCanvasData* d;
444
445 void initTiles(QPixmap p, int h, int v, int tilewidth, int tileheight);
446 ushort* grid;
447 ushort htiles;
448 ushort vtiles;
449 ushort tilew;
450 ushort tileh;
451 bool oneone;
452 QPixmap pm;
453 QTimer* update_timer;
454 QColor bgcolor;
455 bool debug_redraw_areas;
456
457 friend void qt_unview(QtCanvas* c);
458
459 Q_DISABLE_COPY(QtCanvas)
460};
461
462class QtCanvasViewData;
463
464class QtCanvasView : public QScrollArea
465{
466 Q_OBJECT
468public:
469 QtCanvasView(QWidget* parent = 0);
470 QtCanvasView(QtCanvas* viewing, QWidget* parent = 0);
472
473 QtCanvas*
474 canvas() const
475 {
476 return viewing;
477 }
478
479 void setCanvas(QtCanvas* v);
480
481 const QMatrix& worldMatrix() const;
482 const QMatrix& inverseWorldMatrix() const;
483 bool setWorldMatrix(const QMatrix&);
484
485 virtual QSize sizeHint() const;
486
487 bool highQualityRendering() const;
488public slots:
489 void setHighQualityRendering(bool enable);
490
491protected:
492 friend class QtCanvasWidget;
493 virtual void drawContents(QPainter* p, int cx, int cy, int cw, int ch);
494
495 virtual void contentsMousePressEvent(QMouseEvent*);
496 virtual void contentsMouseReleaseEvent(QMouseEvent*);
497 virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
498 virtual void contentsMouseMoveEvent(QMouseEvent*);
499 virtual void contentsDragEnterEvent(QDragEnterEvent*);
500 virtual void contentsDragMoveEvent(QDragMoveEvent*);
501 virtual void contentsDragLeaveEvent(QDragLeaveEvent*);
502 virtual void contentsDropEvent(QDropEvent*);
503 virtual void contentsWheelEvent(QWheelEvent*);
504 virtual void contentsContextMenuEvent(QContextMenuEvent*);
505
506private:
507 friend class QtCanvas;
508 void drawContents(QPainter*);
509 QtCanvas* viewing;
511
512private slots:
513 void updateContentsSize();
514
515private:
516 Q_DISABLE_COPY(QtCanvasView)
517};
518
519class QtCanvasPixmap : public QPixmap
520{
521public:
522#ifndef QT_NO_IMAGEIO
523 QtCanvasPixmap(const QString& datafilename);
524#endif
525 QtCanvasPixmap(const QImage& image);
526 QtCanvasPixmap(const QPixmap&, const QPoint& hotspot);
528
529 int
530 offsetX() const
531 {
532 return hotx;
533 }
534
535 int
536 offsetY() const
537 {
538 return hoty;
539 }
540
541 void
542 setOffset(int x, int y)
543 {
544 hotx = x;
545 hoty = y;
546 }
547
548private:
549 Q_DISABLE_COPY(QtCanvasPixmap)
550
551 void init(const QImage&);
552 void init(const QPixmap& pixmap, int hx, int hy);
553
554 friend class QtCanvasSprite;
556 friend bool qt_testCollision(const QtCanvasSprite* s1, const QtCanvasSprite* s2);
557
558 int hotx, hoty;
559
560 QImage* collision_mask;
561};
562
564{
565public:
567#ifndef QT_NO_IMAGEIO
568 QtCanvasPixmapArray(const QString& datafilenamepattern, int framecount = 0);
569#endif
570 QtCanvasPixmapArray(const QList<QPixmap>& pixmaps, const QPolygon& hotspots = QPolygon());
572
573#ifndef QT_NO_IMAGEIO
574 bool readPixmaps(const QString& datafilenamepattern, int framecount = 0);
575 bool readCollisionMasks(const QString& filenamepattern);
576#endif
577
578 // deprecated
579 bool operator!(); // Failure check.
580 bool isValid() const;
581
583 image(int i) const
584 {
585 return img ? img[i] : 0;
586 }
587
588 void setImage(int i, QtCanvasPixmap* p);
589
590 uint
591 count() const
592 {
593 return (uint)framecount;
594 }
595
596private:
597 Q_DISABLE_COPY(QtCanvasPixmapArray)
598
599#ifndef QT_NO_IMAGEIO
600 bool readPixmaps(const QString& datafilenamepattern, int framecount, bool maskonly);
601#endif
602
603 void reset();
604 int framecount;
605 QtCanvasPixmap** img;
606};
607
609{
610public:
612
614
615 virtual ~QtCanvasSprite();
616
617 void move(double x, double y);
618 virtual void move(double x, double y, int frame);
619 void setFrame(int);
620
626
627 virtual void setFrameAnimation(FrameAnimationType = Cycle, int step = 1, int state = 0);
628
629 int
630 frame() const
631 {
632 return frm;
633 }
634
635 int
637 {
638 return images->count();
639 }
640
641 int rtti() const;
642 static int RTTI;
643
644 bool collidesWith(const QtCanvasItem*) const;
645
646 QRect boundingRect() const;
647
648 // is there a reason for these to be protected? Lars
649 //protected:
650
651 int width() const;
652 int height() const;
653
654 int leftEdge() const;
655 int topEdge() const;
656 int rightEdge() const;
657 int bottomEdge() const;
658
659 int leftEdge(int nx) const;
660 int topEdge(int ny) const;
661 int rightEdge(int nx) const;
662 int bottomEdge(int ny) const;
663
665 image() const
666 {
667 return images->image(frm);
668 }
669
670 virtual QtCanvasPixmap* imageAdvanced() const;
671
673 image(int f) const
674 {
675 return images->image(f);
676 }
677
678 virtual void advance(int stage);
679
680public:
681 void draw(QPainter& painter);
682
683private:
684 Q_DISABLE_COPY(QtCanvasSprite)
685
686 void addToChunks();
687 void removeFromChunks();
688 void changeChunks();
689
690 int frm;
691 ushort anim_val;
692 uint anim_state : 2;
693 uint anim_type : 14;
694 bool collidesWith(const QtCanvasSprite*,
696 const QtCanvasRectangle*,
697 const QtCanvasEllipse*,
698 const QtCanvasText*) const;
699
700 friend bool qt_testCollision(const QtCanvasSprite* s1, const QtCanvasSprite* s2);
701
702 QtCanvasPixmapArray* images;
703};
704
706
708{
709public:
711 virtual ~QtCanvasPolygonalItem();
712
713 bool collidesWith(const QtCanvasItem*) const;
714
715 virtual void setPen(QPen p);
716 virtual void setBrush(QBrush b);
717
718 QPen
719 pen() const
720 {
721 return pn;
722 }
723
724 QBrush
725 brush() const
726 {
727 return br;
728 }
729
730 virtual QPolygon areaPoints() const = 0;
731 virtual QPolygon areaPointsAdvanced() const;
732 QRect boundingRect() const;
733
734 int rtti() const;
735 static int RTTI;
736
737protected:
738 void draw(QPainter&);
739 virtual void drawShape(QPainter&) = 0;
740
741 bool winding() const;
742 void setWinding(bool);
743
744 void invalidate();
745
746 bool
747 isValid() const
748 {
749 return (bool)val;
750 }
751
752private:
753 void scanPolygon(const QPolygon& pa, int winding, QPolygonalProcessor& process) const;
754 QPolygon chunks() const;
755
756 bool collidesWith(const QtCanvasSprite*,
758 const QtCanvasRectangle*,
759 const QtCanvasEllipse*,
760 const QtCanvasText*) const;
761
762 QBrush br;
763 QPen pn;
764 uint wind : 1;
765};
766
768{
769public:
771 QtCanvasRectangle(const QRect&, QtCanvas* canvas);
772 QtCanvasRectangle(int x, int y, int width, int height, QtCanvas* canvas);
773
775
776 int width() const;
777 int height() const;
778 void setSize(int w, int h);
779
780 QSize
781 size() const
782 {
783 return QSize(w, h);
784 }
785
786 QPolygon areaPoints() const;
787
788 QRect
789 rect() const
790 {
791 return QRect(int(x()), int(y()), w, h);
792 }
793
794 bool collidesWith(const QtCanvasItem*) const;
795
796 int rtti() const;
797 static int RTTI;
798
799protected:
800 void drawShape(QPainter&);
801 QPolygon chunks() const;
802
803private:
804 bool collidesWith(const QtCanvasSprite*,
806 const QtCanvasRectangle*,
807 const QtCanvasEllipse*,
808 const QtCanvasText*) const;
809
810 int w, h;
811};
812
814{
815public:
818 void setPoints(QPolygon);
819 QPolygon points() const;
820 void moveBy(double dx, double dy);
821
822 QPolygon areaPoints() const;
823
824 int rtti() const;
825 static int RTTI;
826
827protected:
828 void drawShape(QPainter&);
829 QPolygon poly;
830};
831
833{
834public:
837
838 void setControlPoints(QPolygon, bool closed = true);
839 QPolygon controlPoints() const;
840 bool closed() const;
841
842 int rtti() const;
843 static int RTTI;
844
845private:
846 void recalcPoly();
847 QPolygon bez;
848 bool cl;
849};
850
852{
853public:
856 void setPoints(int x1, int y1, int x2, int y2);
857
858 QPoint
860 {
861 return QPoint(x1, y1);
862 }
863
864 QPoint
865 endPoint() const
866 {
867 return QPoint(x2, y2);
868 }
869
870 int rtti() const;
871 static int RTTI;
872
873 void setPen(QPen p);
874 void moveBy(double dx, double dy);
875
876protected:
877 void drawShape(QPainter&);
878 QPolygon areaPoints() const;
879
880private:
881 int x1, y1, x2, y2;
882};
883
885{
886
887public:
890 QtCanvasEllipse(int width, int height, int startangle, int angle, QtCanvas* canvas);
891
893
894 int width() const;
895 int height() const;
896 void setSize(int w, int h);
897 void setAngles(int start, int length);
898
899 int
901 {
902 return a1;
903 }
904
905 int
907 {
908 return a2;
909 }
910
911 QPolygon areaPoints() const;
912
913 bool collidesWith(const QtCanvasItem*) const;
914
915 int rtti() const;
916 static int RTTI;
917
918protected:
919 void drawShape(QPainter&);
920
921private:
922 bool collidesWith(const QtCanvasSprite*,
924 const QtCanvasRectangle*,
925 const QtCanvasEllipse*,
926 const QtCanvasText*) const;
927 int w, h;
928 int a1, a2;
929};
930
931
932class QtCanvasTextExtra;
933
935{
936public:
938 QtCanvasText(const QString&, QtCanvas* canvas);
939 QtCanvasText(const QString&, QFont, QtCanvas* canvas);
940
941 virtual ~QtCanvasText();
942
943 void setText(const QString&);
944 void setFont(const QFont&);
945 void setColor(const QColor&);
946 QString text() const;
947 QFont font() const;
948 QColor color() const;
949
950 void moveBy(double dx, double dy);
951
952 int
953 textFlags() const
954 {
955 return flags;
956 }
957
958 void setTextFlags(int);
959
960 QRect boundingRect() const;
961
962 bool collidesWith(const QtCanvasItem*) const;
963
964 int rtti() const;
965 static int RTTI;
966
967protected:
968 virtual void draw(QPainter&);
969
970private:
971 Q_DISABLE_COPY(QtCanvasText)
972
973 void addToChunks();
974 void removeFromChunks();
975 void changeChunks();
976
977 void setRect();
978 QRect brect;
979 QString txt;
980 int flags;
981 QFont fnt;
982 QColor col;
983 QtCanvasTextExtra* extra;
984
985 bool collidesWith(const QtCanvasSprite*,
987 const QtCanvasRectangle*,
988 const QtCanvasEllipse*,
989 const QtCanvasText*) const;
990};
constexpr T c
QList< QtCanvasItem * > QtCanvasItemList
Definition qtcanvas.h:62
QList< QtCanvasItem * > QtCanvasItemList
Definition qtcanvas.h:62
void setSize(int w, int h)
void setAngles(int start, int length)
QPolygon areaPoints() const
static int RTTI
Definition qtcanvas.h:916
void drawShape(QPainter &)
int angleLength() const
Definition qtcanvas.h:906
bool collidesWith(const QtCanvasItem *) const
int rtti() const
QtCanvasEllipse(QtCanvas *canvas)
int angleStart() const
Definition qtcanvas.h:900
int height() const
int width() const
void setXVelocity(double vx)
Definition qtcanvas.h:118
void setYVelocity(double vy)
Definition qtcanvas.h:124
friend class QtCanvasSprite
Definition qtcanvas.h:236
virtual void setActive(bool yes)
virtual void setVelocity(double vx, double vy)
static int RTTI
Definition qtcanvas.h:214
virtual QRect boundingRect() const =0
bool visible() const
Definition qtcanvas.h:177
friend class QtCanvasRectangle
Definition qtcanvas.h:237
double xVelocity() const
virtual bool collidesWith(const QtCanvasItem *) const =0
bool isActive() const
Definition qtcanvas.h:171
virtual void setEnabled(bool yes)
friend class QtCanvasPolygon
Definition qtcanvas.h:238
friend class QtCanvasPolygonalItem
Definition qtcanvas.h:235
friend class QtCanvasText
Definition qtcanvas.h:240
bool isSelected() const
Definition qtcanvas.h:155
friend class QtCanvasEllipse
Definition qtcanvas.h:239
QtCanvas * canvas() const
Definition qtcanvas.h:220
void setX(double a)
Definition qtcanvas.h:95
double x() const
Definition qtcanvas.h:74
friend class QtCanvasLine
Definition qtcanvas.h:241
virtual int rtti() const
QtCanvasItem(QtCanvas *canvas)
bool selected() const
Definition qtcanvas.h:183
bool isVisible() const
Definition qtcanvas.h:147
virtual ~QtCanvasItem()
virtual void setVisible(bool yes)
bool isEnabled() const
Definition qtcanvas.h:163
virtual void setCanvas(QtCanvas *)
virtual void draw(QPainter &)=0
virtual void moveBy(double dx, double dy)
virtual QRect boundingRectAdvanced() const
void setZ(double a)
Definition qtcanvas.h:107
void update()
Definition qtcanvas.h:227
virtual void advance(int stage)
double y() const
Definition qtcanvas.h:80
@ Rtti_PolygonalItem
Definition qtcanvas.h:204
virtual void setAnimated(bool y)
QtCanvasItemList collisions(bool exact) const
void setY(double a)
Definition qtcanvas.h:101
bool active() const
Definition qtcanvas.h:195
virtual void setSelected(bool yes)
double z() const
Definition qtcanvas.h:86
bool animated() const
void move(double x, double y)
bool enabled() const
Definition qtcanvas.h:189
double yVelocity() const
QPolygon areaPoints() const
static int RTTI
Definition qtcanvas.h:871
QtCanvasLine(QtCanvas *canvas)
void drawShape(QPainter &)
void setPoints(int x1, int y1, int x2, int y2)
int rtti() const
QPoint endPoint() const
Definition qtcanvas.h:865
void moveBy(double dx, double dy)
QPoint startPoint() const
Definition qtcanvas.h:859
void setPen(QPen p)
uint count() const
Definition qtcanvas.h:591
bool isValid() const
bool readPixmaps(const QString &datafilenamepattern, int framecount=0)
bool readCollisionMasks(const QString &filenamepattern)
QtCanvasPixmap * image(int i) const
Definition qtcanvas.h:583
void setImage(int i, QtCanvasPixmap *p)
friend class QtCanvasSprite
Definition qtcanvas.h:554
int offsetX() const
Definition qtcanvas.h:530
QtCanvasPixmap(const QString &datafilename)
friend class QtCanvasPixmapArray
Definition qtcanvas.h:555
int offsetY() const
Definition qtcanvas.h:536
void setOffset(int x, int y)
Definition qtcanvas.h:542
friend bool qt_testCollision(const QtCanvasSprite *s1, const QtCanvasSprite *s2)
QtCanvasPolygon(QtCanvas *canvas)
QPolygon areaPoints() const
static int RTTI
Definition qtcanvas.h:825
void drawShape(QPainter &)
int rtti() const
QPolygon points() const
void setPoints(QPolygon)
void moveBy(double dx, double dy)
QPolygon poly
Definition qtcanvas.h:829
virtual void setBrush(QBrush b)
QtCanvasPolygonalItem(QtCanvas *canvas)
QBrush brush() const
Definition qtcanvas.h:725
virtual ~QtCanvasPolygonalItem()
bool isValid() const
Definition qtcanvas.h:747
virtual QPolygon areaPointsAdvanced() const
void draw(QPainter &)
bool collidesWith(const QtCanvasItem *) const
QPen pen() const
Definition qtcanvas.h:719
virtual void drawShape(QPainter &)=0
virtual QPolygon areaPoints() const =0
QRect boundingRect() const
virtual void setPen(QPen p)
void setSize(int w, int h)
QPolygon areaPoints() const
static int RTTI
Definition qtcanvas.h:797
QPolygon chunks() const
void drawShape(QPainter &)
QSize size() const
Definition qtcanvas.h:781
bool collidesWith(const QtCanvasItem *) const
QRect rect() const
Definition qtcanvas.h:789
int rtti() const
int height() const
int width() const
QtCanvasRectangle(QtCanvas *canvas)
void setControlPoints(QPolygon, bool closed=true)
static int RTTI
Definition qtcanvas.h:843
QtCanvasSpline(QtCanvas *canvas)
int rtti() const
QPolygon controlPoints() const
bool closed() const
static int RTTI
Definition qtcanvas.h:642
int bottomEdge() const
QtCanvasPixmap * image(int f) const
Definition qtcanvas.h:673
virtual ~QtCanvasSprite()
int frame() const
Definition qtcanvas.h:630
QtCanvasSprite(QtCanvasPixmapArray *array, QtCanvas *canvas)
bool collidesWith(const QtCanvasItem *) const
int rtti() const
virtual void setFrameAnimation(FrameAnimationType=Cycle, int step=1, int state=0)
void setFrame(int)
void setSequence(QtCanvasPixmapArray *seq)
QtCanvasPixmap * image() const
Definition qtcanvas.h:665
int topEdge() const
virtual void advance(int stage)
virtual QtCanvasPixmap * imageAdvanced() const
int height() const
int width() const
int rightEdge() const
QRect boundingRect() const
int frameCount() const
Definition qtcanvas.h:636
void draw(QPainter &painter)
void move(double x, double y)
friend bool qt_testCollision(const QtCanvasSprite *s1, const QtCanvasSprite *s2)
int leftEdge() const
static int RTTI
Definition qtcanvas.h:965
QColor color() const
void setText(const QString &)
virtual void draw(QPainter &)
bool collidesWith(const QtCanvasItem *) const
int rtti() const
int textFlags() const
Definition qtcanvas.h:953
virtual ~QtCanvasText()
QtCanvasText(QtCanvas *canvas)
QString text() const
void moveBy(double dx, double dy)
void setTextFlags(int)
QFont font() const
QRect boundingRect() const
void setFont(const QFont &)
void setColor(const QColor &)
virtual void drawContents(QPainter *p, int cx, int cy, int cw, int ch)
const QMatrix & worldMatrix() const
friend class QtCanvasWidget
Definition qtcanvas.h:492
virtual void contentsMouseDoubleClickEvent(QMouseEvent *)
void setCanvas(QtCanvas *v)
QtCanvasView(QWidget *parent=0)
bool setWorldMatrix(const QMatrix &)
friend class QtCanvas
Definition qtcanvas.h:507
virtual void contentsMouseReleaseEvent(QMouseEvent *)
virtual void contentsDragEnterEvent(QDragEnterEvent *)
QtCanvas * canvas() const
Definition qtcanvas.h:474
void setHighQualityRendering(bool enable)
virtual void contentsWheelEvent(QWheelEvent *)
const QMatrix & inverseWorldMatrix() const
virtual void contentsDropEvent(QDropEvent *)
virtual void contentsMouseMoveEvent(QMouseEvent *)
virtual void contentsMousePressEvent(QMouseEvent *)
virtual void contentsDragLeaveEvent(QDragLeaveEvent *)
virtual QSize sizeHint() const
virtual void contentsContextMenuEvent(QContextMenuEvent *)
virtual void contentsDragMoveEvent(QDragMoveEvent *)
bool highQualityRendering
Definition qtcanvas.h:467
virtual void setAllChanged()
void drawViewArea(QtCanvasView *view, QPainter *p, const QRect &r, bool dbuf)
virtual void setBackgroundColor(const QColor &c)
virtual void setTiles(QPixmap tiles, int h, int v, int tilewidth, int tileheight)
void resized()
QtCanvas(QObject *parent=0)
Definition qtcanvas.cpp:618
int tile(int x, int y) const
Definition qtcanvas.h:290
int tileWidth() const
Definition qtcanvas.h:308
QtCanvasItemList collisions(const QPoint &) const
virtual void setAdvancePeriod(int ms)
Definition qtcanvas.cpp:998
virtual void setUnchanged(const QRect &area)
virtual void setTile(int x, int y, int tilenum)
int tilesHorizontally() const
Definition qtcanvas.h:296
virtual void setUpdatePeriod(int ms)
void drawArea(const QRect &, QPainter *p, bool double_buffer=false)
virtual void setChanged(const QRect &area)
virtual void resize(int width, int height)
Definition qtcanvas.cpp:716
bool validChunk(int x, int y) const
Definition qtcanvas.h:358
friend void qt_unview(QtCanvas *c)
virtual void addView(QtCanvasView *)
Definition qtcanvas.cpp:966
QSize size() const
Definition qtcanvas.h:334
int chunkSize() const
Definition qtcanvas.h:370
virtual void drawBackground(QPainter &, const QRect &area)
virtual void setBackgroundPixmap(const QPixmap &p)
virtual ~QtCanvas()
Definition qtcanvas.cpp:663
void removeItemFromChunkContaining(QtCanvasItem *, int x, int y)
virtual void advance()
QRect rect() const
Definition qtcanvas.h:340
virtual void setChangedChunk(int i, int j)
bool onCanvas(int x, int y) const
Definition qtcanvas.h:346
void removeItemFromChunk(QtCanvasItem *, int i, int j)
QPixmap backgroundPixmap() const
int tileHeight() const
Definition qtcanvas.h:314
virtual void removeItem(QtCanvasItem *)
Definition qtcanvas.cpp:955
virtual void update()
virtual void removeAnimation(QtCanvasItem *)
Definition qtcanvas.cpp:944
virtual void removeView(QtCanvasView *)
Definition qtcanvas.cpp:985
int height() const
Definition qtcanvas.h:328
bool sameChunk(int x1, int y1, int x2, int y2) const
Definition qtcanvas.h:378
void addItemToChunkContaining(QtCanvasItem *, int x, int y)
int width() const
Definition qtcanvas.h:322
QColor backgroundColor() const
virtual void addItem(QtCanvasItem *)
Definition qtcanvas.cpp:922
virtual void addAnimation(QtCanvasItem *)
Definition qtcanvas.cpp:933
void drawCanvasArea(const QRect &, QPainter *p=0, bool double_buffer=true)
QtCanvasItemList allItems()
Definition qtcanvas.cpp:706
bool onCanvas(const QPoint &p) const
Definition qtcanvas.h:352
bool validChunk(const QPoint &p) const
Definition qtcanvas.h:364
int tilesVertically() const
Definition qtcanvas.h:302
void addItemToChunk(QtCanvasItem *, int i, int j)
virtual void setChangedChunkContaining(int x, int y)
virtual void retune(int chunksize, int maxclusters=100)
Definition qtcanvas.cpp:800
virtual void drawForeground(QPainter &, const QRect &area)
This file offers overloads of toIce() and fromIce() functions for STL container types.
double angle(const Point &a, const Point &b, const Point &c)
Definition point.hpp:109