OpenPrinter should fail if pPrinterName is "".
[wine] / dlls / gdi / wing.c
1 /*
2  * WinG support
3  *
4  * Started by Robert Pouliot <krynos@clic.net>
5  */
6
7 #include "config.h"
8
9 #include "wine/winuser16.h"
10 #include "bitmap.h"
11 #include "debugtools.h"
12 #include "palette.h"
13 #include "windef.h"
14
15 DEFAULT_DEBUG_CHANNEL(wing);
16
17
18 typedef enum WING_DITHER_TYPE
19 {
20   WING_DISPERSED_4x4, WING_DISPERSED_8x8, WING_CLUSTERED_4x4
21 } WING_DITHER_TYPE;
22
23 /* 
24  * WinG DIB bitmaps can be selected into DC and then scribbled upon
25  * by GDI functions. They can also be changed directly. This gives us 
26  * three choices 
27  *      - use original WinG 16-bit DLL
28  *              requires working 16-bit driver interface
29  *      - implement DIB graphics driver from scratch
30  *              see wing.zip size
31  *      - use shared pixmaps
32  *              won't work with some videocards and/or videomodes
33  * 961208 - AK
34  */
35
36 /***********************************************************************
37  *          WinGCreateDC        (WING.1001)
38  */
39 HDC16 WINAPI WinGCreateDC16(void)
40 {
41     TRACE("(void)\n");
42         return CreateCompatibleDC16(0);
43 }
44
45 /***********************************************************************
46  *  WinGRecommendDIBFormat    (WING.1002)
47  */
48 BOOL16 WINAPI WinGRecommendDIBFormat16(BITMAPINFO *bmpi)
49 {
50     HDC hdc;
51     TRACE("(%p)\n", bmpi);
52     if (!bmpi)
53         return FALSE;
54
55     hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
56     bmpi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
57     bmpi->bmiHeader.biWidth = 320;
58     bmpi->bmiHeader.biHeight = -1;
59     bmpi->bmiHeader.biPlanes = 1;
60     bmpi->bmiHeader.biBitCount = 8;
61     bmpi->bmiHeader.biCompression = BI_RGB;
62     bmpi->bmiHeader.biSizeImage = 0;
63     bmpi->bmiHeader.biXPelsPerMeter = 0;
64     bmpi->bmiHeader.biYPelsPerMeter = 0;
65     bmpi->bmiHeader.biClrUsed = 0;
66     bmpi->bmiHeader.biClrImportant = 0;
67     DeleteDC(hdc);
68     return TRUE;
69 }
70
71 /***********************************************************************
72  *        WinGCreateBitmap    (WING.1003)
73  */
74 HBITMAP16 WINAPI WinGCreateBitmap16(HDC16 hdc, BITMAPINFO *bmpi,
75                                     SEGPTR *bits)
76 {
77     TRACE("(%d,%p,%p)\n", hdc, bmpi, bits);
78     TRACE(": create %ldx%ldx%d bitmap\n", bmpi->bmiHeader.biWidth,
79           bmpi->bmiHeader.biHeight, bmpi->bmiHeader.biPlanes);
80     return CreateDIBSection16(hdc, bmpi, 0, bits, 0, 0);
81 }
82
83 /***********************************************************************
84  *  WinGGetDIBPointer   (WING.1004)
85  */
86 SEGPTR WINAPI WinGGetDIBPointer16(HBITMAP16 hWinGBitmap, BITMAPINFO* bmpi)
87 {
88     BITMAPOBJ* bmp = (BITMAPOBJ *) GDI_GetObjPtr( hWinGBitmap, BITMAP_MAGIC );
89     SEGPTR res = 0;
90
91     TRACE("(%d,%p)\n", hWinGBitmap, bmpi);
92     if (!bmp) return 0;
93
94     if (bmpi) FIXME(": Todo - implement setting BITMAPINFO\n");
95
96     res = bmp->segptr_bits;
97     GDI_ReleaseObj( hWinGBitmap );
98     return res;
99 }
100
101 /***********************************************************************
102  *  WinGSetDIBColorTable   (WING.1006)
103  */
104 UINT16 WINAPI WinGSetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
105                                      RGBQUAD *colors)
106 {
107     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
108     return SetDIBColorTable16(hdc, start, num, colors);
109 }
110
111 /***********************************************************************
112  *  WinGGetDIBColorTable   (WING.1005)
113  */
114 UINT16 WINAPI WinGGetDIBColorTable16(HDC16 hdc, UINT16 start, UINT16 num,
115                                      RGBQUAD *colors)
116 {
117     TRACE("(%d,%d,%d,%p)\n", hdc, start, num, colors);
118     return GetDIBColorTable16(hdc, start, num, colors);
119 }
120
121 /***********************************************************************
122  *  WinGCreateHalfTonePalette   (WING.1007)
123  */
124 HPALETTE16 WINAPI WinGCreateHalfTonePalette16(void)
125 {
126     HDC hdc = CreateCompatibleDC(0);
127     HPALETTE16 ret = CreateHalftonePalette16(hdc);
128     TRACE("(void)\n");
129     DeleteDC(hdc);
130     return ret;
131 }
132
133 /***********************************************************************
134  *  WinGCreateHalfToneBrush   (WING.1008)
135  */
136 HBRUSH16 WINAPI WinGCreateHalfToneBrush16(HDC16 winDC, COLORREF col,
137                                             WING_DITHER_TYPE type)
138 {
139     TRACE("(%d,%ld,%d)\n", winDC, col, type);
140     return CreateSolidBrush16(col);
141 }
142
143 /***********************************************************************
144  *  WinGStretchBlt   (WING.1009)
145  */
146 BOOL16 WINAPI WinGStretchBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
147                                INT16 widDest, INT16 heiDest,
148                                HDC16 srcDC, INT16 xSrc, INT16 ySrc,
149                                INT16 widSrc, INT16 heiSrc)
150 {
151     BOOL16 retval;
152     TRACE("(%d,%d,...)\n", destDC, srcDC);
153     SetStretchBltMode16 ( destDC, COLORONCOLOR );
154     retval=StretchBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
155                         xSrc, ySrc, widSrc, heiSrc, SRCCOPY);
156     SetStretchBltMode16 ( destDC, BLACKONWHITE );
157     return retval;
158 }
159
160 /***********************************************************************
161  *  WinGBitBlt   (WING.1010)
162  */
163 BOOL16 WINAPI WinGBitBlt16(HDC16 destDC, INT16 xDest, INT16 yDest,
164                            INT16 widDest, INT16 heiDest, HDC16 srcDC,
165                            INT16 xSrc, INT16 ySrc)
166 {
167     TRACE("(%d,%d,...)\n", destDC, srcDC);
168     return BitBlt16(destDC, xDest, yDest, widDest, heiDest, srcDC,
169                     xSrc, ySrc, SRCCOPY);
170 }