ReactOS 0.4.15-dev-7953-g1f49173
CardWindow Class Reference

#include <cardwindow.h>

Collaboration diagram for CardWindow:

Public Member Functions

 CardWindow ()
 
 ~CardWindow ()
 
BOOL Create (HWND hwndParent, DWORD dwExStyle, DWORD dwStyle, int x, int y, int width, int height)
 
BOOL Destroy ()
 
 operator HWND ()
 
CardButtonCreateButton (int id, TCHAR *szText, UINT uStyle, bool fVisible, int x, int y, int width, int height)
 
CardRegionCreateRegion (int id, bool fVisible, int x, int y, int xoffset, int yoffset)
 
CardButtonCardButtonFromId (int id)
 
CardRegionCardRegionFromId (int id)
 
bool DeleteButton (CardButton *pButton)
 
bool DeleteRegion (CardRegion *pRegion)
 
bool DeleteAll ()
 
void SetBackColor (COLORREF cr)
 
COLORREF GetBackColor ()
 
void SetBackCardIdx (UINT uBackIdx)
 
UINT GetBackCardIdx ()
 
void SetBackImage (HBITMAP hBitmap)
 
void EmptyStacks (void)
 
void Redraw (void)
 
void Update (void)
 
bool DistributeStacks (int nIdFrom, int nNumStacks, UINT xJustify, int xSpacing, int nStartX)
 
void SetResizeProc (pResizeWndProc proc)
 
int GetWidth ()
 
int GetHeight ()
 
bool RegisterDropZone (int id, RECT *rect, pDropZoneProc proc)
 
bool DeleteDropZone (int id)
 

Private Member Functions

int GetNumDropZones ()
 
DropZoneGetDropZoneFromRect (RECT *rect)
 
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
 
void Paint (HDC hdc)
 
void PaintCardRgn (HDC hdc, int dx, int dy, int width, int height, int sx, int sy)
 
HPALETTE CreateCardPalette ()
 
CardButtonCardButtonFromPoint (int x, int y)
 
CardRegionCardRegionFromPoint (int x, int y)
 
CardRegionGetBestStack (int x, int y, int w, int h)
 

Static Private Member Functions

static LRESULT CALLBACK CardWndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
 

Private Attributes

HWND m_hWnd
 
int nWidth
 
int nHeight
 
UINT nBackCardIdx
 
HBITMAP hbmBackImage
 
HDC hdcBackImage
 
CardButtonButtons [MAXBUTTONS]
 
int nNumButtons
 
CardRegionRegions [MAXCARDSTACKS]
 
int nNumCardRegions
 
DropZonedropzone [MAXDROPZONES]
 
int nNumDropZones
 
COLORREF crBackgnd
 
pResizeWndProc ResizeWndCallback
 

Friends

class CardRegion
 
class CardButton
 
void RegisterCardWindow ()
 

Detailed Description

Definition at line 13 of file cardwindow.h.

Constructor & Destructor Documentation

◆ CardWindow()

CardWindow::CardWindow ( )

Definition at line 63 of file cardwindow.cpp.

63 : m_hWnd(0)
64{
65 HDC hdc = GetDC(0);
66
67 nNumButtons = 0;
69 nNumDropZones = 0;
70 nBackCardIdx = 53;
71
73 hbmBackImage = 0;
74 hdcBackImage = 0;
75
76 srand((unsigned)GetTickCount());
77
78 //All colours (buttons, highlights, decks)
79 //are calculated off this single base colour
80 crBackgnd = PALETTERGB(0,80,0);//PALETTERGB(0,64,100);
81
82 // If uCardBitmapRef was previously zero, then
83 // load the card bitmaps
85 {
87
89
91
93
95
96 }
97
98 ReleaseDC(0, hdc);
99
100 //register the window class if necessary
101 if(!fRegistered)
102 {
103 fRegistered = true;
105 }
106
107}
#define InterlockedIncrement
Definition: armddk.h:53
void LoadCardBitmaps(void)
Definition: cardbitmaps.cpp:82
HBITMAP CreateSinkBmp(HDC hdcCompat, HDC hdc, COLORREF col, int width, int height)
HPALETTE UseNicePalette(HDC, HPALETTE)
Definition: cardwindow.cpp:14
int __cardwidth
Definition: cardlib.cpp:25
HPALETTE __hPalette
Definition: cardlib.cpp:28
HPALETTE __holdplacepal
Definition: cardlib.cpp:23
HBITMAP __hbmPlaceHolder
Definition: cardlib.cpp:22
HDC __hdcPlaceHolder
Definition: cardlib.cpp:21
int __cardheight
Definition: cardlib.cpp:26
static bool fRegistered
Definition: cardwindow.cpp:38
static LONG uCardBitmapRef
Definition: cardwindow.cpp:39
HPALETTE CreateCardPalette()
Definition: cardwindow.cpp:702
HDC hdcBackImage
Definition: cardwindow.h:97
UINT nBackCardIdx
Definition: cardwindow.h:94
COLORREF crBackgnd
Definition: cardwindow.h:109
pResizeWndProc ResizeWndCallback
Definition: cardwindow.h:111
int nNumDropZones
Definition: cardwindow.h:107
HBITMAP hbmBackImage
Definition: cardwindow.h:96
int nNumButtons
Definition: cardwindow.h:101
HWND m_hWnd
Definition: cardwindow.h:91
friend void RegisterCardWindow()
Definition: cardwindow.cpp:42
int nNumCardRegions
Definition: cardwindow.h:104
DWORD WINAPI GetTickCount(VOID)
Definition: time.c:455
void __cdecl srand(_In_ unsigned int _Seed)
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define PALETTERGB(r, g, b)
Definition: wingdi.h:2942
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HDC WINAPI GetDC(_In_opt_ HWND)

