winecfg: Add ability to change colors and non-client sizes.
[wine.git] / dlls / gdi32 / wing.c
blob7550fe201902458cc3225557f3d57c492edfa73b
1 /*
2 * WinG support
4 * Copyright (C) Robert Pouliot <krynos@clic.net>
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 St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "wownt32.h"
29 #include "gdi_private.h"
30 #include "wine/wingdi16.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(wing);
35 /*************************************************************************
36 * WING {WING}
38 * The Windows Game dll provides a number of functions designed to allow
39 * programmers to bypass Gdi and write directly to video memory. The intention
40 * was to bolster the use of Windows as a gaming platform and remove the
41 * need for Dos based games using 32 bit Dos extenders.
43 * This initial approach could not compete with the performance of Dos games
44 * (such as Doom and Warcraft) at the time, and so this dll was eventually
45 * superseded by DirectX. It should not be used by new applications, and is
46 * provided only for compatibility with older Windows programs.
49 typedef enum WING_DITHER_TYPE
51 WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
52 } WING_DITHER_TYPE;
55 * WinG DIB bitmaps can be selected into DC and then scribbled upon
56 * by GDI functions. They can also be changed directly. This gives us
57 * three choices
58 * - use original WinG 16-bit DLL
59 * requires working 16-bit driver interface
60 * - implement DIB graphics driver from scratch
61 * see wing.zip size
62 * - use shared pixmaps
63 * won't work with some videocards and/or videomodes
64 * 961208 - AK
67 /***********************************************************************
68 * WinGCreateDC (WING.1001)
70 * Create a new WinG device context.
72 * PARAMS
73 * None.
75 * RETURNS
76 * Success: A handle to the created device context.
77 * Failure: A NULL handle.
79 HDC16 WINAPI WinGCreateDC16(void)
81 TRACE("(void)\n");
82 return CreateCompatibleDC16(0);
85 /***********************************************************************
86 * WinGRecommendDIBFormat (WING.1002)
88 * Get the recommended format of bitmaps for the current display.
90 * PARAMS
91 * bmpi [O] Destination for format information
93 * RETURNS
94 * Success: TRUE. bmpi is filled with the best (fastest) bitmap format
95 * Failure: FALSE, if bmpi is NULL.
97 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
99 static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' };
100 HDC hdc;
101 TRACE("(%p)\n", bmpi);
102 if (!bmpi)
103 return FALSE;
105 hdc = CreateDCW( szDisplayW, NULL, NULL, NULL );
106 bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
107 bmpi->bmiHeader.biWidth = 320;
108 bmpi->bmiHeader.biHeight = -1;
109 bmpi->bmiHeader.biPlanes = 1;
110 bmpi->bmiHeader.biBitCount = 8;
111 bmpi->bmiHeader.biCompression = BI_RGB;
112 bmpi->bmiHeader.biSizeImage = 0;
113 bmpi->bmiHeader.biXPelsPerMeter = 0;
114 bmpi->bmiHeader.biYPelsPerMeter = 0;
115 bmpi->bmiHeader.biClrUsed = 0;
116 bmpi->bmiHeader.biClrImportant = 0;
117 DeleteDC(hdc);
118 return TRUE;
121 /***********************************************************************
122 * WinGCreateBitmap (WING.1003)
124 * Create a new WinG bitmap.
126 * PARAMS
127 * hdc [I] WinG device context
128 * bmpi [I] Information about the bitmap
129 * bits [I] Location of the bitmap image data
131 * RETURNS
132 * Success: A handle to the created bitmap.
133 * Failure: A NULL handle.
135 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
136 SEGPTR *bits)
138 TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
139 TRACE(": create %dx%dx%d bitmap\n", bmpi->bmiHeader.biWidth,
140 bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
141 return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
144 /***********************************************************************
145 * WinGGetDIBPointer (WING.1004)
147 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
149 BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( HBITMAP_32(hWinGBitmap),
150 BITMAP_MAGIC );
151 SEGPTR res = 0;
153 TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
154 if (!bmp) return 0;
156 if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
158 res = bmp->segptr_bits;
159 GDI_ReleaseObj( HBITMAP_32(hWinGBitmap) );
160 return res;
163 /***********************************************************************
164 * WinGSetDIBColorTable (WING.1006)
166 * Set all or part of the color table for a WinG device context.
168 * PARAMS
169 * hdc [I] WinG device context
170 * start [I] Start color
171 * num [I] Number of entries to set
172 * colors [I] Array of color data
174 * RETURNS
175 * The number of entries set.
177 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
178 RGBQUAD *colors)
180 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
181 return SetDIBColorTable16(hdc, start, num, colors);
184 /***********************************************************************
185 * WinGGetDIBColorTable (WING.1005)
187 * Get all or part of the color table for a WinG device context.
189 * PARAMS
190 * hdc [I] WinG device context
191 * start [I] Start color
192 * num [I] Number of entries to set
193 * colors [O] Destination for the array of color data
195 * RETURNS
196 * The number of entries retrieved.
198 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
199 RGBQUAD *colors)
201 TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
202 return GetDIBColorTable16(hdc, start, num, colors);
205 /***********************************************************************
206 * WinGCreateHalfTonePalette (WING.1007)
208 * Create a half tone palette.
210 * PARAMS
211 * None.
213 * RETURNS
214 * Success: A handle to the created palette.
215 * Failure: A NULL handle.
217 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
219 HDC16 hdc = CreateCompatibleDC16(0);
220 HPALETTE16 ret = CreateHalftonePalette16(hdc);
221 TRACE("(void)\n");
222 DeleteDC16(hdc);
223 return ret;
226 /***********************************************************************
227 * WinGCreateHalfToneBrush (WING.1008)
229 * Create a half tone brush for a WinG device context.
231 * PARAMS
232 * winDC [I] WinG device context
233 * col [I] Color
234 * type [I] Desired dithering type.
236 * RETURNS
237 * Success: A handle to the created brush.
238 * Failure: A NULL handle.
240 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
241 WING_DITHER_TYPE type)
243 TRACE("(%d,%d,%d)\n", winDC, col, type);
244 return CreateSolidBrush16(col);
247 /***********************************************************************
248 * WinGStretchBlt (WING.1009)
250 * See StretchBlt16.
252 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
253 INT16 widDest, INT16 heiDest,
254 HDC16 srcDC, INT16 xSrc, INT16 ySrc,
255 INT16 widSrc, INT16 heiSrc)
257 BOOL16 retval;
258 TRACE("(%d,%d,...)\n", destDC, srcDC);
259 SetStretchBltMode16 ( destDC, COLORONCOLOR );
260 retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
261 xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
262 SetStretchBltMode16 ( destDC, BLACKONWHITE );
263 return retval;
266 /***********************************************************************
267 * WinGBitBlt (WING.1010)
269 * See BitBlt16.
271 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
272 INT16 widDest, INT16 heiDest, HDC16 srcDC,
273 INT16 xSrc, INT16 ySrc)
275 TRACE("(%d,%d,...)\n", destDC, srcDC);
276 return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
277 xSrc, ySrc, SRCCOPY);