NetpGetComputerName, SHCopyKeyA and SHRegGetPathA don't exist on all
[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 "gdi.h"
26 #include "heap.h"
27 #include "wine/debug.h"
28 #include "font.h"
29 #include "winerror.h"
30 #include "windef.h"
31 #include "wingdi.h"
32 #include "wine/winuser16.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, &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, 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     RealizeDefaultPalette16( dc->hSelf );
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   (GDI.179)
271  *           GetDCState16 (GDI32.@)
272  */
273 HDC16 WINAPI GetDCState16( HDC16 hdc )
274 {
275     DC * newdc, * dc;
276     HGDIOBJ handle;
277
278     if (!(dc = DC_GetDCPtr( hdc ))) return 0;
279     if (!(newdc = GDI_AllocObject( sizeof(DC), DC_MAGIC, &handle, &dc_funcs )))
280     {
281       GDI_ReleaseObj( hdc );
282       return 0;
283     }
284     TRACE("(%04x): returning %04x\n", hdc, handle );
285
286     newdc->flags            = dc->flags | DC_SAVED;
287     newdc->hPen             = dc->hPen;
288     newdc->hBrush           = dc->hBrush;
289     newdc->hFont            = dc->hFont;
290     newdc->hBitmap          = dc->hBitmap;
291     newdc->hDevice          = dc->hDevice;
292     newdc->hPalette         = dc->hPalette;
293     newdc->totalExtent      = dc->totalExtent;
294     newdc->bitsPerPixel     = dc->bitsPerPixel;
295     newdc->ROPmode          = dc->ROPmode;
296     newdc->polyFillMode     = dc->polyFillMode;
297     newdc->stretchBltMode   = dc->stretchBltMode;
298     newdc->relAbsMode       = dc->relAbsMode;
299     newdc->backgroundMode   = dc->backgroundMode;
300     newdc->backgroundColor  = dc->backgroundColor;
301     newdc->textColor        = dc->textColor;
302     newdc->brushOrgX        = dc->brushOrgX;
303     newdc->brushOrgY        = dc->brushOrgY;
304     newdc->textAlign        = dc->textAlign;
305     newdc->charExtra        = dc->charExtra;
306     newdc->breakTotalExtra  = dc->breakTotalExtra;
307     newdc->breakCount       = dc->breakCount;
308     newdc->breakExtra       = dc->breakExtra;
309     newdc->breakRem         = dc->breakRem;
310     newdc->MapMode          = dc->MapMode;
311     newdc->GraphicsMode     = dc->GraphicsMode;
312     newdc->CursPosX         = dc->CursPosX;
313     newdc->CursPosY         = dc->CursPosY;
314     newdc->ArcDirection     = dc->ArcDirection;
315     newdc->xformWorld2Wnd   = dc->xformWorld2Wnd;
316     newdc->xformWorld2Vport = dc->xformWorld2Vport;
317     newdc->xformVport2World = dc->xformVport2World;
318     newdc->vport2WorldValid = dc->vport2WorldValid;
319     newdc->wndOrgX          = dc->wndOrgX;
320     newdc->wndOrgY          = dc->wndOrgY;
321     newdc->wndExtX          = dc->wndExtX;
322     newdc->wndExtY          = dc->wndExtY;
323     newdc->vportOrgX        = dc->vportOrgX;
324     newdc->vportOrgY        = dc->vportOrgY;
325     newdc->vportExtX        = dc->vportExtX;
326     newdc->vportExtY        = dc->vportExtY;
327
328     newdc->hSelf = (HDC)handle;
329     newdc->saveLevel = 0;
330
331     PATH_InitGdiPath( &newdc->path );
332
333     newdc->pAbortProc = NULL;
334     newdc->hookThunk  = NULL;
335     newdc->hookProc   = 0;
336
337     /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
338
339     newdc->hGCClipRgn = newdc->hVisRgn = 0;
340     if (dc->hClipRgn)
341     {
342         newdc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
343         CombineRgn( newdc->hClipRgn, dc->hClipRgn, 0, RGN_COPY );
344     }
345     else
346         newdc->hClipRgn = 0;
347
348     if(dc->gdiFont) {
349         newdc->gdiFont = dc->gdiFont;
350     } else
351         newdc->gdiFont = 0;
352
353     GDI_ReleaseObj( handle );
354     GDI_ReleaseObj( hdc );
355     return handle;
356 }
357
358
359 /***********************************************************************
360  *           SetDCState   (GDI.180)
361  *           SetDCState16 (GDI32.@)
362  */
363 void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
364 {
365     DC *dc, *dcs;
366
367     if (!(dc = DC_GetDCUpdate( hdc ))) return;
368     if (!(dcs = DC_GetDCPtr( hdcs )))
369     {
370       GDI_ReleaseObj( hdc );
371       return;
372     }
373     if (!dcs->flags & DC_SAVED)
374     {
375       GDI_ReleaseObj( hdc );
376       GDI_ReleaseObj( hdcs );
377       return;
378     }
379     TRACE("%04x %04x\n", hdc, hdcs );
380
381     dc->flags            = dcs->flags & ~(DC_SAVED | DC_DIRTY);
382     dc->hDevice          = dcs->hDevice;
383     dc->totalExtent      = dcs->totalExtent;
384     dc->ROPmode          = dcs->ROPmode;
385     dc->polyFillMode     = dcs->polyFillMode;
386     dc->stretchBltMode   = dcs->stretchBltMode;
387     dc->relAbsMode       = dcs->relAbsMode;
388     dc->backgroundMode   = dcs->backgroundMode;
389     dc->backgroundColor  = dcs->backgroundColor;
390     dc->textColor        = dcs->textColor;
391     dc->brushOrgX        = dcs->brushOrgX;
392     dc->brushOrgY        = dcs->brushOrgY;
393     dc->textAlign        = dcs->textAlign;
394     dc->charExtra        = dcs->charExtra;
395     dc->breakTotalExtra  = dcs->breakTotalExtra;
396     dc->breakCount       = dcs->breakCount;
397     dc->breakExtra       = dcs->breakExtra;
398     dc->breakRem         = dcs->breakRem;
399     dc->MapMode          = dcs->MapMode;
400     dc->GraphicsMode     = dcs->GraphicsMode;
401     dc->CursPosX         = dcs->CursPosX;
402     dc->CursPosY         = dcs->CursPosY;
403     dc->ArcDirection     = dcs->ArcDirection;
404     dc->xformWorld2Wnd   = dcs->xformWorld2Wnd;
405     dc->xformWorld2Vport = dcs->xformWorld2Vport;
406     dc->xformVport2World = dcs->xformVport2World;
407     dc->vport2WorldValid = dcs->vport2WorldValid;
408
409     dc->wndOrgX          = dcs->wndOrgX;
410     dc->wndOrgY          = dcs->wndOrgY;
411     dc->wndExtX          = dcs->wndExtX;
412     dc->wndExtY          = dcs->wndExtY;
413     dc->vportOrgX        = dcs->vportOrgX;
414     dc->vportOrgY        = dcs->vportOrgY;
415     dc->vportExtX        = dcs->vportExtX;
416     dc->vportExtY        = dcs->vportExtY;
417
418     if (!(dc->flags & DC_MEMORY)) dc->bitsPerPixel = dcs->bitsPerPixel;
419
420     if (dcs->hClipRgn)
421     {
422         if (!dc->hClipRgn) dc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
423         CombineRgn( dc->hClipRgn, dcs->hClipRgn, 0, RGN_COPY );
424     }
425     else
426     {
427         if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
428         dc->hClipRgn = 0;
429     }
430     CLIPPING_UpdateGCRegion( dc );
431
432     SelectObject( hdc, dcs->hBitmap );
433     SelectObject( hdc, dcs->hBrush );
434     SelectObject( hdc, dcs->hFont );
435     SelectObject( hdc, dcs->hPen );
436     SetBkColor( hdc, dcs->backgroundColor);
437     SetTextColor( hdc, dcs->textColor);
438     GDISelectPalette( hdc, dcs->hPalette, FALSE );
439     GDI_ReleaseObj( hdcs );
440     GDI_ReleaseObj( hdc );
441 }
442
443
444 /***********************************************************************
445  *           SaveDC    (GDI32.@)
446  */
447 INT WINAPI SaveDC( HDC hdc )
448 {
449     HDC hdcs;
450     DC * dc, * dcs;
451     INT ret;
452
453     dc = DC_GetDCPtr( hdc );
454     if (!dc) return 0;
455
456     if(dc->funcs->pSaveDC)
457     {
458         ret = dc->funcs->pSaveDC( dc->physDev );
459         GDI_ReleaseObj( hdc );
460         return ret;
461     }
462
463     if (!(hdcs = GetDCState16( hdc )))
464     {
465       GDI_ReleaseObj( hdc );
466       return 0;
467     }
468     dcs = DC_GetDCPtr( hdcs );
469
470     /* Copy path. The reason why path saving / restoring is in SaveDC/
471      * RestoreDC and not in GetDCState/SetDCState is that the ...DCState
472      * functions are only in Win16 (which doesn't have paths) and that
473      * SetDCState doesn't allow us to signal an error (which can happen
474      * when copying paths).
475      */
476     if (!PATH_AssignGdiPath( &dcs->path, &dc->path ))
477     {
478         GDI_ReleaseObj( hdc );
479         GDI_ReleaseObj( hdcs );
480         DeleteDC( hdcs );
481         return 0;
482     }
483
484     dcs->header.hNext = dc->header.hNext;
485     dc->header.hNext = hdcs;
486     TRACE("(%04x): returning %d\n", hdc, dc->saveLevel+1 );
487     ret = ++dc->saveLevel;
488     GDI_ReleaseObj( hdcs );
489     GDI_ReleaseObj( hdc );
490     return ret;
491 }
492
493
494 /***********************************************************************
495  *           RestoreDC    (GDI32.@)
496  */
497 BOOL WINAPI RestoreDC( HDC hdc, INT level )
498 {
499     DC * dc, * dcs;
500     BOOL success;
501
502     TRACE("%04x %d\n", hdc, level );
503     dc = DC_GetDCUpdate( hdc );
504     if(!dc) return FALSE;
505     if(dc->funcs->pRestoreDC)
506     {
507         success = dc->funcs->pRestoreDC( dc->physDev, level );
508         GDI_ReleaseObj( hdc );
509         return success;
510     }
511
512     if (level == -1) level = dc->saveLevel;
513     if ((level < 1)
514             /* This pair of checks disagrees with MSDN "Platform SDK:
515                Windows GDI" July 2000 which says all negative values
516                for level will be interpreted as an instance relative
517                to the current state.  Restricting it to just -1 does
518                not satisfy this */
519         || (level > dc->saveLevel))
520     {
521         GDI_ReleaseObj( hdc );
522         return FALSE;
523     }
524
525     success=TRUE;
526     while (dc->saveLevel >= level)
527     {
528         HDC16 hdcs = dc->header.hNext;
529         if (!(dcs = DC_GetDCPtr( hdcs )))
530         {
531           GDI_ReleaseObj( hdc );
532           return FALSE;
533         }
534         dc->header.hNext = dcs->header.hNext;
535         if (--dc->saveLevel < level)
536         {
537             SetDCState16( hdc, hdcs );
538             if (!PATH_AssignGdiPath( &dc->path, &dcs->path ))
539                 /* FIXME: This might not be quite right, since we're
540                  * returning FALSE but still destroying the saved DC state */
541                 success=FALSE;
542         }
543         GDI_ReleaseObj( hdcs );
544         GDI_ReleaseObj( hdc );
545         DeleteDC( hdcs );
546         if (!(dc = DC_GetDCPtr( hdc ))) return FALSE;
547     }
548     GDI_ReleaseObj( hdc );
549     return success;
550 }
551
552
553 /***********************************************************************
554  *           CreateDCA    (GDI32.@)
555  */
556 HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
557                           const DEVMODEA *initData )
558 {
559     HDC hdc;
560     DC * dc;
561     const DC_FUNCTIONS *funcs;
562     char buf[300];
563
564     if ((!driver) && (!device))
565         return 0;
566
567     GDI_CheckNotLock();
568
569     if (!device || !DRIVER_GetDriverName( device, buf, sizeof(buf) ))
570         strcpy(buf, driver);
571
572     if (!(funcs = DRIVER_load_driver( buf )))
573     {
574         ERR( "no driver found for %s\n", buf );
575         return 0;
576     }
577     if (!(dc = DC_AllocDC( funcs )))
578     {
579         DRIVER_release_driver( funcs );
580         return 0;
581     }
582
583     dc->flags = 0;
584
585     TRACE("(driver=%s, device=%s, output=%s): returning %04x\n",
586                debugstr_a(driver), debugstr_a(device), debugstr_a(output), dc->hSelf );
587
588     if (dc->funcs->pCreateDC &&
589         !dc->funcs->pCreateDC( dc, &dc->physDev, buf, device, output, initData ))
590     {
591         WARN("creation aborted by device\n" );
592         GDI_FreeObject( dc->hSelf, dc );
593         DRIVER_release_driver( funcs );
594         return 0;
595     }
596
597     dc->totalExtent.left   = 0;
598     dc->totalExtent.top    = 0;
599     dc->totalExtent.right  = GetDeviceCaps( dc->hSelf, HORZRES );
600     dc->totalExtent.bottom = GetDeviceCaps( dc->hSelf, VERTRES );
601     dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
602
603     DC_InitDC( dc );
604     hdc = dc->hSelf;
605     GDI_ReleaseObj( hdc );
606     return hdc;
607 }
608
609
610 /***********************************************************************
611  *           CreateDCW    (GDI32.@)
612  */
613 HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
614                           const DEVMODEW *initData )
615 {
616     LPSTR driverA = HEAP_strdupWtoA( GetProcessHeap(), 0, driver );
617     LPSTR deviceA = HEAP_strdupWtoA( GetProcessHeap(), 0, device );
618     LPSTR outputA = HEAP_strdupWtoA( GetProcessHeap(), 0, output );
619     HDC res = CreateDCA( driverA, deviceA, outputA,
620                             (const DEVMODEA *)initData /*FIXME*/ );
621     HeapFree( GetProcessHeap(), 0, driverA );
622     HeapFree( GetProcessHeap(), 0, deviceA );
623     HeapFree( GetProcessHeap(), 0, outputA );
624     return res;
625 }
626
627
628 /***********************************************************************
629  *           CreateICA    (GDI32.@)
630  */
631 HDC WINAPI CreateICA( LPCSTR driver, LPCSTR device, LPCSTR output,
632                           const DEVMODEA* initData )
633 {
634       /* Nothing special yet for ICs */
635     return CreateDCA( driver, device, output, initData );
636 }
637
638
639 /***********************************************************************
640  *           CreateICW    (GDI32.@)
641  */
642 HDC WINAPI CreateICW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
643                           const DEVMODEW* initData )
644 {
645       /* Nothing special yet for ICs */
646     return CreateDCW( driver, device, output, initData );
647 }
648
649
650 /***********************************************************************
651  *           CreateCompatibleDC   (GDI32.@)
652  */
653 HDC WINAPI CreateCompatibleDC( HDC hdc )
654 {
655     DC *dc, *origDC;
656     const DC_FUNCTIONS *funcs;
657
658     GDI_CheckNotLock();
659
660     if ((origDC = GDI_GetObjPtr( hdc, DC_MAGIC )))
661     {
662         funcs = origDC->funcs;
663         GDI_ReleaseObj( hdc ); /* can't hold the lock while loading the driver */
664         funcs = DRIVER_get_driver( funcs );
665     }
666     else funcs = DRIVER_load_driver( "DISPLAY" );
667
668     if (!funcs) return 0;
669
670     if (!(dc = DC_AllocDC( funcs )))
671     {
672         DRIVER_release_driver( funcs );
673         return 0;
674     }
675
676     TRACE("(%04x): returning %04x\n",
677                hdc, dc->hSelf );
678
679     dc->flags        = DC_MEMORY;
680     dc->bitsPerPixel = 1;
681     dc->hBitmap      = GetStockObject( DEFAULT_BITMAP );
682
683     /* Copy the driver-specific physical device info into
684      * the new DC. The driver may use this read-only info
685      * while creating the compatible DC below. */
686     if ((origDC = GDI_GetObjPtr( hdc, DC_MAGIC ))) dc->physDev = origDC->physDev;
687
688     if (dc->funcs->pCreateDC &&
689         !dc->funcs->pCreateDC( dc, &dc->physDev, NULL, NULL, NULL, NULL ))
690     {
691         WARN("creation aborted by device\n");
692         GDI_FreeObject( dc->hSelf, dc );
693         if (origDC) GDI_ReleaseObj( hdc );
694         DRIVER_release_driver( funcs );
695         return 0;
696     }
697
698     dc->totalExtent.left   = 0;
699     dc->totalExtent.top    = 0;
700     dc->totalExtent.right  = 1;  /* default bitmap is 1x1 */
701     dc->totalExtent.bottom = 1;
702     dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
703
704     DC_InitDC( dc );
705     GDI_ReleaseObj( dc->hSelf );
706     if (origDC) GDI_ReleaseObj( hdc );
707     return dc->hSelf;
708 }
709
710
711 /***********************************************************************
712  *           DeleteDC    (GDI32.@)
713  */
714 BOOL WINAPI DeleteDC( HDC hdc )
715 {
716     const DC_FUNCTIONS *funcs = NULL;
717     DC * dc;
718
719     TRACE("%04x\n", hdc );
720
721     GDI_CheckNotLock();
722
723     if (!(dc = GDI_GetObjPtr( hdc, DC_MAGIC ))) return FALSE;
724
725     /* Call hook procedure to check whether is it OK to delete this DC */
726     if (dc->hookThunk && !(dc->flags & (DC_SAVED | DC_MEMORY)))
727     {
728         DCHOOKPROC proc = dc->hookThunk;
729         if (proc)
730         {
731             DWORD data = dc->dwHookData;
732             GDI_ReleaseObj( hdc );
733             if (!proc( hdc, DCHC_DELETEDC, data, 0 )) return FALSE;
734             if (!(dc = DC_GetDCPtr( hdc ))) return TRUE;  /* deleted by the hook */
735         }
736     }
737
738     while (dc->saveLevel)
739     {
740         DC * dcs;
741         HDC16 hdcs = dc->header.hNext;
742         if (!(dcs = DC_GetDCPtr( hdcs ))) break;
743         dc->header.hNext = dcs->header.hNext;
744         dc->saveLevel--;
745         if (dcs->hClipRgn) DeleteObject( dcs->hClipRgn );
746         if (dcs->hVisRgn) DeleteObject( dcs->hVisRgn );
747         if (dcs->hGCClipRgn) DeleteObject( dcs->hGCClipRgn );
748         PATH_DestroyGdiPath(&dcs->path);
749         GDI_FreeObject( hdcs, dcs );
750     }
751
752     if (!(dc->flags & DC_SAVED))
753     {
754         SelectObject( hdc, GetStockObject(BLACK_PEN) );
755         SelectObject( hdc, GetStockObject(WHITE_BRUSH) );
756         SelectObject( hdc, GetStockObject(SYSTEM_FONT) );
757         SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) );
758         funcs = dc->funcs;
759         if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc->physDev);
760         dc->physDev = NULL;
761     }
762
763     if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
764     if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
765     if (dc->hGCClipRgn) DeleteObject( dc->hGCClipRgn );
766     PATH_DestroyGdiPath(&dc->path);
767
768     GDI_FreeObject( hdc, dc );
769     if (funcs) DRIVER_release_driver( funcs );  /* do that after releasing the GDI lock */
770     return TRUE;
771 }
772
773
774 /***********************************************************************
775  *           ResetDCA    (GDI32.@)
776  */
777 HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
778 {
779     DC *dc;
780     HDC ret = hdc;
781
782     if ((dc = DC_GetDCPtr( hdc )))
783     {
784         if (dc->funcs->pResetDC) ret = dc->funcs->pResetDC( dc->physDev, devmode );
785         GDI_ReleaseObj( hdc );
786     }
787     return ret;
788 }
789
790
791 /***********************************************************************
792  *           ResetDCW    (GDI32.@)
793  */
794 HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
795 {
796     return ResetDCA(hdc, (const DEVMODEA*)devmode); /* FIXME */
797 }
798
799
800 /***********************************************************************
801  *           GetDeviceCaps    (GDI32.@)
802  */
803 INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
804 {
805     DC *dc;
806     INT ret = 0;
807
808     if ((dc = DC_GetDCPtr( hdc )))
809     {
810         if (dc->funcs->pGetDeviceCaps) ret = dc->funcs->pGetDeviceCaps( dc->physDev, cap );
811         GDI_ReleaseObj( hdc );
812     }
813     return ret;
814 }
815
816
817 /***********************************************************************
818  *           SetBkColor    (GDI32.@)
819  */
820 COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
821 {
822     COLORREF oldColor;
823     DC * dc = DC_GetDCPtr( hdc );
824
825     if (!dc) return CLR_INVALID;
826     oldColor = dc->backgroundColor;
827     if (dc->funcs->pSetBkColor)
828     {
829         color = dc->funcs->pSetBkColor(dc->physDev, color);
830         if (color == CLR_INVALID)  /* don't change it */
831         {
832             color = oldColor;
833             oldColor = CLR_INVALID;
834         }
835     }
836     dc->backgroundColor = color;
837     GDI_ReleaseObj( hdc );
838     return oldColor;
839 }
840
841
842 /***********************************************************************
843  *           SetTextColor    (GDI32.@)
844  */
845 COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
846 {
847     COLORREF oldColor;
848     DC * dc = DC_GetDCPtr( hdc );
849
850     if (!dc) return CLR_INVALID;
851     oldColor = dc->textColor;
852     if (dc->funcs->pSetTextColor)
853     {
854         color = dc->funcs->pSetTextColor(dc->physDev, color);
855         if (color == CLR_INVALID)  /* don't change it */
856         {
857             color = oldColor;
858             oldColor = CLR_INVALID;
859         }
860     }
861     dc->textColor = color;
862     GDI_ReleaseObj( hdc );
863     return oldColor;
864 }
865
866
867 /***********************************************************************
868  *           SetTextAlign    (GDI32.@)
869  */
870 UINT WINAPI SetTextAlign( HDC hdc, UINT align )
871 {
872     UINT prevAlign;
873     DC *dc = DC_GetDCPtr( hdc );
874     if (!dc) return 0x0;
875     if (dc->funcs->pSetTextAlign)
876         prevAlign = dc->funcs->pSetTextAlign(dc->physDev, align);
877     else {
878         prevAlign = dc->textAlign;
879         dc->textAlign = align;
880     }
881     GDI_ReleaseObj( hdc );
882     return prevAlign;
883 }
884
885 /***********************************************************************
886  *           GetDCOrgEx  (GDI32.@)
887  */
888 BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
889 {
890     DC * dc;
891
892     if (!lpp) return FALSE;
893     if (!(dc = DC_GetDCPtr( hDC ))) return FALSE;
894
895     lpp->x = lpp->y = 0;
896     if (dc->funcs->pGetDCOrgEx) dc->funcs->pGetDCOrgEx( dc->physDev, lpp );
897     GDI_ReleaseObj( hDC );
898     return TRUE;
899 }
900
901
902 /***********************************************************************
903  *           SetDCOrg   (GDI.117)
904  *           SetDCOrg16 (GDI32.@)
905  */
906 DWORD WINAPI SetDCOrg16( HDC16 hdc, INT16 x, INT16 y )
907 {
908     DWORD prevOrg = 0;
909     DC *dc = DC_GetDCPtr( hdc );
910     if (!dc) return 0;
911     if (dc->funcs->pSetDCOrg) prevOrg = dc->funcs->pSetDCOrg( dc->physDev, x, y );
912     GDI_ReleaseObj( hdc );
913     return prevOrg;
914 }
915
916
917 /***********************************************************************
918  *           SetGraphicsMode    (GDI32.@)
919  */
920 INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
921 {
922     INT ret = 0;
923     DC *dc = DC_GetDCPtr( hdc );
924
925     /* One would think that setting the graphics mode to GM_COMPATIBLE
926      * would also reset the world transformation matrix to the unity
927      * matrix. However, in Windows, this is not the case. This doesn't
928      * make a lot of sense to me, but that's the way it is.
929      */
930     if (!dc) return 0;
931     if ((mode > 0) || (mode <= GM_LAST))
932     {
933         ret = dc->GraphicsMode;
934         dc->GraphicsMode = mode;
935     }
936     GDI_ReleaseObj( hdc );
937     return ret;
938 }
939
940
941 /***********************************************************************
942  *           SetArcDirection    (GDI32.@)
943  */
944 INT WINAPI SetArcDirection( HDC hdc, INT nDirection )
945 {
946     DC * dc;
947     INT nOldDirection = 0;
948
949     if (nDirection!=AD_COUNTERCLOCKWISE && nDirection!=AD_CLOCKWISE)
950     {
951         SetLastError(ERROR_INVALID_PARAMETER);
952         return 0;
953     }
954
955     if ((dc = DC_GetDCPtr( hdc )))
956     {
957         nOldDirection = dc->ArcDirection;
958         dc->ArcDirection = nDirection;
959         GDI_ReleaseObj( hdc );
960     }
961     return nOldDirection;
962 }
963
964
965 /***********************************************************************
966  *           GetWorldTransform    (GDI32.@)
967  */
968 BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform )
969 {
970     DC * dc;
971     if (!xform) return FALSE;
972     if (!(dc = DC_GetDCPtr( hdc ))) return FALSE;
973     *xform = dc->xformWorld2Wnd;
974     GDI_ReleaseObj( hdc );
975     return TRUE;
976 }
977
978
979 /***********************************************************************
980  *           SetWorldTransform    (GDI32.@)
981  */
982 BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform )
983 {
984     BOOL ret = FALSE;
985     DC *dc = DC_GetDCPtr( hdc );
986
987     if (!dc) return FALSE;
988     if (!xform) goto done;
989
990     /* Check that graphics mode is GM_ADVANCED */
991     if (dc->GraphicsMode!=GM_ADVANCED) goto done;
992
993     dc->xformWorld2Wnd = *xform;
994     DC_UpdateXforms( dc );
995     ret = TRUE;
996  done:
997     GDI_ReleaseObj( hdc );
998     return ret;
999 }
1000
1001
1002 /****************************************************************************
1003  * ModifyWorldTransform [GDI32.@]
1004  * Modifies the world transformation for a device context.
1005  *
1006  * PARAMS
1007  *    hdc   [I] Handle to device context
1008  *    xform [I] XFORM structure that will be used to modify the world
1009  *              transformation
1010  *    iMode [I] Specifies in what way to modify the world transformation
1011  *              Possible values:
1012  *              MWT_IDENTITY
1013  *                 Resets the world transformation to the identity matrix.
1014  *                 The parameter xform is ignored.
1015  *              MWT_LEFTMULTIPLY
1016  *                 Multiplies xform into the world transformation matrix from
1017  *                 the left.
1018  *              MWT_RIGHTMULTIPLY
1019  *                 Multiplies xform into the world transformation matrix from
1020  *                 the right.
1021  *
1022  * RETURNS STD
1023  */
1024 BOOL WINAPI ModifyWorldTransform( HDC hdc, const XFORM *xform,
1025     DWORD iMode )
1026 {
1027     BOOL ret = FALSE;
1028     DC *dc = DC_GetDCPtr( hdc );
1029
1030     /* Check for illegal parameters */
1031     if (!dc) return FALSE;
1032     if (!xform) goto done;
1033
1034     /* Check that graphics mode is GM_ADVANCED */
1035     if (dc->GraphicsMode!=GM_ADVANCED) goto done;
1036
1037     switch (iMode)
1038     {
1039         case MWT_IDENTITY:
1040             dc->xformWorld2Wnd.eM11 = 1.0f;
1041             dc->xformWorld2Wnd.eM12 = 0.0f;
1042             dc->xformWorld2Wnd.eM21 = 0.0f;
1043             dc->xformWorld2Wnd.eM22 = 1.0f;
1044             dc->xformWorld2Wnd.eDx  = 0.0f;
1045             dc->xformWorld2Wnd.eDy  = 0.0f;
1046             break;
1047         case MWT_LEFTMULTIPLY:
1048             CombineTransform( &dc->xformWorld2Wnd, xform,
1049                 &dc->xformWorld2Wnd );
1050             break;
1051         case MWT_RIGHTMULTIPLY:
1052             CombineTransform( &dc->xformWorld2Wnd, &dc->xformWorld2Wnd,
1053                 xform );
1054             break;
1055         default:
1056             goto done;
1057     }
1058
1059     DC_UpdateXforms( dc );
1060     ret = TRUE;
1061  done:
1062     GDI_ReleaseObj( hdc );
1063     return ret;
1064 }
1065
1066
1067 /****************************************************************************
1068  * CombineTransform [GDI32.@]
1069  * Combines two transformation matrices.
1070  *
1071  * PARAMS
1072  *    xformResult [O] Stores the result of combining the two matrices
1073  *    xform1      [I] Specifies the first matrix to apply
1074  *    xform2      [I] Specifies the second matrix to apply
1075  *
1076  * REMARKS
1077  *    The same matrix can be passed in for more than one of the parameters.
1078  *
1079  * RETURNS STD
1080  */
1081 BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
1082     const XFORM *xform2 )
1083 {
1084     XFORM xformTemp;
1085
1086     /* Check for illegal parameters */
1087     if (!xformResult || !xform1 || !xform2)
1088         return FALSE;
1089
1090     /* Create the result in a temporary XFORM, since xformResult may be
1091      * equal to xform1 or xform2 */
1092     xformTemp.eM11 = xform1->eM11 * xform2->eM11 +
1093                      xform1->eM12 * xform2->eM21;
1094     xformTemp.eM12 = xform1->eM11 * xform2->eM12 +
1095                      xform1->eM12 * xform2->eM22;
1096     xformTemp.eM21 = xform1->eM21 * xform2->eM11 +
1097                      xform1->eM22 * xform2->eM21;
1098     xformTemp.eM22 = xform1->eM21 * xform2->eM12 +
1099                      xform1->eM22 * xform2->eM22;
1100     xformTemp.eDx  = xform1->eDx  * xform2->eM11 +
1101                      xform1->eDy  * xform2->eM21 +
1102                      xform2->eDx;
1103     xformTemp.eDy  = xform1->eDx  * xform2->eM12 +
1104                      xform1->eDy  * xform2->eM22 +
1105                      xform2->eDy;
1106
1107     /* Copy the result to xformResult */
1108     *xformResult = xformTemp;
1109
1110     return TRUE;
1111 }
1112
1113
1114 /***********************************************************************
1115  *           SetDCHook   (GDI32.@)
1116  *
1117  * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1118  */
1119 BOOL WINAPI SetDCHook( HDC hdc, DCHOOKPROC hookProc, DWORD dwHookData )
1120 {
1121     DC *dc = DC_GetDCPtr( hdc );
1122
1123     if (!dc) return FALSE;
1124     dc->dwHookData = dwHookData;
1125     dc->hookThunk = hookProc;
1126     GDI_ReleaseObj( hdc );
1127     return TRUE;
1128 }
1129
1130
1131 /* relay function to call the 16-bit DC hook proc */
1132 static BOOL16 WINAPI call_dc_hook16( HDC16 hdc, WORD code, DWORD data, LPARAM lParam )
1133 {
1134     FARPROC16 proc = NULL;
1135     DC *dc = DC_GetDCPtr( hdc );
1136     if (!dc) return FALSE;
1137     proc = dc->hookProc;
1138     GDI_ReleaseObj( hdc );
1139     if (!proc) return FALSE;
1140     return GDI_CallTo16_word_wwll( proc, hdc, code, data, lParam );
1141 }
1142
1143 /***********************************************************************
1144  *           SetDCHook   (GDI.190)
1145  */
1146 BOOL16 WINAPI SetDCHook16( HDC16 hdc, FARPROC16 hookProc, DWORD dwHookData )
1147 {
1148     DC *dc = DC_GetDCPtr( hdc );
1149     if (!dc) return FALSE;
1150
1151     dc->hookProc = hookProc;
1152     GDI_ReleaseObj( hdc );
1153     return SetDCHook( hdc, call_dc_hook16, dwHookData );
1154 }
1155
1156
1157 /***********************************************************************
1158  *           GetDCHook   (GDI.191)
1159  */
1160 DWORD WINAPI GetDCHook16( HDC16 hdc, FARPROC16 *phookProc )
1161 {
1162     DC *dc = DC_GetDCPtr( hdc );
1163     if (!dc) return 0;
1164     *phookProc = dc->hookProc;
1165     GDI_ReleaseObj( hdc );
1166     return dc->dwHookData;
1167 }
1168
1169
1170 /***********************************************************************
1171  *           SetHookFlags   (GDI.192)
1172  *           SetHookFlags16 (GDI32.@)
1173  */
1174 WORD WINAPI SetHookFlags16(HDC16 hDC, WORD flags)
1175 {
1176     DC *dc = DC_GetDCPtr( hDC );
1177
1178     if( dc )
1179     {
1180         WORD wRet = dc->flags & DC_DIRTY;
1181
1182         /* "Undocumented Windows" info is slightly confusing.
1183          */
1184
1185         TRACE("hDC %04x, flags %04x\n",hDC,flags);
1186
1187         if( flags & DCHF_INVALIDATEVISRGN )
1188             dc->flags |= DC_DIRTY;
1189         else if( flags & DCHF_VALIDATEVISRGN || !flags )
1190             dc->flags &= ~DC_DIRTY;
1191         GDI_ReleaseObj( hDC );
1192         return wRet;
1193     }
1194     return 0;
1195 }
1196
1197 /***********************************************************************
1198  *           SetICMMode    (GDI32.@)
1199  */
1200 INT WINAPI SetICMMode(HDC hdc, INT iEnableICM)
1201 {
1202 /*FIXME  Asuming that ICM is always off, and cannot be turned on */
1203     if (iEnableICM == ICM_OFF) return ICM_OFF;
1204     if (iEnableICM == ICM_ON) return 0;
1205     if (iEnableICM == ICM_QUERY) return ICM_OFF;
1206     return 0;
1207 }
1208
1209 /***********************************************************************
1210  *           GetDeviceGammaRamp    (GDI32.@)
1211  */
1212 BOOL WINAPI GetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1213 {
1214     BOOL ret = FALSE;
1215     DC *dc = DC_GetDCPtr( hDC );
1216
1217     if( dc )
1218     {
1219         if (dc->funcs->pGetDeviceGammaRamp)
1220             ret = dc->funcs->pGetDeviceGammaRamp(dc->physDev, ptr);
1221         GDI_ReleaseObj( hDC );
1222     }
1223     return ret;
1224 }
1225
1226 /***********************************************************************
1227  *           SetDeviceGammaRamp    (GDI32.@)
1228  */
1229 BOOL WINAPI SetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1230 {
1231     BOOL ret = FALSE;
1232     DC *dc = DC_GetDCPtr( hDC );
1233
1234     if( dc )
1235     {
1236         if (dc->funcs->pSetDeviceGammaRamp)
1237             ret = dc->funcs->pSetDeviceGammaRamp(dc->physDev, ptr);
1238         GDI_ReleaseObj( hDC );
1239     }
1240     return ret;
1241 }
1242
1243 /***********************************************************************
1244  *           GetColorSpace    (GDI32.@)
1245  */
1246 HCOLORSPACE WINAPI GetColorSpace(HDC hdc)
1247 {
1248 /*FIXME    Need to to whatever GetColorSpace actually does */
1249     return 0;
1250 }
1251
1252 /***********************************************************************
1253  *           CreateColorSpaceA    (GDI32.@)
1254  */
1255 HCOLORSPACE WINAPI CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace )
1256 {
1257   FIXME( "stub\n" );
1258   return 0;
1259 }
1260
1261 /***********************************************************************
1262  *           CreateColorSpaceW    (GDI32.@)
1263  */
1264 HCOLORSPACE WINAPI CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace )
1265 {
1266   FIXME( "stub\n" );
1267   return 0;
1268 }
1269
1270 /***********************************************************************
1271  *           DeleteColorSpace     (GDI32.@)
1272  */
1273 BOOL WINAPI DeleteColorSpace( HCOLORSPACE hColorSpace )
1274 {
1275   FIXME( "stub\n" );
1276
1277   return TRUE;
1278 }
1279
1280 /***********************************************************************
1281  *           SetColorSpace     (GDI32.@)
1282  */
1283 HCOLORSPACE WINAPI SetColorSpace( HDC hDC, HCOLORSPACE hColorSpace )
1284 {
1285   FIXME( "stub\n" );
1286
1287   return hColorSpace;
1288 }
1289
1290 /***********************************************************************
1291  *           GetBoundsRect    (GDI.194)
1292  */
1293 UINT16 WINAPI GetBoundsRect16(HDC16 hdc, LPRECT16 rect, UINT16 flags)
1294 {
1295     return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
1296 }
1297
1298 /***********************************************************************
1299  *           GetBoundsRect    (GDI32.@)
1300  */
1301 UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags)
1302 {
1303     FIXME("(): stub\n");
1304     return DCB_RESET;   /* bounding rectangle always empty */
1305 }
1306
1307 /***********************************************************************
1308  *           SetBoundsRect    (GDI.193)
1309  */
1310 UINT16 WINAPI SetBoundsRect16(HDC16 hdc, const RECT16* rect, UINT16 flags)
1311 {
1312     if ( (flags & DCB_ACCUMULATE) || (flags & DCB_ENABLE) )
1313         FIXME("(%04x, %p, %04x): stub\n", hdc, rect, flags );
1314
1315     return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
1316 }
1317
1318 /***********************************************************************
1319  *           SetBoundsRect    (GDI32.@)
1320  */
1321 UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags)
1322 {
1323     FIXME("(): stub\n");
1324     return DCB_DISABLE;   /* bounding rectangle always empty */
1325 }
1326
1327
1328 /***********************************************************************
1329  *              GetRelAbs               (GDI32.@)
1330  */
1331 INT WINAPI GetRelAbs( HDC hdc, DWORD dwIgnore )
1332 {
1333     INT ret = 0;
1334     DC *dc = DC_GetDCPtr( hdc );
1335     if (dc) ret = dc->relAbsMode;
1336     GDI_ReleaseObj( hdc );
1337     return ret;
1338 }
1339
1340 /***********************************************************************
1341  *           GetLayout    (GDI32.@)
1342  *
1343  * Gets left->right or right->left text layout flags of a dc.
1344  * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1345  *
1346  */
1347 DWORD WINAPI GetLayout(HDC hdc)
1348 {
1349     FIXME("(%08x): stub\n", hdc);
1350     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1351     return 0;
1352 }
1353
1354 /***********************************************************************
1355  *           SetLayout    (GDI32.@)
1356  *
1357  * Sets left->right or right->left text layout flags of a dc.
1358  * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1359  *
1360  */
1361 DWORD WINAPI SetLayout(HDC hdc, DWORD layout)
1362 {
1363     FIXME("(%08x,%08lx): stub\n", hdc, layout);
1364     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1365     return 0;
1366 }