- Enumerated different drawing modes.

- Implemented HILITE, REMOVE and GHOST drawing modes.
oldstable
Sami Nopanen 2004-03-16 19:13:47 +00:00 committed by Alexandre Julliard
parent bb86eb6588
commit 7e8732c8ad
2 changed files with 72 additions and 23 deletions

View File

@ -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);
hCardBitmap = cardBitmaps[card];
if(hCardBitmap == 0)
return FALSE; return FALSE;
}
if(mode == MODE_INVISIBLEGHOST || mode == MODE_DECKX || mode == MODE_DECKO)
{
FIXME("Mode %d not implemented.\n", mode);
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;
SetBkColor(hdc, color); hCardBitmap = cardBitmaps[card];
if(hCardBitmap == 0)
return FALSE;
if((cardWidth == dx) && (cardHeight == dy)) result = SelectObject(hMemoryDC, hCardBitmap);
BitBlt(hdc, x, y, cardWidth, cardHeight, hMemoryDC, 0, 0, SRCCOPY); if((result == 0) || (result == HGDI_ERROR))
else {
StretchBlt(hdc, x, y, dx, dy, hMemoryDC, 0, 0, cardWidth, cardHeight, SRCCOPY); DeleteDC(hMemoryDC);
return FALSE;
}
SetBkColor(hdc, color);
if((cardWidth == dx) && (cardHeight == dy))
BitBlt(hdc, x, y, cardWidth, cardHeight, hMemoryDC, 0, 0, rasterOp);
else
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
* 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
* 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);
} }

View File

@ -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)