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