1 #ifndef CARDREGION_INCLUDED
2 #define CARDREGION_INCLUDED
11 // This class defines a physical card-stack,
12 // which draws the cards, supports
17 friend class CardWindow
;
18 friend class CardStack
;
21 // Constructor is PRIVATE - only
22 // a CardWindow can create cardstacks!
24 CardRegion(CardWindow
&parent
, int id
, bool fVisible
,
25 int x
, int y
, int xOffset
, int yOffset
);
31 void SetBackColor(COLORREF cr
);
33 void SetCardStack(const CardStack
&cs
);
34 const CardStack
& GetCardStack();
37 // Event-callback support
39 bool SetDragRule(UINT uDragType
, pCanDragProc proc
= 0);
40 bool SetDropRule(UINT uDropType
, pCanDropProc proc
= 0);
42 void SetClickProc (pClickProc proc
);
43 void SetDblClickProc (pClickProc proc
);
45 void SetAddCardProc (pAddProc proc
);
46 void SetRemoveCardProc (pRemoveProc proc
);
49 // Physical attribute support
51 bool SetThreedCount (int count
);
52 void SetOffsets (int x
, int y
);
53 void SetPos (int x
, int y
);
54 void Show (bool fShow
);
57 void SetEmptyImage (UINT uImage
);
58 void SetBackCardIdx (UINT uBackIdx
);
59 void SetPlacement (UINT xJustify
, UINT yJustify
, int xAdjust
, int yAdjust
);
64 void SetFaceDirection(UINT uDirType
, int nOption
);
65 UINT
GetFaceDirection(int *pnOption
);
67 void Flash(int count
, int timeout
);
72 CardWindow
&GetCardWindow() { return parentWnd
; }
74 bool PlayCard(CardRegion
*pDestStack
, int value
, int num
);
75 bool MoveCard(CardRegion
*pDestStack
, int nNumCards
, bool fAnimate
);
76 bool SimulateDrag(CardRegion
*pDestStack
, int nNumCards
, bool fAnimate
);
82 // Common wrappers for the CardStack object
85 void NewDeck() { cardstack
.NewDeck(); }
86 void Shuffle() { cardstack
.Shuffle(); }
87 void Clear() { cardstack
.Clear(); }
89 void Reverse() { cardstack
.Reverse(); }
91 void Push(const Card card
) { cardstack
.Push(card
); }
92 void Push(const CardStack
&cs
) { cardstack
.Push(cs
); }
94 Card
Pop() { return cardstack
.Pop(); }
95 CardStack
Pop(int items
) { return cardstack
.Pop(items
); }
97 Card
Top() { return cardstack
.Top(); }
98 CardStack
Top(int items
) { return cardstack
.Top(items
); }
104 void RedrawIfNotDim(CardRegion
*compare
, bool fFullRedraw
);
106 void UpdateFaceDir(CardStack
&cards
);
108 void Render(HDC hdc
);
109 int GetOverlapRatio(int x
, int y
, int width
, int height
);
111 void MoveDragCardTo(HDC hdc
, int x
, int y
);
112 void ZoomCard(HDC hdc
, int xpos
, int ypos
, CardRegion
*dest
);
114 void RenderBottomMost(HDC hdc
, int minustopmost
= 0);
115 void PrepareDragBitmaps(int numtodrag
);
116 void PrepareDragBitmapsThreed(int numtodrag
);
117 void ReleaseDragBitmaps(void);
119 bool CanDragCards(int iNumCards
);
120 bool CanDropCards(CardStack
&cards
);
122 void CalcApparentCards();
123 int CalcApparentCards(int realnum
);
126 void AdjustPosition(int winwidth
, int winheight
);
128 bool IsPointInStack(int x
, int y
);
130 int GetNumDragCards(int x
, int y
);
131 bool OnLButtonDown(int x
, int y
);
132 bool OnLButtonDblClk(int x
, int y
);
133 bool OnMouseMove(int x
, int y
);
134 bool OnLButtonUp(int x
, int y
);
138 // Private data members
143 CardWindow
&parentWnd
;
145 CardStack cardstack
; //cards in this stack
146 CardStack dragstack
; //cards which we might be dragging
150 int xpos
; //coordinates of stack
153 int xoffset
; //direction that cards take
156 int width
; //stack-size of all cards
160 // justify / placement vars
167 // Used for mouse-dragging / moving cards
183 int nNumApparentCards
;
202 // Stack callback support
204 pCanDragProc CanDragCallback
;
205 pCanDropProc CanDropCallback
;
206 pClickProc ClickCallback
;
207 pClickProc DblClickCallback
;
208 pAddProc AddCallback
;
209 pRemoveProc RemoveCallback
;
211 //locking mechanism to prevent user dragging etc