1 #ifndef CARDREGION_INCLUDED
2 #define CARDREGION_INCLUDED
7 // This class defines a physical card-stack,
8 // which draws the cards, supports
13 friend class CardWindow
;
14 friend class CardStack
;
17 // Constructor is PRIVATE - only
18 // a CardWindow can create cardstacks!
20 CardRegion(CardWindow
&parent
, int id
, bool fVisible
,
21 int x
, int y
, int xOffset
, int yOffset
);
27 void SetBackColor(COLORREF cr
);
29 void SetCardStack(const CardStack
&cs
);
30 const CardStack
& GetCardStack();
33 // Event-callback support
35 bool SetDragRule(UINT uDragType
, pCanDragProc proc
= 0);
36 bool SetDropRule(UINT uDropType
, pCanDropProc proc
= 0);
38 void SetClickProc (pClickProc proc
);
39 void SetClickReleaseProc (pClickProc proc
);
40 void SetDblClickProc (pClickProc proc
);
42 void SetAddCardProc (pAddProc proc
);
43 void SetRemoveCardProc (pRemoveProc proc
);
46 // Physical attribute support
48 bool SetThreedCount (int count
);
49 void SetOffsets (int x
, int y
);
50 void SetPos (int x
, int y
);
51 void Show (bool fShow
);
54 void SetEmptyImage (UINT uImage
);
55 void SetBackCardIdx (UINT uBackIdx
);
56 void SetPlacement (UINT xJustify
, UINT yJustify
, int xAdjust
, int yAdjust
);
61 void SetFaceDirection(UINT uDirType
, int nOption
);
62 UINT
GetFaceDirection(int *pnOption
);
64 void Flash(int count
, int timeout
);
69 CardWindow
&GetCardWindow() { return parentWnd
; }
71 bool PlayCard(CardRegion
*pDestStack
, int value
, int num
);
72 bool MoveCard(CardRegion
*pDestStack
, int nNumCards
, bool fAnimate
);
73 bool SimulateDrag(CardRegion
*pDestStack
, int nNumCards
, bool fAnimate
);
79 // Common wrappers for the CardStack object
82 void NewDeck() { cardstack
.NewDeck(); }
83 void Shuffle() { cardstack
.Shuffle(); }
84 void Clear() { cardstack
.Clear(); }
86 void Reverse() { cardstack
.Reverse(); }
88 void Push(const Card card
) { cardstack
.Push(card
); }
89 void Push(const CardStack
&cs
) { cardstack
.Push(cs
); }
91 Card
Pop() { return cardstack
.Pop(); }
92 CardStack
Pop(int items
) { return cardstack
.Pop(items
); }
94 Card
Top() { return cardstack
.Top(); }
95 CardStack
Top(int items
) { return cardstack
.Top(items
); }
101 void RedrawIfNotDim(CardRegion
*compare
, bool fFullRedraw
);
103 void UpdateFaceDir(CardStack
&cards
);
105 void Render(HDC hdc
);
106 int GetOverlapRatio(int x
, int y
, int width
, int height
);
108 void MoveDragCardTo(HDC hdc
, int x
, int y
);
109 void ZoomCard(HDC hdc
, int xpos
, int ypos
, CardRegion
*dest
);
111 void RenderBottomMost(HDC hdc
, int minustopmost
= 0);
112 void PrepareDragBitmaps(int numtodrag
);
113 void PrepareDragBitmapsThreed(int numtodrag
);
114 void ReleaseDragBitmaps(void);
116 bool CanDragCards(int iNumCards
);
117 bool CanDropCards(CardStack
&cards
);
119 void CalcApparentCards();
120 int CalcApparentCards(int realnum
);
123 void AdjustPosition(int winwidth
, int winheight
);
125 bool IsPointInStack(int x
, int y
);
127 int GetNumDragCards(int x
, int y
);
128 bool OnLButtonDown(int x
, int y
);
129 bool OnLButtonDblClk(int x
, int y
);
130 bool OnMouseMove(int x
, int y
);
131 bool OnLButtonUp(int x
, int y
);
132 void ClickRelease(int x
, int y
);
136 // Private data members
141 CardWindow
&parentWnd
;
143 CardStack cardstack
; //cards in this stack
144 CardStack dragstack
; //cards which we might be dragging
148 int xpos
; //coordinates of stack
151 int xoffset
; //direction that cards take
154 int width
; //stack-size of all cards
158 // justify / placement vars
165 // Used for mouse-dragging / moving cards
181 int nNumApparentCards
;
200 // Stack callback support
202 pCanDragProc CanDragCallback
;
203 pCanDropProc CanDropCallback
;
204 pClickProc ClickCallback
;
205 pClickProc ClickReleaseCallback
;
206 pClickProc DblClickCallback
;
207 pAddProc AddCallback
;
208 pRemoveProc RemoveCallback
;
210 //locking mechanism to prevent user dragging etc
214 #endif /* CARDREGION_INCLUDED */