◆ ~CardWindow()

CardWindow::~CardWindow ( )

Definition at line 131 of file cardwindow.cpp.

132{
133 if(m_hWnd)
135
136 DeleteAll();
137
139 {
141
144
146
147 if(__hPalette)
149 }
150}
#define InterlockedDecrement
Definition: armddk.h:52
void FreeCardBitmaps()
void RestorePalette(HDC, HPALETTE)
bool DeleteAll()
Definition: cardwindow.cpp:152
pKey DeleteObject()
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI DestroyWindow(_In_ HWND)

Member Function Documentation

◆ CardButtonFromId()

CardButton * CardWindow::CardButtonFromId ( int  id)

Definition at line 542 of file cardwindow.cpp.

543{
544 for(int i = 0; i < nNumButtons; i++)
545 {
546 if(Buttons[i]->id == id)
547 return Buttons[i];
548 }
549
550 return 0;
551}
CardButton * Buttons[MAXBUTTONS]
Definition: cardwindow.h:100
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

◆ CardButtonFromPoint()

CardButton * CardWindow::CardButtonFromPoint ( int  x,
int  y 
)
private

Definition at line 229 of file cardwindow.cpp.

230{
231 CardButton *bptr = 0;
232
233 POINT pt;
234 pt.x = x;
235 pt.y = y;
236
237 //Search BACKWARDS...to reflect the implicit Z-order that
238 //the button creation provided
239 for(int i = nNumButtons - 1; i >= 0; i--)
240 {
241 bptr = Buttons[i];
242 if(PtInRect(&bptr->rect, pt) && bptr->fVisible)
243 return bptr;
244 }
245
246 return 0;
247}
RECT rect
Definition: cardbutton.h:70
bool fVisible
Definition: cardbutton.h:73
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)

Referenced by CardButton::OnLButtonUp(), and WndProc().

◆ CardRegionFromId()

CardRegion * CardWindow::CardRegionFromId ( int  id)

Definition at line 531 of file cardwindow.cpp.

532{
533 for(int i = 0; i < nNumCardRegions; i++)
534 {
535 if(Regions[i]->id == id)
536 return Regions[i];
537 }
538
539 return 0;
540}
CardRegion * Regions[MAXCARDSTACKS]
Definition: cardwindow.h:103

Referenced by CardRegion::OnLButtonUp().

◆ CardRegionFromPoint()

CardRegion * CardWindow::CardRegionFromPoint ( int  x,
int  y 
)
private

Definition at line 249 of file cardwindow.cpp.

250{
251 POINT pt;
252 pt.x = x;
253 pt.y = y;
254
255 //Search BACKWARDS...to reflect the implicit Z-order that
256 //the stack creation provided
257 for(int i = nNumCardRegions - 1; i >= 0; i--)
258 {
259 if(Regions[i]->IsPointInStack(x, y))
260 return Regions[i];
261 }
262
263 return 0;
264}

Referenced by WndProc().

◆ CardWndProc()

