blob: 61e6a9d13a084d5b11f65441d20b0846b47e292d [file] [log] [blame]
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00001/*
Alexandre Julliard767e6f61998-08-09 12:47:43 +00002 * PostScript driver initialization functions
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00003 *
4 * Copyright 1998 Huw D M Davies
5 *
6 */
Jeff Garzikc3e1f721999-02-19 15:42:11 +00007#include <string.h>
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +00008
Alexandre Julliarda0d77311998-09-13 16:32:00 +00009#include "gdi.h"
10#include "psdrv.h"
Alexandre Julliard61fece01999-06-26 19:09:08 +000011#include "debugtools.h"
Alexandre Julliarda0d77311998-09-13 16:32:00 +000012#include "heap.h"
13#include "winreg.h"
Alexandre Julliard59545601999-02-10 06:52:57 +000014#include "winspool.h"
Alexandre Julliarda0d77311998-09-13 16:32:00 +000015#include "winerror.h"
Huw D M Davies91547cb1999-07-24 10:11:05 +000016#include "options.h"
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000017
Dimitrie O. Paun529da542000-11-27 23:54:25 +000018DEFAULT_DEBUG_CHANNEL(psdrv);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000019
Alexandre Julliarda3960291999-02-26 11:11:13 +000020static BOOL PSDRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
Huw D M Daviese39b6761999-05-17 16:20:51 +000021 LPCSTR output, const DEVMODEA* initData );
Alexandre Julliarda3960291999-02-26 11:11:13 +000022static BOOL PSDRV_DeleteDC( DC *dc );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000023
24static const DC_FUNCTIONS PSDRV_Funcs =
25{
Huw D M Daviese39b6761999-05-17 16:20:51 +000026 NULL, /* pAbortDoc */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000027 NULL, /* pAbortPath */
28 NULL, /* pAngleArc */
Huw D M Davies14c99d01998-10-24 10:44:05 +000029 PSDRV_Arc, /* pArc */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000030 NULL, /* pArcTo */
31 NULL, /* pBeginPath */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000032 NULL, /* pBitBlt */
Huw D M Davies87f87bf1998-10-28 09:53:53 +000033 NULL, /* pBitmapBits */
Lionel Ulmerbedf40b2000-05-12 20:18:14 +000034 NULL, /* pChoosePixelFormat */
Huw D M Davies14c99d01998-10-24 10:44:05 +000035 PSDRV_Chord, /* pChord */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000036 NULL, /* pCloseFigure */
Huw D M Davies87f87bf1998-10-28 09:53:53 +000037 NULL, /* pCreateBitmap */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000038 PSDRV_CreateDC, /* pCreateDC */
Patrik Stridvallb87fe2e1999-04-01 08:16:08 +000039 NULL, /* pCreateDIBSection */
40 NULL, /* pCreateDIBSection16 */
Huw D M Daviese39b6761999-05-17 16:20:51 +000041 PSDRV_DeleteDC, /* pDeleteDC */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000042 NULL, /* pDeleteObject */
Lionel Ulmerbedf40b2000-05-12 20:18:14 +000043 NULL, /* pDescribePixelFormat */
Huw D M Daviese39b6761999-05-17 16:20:51 +000044 PSDRV_DeviceCapabilities, /* pDeviceCapabilities */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000045 PSDRV_Ellipse, /* pEllipse */
Huw D M Davies81561501999-07-25 11:25:59 +000046 PSDRV_EndDoc, /* pEndDoc */
47 PSDRV_EndPage, /* pEndPage */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000048 NULL, /* pEndPath */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000049 PSDRV_EnumDeviceFonts, /* pEnumDeviceFonts */
50 PSDRV_Escape, /* pEscape */
51 NULL, /* pExcludeClipRect */
Huw D M Daviese39b6761999-05-17 16:20:51 +000052 PSDRV_ExtDeviceMode, /* pExtDeviceMode */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000053 NULL, /* pExtFloodFill */
54 PSDRV_ExtTextOut, /* pExtTextOut */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000055 NULL, /* pFillPath */
Huw D M Davies7603dea1999-04-25 09:24:23 +000056 NULL, /* pFillRgn */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000057 NULL, /* pFlattenPath */
Huw D M Davies7603dea1999-04-25 09:24:23 +000058 NULL, /* pFrameRgn */
Huw D M Davies14c99d01998-10-24 10:44:05 +000059 PSDRV_GetCharWidth, /* pGetCharWidth */
Alexandre Julliard07e42132000-03-19 21:19:21 +000060 NULL, /* pGetDCOrgEx */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000061 NULL, /* pGetPixel */
Lionel Ulmerbedf40b2000-05-12 20:18:14 +000062 NULL, /* pGetPixelFormat */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000063 PSDRV_GetTextExtentPoint, /* pGetTextExtentPoint */
64 PSDRV_GetTextMetrics, /* pGetTextMetrics */
65 NULL, /* pIntersectClipRect */
Huw D M Davies7603dea1999-04-25 09:24:23 +000066 NULL, /* pInvertRgn */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000067 PSDRV_LineTo, /* pLineTo */
Patrik Stridvalld3534c32000-11-05 03:28:18 +000068 NULL, /* pMoveTo */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000069 NULL, /* pOffsetClipRgn */
70 NULL, /* pOffsetViewportOrg (optional) */
71 NULL, /* pOffsetWindowOrg (optional) */
72 NULL, /* pPaintRgn */
Huw D M Daviese28224f1999-07-10 10:21:03 +000073 PSDRV_PatBlt, /* pPatBlt */
Huw D M Davies14c99d01998-10-24 10:44:05 +000074 PSDRV_Pie, /* pPie */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000075 NULL, /* pPolyBezier */
76 NULL, /* pPolyBezierTo */
77 NULL, /* pPolyDraw */
Huw D M Davies14c99d01998-10-24 10:44:05 +000078 PSDRV_PolyPolygon, /* pPolyPolygon */
79 PSDRV_PolyPolyline, /* pPolyPolyline */
Alexandre Julliard767e6f61998-08-09 12:47:43 +000080 PSDRV_Polygon, /* pPolygon */
81 PSDRV_Polyline, /* pPolyline */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000082 NULL, /* pPolylineTo */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000083 NULL, /* pRealizePalette */
84 PSDRV_Rectangle, /* pRectangle */
85 NULL, /* pRestoreDC */
Huw D M Davies14c99d01998-10-24 10:44:05 +000086 PSDRV_RoundRect, /* pRoundRect */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000087 NULL, /* pSaveDC */
88 NULL, /* pScaleViewportExt (optional) */
89 NULL, /* pScaleWindowExt (optional) */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +000090 NULL, /* pSelectClipPath */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000091 NULL, /* pSelectClipRgn */
92 PSDRV_SelectObject, /* pSelectObject */
93 NULL, /* pSelectPalette */
Alexandre Julliarda0d77311998-09-13 16:32:00 +000094 PSDRV_SetBkColor, /* pSetBkColor */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000095 NULL, /* pSetBkMode */
Stephane Lussier62efee21999-10-13 13:58:45 +000096 PSDRV_SetDeviceClipping, /* pSetDeviceClipping */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +000097 NULL, /* pSetDIBitsToDevice */
98 NULL, /* pSetMapMode (optional) */
99 NULL, /* pSetMapperFlags */
Huw D M Davies14c99d01998-10-24 10:44:05 +0000100 PSDRV_SetPixel, /* pSetPixel */
Lionel Ulmerbedf40b2000-05-12 20:18:14 +0000101 NULL, /* pSetPixelFormat */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000102 NULL, /* pSetPolyFillMode */
103 NULL, /* pSetROP2 */
104 NULL, /* pSetRelAbs */
105 NULL, /* pSetStretchBltMode */
106 NULL, /* pSetTextAlign */
107 NULL, /* pSetTextCharacterExtra */
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000108 PSDRV_SetTextColor, /* pSetTextColor */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000109 NULL, /* pSetTextJustification */
110 NULL, /* pSetViewportExt (optional) */
111 NULL, /* pSetViewportOrg (optional) */
112 NULL, /* pSetWindowExt (optional) */
113 NULL, /* pSetWindowOrg (optional) */
Huw D M Davies81561501999-07-25 11:25:59 +0000114 PSDRV_StartDoc, /* pStartDoc */
115 PSDRV_StartPage, /* pStartPage */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000116 NULL, /* pStretchBlt */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000117 PSDRV_StretchDIBits, /* pStretchDIBits */
118 NULL, /* pStrokeAndFillPath */
119 NULL, /* pStrokePath */
Lionel Ulmerbedf40b2000-05-12 20:18:14 +0000120 NULL, /* pSwapBuffers */
Huw D M Daviesf0f8da51999-12-05 23:54:02 +0000121 NULL /* pWidenPath */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000122};
123
124
125/* Default entries for devcaps */
126
127static DeviceCaps PSDRV_DevCaps = {
128/* version */ 0,
129/* technology */ DT_RASPRINTER,
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000130/* horzSize */ 210,
131/* vertSize */ 297,
132/* horzRes */ 4961,
133/* vertRes */ 7016,
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000134/* bitsPixel */ 1,
135/* planes */ 1,
136/* numBrushes */ -1,
137/* numPens */ 10,
138/* numMarkers */ 0,
139/* numFonts */ 39,
140/* numColors */ 2,
141/* pdeviceSize */ 0,
142/* curveCaps */ CC_CIRCLES | CC_PIE | CC_CHORD | CC_ELLIPSES |
143 CC_WIDE | CC_STYLED | CC_WIDESTYLED | CC_INTERIORS |
144 CC_ROUNDRECT,
145/* lineCaps */ LC_POLYLINE | LC_MARKER | LC_POLYMARKER | LC_WIDE |
146 LC_STYLED | LC_WIDESTYLED | LC_INTERIORS,
147/* polygoalnCaps */ PC_POLYGON | PC_RECTANGLE | PC_WINDPOLYGON |
148 PC_SCANLINE | PC_WIDE | PC_STYLED | PC_WIDESTYLED |
149 PC_INTERIORS,
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000150/* textCaps */ TC_CR_ANY, /* psdrv 0x59f7 */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000151/* clipCaps */ CP_RECTANGLE,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000152/* rasterCaps */ RC_BITBLT | RC_BITMAP64 | RC_GDI20_OUTPUT |
153 RC_DIBTODEV | RC_STRETCHBLT |
154 RC_STRETCHDIB, /* psdrv 0x6e99 */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000155/* aspectX */ 600,
156/* aspectY */ 600,
157/* aspectXY */ 848,
158/* pad1 */ { 0 },
159/* logPixelsX */ 600,
160/* logPixelsY */ 600,
161/* pad2 */ { 0 },
162/* palette size */ 0,
163/* ..etc */ 0, 0 };
164
Huw D M Daviese39b6761999-05-17 16:20:51 +0000165static PSDRV_DEVMODEA DefaultDevmode =
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000166{
167 { /* dmPublic */
168/* dmDeviceName */ "Wine PostScript Driver",
169/* dmSpecVersion */ 0x30a,
170/* dmDriverVersion */ 0x001,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000171/* dmSize */ sizeof(DEVMODEA),
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000172/* dmDriverExtra */ 0,
Luc Tourangeaueffc55e1999-07-18 18:34:45 +0000173/* dmFields */ DM_ORIENTATION | DM_PAPERSIZE | DM_SCALE |
174 DM_COPIES | DM_DEFAULTSOURCE | DM_COLOR |
175 DM_DUPLEX | DM_YRESOLUTION | DM_TTOPTION,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000176 { /* u1 */
177 { /* s1 */
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000178/* dmOrientation */ DMORIENT_PORTRAIT,
179/* dmPaperSize */ DMPAPER_A4,
180/* dmPaperLength */ 2969,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000181/* dmPaperWidth */ 2101
182 }
183 },
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000184/* dmScale */ 100, /* ?? */
185/* dmCopies */ 1,
186/* dmDefaultSource */ DMBIN_AUTO,
187/* dmPrintQuality */ 0,
188/* dmColor */ DMCOLOR_MONOCHROME,
189/* dmDuplex */ 0,
190/* dmYResolution */ 0,
191/* dmTTOption */ DMTT_SUBDEV,
192/* dmCollate */ 0,
193/* dmFormName */ "",
194/* dmUnusedPadding */ 0,
195/* dmBitsPerPel */ 0,
196/* dmPelsWidth */ 0,
197/* dmPelsHeight */ 0,
198/* dmDisplayFlags */ 0,
Patrik Stridvalla9f6a9d2000-10-24 02:22:16 +0000199/* dmDisplayFrequency */ 0,
200/* dmICMMethod */ 0,
201/* dmICMIntent */ 0,
202/* dmMediaType */ 0,
203/* dmDitherType */ 0,
204/* dmReserved1 */ 0,
205/* dmReserved2 */ 0,
206/* dmPanningWidth */ 0,
207/* dmPanningHeight */ 0
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000208 },
209 { /* dmDocPrivate */
Patrik Stridvalla9f6a9d2000-10-24 02:22:16 +0000210 /* dummy */ 0
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000211 },
212 { /* dmDrvPrivate */
Patrik Stridvalla9f6a9d2000-10-24 02:22:16 +0000213 /* ppdfilename */ "default.ppd",
214 /* numInstalledOptions */ 0
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000215 }
216};
217
Alexandre Julliarda3960291999-02-26 11:11:13 +0000218HANDLE PSDRV_Heap = 0;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000219
Alexandre Julliarda3960291999-02-26 11:11:13 +0000220static HANDLE PSDRV_DefaultFont = 0;
221static LOGFONTA DefaultLogFont = {
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000222 100, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, ANSI_CHARSET, 0, 0,
223 DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN, ""
224};
225
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000226/*********************************************************************
227 * PSDRV_Init
228 *
229 * Initializes font metrics and registers driver. Called from GDI_Init()
230 *
231 */
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000232BOOL WINAPI PSDRV_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000233{
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000234 TRACE("(0x%4x, 0x%08lx, %p)\n", hinst, reason, reserved);
235
236 switch(reason) {
237 case DLL_PROCESS_ATTACH:
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000238 /* FIXME: return FALSE if we fail any of these steps */
239 PSDRV_Heap = HeapCreate(0, 0x10000, 0);
240 PSDRV_GetFontMetrics();
241 PSDRV_DefaultFont = CreateFontIndirectA(&DefaultLogFont);
Dmitry Timoshkovad970052000-08-26 20:27:28 +0000242 /* Register driver as "WINEPS", "WINEPS.DLL" and "WINEPS.DRV"
243 to allow an easy configuring for users */
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000244 DRIVER_RegisterDriver( "WINEPS", &PSDRV_Funcs );
Dmitry Timoshkovad970052000-08-26 20:27:28 +0000245 DRIVER_RegisterDriver( "WINEPS.DLL", &PSDRV_Funcs );
246 DRIVER_RegisterDriver( "WINEPS.DRV", &PSDRV_Funcs );
Alexandre Julliard06187462001-01-17 22:03:18 +0000247 break;
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000248 case DLL_PROCESS_DETACH:
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000249 DeleteObject( PSDRV_DefaultFont );
250 HeapDestroy( PSDRV_Heap );
251 DRIVER_UnregisterDriver( "WINEPS" );
Dmitry Timoshkovad970052000-08-26 20:27:28 +0000252 DRIVER_UnregisterDriver( "WINEPS.DLL" );
253 DRIVER_UnregisterDriver( "WINEPS.DRV" );
Alexandre Julliard06187462001-01-17 22:03:18 +0000254 break;
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000255 }
256
257 return TRUE;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000258}
259
Dimitrie O. Paun84bde6a2000-05-30 20:27:23 +0000260
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000261/**********************************************************************
262 * PSDRV_CreateDC
263 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000264static BOOL PSDRV_CreateDC( DC *dc, LPCSTR driver, LPCSTR device,
Huw D M Daviese39b6761999-05-17 16:20:51 +0000265 LPCSTR output, const DEVMODEA* initData )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000266{
267 PSDRV_PDEVICE *physDev;
Noel Borthwick86b686f1999-06-05 08:52:30 +0000268 PRINTERINFO *pi;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000269 DeviceCaps *devCaps;
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000270
Noel Borthwick86b686f1999-06-05 08:52:30 +0000271 /* If no device name was specified, retrieve the device name
272 * from the DEVMODE structure from the DC's physDev.
273 * (See CreateCompatibleDC) */
274 if ( !device && dc->physDev )
275 {
276 physDev = (PSDRV_PDEVICE *)dc->physDev;
277 device = physDev->Devmode->dmPublic.dmDeviceName;
278 }
279 pi = PSDRV_FindPrinterInfo(device);
280
Alexandre Julliard61fece01999-06-26 19:09:08 +0000281 TRACE("(%s %s %s %p)\n", driver, device, output, initData);
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000282
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000283 if(!pi) return FALSE;
284
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000285 if(!pi->Fonts) {
Alexandre Julliard61fece01999-06-26 19:09:08 +0000286 MESSAGE("To use WINEPS you need to install some AFM files.\n");
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000287 return FALSE;
288 }
289
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000290 physDev = (PSDRV_PDEVICE *)HeapAlloc( PSDRV_Heap, HEAP_ZERO_MEMORY,
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000291 sizeof(*physDev) );
292 if (!physDev) return FALSE;
293 dc->physDev = physDev;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000294
295 physDev->pi = pi;
296
Huw D M Daviese39b6761999-05-17 16:20:51 +0000297 physDev->Devmode = (PSDRV_DEVMODEA *)HeapAlloc( PSDRV_Heap, 0,
298 sizeof(PSDRV_DEVMODEA) );
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000299 if(!physDev->Devmode) {
300 HeapFree( PSDRV_Heap, 0, physDev );
301 return FALSE;
302 }
303
Huw D M Daviese39b6761999-05-17 16:20:51 +0000304 memcpy( physDev->Devmode, pi->Devmode, sizeof(PSDRV_DEVMODEA) );
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000305
306 if(initData) {
Huw D M Daviese39b6761999-05-17 16:20:51 +0000307 PSDRV_MergeDevmodes(physDev->Devmode, (PSDRV_DEVMODEA *)initData, pi);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000308 }
309
310
311 devCaps = HeapAlloc( PSDRV_Heap, 0, sizeof(PSDRV_DevCaps) );
312 memcpy(devCaps, &PSDRV_DevCaps, sizeof(PSDRV_DevCaps));
313
Huw D M Daviese39b6761999-05-17 16:20:51 +0000314 if(physDev->Devmode->dmPublic.u1.s1.dmOrientation == DMORIENT_PORTRAIT) {
315 devCaps->horzSize = physDev->Devmode->dmPublic.u1.s1.dmPaperWidth / 10;
316 devCaps->vertSize = physDev->Devmode->dmPublic.u1.s1.dmPaperLength / 10;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000317 } else {
Huw D M Daviese39b6761999-05-17 16:20:51 +0000318 devCaps->horzSize = physDev->Devmode->dmPublic.u1.s1.dmPaperLength / 10;
319 devCaps->vertSize = physDev->Devmode->dmPublic.u1.s1.dmPaperWidth / 10;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000320 }
321
322 devCaps->horzRes = physDev->pi->ppd->DefaultResolution *
323 devCaps->horzSize / 25.4;
324 devCaps->vertRes = physDev->pi->ppd->DefaultResolution *
325 devCaps->vertSize / 25.4;
326
327 /* Are aspect[XY] and logPixels[XY] correct? */
328 /* Need to handle different res in x and y => fix ppd */
329 devCaps->aspectX = devCaps->logPixelsX =
330 physDev->pi->ppd->DefaultResolution;
331 devCaps->aspectY = devCaps->logPixelsY =
332 physDev->pi->ppd->DefaultResolution;
333 devCaps->aspectXY = (int)hypot( (double)devCaps->aspectX,
334 (double)devCaps->aspectY );
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000335
336 if(physDev->pi->ppd->ColorDevice) {
337 devCaps->bitsPixel = 8;
338 devCaps->numColors = 256;
339 /* FIXME are these values OK? */
340 }
341
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000342 /* etc */
343
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000344 dc->devCaps = devCaps;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000345
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000346 dc->hVisRgn = CreateRectRgn(0, 0, dc->devCaps->horzRes,
347 dc->devCaps->vertRes);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000348
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000349 dc->hFont = PSDRV_DefaultFont;
Huw D M Davies91547cb1999-07-24 10:11:05 +0000350 physDev->job.output = output ?
351 HEAP_strdupA( PSDRV_Heap, 0, output ) :
352 HEAP_strdupA( PSDRV_Heap, 0, "LPT1:" ); /* HACK */
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000353 physDev->job.hJob = 0;
354 return TRUE;
355}
356
357
358/**********************************************************************
359 * PSDRV_DeleteDC
360 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000361static BOOL PSDRV_DeleteDC( DC *dc )
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000362{
363 PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000364
Alexandre Julliard61fece01999-06-26 19:09:08 +0000365 TRACE("\n");
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000366
367 HeapFree( PSDRV_Heap, 0, physDev->Devmode );
368 HeapFree( PSDRV_Heap, 0, physDev->job.output );
Alexandre Julliard2239abb2000-11-05 02:05:07 +0000369 HeapFree( PSDRV_Heap, 0, (void *)dc->devCaps );
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000370 HeapFree( PSDRV_Heap, 0, physDev );
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000371 dc->physDev = NULL;
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000372
Alexandre Julliardebfc0fe1998-06-28 18:40:26 +0000373 return TRUE;
374}
375
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000376
377
378
379/**********************************************************************
380 * PSDRV_FindPrinterInfo
381 */
382PRINTERINFO *PSDRV_FindPrinterInfo(LPCSTR name)
383{
384 static PRINTERINFO *PSDRV_PrinterList;
385 DWORD type = REG_BINARY, needed, res;
386 PRINTERINFO *pi = PSDRV_PrinterList, **last = &PSDRV_PrinterList;
387 FONTNAME *font;
388 AFM *afm;
389
Alexandre Julliard61fece01999-06-26 19:09:08 +0000390 TRACE("'%s'\n", name);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000391
392 for( ; pi; last = &pi->next, pi = pi->next) {
393 if(!strcmp(pi->FriendlyName, name))
394 return pi;
395 }
396
397 pi = *last = HeapAlloc( PSDRV_Heap, 0, sizeof(*pi) );
398 pi->FriendlyName = HEAP_strdupA( PSDRV_Heap, 0, name );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000399 res = DrvGetPrinterData16((LPSTR)name, (LPSTR)INT_PD_DEFAULT_DEVMODE, &type,
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000400 NULL, 0, &needed );
401
Huw D M Davies450270b1999-07-10 11:58:50 +0000402 if(res == ERROR_INVALID_PRINTER_NAME || needed != sizeof(DefaultDevmode)) {
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000403 pi->Devmode = HeapAlloc( PSDRV_Heap, 0, sizeof(DefaultDevmode) );
404 memcpy(pi->Devmode, &DefaultDevmode, sizeof(DefaultDevmode) );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000405 DrvSetPrinterData16((LPSTR)name, (LPSTR)INT_PD_DEFAULT_DEVMODE,
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000406 REG_BINARY, (LPBYTE)&DefaultDevmode, sizeof(DefaultDevmode) );
407
408 /* need to do something here AddPrinter?? */
409 } else {
410 pi->Devmode = HeapAlloc( PSDRV_Heap, 0, needed );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000411 DrvGetPrinterData16((LPSTR)name, (LPSTR)INT_PD_DEFAULT_DEVMODE, &type,
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000412 (LPBYTE)pi->Devmode, needed, &needed);
413 }
414
Thuy Nguyen48843961999-07-18 15:25:34 +0000415 PROFILE_GetWineIniString("psdrv", "ppdfile", "default.ppd",
416 pi->Devmode->dmDrvPrivate.ppdFileName, 256);
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000417 pi->ppd = PSDRV_ParsePPD(pi->Devmode->dmDrvPrivate.ppdFileName);
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000418 if(!pi->ppd) {
419 HeapFree(PSDRV_Heap, 0, pi->FriendlyName);
420 HeapFree(PSDRV_Heap, 0, pi->Devmode);
421 HeapFree(PSDRV_Heap, 0, pi);
422 *last = NULL;
Alexandre Julliard61fece01999-06-26 19:09:08 +0000423 MESSAGE("Couldn't find PPD file '%s', expect a crash now!\n",
Huw D M Daviesbcad2551998-11-01 13:02:27 +0000424 pi->Devmode->dmDrvPrivate.ppdFileName);
Alexandre Julliarda0d77311998-09-13 16:32:00 +0000425 return NULL;
426 }
427
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000428 pi->next = NULL;
429 pi->Fonts = NULL;
430
431 for(font = pi->ppd->InstalledFonts; font; font = font->next) {
432 afm = PSDRV_FindAFMinList(PSDRV_AFMFontList, font->Name);
433 if(!afm) {
Alexandre Julliard61fece01999-06-26 19:09:08 +0000434 MESSAGE(
Alexandre Julliard767e6f61998-08-09 12:47:43 +0000435 "Couldn't find AFM file for installed printer font '%s' - ignoring\n",
436 font->Name);
437 } else {
438 PSDRV_AddAFMtoList(&pi->Fonts, afm);
439 }
440 }
441
442 return pi;
443}