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