comctl32/tooltips: Reset window subclass data when removing tools.
[wine.git] / dlls / gdi32 / driver.c
blob6a3975a531e612ab689c92fb0a109a431dc62b40
1 /*
2 * Graphics driver management functions
4 * Copyright 1994 Bob Amstadt
5 * Copyright 1996, 2001 Alexandre Julliard
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "config.h"
23 #include "wine/port.h"
25 #include <assert.h>
26 #include <stdarg.h>
27 #include <string.h>
28 #include <stdio.h>
29 #include "windef.h"
30 #include "winbase.h"
31 #include "ddrawgdi.h"
32 #include "wine/winbase16.h"
33 #include "winternl.h"
35 #include "gdi_private.h"
36 #include "wine/unicode.h"
37 #include "wine/list.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(driver);
42 struct graphics_driver
44 struct list entry;
45 HMODULE module; /* module handle */
46 const struct gdi_dc_funcs *funcs;
49 static struct list drivers = LIST_INIT( drivers );
50 static struct graphics_driver *display_driver;
52 const struct gdi_dc_funcs *font_driver = NULL;
54 static CRITICAL_SECTION driver_section;
55 static CRITICAL_SECTION_DEBUG critsect_debug =
57 0, 0, &driver_section,
58 { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
59 0, 0, { (DWORD_PTR)(__FILE__ ": driver_section") }
61 static CRITICAL_SECTION driver_section = { &critsect_debug, -1, 0, 0, 0, 0 };
63 /**********************************************************************
64 * create_driver
66 * Allocate and fill the driver structure for a given module.
68 static struct graphics_driver *create_driver( HMODULE module )
70 static const struct gdi_dc_funcs empty_funcs;
71 const struct gdi_dc_funcs *funcs = NULL;
72 struct graphics_driver *driver;
74 if (!(driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver)))) return NULL;
75 driver->module = module;
77 if (module)
79 const struct gdi_dc_funcs * (CDECL *wine_get_gdi_driver)( unsigned int version );
81 if ((wine_get_gdi_driver = (void *)GetProcAddress( module, "wine_get_gdi_driver" )))
82 funcs = wine_get_gdi_driver( WINE_GDI_DRIVER_VERSION );
84 if (!funcs) funcs = &empty_funcs;
85 driver->funcs = funcs;
86 return driver;
90 /**********************************************************************
91 * get_display_driver
93 * Special case for loading the display driver: get the name from the config file
95 static const struct gdi_dc_funcs *get_display_driver(void)
97 if (!display_driver)
99 HMODULE user32 = LoadLibraryA( "user32.dll" );
100 HWND (WINAPI *pGetDesktopWindow)(void) = (void *)GetProcAddress( user32, "GetDesktopWindow" );
102 if (!pGetDesktopWindow() || !display_driver)
104 WARN( "failed to load the display driver, falling back to null driver\n" );
105 __wine_set_display_driver( 0 );
108 return display_driver->funcs;
112 /**********************************************************************
113 * DRIVER_load_driver
115 const struct gdi_dc_funcs *DRIVER_load_driver( LPCWSTR name )
117 HMODULE module;
118 struct graphics_driver *driver, *new_driver;
119 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
120 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
122 /* display driver is a special case */
123 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return get_display_driver();
125 if ((module = GetModuleHandleW( name )))
127 if (display_driver && display_driver->module == module) return display_driver->funcs;
129 EnterCriticalSection( &driver_section );
130 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
132 if (driver->module == module) goto done;
134 LeaveCriticalSection( &driver_section );
137 if (!(module = LoadLibraryW( name ))) return NULL;
139 if (!(new_driver = create_driver( module )))
141 FreeLibrary( module );
142 return NULL;
145 /* check if someone else added it in the meantime */
146 EnterCriticalSection( &driver_section );
147 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
149 if (driver->module != module) continue;
150 FreeLibrary( module );
151 HeapFree( GetProcessHeap(), 0, new_driver );
152 goto done;
154 driver = new_driver;
155 list_add_head( &drivers, &driver->entry );
156 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
157 done:
158 LeaveCriticalSection( &driver_section );
159 return driver->funcs;
163 /***********************************************************************
164 * __wine_set_display_driver (GDI32.@)
166 void CDECL __wine_set_display_driver( HMODULE module )
168 struct graphics_driver *driver;
170 if (!(driver = create_driver( module )))
172 ERR( "Could not create graphics driver\n" );
173 ExitProcess(1);
175 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
176 HeapFree( GetProcessHeap(), 0, driver );
180 static INT nulldrv_AbortDoc( PHYSDEV dev )
182 return 0;
185 static BOOL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
186 INT xstart, INT ystart, INT xend, INT yend )
188 return TRUE;
191 static BOOL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
192 INT xstart, INT ystart, INT xend, INT yend )
194 return TRUE;
197 static BOOL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
199 if (!display_driver || !display_driver->funcs->pCreateCompatibleDC) return TRUE;
200 return display_driver->funcs->pCreateCompatibleDC( NULL, pdev );
203 static BOOL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
204 LPCWSTR output, const DEVMODEW *devmode )
206 assert(0); /* should never be called */
207 return FALSE;
210 static BOOL nulldrv_DeleteDC( PHYSDEV dev )
212 assert(0); /* should never be called */
213 return TRUE;
216 static BOOL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
218 return TRUE;
221 static DWORD nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
222 WORD cap, LPSTR output, DEVMODEA *devmode )
224 return -1;
227 static BOOL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
229 return TRUE;
232 static INT nulldrv_EndDoc( PHYSDEV dev )
234 return 0;
237 static INT nulldrv_EndPage( PHYSDEV dev )
239 return 0;
242 static BOOL nulldrv_EnumFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
244 return TRUE;
247 static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
249 return -1;
252 static INT nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
253 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
255 return -1;
258 static INT nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
259 INT out_size, void *out_data )
261 return 0;
264 static BOOL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
266 return TRUE;
269 static BOOL nulldrv_FontIsLinked( PHYSDEV dev )
271 return FALSE;
274 static BOOL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
276 return FALSE;
279 static UINT nulldrv_GetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
281 return DCB_RESET;
284 static BOOL nulldrv_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, LPABC abc )
286 return FALSE;
289 static BOOL nulldrv_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *indices, LPABC abc )
291 return FALSE;
294 static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
296 return FALSE;
299 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
301 static int screen_dpi;
302 int bpp;
304 switch (cap)
306 case DRIVERVERSION: return 0x4000;
307 case TECHNOLOGY: return DT_RASDISPLAY;
308 case HORZSIZE: return MulDiv( GetDeviceCaps( dev->hdc, HORZRES ), 254,
309 GetDeviceCaps( dev->hdc, LOGPIXELSX ) * 10 );
310 case VERTSIZE: return MulDiv( GetDeviceCaps( dev->hdc, VERTRES ), 254,
311 GetDeviceCaps( dev->hdc, LOGPIXELSY ) * 10 );
312 case HORZRES: return 640;
313 case VERTRES: return 480;
314 case BITSPIXEL: return 32;
315 case PLANES: return 1;
316 case NUMBRUSHES: return -1;
317 case NUMPENS: return -1;
318 case NUMMARKERS: return 0;
319 case NUMFONTS: return 0;
320 case PDEVICESIZE: return 0;
321 case CURVECAPS: return (CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES | CC_WIDE |
322 CC_STYLED | CC_WIDESTYLED | CC_INTERIORS | CC_ROUNDRECT);
323 case LINECAPS: return (LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
324 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS);
325 case POLYGONALCAPS: return (PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON | PC_SCANLINE |
326 PC_WIDE | PC_STYLED | PC_WIDESTYLED | PC_INTERIORS);
327 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
328 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
329 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
330 case CLIPCAPS: return CP_RECTANGLE;
331 case RASTERCAPS: return (RC_BITBLT | RC_BITMAP64 | RC_GDI20_OUTPUT | RC_DI_BITMAP | RC_DIBTODEV |
332 RC_BIGFONT | RC_STRETCHBLT | RC_FLOODFILL | RC_STRETCHDIB | RC_DEVBITS |
333 (GetDeviceCaps( dev->hdc, SIZEPALETTE ) ? RC_PALETTE : 0));
334 case ASPECTX: return 36;
335 case ASPECTY: return 36;
336 case ASPECTXY: return (int)(hypot( GetDeviceCaps( dev->hdc, ASPECTX ),
337 GetDeviceCaps( dev->hdc, ASPECTY )) + 0.5);
338 case CAPS1: return 0;
339 case SIZEPALETTE: return 0;
340 case NUMRESERVED: return 20;
341 case PHYSICALWIDTH: return 0;
342 case PHYSICALHEIGHT: return 0;
343 case PHYSICALOFFSETX: return 0;
344 case PHYSICALOFFSETY: return 0;
345 case SCALINGFACTORX: return 0;
346 case SCALINGFACTORY: return 0;
347 case VREFRESH: return GetDeviceCaps( dev->hdc, TECHNOLOGY ) == DT_RASDISPLAY ? 1 : 0;
348 case DESKTOPVERTRES: return GetDeviceCaps( dev->hdc, VERTRES );
349 case DESKTOPHORZRES: return GetDeviceCaps( dev->hdc, HORZRES );
350 case BLTALIGNMENT: return 0;
351 case SHADEBLENDCAPS: return 0;
352 case COLORMGMTCAPS: return 0;
353 case LOGPIXELSX:
354 case LOGPIXELSY:
355 if (!screen_dpi && !(screen_dpi = get_dpi())) screen_dpi = 96;
356 return screen_dpi;
357 case NUMCOLORS:
358 bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
359 return (bpp > 8) ? -1 : (1 << bpp);
360 case COLORRES:
361 /* The observed correspondence between BITSPIXEL and COLORRES is:
362 * BITSPIXEL: 8 -> COLORRES: 18
363 * BITSPIXEL: 16 -> COLORRES: 16
364 * BITSPIXEL: 24 -> COLORRES: 24
365 * BITSPIXEL: 32 -> COLORRES: 24 */
366 bpp = GetDeviceCaps( dev->hdc, BITSPIXEL );
367 return (bpp <= 8) ? 18 : min( 24, bpp );
368 default:
369 FIXME("(%p): unsupported capability %d, will return 0\n", dev->hdc, cap );
370 return 0;
374 static BOOL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
376 SetLastError( ERROR_INVALID_PARAMETER );
377 return FALSE;
380 static DWORD nulldrv_GetFontData( PHYSDEV dev, DWORD table, DWORD offset, LPVOID buffer, DWORD length )
382 return FALSE;
385 static BOOL nulldrv_GetFontRealizationInfo( PHYSDEV dev, void *info )
387 return FALSE;
390 static DWORD nulldrv_GetFontUnicodeRanges( PHYSDEV dev, LPGLYPHSET glyphs )
392 return 0;
395 static DWORD nulldrv_GetGlyphIndices( PHYSDEV dev, LPCWSTR str, INT count, LPWORD indices, DWORD flags )
397 return GDI_ERROR;
400 static DWORD nulldrv_GetGlyphOutline( PHYSDEV dev, UINT ch, UINT format, LPGLYPHMETRICS metrics,
401 DWORD size, LPVOID buffer, const MAT2 *mat )
403 return GDI_ERROR;
406 static BOOL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
408 return FALSE;
411 static DWORD nulldrv_GetImage( PHYSDEV dev, BITMAPINFO *info, struct gdi_image_bits *bits,
412 struct bitblt_coords *src )
414 return ERROR_NOT_SUPPORTED;
417 static DWORD nulldrv_GetKerningPairs( PHYSDEV dev, DWORD count, LPKERNINGPAIR pairs )
419 return 0;
422 static UINT nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXTMETRICW otm )
424 return 0;
427 static UINT nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
429 return DEFAULT_CHARSET;
432 static BOOL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT *dx )
434 return FALSE;
437 static BOOL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT *dx )
439 return FALSE;
442 static INT nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
444 INT ret = 0;
445 LOGFONTW font;
446 DC *dc = get_nulldrv_dc( dev );
448 if (GetObjectW( dc->hFont, sizeof(font), &font ))
450 ret = strlenW( font.lfFaceName ) + 1;
451 if (name)
453 lstrcpynW( name, font.lfFaceName, size );
454 ret = min( size, ret );
457 return ret;
460 static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
462 return FALSE;
465 static BOOL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
467 return TRUE;
470 static BOOL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
472 return TRUE;
475 static BOOL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
477 return TRUE;
480 static BOOL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
482 return TRUE;
485 static BOOL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
486 INT xstart, INT ystart, INT xend, INT yend )
488 return TRUE;
491 static BOOL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
493 return TRUE;
496 static BOOL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
498 return TRUE;
501 static BOOL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
503 INT counts[1] = { count };
505 return PolyPolygon( dev->hdc, points, counts, 1 );
508 static BOOL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
510 DWORD counts[1] = { count };
512 if (count < 0) return FALSE;
513 return PolyPolyline( dev->hdc, points, counts, 1 );
516 static DWORD nulldrv_PutImage( PHYSDEV dev, HRGN clip, BITMAPINFO *info,
517 const struct gdi_image_bits *bits, struct bitblt_coords *src,
518 struct bitblt_coords *dst, DWORD rop )
520 return ERROR_SUCCESS;
523 static UINT nulldrv_RealizeDefaultPalette( PHYSDEV dev )
525 return 0;
528 static UINT nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
530 return 0;
533 static BOOL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
535 return TRUE;
538 static HDC nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
540 return 0;
543 static BOOL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
544 INT ell_width, INT ell_height )
546 return TRUE;
549 static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
551 return bitmap;
554 static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, const struct brush_pattern *pattern )
556 return brush;
559 static HPALETTE nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
561 return palette;
564 static HPEN nulldrv_SelectPen( PHYSDEV dev, HPEN pen, const struct brush_pattern *pattern )
566 return pen;
569 static INT nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
571 return dir;
574 static COLORREF nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
576 return color;
579 static INT nulldrv_SetBkMode( PHYSDEV dev, INT mode )
581 return mode;
584 static UINT nulldrv_SetBoundsRect( PHYSDEV dev, RECT *rect, UINT flags )
586 return DCB_RESET;
589 static COLORREF nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
591 return color;
594 static COLORREF nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
596 return color;
599 static void nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN rgn )
603 static DWORD nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
605 return layout;
608 static BOOL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
610 SetLastError( ERROR_INVALID_PARAMETER );
611 return FALSE;
614 static DWORD nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
616 return flags;
619 static COLORREF nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
621 return color;
624 static INT nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
626 return mode;
629 static INT nulldrv_SetROP2( PHYSDEV dev, INT rop )
631 return rop;
634 static INT nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
636 return mode;
639 static INT nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
641 return mode;
644 static UINT nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
646 return align;
649 static INT nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
651 return extra;
654 static COLORREF nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
656 return color;
659 static BOOL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
661 return TRUE;
664 static INT nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
666 return 0;
669 static INT nulldrv_StartPage( PHYSDEV dev )
671 return 1;
674 static BOOL nulldrv_UnrealizePalette( HPALETTE palette )
676 return FALSE;
679 static struct opengl_funcs *nulldrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
681 return (void *)-1;
684 const struct gdi_dc_funcs null_driver =
686 nulldrv_AbortDoc, /* pAbortDoc */
687 nulldrv_AbortPath, /* pAbortPath */
688 nulldrv_AlphaBlend, /* pAlphaBlend */
689 nulldrv_AngleArc, /* pAngleArc */
690 nulldrv_Arc, /* pArc */
691 nulldrv_ArcTo, /* pArcTo */
692 nulldrv_BeginPath, /* pBeginPath */
693 nulldrv_BlendImage, /* pBlendImage */
694 nulldrv_Chord, /* pChord */
695 nulldrv_CloseFigure, /* pCloseFigure */
696 nulldrv_CreateCompatibleDC, /* pCreateCompatibleDC */
697 nulldrv_CreateDC, /* pCreateDC */
698 nulldrv_DeleteDC, /* pDeleteDC */
699 nulldrv_DeleteObject, /* pDeleteObject */
700 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
701 nulldrv_Ellipse, /* pEllipse */
702 nulldrv_EndDoc, /* pEndDoc */
703 nulldrv_EndPage, /* pEndPage */
704 nulldrv_EndPath, /* pEndPath */
705 nulldrv_EnumFonts, /* pEnumFonts */
706 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
707 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
708 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
709 nulldrv_ExtEscape, /* pExtEscape */
710 nulldrv_ExtFloodFill, /* pExtFloodFill */
711 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
712 nulldrv_ExtTextOut, /* pExtTextOut */
713 nulldrv_FillPath, /* pFillPath */
714 nulldrv_FillRgn, /* pFillRgn */
715 nulldrv_FlattenPath, /* pFlattenPath */
716 nulldrv_FontIsLinked, /* pFontIsLinked */
717 nulldrv_FrameRgn, /* pFrameRgn */
718 nulldrv_GdiComment, /* pGdiComment */
719 nulldrv_GetBoundsRect, /* pGetBoundsRect */
720 nulldrv_GetCharABCWidths, /* pGetCharABCWidths */
721 nulldrv_GetCharABCWidthsI, /* pGetCharABCWidthsI */
722 nulldrv_GetCharWidth, /* pGetCharWidth */
723 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
724 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
725 nulldrv_GetFontData, /* pGetFontData */
726 nulldrv_GetFontRealizationInfo, /* pGetFontRealizationInfo */
727 nulldrv_GetFontUnicodeRanges, /* pGetFontUnicodeRanges */
728 nulldrv_GetGlyphIndices, /* pGetGlyphIndices */
729 nulldrv_GetGlyphOutline, /* pGetGlyphOutline */
730 nulldrv_GetICMProfile, /* pGetICMProfile */
731 nulldrv_GetImage, /* pGetImage */
732 nulldrv_GetKerningPairs, /* pGetKerningPairs */
733 nulldrv_GetNearestColor, /* pGetNearestColor */
734 nulldrv_GetOutlineTextMetrics, /* pGetOutlineTextMetrics */
735 nulldrv_GetPixel, /* pGetPixel */
736 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
737 nulldrv_GetTextCharsetInfo, /* pGetTextCharsetInfo */
738 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
739 nulldrv_GetTextExtentExPointI, /* pGetTextExtentExPointI */
740 nulldrv_GetTextFace, /* pGetTextFace */
741 nulldrv_GetTextMetrics, /* pGetTextMetrics */
742 nulldrv_GradientFill, /* pGradientFill */
743 nulldrv_IntersectClipRect, /* pIntersectClipRect */
744 nulldrv_InvertRgn, /* pInvertRgn */
745 nulldrv_LineTo, /* pLineTo */
746 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
747 nulldrv_MoveTo, /* pMoveTo */
748 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
749 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
750 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
751 nulldrv_PaintRgn, /* pPaintRgn */
752 nulldrv_PatBlt, /* pPatBlt */
753 nulldrv_Pie, /* pPie */
754 nulldrv_PolyBezier, /* pPolyBezier */
755 nulldrv_PolyBezierTo, /* pPolyBezierTo */
756 nulldrv_PolyDraw, /* pPolyDraw */
757 nulldrv_PolyPolygon, /* pPolyPolygon */
758 nulldrv_PolyPolyline, /* pPolyPolyline */
759 nulldrv_Polygon, /* pPolygon */
760 nulldrv_Polyline, /* pPolyline */
761 nulldrv_PolylineTo, /* pPolylineTo */
762 nulldrv_PutImage, /* pPutImage */
763 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
764 nulldrv_RealizePalette, /* pRealizePalette */
765 nulldrv_Rectangle, /* pRectangle */
766 nulldrv_ResetDC, /* pResetDC */
767 nulldrv_RestoreDC, /* pRestoreDC */
768 nulldrv_RoundRect, /* pRoundRect */
769 nulldrv_SaveDC, /* pSaveDC */
770 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
771 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
772 nulldrv_SelectBitmap, /* pSelectBitmap */
773 nulldrv_SelectBrush, /* pSelectBrush */
774 nulldrv_SelectClipPath, /* pSelectClipPath */
775 nulldrv_SelectFont, /* pSelectFont */
776 nulldrv_SelectPalette, /* pSelectPalette */
777 nulldrv_SelectPen, /* pSelectPen */
778 nulldrv_SetArcDirection, /* pSetArcDirection */
779 nulldrv_SetBkColor, /* pSetBkColor */
780 nulldrv_SetBkMode, /* pSetBkMode */
781 nulldrv_SetBoundsRect, /* pSetBoundsRect */
782 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
783 nulldrv_SetDCPenColor, /* pSetDCPenColor */
784 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
785 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
786 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
787 nulldrv_SetLayout, /* pSetLayout */
788 nulldrv_SetMapMode, /* pSetMapMode */
789 nulldrv_SetMapperFlags, /* pSetMapperFlags */
790 nulldrv_SetPixel, /* pSetPixel */
791 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
792 nulldrv_SetROP2, /* pSetROP2 */
793 nulldrv_SetRelAbs, /* pSetRelAbs */
794 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
795 nulldrv_SetTextAlign, /* pSetTextAlign */
796 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
797 nulldrv_SetTextColor, /* pSetTextColor */
798 nulldrv_SetTextJustification, /* pSetTextJustification */
799 nulldrv_SetViewportExtEx, /* pSetViewportExt */
800 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
801 nulldrv_SetWindowExtEx, /* pSetWindowExt */
802 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
803 nulldrv_SetWorldTransform, /* pSetWorldTransform */
804 nulldrv_StartDoc, /* pStartDoc */
805 nulldrv_StartPage, /* pStartPage */
806 nulldrv_StretchBlt, /* pStretchBlt */
807 nulldrv_StretchDIBits, /* pStretchDIBits */
808 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
809 nulldrv_StrokePath, /* pStrokePath */
810 nulldrv_UnrealizePalette, /* pUnrealizePalette */
811 nulldrv_WidenPath, /* pWidenPath */
812 nulldrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
814 GDI_PRIORITY_NULL_DRV /* priority */
818 /*****************************************************************************
819 * DRIVER_GetDriverName
822 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
824 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
825 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
826 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
827 static const WCHAR empty_strW[] = { 0 };
828 WCHAR *p;
830 /* display is a special case */
831 if (!strcmpiW( device, displayW ) ||
832 !strcmpiW( device, display1W ))
834 lstrcpynW( driver, displayW, size );
835 return TRUE;
838 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
839 if(!size) {
840 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
841 return FALSE;
843 p = strchrW(driver, ',');
844 if(!p)
846 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
847 return FALSE;
849 *p = 0;
850 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
851 return TRUE;
855 /***********************************************************************
856 * GdiConvertToDevmodeW (GDI32.@)
858 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
860 DEVMODEW *dmW;
861 WORD dmW_size, dmA_size;
863 dmA_size = dmA->dmSize;
865 /* this is the minimal dmSize that XP accepts */
866 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
867 return NULL;
869 if (dmA_size > sizeof(DEVMODEA))
870 dmA_size = sizeof(DEVMODEA);
872 dmW_size = dmA_size + CCHDEVICENAME;
873 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
874 dmW_size += CCHFORMNAME;
876 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
877 if (!dmW) return NULL;
879 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
880 dmW->dmDeviceName, CCHDEVICENAME);
881 /* copy slightly more, to avoid long computations */
882 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
884 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
886 if (dmA->dmFields & DM_FORMNAME)
887 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
888 dmW->dmFormName, CCHFORMNAME);
889 else
890 dmW->dmFormName[0] = 0;
892 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
893 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
896 if (dmA->dmDriverExtra)
897 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
899 dmW->dmSize = dmW_size;
901 return dmW;
905 /*****************************************************************************
906 * @ [GDI32.100]
908 * This should thunk to 16-bit and simply call the proc with the given args.
910 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
911 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
913 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
914 return -1;
917 /*****************************************************************************
918 * @ [GDI32.101]
920 * This should load the correct driver for lpszDevice and calls this driver's
921 * ExtDeviceModePropSheet proc.
923 * Note: The driver calls a callback routine for each property sheet page; these
924 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
925 * The layout of this structure is:
927 * struct
929 * DWORD nPages;
930 * DWORD unknown;
931 * HPROPSHEETPAGE pages[10];
932 * };
934 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
935 LPCSTR lpszPort, LPVOID lpPropSheet )
937 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
938 return -1;
941 /*****************************************************************************
942 * @ [GDI32.102]
944 * This should load the correct driver for lpszDevice and call this driver's
945 * ExtDeviceMode proc.
947 * FIXME: convert ExtDeviceMode to unicode in the driver interface
949 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
950 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
951 LPSTR lpszPort, LPDEVMODEA lpdmInput,
952 LPSTR lpszProfile, DWORD fwMode )
954 WCHAR deviceW[300];
955 WCHAR bufW[300];
956 char buf[300];
957 HDC hdc;
958 DC *dc;
959 INT ret = -1;
961 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
962 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
964 if (!lpszDevice) return -1;
965 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
967 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
969 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
971 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
973 if ((dc = get_dc_ptr( hdc )))
975 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
976 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
977 lpdmInput, lpszProfile, fwMode );
978 release_dc_ptr( dc );
980 DeleteDC( hdc );
981 return ret;
984 /****************************************************************************
985 * @ [GDI32.103]
987 * This should load the correct driver for lpszDevice and calls this driver's
988 * AdvancedSetupDialog proc.
990 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
991 LPDEVMODEA devin, LPDEVMODEA devout )
993 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
994 return -1;
997 /*****************************************************************************
998 * @ [GDI32.104]
1000 * This should load the correct driver for lpszDevice and calls this driver's
1001 * DeviceCapabilities proc.
1003 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1005 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1006 WORD fwCapability, LPSTR lpszOutput,
1007 LPDEVMODEA lpdm )
1009 WCHAR deviceW[300];
1010 WCHAR bufW[300];
1011 char buf[300];
1012 HDC hdc;
1013 DC *dc;
1014 INT ret = -1;
1016 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1018 if (!lpszDevice) return -1;
1019 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1021 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1023 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1025 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1027 if ((dc = get_dc_ptr( hdc )))
1029 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1030 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1031 fwCapability, lpszOutput, lpdm );
1032 release_dc_ptr( dc );
1034 DeleteDC( hdc );
1035 return ret;
1039 /************************************************************************
1040 * Escape [GDI32.@]
1042 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1044 INT ret;
1045 POINT *pt;
1047 switch (escape)
1049 case ABORTDOC:
1050 return AbortDoc( hdc );
1052 case ENDDOC:
1053 return EndDoc( hdc );
1055 case GETPHYSPAGESIZE:
1056 pt = out_data;
1057 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1058 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1059 return 1;
1061 case GETPRINTINGOFFSET:
1062 pt = out_data;
1063 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1064 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1065 return 1;
1067 case GETSCALINGFACTOR:
1068 pt = out_data;
1069 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1070 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1071 return 1;
1073 case NEWFRAME:
1074 return EndPage( hdc );
1076 case SETABORTPROC:
1077 return SetAbortProc( hdc, (ABORTPROC)in_data );
1079 case STARTDOC:
1081 DOCINFOA doc;
1082 char *name = NULL;
1084 /* in_data may not be 0 terminated so we must copy it */
1085 if (in_data)
1087 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1088 memcpy( name, in_data, in_count );
1089 name[in_count] = 0;
1091 /* out_data is actually a pointer to the DocInfo structure and used as
1092 * a second input parameter */
1093 if (out_data) doc = *(DOCINFOA *)out_data;
1094 else
1096 doc.cbSize = sizeof(doc);
1097 doc.lpszOutput = NULL;
1098 doc.lpszDatatype = NULL;
1099 doc.fwType = 0;
1101 doc.lpszDocName = name;
1102 ret = StartDocA( hdc, &doc );
1103 HeapFree( GetProcessHeap(), 0, name );
1104 if (ret > 0) ret = StartPage( hdc );
1105 return ret;
1108 case QUERYESCSUPPORT:
1110 DWORD code;
1112 if (in_count < sizeof(SHORT)) return 0;
1113 code = (in_count < sizeof(DWORD)) ? *(const USHORT *)in_data : *(const DWORD *)in_data;
1114 switch (code)
1116 case ABORTDOC:
1117 case ENDDOC:
1118 case GETPHYSPAGESIZE:
1119 case GETPRINTINGOFFSET:
1120 case GETSCALINGFACTOR:
1121 case NEWFRAME:
1122 case QUERYESCSUPPORT:
1123 case SETABORTPROC:
1124 case STARTDOC:
1125 return TRUE;
1127 break;
1131 /* if not handled internally, pass it to the driver */
1132 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1136 /******************************************************************************
1137 * ExtEscape [GDI32.@]
1139 * Access capabilities of a particular device that are not available through GDI.
1141 * PARAMS
1142 * hdc [I] Handle to device context
1143 * nEscape [I] Escape function
1144 * cbInput [I] Number of bytes in input structure
1145 * lpszInData [I] Pointer to input structure
1146 * cbOutput [I] Number of bytes in output structure
1147 * lpszOutData [O] Pointer to output structure
1149 * RETURNS
1150 * Success: >0
1151 * Not implemented: 0
1152 * Failure: <0
1154 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1155 INT cbOutput, LPSTR lpszOutData )
1157 PHYSDEV physdev;
1158 INT ret;
1159 DC * dc = get_dc_ptr( hdc );
1161 if (!dc) return 0;
1162 update_dc( dc );
1163 physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1164 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1165 release_dc_ptr( dc );
1166 return ret;
1170 /*******************************************************************
1171 * DrawEscape [GDI32.@]
1175 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1177 FIXME("DrawEscape, stub\n");
1178 return 0;
1181 /*******************************************************************
1182 * NamedEscape [GDI32.@]
1184 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1185 INT cbOutput, LPSTR lpszOutData )
1187 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1188 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1189 lpszOutData);
1190 return 0;
1193 /*******************************************************************
1194 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1195 * GdiEntry13 [GDI32.@]
1197 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1199 static int warn_once;
1201 if (!warn_once++)
1202 FIXME("stub\n");
1203 return 0;
1206 /******************************************************************************
1207 * D3DKMTOpenAdapterFromHdc [GDI32.@]
1209 NTSTATUS WINAPI D3DKMTOpenAdapterFromHdc( void *pData )
1211 FIXME("(%p): stub\n", pData);
1212 return STATUS_NO_MEMORY;
1215 /******************************************************************************
1216 * D3DKMTEscape [GDI32.@]
1218 NTSTATUS WINAPI D3DKMTEscape( const void *pData )
1220 FIXME("(%p): stub\n", pData);
1221 return STATUS_NO_MEMORY;