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

canvascardgame.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_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() { }  //added for freecell
00081 
00082 protected:
00083     // Mouse event state variables
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 

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