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