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

cardpile.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 CARD_PILE_H
00021 #define CARD_PILE_H
00022 
00023 #include "card.h"
00024 
00025 
00026 #include <qpoint.h>
00027 #include <qlist.h>
00028 
00029 
00030 enum ePileStackingType {
00031     pileCascades = 0, pileStacks, pileCascadesOrStacks
00032 };
00033 
00034 
00035 enum ePileFaceingType {
00036     pileFaceUp = 0, pileFaceDown, pileFaceUpOrDown
00037 };
00038 
00039 
00040 class Card;
00041 class Config;
00042 
00043 
00044 class CardPile : public QList<Card>
00045 {
00046 public:
00047     CardPile(int x, int y);
00048     virtual ~CardPile() { }
00049 
00050     int getX() { return pileX; }
00051     int getY() { return pileY; }
00052     int getNextX() { return pileNextX; }
00053     int getNextY() { return pileNextY; }
00054     int getWidth() { return pileWidth; }
00055     int getHeight() { return pileHeight; }
00056     int getOffsetDown() { return pileOffsetDown; }
00057     int getAnzCardsInPile() { 
00058         int anz=0;
00059         Card *card = cardOnBottom();
00060         while (card != NULL) { anz++; card = cardInfront(card); }
00061         return anz;
00062     }
00063 
00064     void setX(int x) { pileX = x; }
00065     void setY(int y) { pileY = y; }
00066     void setNextX(int x) { pileNextX = x; }
00067     void setNextY(int y) { pileNextY = y; }
00068     void setWidth(int width) { pileWidth = width; }
00069     void setHeight(int height) { pileHeight = height; }
00070     void setOffsetDown(int down) { pileOffsetDown = down; }
00071     
00072     void beginDealing() { dealing = TRUE; }
00073     void endDealing() { dealing = FALSE; }
00074     bool isDealing() { return dealing; }
00075 
00076     void beginPileResize() { PileResize = TRUE; }
00077     void endPileResize() { PileResize = FALSE; }
00078     bool isPileResize() { return PileResize; }
00079     
00080     int distanceFromPile(int x, int y);
00081     int distanceFromNextPos(int x, int y);
00082     
00083     Card *cardOnTop() { return getLast(); }
00084     Card *cardOnBottom() { return getFirst(); }
00085     Card *cardInfront(Card *c);
00086     bool kingOnTop();
00087 
00088     bool addCardToTop(Card *c);
00089     bool addCardToBottom(Card *c);
00090     bool removeCard(Card *c);
00091     
00092     virtual void cardAddedToTop(Card *) { }
00093     virtual void cardAddedToBottom(Card *) { }
00094     virtual void cardRemoved(Card *) { }
00095     virtual bool isAllowedOnTop(Card *) { return FALSE; }
00096     virtual bool isAllowedOnBottom(Card *) { return FALSE; }
00097     virtual bool isAllowedToBeMoved(Card *) { return FALSE; }
00098     virtual QPoint getCardPos(Card *) { return QPoint(pileX, pileY); }
00099     virtual QPoint getHypertheticalNextCardPos() { return QPoint(pileX, pileY); }
00100 
00101     void writeConfig( Config& cfg, QString name );
00102     
00103 protected:    
00104     int pileX, pileY;
00105     int pileNextX, pileNextY;
00106     int pileWidth, pileHeight;
00107     int pileCenterX, pileCenterY;
00108     int pileRadius;
00109     int pileOffsetDown;
00110 private:
00111     bool dealing;
00112     bool PileResize;
00113 };
00114 
00115 
00116 #endif
00117 

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