LRESULT CALLBACK CardWindow::CardWndProc ( HWND  hwnd,
UINT  iMsg,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 270 of file cardwindow.cpp.

271{
273 return cw->WndProc(hwnd, iMsg, wParam, lParam);
274}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: cardwindow.cpp:339
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define GetWindowLongPtr
Definition: treelist.c:73
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

◆ Create()

BOOL CardWindow::Create ( HWND  hwndParent,
DWORD  dwExStyle,
DWORD  dwStyle,
int  x,
int  y,
int  width,
int  height 
)

Definition at line 109 of file cardwindow.cpp.

110{
111 if(m_hWnd)
112 return FALSE;
113
114 //Create the window associated with this object
115 m_hWnd = CreateWindowEx(dwExStyle, szCardName, NULL,
116 dwStyle,
117 x, y, width, height,
119
120 return TRUE;
121}
static TCHAR szCardName[]
Definition: cardwindow.cpp:37
static HWND hwndParent
Definition: cryptui.c:300
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define GetModuleHandle
Definition: winbase.h:3827
#define CreateWindowEx
Definition: winuser.h:5755

Referenced by WndProc().

◆ CreateButton()

CardButton * CardWindow::CreateButton ( int  id,
TCHAR szText,
UINT  uStyle,
bool  fVisible,
int  x,
int  y,
int  width,
int  height 
)

Definition at line 334 of file cardbutton.cpp.

335{
336 CardButton *cb;
337
339 return 0;
340
341 cb = new CardButton(*this, id, szText, uStyle, fVisible, x, y, width, height);
343
344 if(uStyle & CB_PUSHBUTTON)
345 {
346 cb->SetBackColor(CardButton::GetFace(crBackgnd));
347 //cb->SetBackColor(ScaleLumRGB(crBackgnd, 0.1));
348 cb->SetForeColor(RGB(255,255,255));
349 }
350 else
351 {
352 cb->SetBackColor(crBackgnd);
353 cb->SetForeColor(RGB(255,255,255));
354 }
355
356 return cb;
357}
#define CB_PUSHBUTTON
Definition: cardlib.h:46
#define MAXBUTTONS
Definition: cardwindow.h:4
static COLORREF GetFace(COLORREF crBase)
Definition: cardbutton.cpp:426
friend class CardButton
Definition: cardwindow.h:16
#define RGB(r, g, b)
Definition: precomp.h:71
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33

◆ CreateCardPalette()

HPALETTE CardWindow::CreateCardPalette ( )
private

Definition at line 702 of file cardwindow.cpp.

703{
704 COLORREF cols[10];
705 int nNumCols;
706
707
708 //include button text colours
709 cols[0] = RGB(0, 0, 0);
710 cols[1] = RGB(255, 255, 255);
711
712 //include the base background colour
713 cols[2] = crBackgnd;
714
715 //include the standard button colours...
719
720 //include the sunken image bitmap colours...
721 GetSinkCols(crBackgnd, &cols[6], &cols[7], &cols[8], &cols[9]);
722
723 nNumCols = 10;
724
725 return MakePaletteFromCols(cols, nNumCols);
726}
HPALETTE MakePaletteFromCols(COLORREF cols[], int nNumColours)
void GetSinkCols(COLORREF crBase, COLORREF *fg, COLORREF *bg, COLORREF *sh1, COLORREF *sh2)
static COLORREF GetHighlight(COLORREF crBase)
Definition: cardbutton.cpp:415
static COLORREF GetShadow(COLORREF crBase)
Definition: cardbutton.cpp:421
DWORD COLORREF
Definition: windef.h:300

Referenced by CardWindow(), and SetBackColor().

◆ CreateRegion()

CardRegion * CardWindow::CreateRegion ( int  id,
bool  fVisible,
int  x,
int  y,
int  xoffset,
int  yoffset 
)

Definition at line 104 of file cardregion.cpp.

105{
106 CardRegion *cr;
107
109 return FALSE;
110
111 cr = new CardRegion(*this, id, fVisible, x, y, xoffset, yoffset);
114
115 Regions[nNumCardRegions++] = cr;
116
117 return cr;
118}
#define MAXCARDSTACKS
Definition: cardwindow.h:5
void SetBackColor(COLORREF cr)
Definition: cardregion.cpp:67
void SetBackCardIdx(UINT uBackIdx)
Definition: cardregion.cpp:384
friend class CardRegion
Definition: cardwindow.h:15
GLint GLint xoffset
Definition: gl.h:1547
GLint GLint GLint yoffset
Definition: gl.h:1547

Referenced by CreateSol(), and CreateSpider().

◆ DeleteAll()

bool CardWindow::DeleteAll ( )

Definition at line 152 of file cardwindow.cpp.

153{
154 int i;
155
156 for(i = 0; i < nNumCardRegions; i++)
157 {
158 delete Regions[i];
159 }
160
161 for(i = 0; i < nNumButtons; i++)
162 {
163 delete Buttons[i];
164 }
165
166 for(i = 0; i < nNumDropZones; i++)
167 {
168 delete dropzone[i];
169 }
170
172
173 return true;
174}
DropZone * dropzone[MAXDROPZONES]
Definition: cardwindow.h:106

Referenced by ~CardWindow().

◆ DeleteButton()

bool CardWindow::DeleteButton ( CardButton pButton)

Definition at line 559 of file cardwindow.cpp.

560{
561 for(int i = 0; i < nNumButtons; i++)
562 {
563 if(Buttons[i] == pButton)
564 {
566
567 //shift any after this one backwards
568 for(int j = i; j < nNumButtons - 1; j++)
569 {
570 Buttons[j] = Buttons[j + 1];
571 }
572
573 delete cb;
574 nNumButtons--;
575
576 return true;
577 }
578 }
579
580 return false;
581}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250

◆ DeleteDropZone()

bool CardWindow::DeleteDropZone ( int  id)

Definition at line 44 of file dropzone.cpp.

45{
46 for(int i = 0; i < nNumDropZones; i++)
47 {
48 if(dropzone[i]->id == id)
49 {
50 DropZone *dz = dropzone[i];
51
52 //shift any after this one backwards
53 for(int j = i; j < nNumDropZones - 1; j++)
54 {
55 dropzone[j] = dropzone[j + 1];
56 }
57
58 delete dz;
60 return true;
61 }
62 }
63
64 return false;
65}

◆ DeleteRegion()

bool CardWindow::DeleteRegion ( CardRegion pRegion)

Definition at line 583 of file cardwindow.cpp.

584{
585 for(int i = 0; i < nNumCardRegions; i++)
586 {
587 if(Regions[i] == pRegion)
588 {
589 CardRegion *cr = Regions[i];
590
591 //shift any after this one backwards
592 for(int j = i; j < nNumCardRegions - 1; j++)
593 {
594 Regions[j] = Regions[j + 1];
595 }
596
597 delete cr;
599
600 return true;
601 }
602 }
603
604 return false;
605}

◆ Destroy()

BOOL CardWindow::Destroy ( )

Definition at line 123 of file cardwindow.cpp.

124{
126 m_hWnd = 0;
127
128 return TRUE;
129}

◆ DistributeStacks()

bool CardWindow::DistributeStacks ( int  nIdFrom,
int  nNumStacks,
UINT  xJustify,
int  xSpacing,
int  nStartX 
)

Definition at line 618 of file cardwindow.cpp.

619{
620 int numvisiblestacks = 0;
621 int curx = nStartX;
622 int startindex = -1;
623 int i;
624
625 //find the stack which starts with our ID
626 for(i = 0; i < nNumCardRegions; i++)
627 {
628 if(Regions[i]->Id() == nIdFrom)
629 {
630 startindex = i;
631 break;
632 }
633 }
634
635 //if didn't find, return
636 if(i == nNumCardRegions) return false;
637
638 //count the stacks that are visible
639 for(i = startindex; i < startindex + nNumStacks; i++)
640 {
641 if(Regions[i]->IsVisible())
642 numvisiblestacks++;
643 }
644
645 if(xJustify == CS_XJUST_CENTER)
646 {
647 //startx -= ((numvisiblestacks + spacing) * cardwidth - spacing) / 2;
648 int viswidth;
649 viswidth = numvisiblestacks * __cardwidth;
650 viswidth += xSpacing * (numvisiblestacks - 1);
651 curx = -(viswidth - __cardwidth) / 2;
652
653 for(i = startindex; i < startindex + nNumStacks; i++)
654 {
655 if(Regions[i]->IsVisible())
656 {
657 Regions[i]->xadjust = curx;
659 curx += Regions[i]->width + xSpacing;
660 }
661
662 }
663 }
664
665 if(xJustify == CS_XJUST_RIGHT)
666 {
667 nStartX -= ((numvisiblestacks + xSpacing) * __cardwidth - xSpacing);
668 }
669
670 if(xJustify == CS_XJUST_NONE)
671 {
672 for(i = startindex; i < startindex + nNumStacks; i++)
673 {
674 if(Regions[i]->IsVisible())
675 {
676 Regions[i]->xpos = curx;
677 curx += Regions[i]->width + xSpacing;
678 Regions[i]->UpdateSize();
679 }
680
681 }
682 }
683
684 return 0;
685}
DWORD Id
#define CS_XJUST_CENTER
Definition: cardlib.h:39
#define CS_XJUST_RIGHT
Definition: cardlib.h:38
#define CS_XJUST_NONE
Definition: cardlib.h:37
void UpdateSize()
Definition: cardregion.cpp:83
int xjustify
Definition: cardregion.h:159

◆ EmptyStacks()

void CardWindow::EmptyStacks ( void  )

Definition at line 607 of file cardwindow.cpp.

608{
609 for(int i = 0; i < nNumCardRegions; i++)
610 {
611 Regions[i]->Clear();
612 Regions[i]->Update();
613 }
614
615 Redraw();
616}
void Update()
Definition: cardregion.cpp:207
void Clear()
Definition: cardregion.h:84
void Redraw(void)
Definition: cardwindow.cpp:553

Referenced by GameFinished(), NewGame(), and SuitStackAddProc().

◆ GetBackCardIdx()

UINT CardWindow::GetBackCardIdx ( )

Definition at line 738 of file cardwindow.cpp.

739{
740 return nBackCardIdx;
741}

Referenced by SaveSettings().

◆ GetBackColor()

COLORREF CardWindow::GetBackColor ( )

Definition at line 224 of file cardwindow.cpp.

225{
226 return crBackgnd;
227}

◆ GetBestStack()

CardRegion * CardWindow::GetBestStack ( int  x,
int  y,
int  w,
int  h 
)
private

Definition at line 34 of file cardrgnmouse.cpp.

35{
36 int maxoverlap = 0;
37 int maxoverlapidx = -1;
38
39 //find the stack which is most covered by the dropped
40 //cards. Only include those which allow drops.
41 //
42 for(int i = 0; i < nNumCardRegions; i++)
43 {
44 int percent = Regions[i]->GetOverlapRatio(x, y, w, h);
45
46 //if this stack has the biggest coverage yet
47 if(percent > maxoverlap && Regions[i]->IsVisible())
48 {
49 maxoverlap = percent;
50 maxoverlapidx = i;
51 }
52 }
53
54 //if we found a stack to drop onto
55 if(maxoverlapidx != -1)
56 {
57 return Regions[maxoverlapidx];
58 }
59 else
60 {
61 return 0;
62 }
63}
int GetOverlapRatio(int x, int y, int width, int height)
Definition: cardregion.cpp:120
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723

Referenced by CardRegion::OnLButtonUp().

◆ GetDropZoneFromRect()

DropZone * CardWindow::GetDropZoneFromRect ( RECT rect)
private

Definition at line 22 of file dropzone.cpp.

23{
24 for(int i = 0; i < nNumDropZones; i++)
25 {
26 RECT inter;
27 RECT zone;
28
29 //if any part of the drag rectangle falls within a drop zone,
30 //let that take priority over any other card stack.
32
33 if(IntersectRect(&inter, rect, &zone))
34 {
35 //see if the callback wants us to drop a card on
36 //a particular stack
37 return dropzone[i];
38 }
39 }
40
41 return 0;
42}
void GetZone(RECT *rect)
Definition: dropzone.h:21
DWORD zone
Definition: sec_mgr.c:1754
& rect
Definition: startmenu.cpp:1413
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)

Referenced by CardRegion::OnLButtonUp().

◆ GetHeight()

int CardWindow::GetHeight ( )
inline

Definition at line 56 of file cardwindow.h.

56{ return nHeight; }
int nHeight
Definition: cardwindow.h:92

◆ GetNumDropZones()

int CardWindow::GetNumDropZones ( )
inlineprivate

Definition at line 66 of file cardwindow.h.

66{ return nNumDropZones; }

◆ GetWidth()

int CardWindow::GetWidth ( )
inline

Definition at line 55 of file cardwindow.h.

55{ return nWidth; }
int nWidth
Definition: cardwindow.h:92

◆ operator HWND()

CardWindow::operator HWND ( )
inline

Definition at line 31 of file cardwindow.h.

31{ return m_hWnd; }

◆ Paint()

void CardWindow::Paint ( HDC  hdc)
private

Definition at line 276 of file cardwindow.cpp.

277{
278 int i;
279 RECT rect;
280 HPALETTE hOldPal;
281
282 hOldPal = UseNicePalette(hdc, __hPalette);
283
284 //
285 // Clip the card stacks so that they won't
286 // get painted over
287 //
288 for(i = 0; i < nNumCardRegions; i++)
289 {
290 Regions[i]->Clip(hdc);
291 }
292
293 //
294 // Clip the buttons
295 //
296 for(i = 0; i < nNumButtons; i++)
297 {
298 Buttons[i]->Clip(hdc);
299 }
300
301
302 // Now paint the whole screen with background colour,
303 //
305
306 //PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));
307 PaintCardRgn(hdc, 0, 0, rect.right, rect.bottom, 0, 0);
309
310 // Don't let cards draw over buttons, so clip buttons again
311 //
312 for(i = 0; i < nNumButtons; i++)
313 {
314 Buttons[i]->Clip(hdc);
315 }
316
317 // Paint each card stack in turn
318 //
319 for(i = 0; i < nNumCardRegions; i++)
320 {
321 Regions[i]->Render(hdc);
322 }
323
324 // Paint each button now
325 //
327
328 for(i = 0; i < nNumButtons; i++)
329 {
330 Buttons[i]->Redraw();
331 }
332
333 RestorePalette(hdc, hOldPal);
334}
void Redraw()
Definition: cardbutton.cpp:385
void Clip(HDC hdc)
Definition: cardbutton.cpp:102
void Clip(HDC hdc)
void Render(HDC hdc)
void PaintCardRgn(HDC hdc, int dx, int dy, int width, int height, int sx, int sy)
Definition: cardwindow.cpp:743
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)

