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