apphelp: Add stub for ApphelpCheckInstallShieldPackage.
[wine/wine-gecko.git] / dlls / gdi32 / driver.c
blob0986d687878ea9b0339841df5b37cc7223540b04
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 "winreg.h"
32 #include "ddrawgdi.h"
33 #include "wine/winbase16.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 struct graphics_driver *driver;
98 char buffer[MAX_PATH], libname[32], *name, *next;
99 HMODULE module = 0;
100 HKEY hkey;
102 if (display_driver) return display_driver->funcs; /* already loaded */
104 strcpy( buffer, "x11" ); /* default value */
105 /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
106 if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
108 DWORD type, count = sizeof(buffer);
109 RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
110 RegCloseKey( hkey );
113 name = buffer;
114 while (name)
116 next = strchr( name, ',' );
117 if (next) *next++ = 0;
119 snprintf( libname, sizeof(libname), "wine%s.drv", name );
120 if ((module = LoadLibraryA( libname )) != 0) break;
121 name = next;
124 if (!(driver = create_driver( module )))
126 MESSAGE( "Could not create graphics driver '%s'\n", buffer );
127 FreeLibrary( module );
128 ExitProcess(1);
130 if (InterlockedCompareExchangePointer( (void **)&display_driver, driver, NULL ))
132 /* somebody beat us to it */
133 FreeLibrary( driver->module );
134 HeapFree( GetProcessHeap(), 0, driver );
136 return display_driver->funcs;
140 /**********************************************************************
141 * DRIVER_load_driver
143 const struct gdi_dc_funcs *DRIVER_load_driver( LPCWSTR name )
145 HMODULE module;
146 struct graphics_driver *driver, *new_driver;
147 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
148 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
150 /* display driver is a special case */
151 if (!strcmpiW( name, displayW ) || !strcmpiW( name, display1W )) return get_display_driver();
153 if ((module = GetModuleHandleW( name )))
155 if (display_driver && display_driver->module == module) return display_driver->funcs;
156 EnterCriticalSection( &driver_section );
157 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
159 if (driver->module == module) goto done;
161 LeaveCriticalSection( &driver_section );
164 if (!(module = LoadLibraryW( name ))) return NULL;
166 if (!(new_driver = create_driver( module )))
168 FreeLibrary( module );
169 return NULL;
172 /* check if someone else added it in the meantime */
173 EnterCriticalSection( &driver_section );
174 LIST_FOR_EACH_ENTRY( driver, &drivers, struct graphics_driver, entry )
176 if (driver->module != module) continue;
177 FreeLibrary( module );
178 HeapFree( GetProcessHeap(), 0, new_driver );
179 goto done;
181 driver = new_driver;
182 list_add_head( &drivers, &driver->entry );
183 TRACE( "loaded driver %p for %s\n", driver, debugstr_w(name) );
184 done:
185 LeaveCriticalSection( &driver_section );
186 return driver->funcs;
190 static INT nulldrv_AbortDoc( PHYSDEV dev )
192 return 0;
195 static BOOL nulldrv_Arc( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
196 INT xstart, INT ystart, INT xend, INT yend )
198 return TRUE;
201 static INT nulldrv_ChoosePixelFormat( PHYSDEV dev, const PIXELFORMATDESCRIPTOR *descr )
203 return 0;
206 static BOOL nulldrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
207 INT xstart, INT ystart, INT xend, INT yend )
209 return TRUE;
212 static BOOL nulldrv_CreateBitmap( PHYSDEV dev, HBITMAP bitmap )
214 return TRUE;
217 static BOOL nulldrv_CreateCompatibleDC( PHYSDEV orig, PHYSDEV *pdev )
219 if (!display_driver || !display_driver->funcs->pCreateCompatibleDC) return TRUE;
220 return display_driver->funcs->pCreateCompatibleDC( NULL, pdev );
223 static BOOL nulldrv_CreateDC( PHYSDEV *dev, LPCWSTR driver, LPCWSTR device,
224 LPCWSTR output, const DEVMODEW *devmode )
226 assert(0); /* should never be called */
227 return FALSE;
230 static HBITMAP nulldrv_CreateDIBSection( PHYSDEV dev, HBITMAP bitmap, BITMAPINFO *info, UINT usage )
232 return bitmap;
235 static BOOL nulldrv_DeleteBitmap( HBITMAP bitmap )
237 return TRUE;
240 static BOOL nulldrv_DeleteDC( PHYSDEV dev )
242 assert(0); /* should never be called */
243 return TRUE;
246 static BOOL nulldrv_DeleteObject( PHYSDEV dev, HGDIOBJ obj )
248 return TRUE;
251 static INT nulldrv_DescribePixelFormat( PHYSDEV dev, INT format, UINT size, PIXELFORMATDESCRIPTOR * descr )
253 return 0;
256 static DWORD nulldrv_DeviceCapabilities( LPSTR buffer, LPCSTR device, LPCSTR port,
257 WORD cap, LPSTR output, DEVMODEA *devmode )
259 return -1;
262 static BOOL nulldrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
264 return TRUE;
267 static INT nulldrv_EndDoc( PHYSDEV dev )
269 return 0;
272 static INT nulldrv_EndPage( PHYSDEV dev )
274 return 0;
277 static BOOL nulldrv_EnumFonts( PHYSDEV dev, LOGFONTW *logfont, FONTENUMPROCW proc, LPARAM lParam )
279 return TRUE;
282 static INT nulldrv_EnumICMProfiles( PHYSDEV dev, ICMENUMPROCW func, LPARAM lparam )
284 return -1;
287 static INT nulldrv_ExtDeviceMode( LPSTR buffer, HWND hwnd, DEVMODEA *output, LPSTR device,
288 LPSTR port, DEVMODEA *input, LPSTR profile, DWORD mode )
290 return -1;
293 static INT nulldrv_ExtEscape( PHYSDEV dev, INT escape, INT in_size, const void *in_data,
294 INT out_size, void *out_data )
296 return 0;
299 static BOOL nulldrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type )
301 return TRUE;
304 static BOOL nulldrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, const RECT *rect,
305 LPCWSTR str, UINT count, const INT *dx )
307 return TRUE;
310 static BOOL nulldrv_FontIsLinked( PHYSDEV dev )
312 return FALSE;
315 static BOOL nulldrv_GdiComment( PHYSDEV dev, UINT size, const BYTE *data )
317 return FALSE;
320 static BOOL nulldrv_GdiRealizationInfo( PHYSDEV dev, void *info )
322 return FALSE;
325 static BOOL nulldrv_GetCharABCWidths( PHYSDEV dev, UINT first, UINT last, LPABC abc )
327 return FALSE;
330 static BOOL nulldrv_GetCharABCWidthsI( PHYSDEV dev, UINT first, UINT count, WORD *indices, LPABC abc )
332 return FALSE;
335 static BOOL nulldrv_GetCharWidth( PHYSDEV dev, UINT first, UINT last, INT *buffer )
337 return FALSE;
340 static INT nulldrv_GetDeviceCaps( PHYSDEV dev, INT cap )
342 switch (cap) /* return meaningful values for some entries */
344 case HORZRES: return 640;
345 case VERTRES: return 480;
346 case BITSPIXEL: return 1;
347 case PLANES: return 1;
348 case NUMCOLORS: return 2;
349 case ASPECTX: return 36;
350 case ASPECTY: return 36;
351 case ASPECTXY: return 51;
352 case LOGPIXELSX: return 72;
353 case LOGPIXELSY: return 72;
354 case SIZEPALETTE: return 2;
355 case TEXTCAPS: return (TC_OP_CHARACTER | TC_OP_STROKE | TC_CP_STROKE |
356 TC_CR_ANY | TC_SF_X_YINDEP | TC_SA_DOUBLE | TC_SA_INTEGER |
357 TC_SA_CONTIN | TC_UA_ABLE | TC_SO_ABLE | TC_RA_ABLE | TC_VA_ABLE);
358 default: return 0;
362 static BOOL nulldrv_GetDeviceGammaRamp( PHYSDEV dev, void *ramp )
364 return FALSE;
367 static DWORD nulldrv_GetFontData( PHYSDEV dev, DWORD table, DWORD offset, LPVOID buffer, DWORD length )
369 return FALSE;
372 static DWORD nulldrv_GetFontUnicodeRanges( PHYSDEV dev, LPGLYPHSET glyphs )
374 return 0;
377 static DWORD nulldrv_GetGlyphIndices( PHYSDEV dev, LPCWSTR str, INT count, LPWORD indices, DWORD flags )
379 return GDI_ERROR;
382 static DWORD nulldrv_GetGlyphOutline( PHYSDEV dev, UINT ch, UINT format, LPGLYPHMETRICS metrics,
383 DWORD size, LPVOID buffer, const MAT2 *mat )
385 return GDI_ERROR;
388 static BOOL nulldrv_GetICMProfile( PHYSDEV dev, LPDWORD size, LPWSTR filename )
390 return FALSE;
393 static DWORD nulldrv_GetKerningPairs( PHYSDEV dev, DWORD count, LPKERNINGPAIR pairs )
395 return 0;
398 static UINT nulldrv_GetOutlineTextMetrics( PHYSDEV dev, UINT size, LPOUTLINETEXTMETRICW otm )
400 return 0;
403 static COLORREF nulldrv_GetPixel( PHYSDEV dev, INT x, INT y )
405 return CLR_INVALID;
408 static INT nulldrv_GetPixelFormat( PHYSDEV dev )
410 return 0;
413 static UINT nulldrv_GetSystemPaletteEntries( PHYSDEV dev, UINT start, UINT count, PALETTEENTRY *entries )
415 return 0;
418 static UINT nulldrv_GetTextCharsetInfo( PHYSDEV dev, LPFONTSIGNATURE fs, DWORD flags )
420 return DEFAULT_CHARSET;
423 static BOOL nulldrv_GetTextExtentExPoint( PHYSDEV dev, LPCWSTR str, INT count, INT max_ext,
424 INT *fit, INT *dx, SIZE *size )
426 return FALSE;
429 static BOOL nulldrv_GetTextExtentExPointI( PHYSDEV dev, const WORD *indices, INT count, INT max_ext,
430 INT *fit, INT *dx, SIZE *size )
432 return FALSE;
435 static INT nulldrv_GetTextFace( PHYSDEV dev, INT size, LPWSTR name )
437 INT ret = 0;
438 LOGFONTW font;
439 HFONT hfont = GetCurrentObject( dev->hdc, OBJ_FONT );
441 if (GetObjectW( hfont, sizeof(font), &font ))
443 ret = strlenW( font.lfFaceName ) + 1;
444 if (name)
446 lstrcpynW( name, font.lfFaceName, size );
447 ret = min( size, ret );
450 return ret;
453 static BOOL nulldrv_GetTextMetrics( PHYSDEV dev, TEXTMETRICW *metrics )
455 return FALSE;
458 static BOOL nulldrv_LineTo( PHYSDEV dev, INT x, INT y )
460 return TRUE;
463 static BOOL nulldrv_MoveTo( PHYSDEV dev, INT x, INT y )
465 return TRUE;
468 static BOOL nulldrv_PaintRgn( PHYSDEV dev, HRGN rgn )
470 return TRUE;
473 static BOOL nulldrv_PatBlt( PHYSDEV dev, struct bitblt_coords *dst, DWORD rop )
475 return TRUE;
478 static BOOL nulldrv_Pie( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
479 INT xstart, INT ystart, INT xend, INT yend )
481 return TRUE;
484 static BOOL nulldrv_PolyPolygon( PHYSDEV dev, const POINT *points, const INT *counts, UINT polygons )
486 /* FIXME: could be implemented with Polygon */
487 return TRUE;
490 static BOOL nulldrv_PolyPolyline( PHYSDEV dev, const POINT *points, const DWORD *counts, DWORD lines )
492 /* FIXME: could be implemented with Polyline */
493 return TRUE;
496 static BOOL nulldrv_Polygon( PHYSDEV dev, const POINT *points, INT count )
498 return TRUE;
501 static BOOL nulldrv_Polyline( PHYSDEV dev, const POINT *points, INT count )
503 return TRUE;
506 static UINT nulldrv_RealizeDefaultPalette( PHYSDEV dev )
508 return 0;
511 static UINT nulldrv_RealizePalette( PHYSDEV dev, HPALETTE palette, BOOL primary )
513 return 0;
516 static BOOL nulldrv_Rectangle( PHYSDEV dev, INT left, INT top, INT right, INT bottom )
518 return TRUE;
521 static HDC nulldrv_ResetDC( PHYSDEV dev, const DEVMODEW *devmode )
523 return 0;
526 static BOOL nulldrv_RoundRect( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
527 INT ell_width, INT ell_height )
529 return TRUE;
532 static HBITMAP nulldrv_SelectBitmap( PHYSDEV dev, HBITMAP bitmap )
534 return bitmap;
537 static HBRUSH nulldrv_SelectBrush( PHYSDEV dev, HBRUSH brush, HBITMAP bitmap,
538 const BITMAPINFO *info, void *bits, UINT usage )
540 return brush;
543 static HFONT nulldrv_SelectFont( PHYSDEV dev, HFONT font )
545 return 0;
548 static HPALETTE nulldrv_SelectPalette( PHYSDEV dev, HPALETTE palette, BOOL bkgnd )
550 return palette;
553 static HPEN nulldrv_SelectPen( PHYSDEV dev, HPEN pen )
555 return pen;
558 static INT nulldrv_SetArcDirection( PHYSDEV dev, INT dir )
560 return dir;
563 static COLORREF nulldrv_SetBkColor( PHYSDEV dev, COLORREF color )
565 return color;
568 static INT nulldrv_SetBkMode( PHYSDEV dev, INT mode )
570 return mode;
573 static COLORREF nulldrv_SetDCBrushColor( PHYSDEV dev, COLORREF color )
575 return color;
578 static COLORREF nulldrv_SetDCPenColor( PHYSDEV dev, COLORREF color )
580 return color;
583 static UINT nulldrv_SetDIBColorTable( PHYSDEV dev, UINT pos, UINT count, const RGBQUAD *colors )
585 return 0;
588 static void nulldrv_SetDeviceClipping( PHYSDEV dev, HRGN vis_rgn, HRGN clip_rgn )
592 static DWORD nulldrv_SetLayout( PHYSDEV dev, DWORD layout )
594 return layout;
597 static BOOL nulldrv_SetDeviceGammaRamp( PHYSDEV dev, void *ramp )
599 return FALSE;
602 static DWORD nulldrv_SetMapperFlags( PHYSDEV dev, DWORD flags )
604 return flags;
607 static COLORREF nulldrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color )
609 return color;
612 static BOOL nulldrv_SetPixelFormat( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
614 return FALSE;
617 static INT nulldrv_SetPolyFillMode( PHYSDEV dev, INT mode )
619 return mode;
622 static INT nulldrv_SetROP2( PHYSDEV dev, INT rop )
624 return rop;
627 static INT nulldrv_SetRelAbs( PHYSDEV dev, INT mode )
629 return mode;
632 static INT nulldrv_SetStretchBltMode( PHYSDEV dev, INT mode )
634 return mode;
637 static UINT nulldrv_SetTextAlign( PHYSDEV dev, UINT align )
639 return align;
642 static INT nulldrv_SetTextCharacterExtra( PHYSDEV dev, INT extra )
644 return extra;
647 static COLORREF nulldrv_SetTextColor( PHYSDEV dev, COLORREF color )
649 return color;
652 static BOOL nulldrv_SetTextJustification( PHYSDEV dev, INT extra, INT breaks )
654 return TRUE;
657 static INT nulldrv_StartDoc( PHYSDEV dev, const DOCINFOW *info )
659 return 0;
662 static INT nulldrv_StartPage( PHYSDEV dev )
664 return 1;
667 static BOOL nulldrv_SwapBuffers( PHYSDEV dev )
669 return TRUE;
672 static BOOL nulldrv_UnrealizePalette( HPALETTE palette )
674 return FALSE;
677 static BOOL nulldrv_wglCopyContext( HGLRC ctx_src, HGLRC ctx_dst, UINT mask )
679 return FALSE;
682 static HGLRC nulldrv_wglCreateContext( PHYSDEV dev )
684 return 0;
687 static HGLRC nulldrv_wglCreateContextAttribsARB( PHYSDEV dev, HGLRC share_ctx, const int *attribs )
689 return 0;
692 static BOOL nulldrv_wglDeleteContext( HGLRC ctx )
694 return FALSE;
697 static PROC nulldrv_wglGetProcAddress( LPCSTR name )
699 return NULL;
702 static HDC nulldrv_wglGetPbufferDCARB( PHYSDEV dev, void *pbuffer )
704 return 0;
707 static BOOL nulldrv_wglMakeCurrent( PHYSDEV dev, HGLRC ctx )
709 return FALSE;
712 static BOOL nulldrv_wglMakeContextCurrentARB( PHYSDEV dev_draw, PHYSDEV dev_read, HGLRC ctx )
714 return FALSE;
717 static BOOL nulldrv_wglSetPixelFormatWINE( PHYSDEV dev, INT format, const PIXELFORMATDESCRIPTOR *descr )
719 return FALSE;
722 static BOOL nulldrv_wglShareLists( HGLRC ctx1, HGLRC ctx2 )
724 return FALSE;
727 static BOOL nulldrv_wglUseFontBitmapsA( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
729 return FALSE;
732 static BOOL nulldrv_wglUseFontBitmapsW( PHYSDEV dev, DWORD start, DWORD count, DWORD base )
734 return FALSE;
737 const struct gdi_dc_funcs null_driver =
739 nulldrv_AbortDoc, /* pAbortDoc */
740 nulldrv_AbortPath, /* pAbortPath */
741 nulldrv_AlphaBlend, /* pAlphaBlend */
742 nulldrv_AngleArc, /* pAngleArc */
743 nulldrv_Arc, /* pArc */
744 nulldrv_ArcTo, /* pArcTo */
745 nulldrv_BeginPath, /* pBeginPath */
746 nulldrv_BlendImage, /* pBlendImage */
747 nulldrv_ChoosePixelFormat, /* pChoosePixelFormat */
748 nulldrv_Chord, /* pChord */
749 nulldrv_CloseFigure, /* pCloseFigure */
750 nulldrv_CreateBitmap, /* pCreateBitmap */
751 nulldrv_CreateCompatibleDC, /* pCreateCompatibleDC */
752 nulldrv_CreateDC, /* pCreateDC */
753 nulldrv_CreateDIBSection, /* pCreateDIBSection */
754 nulldrv_DeleteBitmap, /* pDeleteBitmap */
755 nulldrv_DeleteDC, /* pDeleteDC */
756 nulldrv_DeleteObject, /* pDeleteObject */
757 nulldrv_DescribePixelFormat, /* pDescribePixelFormat */
758 nulldrv_DeviceCapabilities, /* pDeviceCapabilities */
759 nulldrv_Ellipse, /* pEllipse */
760 nulldrv_EndDoc, /* pEndDoc */
761 nulldrv_EndPage, /* pEndPage */
762 nulldrv_EndPath, /* pEndPath */
763 nulldrv_EnumFonts, /* pEnumFonts */
764 nulldrv_EnumICMProfiles, /* pEnumICMProfiles */
765 nulldrv_ExcludeClipRect, /* pExcludeClipRect */
766 nulldrv_ExtDeviceMode, /* pExtDeviceMode */
767 nulldrv_ExtEscape, /* pExtEscape */
768 nulldrv_ExtFloodFill, /* pExtFloodFill */
769 nulldrv_ExtSelectClipRgn, /* pExtSelectClipRgn */
770 nulldrv_ExtTextOut, /* pExtTextOut */
771 nulldrv_FillPath, /* pFillPath */
772 nulldrv_FillRgn, /* pFillRgn */
773 nulldrv_FlattenPath, /* pFlattenPath */
774 nulldrv_FontIsLinked, /* pFontIsLinked */
775 nulldrv_FrameRgn, /* pFrameRgn */
776 nulldrv_GdiComment, /* pGdiComment */
777 nulldrv_GdiRealizationInfo, /* pGdiRealizationInfo */
778 nulldrv_GetCharABCWidths, /* pGetCharABCWidths */
779 nulldrv_GetCharABCWidthsI, /* pGetCharABCWidthsI */
780 nulldrv_GetCharWidth, /* pGetCharWidth */
781 nulldrv_GetDeviceCaps, /* pGetDeviceCaps */
782 nulldrv_GetDeviceGammaRamp, /* pGetDeviceGammaRamp */
783 nulldrv_GetFontData, /* pGetFontData */
784 nulldrv_GetFontUnicodeRanges, /* pGetFontUnicodeRanges */
785 nulldrv_GetGlyphIndices, /* pGetGlyphIndices */
786 nulldrv_GetGlyphOutline, /* pGetGlyphOutline */
787 nulldrv_GetICMProfile, /* pGetICMProfile */
788 nulldrv_GetImage, /* pGetImage */
789 nulldrv_GetKerningPairs, /* pGetKerningPairs */
790 nulldrv_GetNearestColor, /* pGetNearestColor */
791 nulldrv_GetOutlineTextMetrics, /* pGetOutlineTextMetrics */
792 nulldrv_GetPixel, /* pGetPixel */
793 nulldrv_GetPixelFormat, /* pGetPixelFormat */
794 nulldrv_GetSystemPaletteEntries, /* pGetSystemPaletteEntries */
795 nulldrv_GetTextCharsetInfo, /* pGetTextCharsetInfo */
796 nulldrv_GetTextExtentExPoint, /* pGetTextExtentExPoint */
797 nulldrv_GetTextExtentExPointI, /* pGetTextExtentExPointI */
798 nulldrv_GetTextFace, /* pGetTextFace */
799 nulldrv_GetTextMetrics, /* pGetTextMetrics */
800 nulldrv_GradientFill, /* pGradientFill */
801 nulldrv_IntersectClipRect, /* pIntersectClipRect */
802 nulldrv_InvertRgn, /* pInvertRgn */
803 nulldrv_LineTo, /* pLineTo */
804 nulldrv_ModifyWorldTransform, /* pModifyWorldTransform */
805 nulldrv_MoveTo, /* pMoveTo */
806 nulldrv_OffsetClipRgn, /* pOffsetClipRgn */
807 nulldrv_OffsetViewportOrgEx, /* pOffsetViewportOrg */
808 nulldrv_OffsetWindowOrgEx, /* pOffsetWindowOrg */
809 nulldrv_PaintRgn, /* pPaintRgn */
810 nulldrv_PatBlt, /* pPatBlt */
811 nulldrv_Pie, /* pPie */
812 nulldrv_PolyBezier, /* pPolyBezier */
813 nulldrv_PolyBezierTo, /* pPolyBezierTo */
814 nulldrv_PolyDraw, /* pPolyDraw */
815 nulldrv_PolyPolygon, /* pPolyPolygon */
816 nulldrv_PolyPolyline, /* pPolyPolyline */
817 nulldrv_Polygon, /* pPolygon */
818 nulldrv_Polyline, /* pPolyline */
819 nulldrv_PolylineTo, /* pPolylineTo */
820 nulldrv_PutImage, /* pPutImage */
821 nulldrv_RealizeDefaultPalette, /* pRealizeDefaultPalette */
822 nulldrv_RealizePalette, /* pRealizePalette */
823 nulldrv_Rectangle, /* pRectangle */
824 nulldrv_ResetDC, /* pResetDC */
825 nulldrv_RestoreDC, /* pRestoreDC */
826 nulldrv_RoundRect, /* pRoundRect */
827 nulldrv_SaveDC, /* pSaveDC */
828 nulldrv_ScaleViewportExtEx, /* pScaleViewportExt */
829 nulldrv_ScaleWindowExtEx, /* pScaleWindowExt */
830 nulldrv_SelectBitmap, /* pSelectBitmap */
831 nulldrv_SelectBrush, /* pSelectBrush */
832 nulldrv_SelectClipPath, /* pSelectClipPath */
833 nulldrv_SelectFont, /* pSelectFont */
834 nulldrv_SelectPalette, /* pSelectPalette */
835 nulldrv_SelectPen, /* pSelectPen */
836 nulldrv_SetArcDirection, /* pSetArcDirection */
837 nulldrv_SetBkColor, /* pSetBkColor */
838 nulldrv_SetBkMode, /* pSetBkMode */
839 nulldrv_SetDCBrushColor, /* pSetDCBrushColor */
840 nulldrv_SetDCPenColor, /* pSetDCPenColor */
841 nulldrv_SetDIBColorTable, /* pSetDIBColorTable */
842 nulldrv_SetDIBitsToDevice, /* pSetDIBitsToDevice */
843 nulldrv_SetDeviceClipping, /* pSetDeviceClipping */
844 nulldrv_SetDeviceGammaRamp, /* pSetDeviceGammaRamp */
845 nulldrv_SetLayout, /* pSetLayout */
846 nulldrv_SetMapMode, /* pSetMapMode */
847 nulldrv_SetMapperFlags, /* pSetMapperFlags */
848 nulldrv_SetPixel, /* pSetPixel */
849 nulldrv_SetPixelFormat, /* pSetPixelFormat */
850 nulldrv_SetPolyFillMode, /* pSetPolyFillMode */
851 nulldrv_SetROP2, /* pSetROP2 */
852 nulldrv_SetRelAbs, /* pSetRelAbs */
853 nulldrv_SetStretchBltMode, /* pSetStretchBltMode */
854 nulldrv_SetTextAlign, /* pSetTextAlign */
855 nulldrv_SetTextCharacterExtra, /* pSetTextCharacterExtra */
856 nulldrv_SetTextColor, /* pSetTextColor */
857 nulldrv_SetTextJustification, /* pSetTextJustification */
858 nulldrv_SetViewportExtEx, /* pSetViewportExt */
859 nulldrv_SetViewportOrgEx, /* pSetViewportOrg */
860 nulldrv_SetWindowExtEx, /* pSetWindowExt */
861 nulldrv_SetWindowOrgEx, /* pSetWindowOrg */
862 nulldrv_SetWorldTransform, /* pSetWorldTransform */
863 nulldrv_StartDoc, /* pStartDoc */
864 nulldrv_StartPage, /* pStartPage */
865 nulldrv_StretchBlt, /* pStretchBlt */
866 nulldrv_StretchDIBits, /* pStretchDIBits */
867 nulldrv_StrokeAndFillPath, /* pStrokeAndFillPath */
868 nulldrv_StrokePath, /* pStrokePath */
869 nulldrv_SwapBuffers, /* pSwapBuffers */
870 nulldrv_UnrealizePalette, /* pUnrealizePalette */
871 nulldrv_WidenPath, /* pWidenPath */
872 nulldrv_wglCopyContext, /* pwglCopyContext */
873 nulldrv_wglCreateContext, /* pwglCreateContext */
874 nulldrv_wglCreateContextAttribsARB, /* pwglCreateContextAttribsARB */
875 nulldrv_wglDeleteContext, /* pwglDeleteContext */
876 nulldrv_wglGetPbufferDCARB, /* pwglGetPbufferDCARB */
877 nulldrv_wglGetProcAddress, /* pwglGetProcAddress */
878 nulldrv_wglMakeContextCurrentARB, /* pwglMakeContextCurrentARB */
879 nulldrv_wglMakeCurrent, /* pwglMakeCurrent */
880 nulldrv_wglSetPixelFormatWINE, /* pwglSetPixelFormatWINE */
881 nulldrv_wglShareLists, /* pwglShareLists */
882 nulldrv_wglUseFontBitmapsA, /* pwglUseFontBitmapsA */
883 nulldrv_wglUseFontBitmapsW, /* pwglUseFontBitmapsW */
887 /*****************************************************************************
888 * DRIVER_GetDriverName
891 BOOL DRIVER_GetDriverName( LPCWSTR device, LPWSTR driver, DWORD size )
893 static const WCHAR displayW[] = { 'd','i','s','p','l','a','y',0 };
894 static const WCHAR devicesW[] = { 'd','e','v','i','c','e','s',0 };
895 static const WCHAR display1W[] = {'\\','\\','.','\\','D','I','S','P','L','A','Y','1',0};
896 static const WCHAR empty_strW[] = { 0 };
897 WCHAR *p;
899 /* display is a special case */
900 if (!strcmpiW( device, displayW ) ||
901 !strcmpiW( device, display1W ))
903 lstrcpynW( driver, displayW, size );
904 return TRUE;
907 size = GetProfileStringW(devicesW, device, empty_strW, driver, size);
908 if(!size) {
909 WARN("Unable to find %s in [devices] section of win.ini\n", debugstr_w(device));
910 return FALSE;
912 p = strchrW(driver, ',');
913 if(!p)
915 WARN("%s entry in [devices] section of win.ini is malformed.\n", debugstr_w(device));
916 return FALSE;
918 *p = 0;
919 TRACE("Found %s for %s\n", debugstr_w(driver), debugstr_w(device));
920 return TRUE;
924 /***********************************************************************
925 * GdiConvertToDevmodeW (GDI32.@)
927 DEVMODEW * WINAPI GdiConvertToDevmodeW(const DEVMODEA *dmA)
929 DEVMODEW *dmW;
930 WORD dmW_size, dmA_size;
932 dmA_size = dmA->dmSize;
934 /* this is the minimal dmSize that XP accepts */
935 if (dmA_size < FIELD_OFFSET(DEVMODEA, dmFields))
936 return NULL;
938 if (dmA_size > sizeof(DEVMODEA))
939 dmA_size = sizeof(DEVMODEA);
941 dmW_size = dmA_size + CCHDEVICENAME;
942 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
943 dmW_size += CCHFORMNAME;
945 dmW = HeapAlloc(GetProcessHeap(), 0, dmW_size + dmA->dmDriverExtra);
946 if (!dmW) return NULL;
948 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmDeviceName, -1,
949 dmW->dmDeviceName, CCHDEVICENAME);
950 /* copy slightly more, to avoid long computations */
951 memcpy(&dmW->dmSpecVersion, &dmA->dmSpecVersion, dmA_size - CCHDEVICENAME);
953 if (dmA_size >= FIELD_OFFSET(DEVMODEA, dmFormName) + CCHFORMNAME)
955 if (dmA->dmFields & DM_FORMNAME)
956 MultiByteToWideChar(CP_ACP, 0, (const char*) dmA->dmFormName, -1,
957 dmW->dmFormName, CCHFORMNAME);
958 else
959 dmW->dmFormName[0] = 0;
961 if (dmA_size > FIELD_OFFSET(DEVMODEA, dmLogPixels))
962 memcpy(&dmW->dmLogPixels, &dmA->dmLogPixels, dmA_size - FIELD_OFFSET(DEVMODEA, dmLogPixels));
965 if (dmA->dmDriverExtra)
966 memcpy((char *)dmW + dmW_size, (const char *)dmA + dmA_size, dmA->dmDriverExtra);
968 dmW->dmSize = dmW_size;
970 return dmW;
974 /*****************************************************************************
975 * @ [GDI32.100]
977 * This should thunk to 16-bit and simply call the proc with the given args.
979 INT WINAPI GDI_CallDevInstall16( FARPROC16 lpfnDevInstallProc, HWND hWnd,
980 LPSTR lpModelName, LPSTR OldPort, LPSTR NewPort )
982 FIXME("(%p, %p, %s, %s, %s)\n", lpfnDevInstallProc, hWnd, lpModelName, OldPort, NewPort );
983 return -1;
986 /*****************************************************************************
987 * @ [GDI32.101]
989 * This should load the correct driver for lpszDevice and calls this driver's
990 * ExtDeviceModePropSheet proc.
992 * Note: The driver calls a callback routine for each property sheet page; these
993 * pages are supposed to be filled into the structure pointed to by lpPropSheet.
994 * The layout of this structure is:
996 * struct
998 * DWORD nPages;
999 * DWORD unknown;
1000 * HPROPSHEETPAGE pages[10];
1001 * };
1003 INT WINAPI GDI_CallExtDeviceModePropSheet16( HWND hWnd, LPCSTR lpszDevice,
1004 LPCSTR lpszPort, LPVOID lpPropSheet )
1006 FIXME("(%p, %s, %s, %p)\n", hWnd, lpszDevice, lpszPort, lpPropSheet );
1007 return -1;
1010 /*****************************************************************************
1011 * @ [GDI32.102]
1013 * This should load the correct driver for lpszDevice and call this driver's
1014 * ExtDeviceMode proc.
1016 * FIXME: convert ExtDeviceMode to unicode in the driver interface
1018 INT WINAPI GDI_CallExtDeviceMode16( HWND hwnd,
1019 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
1020 LPSTR lpszPort, LPDEVMODEA lpdmInput,
1021 LPSTR lpszProfile, DWORD fwMode )
1023 WCHAR deviceW[300];
1024 WCHAR bufW[300];
1025 char buf[300];
1026 HDC hdc;
1027 DC *dc;
1028 INT ret = -1;
1030 TRACE("(%p, %p, %s, %s, %p, %s, %d)\n",
1031 hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, fwMode );
1033 if (!lpszDevice) return -1;
1034 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1036 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1038 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1040 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1042 if ((dc = get_dc_ptr( hdc )))
1044 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtDeviceMode );
1045 ret = physdev->funcs->pExtDeviceMode( buf, hwnd, lpdmOutput, lpszDevice, lpszPort,
1046 lpdmInput, lpszProfile, fwMode );
1047 release_dc_ptr( dc );
1049 DeleteDC( hdc );
1050 return ret;
1053 /****************************************************************************
1054 * @ [GDI32.103]
1056 * This should load the correct driver for lpszDevice and calls this driver's
1057 * AdvancedSetupDialog proc.
1059 INT WINAPI GDI_CallAdvancedSetupDialog16( HWND hwnd, LPSTR lpszDevice,
1060 LPDEVMODEA devin, LPDEVMODEA devout )
1062 TRACE("(%p, %s, %p, %p)\n", hwnd, lpszDevice, devin, devout );
1063 return -1;
1066 /*****************************************************************************
1067 * @ [GDI32.104]
1069 * This should load the correct driver for lpszDevice and calls this driver's
1070 * DeviceCapabilities proc.
1072 * FIXME: convert DeviceCapabilities to unicode in the driver interface
1074 DWORD WINAPI GDI_CallDeviceCapabilities16( LPCSTR lpszDevice, LPCSTR lpszPort,
1075 WORD fwCapability, LPSTR lpszOutput,
1076 LPDEVMODEA lpdm )
1078 WCHAR deviceW[300];
1079 WCHAR bufW[300];
1080 char buf[300];
1081 HDC hdc;
1082 DC *dc;
1083 INT ret = -1;
1085 TRACE("(%s, %s, %d, %p, %p)\n", lpszDevice, lpszPort, fwCapability, lpszOutput, lpdm );
1087 if (!lpszDevice) return -1;
1088 if (!MultiByteToWideChar(CP_ACP, 0, lpszDevice, -1, deviceW, 300)) return -1;
1090 if(!DRIVER_GetDriverName( deviceW, bufW, 300 )) return -1;
1092 if (!WideCharToMultiByte(CP_ACP, 0, bufW, -1, buf, 300, NULL, NULL)) return -1;
1094 if (!(hdc = CreateICA( buf, lpszDevice, lpszPort, NULL ))) return -1;
1096 if ((dc = get_dc_ptr( hdc )))
1098 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pDeviceCapabilities );
1099 ret = physdev->funcs->pDeviceCapabilities( buf, lpszDevice, lpszPort,
1100 fwCapability, lpszOutput, lpdm );
1101 release_dc_ptr( dc );
1103 DeleteDC( hdc );
1104 return ret;
1108 /************************************************************************
1109 * Escape [GDI32.@]
1111 INT WINAPI Escape( HDC hdc, INT escape, INT in_count, LPCSTR in_data, LPVOID out_data )
1113 INT ret;
1114 POINT *pt;
1116 switch (escape)
1118 case ABORTDOC:
1119 return AbortDoc( hdc );
1121 case ENDDOC:
1122 return EndDoc( hdc );
1124 case GETPHYSPAGESIZE:
1125 pt = out_data;
1126 pt->x = GetDeviceCaps( hdc, PHYSICALWIDTH );
1127 pt->y = GetDeviceCaps( hdc, PHYSICALHEIGHT );
1128 return 1;
1130 case GETPRINTINGOFFSET:
1131 pt = out_data;
1132 pt->x = GetDeviceCaps( hdc, PHYSICALOFFSETX );
1133 pt->y = GetDeviceCaps( hdc, PHYSICALOFFSETY );
1134 return 1;
1136 case GETSCALINGFACTOR:
1137 pt = out_data;
1138 pt->x = GetDeviceCaps( hdc, SCALINGFACTORX );
1139 pt->y = GetDeviceCaps( hdc, SCALINGFACTORY );
1140 return 1;
1142 case NEWFRAME:
1143 return EndPage( hdc );
1145 case SETABORTPROC:
1146 return SetAbortProc( hdc, (ABORTPROC)in_data );
1148 case STARTDOC:
1150 DOCINFOA doc;
1151 char *name = NULL;
1153 /* in_data may not be 0 terminated so we must copy it */
1154 if (in_data)
1156 name = HeapAlloc( GetProcessHeap(), 0, in_count+1 );
1157 memcpy( name, in_data, in_count );
1158 name[in_count] = 0;
1160 /* out_data is actually a pointer to the DocInfo structure and used as
1161 * a second input parameter */
1162 if (out_data) doc = *(DOCINFOA *)out_data;
1163 else
1165 doc.cbSize = sizeof(doc);
1166 doc.lpszOutput = NULL;
1167 doc.lpszDatatype = NULL;
1168 doc.fwType = 0;
1170 doc.lpszDocName = name;
1171 ret = StartDocA( hdc, &doc );
1172 HeapFree( GetProcessHeap(), 0, name );
1173 if (ret > 0) ret = StartPage( hdc );
1174 return ret;
1177 case QUERYESCSUPPORT:
1179 const INT *ptr = (const INT *)in_data;
1180 if (in_count < sizeof(INT)) return 0;
1181 switch(*ptr)
1183 case ABORTDOC:
1184 case ENDDOC:
1185 case GETPHYSPAGESIZE:
1186 case GETPRINTINGOFFSET:
1187 case GETSCALINGFACTOR:
1188 case NEWFRAME:
1189 case QUERYESCSUPPORT:
1190 case SETABORTPROC:
1191 case STARTDOC:
1192 return TRUE;
1194 break;
1198 /* if not handled internally, pass it to the driver */
1199 return ExtEscape( hdc, escape, in_count, in_data, 0, out_data );
1203 /******************************************************************************
1204 * ExtEscape [GDI32.@]
1206 * Access capabilities of a particular device that are not available through GDI.
1208 * PARAMS
1209 * hdc [I] Handle to device context
1210 * nEscape [I] Escape function
1211 * cbInput [I] Number of bytes in input structure
1212 * lpszInData [I] Pointer to input structure
1213 * cbOutput [I] Number of bytes in output structure
1214 * lpszOutData [O] Pointer to output structure
1216 * RETURNS
1217 * Success: >0
1218 * Not implemented: 0
1219 * Failure: <0
1221 INT WINAPI ExtEscape( HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData,
1222 INT cbOutput, LPSTR lpszOutData )
1224 INT ret = 0;
1225 DC * dc = get_dc_ptr( hdc );
1227 if (dc)
1229 PHYSDEV physdev = GET_DC_PHYSDEV( dc, pExtEscape );
1230 update_dc( dc );
1231 ret = physdev->funcs->pExtEscape( physdev, nEscape, cbInput, lpszInData, cbOutput, lpszOutData );
1232 release_dc_ptr( dc );
1234 return ret;
1238 /*******************************************************************
1239 * DrawEscape [GDI32.@]
1243 INT WINAPI DrawEscape(HDC hdc, INT nEscape, INT cbInput, LPCSTR lpszInData)
1245 FIXME("DrawEscape, stub\n");
1246 return 0;
1249 /*******************************************************************
1250 * NamedEscape [GDI32.@]
1252 INT WINAPI NamedEscape( HDC hdc, LPCWSTR pDriver, INT nEscape, INT cbInput, LPCSTR lpszInData,
1253 INT cbOutput, LPSTR lpszOutData )
1255 FIXME("(%p, %s, %d, %d, %p, %d, %p)\n",
1256 hdc, wine_dbgstr_w(pDriver), nEscape, cbInput, lpszInData, cbOutput,
1257 lpszOutData);
1258 return 0;
1261 /*******************************************************************
1262 * DdQueryDisplaySettingsUniqueness [GDI32.@]
1263 * GdiEntry13 [GDI32.@]
1265 ULONG WINAPI DdQueryDisplaySettingsUniqueness(VOID)
1267 static int warn_once;
1269 if (!warn_once++)
1270 FIXME("stub\n");
1271 return 0;