2 * Cards dll implementation
4 * Copyright (C) 2004 Sami Nopanen
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(cards);
36 void WINAPI cdtTerm(void);
39 static HINSTANCE hInst;
41 static int cardHeight;
42 static HBITMAP cardBitmaps[CARD_MAX + 1];
45 /***********************************************************************
46 * Initializes the cards.dll library. Loads the card bitmaps from the
47 * resources, and initializes the card size variables.
49 BOOL WINAPI cdtInit(int *width, int *height)
54 TRACE("(%p, %p)\n", width, height);
56 for(i = 0; i <= CARD_MAX; i++)
59 for(i = 0; i <= CARD_MAX; i++)
61 cardBitmaps[i] = LoadBitmapA(hInst, MAKEINTRESOURCEA(i));
62 if(cardBitmaps[i] == 0)
69 GetObjectA(cardBitmaps[0], sizeof(BITMAP), &bm);
70 *width = cardWidth = bm.bmWidth;
71 *height = cardHeight = bm.bmHeight;
76 /***********************************************************************
77 * Draw a card. Unlike cdtDrawCard, this version allows you to stretch
78 * card bitmaps to the size you specify (dx, dy). See cdtDraw for info
79 * on card, type and color parameters.
81 BOOL WINAPI cdtDrawExt(HDC hdc, int x, int y, int dx, int dy, int card, int type, DWORD color)
87 TRACE("(%p, %d, %d, %d, %d, %d, %d, %ld)\n", hdc, x, y, dx, dy, card, type, color);
89 if((card < 0) || (card > CARD_MAX))
91 FIXME("Unexpected card: %d\n", card);
95 if((type < 0) || (type > 2))
96 FIXME("Unexpected type: %d\n", type);
98 hCardBitmap = cardBitmaps[card];
102 hMemoryDC = CreateCompatibleDC(hdc);
106 result = SelectObject(hMemoryDC, hCardBitmap);
107 if((result == 0) || (result == HGDI_ERROR))
113 SetBkColor(hdc, color);
115 if((cardWidth == dx) && (cardHeight == dy))
116 BitBlt(hdc, x, y, cardWidth, cardHeight, hMemoryDC, 0, 0, SRCCOPY);
118 StretchBlt(hdc, x, y, dx, dy, hMemoryDC, 0, 0, cardWidth, cardHeight, SRCCOPY);
126 /***********************************************************************
127 * Draws a card at position x, y in its default size (as returned by
130 * Type parameter controls whether the front (0), back (1), or inverted
131 * front (2) of the card is to be drawn.
133 * The card parameter defines the card graphic to be drawn. If we are
134 * drawing fronts of cards, card should have a value from 0 through 51
135 * to represent the card face. If we are drawing card backs, 53 through
136 * 68 represent different card backs.
138 * When drawing card faces, two lowest bits represent the card suit
139 * (clubs, diamonds, hearts, spades), and the bits above that define the
140 * card value (ace, 2, ..., king). That is,
141 * card = face * 4 + suit.
143 * Color parameter defines the background color, used when drawing some
146 BOOL WINAPI cdtDraw(HDC hdc, int x, int y, int card, int type, DWORD color)
148 TRACE("(%p, %d, %d, %d, %d, %ld)\n", hdc, x, y, card, type, color);
150 return cdtDrawExt(hdc, x, y, cardWidth, cardHeight, card, type, color);
154 /***********************************************************************
155 * Animates the card backs, e.g. blinking lights on the robot, the sun
156 * donning sunglasses, bats flying across the caste, etc.. Works only
157 * for cards of normal size (as drawn with cdtDraw). To draw frames of
158 * the card back animation, start with frame = 0, and increment the
159 * frame by one, until cdtAnimate returns FALSE (to indicate that we
160 * have gone through all frames of animation).
162 BOOL WINAPI cdtAnimate(HDC hdc, int cardback, int x, int y, int frame)
164 TRACE("(%p, %d, %d, %d, %d)\n", hdc, cardback, x, y, frame);
165 FIXME("Implement me.");
171 /***********************************************************************
172 * Frees resources reserved by cdtInitialize.
174 void WINAPI cdtTerm()
180 for(i = 0; i <= CARD_MAX; i++)
182 if(cardBitmaps[i] != 0)
183 DeleteObject(cardBitmaps[i]);
189 /***********************************************************************
192 BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
196 case DLL_PROCESS_ATTACH:
198 DisableThreadLibraryCalls( inst );
200 case DLL_PROCESS_DETACH: