00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CANVAS_CARD_H
00021 #define CANVAS_CARD_H
00022
00023
00024 #include <qpainter.h>
00025 #include <qbitmap.h>
00026 #include <qpixmap.h>
00027 #include <qpoint.h>
00028 #include <qcanvas.h>
00029 #include "cardgame.h"
00030
00031
00032
00033 static const int canvasCardId = 2434321;
00034
00035
00036 class CanvasCard : public Card, public QCanvasRectangle
00037 {
00038 public:
00039 CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas );
00040 virtual ~CanvasCard() { canvas()->removeItem(this); }
00041
00042 int rtti () const { return canvasCardId; }
00043 void move(QPoint p) { QCanvasItem::move( p.x(), p.y() ); }
00044 void move(int x, int y) { QCanvasItem::move( x, y ); }
00045 void animatedMove(int x, int y, int steps = 10);
00046 void animatedMove() { animatedMove(savedX, savedY); }
00047 void savePos(void) { savedX = (int)x(); savedY = (int)y(); }
00048 void moveToPile(int p) { Q_UNUSED(p); }
00049 void setCardBack(int b);
00050
00051 void flipTo(int x, int y, int steps = 8);
00052 void setPos( int x, int y, int z ) { setX( x ); setY( y ); setZ( z ); }
00053 void showCard(void) { show(); }
00054 void redraw(void) { hide(); show(); }
00055 void draw(QPainter &p);
00056
00057 void advance(int stage);
00058
00059 protected:
00060 void flip(void) { redraw(); }
00061
00062 private:
00063 int destX, destY;
00064 int animSteps;
00065 int flipSteps;
00066 bool flipping;
00067 int savedX, savedY;
00068 int cardBack;
00069 int oldCardBack;
00070 double scaleX, scaleY;
00071 int xOff, yOff;
00072 static QPixmap *cardsFaces;
00073 static QPixmap *cardsBacks;
00074 static QBitmap *cardsChars;
00075 static QBitmap *cardsSuits;
00076 static QBitmap *cardsCharsUpsideDown;
00077 static QBitmap *cardsSuitsUpsideDown;
00078 };
00079
00080
00081 #endif
00082