Compiler warnings fix.
[wine] / objects / dc.c
1 /*
2  * GDI Device Context functions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
6  */
7
8 #include "config.h"
9
10 #ifndef X_DISPLAY_MISSING
11 #include "ts_xlib.h"
12 #include "x11drv.h"
13 #endif  /* !defined(X_DISPLAY_MISSING) */
14
15 #include <stdlib.h>
16 #include <string.h>
17 #include "dc.h"
18 #include "gdi.h"
19 #include "heap.h"
20 #include "debugtools.h"
21 #include "font.h"
22 #include "winerror.h"
23 #include "wine/winuser16.h"
24
25 DEFAULT_DEBUG_CHANNEL(dc)
26
27 /***********************************************************************
28  *           DC_Init_DC_INFO
29  *
30  * Fill the WIN_DC_INFO structure.
31  */
32 static void DC_Init_DC_INFO( WIN_DC_INFO *win_dc_info )
33 {
34     win_dc_info->flags               = 0;
35     win_dc_info->devCaps             = NULL;
36     win_dc_info->hClipRgn            = 0;
37     win_dc_info->hVisRgn             = 0;
38     win_dc_info->hGCClipRgn          = 0;
39     win_dc_info->hPen                = STOCK_BLACK_PEN;
40     win_dc_info->hBrush              = STOCK_WHITE_BRUSH;
41     win_dc_info->hFont               = STOCK_SYSTEM_FONT;
42     win_dc_info->hBitmap             = 0;
43     win_dc_info->hFirstBitmap        = 0;
44     win_dc_info->hDevice             = 0;
45     win_dc_info->hPalette            = STOCK_DEFAULT_PALETTE;
46     win_dc_info->ROPmode             = R2_COPYPEN;
47     win_dc_info->polyFillMode        = ALTERNATE;
48     win_dc_info->stretchBltMode      = BLACKONWHITE;
49     win_dc_info->relAbsMode          = ABSOLUTE;
50     win_dc_info->backgroundMode      = OPAQUE;
51     win_dc_info->backgroundColor     = RGB( 255, 255, 255 );
52     win_dc_info->textColor           = RGB( 0, 0, 0 );
53     win_dc_info->brushOrgX           = 0;
54     win_dc_info->brushOrgY           = 0;
55     win_dc_info->textAlign           = TA_LEFT | TA_TOP | TA_NOUPDATECP;
56     win_dc_info->charExtra           = 0;
57     win_dc_info->breakTotalExtra     = 0;
58     win_dc_info->breakCount          = 0;
59     win_dc_info->breakExtra          = 0;
60     win_dc_info->breakRem            = 0;
61     win_dc_info->bitsPerPixel        = 1;
62     win_dc_info->MapMode             = MM_TEXT;
63     win_dc_info->GraphicsMode        = GM_COMPATIBLE;
64     win_dc_info->DCOrgX              = 0;
65     win_dc_info->DCOrgY              = 0;
66     win_dc_info->lpfnPrint           = NULL;
67     win_dc_info->CursPosX            = 0;
68     win_dc_info->CursPosY            = 0;
69     win_dc_info->ArcDirection        = AD_COUNTERCLOCKWISE;
70     win_dc_info->xformWorld2Wnd.eM11 = 1.0f;
71     win_dc_info->xformWorld2Wnd.eM12 = 0.0f;
72     win_dc_info->xformWorld2Wnd.eM21 = 0.0f;
73     win_dc_info->xformWorld2Wnd.eM22 = 1.0f;
74     win_dc_info->xformWorld2Wnd.eDx  = 0.0f;
75     win_dc_info->xformWorld2Wnd.eDy  = 0.0f;
76     win_dc_info->xformWorld2Vport    = win_dc_info->xformWorld2Wnd;
77     win_dc_info->xformVport2World    = win_dc_info->xformWorld2Wnd;
78     win_dc_info->vport2WorldValid    = TRUE;
79
80     PATH_InitGdiPath(&win_dc_info->path);
81 }
82
83
84 /***********************************************************************
85  *           DC_AllocDC
86  */
87 DC *DC_AllocDC( const DC_FUNCTIONS *funcs )
88 {
89     HDC16 hdc;
90     DC *dc;
91
92     if (!(hdc = GDI_AllocObject( sizeof(DC), DC_MAGIC ))) return NULL;
93     dc = (DC *) GDI_HEAP_LOCK( hdc );
94
95     dc->hSelf      = hdc;
96     dc->funcs      = funcs;
97     dc->physDev    = NULL;
98     dc->saveLevel  = 0;
99     dc->dwHookData = 0L;
100     dc->hookProc   = NULL;
101     dc->wndOrgX    = 0;
102     dc->wndOrgY    = 0;
103     dc->wndExtX    = 1;
104     dc->wndExtY    = 1;
105     dc->vportOrgX  = 0;
106     dc->vportOrgY  = 0;
107     dc->vportExtX  = 1;
108     dc->vportExtY  = 1;
109
110     DC_Init_DC_INFO( &dc->w );
111
112     return dc;
113 }
114
115
116
117 /***********************************************************************
118  *           DC_GetDCPtr
119  */
120 DC *DC_GetDCPtr( HDC hdc )
121 {
122     GDIOBJHDR *ptr = (GDIOBJHDR *)GDI_HEAP_LOCK( hdc );
123     if (!ptr) return NULL;
124     if ((ptr->wMagic == DC_MAGIC) || (ptr->wMagic == METAFILE_DC_MAGIC) ||
125         (ptr->wMagic == ENHMETAFILE_DC_MAGIC))
126         return (DC *)ptr;
127     GDI_HEAP_UNLOCK( hdc );
128     return NULL;
129 }
130
131
132 /***********************************************************************
133  *           DC_InitDC
134  *
135  * Setup device-specific DC values for a newly created DC.
136  */
137 void DC_InitDC( DC* dc )
138 {
139     RealizeDefaultPalette16( dc->hSelf );
140     SetTextColor( dc->hSelf, dc->w.textColor );
141     SetBkColor( dc->hSelf, dc->w.backgroundColor );
142     SelectObject( dc->hSelf, dc->w.hPen );
143     SelectObject( dc->hSelf, dc->w.hBrush );
144     SelectObject( dc->hSelf, dc->w.hFont );
145     CLIPPING_UpdateGCRegion( dc );
146 }
147
148
149 /***********************************************************************
150  *           DC_InvertXform
151  *
152  * Computes the inverse of the transformation xformSrc and stores it to
153  * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
154  * is singular.
155  */
156 static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
157 {
158     FLOAT determinant;
159     
160     determinant = xformSrc->eM11*xformSrc->eM22 -
161         xformSrc->eM12*xformSrc->eM21;
162     if (determinant > -1e-12 && determinant < 1e-12)
163         return FALSE;
164
165     xformDest->eM11 =  xformSrc->eM22 / determinant;
166     xformDest->eM12 = -xformSrc->eM12 / determinant;
167     xformDest->eM21 = -xformSrc->eM21 / determinant;
168     xformDest->eM22 =  xformSrc->eM11 / determinant;
169     xformDest->eDx  = -xformSrc->eDx * xformDest->eM11 -
170                        xformSrc->eDy * xformDest->eM21;
171     xformDest->eDy  = -xformSrc->eDx * xformDest->eM12 -
172                        xformSrc->eDy * xformDest->eM22;
173
174     return TRUE;
175 }
176
177
178 /***********************************************************************
179  *           DC_UpdateXforms
180  *
181  * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
182  * fields of the specified DC by creating a transformation that
183  * represents the current mapping mode and combining it with the DC's
184  * world transform. This function should be called whenever the
185  * parameters associated with the mapping mode (window and viewport
186  * extents and origins) or the world transform change.
187  */
188 void DC_UpdateXforms( DC *dc )
189 {
190     XFORM xformWnd2Vport;
191     FLOAT scaleX, scaleY;
192     
193     /* Construct a transformation to do the window-to-viewport conversion */
194     scaleX = (FLOAT)dc->vportExtX / (FLOAT)dc->wndExtX;
195     scaleY = (FLOAT)dc->vportExtY / (FLOAT)dc->wndExtY;
196     xformWnd2Vport.eM11 = scaleX;
197     xformWnd2Vport.eM12 = 0.0;
198     xformWnd2Vport.eM21 = 0.0;
199     xformWnd2Vport.eM22 = scaleY;
200     xformWnd2Vport.eDx  = (FLOAT)dc->vportOrgX -
201         scaleX * (FLOAT)dc->wndOrgX;
202     xformWnd2Vport.eDy  = (FLOAT)dc->vportOrgY -
203         scaleY * (FLOAT)dc->wndOrgY;
204
205     /* Combine with the world transformation */
206     CombineTransform( &dc->w.xformWorld2Vport, &dc->w.xformWorld2Wnd,
207         &xformWnd2Vport );
208
209     /* Create inverse of world-to-viewport transformation */
210     dc->w.vport2WorldValid = DC_InvertXform( &dc->w.xformWorld2Vport,
211         &dc->w.xformVport2World );
212 }
213
214
215 /***********************************************************************
216  *           GetDCState    (GDI.179)
217  */
218 HDC16 WINAPI GetDCState16( HDC16 hdc )
219 {
220     DC * newdc, * dc;
221     HGDIOBJ16 handle;
222     
223     if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return 0;
224     if (!(handle = GDI_AllocObject( sizeof(DC), DC_MAGIC )))
225     {
226       GDI_HEAP_UNLOCK( hdc );
227       return 0;
228     }
229     newdc = (DC *) GDI_HEAP_LOCK( handle );
230
231     TRACE("(%04x): returning %04x\n", hdc, handle );
232
233     newdc->w.flags            = dc->w.flags | DC_SAVED;
234     newdc->w.devCaps          = dc->w.devCaps;
235     newdc->w.hPen             = dc->w.hPen;       
236     newdc->w.hBrush           = dc->w.hBrush;     
237     newdc->w.hFont            = dc->w.hFont;      
238     newdc->w.hBitmap          = dc->w.hBitmap;    
239     newdc->w.hFirstBitmap     = dc->w.hFirstBitmap;
240     newdc->w.hDevice          = dc->w.hDevice;
241     newdc->w.hPalette         = dc->w.hPalette;   
242     newdc->w.totalExtent      = dc->w.totalExtent;
243     newdc->w.bitsPerPixel     = dc->w.bitsPerPixel;
244     newdc->w.ROPmode          = dc->w.ROPmode;
245     newdc->w.polyFillMode     = dc->w.polyFillMode;
246     newdc->w.stretchBltMode   = dc->w.stretchBltMode;
247     newdc->w.relAbsMode       = dc->w.relAbsMode;
248     newdc->w.backgroundMode   = dc->w.backgroundMode;
249     newdc->w.backgroundColor  = dc->w.backgroundColor;
250     newdc->w.textColor        = dc->w.textColor;
251     newdc->w.brushOrgX        = dc->w.brushOrgX;
252     newdc->w.brushOrgY        = dc->w.brushOrgY;
253     newdc->w.textAlign        = dc->w.textAlign;
254     newdc->w.charExtra        = dc->w.charExtra;
255     newdc->w.breakTotalExtra  = dc->w.breakTotalExtra;
256     newdc->w.breakCount       = dc->w.breakCount;
257     newdc->w.breakExtra       = dc->w.breakExtra;
258     newdc->w.breakRem         = dc->w.breakRem;
259     newdc->w.MapMode          = dc->w.MapMode;
260     newdc->w.GraphicsMode     = dc->w.GraphicsMode;
261 #if 0
262     /* Apparently, the DC origin is not changed by [GS]etDCState */
263     newdc->w.DCOrgX           = dc->w.DCOrgX;
264     newdc->w.DCOrgY           = dc->w.DCOrgY;
265 #endif
266     newdc->w.CursPosX         = dc->w.CursPosX;
267     newdc->w.CursPosY         = dc->w.CursPosY;
268     newdc->w.ArcDirection     = dc->w.ArcDirection;
269     newdc->w.xformWorld2Wnd   = dc->w.xformWorld2Wnd;
270     newdc->w.xformWorld2Vport = dc->w.xformWorld2Vport;
271     newdc->w.xformVport2World = dc->w.xformVport2World;
272     newdc->w.vport2WorldValid = dc->w.vport2WorldValid;
273     newdc->wndOrgX            = dc->wndOrgX;
274     newdc->wndOrgY            = dc->wndOrgY;
275     newdc->wndExtX            = dc->wndExtX;
276     newdc->wndExtY            = dc->wndExtY;
277     newdc->vportOrgX          = dc->vportOrgX;
278     newdc->vportOrgY          = dc->vportOrgY;
279     newdc->vportExtX          = dc->vportExtX;
280     newdc->vportExtY          = dc->vportExtY;
281
282     newdc->hSelf = (HDC)handle;
283     newdc->saveLevel = 0;
284
285     PATH_InitGdiPath( &newdc->w.path );
286     
287     /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
288
289     newdc->w.hGCClipRgn = newdc->w.hVisRgn = 0;
290     if (dc->w.hClipRgn)
291     {
292         newdc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
293         CombineRgn( newdc->w.hClipRgn, dc->w.hClipRgn, 0, RGN_COPY );
294     }
295     else
296         newdc->w.hClipRgn = 0;
297     GDI_HEAP_UNLOCK( handle );
298     GDI_HEAP_UNLOCK( hdc );
299     return handle;
300 }
301
302
303 /***********************************************************************
304  *           SetDCState    (GDI.180)
305  */
306 void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
307 {
308     DC *dc, *dcs;
309     
310     if (!(dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC ))) return;
311     if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC )))
312     {
313       GDI_HEAP_UNLOCK( hdc );
314       return;
315     }
316     if (!dcs->w.flags & DC_SAVED)
317     {
318       GDI_HEAP_UNLOCK( hdc );
319       GDI_HEAP_UNLOCK( hdcs );
320       return;
321     }
322     TRACE("%04x %04x\n", hdc, hdcs );
323
324     dc->w.flags            = dcs->w.flags & ~DC_SAVED;
325     dc->w.devCaps          = dcs->w.devCaps;
326     dc->w.hFirstBitmap     = dcs->w.hFirstBitmap;
327     dc->w.hDevice          = dcs->w.hDevice;
328     dc->w.totalExtent      = dcs->w.totalExtent;
329     dc->w.ROPmode          = dcs->w.ROPmode;
330     dc->w.polyFillMode     = dcs->w.polyFillMode;
331     dc->w.stretchBltMode   = dcs->w.stretchBltMode;
332     dc->w.relAbsMode       = dcs->w.relAbsMode;
333     dc->w.backgroundMode   = dcs->w.backgroundMode;
334     dc->w.backgroundColor  = dcs->w.backgroundColor;
335     dc->w.textColor        = dcs->w.textColor;
336     dc->w.brushOrgX        = dcs->w.brushOrgX;
337     dc->w.brushOrgY        = dcs->w.brushOrgY;
338     dc->w.textAlign        = dcs->w.textAlign;
339     dc->w.charExtra        = dcs->w.charExtra;
340     dc->w.breakTotalExtra  = dcs->w.breakTotalExtra;
341     dc->w.breakCount       = dcs->w.breakCount;
342     dc->w.breakExtra       = dcs->w.breakExtra;
343     dc->w.breakRem         = dcs->w.breakRem;
344     dc->w.MapMode          = dcs->w.MapMode;
345     dc->w.GraphicsMode     = dcs->w.GraphicsMode;
346 #if 0
347     /* Apparently, the DC origin is not changed by [GS]etDCState */
348     dc->w.DCOrgX           = dcs->w.DCOrgX;
349     dc->w.DCOrgY           = dcs->w.DCOrgY;
350 #endif
351     dc->w.CursPosX         = dcs->w.CursPosX;
352     dc->w.CursPosY         = dcs->w.CursPosY;
353     dc->w.ArcDirection     = dcs->w.ArcDirection;
354     dc->w.xformWorld2Wnd   = dcs->w.xformWorld2Wnd;
355     dc->w.xformWorld2Vport = dcs->w.xformWorld2Vport;
356     dc->w.xformVport2World = dcs->w.xformVport2World;
357     dc->w.vport2WorldValid = dcs->w.vport2WorldValid;
358
359     dc->wndOrgX            = dcs->wndOrgX;
360     dc->wndOrgY            = dcs->wndOrgY;
361     dc->wndExtX            = dcs->wndExtX;
362     dc->wndExtY            = dcs->wndExtY;
363     dc->vportOrgX          = dcs->vportOrgX;
364     dc->vportOrgY          = dcs->vportOrgY;
365     dc->vportExtX          = dcs->vportExtX;
366     dc->vportExtY          = dcs->vportExtY;
367
368     if (!(dc->w.flags & DC_MEMORY)) dc->w.bitsPerPixel = dcs->w.bitsPerPixel;
369
370     if (dcs->w.hClipRgn)
371     {
372         if (!dc->w.hClipRgn) dc->w.hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
373         CombineRgn( dc->w.hClipRgn, dcs->w.hClipRgn, 0, RGN_COPY );
374     }
375     else
376     {
377         if (dc->w.hClipRgn) DeleteObject16( dc->w.hClipRgn );
378         dc->w.hClipRgn = 0;
379     }
380     CLIPPING_UpdateGCRegion( dc );
381
382     SelectObject( hdc, dcs->w.hBitmap );
383     SelectObject( hdc, dcs->w.hBrush );
384     SelectObject( hdc, dcs->w.hFont );
385     SelectObject( hdc, dcs->w.hPen );
386     SetBkColor( hdc, dcs->w.backgroundColor);
387     SetTextColor( hdc, dcs->w.textColor);
388     GDISelectPalette16( hdc, dcs->w.hPalette, FALSE );
389     GDI_HEAP_UNLOCK( hdc );
390     GDI_HEAP_UNLOCK( hdcs );
391 }
392
393
394 /***********************************************************************
395  *           SaveDC16    (GDI.30)
396  */
397 INT16 WINAPI SaveDC16( HDC16 hdc )
398 {
399     return (INT16)SaveDC( hdc );
400 }
401
402
403 /***********************************************************************
404  *           SaveDC32    (GDI32.292)
405  */
406 INT WINAPI SaveDC( HDC hdc )
407 {
408     HDC hdcs;
409     DC * dc, * dcs;
410     INT ret;
411
412     dc = DC_GetDCPtr( hdc );
413     if (!dc) return 0;
414
415     if(dc->funcs->pSaveDC)
416         return dc->funcs->pSaveDC( dc );
417
418     if (!(hdcs = GetDCState16( hdc )))
419     {
420       GDI_HEAP_UNLOCK( hdc );
421       return 0;
422     }
423     dcs = (DC *) GDI_HEAP_LOCK( hdcs );
424
425     /* Copy path. The reason why path saving / restoring is in SaveDC/
426      * RestoreDC and not in GetDCState/SetDCState is that the ...DCState
427      * functions are only in Win16 (which doesn't have paths) and that
428      * SetDCState doesn't allow us to signal an error (which can happen
429      * when copying paths).
430      */
431     if (!PATH_AssignGdiPath( &dcs->w.path, &dc->w.path ))
432     {
433         GDI_HEAP_UNLOCK( hdc );
434         GDI_HEAP_UNLOCK( hdcs );
435         DeleteDC( hdcs );
436         return 0;
437     }
438     
439     dcs->header.hNext = dc->header.hNext;
440     dc->header.hNext = hdcs;
441     TRACE("(%04x): returning %d\n", hdc, dc->saveLevel+1 );
442     ret = ++dc->saveLevel;
443     GDI_HEAP_UNLOCK( hdcs );
444     GDI_HEAP_UNLOCK( hdc );
445     return ret;
446 }
447
448
449 /***********************************************************************
450  *           RestoreDC16    (GDI.39)
451  */
452 BOOL16 WINAPI RestoreDC16( HDC16 hdc, INT16 level )
453 {
454     return RestoreDC( hdc, level );
455 }
456
457
458 /***********************************************************************
459  *           RestoreDC32    (GDI32.290)
460  */
461 BOOL WINAPI RestoreDC( HDC hdc, INT level )
462 {
463     DC * dc, * dcs;
464     BOOL success;
465
466     TRACE("%04x %d\n", hdc, level );
467     dc = DC_GetDCPtr( hdc );
468     if(!dc) return FALSE;
469     if(dc->funcs->pRestoreDC)
470         return dc->funcs->pRestoreDC( dc, level );
471
472     if (level == -1) level = dc->saveLevel;
473     if ((level < 1) || (level > dc->saveLevel))
474     {
475       GDI_HEAP_UNLOCK( hdc );
476       return FALSE;
477     }
478     
479     success=TRUE;
480     while (dc->saveLevel >= level)
481     {
482         HDC16 hdcs = dc->header.hNext;
483         if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC )))
484         {
485           GDI_HEAP_UNLOCK( hdc );
486           return FALSE;
487         }       
488         dc->header.hNext = dcs->header.hNext;
489         if (--dc->saveLevel < level)
490         {
491             SetDCState16( hdc, hdcs );
492             if (!PATH_AssignGdiPath( &dc->w.path, &dcs->w.path ))
493                 /* FIXME: This might not be quite right, since we're
494                  * returning FALSE but still destroying the saved DC state */
495                 success=FALSE;
496         }
497         DeleteDC( hdcs );
498     }
499     GDI_HEAP_UNLOCK( hdc );
500     return success;
501 }
502
503
504 /***********************************************************************
505  *           CreateDC16    (GDI.53)
506  */
507 HDC16 WINAPI CreateDC16( LPCSTR driver, LPCSTR device, LPCSTR output,
508                          const DEVMODEA *initData )
509 {
510     DC * dc;
511     const DC_FUNCTIONS *funcs;
512     char buf[300];
513
514     if (device) {
515         if(!DRIVER_GetDriverName( device, buf, sizeof(buf) )) return 0;
516     } else
517         strcpy(buf, driver);
518
519     if (!(funcs = DRIVER_FindDriver( buf ))) return 0;
520     if (!(dc = DC_AllocDC( funcs ))) return 0;
521     dc->w.flags = 0;
522
523     TRACE("(driver=%s, device=%s, output=%s): returning %04x\n",
524                debugstr_a(driver), debugstr_a(device), debugstr_a(output), dc->hSelf );
525
526     if (dc->funcs->pCreateDC &&
527         !dc->funcs->pCreateDC( dc, driver, device, output, initData ))
528     {
529         WARN("creation aborted by device\n" );
530         GDI_HEAP_FREE( dc->hSelf );
531         return 0;
532     }
533
534     DC_InitDC( dc );
535     GDI_HEAP_UNLOCK( dc->hSelf );
536     return dc->hSelf;
537 }
538
539
540 /***********************************************************************
541  *           CreateDC32A    (GDI32.)
542  */
543 HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
544                           const DEVMODEA *initData )
545 {
546     return CreateDC16( driver, device, output, (const DEVMODEA *)initData );
547 }
548
549
550 /***********************************************************************
551  *           CreateDC32W    (GDI32.)
552  */
553 HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
554                           const DEVMODEW *initData )
555
556     LPSTR driverA = HEAP_strdupWtoA( GetProcessHeap(), 0, driver );
557     LPSTR deviceA = HEAP_strdupWtoA( GetProcessHeap(), 0, device );
558     LPSTR outputA = HEAP_strdupWtoA( GetProcessHeap(), 0, output );
559     HDC res = CreateDC16( driverA, deviceA, outputA,
560                             (const DEVMODEA *)initData /*FIXME*/ );
561     HeapFree( GetProcessHeap(), 0, driverA );
562     HeapFree( GetProcessHeap(), 0, deviceA );
563     HeapFree( GetProcessHeap(), 0, outputA );
564     return res;
565 }
566
567
568 /***********************************************************************
569  *           CreateIC16    (GDI.153)
570  */
571 HDC16 WINAPI CreateIC16( LPCSTR driver, LPCSTR device, LPCSTR output,
572                          const DEVMODEA* initData )
573 {
574       /* Nothing special yet for ICs */
575     return CreateDC16( driver, device, output, initData );
576 }
577
578
579 /***********************************************************************
580  *           CreateIC32A    (GDI32.49)
581  */
582 HDC WINAPI CreateICA( LPCSTR driver, LPCSTR device, LPCSTR output,
583                           const DEVMODEA* initData )
584 {
585       /* Nothing special yet for ICs */
586     return CreateDCA( driver, device, output, initData );
587 }
588
589
590 /***********************************************************************
591  *           CreateIC32W    (GDI32.50)
592  */
593 HDC WINAPI CreateICW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
594                           const DEVMODEW* initData )
595 {
596       /* Nothing special yet for ICs */
597     return CreateDCW( driver, device, output, initData );
598 }
599
600
601 /***********************************************************************
602  *           CreateCompatibleDC16    (GDI.52)
603  */
604 HDC16 WINAPI CreateCompatibleDC16( HDC16 hdc )
605 {
606     return (HDC16)CreateCompatibleDC( hdc );
607 }
608
609
610 /***********************************************************************
611  *           CreateCompatibleDC32   (GDI32.31)
612  */
613 HDC WINAPI CreateCompatibleDC( HDC hdc )
614 {
615     DC *dc, *origDC;
616     HBITMAP hbitmap;
617     const DC_FUNCTIONS *funcs;
618
619     if ((origDC = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC ))) funcs = origDC->funcs;
620     else funcs = DRIVER_FindDriver( "DISPLAY" );
621     if (!funcs) return 0;
622
623     if (!(dc = DC_AllocDC( funcs ))) return 0;
624
625     TRACE("(%04x): returning %04x\n",
626                hdc, dc->hSelf );
627
628       /* Create default bitmap */
629     if (!(hbitmap = CreateBitmap( 1, 1, 1, 1, NULL )))
630     {
631         GDI_HEAP_FREE( dc->hSelf );
632         return 0;
633     }
634     dc->w.flags        = DC_MEMORY;
635     dc->w.bitsPerPixel = 1;
636     dc->w.hBitmap      = hbitmap;
637     dc->w.hFirstBitmap = hbitmap;
638
639     /* Copy the driver-specific physical device info into
640      * the new DC. The driver may use this read-only info
641      * while creating the compatible DC below. */
642     if (origDC)
643         dc->physDev = origDC->physDev;
644
645     if (dc->funcs->pCreateDC &&
646         !dc->funcs->pCreateDC( dc, NULL, NULL, NULL, NULL ))
647     {
648         WARN("creation aborted by device\n");
649         DeleteObject( hbitmap );
650         GDI_HEAP_FREE( dc->hSelf );
651         return 0;
652     }
653
654     DC_InitDC( dc );
655     GDI_HEAP_UNLOCK( dc->hSelf );
656     return dc->hSelf;
657 }
658
659
660 /***********************************************************************
661  *           DeleteDC16    (GDI.68)
662  */
663 BOOL16 WINAPI DeleteDC16( HDC16 hdc )
664 {
665     return DeleteDC( hdc );
666 }
667
668
669 /***********************************************************************
670  *           DeleteDC32    (GDI32.67)
671  */
672 BOOL WINAPI DeleteDC( HDC hdc )
673 {
674     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
675     if (!dc) return FALSE;
676
677     TRACE("%04x\n", hdc );
678
679     /* Call hook procedure to check whether is it OK to delete this DC */
680     if (    dc->hookProc && !(dc->w.flags & (DC_SAVED | DC_MEMORY))
681          && dc->hookProc( hdc, DCHC_DELETEDC, dc->dwHookData, 0 ) == FALSE )
682     {
683         GDI_HEAP_UNLOCK( hdc );
684         return FALSE;
685     }
686
687     while (dc->saveLevel)
688     {
689         DC * dcs;
690         HDC16 hdcs = dc->header.hNext;
691         if (!(dcs = (DC *) GDI_GetObjPtr( hdcs, DC_MAGIC ))) break;
692         dc->header.hNext = dcs->header.hNext;
693         dc->saveLevel--;
694         DeleteDC( hdcs );
695     }
696     
697     if (!(dc->w.flags & DC_SAVED))
698     {
699         SelectObject( hdc, STOCK_BLACK_PEN );
700         SelectObject( hdc, STOCK_WHITE_BRUSH );
701         SelectObject( hdc, STOCK_SYSTEM_FONT );
702         if (dc->w.flags & DC_MEMORY) DeleteObject( dc->w.hFirstBitmap );
703         if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc);
704     }
705
706     if (dc->w.hClipRgn) DeleteObject( dc->w.hClipRgn );
707     if (dc->w.hVisRgn) DeleteObject( dc->w.hVisRgn );
708     if (dc->w.hGCClipRgn) DeleteObject( dc->w.hGCClipRgn );
709     
710     PATH_DestroyGdiPath(&dc->w.path);
711     
712     return GDI_FreeObject( hdc );
713 }
714
715
716 /***********************************************************************
717  *           ResetDC16    (GDI.376)
718  */
719 HDC16 WINAPI ResetDC16( HDC16 hdc, const DEVMODEA *devmode )
720 {
721     FIXME("stub\n" );
722     return hdc;
723 }
724
725
726 /***********************************************************************
727  *           ResetDC32A    (GDI32.287)
728  */
729 HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
730 {
731     FIXME("stub\n" );
732     return hdc;
733 }
734
735
736 /***********************************************************************
737  *           ResetDC32W    (GDI32.288)
738  */
739 HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
740 {
741     FIXME("stub\n" );
742     return hdc;
743 }
744
745
746 /***********************************************************************
747  *           GetDeviceCaps16    (GDI.80)
748  */
749 INT16 WINAPI GetDeviceCaps16( HDC16 hdc, INT16 cap )
750 {
751     return GetDeviceCaps( hdc, cap );
752 }
753
754
755 /***********************************************************************
756  *           GetDeviceCaps32    (GDI32.171)
757  */
758 INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
759 {
760     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
761     INT ret;
762     POINT pt;
763
764     if (!dc) return 0;
765
766     /* Device capabilities for the printer */
767     switch (cap)
768     {
769     case PHYSICALWIDTH:
770         if(Escape(hdc, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0)
771             return pt.x;
772     case PHYSICALHEIGHT:
773         if(Escape(hdc, GETPHYSPAGESIZE, 0, NULL, (LPVOID)&pt) > 0)
774             return pt.y;
775     case PHYSICALOFFSETX:
776         if(Escape(hdc, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
777             return pt.x;
778     case PHYSICALOFFSETY:
779         if(Escape(hdc, GETPRINTINGOFFSET, 0, NULL, (LPVOID)&pt) > 0)
780             return pt.y;
781     case SCALINGFACTORX:
782         if(Escape(hdc, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
783             return pt.x;
784     case SCALINGFACTORY:
785         if(Escape(hdc, GETSCALINGFACTOR, 0, NULL, (LPVOID)&pt) > 0)
786             return pt.y;
787     }
788
789     if ((cap < 0) || (cap > sizeof(DeviceCaps)-sizeof(WORD)))
790     {
791       GDI_HEAP_UNLOCK( hdc );
792       return 0;
793     }
794     
795     TRACE("(%04x,%d): returning %d\n",
796             hdc, cap, *(WORD *)(((char *)dc->w.devCaps) + cap) );
797     ret = *(WORD *)(((char *)dc->w.devCaps) + cap);
798     GDI_HEAP_UNLOCK( hdc );
799     return ret;
800 }
801
802
803 /***********************************************************************
804  *           SetBkColor16    (GDI.1)
805  */
806 COLORREF WINAPI SetBkColor16( HDC16 hdc, COLORREF color )
807 {
808     return SetBkColor( hdc, color );
809 }
810
811
812 /***********************************************************************
813  *           SetBkColor32    (GDI32.305)
814  */
815 COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
816 {
817     COLORREF oldColor;
818     DC * dc = DC_GetDCPtr( hdc );
819   
820     if (!dc) return 0x80000000;
821     if (dc->funcs->pSetBkColor)
822         oldColor = dc->funcs->pSetBkColor(dc, color);
823     else {
824         oldColor = dc->w.backgroundColor;
825         dc->w.backgroundColor = color;
826     }
827     GDI_HEAP_UNLOCK( hdc );
828     return oldColor;
829 }
830
831
832 /***********************************************************************
833  *           SetTextColor16    (GDI.9)
834  */
835 COLORREF WINAPI SetTextColor16( HDC16 hdc, COLORREF color )
836 {
837     return SetTextColor( hdc, color );
838 }
839
840
841 /***********************************************************************
842  *           SetTextColor32    (GDI32.338)
843  */
844 COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
845 {
846     COLORREF oldColor;
847     DC * dc = DC_GetDCPtr( hdc );
848   
849     if (!dc) return 0x80000000;
850     if (dc->funcs->pSetTextColor)
851         oldColor = dc->funcs->pSetTextColor(dc, color);
852     else {
853         oldColor = dc->w.textColor;
854         dc->w.textColor = color;
855     }
856     GDI_HEAP_UNLOCK( hdc );
857     return oldColor;
858 }
859
860 /***********************************************************************
861  *           SetTextAlign16    (GDI.346)
862  */
863 UINT16 WINAPI SetTextAlign16( HDC16 hdc, UINT16 align )
864 {
865     return SetTextAlign( hdc, align );
866 }
867
868
869 /***********************************************************************
870  *           SetTextAlign    (GDI32.336)
871  */
872 UINT WINAPI SetTextAlign( HDC hdc, UINT align )
873 {
874     UINT prevAlign;
875     DC *dc = DC_GetDCPtr( hdc );
876     if (!dc) return 0x0;
877     if (dc->funcs->pSetTextAlign)
878         prevAlign = dc->funcs->pSetTextAlign(dc, align);
879     else {
880         prevAlign = dc->w.textAlign;
881         dc->w.textAlign = align;
882     }
883     GDI_HEAP_UNLOCK( hdc );
884     return prevAlign;
885 }
886
887 /***********************************************************************
888  *           GetDCOrgEx  (GDI32.168)
889  */
890 BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
891 {
892     DC * dc;
893
894     if (!lpp) return FALSE;
895     if (!(dc = (DC *) GDI_GetObjPtr( hDC, DC_MAGIC ))) return FALSE;
896
897 #ifndef X_DISPLAY_MISSING
898     if (!(dc->w.flags & DC_MEMORY))
899     {
900        X11DRV_PDEVICE *physDev;
901        Window root;
902        int w, h, border, depth;
903
904        physDev = (X11DRV_PDEVICE *) dc->physDev;
905
906        /* FIXME: this is not correct for managed windows */
907        TSXGetGeometry( display, physDev->drawable, &root,
908                     (int*)&lpp->x, (int*)&lpp->y, &w, &h, &border, &depth );
909     }
910     else 
911 #endif  /* !defined(X_DISPLAY_MISSING) */
912       lpp->x = lpp->y = 0;
913
914     lpp->x += dc->w.DCOrgX; lpp->y += dc->w.DCOrgY;
915     GDI_HEAP_UNLOCK( hDC );
916     return TRUE;
917 }
918
919
920 /***********************************************************************
921  *           GetDCOrg    (GDI.79)
922  */
923 DWORD WINAPI GetDCOrg16( HDC16 hdc )
924 {
925     POINT       pt;
926     if( GetDCOrgEx( hdc, &pt) )
927         return MAKELONG( (WORD)pt.x, (WORD)pt.y );    
928     return 0;
929 }
930
931
932 /***********************************************************************
933  *           SetDCOrg    (GDI.117)
934  */
935 DWORD WINAPI SetDCOrg16( HDC16 hdc, INT16 x, INT16 y )
936 {
937     DWORD prevOrg;
938     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
939     if (!dc) return 0;
940     prevOrg = dc->w.DCOrgX | (dc->w.DCOrgY << 16);
941     dc->w.DCOrgX = x;
942     dc->w.DCOrgY = y;
943     GDI_HEAP_UNLOCK( hdc );
944     return prevOrg;
945 }
946
947
948 /***********************************************************************
949  *           GetGraphicsMode    (GDI32.188)
950  */
951 INT WINAPI GetGraphicsMode( HDC hdc )
952 {
953     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
954     if (!dc) return 0;
955     return dc->w.GraphicsMode;
956 }
957
958
959 /***********************************************************************
960  *           SetGraphicsMode    (GDI32.317)
961  */
962 INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
963 {
964     INT ret;
965     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
966
967     /* One would think that setting the graphics mode to GM_COMPATIBLE
968      * would also reset the world transformation matrix to the unity
969      * matrix. However, in Windows, this is not the case. This doesn't
970      * make a lot of sense to me, but that's the way it is.
971      */
972     
973     if (!dc) return 0;
974     if ((mode <= 0) || (mode > GM_LAST)) return 0;
975     ret = dc->w.GraphicsMode;
976     dc->w.GraphicsMode = mode;
977     return ret;
978 }
979
980
981 /***********************************************************************
982  *           GetArcDirection16    (GDI.524)
983  */
984 INT16 WINAPI GetArcDirection16( HDC16 hdc )
985 {
986     return GetArcDirection( (HDC)hdc );
987 }
988
989
990 /***********************************************************************
991  *           GetArcDirection32    (GDI32.141)
992  */
993 INT WINAPI GetArcDirection( HDC hdc )
994 {
995     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
996     
997     if (!dc)
998         return 0;
999
1000     return dc->w.ArcDirection;
1001 }
1002
1003
1004 /***********************************************************************
1005  *           SetArcDirection16    (GDI.525)
1006  */
1007 INT16 WINAPI SetArcDirection16( HDC16 hdc, INT16 nDirection )
1008 {
1009     return SetArcDirection( (HDC)hdc, (INT)nDirection );
1010 }
1011
1012
1013 /***********************************************************************
1014  *           SetArcDirection32    (GDI32.302)
1015  */
1016 INT WINAPI SetArcDirection( HDC hdc, INT nDirection )
1017 {
1018     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1019     INT nOldDirection;
1020     
1021     if (!dc)
1022         return 0;
1023
1024     if (nDirection!=AD_COUNTERCLOCKWISE && nDirection!=AD_CLOCKWISE)
1025     {
1026         SetLastError(ERROR_INVALID_PARAMETER);
1027         return 0;
1028     }
1029
1030     nOldDirection = dc->w.ArcDirection;
1031     dc->w.ArcDirection = nDirection;
1032
1033     return nOldDirection;
1034 }
1035
1036
1037 /***********************************************************************
1038  *           GetWorldTransform    (GDI32.244)
1039  */
1040 BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform )
1041 {
1042     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1043     
1044     if (!dc)
1045         return FALSE;
1046     if (!xform)
1047         return FALSE;
1048
1049     *xform = dc->w.xformWorld2Wnd;
1050     
1051     return TRUE;
1052 }
1053
1054
1055 /***********************************************************************
1056  *           SetWorldTransform    (GDI32.346)
1057  */
1058 BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform )
1059 {
1060     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1061     
1062     if (!dc)
1063     {
1064         SetLastError( ERROR_INVALID_HANDLE );
1065         return FALSE;
1066     }
1067
1068     if (!xform)
1069         return FALSE;
1070     
1071     /* Check that graphics mode is GM_ADVANCED */
1072     if (dc->w.GraphicsMode!=GM_ADVANCED)
1073        return FALSE;
1074
1075     dc->w.xformWorld2Wnd = *xform;
1076     
1077     DC_UpdateXforms( dc );
1078
1079     return TRUE;
1080 }
1081
1082
1083 /****************************************************************************
1084  * ModifyWorldTransform [GDI32.253]
1085  * Modifies the world transformation for a device context.
1086  *
1087  * PARAMS
1088  *    hdc   [I] Handle to device context
1089  *    xform [I] XFORM structure that will be used to modify the world
1090  *              transformation
1091  *    iMode [I] Specifies in what way to modify the world transformation
1092  *              Possible values:
1093  *              MWT_IDENTITY
1094  *                 Resets the world transformation to the identity matrix.
1095  *                 The parameter xform is ignored.
1096  *              MWT_LEFTMULTIPLY
1097  *                 Multiplies xform into the world transformation matrix from
1098  *                 the left.
1099  *              MWT_RIGHTMULTIPLY
1100  *                 Multiplies xform into the world transformation matrix from
1101  *                 the right.
1102  *
1103  * RETURNS STD
1104  */
1105 BOOL WINAPI ModifyWorldTransform( HDC hdc, const XFORM *xform,
1106     DWORD iMode )
1107 {
1108     DC * dc = (DC *) GDI_GetObjPtr( hdc, DC_MAGIC );
1109     
1110     /* Check for illegal parameters */
1111     if (!dc)
1112     {
1113         SetLastError( ERROR_INVALID_HANDLE );
1114         return FALSE;
1115     }
1116     if (!xform)
1117         return FALSE;
1118     
1119     /* Check that graphics mode is GM_ADVANCED */
1120     if (dc->w.GraphicsMode!=GM_ADVANCED)
1121        return FALSE;
1122        
1123     switch (iMode)
1124     {
1125         case MWT_IDENTITY:
1126             dc->w.xformWorld2Wnd.eM11 = 1.0f;
1127             dc->w.xformWorld2Wnd.eM12 = 0.0f;
1128             dc->w.xformWorld2Wnd.eM21 = 0.0f;
1129             dc->w.xformWorld2Wnd.eM22 = 1.0f;
1130             dc->w.xformWorld2Wnd.eDx  = 0.0f;
1131             dc->w.xformWorld2Wnd.eDy  = 0.0f;
1132             break;
1133         case MWT_LEFTMULTIPLY:
1134             CombineTransform( &dc->w.xformWorld2Wnd, xform,
1135                 &dc->w.xformWorld2Wnd );
1136             break;
1137         case MWT_RIGHTMULTIPLY:
1138             CombineTransform( &dc->w.xformWorld2Wnd, &dc->w.xformWorld2Wnd,
1139                 xform );
1140             break;
1141         default:
1142             return FALSE;
1143     }
1144
1145     DC_UpdateXforms( dc );
1146
1147     return TRUE;
1148 }
1149
1150
1151 /****************************************************************************
1152  * CombineTransform [GDI32.20]
1153  * Combines two transformation matrices.
1154  *
1155  * PARAMS
1156  *    xformResult [O] Stores the result of combining the two matrices
1157  *    xform1      [I] Specifies the first matrix to apply
1158  *    xform2      [I] Specifies the second matrix to apply
1159  *
1160  * REMARKS
1161  *    The same matrix can be passed in for more than one of the parameters.
1162  *
1163  * RETURNS STD
1164  */
1165 BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
1166     const XFORM *xform2 )
1167 {
1168     XFORM xformTemp;
1169     
1170     /* Check for illegal parameters */
1171     if (!xformResult || !xform1 || !xform2)
1172         return FALSE;
1173
1174     /* Create the result in a temporary XFORM, since xformResult may be
1175      * equal to xform1 or xform2 */
1176     xformTemp.eM11 = xform1->eM11 * xform2->eM11 +
1177                      xform1->eM12 * xform2->eM21;
1178     xformTemp.eM12 = xform1->eM11 * xform2->eM12 +
1179                      xform1->eM12 * xform2->eM22;
1180     xformTemp.eM21 = xform1->eM21 * xform2->eM11 +
1181                      xform1->eM22 * xform2->eM21;
1182     xformTemp.eM22 = xform1->eM21 * xform2->eM12 +
1183                      xform1->eM22 * xform2->eM22;
1184     xformTemp.eDx  = xform1->eDx  * xform2->eM11 +
1185                      xform1->eDy  * xform2->eM21 +
1186                      xform2->eDx;
1187     xformTemp.eDy  = xform1->eDx  * xform2->eM12 +
1188                      xform1->eDy  * xform2->eM22 +
1189                      xform2->eDy;
1190
1191     /* Copy the result to xformResult */
1192     *xformResult = xformTemp;
1193
1194     return TRUE;
1195 }
1196
1197
1198 /***********************************************************************
1199  *           SetDCHook   (GDI.190)
1200  */
1201 BOOL16 WINAPI SetDCHook( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData )
1202 {
1203     DC *dc = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC );
1204
1205     TRACE("hookProc %08x, default is %08x\n",
1206                 (UINT)hookProc, (UINT)DCHook16 );
1207
1208     if (!dc) return FALSE;
1209     dc->hookProc = hookProc;
1210     dc->dwHookData = dwHookData;
1211     GDI_HEAP_UNLOCK( hdc );
1212     return TRUE;
1213 }
1214
1215
1216 /***********************************************************************
1217  *           GetDCHook   (GDI.191)
1218  */
1219 DWORD WINAPI GetDCHook( HDC16 hdc, FARPROC16 *phookProc )
1220 {
1221     DC *dc = (DC *)GDI_GetObjPtr( hdc, DC_MAGIC );
1222     if (!dc) return 0;
1223     *phookProc = dc->hookProc;
1224     GDI_HEAP_UNLOCK( hdc );
1225     return dc->dwHookData;
1226 }
1227
1228
1229 /***********************************************************************
1230  *           SetHookFlags       (GDI.192)
1231  */
1232 WORD WINAPI SetHookFlags16(HDC16 hDC, WORD flags)
1233 {
1234     DC* dc = (DC*)GDI_GetObjPtr( hDC, DC_MAGIC );
1235
1236     if( dc )
1237     {
1238         WORD wRet = dc->w.flags & DC_DIRTY;
1239
1240         /* "Undocumented Windows" info is slightly confusing.
1241          */
1242
1243         TRACE("hDC %04x, flags %04x\n",hDC,flags);
1244
1245         if( flags & DCHF_INVALIDATEVISRGN )
1246             dc->w.flags |= DC_DIRTY;
1247         else if( flags & DCHF_VALIDATEVISRGN || !flags )
1248             dc->w.flags &= ~DC_DIRTY;
1249         GDI_HEAP_UNLOCK( hDC );
1250         return wRet;
1251     }
1252     return 0;
1253 }
1254
1255 /***********************************************************************
1256  *           SetICMMode    (GDI32.318)
1257  */
1258 INT WINAPI SetICMMode(HDC hdc, INT iEnableICM)
1259 {
1260 /*FIXME  Asuming that ICM is always off, and cannot be turned on */
1261     if (iEnableICM == ICM_OFF) return ICM_OFF;
1262     if (iEnableICM == ICM_ON) return 0;
1263     if (iEnableICM == ICM_QUERY) return ICM_OFF;
1264     return 0;
1265 }
1266
1267
1268 /***********************************************************************
1269  *           GetColorSpace    (GDI32.165)
1270  */
1271 HCOLORSPACE WINAPI GetColorSpace(HDC hdc)
1272 {
1273 /*FIXME    Need to to whatever GetColorSpace actually does */
1274     return 0;
1275 }
1276
1277 /***********************************************************************
1278  *           GetBoundsRect16    (GDI.194)
1279  */
1280 UINT16 WINAPI GetBoundsRect16(HDC16 hdc, LPRECT16 rect, UINT16 flags)
1281 {
1282     return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
1283 }
1284
1285 /***********************************************************************
1286  *           GetBoundsRect32    (GDI32.147)
1287  */
1288 UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags)
1289 {
1290     FIXME("(): stub\n");
1291     return DCB_RESET;   /* bounding rectangle always empty */
1292 }
1293  
1294 /***********************************************************************
1295  *           SetBoundsRect16    (GDI.193)
1296  */
1297 UINT16 WINAPI SetBoundsRect16(HDC16 hdc, const RECT16* rect, UINT16 flags)
1298 {
1299     if ( (flags & DCB_ACCUMULATE) || (flags & DCB_ENABLE) )
1300         FIXME("(%04x, %p, %04x): stub\n", hdc, rect, flags );
1301
1302     return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
1303 }
1304
1305 /***********************************************************************
1306  *           SetBoundsRect32    (GDI32.307)
1307  */
1308 UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags)
1309 {
1310     FIXME("(): stub\n");
1311     return DCB_DISABLE;   /* bounding rectangle always empty */
1312 }
1313
1314 /***********************************************************************
1315  *           Death    (GDI.121)
1316  *
1317  * Disables GDI, switches back to text mode.
1318  * We don't have to do anything here,
1319  * just let console support handle everything
1320  */
1321 void WINAPI Death16(HDC16 hDC)
1322 {
1323     MESSAGE("Death(%04x) called. Application enters text mode...\n", hDC);
1324 }
1325
1326 /***********************************************************************
1327  *           Resurrection    (GDI.122)
1328  *
1329  * Restores GDI functionality
1330  */
1331 void WINAPI Resurrection16(HDC16 hDC,
1332                            WORD w1, WORD w2, WORD w3, WORD w4, WORD w5, WORD w6)
1333 {
1334     MESSAGE("Resurrection(%04x, %04x, %04x, %04x, %04x, %04x, %04x) called. Application left text mode.\n", hDC, w1, w2, w3, w4, w5, w6);
1335 }