00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef CANVAS_CARD_GAME_H
00021 #define CANVAS_CARD_GAME_H
00022
00023 #include "cardgame.h"
00024 #include "canvasshapes.h"
00025 #include "canvascard.h"
00026
00027 #include <qpe/config.h>
00028
00029 #include <qmainwindow.h>
00030 #include <qmenubar.h>
00031 #include <qpainter.h>
00032
00033 #include <stdlib.h>
00034 #include <time.h>
00035
00036
00037 class CanvasCardPile;
00038
00039
00040 class CanvasCardGame : public QCanvasView, public CardGame
00041 {
00042 public:
00043 CanvasCardGame(QCanvas &c, bool snap, QWidget *parent = 0, int numOfDecks = 1, const char *name = 0, WFlags f = 0) :
00044 QCanvasView( &c, parent, name, f ),
00045 CardGame(0,numOfDecks),
00046 moved(FALSE),
00047 moving(NULL),
00048 alphaCardPile( NULL ),
00049 cardXOff(0), cardYOff(0),
00050 snapOn(snap),
00051 numberToDraw(1) { }
00052
00053 virtual ~CanvasCardGame();
00054
00055 virtual Card *newCard( eValue v, eSuit s, bool f ) {
00056 return new CanvasCard( v, s, f, canvas() );
00057 }
00058
00059 virtual void readConfig( Config& cfg ) { Q_UNUSED( cfg ); }
00060 virtual void writeConfig( Config& cfg ) { Q_UNUSED( cfg ); }
00061
00062 virtual void gameWon();
00063 virtual bool haveWeWon() { return FALSE; }
00064
00065 virtual bool mousePressCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); return FALSE; }
00066 virtual void mouseReleaseCard(Card *card, QPoint p) { Q_UNUSED(card); Q_UNUSED(p); }
00067
00068 void cancelMoving() { moving = NULL; }
00069 void toggleSnap() { snapOn = (snapOn == TRUE) ? FALSE : TRUE; }
00070 void toggleCardsDrawn() { numberToDraw = (numberToDraw == 1) ? 3 : 1; }
00071 int cardsDrawn() { return numberToDraw; }
00072 void setNumberToDraw(int numToDraw) { this->numberToDraw = numToDraw; }
00073
00074 void readPile( Config& cfg, CardPile *pile, QString name, int& highestZ );
00075
00076 protected:
00077 void contentsMousePressEvent(QMouseEvent *e);
00078 void contentsMouseReleaseEvent(QMouseEvent *e);
00079 void contentsMouseMoveEvent(QMouseEvent *e);
00080 virtual void checkUnusable() { }
00081
00082 protected:
00083
00084 bool moved;
00085 CanvasCard *moving;
00086 CanvasCardPile *alphaCardPile;
00087 int cardXOff, cardYOff;
00088
00089 private:
00090 bool snapOn;
00091 int numberToDraw;
00092 };
00093
00094
00095 #endif
00096