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