Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

canvascard.h

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
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 // ### Just made the number up, is that what you do???
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     /*virtual*/ void flipTo(int x, int y, int steps = 8);
00052     /*virtual*/ void setPos( int x, int y, int z ) { setX( x ); setY( y ); setZ( z ); }
00053     /*virtual*/ void showCard(void) { show(); }
00054     /*virtual*/ void redraw(void) { hide(); show(); }
00055     /*virtual*/ void draw(QPainter &p);
00056 
00057     void advance(int stage);
00058 
00059 protected:
00060     /*virtual*/ 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 

Generated on Sat Nov 5 16:17:25 2005 for OPIE by  doxygen 1.4.2