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