Referenced by WndProc().

◆ PaintCardRgn()

void CardWindow::PaintCardRgn ( HDC  hdc,
int  dx,
int  dy,
int  width,
int  height,
int  sx,
int  sy 
)
private

Definition at line 743 of file cardwindow.cpp.

744{
745 RECT rect;
746
747 //if just a solid background colour
748 if(hbmBackImage == 0)
749 {
751
752 /*if(GetVersion() < 0x80000000)
753 {
754 PaintRect(hdc, &rect, MAKE_PALETTERGB(crBackgnd));
755 }
756 else*/
757 {
759 FillRect(hdc, &rect, hbr);
760 DeleteObject(hbr);
761 }
762 }
763 //otherwise, paint using the bitmap
764 else
765 {
766 // Draw whatever part of background we can
768
769 // Now we need to paint any area outside the bitmap,
770 // just in case the bitmap is too small to fill whole window
771 if(0)//sx + width > bm.bmWidth || sy + height > bm.bmHeight)
772 {
773 // Find out size of bitmap
774 BITMAP bm;
775 GetObject(hbmBackImage, sizeof(bm), &bm);
776
777 HRGN hr1 = CreateRectRgn(sx, sy, sx+width, sy+height);
778 HRGN hr2 = CreateRectRgn(0, 0, bm.bmWidth, bm.bmHeight);
779 HRGN hr3 = CreateRectRgn(0,0, 1, 1);
780 HRGN hr4 = CreateRectRgn(0,0, 1, 1);
781
782 CombineRgn(hr3, hr1, hr2, RGN_DIFF);
783
784 GetClipRgn(hdc, hr4);
785
786 CombineRgn(hr3, hr4, hr3, RGN_AND);
787 SelectClipRgn(hdc, hr3);
788
789 // Fill remaining space not filled with bitmap
790 HBRUSH hbr = CreateSolidBrush(crBackgnd);
791 FillRgn(hdc, hr3, hbr);
792 DeleteObject(hbr);
793
794 // Clean up
795 SelectClipRgn(hdc, hr4);
796
797 DeleteObject(hr1);
798 DeleteObject(hr2);
799 DeleteObject(hr3);
800 DeleteObject(hr4);
801 }
802 }
803}
#define MAKE_PALETTERGB(colref)
Definition: cardcolor.h:17
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97
Definition: bl.h:1331
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define RGN_DIFF
Definition: wingdi.h:358
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define RGN_AND
Definition: wingdi.h:356
#define SRCCOPY
Definition: wingdi.h:333
int WINAPI FillRgn(_In_ HDC, _In_ HRGN, _In_ HBRUSH)
Definition: painting.c:183
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define GetObject
Definition: wingdi.h:4468
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by Paint(), CardRegion::PrepareDragBitmaps(), CardRegion::PrepareDragBitmapsThreed(), and CardRegion::Render().

