Avoid including wine/obj_*.h files directly from C files.
[wine/multimedia.git] / objects / dc.c
blob140860049b90ec08c2eb8dabc196c073499a518d
1 /*
2 * GDI Device Context functions
4 * Copyright 1993 Alexandre Julliard
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.
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.
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
21 #include "config.h"
23 #include <stdlib.h>
24 #include <string.h>
25 #include "windef.h"
26 #include "wingdi.h"
27 #include "winternl.h"
28 #include "winerror.h"
29 #include "wownt32.h"
30 #include "wine/winuser16.h"
31 #include "gdi.h"
32 #include "heap.h"
33 #include "wine/unicode.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(dc);
38 static BOOL DC_DeleteObject( HGDIOBJ handle, void *obj );
40 static const struct gdi_obj_funcs dc_funcs =
42 NULL, /* pSelectObject */
43 NULL, /* pGetObject16 */
44 NULL, /* pGetObjectA */
45 NULL, /* pGetObjectW */
46 NULL, /* pUnrealizeObject */
47 DC_DeleteObject /* pDeleteObject */
50 /***********************************************************************
51 * DC_AllocDC
53 DC *DC_AllocDC( const DC_FUNCTIONS *funcs, WORD magic )
55 HDC hdc;
56 DC *dc;
58 if (!(dc = GDI_AllocObject( sizeof(*dc), magic, (HGDIOBJ*)&hdc, &dc_funcs ))) return NULL;
60 dc->hSelf = hdc;
61 dc->funcs = funcs;
62 dc->physDev = NULL;
63 dc->saveLevel = 0;
64 dc->dwHookData = 0;
65 dc->hookProc = NULL;
66 dc->hookThunk = NULL;
67 dc->wndOrgX = 0;
68 dc->wndOrgY = 0;
69 dc->wndExtX = 1;
70 dc->wndExtY = 1;
71 dc->vportOrgX = 0;
72 dc->vportOrgY = 0;
73 dc->vportExtX = 1;
74 dc->vportExtY = 1;
75 dc->flags = 0;
76 dc->hClipRgn = 0;
77 dc->hVisRgn = 0;
78 dc->hGCClipRgn = 0;
79 dc->hPen = GetStockObject( BLACK_PEN );
80 dc->hBrush = GetStockObject( WHITE_BRUSH );
81 dc->hFont = GetStockObject( SYSTEM_FONT );
82 dc->hBitmap = 0;
83 dc->hDevice = 0;
84 dc->hPalette = GetStockObject( DEFAULT_PALETTE );
85 dc->gdiFont = 0;
86 dc->ROPmode = R2_COPYPEN;
87 dc->polyFillMode = ALTERNATE;
88 dc->stretchBltMode = BLACKONWHITE;
89 dc->relAbsMode = ABSOLUTE;
90 dc->backgroundMode = OPAQUE;
91 dc->backgroundColor = RGB( 255, 255, 255 );
92 dc->textColor = RGB( 0, 0, 0 );
93 dc->brushOrgX = 0;
94 dc->brushOrgY = 0;
95 dc->textAlign = TA_LEFT | TA_TOP | TA_NOUPDATECP;
96 dc->charExtra = 0;
97 dc->breakTotalExtra = 0;
98 dc->breakCount = 0;
99 dc->breakExtra = 0;
100 dc->breakRem = 0;
101 dc->totalExtent.left = 0;
102 dc->totalExtent.top = 0;
103 dc->totalExtent.right = 0;
104 dc->totalExtent.bottom = 0;
105 dc->bitsPerPixel = 1;
106 dc->MapMode = MM_TEXT;
107 dc->GraphicsMode = GM_COMPATIBLE;
108 dc->pAbortProc = NULL;
109 dc->CursPosX = 0;
110 dc->CursPosY = 0;
111 dc->ArcDirection = AD_COUNTERCLOCKWISE;
112 dc->xformWorld2Wnd.eM11 = 1.0f;
113 dc->xformWorld2Wnd.eM12 = 0.0f;
114 dc->xformWorld2Wnd.eM21 = 0.0f;
115 dc->xformWorld2Wnd.eM22 = 1.0f;
116 dc->xformWorld2Wnd.eDx = 0.0f;
117 dc->xformWorld2Wnd.eDy = 0.0f;
118 dc->xformWorld2Vport = dc->xformWorld2Wnd;
119 dc->xformVport2World = dc->xformWorld2Wnd;
120 dc->vport2WorldValid = TRUE;
121 PATH_InitGdiPath(&dc->path);
122 return dc;
127 /***********************************************************************
128 * DC_GetDCPtr
130 DC *DC_GetDCPtr( HDC hdc )
132 GDIOBJHDR *ptr = GDI_GetObjPtr( hdc, MAGIC_DONTCARE );
133 if (!ptr) return NULL;
134 if ((GDIMAGIC(ptr->wMagic) == DC_MAGIC) ||
135 (GDIMAGIC(ptr->wMagic) == MEMORY_DC_MAGIC) ||
136 (GDIMAGIC(ptr->wMagic) == METAFILE_DC_MAGIC) ||
137 (GDIMAGIC(ptr->wMagic) == ENHMETAFILE_DC_MAGIC))
138 return (DC *)ptr;
139 GDI_ReleaseObj( hdc );
140 SetLastError( ERROR_INVALID_HANDLE );
141 return NULL;
144 /***********************************************************************
145 * DC_GetDCUpdate
147 * Retrieve a DC ptr while making sure the visRgn is updated.
148 * This function may call up to USER so the GDI lock should _not_
149 * be held when calling it.
151 DC *DC_GetDCUpdate( HDC hdc )
153 DC *dc = DC_GetDCPtr( hdc );
154 if (!dc) return NULL;
155 while (dc->flags & DC_DIRTY)
157 DCHOOKPROC proc = dc->hookThunk;
158 dc->flags &= ~DC_DIRTY;
159 if (proc)
161 DWORD data = dc->dwHookData;
162 GDI_ReleaseObj( hdc );
163 proc( HDC_16(hdc), DCHC_INVALIDVISRGN, data, 0 );
164 if (!(dc = DC_GetDCPtr( hdc ))) break;
165 /* otherwise restart the loop in case it became dirty again in the meantime */
168 return dc;
172 /***********************************************************************
173 * DC_DeleteObject
175 static BOOL DC_DeleteObject( HGDIOBJ handle, void *obj )
177 GDI_ReleaseObj( handle );
178 return DeleteDC( handle );
182 /***********************************************************************
183 * DC_InitDC
185 * Setup device-specific DC values for a newly created DC.
187 void DC_InitDC( DC* dc )
189 if (dc->funcs->pRealizeDefaultPalette) dc->funcs->pRealizeDefaultPalette( dc->physDev );
190 SetTextColor( dc->hSelf, dc->textColor );
191 SetBkColor( dc->hSelf, dc->backgroundColor );
192 SelectObject( dc->hSelf, dc->hPen );
193 SelectObject( dc->hSelf, dc->hBrush );
194 SelectObject( dc->hSelf, dc->hFont );
195 CLIPPING_UpdateGCRegion( dc );
199 /***********************************************************************
200 * DC_InvertXform
202 * Computes the inverse of the transformation xformSrc and stores it to
203 * xformDest. Returns TRUE if successful or FALSE if the xformSrc matrix
204 * is singular.
206 static BOOL DC_InvertXform( const XFORM *xformSrc, XFORM *xformDest )
208 FLOAT determinant;
210 determinant = xformSrc->eM11*xformSrc->eM22 -
211 xformSrc->eM12*xformSrc->eM21;
212 if (determinant > -1e-12 && determinant < 1e-12)
213 return FALSE;
215 xformDest->eM11 = xformSrc->eM22 / determinant;
216 xformDest->eM12 = -xformSrc->eM12 / determinant;
217 xformDest->eM21 = -xformSrc->eM21 / determinant;
218 xformDest->eM22 = xformSrc->eM11 / determinant;
219 xformDest->eDx = -xformSrc->eDx * xformDest->eM11 -
220 xformSrc->eDy * xformDest->eM21;
221 xformDest->eDy = -xformSrc->eDx * xformDest->eM12 -
222 xformSrc->eDy * xformDest->eM22;
224 return TRUE;
228 /***********************************************************************
229 * DC_UpdateXforms
231 * Updates the xformWorld2Vport, xformVport2World and vport2WorldValid
232 * fields of the specified DC by creating a transformation that
233 * represents the current mapping mode and combining it with the DC's
234 * world transform. This function should be called whenever the
235 * parameters associated with the mapping mode (window and viewport
236 * extents and origins) or the world transform change.
238 void DC_UpdateXforms( DC *dc )
240 XFORM xformWnd2Vport;
241 FLOAT scaleX, scaleY;
243 /* Construct a transformation to do the window-to-viewport conversion */
244 scaleX = (FLOAT)dc->vportExtX / (FLOAT)dc->wndExtX;
245 scaleY = (FLOAT)dc->vportExtY / (FLOAT)dc->wndExtY;
246 xformWnd2Vport.eM11 = scaleX;
247 xformWnd2Vport.eM12 = 0.0;
248 xformWnd2Vport.eM21 = 0.0;
249 xformWnd2Vport.eM22 = scaleY;
250 xformWnd2Vport.eDx = (FLOAT)dc->vportOrgX -
251 scaleX * (FLOAT)dc->wndOrgX;
252 xformWnd2Vport.eDy = (FLOAT)dc->vportOrgY -
253 scaleY * (FLOAT)dc->wndOrgY;
255 /* Combine with the world transformation */
256 CombineTransform( &dc->xformWorld2Vport, &dc->xformWorld2Wnd,
257 &xformWnd2Vport );
259 /* Create inverse of world-to-viewport transformation */
260 dc->vport2WorldValid = DC_InvertXform( &dc->xformWorld2Vport,
261 &dc->xformVport2World );
263 /* Reselect the font back into the dc so that the font size
264 gets updated. */
265 SelectObject(dc->hSelf, GetCurrentObject(dc->hSelf, OBJ_FONT));
269 /***********************************************************************
270 * GetDCState (Not a Windows API)
272 HDC WINAPI GetDCState( HDC hdc )
274 DC * newdc, * dc;
275 HGDIOBJ handle;
277 if (!(dc = DC_GetDCPtr( hdc ))) return 0;
278 if (!(newdc = GDI_AllocObject( sizeof(DC), GDIMAGIC(dc->header.wMagic), &handle, &dc_funcs )))
280 GDI_ReleaseObj( hdc );
281 return 0;
283 TRACE("(%p): returning %p\n", hdc, handle );
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;
327 newdc->hSelf = (HDC)handle;
328 newdc->saveLevel = 0;
330 PATH_InitGdiPath( &newdc->path );
332 newdc->pAbortProc = NULL;
333 newdc->hookThunk = NULL;
334 newdc->hookProc = 0;
336 /* Get/SetDCState() don't change hVisRgn field ("Undoc. Windows" p.559). */
338 newdc->hGCClipRgn = newdc->hVisRgn = 0;
339 if (dc->hClipRgn)
341 newdc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
342 CombineRgn( newdc->hClipRgn, dc->hClipRgn, 0, RGN_COPY );
344 else
345 newdc->hClipRgn = 0;
347 if(dc->gdiFont) {
348 newdc->gdiFont = dc->gdiFont;
349 } else
350 newdc->gdiFont = 0;
352 GDI_ReleaseObj( handle );
353 GDI_ReleaseObj( hdc );
354 return handle;
358 /***********************************************************************
359 * SetDCState (Not a Windows API)
361 void WINAPI SetDCState( HDC hdc, HDC hdcs )
363 DC *dc, *dcs;
365 if (!(dc = DC_GetDCUpdate( hdc ))) return;
366 if (!(dcs = DC_GetDCPtr( hdcs )))
368 GDI_ReleaseObj( hdc );
369 return;
371 if (!dcs->flags & DC_SAVED)
373 GDI_ReleaseObj( hdc );
374 GDI_ReleaseObj( hdcs );
375 return;
377 TRACE("%p %p\n", hdc, hdcs );
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;
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;
416 if (GDIMAGIC(dc->header.wMagic) != MEMORY_DC_MAGIC) dc->bitsPerPixel = dcs->bitsPerPixel;
418 if (dcs->hClipRgn)
420 if (!dc->hClipRgn) dc->hClipRgn = CreateRectRgn( 0, 0, 0, 0 );
421 CombineRgn( dc->hClipRgn, dcs->hClipRgn, 0, RGN_COPY );
423 else
425 if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
426 dc->hClipRgn = 0;
428 CLIPPING_UpdateGCRegion( dc );
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 );
442 /***********************************************************************
443 * GetDCState (GDI.179)
445 HDC16 WINAPI GetDCState16( HDC16 hdc )
447 return HDC_16( GetDCState( HDC_32(hdc) ));
451 /***********************************************************************
452 * SetDCState (GDI.180)
454 void WINAPI SetDCState16( HDC16 hdc, HDC16 hdcs )
456 SetDCState( HDC_32(hdc), HDC_32(hdcs) );
460 /***********************************************************************
461 * SaveDC (GDI32.@)
463 INT WINAPI SaveDC( HDC hdc )
465 HDC hdcs;
466 DC * dc, * dcs;
467 INT ret;
469 dc = DC_GetDCPtr( hdc );
470 if (!dc) return 0;
472 if(dc->funcs->pSaveDC)
474 ret = dc->funcs->pSaveDC( dc->physDev );
475 GDI_ReleaseObj( hdc );
476 return ret;
479 if (!(hdcs = GetDCState( hdc )))
481 GDI_ReleaseObj( hdc );
482 return 0;
484 dcs = DC_GetDCPtr( hdcs );
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).
492 if (!PATH_AssignGdiPath( &dcs->path, &dc->path ))
494 GDI_ReleaseObj( hdc );
495 GDI_ReleaseObj( hdcs );
496 DeleteDC( hdcs );
497 return 0;
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;
510 /***********************************************************************
511 * RestoreDC (GDI32.@)
513 BOOL WINAPI RestoreDC( HDC hdc, INT level )
515 DC * dc, * dcs;
516 BOOL success;
518 TRACE("%p %d\n", hdc, level );
519 dc = DC_GetDCUpdate( hdc );
520 if(!dc) return FALSE;
521 if(dc->funcs->pRestoreDC)
523 success = dc->funcs->pRestoreDC( dc->physDev, level );
524 GDI_ReleaseObj( hdc );
525 return success;
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))
537 GDI_ReleaseObj( hdc );
538 return FALSE;
541 success=TRUE;
542 while (dc->saveLevel >= level)
544 HDC hdcs = HDC_32(dc->header.hNext);
545 if (!(dcs = DC_GetDCPtr( hdcs )))
547 GDI_ReleaseObj( hdc );
548 return FALSE;
550 dc->header.hNext = dcs->header.hNext;
551 if (--dc->saveLevel < level)
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;
559 GDI_ReleaseObj( hdcs );
560 GDI_ReleaseObj( hdc );
561 DeleteDC( hdcs );
562 if (!(dc = DC_GetDCPtr( hdc ))) return FALSE;
564 GDI_ReleaseObj( hdc );
565 return success;
569 /***********************************************************************
570 * CreateDCW (GDI32.@)
572 HDC WINAPI CreateDCW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
573 const DEVMODEW *initData )
575 HDC hdc;
576 DC * dc;
577 const DC_FUNCTIONS *funcs;
578 WCHAR buf[300];
580 GDI_CheckNotLock();
582 if (!device || !DRIVER_GetDriverName( device, buf, 300 ))
584 if (!driver) return 0;
585 strcpyW(buf, driver);
588 if (!(funcs = DRIVER_load_driver( buf )))
590 ERR( "no driver found for %s\n", debugstr_w(buf) );
591 return 0;
593 if (!(dc = DC_AllocDC( funcs, DC_MAGIC )))
595 DRIVER_release_driver( funcs );
596 return 0;
599 dc->hBitmap = GetStockObject( DEFAULT_BITMAP );
601 TRACE("(driver=%s, device=%s, output=%s): returning %p\n",
602 debugstr_w(driver), debugstr_w(device), debugstr_w(output), dc->hSelf );
604 if (dc->funcs->pCreateDC &&
605 !dc->funcs->pCreateDC( dc, &dc->physDev, buf, device, output, initData ))
607 WARN("creation aborted by device\n" );
608 GDI_FreeObject( dc->hSelf, dc );
609 DRIVER_release_driver( funcs );
610 return 0;
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 );
619 DC_InitDC( dc );
620 hdc = dc->hSelf;
621 GDI_ReleaseObj( hdc );
622 return hdc;
626 /***********************************************************************
627 * CreateDCA (GDI32.@)
629 HDC WINAPI CreateDCA( LPCSTR driver, LPCSTR device, LPCSTR output,
630 const DEVMODEA *initData )
632 UNICODE_STRING driverW, deviceW, outputW;
633 DEVMODEW *initDataW;
634 HDC ret;
636 if (driver) RtlCreateUnicodeStringFromAsciiz(&driverW, driver);
637 else driverW.Buffer = NULL;
639 if (device) RtlCreateUnicodeStringFromAsciiz(&deviceW, device);
640 else deviceW.Buffer = NULL;
642 if (output) RtlCreateUnicodeStringFromAsciiz(&outputW, output);
643 else outputW.Buffer = NULL;
645 if (initData) initDataW = GdiConvertToDevmodeW(initData);
646 else initDataW = NULL;
648 ret = CreateDCW( driverW.Buffer, deviceW.Buffer, outputW.Buffer, initDataW );
650 RtlFreeUnicodeString(&driverW);
651 RtlFreeUnicodeString(&deviceW);
652 RtlFreeUnicodeString(&outputW);
653 if (initDataW) HeapFree(GetProcessHeap(), 0, initDataW);
654 return ret;
658 /***********************************************************************
659 * CreateICA (GDI32.@)
661 HDC WINAPI CreateICA( LPCSTR driver, LPCSTR device, LPCSTR output,
662 const DEVMODEA* initData )
664 /* Nothing special yet for ICs */
665 return CreateDCA( driver, device, output, initData );
669 /***********************************************************************
670 * CreateICW (GDI32.@)
672 HDC WINAPI CreateICW( LPCWSTR driver, LPCWSTR device, LPCWSTR output,
673 const DEVMODEW* initData )
675 /* Nothing special yet for ICs */
676 return CreateDCW( driver, device, output, initData );
680 /***********************************************************************
681 * CreateCompatibleDC (GDI32.@)
683 HDC WINAPI CreateCompatibleDC( HDC hdc )
685 DC *dc, *origDC;
686 const DC_FUNCTIONS *funcs;
687 PHYSDEV physDev;
689 GDI_CheckNotLock();
691 if ((origDC = GDI_GetObjPtr( hdc, DC_MAGIC )))
693 funcs = origDC->funcs;
694 physDev = origDC->physDev;
695 GDI_ReleaseObj( hdc ); /* can't hold the lock while loading the driver */
696 funcs = DRIVER_get_driver( funcs );
698 else
700 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
701 funcs = DRIVER_load_driver( displayW );
702 physDev = NULL;
705 if (!funcs) return 0;
707 if (!(dc = DC_AllocDC( funcs, MEMORY_DC_MAGIC )))
709 DRIVER_release_driver( funcs );
710 return 0;
713 TRACE("(%p): returning %p\n", hdc, dc->hSelf );
715 dc->bitsPerPixel = 1;
716 dc->hBitmap = GetStockObject( DEFAULT_BITMAP );
718 /* Copy the driver-specific physical device info into
719 * the new DC. The driver may use this read-only info
720 * while creating the compatible DC below. */
721 dc->physDev = physDev;
723 if (dc->funcs->pCreateDC &&
724 !dc->funcs->pCreateDC( dc, &dc->physDev, NULL, NULL, NULL, NULL ))
726 WARN("creation aborted by device\n");
727 GDI_FreeObject( dc->hSelf, dc );
728 DRIVER_release_driver( funcs );
729 return 0;
732 dc->totalExtent.left = 0;
733 dc->totalExtent.top = 0;
734 dc->totalExtent.right = 1; /* default bitmap is 1x1 */
735 dc->totalExtent.bottom = 1;
736 dc->hVisRgn = CreateRectRgnIndirect( &dc->totalExtent );
738 DC_InitDC( dc );
739 GDI_ReleaseObj( dc->hSelf );
740 return dc->hSelf;
744 /***********************************************************************
745 * DeleteDC (GDI32.@)
747 BOOL WINAPI DeleteDC( HDC hdc )
749 const DC_FUNCTIONS *funcs = NULL;
750 DC * dc;
752 TRACE("%p\n", hdc );
754 GDI_CheckNotLock();
756 if (!(dc = DC_GetDCPtr( hdc ))) return FALSE;
758 /* Call hook procedure to check whether is it OK to delete this DC */
759 if (dc->hookThunk)
761 DCHOOKPROC proc = dc->hookThunk;
762 DWORD data = dc->dwHookData;
763 GDI_ReleaseObj( hdc );
764 if (!proc( HDC_16(hdc), DCHC_DELETEDC, data, 0 )) return FALSE;
765 if (!(dc = DC_GetDCPtr( hdc ))) return TRUE; /* deleted by the hook */
768 while (dc->saveLevel)
770 DC * dcs;
771 HDC hdcs = HDC_32(dc->header.hNext);
772 if (!(dcs = DC_GetDCPtr( hdcs ))) break;
773 dc->header.hNext = dcs->header.hNext;
774 dc->saveLevel--;
775 if (dcs->hClipRgn) DeleteObject( dcs->hClipRgn );
776 if (dcs->hVisRgn) DeleteObject( dcs->hVisRgn );
777 if (dcs->hGCClipRgn) DeleteObject( dcs->hGCClipRgn );
778 PATH_DestroyGdiPath(&dcs->path);
779 GDI_FreeObject( hdcs, dcs );
782 if (!(dc->flags & DC_SAVED))
784 SelectObject( hdc, GetStockObject(BLACK_PEN) );
785 SelectObject( hdc, GetStockObject(WHITE_BRUSH) );
786 SelectObject( hdc, GetStockObject(SYSTEM_FONT) );
787 SelectObject( hdc, GetStockObject(DEFAULT_BITMAP) );
788 funcs = dc->funcs;
789 if (dc->funcs->pDeleteDC) dc->funcs->pDeleteDC(dc->physDev);
790 dc->physDev = NULL;
793 if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
794 if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
795 if (dc->hGCClipRgn) DeleteObject( dc->hGCClipRgn );
796 PATH_DestroyGdiPath(&dc->path);
798 GDI_FreeObject( hdc, dc );
799 if (funcs) DRIVER_release_driver( funcs ); /* do that after releasing the GDI lock */
800 return TRUE;
804 /***********************************************************************
805 * ResetDCA (GDI32.@)
807 HDC WINAPI ResetDCA( HDC hdc, const DEVMODEA *devmode )
809 DC *dc;
810 HDC ret = hdc;
812 if ((dc = DC_GetDCPtr( hdc )))
814 if (dc->funcs->pResetDC) ret = dc->funcs->pResetDC( dc->physDev, devmode );
815 GDI_ReleaseObj( hdc );
817 return ret;
821 /***********************************************************************
822 * ResetDCW (GDI32.@)
824 HDC WINAPI ResetDCW( HDC hdc, const DEVMODEW *devmode )
826 return ResetDCA(hdc, (const DEVMODEA*)devmode); /* FIXME */
830 /***********************************************************************
831 * GetDeviceCaps (GDI32.@)
833 INT WINAPI GetDeviceCaps( HDC hdc, INT cap )
835 DC *dc;
836 INT ret = 0;
838 if ((dc = DC_GetDCPtr( hdc )))
840 if (dc->funcs->pGetDeviceCaps) ret = dc->funcs->pGetDeviceCaps( dc->physDev, cap );
841 GDI_ReleaseObj( hdc );
843 return ret;
847 /***********************************************************************
848 * SetBkColor (GDI32.@)
850 COLORREF WINAPI SetBkColor( HDC hdc, COLORREF color )
852 COLORREF oldColor;
853 DC * dc = DC_GetDCPtr( hdc );
855 if (!dc) return CLR_INVALID;
856 oldColor = dc->backgroundColor;
857 if (dc->funcs->pSetBkColor)
859 color = dc->funcs->pSetBkColor(dc->physDev, color);
860 if (color == CLR_INVALID) /* don't change it */
862 color = oldColor;
863 oldColor = CLR_INVALID;
866 dc->backgroundColor = color;
867 GDI_ReleaseObj( hdc );
868 return oldColor;
872 /***********************************************************************
873 * SetTextColor (GDI32.@)
875 COLORREF WINAPI SetTextColor( HDC hdc, COLORREF color )
877 COLORREF oldColor;
878 DC * dc = DC_GetDCPtr( hdc );
880 if (!dc) return CLR_INVALID;
881 oldColor = dc->textColor;
882 if (dc->funcs->pSetTextColor)
884 color = dc->funcs->pSetTextColor(dc->physDev, color);
885 if (color == CLR_INVALID) /* don't change it */
887 color = oldColor;
888 oldColor = CLR_INVALID;
891 dc->textColor = color;
892 GDI_ReleaseObj( hdc );
893 return oldColor;
897 /***********************************************************************
898 * SetTextAlign (GDI32.@)
900 UINT WINAPI SetTextAlign( HDC hdc, UINT align )
902 UINT prevAlign;
903 DC *dc = DC_GetDCPtr( hdc );
904 if (!dc) return 0x0;
905 if (dc->funcs->pSetTextAlign)
906 prevAlign = dc->funcs->pSetTextAlign(dc->physDev, align);
907 else {
908 prevAlign = dc->textAlign;
909 dc->textAlign = align;
911 GDI_ReleaseObj( hdc );
912 return prevAlign;
915 /***********************************************************************
916 * GetDCOrgEx (GDI32.@)
918 BOOL WINAPI GetDCOrgEx( HDC hDC, LPPOINT lpp )
920 DC * dc;
922 if (!lpp) return FALSE;
923 if (!(dc = DC_GetDCPtr( hDC ))) return FALSE;
925 lpp->x = lpp->y = 0;
926 if (dc->funcs->pGetDCOrgEx) dc->funcs->pGetDCOrgEx( dc->physDev, lpp );
927 GDI_ReleaseObj( hDC );
928 return TRUE;
932 /***********************************************************************
933 * SetDCOrg (GDI.117)
935 DWORD WINAPI SetDCOrg16( HDC16 hdc16, INT16 x, INT16 y )
937 DWORD prevOrg = 0;
938 HDC hdc = HDC_32( hdc16 );
939 DC *dc = DC_GetDCPtr( hdc );
940 if (!dc) return 0;
941 if (dc->funcs->pSetDCOrg) prevOrg = dc->funcs->pSetDCOrg( dc->physDev, x, y );
942 GDI_ReleaseObj( hdc );
943 return prevOrg;
947 /***********************************************************************
948 * SetGraphicsMode (GDI32.@)
950 INT WINAPI SetGraphicsMode( HDC hdc, INT mode )
952 INT ret = 0;
953 DC *dc = DC_GetDCPtr( hdc );
955 /* One would think that setting the graphics mode to GM_COMPATIBLE
956 * would also reset the world transformation matrix to the unity
957 * matrix. However, in Windows, this is not the case. This doesn't
958 * make a lot of sense to me, but that's the way it is.
960 if (!dc) return 0;
961 if ((mode > 0) && (mode <= GM_LAST))
963 ret = dc->GraphicsMode;
964 dc->GraphicsMode = mode;
966 GDI_ReleaseObj( hdc );
967 return ret;
971 /***********************************************************************
972 * SetArcDirection (GDI32.@)
974 INT WINAPI SetArcDirection( HDC hdc, INT nDirection )
976 DC * dc;
977 INT nOldDirection = 0;
979 if (nDirection!=AD_COUNTERCLOCKWISE && nDirection!=AD_CLOCKWISE)
981 SetLastError(ERROR_INVALID_PARAMETER);
982 return 0;
985 if ((dc = DC_GetDCPtr( hdc )))
987 nOldDirection = dc->ArcDirection;
988 dc->ArcDirection = nDirection;
989 GDI_ReleaseObj( hdc );
991 return nOldDirection;
995 /***********************************************************************
996 * GetWorldTransform (GDI32.@)
998 BOOL WINAPI GetWorldTransform( HDC hdc, LPXFORM xform )
1000 DC * dc;
1001 if (!xform) return FALSE;
1002 if (!(dc = DC_GetDCPtr( hdc ))) return FALSE;
1003 *xform = dc->xformWorld2Wnd;
1004 GDI_ReleaseObj( hdc );
1005 return TRUE;
1009 /***********************************************************************
1010 * GetTransform (GDI32.@)
1012 BOOL WINAPI GetTransform( HDC hdc, DWORD unknown, LPXFORM xform )
1014 if (unknown == 0x0203) return GetWorldTransform( hdc, xform );
1015 ERR("stub: don't know what to do for code %lx\n", unknown );
1016 return FALSE;
1020 /***********************************************************************
1021 * SetWorldTransform (GDI32.@)
1023 BOOL WINAPI SetWorldTransform( HDC hdc, const XFORM *xform )
1025 BOOL ret = FALSE;
1026 DC *dc = DC_GetDCPtr( hdc );
1028 if (!dc) return FALSE;
1029 if (!xform) goto done;
1031 /* Check that graphics mode is GM_ADVANCED */
1032 if (dc->GraphicsMode!=GM_ADVANCED) goto done;
1034 if (dc->funcs->pSetWorldTransform)
1036 ret = dc->funcs->pSetWorldTransform(dc->physDev, xform);
1037 if (!ret) goto done;
1040 dc->xformWorld2Wnd = *xform;
1041 DC_UpdateXforms( dc );
1042 ret = TRUE;
1043 done:
1044 GDI_ReleaseObj( hdc );
1045 return ret;
1049 /****************************************************************************
1050 * ModifyWorldTransform [GDI32.@]
1051 * Modifies the world transformation for a device context.
1053 * PARAMS
1054 * hdc [I] Handle to device context
1055 * xform [I] XFORM structure that will be used to modify the world
1056 * transformation
1057 * iMode [I] Specifies in what way to modify the world transformation
1058 * Possible values:
1059 * MWT_IDENTITY
1060 * Resets the world transformation to the identity matrix.
1061 * The parameter xform is ignored.
1062 * MWT_LEFTMULTIPLY
1063 * Multiplies xform into the world transformation matrix from
1064 * the left.
1065 * MWT_RIGHTMULTIPLY
1066 * Multiplies xform into the world transformation matrix from
1067 * the right.
1069 * RETURNS STD
1071 BOOL WINAPI ModifyWorldTransform( HDC hdc, const XFORM *xform,
1072 DWORD iMode )
1074 BOOL ret = FALSE;
1075 DC *dc = DC_GetDCPtr( hdc );
1077 /* Check for illegal parameters */
1078 if (!dc) return FALSE;
1079 if (!xform) goto done;
1081 /* Check that graphics mode is GM_ADVANCED */
1082 if (dc->GraphicsMode!=GM_ADVANCED) goto done;
1084 if (dc->funcs->pModifyWorldTransform)
1086 ret = dc->funcs->pModifyWorldTransform(dc->physDev, xform, iMode);
1087 if (!ret) goto done;
1090 switch (iMode)
1092 case MWT_IDENTITY:
1093 dc->xformWorld2Wnd.eM11 = 1.0f;
1094 dc->xformWorld2Wnd.eM12 = 0.0f;
1095 dc->xformWorld2Wnd.eM21 = 0.0f;
1096 dc->xformWorld2Wnd.eM22 = 1.0f;
1097 dc->xformWorld2Wnd.eDx = 0.0f;
1098 dc->xformWorld2Wnd.eDy = 0.0f;
1099 break;
1100 case MWT_LEFTMULTIPLY:
1101 CombineTransform( &dc->xformWorld2Wnd, xform,
1102 &dc->xformWorld2Wnd );
1103 break;
1104 case MWT_RIGHTMULTIPLY:
1105 CombineTransform( &dc->xformWorld2Wnd, &dc->xformWorld2Wnd,
1106 xform );
1107 break;
1108 default:
1109 goto done;
1112 DC_UpdateXforms( dc );
1113 ret = TRUE;
1114 done:
1115 GDI_ReleaseObj( hdc );
1116 return ret;
1120 /****************************************************************************
1121 * CombineTransform [GDI32.@]
1122 * Combines two transformation matrices.
1124 * PARAMS
1125 * xformResult [O] Stores the result of combining the two matrices
1126 * xform1 [I] Specifies the first matrix to apply
1127 * xform2 [I] Specifies the second matrix to apply
1129 * REMARKS
1130 * The same matrix can be passed in for more than one of the parameters.
1132 * RETURNS STD
1134 BOOL WINAPI CombineTransform( LPXFORM xformResult, const XFORM *xform1,
1135 const XFORM *xform2 )
1137 XFORM xformTemp;
1139 /* Check for illegal parameters */
1140 if (!xformResult || !xform1 || !xform2)
1141 return FALSE;
1143 /* Create the result in a temporary XFORM, since xformResult may be
1144 * equal to xform1 or xform2 */
1145 xformTemp.eM11 = xform1->eM11 * xform2->eM11 +
1146 xform1->eM12 * xform2->eM21;
1147 xformTemp.eM12 = xform1->eM11 * xform2->eM12 +
1148 xform1->eM12 * xform2->eM22;
1149 xformTemp.eM21 = xform1->eM21 * xform2->eM11 +
1150 xform1->eM22 * xform2->eM21;
1151 xformTemp.eM22 = xform1->eM21 * xform2->eM12 +
1152 xform1->eM22 * xform2->eM22;
1153 xformTemp.eDx = xform1->eDx * xform2->eM11 +
1154 xform1->eDy * xform2->eM21 +
1155 xform2->eDx;
1156 xformTemp.eDy = xform1->eDx * xform2->eM12 +
1157 xform1->eDy * xform2->eM22 +
1158 xform2->eDy;
1160 /* Copy the result to xformResult */
1161 *xformResult = xformTemp;
1163 return TRUE;
1167 /***********************************************************************
1168 * SetDCHook (GDI32.@)
1170 * Note: this doesn't exist in Win32, we add it here because user32 needs it.
1172 BOOL WINAPI SetDCHook( HDC hdc, DCHOOKPROC hookProc, DWORD dwHookData )
1174 DC *dc = GDI_GetObjPtr( hdc, DC_MAGIC );
1176 if (!dc) return FALSE;
1178 if (!(dc->flags & DC_SAVED))
1180 dc->dwHookData = dwHookData;
1181 dc->hookThunk = hookProc;
1183 GDI_ReleaseObj( hdc );
1184 return TRUE;
1188 /* relay function to call the 16-bit DC hook proc */
1189 static BOOL16 WINAPI call_dc_hook16( HDC16 hdc16, WORD code, DWORD data, LPARAM lParam )
1191 WORD args[6];
1192 DWORD ret;
1193 FARPROC16 proc = NULL;
1194 HDC hdc = HDC_32( hdc16 );
1195 DC *dc = DC_GetDCPtr( hdc );
1197 if (!dc) return FALSE;
1198 proc = dc->hookProc;
1199 GDI_ReleaseObj( hdc );
1200 if (!proc) return FALSE;
1201 args[5] = hdc16;
1202 args[4] = code;
1203 args[3] = HIWORD(data);
1204 args[2] = LOWORD(data);
1205 args[1] = HIWORD(lParam);
1206 args[0] = LOWORD(lParam);
1207 WOWCallback16Ex( (DWORD)proc, WCB16_PASCAL, sizeof(args), args, &ret );
1208 return LOWORD(ret);
1211 /***********************************************************************
1212 * SetDCHook (GDI.190)
1214 BOOL16 WINAPI SetDCHook16( HDC16 hdc16, FARPROC16 hookProc, DWORD dwHookData )
1216 HDC hdc = HDC_32( hdc16 );
1217 DC *dc = DC_GetDCPtr( hdc );
1218 if (!dc) return FALSE;
1220 dc->hookProc = hookProc;
1221 GDI_ReleaseObj( hdc );
1222 return SetDCHook( hdc, call_dc_hook16, dwHookData );
1226 /***********************************************************************
1227 * GetDCHook (GDI.191)
1229 DWORD WINAPI GetDCHook16( HDC16 hdc16, FARPROC16 *phookProc )
1231 HDC hdc = HDC_32( hdc16 );
1232 DC *dc = DC_GetDCPtr( hdc );
1233 DWORD ret;
1235 if (!dc) return 0;
1236 *phookProc = dc->hookProc;
1237 ret = dc->dwHookData;
1238 GDI_ReleaseObj( hdc );
1239 return ret;
1243 /***********************************************************************
1244 * SetHookFlags (GDI.192)
1246 WORD WINAPI SetHookFlags16(HDC16 hdc16, WORD flags)
1248 HDC hdc = HDC_32( hdc16 );
1249 DC *dc = DC_GetDCPtr( hdc );
1251 if( dc )
1253 WORD wRet = dc->flags & DC_DIRTY;
1255 /* "Undocumented Windows" info is slightly confusing.
1258 TRACE("hDC %p, flags %04x\n",hdc,flags);
1260 if( flags & DCHF_INVALIDATEVISRGN )
1261 dc->flags |= DC_DIRTY;
1262 else if( flags & DCHF_VALIDATEVISRGN || !flags )
1263 dc->flags &= ~DC_DIRTY;
1264 GDI_ReleaseObj( hdc );
1265 return wRet;
1267 return 0;
1270 /***********************************************************************
1271 * SetICMMode (GDI32.@)
1273 INT WINAPI SetICMMode(HDC hdc, INT iEnableICM)
1275 /*FIXME Asuming that ICM is always off, and cannot be turned on */
1276 if (iEnableICM == ICM_OFF) return ICM_OFF;
1277 if (iEnableICM == ICM_ON) return 0;
1278 if (iEnableICM == ICM_QUERY) return ICM_OFF;
1279 return 0;
1282 /***********************************************************************
1283 * GetDeviceGammaRamp (GDI32.@)
1285 BOOL WINAPI GetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1287 BOOL ret = FALSE;
1288 DC *dc = DC_GetDCPtr( hDC );
1290 if( dc )
1292 if (dc->funcs->pGetDeviceGammaRamp)
1293 ret = dc->funcs->pGetDeviceGammaRamp(dc->physDev, ptr);
1294 GDI_ReleaseObj( hDC );
1296 return ret;
1299 /***********************************************************************
1300 * SetDeviceGammaRamp (GDI32.@)
1302 BOOL WINAPI SetDeviceGammaRamp(HDC hDC, LPVOID ptr)
1304 BOOL ret = FALSE;
1305 DC *dc = DC_GetDCPtr( hDC );
1307 if( dc )
1309 if (dc->funcs->pSetDeviceGammaRamp)
1310 ret = dc->funcs->pSetDeviceGammaRamp(dc->physDev, ptr);
1311 GDI_ReleaseObj( hDC );
1313 return ret;
1316 /***********************************************************************
1317 * GetColorSpace (GDI32.@)
1319 HCOLORSPACE WINAPI GetColorSpace(HDC hdc)
1321 /*FIXME Need to to whatever GetColorSpace actually does */
1322 return 0;
1325 /***********************************************************************
1326 * CreateColorSpaceA (GDI32.@)
1328 HCOLORSPACE WINAPI CreateColorSpaceA( LPLOGCOLORSPACEA lpLogColorSpace )
1330 FIXME( "stub\n" );
1331 return 0;
1334 /***********************************************************************
1335 * CreateColorSpaceW (GDI32.@)
1337 HCOLORSPACE WINAPI CreateColorSpaceW( LPLOGCOLORSPACEW lpLogColorSpace )
1339 FIXME( "stub\n" );
1340 return 0;
1343 /***********************************************************************
1344 * DeleteColorSpace (GDI32.@)
1346 BOOL WINAPI DeleteColorSpace( HCOLORSPACE hColorSpace )
1348 FIXME( "stub\n" );
1350 return TRUE;
1353 /***********************************************************************
1354 * SetColorSpace (GDI32.@)
1356 HCOLORSPACE WINAPI SetColorSpace( HDC hDC, HCOLORSPACE hColorSpace )
1358 FIXME( "stub\n" );
1360 return hColorSpace;
1363 /***********************************************************************
1364 * GetBoundsRect (GDI.194)
1366 UINT16 WINAPI GetBoundsRect16(HDC16 hdc, LPRECT16 rect, UINT16 flags)
1368 return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
1371 /***********************************************************************
1372 * GetBoundsRect (GDI32.@)
1374 UINT WINAPI GetBoundsRect(HDC hdc, LPRECT rect, UINT flags)
1376 FIXME("(): stub\n");
1377 return DCB_RESET; /* bounding rectangle always empty */
1380 /***********************************************************************
1381 * SetBoundsRect (GDI.193)
1383 UINT16 WINAPI SetBoundsRect16(HDC16 hdc, const RECT16* rect, UINT16 flags)
1385 if ( (flags & DCB_ACCUMULATE) || (flags & DCB_ENABLE) )
1386 FIXME("(%04x, %p, %04x): stub\n", hdc, rect, flags );
1388 return DCB_RESET | DCB_DISABLE; /* bounding rectangle always empty and disabled*/
1391 /***********************************************************************
1392 * SetBoundsRect (GDI32.@)
1394 UINT WINAPI SetBoundsRect(HDC hdc, const RECT* rect, UINT flags)
1396 FIXME("(): stub\n");
1397 return DCB_DISABLE; /* bounding rectangle always empty */
1401 /***********************************************************************
1402 * GetRelAbs (GDI32.@)
1404 INT WINAPI GetRelAbs( HDC hdc, DWORD dwIgnore )
1406 INT ret = 0;
1407 DC *dc = DC_GetDCPtr( hdc );
1408 if (dc) ret = dc->relAbsMode;
1409 GDI_ReleaseObj( hdc );
1410 return ret;
1413 /***********************************************************************
1414 * GetLayout (GDI32.@)
1416 * Gets left->right or right->left text layout flags of a dc.
1417 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1420 DWORD WINAPI GetLayout(HDC hdc)
1422 FIXME("(%p): stub\n", hdc);
1423 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1424 return 0;
1427 /***********************************************************************
1428 * SetLayout (GDI32.@)
1430 * Sets left->right or right->left text layout flags of a dc.
1431 * win98 just returns 0 and sets ERROR_CALL_NOT_IMPLEMENTED so we do the same
1434 DWORD WINAPI SetLayout(HDC hdc, DWORD layout)
1436 FIXME("(%p,%08lx): stub\n", hdc, layout);
1437 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1438 return 0;
1441 /***********************************************************************
1442 * SetDCBrushColor (GDI32.@)
1444 * Sets the current device context (DC) brush color to the specified
1445 * color value. If the device cannot represent the specified color
1446 * value, the color is set to the nearest physical color.
1449 COLORREF WINAPI SetDCBrushColor(HDC hdc, COLORREF crColor)
1451 FIXME("(%p, %08lx): stub\n", hdc, crColor);
1452 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1453 return CLR_INVALID;
1456 /***********************************************************************
1457 * SetVirtualResolution (GDI32.@)
1459 * Undocumented on msdn. Called when PowerPoint XP saves a file.
1461 DWORD WINAPI SetVirtualResolution(HDC hdc, DWORD dw2, DWORD dw3, DWORD dw4, DWORD dw5)
1463 FIXME("(%p %08lx %08lx %08lx %08lx): stub!\n", hdc, dw2, dw3, dw4, dw5);
1464 return FALSE;