card.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: card.h
  3. // Purpose: Forty Thieves patience game
  4. // Author: Chris Breeze
  5. // Modified by:
  6. // Created: 21/07/97
  7. // Copyright: (c) 1993-1998 Chris Breeze
  8. // Licence: wxWindows licence
  9. //---------------------------------------------------------------------------
  10. // Last modified: 22nd July 1998 - ported to wxWidgets 2.0
  11. /////////////////////////////////////////////////////////////////////////////
  12. //+-------------------------------------------------------------+
  13. //| Description: |
  14. //| A class for drawing playing cards. |
  15. //| InitCards() must be called before using the Card class, |
  16. //| otherwise the card bitmaps will not be loaded. |
  17. //| CloseCards() must be called before terminating the |
  18. //| program so that the bitmaps are deleted and the memory |
  19. //| given back to Windows. |
  20. //+-------------------------------------------------------------+
  21. #ifndef _CARD_H_
  22. #define _CARD_H_
  23. // Constants
  24. const int PackSize = 52;
  25. #define CardHeight Card::GetHeight()
  26. #define CardWidth Card::GetWidth()
  27. // Data types
  28. enum Suit { clubs = 0, diamonds = 1, hearts = 2, spades = 3 };
  29. enum SuitColour { red = 0, black = 1 };
  30. enum WayUp { faceup, facedown };
  31. //--------------------------------//
  32. // A class defining a single card //
  33. //--------------------------------//
  34. class Card {
  35. friend class FortyApp;
  36. static double m_scale;
  37. static int m_width,m_height;
  38. public:
  39. Card(int value, WayUp way_up = facedown);
  40. virtual ~Card(){};
  41. void Draw(wxDC& pDC, int x, int y);
  42. static void DrawNullCard(wxDC& pDC, int x, int y); // Draw card place-holder
  43. void Erase(wxDC& pDC, int x, int y);
  44. void TurnCard(WayUp way_up = faceup) { m_wayUp = way_up; }
  45. WayUp GetWayUp() const { return m_wayUp; }
  46. int GetPipValue() const { return m_pipValue; }
  47. Suit GetSuit() const { return m_suit; }
  48. SuitColour GetColour() const { return m_colour; }
  49. static void SetScale(double scale);
  50. static int GetHeight() { return m_height; };
  51. static int GetWidth() { return m_width; };
  52. static double GetScale() { return m_scale; };
  53. private:
  54. Suit m_suit;
  55. int m_pipValue; // in the range 1 (Ace) to 13 (King)
  56. SuitColour m_colour; // red or black
  57. bool m_status;
  58. WayUp m_wayUp;
  59. static wxBitmap* m_symbolBmap;
  60. static wxBitmap* m_pictureBmap;
  61. };
  62. #endif // _CARD_H_