◆ Redraw()

void CardWindow::Redraw ( void  )

Definition at line 553 of file cardwindow.cpp.

554{
555 InvalidateRect(m_hWnd, 0, 0);
557}
BOOL WINAPI UpdateWindow(_In_ HWND)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)

Referenced by DeckClickProc(), CardRegion::DoFlash(), EmptyStacks(), CardRegion::Flash(), NewGame(), CardRegion::RedrawIfNotDim(), ShowDeckOptionsDlg(), and Undo().

◆ RegisterDropZone()

bool CardWindow::RegisterDropZone ( int  id,
RECT rect,
pDropZoneProc  proc 
)

Definition at line 10 of file dropzone.cpp.

11{
13 return false;
14
15 DropZone *dz = new DropZone(id, rect, proc);
16
17 dropzone[nNumDropZones++] = dz;
18
19 return false;
20}
#define MAXDROPZONES
Definition: cardwindow.h:6
static HANDLE proc()
Definition: pdb.c:34

◆ SetBackCardIdx()

void CardWindow::SetBackCardIdx ( UINT  uBackIdx)

Definition at line 728 of file cardwindow.cpp.

729{
730 if(uBackIdx >= 52 && uBackIdx <= 68)
731 nBackCardIdx = uBackIdx;
732
733 for(int i = 0; i < nNumCardRegions; i++)
734 Regions[i]->SetBackCardIdx(uBackIdx);
735
736}
void SetBackCardIdx(UINT uBackIdx)
Definition: cardwindow.cpp:728

Referenced by LoadSettings(), SetBackCardIdx(), and ShowDeckOptionsDlg().

◆ SetBackColor()

void CardWindow::SetBackColor ( COLORREF  cr)

Definition at line 176 of file cardwindow.cpp.

177{
178 crBackgnd = cr;
179 int i;
180
181 //
182 // Create the exact palette we need to render the buttons/stacks
183 //
185
186 if(__hPalette)
188
190
191 //
192 // re-create the place-holder!
193 HDC hdc = GetDC(m_hWnd);
194
196
198
200 //SelectObject(__hdcPlaceHolder, __hbmPlaceHolder);
201
202 //reset all buttons to same colour
203 for(i = 0; i < nNumButtons; i++)
204 {
205 if(Buttons[i]->GetStyle() & CB_PUSHBUTTON)
206 {
207 Buttons[i]->SetBackColor(ColorScaleRGB(crBackgnd, RGB(255,255,255), 0.1));
208 }
209 else
210 {
212 }
213 }
214
215 for(i = 0; i < nNumCardRegions; i++)
216 {
218 }
219
220
222}
COLORREF ColorScaleRGB(const COLORREF Col1, const COLORREF Col2, const double Ratio)
Definition: cardcolor.cpp:154
void SetBackColor(COLORREF cr)
Definition: cardbutton.cpp:403

◆ SetBackImage()

void CardWindow::SetBackImage ( HBITMAP  hBitmap)

Definition at line 805 of file cardwindow.cpp.

806{
807 //delete current image?? NO!
808 if(hdcBackImage == 0)
809 {
811 }
812
814
815 if(hBitmap)
817}
static HBITMAP hBitmap
Definition: timezone.c:26
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539

◆ SetResizeProc()

void CardWindow::SetResizeProc ( pResizeWndProc  proc)

Definition at line 696 of file cardwindow.cpp.

697{
699}

◆ Update()

void CardWindow::Update ( void  )

Definition at line 687 of file cardwindow.cpp.

688{
689 for(int i = 0; i < nNumCardRegions; i++)
690 {
692 }
693}
void AdjustPosition(int winwidth, int winheight)
Definition: cardregion.cpp:281

◆ WndProc()

LRESULT CALLBACK CardWindow::WndProc ( HWND  hwnd,
UINT  iMsg,
WPARAM  wParam,
LPARAM  lParam 
)
private

Definition at line 339 of file cardwindow.cpp.

