ReactOS  0.4.13-dev-99-g7e18b6d
cardregion.h
Go to the documentation of this file.
1 #ifndef CARDREGION_INCLUDED
2 #define CARDREGION_INCLUDED
3 
4 class CardWindow;
5 
6 //
7 // This class defines a physical card-stack,
8 // which draws the cards, supports
9 //
10 
12 {
13  friend class CardWindow;
14  friend class CardStack;
15 
16  //
17  // Constructor is PRIVATE - only
18  // a CardWindow can create cardstacks!
19  //
20  CardRegion(CardWindow &parent, int id, bool fVisible,
21  int x, int y, int xOffset, int yOffset);
22 
23  ~CardRegion();
24 
25 public:
26 
27  void SetBackColor(COLORREF cr);
28 
29  void SetCardStack(const CardStack &cs);
30  const CardStack & GetCardStack();
31 
32  //
33  // Event-callback support
34  //
35  bool SetDragRule(UINT uDragType, pCanDragProc proc = 0);
36  bool SetDropRule(UINT uDropType, pCanDropProc proc = 0);
37 
41 
44 
45  //
46  // Physical attribute support
47  //
48  bool SetThreedCount (int count);
49  void SetOffsets (int x, int y);
50  void SetPos (int x, int y);
51  void Show (bool fShow);
52  bool IsVisible ();
53 
54  void SetEmptyImage (UINT uImage);
55  void SetBackCardIdx (UINT uBackIdx);
56  void SetPlacement (UINT xJustify, UINT yJustify, int xAdjust, int yAdjust);
57 
58  void Update();
59  void Redraw();
60 
61  void SetFaceDirection(UINT uDirType, int nOption);
62  UINT GetFaceDirection(int *pnOption);
63 
64  void Flash(int count, int timeout);
65  void StopFlash();
66 
67  int Id();
68 
70 
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);
74 
75  bool Lock();
76  bool UnLock();
77 
78  //
79  // Common wrappers for the CardStack object
80  //
81  int NumCards() const;
82  void NewDeck() { cardstack.NewDeck(); }
83  void Shuffle() { cardstack.Shuffle(); }
84  void Clear() { cardstack.Clear(); }
85 
86  void Reverse() { cardstack.Reverse(); }
87 
88  void Push(const Card card) { cardstack.Push(card); }
89  void Push(const CardStack &cs) { cardstack.Push(cs); }
90 
91  Card Pop() { return cardstack.Pop(); }
92  CardStack Pop(int items) { return cardstack.Pop(items); }
93 
94  Card Top() { return cardstack.Top(); }
95  CardStack Top(int items) { return cardstack.Top(items); }
96 
97 
98 private:
99 
100  void DoFlash();
101  void RedrawIfNotDim(CardRegion *compare, bool fFullRedraw);
102 
103  void UpdateFaceDir(CardStack &cards);
104  void Clip(HDC hdc);
105  void Render(HDC hdc);
106  int GetOverlapRatio(int x, int y, int width, int height);
107 
108  void MoveDragCardTo(HDC hdc, int x, int y);
109  void ZoomCard(HDC hdc, int xpos, int ypos, CardRegion *dest);
110 
111  void RenderBottomMost(HDC hdc, int minustopmost = 0);
112  void PrepareDragBitmaps(int numtodrag);
113  void PrepareDragBitmapsThreed(int numtodrag);
114  void ReleaseDragBitmaps(void);
115 
116  bool CanDragCards(int iNumCards);
117  bool CanDropCards(CardStack &cards);
118 
119  void CalcApparentCards();
120  int CalcApparentCards(int realnum);
121 
122  void UpdateSize();
123  void AdjustPosition(int winwidth, int winheight);
124 
125  bool IsPointInStack(int x, int y);
126 
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);
133 
134 
135  //
136  // Private data members
137  //
138 
139  int id;
140 
142 
143  CardStack cardstack; //cards in this stack
144  CardStack dragstack; //cards which we might be dragging
145 
147 
148  int xpos; //coordinates of stack
149  int ypos;
150 
151  int xoffset; //direction that cards take
152  int yoffset;
153 
154  int width; //stack-size of all cards
155  int height;
156 
157  //
158  // justify / placement vars
159  int xjustify;
160  int yjustify;
161  int xadjust;
162  int yadjust;
163 
164  //
165  // Used for mouse-dragging / moving cards
166  //
170  int oldx;
171  int oldy;
172 
175 
180 
183  bool fVisible;
184 
188 
190 
195 
198 
199  //
200  // Stack callback support
201  //
202  pCanDragProc CanDragCallback;
209 
210  //locking mechanism to prevent user dragging etc
212 };
213 
214 #endif /* CARDREGION_INCLUDED */
pAddProc AddCallback
Definition: cardregion.h:207
Definition: bug.cpp:7
pClickProc DblClickCallback
Definition: cardregion.h:206
GLint GLint GLsizei width
Definition: gl.h:1546
void MoveDragCardTo(HDC hdc, int x, int y)
HDC hdcDragCard
Definition: cardregion.h:178
CardStack cardstack
Definition: cardregion.h:143
bool(CARDLIBPROC * pCanDropProc)(CardRegion &stackobj, CardStack &cards)
Definition: cardlib.h:86
void SetFaceDirection(UINT uDirType, int nOption)
Definition: cardregion.cpp:258
void(CARDLIBPROC * pClickProc)(CardRegion &stackobj, int iNumCards)
Definition: cardlib.h:87
int nThreedCount
Definition: cardregion.h:182
pRemoveProc RemoveCallback
Definition: cardregion.h:208
int nNumApparentCards
Definition: cardregion.h:181
bool IsPointInStack(int x, int y)
bool MoveCard(CardRegion *pDestStack, int nNumCards, bool fAnimate)
Definition: cardregion.cpp:477
const CardStack & GetCardStack()
Definition: cardregion.cpp:399
void SetClickReleaseProc(pClickProc proc)
Definition: cardregion.cpp:187
void StopFlash()
Definition: cardregion.cpp:333
GLuint GLuint GLsizei count
Definition: gl.h:1545
int GetNumDragCards(int x, int y)
static HDC
Definition: imagelist.c:92
void PrepareDragBitmapsThreed(int numtodrag)
void NewDeck()
Definition: cardregion.h:82
void Clear()
Definition: cardstack.cpp:37
bool OnLButtonUp(int x, int y)
void Push(const Card card)
Definition: cardstack.cpp:83
void SetPlacement(UINT xJustify, UINT yJustify, int xAdjust, int yAdjust)
Definition: cardregion.cpp:250
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
void Push(const CardStack &cs)
Definition: cardregion.h:89
pClickProc ClickReleaseCallback
Definition: cardregion.h:205
Card Top()
Definition: cardstack.cpp:151
Definition: dhcpd.h:245
bool SimulateDrag(CardRegion *pDestStack, int nNumCards, bool fAnimate)
Definition: cardregion.cpp:636
static HANDLE proc()
Definition: pdb.c:32
void Redraw()
Card Pop()
Definition: cardregion.h:91
HBITMAP hbmDragCard
Definition: cardregion.h:179
void Flash(int count, int timeout)
Definition: cardregion.cpp:322
CardRegion(CardWindow &parent, int id, bool fVisible, int x, int y, int xOffset, int yOffset)
Definition: cardregion.cpp:14
void SetDblClickProc(pClickProc proc)
Definition: cardregion.cpp:192
pCanDropProc CanDropCallback
Definition: cardregion.h:203
bool OnMouseMove(int x, int y)
void SetEmptyImage(UINT uImage)
Definition: cardregion.cpp:366
uint32_t cs
Definition: isohybrid.c:75
void NewDeck()
Definition: cardstack.cpp:42
bool fMouseDragging
Definition: cardregion.h:146
void UpdateFaceDir(CardStack &cards)
Definition: cardregion.cpp:409
bool UnLock()
Definition: cardregion.cpp:569
void Show(bool fShow)
Definition: cardregion.cpp:240
CardStack Top(int items)
Definition: cardregion.h:95
bool SetThreedCount(int count)
Definition: cardregion.cpp:215
void Update()
Definition: cardregion.cpp:207
void Reverse()
Definition: cardstack.cpp:73
int xjustify
Definition: cardregion.h:159
HANDLE mxlock
Definition: cardregion.h:211
int nDragCardHeight
Definition: cardregion.h:174
UINT uFlashTimer
Definition: cardregion.h:187
void Reverse()
Definition: cardregion.h:86
bool SetDragRule(UINT uDragType, pCanDragProc proc=0)
Definition: cardregion.cpp:146
int GetOverlapRatio(int x, int y, int width, int height)
Definition: cardregion.cpp:120
HDC hdcBackGnd
Definition: cardregion.h:176
int nNumCards
Definition: cardstack.h:48
bool OnLButtonDblClk(int x, int y)
void(CARDLIBPROC * pAddProc)(CardRegion &stackobj, const CardStack &cards)
Definition: cardlib.h:88
UINT uFaceDirType
Definition: cardregion.h:192
void UpdateSize()
Definition: cardregion.cpp:83
void CalcApparentCards()
Definition: cardregion.cpp:77
void SetPos(int x, int y)
Definition: cardregion.cpp:234
CardStack dragstack
Definition: cardregion.h:144
bool PlayCard(CardRegion *pDestStack, int value, int num)
Definition: cardregion.cpp:583
void Shuffle()
Definition: cardstack.cpp:50
r parent
Definition: btrfs.c:2659
bool OnLButtonDown(int x, int y)
DWORD COLORREF
Definition: windef.h:285
int yjustify
Definition: cardregion.h:160
int NumCards() const
Definition: cardregion.cpp:544
void RenderBottomMost(HDC hdc, int minustopmost=0)
Card Pop()
Definition: cardstack.cpp:127
GLuint GLuint num
Definition: glext.h:9618
int nBackCardIdx
Definition: cardregion.h:194
void ZoomCard(HDC hdc, int xpos, int ypos, CardRegion *dest)
bool CanDropCards(CardStack &cards)
int mousexoffset
Definition: cardregion.h:168
void SetClickProc(pClickProc proc)
Definition: cardregion.cpp:182
void RedrawIfNotDim(CardRegion *compare, bool fFullRedraw)
Definition: cardregion.cpp:611
UINT uDropRule
Definition: cardregion.h:197
void(CARDLIBPROC * pRemoveProc)(CardRegion &stackobj, int iNumRemoved)
Definition: cardlib.h:89
HDC hdc
Definition: main.c:9
CardStack Pop(int items)
Definition: cardregion.h:92
pClickProc ClickCallback
Definition: cardregion.h:204
void Render(HDC hdc)
UINT uDragRule
Definition: cardregion.h:196
bool fFlashVisible
Definition: cardregion.h:186
void SetCardStack(const CardStack &cs)
Definition: cardregion.cpp:390
COLORREF crBackgnd
Definition: cardregion.h:189
int nFaceDirOption
Definition: cardregion.h:193
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
void SetOffsets(int x, int y)
Definition: cardregion.cpp:228
void Clear()
Definition: cardregion.h:84
void Push(const Card card)
Definition: cardregion.h:88
Definition: card.h:27
int mouseyoffset
Definition: cardregion.h:169
bool IsVisible()
Definition: cardregion.cpp:245
void ReleaseDragBitmaps(void)
void Shuffle()
Definition: cardregion.h:83
void SetBackCardIdx(UINT uBackIdx)
Definition: cardregion.cpp:384
int nDragCardWidth
Definition: cardregion.h:173
void AdjustPosition(int winwidth, int winheight)
Definition: cardregion.cpp:281
int xOffset
Definition: appswitch.c:59
unsigned int UINT
Definition: ndis.h:50
int nFlashCount
Definition: cardregion.h:185
void DoFlash()
Definition: cardregion.cpp:344
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
void SetAddCardProc(pAddProc proc)
Definition: cardregion.cpp:197
pCanDragProc CanDragCallback
Definition: cardregion.h:202
void SetRemoveCardProc(pRemoveProc proc)
Definition: cardregion.cpp:202
void SetBackColor(COLORREF cr)
Definition: cardregion.cpp:67
bool SetDropRule(UINT uDropType, pCanDropProc proc=0)
Definition: cardregion.cpp:164
void ClickRelease(int x, int y)
UINT GetFaceDirection(int *pnOption)
Definition: cardregion.cpp:273
static char * dest
Definition: rtl.c:135
Card Top()
Definition: cardregion.h:94
static HBITMAP
Definition: button.c:44
int yOffset
Definition: appswitch.c:59
static TCHAR * items[]
Definition: page1.c:45
CardWindow & parentWnd
Definition: cardregion.h:141
UINT uEmptyImage
Definition: cardregion.h:191
HBITMAP hbmBackGnd
Definition: cardregion.h:177
bool fVisible
Definition: cardregion.h:183
bool Lock()
Definition: cardregion.cpp:552
void PrepareDragBitmaps(int numtodrag)
int iNumDragCards
Definition: cardregion.h:167
bool CanDragCards(int iNumCards)
void Clip(HDC hdc)
CardWindow & GetCardWindow()
Definition: cardregion.h:69