4 * Copyright (C) 2003 Filip Navara <xnavara@volny.org>
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 HBITMAP g_CardBitmaps
[MAX_CARD_BITMAPS
];
29 HINSTANCE g_hModule
= 0;
32 * Redundant function from 16-bit Windows time
34 BOOL WINAPI
WEP(DWORD Unknown
)
36 UNREFERENCED_PARAMETER(Unknown
);
41 * Initialize card library and return cards width and height
43 BOOL WINAPI
cdtInit(INT
*Width
, INT
*Height
)
47 /* Report card width and height to user */
49 *Height
= CARD_HEIGHT
;
52 for (dwIndex
= 0; dwIndex
< MAX_CARD_BITMAPS
; ++dwIndex
)
53 g_CardBitmaps
[dwIndex
] =
54 (HBITMAP
)LoadBitmapA(g_hModule
, MAKEINTRESOURCEA(dwIndex
+ 1));
60 * Terminate card library
62 VOID WINAPI
cdtTerm(VOID
)
67 for (dwIndex
= 0; dwIndex
< MAX_CARD_BITMAPS
; dwIndex
++)
68 DeleteObject(g_CardBitmaps
[dwIndex
]);
72 * Render card with no stretching
74 BOOL WINAPI
cdtDraw(HDC hdc
, INT x
, INT y
, INT card
, INT type
, COLORREF color
)
76 return cdtDrawExt(hdc
, x
, y
, CARD_WIDTH
, CARD_HEIGHT
, card
, type
, color
);
82 static __inline VOID
BltCard(HDC hdc
, INT x
, INT y
, INT dx
, INT dy
, HDC hdcCard
, DWORD dwRasterOp
, BOOL bStretch
)
86 StretchBlt(hdc
, x
, y
, dx
, dy
, hdcCard
, 0, 0, CARD_WIDTH
, CARD_HEIGHT
, dwRasterOp
);
90 BitBlt(hdc
, x
, y
, dx
, dy
, hdcCard
, 0, 0, dwRasterOp
);
92 * This is need when using Microsoft images, because they use two-color red/white images for
93 * red cards and thus needs fix-up of the edge to black color.
98 PatBlt(hdc
, x
, y
+ 2, 1, dy
- 4, BLACKNESS
);
99 PatBlt(hdc
, x
+ dx
- 1, y
+ 2, 1, dy
- 4, BLACKNESS
);
100 PatBlt(hdc
, x
+ 2, y
, dx
- 4, 1, BLACKNESS
);
101 PatBlt(hdc
, x
+ 2, y
+ dy
- 1, dx
- 4, 1, BLACKNESS
);
102 SetPixel(hdc
, x
+ 1, y
+ 1, 0);
103 SetPixel(hdc
, x
+ dx
- 2, y
+ 1, 0);
104 SetPixel(hdc
, x
+ 1, y
+ dy
- 2, 0);
105 SetPixel(hdc
, x
+ dx
- 2, y
+ dy
- 2, 0);
115 * hdc - Handle of destination device context
118 * dx - Destination width
119 * dy - Destination height
120 * card - Image id (meaning depend on type)
121 * type - One of edt* constants
122 * color - Background color (?)
124 BOOL WINAPI
cdtDrawExt(HDC hdc
, INT x
, INT y
, INT dx
, INT dy
, INT card
, INT type
, COLORREF color
)
126 DWORD dwRasterOp
= SRCCOPY
;
127 BOOL bSaveEdges
= TRUE
;
128 BOOL bStretch
= FALSE
;
130 if (type
& ectSAVEEDGESMASK
)
132 type
&= ~ectSAVEEDGESMASK
;
136 if (dx
!= CARD_WIDTH
|| dy
!= CARD_HEIGHT
)
145 dwRasterOp
= NOTSRCCOPY
;
147 card
= (card
% 4) * 13 + (card
/ 4);
169 if (type
== ectEMPTY
|| type
== ectERASE
)
174 hBrush
= CreateSolidBrush(color
);
175 GetDCOrgEx(hdc
, &pPoint
);
176 SetBrushOrgEx(hdc
, pPoint
.x
, pPoint
.y
, 0);
177 SelectObject(hdc
, hBrush
);
178 PatBlt(hdc
, x
, y
, dx
, dy
, PATCOPY
);
180 if (type
!= ectERASE
)
185 hdcCard
= CreateCompatibleDC(hdc
);
186 SelectObject(hdcCard
, g_CardBitmaps
[card
]);
187 OldBkColor
= SetBkColor(hdc
, (type
== ectFACES
) ? 0xFFFFFF : color
);
190 COLORREF SavedPixels
[12];
191 SavedPixels
[0] = GetPixel(hdc
, x
, y
);
192 SavedPixels
[1] = GetPixel(hdc
, x
+ 1, y
);
193 SavedPixels
[2] = GetPixel(hdc
, x
, y
+ 1);
194 SavedPixels
[3] = GetPixel(hdc
, x
+ dx
- 1, y
);
195 SavedPixels
[4] = GetPixel(hdc
, x
+ dx
- 2, y
);
196 SavedPixels
[5] = GetPixel(hdc
, x
+ dx
- 1, y
+ 1);
197 SavedPixels
[6] = GetPixel(hdc
, x
, y
+ dy
- 1);
198 SavedPixels
[7] = GetPixel(hdc
, x
+ 1, y
+ dy
- 1);
199 SavedPixels
[8] = GetPixel(hdc
, x
, y
+ dy
- 2);
200 SavedPixels
[9] = GetPixel(hdc
, x
+ dx
- 1, y
+ dy
- 1);
201 SavedPixels
[10] = GetPixel(hdc
, x
+ dx
- 2, y
+ dy
- 1);
202 SavedPixels
[11] = GetPixel(hdc
, x
+ dx
- 1, y
+ dy
- 2);
204 BltCard(hdc
, x
, y
, dx
, dy
, hdcCard
, dwRasterOp
, bStretch
);
206 SetPixel(hdc
, x
, y
, SavedPixels
[0]);
207 SetPixel(hdc
, x
+ 1, y
, SavedPixels
[1]);
208 SetPixel(hdc
, x
, y
+ 1, SavedPixels
[2]);
209 SetPixel(hdc
, x
+ dx
- 1, y
, SavedPixels
[3]);
210 SetPixel(hdc
, x
+ dx
- 2, y
, SavedPixels
[4]);
211 SetPixel(hdc
, x
+ dx
- 1, y
+ 1, SavedPixels
[5]);
212 SetPixel(hdc
, x
, y
+ dy
- 1, SavedPixels
[6]);
213 SetPixel(hdc
, x
+ 1, y
+ dy
- 1, SavedPixels
[7]);
214 SetPixel(hdc
, x
, y
+ dy
- 2, SavedPixels
[8]);
215 SetPixel(hdc
, x
+ dx
- 1, y
+ dy
- 1, SavedPixels
[9]);
216 SetPixel(hdc
, x
+ dx
- 2, y
+ dy
- 1, SavedPixels
[10]);
217 SetPixel(hdc
, x
+ dx
- 1, y
+ dy
- 2, SavedPixels
[11]);
221 BltCard(hdc
, x
, y
, dx
, dy
, hdcCard
, dwRasterOp
, bStretch
);
223 SetBkColor(hdc
, OldBkColor
);
231 /***********************************************************************
232 * cdtAnimate (CARDS.@)
234 * Animate card background, we don't use it
236 BOOL WINAPI
cdtAnimate(HDC hdc
, int cardback
, int x
, int y
, int frame
)
238 UNREFERENCED_PARAMETER(frame
);
239 UNREFERENCED_PARAMETER(y
);
240 UNREFERENCED_PARAMETER(x
);
241 UNREFERENCED_PARAMETER(cardback
);
242 UNREFERENCED_PARAMETER(hdc
);
246 BOOL WINAPI
DllMain(HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
248 UNREFERENCED_PARAMETER(lpvReserved
);
250 if (fdwReason
== DLL_PROCESS_ATTACH
)
251 g_hModule
= hinstDLL
;