340{
341 HDC hdc;
342 PAINTSTRUCT ps;
343
345
346 static CardButton *buttonptr = 0;
347 static CardRegion *stackptr = 0;
348
349 int x, y, i;
350
351 switch(iMsg)
352 {
353 case WM_NCCREATE:
354
355 // When we created this window, we passed in the
356 // pointer to the class object (CardWindow *) in the
357 // call to CreateWindow.
359
360 //
361 // associate this class with the window
362 //
363 SetWindowLongPtr(hwnd, 0, (LONG_PTR)cs->lpCreateParams);
364
365 return 1;
366
367 case WM_NCDESTROY:
368 // Don't delete anything here..
369 break;
370
371 case WM_SIZE:
374
375 //
376 // reposition all the stacks and buttons
377 // in case any of them are centered, right-justified etc
378 //
379 for(i = 0; i < nNumCardRegions; i++)
380 {
382 }
383
384 for(i = 0; i < nNumButtons; i++)
385 {
387 }
388
389 //
390 // Call the user-defined resize proc AFTER all the stacks
391 // have been positioned
392 //
395
396 return 0;
397
398 case WM_PAINT:
399
400 hdc = BeginPaint(hwnd, &ps);
401
402 Paint(hdc);
403
404 EndPaint(hwnd, &ps);
405 return 0;
406
407 case WM_TIMER:
408
409 //find the timer object in the registered funcs
410 /*if(wParam >= 0x10000)
411 {
412 for(i = 0; i < nRegFuncs; i++)
413 {
414 if(RegFuncs[i].id == wParam)
415 {
416 KillTimer(hwnd, wParam);
417
418 //call the registered function!!
419 RegFuncs[i].func(RegFuncs[i].dwParam);
420
421 RegFuncs[i] = RegFuncs[nRegFuncs-1];
422 nRegFuncs--;
423 }
424 }
425 }
426 else*/
427 {
428 //find the cardstack
429 CardRegion *stackobj = (CardRegion *)wParam;//CardStackFromId(wParam);
430 stackobj->DoFlash();
431 }
432
433 return 0;
434
435 case WM_LBUTTONDBLCLK:
436
437 x = (short)LOWORD(lParam);
438 y = (short)HIWORD(lParam);
439
440 if((buttonptr = CardButtonFromPoint(x, y)) != 0)
441 {
442 buttonptr->OnLButtonDown(hwnd, x, y);
443 return 0;
444 }
445
446 if((stackptr = CardRegionFromPoint(x, y)) != 0)
447 {
448 stackptr->OnLButtonDblClk(x, y);
449 stackptr = 0;
450 }
451
452 return 0;
453
454 case WM_LBUTTONDOWN:
455
456 x = (short)LOWORD(lParam);
457 y = (short)HIWORD(lParam);
458
459 //if clicked on a button
460 if((buttonptr = CardButtonFromPoint(x, y)) != 0)
461 {
462 if(buttonptr->OnLButtonDown(hwnd, x, y) == 0)
463 buttonptr = 0;
464
465 return 0;
466 }
467
468 if((stackptr = CardRegionFromPoint(x, y)) != 0)
469 {
470 if(!stackptr->OnLButtonDown(x, y))
471 stackptr = 0;
472 }
473
474 return 0;
475
476 case WM_LBUTTONUP:
477
478 x = (short)LOWORD(lParam);
479 y = (short)HIWORD(lParam);
480
481 //
482 // if we were clicking a button
483 //
484 if(buttonptr != 0)
485 {
486 buttonptr->OnLButtonUp(hwnd, x, y);
487 buttonptr = 0;
488 return 0;
489 }
490
491 if(stackptr != 0)
492 {
493 stackptr->OnLButtonUp(x, y);
494 stackptr = 0;
495 return 0;
496 }
497
498 if ((stackptr = CardRegionFromPoint(x, y)) != 0)
499 {
500 stackptr->ClickRelease(x, y);
501 stackptr = 0;
502 }
503
504 return 0;
505
506 case WM_MOUSEMOVE:
507
508 x = (short)LOWORD(lParam);
509 y = (short)HIWORD(lParam);
510
511 // if we were clicking a button
512 if(buttonptr != 0)
513 {
514 buttonptr->OnMouseMove(hwnd, x, y);
515 return 0;
516 }
517
518 if(stackptr != 0)
519 {
520 return stackptr->OnMouseMove(x, y);
521 }
522
523 return 0;
524
525 }
526
527 return DefWindowProc (hwnd, iMsg, wParam, lParam);
528}
int OnMouseMove(HWND hwnd, int x, int y)
Definition: cardbutton.cpp:278
int OnLButtonUp(HWND hwnd, int x, int y)
Definition: cardbutton.cpp:301
void AdjustPosition(int winwidth, int winheight)
Definition: cardbutton.cpp:208
int OnLButtonDown(HWND hwnd, int x, int y)
Definition: cardbutton.cpp:253
void DoFlash()
Definition: cardregion.cpp:344
void ClickRelease(int x, int y)
bool OnLButtonDblClk(int x, int y)
bool OnMouseMove(int x, int y)
bool OnLButtonUp(int x, int y)
bool OnLButtonDown(int x, int y)
void Paint(HDC hdc)
Definition: cardwindow.cpp:276
CardButton * CardButtonFromPoint(int x, int y)
Definition: cardwindow.cpp:229
CardRegion * CardRegionFromPoint(int x, int y)
Definition: cardwindow.cpp:249
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define cs
Definition: i386-dis.c:442
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define LOWORD(l)
Definition: pedump.c:82
#define DefWindowProc
Definition: ros2win.h:31
#define SetWindowLongPtr
Definition: treelist.c:70
#define HIWORD(l)
Definition: typedefs.h:247
#define WM_PAINT
Definition: winuser.h:1620
#define WM_SIZE
Definition: winuser.h:1611
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1778
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define WM_LBUTTONDOWN
Definition: winuser.h:1776
#define WM_NCCREATE
Definition: winuser.h:1683
#define WM_TIMER
Definition: winuser.h:1742
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define WM_NCDESTROY
Definition: winuser.h:1684
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by CardWndProc().

