Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
4.5 KiB

  1. /***************************************************************************/
  2. /** Microsoft Windows **/
  3. /** Copyright(c) Microsoft Corp., 1991, 1992 **/
  4. /***************************************************************************/
  5. /****************************************************************************
  6. card.h
  7. Feb 92, JimH
  8. Header file for class card
  9. ****************************************************************************/
  10. #ifndef CARD_INC
  11. #define CARD_INC
  12. // typedefs for pointers to functions in cards.dll
  13. // cdtTerm() can use standard FARPROC
  14. typedef BOOL (FAR PASCAL *DRAWPROC)(HDC, int, int, int, int, DWORD);
  15. typedef BOOL (FAR PASCAL *INITPROC)(int FAR *, int FAR *);
  16. const int EMPTY = -1;
  17. const int FACEUP = 0;
  18. const int FACEDOWN = 1;
  19. const int HILITE = 2;
  20. const int CARDBACK = 54;
  21. const int ACE = 0;
  22. const int QUEEN = 11;
  23. const int KING = 12;
  24. const int TWOCLUBS = 4;
  25. const int BLACKLADY = 47;
  26. const int CLUBS = 0;
  27. const int DIAMONDS = 1;
  28. const int HEARTS = 2;
  29. const int SPADES = 3;
  30. const int POPSPACING = 20; // selected cards pop up this high
  31. const int MAXSUIT = 4;
  32. enum statetype { NORMAL, SELECTED, PLAYED, HIDDEN };
  33. class card {
  34. private:
  35. int id; // 0 to 51
  36. POINT loc; // current top-left corner loc.
  37. statetype state; // selected or hidden?
  38. static int count; // number of card instances
  39. static int stepsize; // size of glide() steps
  40. static HINSTANCE hCardsDLL; // handle to cards.dll
  41. static INITPROC lpcdtInit; // ptr to cards.cdtInit()
  42. static DRAWPROC lpcdtDraw; // ptr to cards.cdtDraw()
  43. static FARPROC lpcdtTerm; // ptr to cards.cdtTerm()
  44. static CBitmap m_bmFgnd; // animation card
  45. static CBitmap m_bmBgnd2; // background dest bitmap
  46. static CDC m_MemB, m_MemB2; // memory DCs for bkgnd bitmaps
  47. static CRgn m_Rgn1, m_Rgn2; // hRgn1 is source, hRgn2 is dest
  48. static CRgn m_Rgn; // combined region
  49. static DWORD dwPixel[12]; // corner pixels for save/restore
  50. VOID GlideStep(CDC &dc, int x1, int y1, int x2, int y2);
  51. VOID SaveCorners(CDC &dc, int x, int y);
  52. VOID RestoreCorners(CDC &dc, int x, int y);
  53. int IntSqrt(long square);
  54. public:
  55. static BOOL bConstructed;
  56. static int dxCrd, dyCrd; // size of card bitmap
  57. static CBitmap m_bmBgnd; // what's under card to glide
  58. card(int n = EMPTY);
  59. ~card();
  60. int ID() { ASSERT(this != NULL); return id; }
  61. int Suit() { ASSERT(this != NULL); return (id % MAXSUIT); }
  62. int Value() { ASSERT(this != NULL); return (id / MAXSUIT); }
  63. int Value2() { int v = Value(); return ((v == ACE) ? (KING + 1) : v); }
  64. VOID Select(BOOL b) { state = (b ? SELECTED : NORMAL); }
  65. BOOL IsEmpty() { ASSERT(this != NULL); return (id == EMPTY); }
  66. BOOL IsSelected() { ASSERT(this != NULL); return (state == SELECTED); }
  67. BOOL IsPlayed() { ASSERT(this != NULL); return (state == PLAYED); }
  68. BOOL IsHeart() { return (Suit() == HEARTS); }
  69. BOOL IsValid() { return ((this != NULL) && (id != EMPTY)); }
  70. VOID SetID(int n) { id = n; }
  71. VOID SetLoc(int x, int y) { loc.x = x; loc.y = y; }
  72. int SetStepSize(int s) { int old = stepsize; stepsize = s; return old;}
  73. int GetX(void) { return loc.x; }
  74. int GetY(void) { return loc.y; }
  75. BOOL Draw(CDC &dc, int x, int y,
  76. int mode = FACEUP, BOOL bUpdateLoc = TRUE);
  77. BOOL Draw(CDC &dc) { return Draw(dc, loc.x, loc.y, FACEUP); }
  78. BOOL Draw(CDC &dc, int mode) { return Draw(dc, loc.x, loc.y, mode); }
  79. BOOL PopDraw(CDC &dc); // draw with selections popped
  80. BOOL CleanDraw(CDC &dc); // draw with clean corners
  81. VOID Glide(CDC &dc, int xEnd, int yEnd);
  82. CRect &GetRect(CRect& rect);
  83. VOID Remove() { state = HIDDEN; id = EMPTY; }
  84. VOID Play() { state = PLAYED; }
  85. BOOL IsNormal() { return (state == NORMAL); }
  86. BOOL IsInHand() { return ((state == NORMAL) || (state == SELECTED)); }
  87. };
  88. #endif // conditional include