///////////////////////////////////////////////////////////////////////////// // Name: card.h // tag: header for the card class // Author: Chris Breeze // Modified by: David Roundy // Created: 21/07/97 // RCS-ID: $Id: card.h,v 1.4 2002/02/21 13:29:08 droundy Exp $ // Copyright: (c) 1993-1998 Chris Breeze // 2001-2003 David Roundy // Licence: GPL /* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CARD_H_ #define _CARD_H_ // Constants const int PackSize = 52; const int CardWidth = 50; const int CardHeight = 70; // Data types enum WayUp { faceup, facedown }; #include class wxBitmap; #include "suit.h" class Card { public: Card(int value=1, WayUp way_up = facedown); Card(wxString string, WayUp way_up = facedown); Card(const Card &); virtual ~Card(); void SetSameAs(const Card &); void Draw(wxDC& pDC, int x, int y, int w, int h); void TurnCard(WayUp way_up = faceup); WayUp GetWayUp() const { return m_wayUp; } int GetPipValue() const { return m_pipValue; } int GetBridgeValue() const { return (m_pipValue==1)?14:m_pipValue; } Suit GetSuit() const { return m_suit; } SuitColour GetColour() const { return m_colour; } int GetCardValue() const; wxString GetString() const; bool operator==(const Card &) const; bool operator<(const Card &) const; bool operator>(const Card &) const; bool IsFaceDown() const { return m_wayUp == facedown; }; static wxBitmap GetSuitSymbol(Suit suit, wxColor back = wxNullColour); Card *next; private: Suit m_suit; int m_pipValue; // in the range 1 (Ace) to 13 (King) SuitColour m_colour; // red or black bool m_status; WayUp m_wayUp; wxBitmap *cachedbits; int cached_w, cached_h; static wxBitmap* m_symbolBmap; static wxBitmap* m_pictureBmap; }; class wxCard : public wxControl { public: wxCard(wxWindow* parent, int value=1, WayUp way_up = facedown, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(CardWidth,CardHeight)); wxCard(wxWindow* parent, const Card &, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize(CardWidth,CardHeight)); virtual ~wxCard(); void DoPaint(wxPaintEvent& event); Suit GetSuit() const { return m_card.GetSuit(); } void SetSameAs(const Card &c) { m_card.SetSameAs(c); } wxString GetString() const { return m_card.GetString(); } Card GetCard() const { return m_card; } void TurnCard(WayUp w = faceup) { m_card.TurnCard(w); } DECLARE_EVENT_TABLE(); private: Card m_card; }; #endif // _CARD_H_