Friends And Related Function Documentation

◆ CardButton

friend class CardButton
friend

Definition at line 16 of file cardwindow.h.

Referenced by CreateButton().

◆ CardRegion

friend class CardRegion
friend

Definition at line 15 of file cardwindow.h.

Referenced by CreateRegion().

◆ RegisterCardWindow

void RegisterCardWindow ( )
friend

Definition at line 42 of file cardwindow.cpp.

43{
44 WNDCLASSEX wc;
45
46 //Window class for the main application parent window
47 wc.cbSize = sizeof(wc);
50 wc.cbClsExtra = 0;
51 wc.cbWndExtra = sizeof(CardWindow *);
53 wc.hIcon = 0;
55 wc.hbrBackground = 0;
56 wc.lpszMenuName = 0;
58 wc.hIconSm = 0;
59
60 RegisterClassEx(&wc);
61}
static LRESULT CALLBACK CardWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: cardwindow.cpp:270
int cbClsExtra
Definition: winuser.h:3204
HINSTANCE hInstance
Definition: winuser.h:3206
HCURSOR hCursor
Definition: winuser.h:3208
LPCSTR lpszMenuName
Definition: winuser.h:3210
HICON hIconSm
Definition: winuser.h:3212
UINT style
Definition: winuser.h:3202
int cbWndExtra
Definition: winuser.h:3205
UINT cbSize
Definition: winuser.h:3201
WNDPROC lpfnWndProc
Definition: winuser.h:3203
LPCSTR lpszClassName
Definition: winuser.h:3211
HICON hIcon
Definition: winuser.h:3207
HBRUSH hbrBackground
Definition: winuser.h:3209
#define CS_VREDRAW
Definition: winuser.h:658
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define CS_DBLCLKS
Definition: winuser.h:651
#define RegisterClassEx
Definition: winuser.h:5837
#define LoadCursor
Definition: winuser.h:5812

Referenced by CardWindow().

Member Data Documentation

◆ Buttons

CardButton* CardWindow::Buttons[MAXBUTTONS]
private

◆ crBackgnd

COLORREF CardWindow::crBackgnd
private

◆ dropzone

DropZone* CardWindow::dropzone[MAXDROPZONES]
private

Definition at line 106 of file cardwindow.h.

Referenced by DeleteAll(), DeleteDropZone(), GetDropZoneFromRect(), and RegisterDropZone().

◆ hbmBackImage

HBITMAP CardWindow::hbmBackImage
private

Definition at line 96 of file cardwindow.h.

Referenced by CardWindow(), PaintCardRgn(), and SetBackImage().

◆ hdcBackImage

HDC CardWindow::hdcBackImage
private

Definition at line 97 of file cardwindow.h.

Referenced by CardWindow(), PaintCardRgn(), and SetBackImage().

◆ m_hWnd

HWND CardWindow::m_hWnd
private

Definition at line 91 of file cardwindow.h.

Referenced by Create(), Destroy(), operator HWND(), Paint(), Redraw(), SetBackColor(), and ~CardWindow().

◆ nBackCardIdx

UINT CardWindow::nBackCardIdx
private

Definition at line 94 of file cardwindow.h.

Referenced by CardWindow(), CreateRegion(), GetBackCardIdx(), and SetBackCardIdx().

◆ nHeight

int CardWindow::nHeight
private

Definition at line 92 of file cardwindow.h.

Referenced by GetHeight(), Update(), and WndProc().

◆ nNumButtons

int CardWindow::nNumButtons
private

◆ nNumCardRegions

◆ nNumDropZones

int CardWindow::nNumDropZones
private

◆ nWidth

int CardWindow::nWidth
private

Definition at line 92 of file cardwindow.h.

Referenced by GetWidth(), Update(), and WndProc().

◆ Regions

◆ ResizeWndCallback

pResizeWndProc CardWindow::ResizeWndCallback
private

Definition at line 111 of file cardwindow.h.

Referenced by CardWindow(), SetResizeProc(), and WndProc().


The documentation for this class was generated from the following files: