Commit 7e8732c8 authored by Sami Nopanen's avatar Sami Nopanen Committed by Alexandre Julliard

- Enumerated different drawing modes.

- Implemented HILITE, REMOVE and GHOST drawing modes.
parent bb86eb65
...@@ -76,46 +76,79 @@ BOOL WINAPI cdtInit(int *width, int *height) ...@@ -76,46 +76,79 @@ BOOL WINAPI cdtInit(int *width, int *height)
/*********************************************************************** /***********************************************************************
* Draw a card. Unlike cdtDrawCard, this version allows you to stretch * Draw a card. Unlike cdtDrawCard, this version allows you to stretch
* card bitmaps to the size you specify (dx, dy). See cdtDraw for info * card bitmaps to the size you specify (dx, dy). See cdtDraw for info
* on card, type and color parameters. * on card, mode and color parameters.
*/ */
BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int card, int type, DWORD color) BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int card, int mode, DWORD color)
{ {
HDC hMemoryDC; HDC hMemoryDC;
HBITMAP hCardBitmap; HBITMAP hCardBitmap;
HGDIOBJ result; HGDIOBJ result;
DWORD rasterOp = SRCCOPY;
TRACE("(%p, %d, %d, %d, %d, %d, %d, %ld)\n", hdc, x, y, dx, dy, card, type, color); TRACE("(%p, %d, %d, %d, %d, %d, %d, %ld)\n", hdc, x, y, dx, dy, card, mode, color);
if((card < 0) || (card > CARD_MAX)) if((card < 0) || (card > CARD_MAX))
{ {
FIXME("Unexpected card: %d\n", card); FIXME("Unexpected card: %d\n", card);
return 0; return FALSE;
} }
if((type < 0) || (type > 2)) if((mode < MODE_FACEUP) || (mode > MODE_DECKO))
FIXME("Unexpected type: %d\n", type); {
FIXME("Unexpected mode: %d\n", mode);
return FALSE;
}
hCardBitmap = cardBitmaps[card]; if(mode == MODE_INVISIBLEGHOST || mode == MODE_DECKX || mode == MODE_DECKO)
if(hCardBitmap == 0) {
FIXME("Mode %d not implemented.\n", mode);
return FALSE; return FALSE;
}
hMemoryDC = CreateCompatibleDC(hdc); hMemoryDC = CreateCompatibleDC(hdc);
if(hMemoryDC == 0) if(hMemoryDC == 0)
return FALSE; return FALSE;
result = SelectObject(hMemoryDC, hCardBitmap); if((mode == MODE_REMOVE) || (mode == MODE_GHOST))
if((result == 0) || (result == HGDI_ERROR))
{ {
DeleteDC(hMemoryDC); HBRUSH hBrush;
return FALSE; RECT rect;
hBrush = CreateSolidBrush(color);
rect.left = x;
rect.top = y;
rect.right = x + cardWidth - 1;
rect.bottom = y + cardHeight - 1;
FillRect(hdc, &rect, hBrush);
if(mode == MODE_GHOST)
{
hBrush = CreateSolidBrush(RGB(255, 255, 255));
FrameRect(hdc, &rect, hBrush);
}
} }
else /* MODE_FACEUP, MODE_FACEDOWN, MODE_HILITE */
{
if(mode == MODE_HILITE)
rasterOp = NOTSRCCOPY;
hCardBitmap = cardBitmaps[card];
if(hCardBitmap == 0)
return FALSE;
result = SelectObject(hMemoryDC, hCardBitmap);
if((result == 0) || (result == HGDI_ERROR))
{
DeleteDC(hMemoryDC);
return FALSE;
}
SetBkColor(hdc, color); SetBkColor(hdc, color);
if((cardWidth == dx) && (cardHeight == dy)) if((cardWidth == dx) && (cardHeight == dy))
BitBlt(hdc, x, y, cardWidth, cardHeight, hMemoryDC, 0, 0, SRCCOPY); BitBlt(hdc, x, y, cardWidth, cardHeight, hMemoryDC, 0, 0, rasterOp);
else else
StretchBlt(hdc, x, y, dx, dy, hMemoryDC, 0, 0, cardWidth, cardHeight, SRCCOPY); StretchBlt(hdc, x, y, dx, dy, hMemoryDC, 0, 0, cardWidth, cardHeight, rasterOp);
}
DeleteDC(hMemoryDC); DeleteDC(hMemoryDC);
...@@ -127,8 +160,15 @@ BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int card, int type ...@@ -127,8 +160,15 @@ BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int card, int type
* Draws a card at position x, y in its default size (as returned by * Draws a card at position x, y in its default size (as returned by
* cdtInit. * cdtInit.
* *
* Type parameter controls whether the front (0), back (1), or inverted * Mode controls how the card gets drawn:
* front (2) of the card is to be drawn. * MODE_FACEUP ; draw card facing up
* MODE_FACEDOWN ; draw card facing down
* MODE_HILITE ; draw face up, with NOTSRCCOPY
* MODE_GHOST ; draw 'ghost' card
* MODE_REMOVE ; draw with background color
* MODE_INVISIBLEGHOST ; ?
* MODE_DECKX ; draw X
* MODE_DECKO ; draw O
* *
* The card parameter defines the card graphic to be drawn. If we are * The card parameter defines the card graphic to be drawn. If we are
* drawing fronts of cards, card should have a value from 0 through 51 * drawing fronts of cards, card should have a value from 0 through 51
...@@ -143,11 +183,11 @@ BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int card, int type ...@@ -143,11 +183,11 @@ BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int card, int type
* Color parameter defines the background color, used when drawing some * Color parameter defines the background color, used when drawing some
* card backs. * card backs.
*/ */
BOOL WINAPI cdtDraw(HDC hdc, int x, int y, int card, int type, DWORD color) BOOL WINAPI cdtDraw(HDC hdc, int x, int y, int card, int mode, DWORD color)
{ {
TRACE("(%p, %d, %d, %d, %d, %ld)\n", hdc, x, y, card, type, color); TRACE("(%p, %d, %d, %d, %d, %ld)\n", hdc, x, y, card, mode, color);
return cdtDrawExt(hdc, x, y, cardWidth, cardHeight, card, type, color); return cdtDrawExt(hdc, x, y, cardWidth, cardHeight, card, mode, color);
} }
......
...@@ -51,6 +51,15 @@ ...@@ -51,6 +51,15 @@
#define CARD_MAX 68 #define CARD_MAX 68
/* Drawing modes */
#define MODE_FACEUP 0
#define MODE_FACEDOWN 1
#define MODE_HILITE 2
#define MODE_GHOST 3
#define MODE_REMOVE 4
#define MODE_INVISIBLEGHOST 5
#define MODE_DECKX 6
#define MODE_DECKO 7
/* As defined by CARD_SUIT_* */ /* As defined by CARD_SUIT_* */
#define SUIT_FROM_CARD(card) (card & 3) #define SUIT_FROM_CARD(card) (card & 3)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment