//*****************************************************************************
// 
// Blackjack - an X windows program of the casino game.
// Copyright (C) 1997  Tom Daley 
// 
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// 
// The license is in the file COPYING.
// 
// Tom Daley
// 1309 W. Lorraine Ave.
// Woodland Park, CO  80863-2329
// 
// daley@codenet.net (Tom Daley)
// http://users.codenet.net/daley
// 
//*****************************************************************************
//
// The _init flag indicates that the pixmaps for the card have been made. 
// The bitmaps can be made explicitly by calling init().
// If init() is not called, the first call to getPixmap() will call init().
//
//*****************************************************************************

#ifndef _CARD_INCLUDED_
#define _CARD_INCLUDED_

#include <qwidget.h>
#include <qbitmap.h>

#define CARD_WIDTH   79
#define CARD_HEIGHT 123 

//*****************************************************************************

class Card {
   public:
      enum SuitType {SPADE, HEART, DIAMOND, CLUB};
      enum RankType {ACE = 1, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, 
                     TEN, JACK, QUEEN, KING};
      enum Direction {FACE_UP, FACE_DOWN};
   private:
      enum CardBackType {DEFAULT, USER};
      Direction _dir;
      SuitType _suit;
      RankType _rank;

      static   int      _init_flag;
      static   QBitmap *_suit_bitmaps[CLUB + 1];
      static   QBitmap *_small_suit_bitmaps[CLUB + 1];
      static   QBitmap *_large_spade_bitmap;
      static   QBitmap *_rank_bitmaps[KING + 1];
      static   QBitmap *_royalty_bitmaps[KING - JACK + 1][CLUB + 1];

      static   QPixmap *_card_pixmaps[KING + 1][CLUB + 1];
      static   QPixmap *_card_back_pixmaps[USER + 1];
   public:
      Card(RankType rank, SuitType suit, Direction dir = FACE_UP) : 
           _rank(rank), _suit(suit), _dir(dir) { }
      static void init(void);
      RankType getRank(void) { return _rank; }
      SuitType getSuit(void) { return _suit; }
      void setDirection(Direction dir) { _dir = dir; }
      QPixmap *getPixmap(void);
      QPixmap *setCardBackPixmap(QPixmap *pixmap_p) { 
              QPixmap *temp = _card_back_pixmaps[USER];
              _card_back_pixmaps[USER] = pixmap_p;
              return (temp);
      }
   private:
      QPixmap *makePixmap(void);
      static QPixmap *makeCardbackPixmap(void);
};

#endif     

//*****************************************************************************
