Removed some unnecessary #includes and dll dependencies.
[wine/multimedia.git] / dlls / wineps / driver.c
blobaa2193d208d55065bb6eefc27903208d66bbf99d
1 /*
2 * Exported functions from the PostScript driver.
4 * [Ext]DeviceMode, DeviceCapabilities, AdvancedSetupDialog.
6 * Will need ExtTextOut for winword6 (urgh!)
8 * Copyright 1998 Huw D M Davies
12 #include <string.h>
13 #include "psdrv.h"
14 #include "debugtools.h"
15 #include "winuser.h"
16 #include "winspool.h"
18 DEFAULT_DEBUG_CHANNEL(psdrv)
21 /************************************************************************
23 * PSDRV_MergeDevmodes
25 * Updates dm1 with some fields from dm2
28 void PSDRV_MergeDevmodes(PSDRV_DEVMODEA *dm1, PSDRV_DEVMODEA *dm2,
29 PRINTERINFO *pi)
31 /* some sanity checks here on dm2 */
33 if(dm2->dmPublic.dmFields & DM_ORIENTATION)
34 dm1->dmPublic.u1.s1.dmOrientation = dm2->dmPublic.u1.s1.dmOrientation;
36 /* NB PaperWidth is always < PaperLength */
38 if(dm2->dmPublic.dmFields & DM_PAPERSIZE) {
39 PAGESIZE *page;
41 for(page = pi->ppd->PageSizes; page; page = page->next) {
42 if(page->WinPage == dm2->dmPublic.u1.s1.dmPaperSize)
43 break;
45 if(page) {
46 dm1->dmPublic.u1.s1.dmPaperSize = dm2->dmPublic.u1.s1.dmPaperSize;
47 dm1->dmPublic.u1.s1.dmPaperWidth = page->PaperDimension->x *
48 254.0 / 72.0;
49 dm1->dmPublic.u1.s1.dmPaperLength = page->PaperDimension->y *
50 254.0 / 72.0;
51 TRACE("Changing page to %s %d x %d\n", page->FullName,
52 dm1->dmPublic.u1.s1.dmPaperWidth,
53 dm1->dmPublic.u1.s1.dmPaperLength );
54 } else {
55 TRACE("Trying to change to unsupported pagesize %d\n",
56 dm2->dmPublic.u1.s1.dmPaperSize);
60 if(dm2->dmPublic.dmFields & DM_PAPERLENGTH) {
61 dm1->dmPublic.u1.s1.dmPaperLength = dm2->dmPublic.u1.s1.dmPaperLength;
62 TRACE("Changing PaperLength to %d\n",
63 dm2->dmPublic.u1.s1.dmPaperLength);
64 FIXME("Changing PaperLength. Do we adjust PaperSize?\n");
67 if(dm2->dmPublic.dmFields & DM_PAPERWIDTH) {
68 dm1->dmPublic.u1.s1.dmPaperWidth = dm2->dmPublic.u1.s1.dmPaperWidth;
69 TRACE("Changing PaperWidth to %d\n",
70 dm2->dmPublic.u1.s1.dmPaperWidth);
71 FIXME("Changing PaperWidth. Do we adjust PaperSize?\n");
74 if(dm2->dmPublic.dmFields & DM_SCALE) {
75 dm1->dmPublic.dmScale = dm2->dmPublic.dmScale;
76 TRACE("Changing Scale to %d\n", dm2->dmPublic.dmScale);
79 if(dm2->dmPublic.dmFields & DM_COPIES) {
80 dm1->dmPublic.dmCopies = dm2->dmPublic.dmCopies;
81 TRACE("Changing Copies to %d\n", dm2->dmPublic.dmCopies);
84 if(dm2->dmPublic.dmFields & DM_DEFAULTSOURCE) {
85 INPUTSLOT *slot;
87 for(slot = pi->ppd->InputSlots; slot; slot = slot->next) {
88 if(slot->WinBin == dm2->dmPublic.dmDefaultSource)
89 break;
91 if(slot) {
92 dm1->dmPublic.dmDefaultSource = dm2->dmPublic.dmDefaultSource;
93 TRACE("Changing bin to '%s'\n", slot->FullName);
94 } else {
95 TRACE("Trying to change to unsupported bin %d\n",
96 dm2->dmPublic.dmDefaultSource);
100 if (dm2->dmPublic.dmFields & DM_DEFAULTSOURCE )
101 dm1->dmPublic.dmDefaultSource = dm2->dmPublic.dmDefaultSource;
102 if (dm2->dmPublic.dmFields & DM_PRINTQUALITY )
103 dm1->dmPublic.dmPrintQuality = dm2->dmPublic.dmPrintQuality;
104 if (dm2->dmPublic.dmFields & DM_COLOR )
105 dm1->dmPublic.dmColor = dm2->dmPublic.dmColor;
106 if (dm2->dmPublic.dmFields & DM_DUPLEX )
107 dm1->dmPublic.dmDuplex = dm2->dmPublic.dmDuplex;
108 if (dm2->dmPublic.dmFields & DM_YRESOLUTION )
109 dm1->dmPublic.dmYResolution = dm2->dmPublic.dmYResolution;
110 if (dm2->dmPublic.dmFields & DM_TTOPTION )
111 dm1->dmPublic.dmTTOption = dm2->dmPublic.dmTTOption;
112 if (dm2->dmPublic.dmFields & DM_COLLATE )
113 dm1->dmPublic.dmCollate = dm2->dmPublic.dmCollate;
114 if (dm2->dmPublic.dmFields & DM_FORMNAME )
115 lstrcpynA(dm1->dmPublic.dmFormName, dm2->dmPublic.dmFormName, CCHFORMNAME);
116 if (dm2->dmPublic.dmFields & DM_BITSPERPEL )
117 dm1->dmPublic.dmBitsPerPel = dm2->dmPublic.dmBitsPerPel;
118 if (dm2->dmPublic.dmFields & DM_PELSWIDTH )
119 dm1->dmPublic.dmPelsWidth = dm2->dmPublic.dmPelsWidth;
120 if (dm2->dmPublic.dmFields & DM_PELSHEIGHT )
121 dm1->dmPublic.dmPelsHeight = dm2->dmPublic.dmPelsHeight;
122 if (dm2->dmPublic.dmFields & DM_DISPLAYFLAGS )
123 dm1->dmPublic.dmDisplayFlags = dm2->dmPublic.dmDisplayFlags;
124 if (dm2->dmPublic.dmFields & DM_DISPLAYFREQUENCY )
125 dm1->dmPublic.dmDisplayFrequency = dm2->dmPublic.dmDisplayFrequency;
126 if (dm2->dmPublic.dmFields & DM_POSITION )
127 dm1->dmPublic.u1.dmPosition = dm2->dmPublic.u1.dmPosition;
128 if (dm2->dmPublic.dmFields & DM_LOGPIXELS )
129 dm1->dmPublic.dmLogPixels = dm2->dmPublic.dmLogPixels;
130 if (dm2->dmPublic.dmFields & DM_ICMMETHOD )
131 dm1->dmPublic.dmICMMethod = dm2->dmPublic.dmICMMethod;
132 if (dm2->dmPublic.dmFields & DM_ICMINTENT )
133 dm1->dmPublic.dmICMIntent = dm2->dmPublic.dmICMIntent;
134 if (dm2->dmPublic.dmFields & DM_MEDIATYPE )
135 dm1->dmPublic.dmMediaType = dm2->dmPublic.dmMediaType;
136 if (dm2->dmPublic.dmFields & DM_DITHERTYPE )
137 dm1->dmPublic.dmDitherType = dm2->dmPublic.dmDitherType;
138 if (dm2->dmPublic.dmFields & DM_PANNINGWIDTH )
139 dm1->dmPublic.dmPanningWidth = dm2->dmPublic.dmPanningWidth;
140 if (dm2->dmPublic.dmFields & DM_PANNINGHEIGHT )
141 dm1->dmPublic.dmPanningHeight = dm2->dmPublic.dmPanningHeight;
143 return;
147 #if 0
148 /*******************************************************************
150 * PSDRV_NewPrinterDlgProc32
154 LRESULT WINAPI PSDRV_NewPrinterDlgProc(HWND hWnd, UINT wMsg,
155 WPARAM wParam, LPARAM lParam)
157 switch (wMsg) {
158 case WM_INITDIALOG:
159 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
160 ShowWindow(hWnd, SW_SHOWNORMAL);
161 return TRUE;
163 case WM_COMMAND:
164 switch (LOWORD(wParam)) {
165 case IDOK:
166 EndDialog(hWnd, TRUE);
167 return TRUE;
169 case IDCANCEL:
170 EndDialog(hWnd, FALSE);
171 return TRUE;
173 default:
174 return FALSE;
177 default:
178 return FALSE;
182 LRESULT WINAPI PSDRV_AdvancedSetupDlgProc(HWND hWnd, UINT wMsg,
183 WPARAM wParam, LPARAM lParam)
185 switch (wMsg) {
186 case WM_INITDIALOG:
187 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
188 SendDlgItemMessageA(hWnd, 99, CB_ADDSTRING, 0,
189 (LPARAM)"Default Tray");
190 ShowWindow(hWnd, SW_SHOWNORMAL);
191 return TRUE;
193 case WM_COMMAND:
194 switch (LOWORD(wParam)) {
195 case IDOK:
196 EndDialog(hWnd, TRUE);
197 return TRUE;
199 case IDCANCEL:
200 EndDialog(hWnd, FALSE);
201 return TRUE;
203 case 200:
204 DialogBoxIndirectParamA( GetWindowLongA( hWnd, GWL_HINSTANCE ),
205 SYSRES_GetResPtr( SYSRES_DIALOG_PSDRV_NEWPRINTER ),
206 hWnd, PSDRV_NewPrinterDlgProc, (LPARAM) NULL );
207 return TRUE;
209 default:
210 return FALSE;
213 default:
214 return FALSE;
217 #endif /* 0 */
219 /***********************************************************************
221 * PSDRV_AdvancedSetupDialog16 [WINEPS.93]
224 WORD WINAPI PSDRV_AdvancedSetupDialog16(HWND16 hwnd, HANDLE16 hDriver,
225 LPDEVMODEA devin, LPDEVMODEA devout)
228 TRACE("hwnd = %04x, hDriver = %04x devin=%p devout=%p\n", hwnd,
229 hDriver, devin, devout);
230 return IDCANCEL;
233 #if 0
234 return DialogBoxIndirectParamA( GetWindowLongA( hwnd, GWL_HINSTANCE ),
235 SYSRES_GetResPtr( SYSRES_DIALOG_PSDRV_ADVANCEDSETUP ),
236 hwnd, PSDRV_AdvancedSetupDlgProc, (LPARAM) NULL );
237 #endif
242 /***********************************************************************
244 * PSDRV_ExtDeviceMode16 [WINEPS.90]
246 * Just returns default devmode at the moment
248 INT16 WINAPI PSDRV_ExtDeviceMode16(HWND16 hwnd, HANDLE16 hDriver,
249 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
250 LPSTR lpszPort, LPDEVMODEA lpdmInput,
251 LPSTR lpszProfile, WORD fwMode)
253 PRINTERINFO *pi = PSDRV_FindPrinterInfo(lpszDevice);
255 TRACE("(hwnd=%04x, hDriver=%04x, devOut=%p, Device='%s', Port='%s', devIn=%p, Profile='%s', Mode=%04x)\n",
256 hwnd, hDriver, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile,
257 fwMode);
259 if(!fwMode)
260 return sizeof(DEVMODEA); /* Just copy dmPublic bit of PSDRV_DEVMODE */
262 if(fwMode & DM_PROMPT)
263 FIXME("Mode DM_PROMPT not implemented\n");
265 if(fwMode & DM_UPDATE)
266 FIXME("Mode DM_UPDATE. Just do the same as DM_COPY\n");
268 if((fwMode & DM_MODIFY) && lpdmInput) {
269 TRACE("DM_MODIFY set. devIn->dmFields = %08lx\n", lpdmInput->dmFields);
270 PSDRV_MergeDevmodes(pi->Devmode, (PSDRV_DEVMODEA *)lpdmInput, pi);
273 if((fwMode & DM_COPY) || (fwMode & DM_UPDATE)) {
274 memcpy(lpdmOutput, pi->Devmode, sizeof(DEVMODEA));
276 return IDOK;
279 /**************************************************************
281 * PSDRV_ExtDeviceMode
283 INT PSDRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput,
284 LPSTR lpszDevice, LPSTR lpszPort, LPDEVMODEA lpdmInput,
285 LPSTR lpszProfile, DWORD dwMode)
287 return PSDRV_ExtDeviceMode16(hwnd, 0, lpdmOutput, lpszDevice, lpszPort,
288 lpdmInput, lpszProfile, dwMode);
291 /***********************************************************************
293 * PSDRV_DeviceCapabilities16 [WINEPS.91]
296 DWORD WINAPI PSDRV_DeviceCapabilities16(LPCSTR lpszDevice, LPCSTR lpszPort,
297 WORD fwCapability, LPSTR lpszOutput,
298 LPDEVMODEA lpDevMode)
300 PRINTERINFO *pi;
301 DEVMODEA *lpdm;
302 pi = PSDRV_FindPrinterInfo(lpszDevice);
304 TRACE("Cap=%d. Got PrinterInfo = %p\n", fwCapability, pi);
307 if (!pi) {
308 ERR("no printerinfo for %s, return 0!\n",lpszDevice);
309 return 0;
313 lpdm = lpDevMode ? lpDevMode : (DEVMODEA *)pi->Devmode;
315 switch(fwCapability) {
317 case DC_PAPERS:
319 PAGESIZE *ps;
320 WORD *wp = (WORD *)lpszOutput;
321 int i = 0;
323 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++)
324 if(lpszOutput != NULL)
325 *wp++ = ps->WinPage;
326 return i;
329 case DC_PAPERSIZE:
331 PAGESIZE *ps;
332 POINT16 *pt = (POINT16 *)lpszOutput;
333 int i = 0;
335 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++)
336 if(lpszOutput != NULL) {
337 pt->x = ps->PaperDimension->x * 254.0 / 72.0;
338 pt->y = ps->PaperDimension->y * 254.0 / 72.0;
339 pt++;
341 return i;
344 case DC_PAPERNAMES:
346 PAGESIZE *ps;
347 char *cp = lpszOutput;
348 int i = 0;
350 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++)
351 if(lpszOutput != NULL) {
352 lstrcpynA(cp, ps->FullName, 64);
353 cp += 64;
355 return i;
358 case DC_ORIENTATION:
359 return pi->ppd->LandscapeOrientation ? pi->ppd->LandscapeOrientation : 90;
361 case DC_BINS:
363 INPUTSLOT *slot;
364 WORD *wp = (WORD *)lpszOutput;
365 int i = 0;
367 for(slot = pi->ppd->InputSlots; slot; slot = slot->next, i++)
368 if(lpszOutput != NULL)
369 *wp++ = slot->WinBin;
370 return i;
373 case DC_BINNAMES:
375 INPUTSLOT *slot;
376 char *cp = lpszOutput;
377 int i = 0;
379 for(slot = pi->ppd->InputSlots; slot; slot = slot->next, i++)
380 if(lpszOutput != NULL) {
381 lstrcpynA(cp, slot->FullName, 24);
382 cp += 24;
384 return i;
387 case DC_BINADJUST:
388 FIXME("DC_BINADJUST: stub.\n");
389 return DCBA_FACEUPNONE;
391 case DC_ENUMRESOLUTIONS:
393 LONG *lp = (LONG*)lpszOutput;
395 if(lpszOutput != NULL) {
396 lp[0] = (LONG)pi->ppd->DefaultResolution;
397 lp[1] = (LONG)pi->ppd->DefaultResolution;
399 return 1;
402 case DC_COPIES:
403 FIXME("DC_COPIES: returning %d. Is this correct?\n", lpdm->dmCopies);
404 return lpdm->dmCopies;
406 case DC_DRIVER:
407 return lpdm->dmDriverVersion;
409 case DC_DATATYPE_PRODUCED:
410 FIXME("DATA_TYPE_PRODUCED: stub.\n");
411 return -1; /* simulate that the driver supports 'RAW' */
413 case DC_DUPLEX:
414 FIXME("DC_DUPLEX: returning %d. Is this correct?\n", lpdm->dmDuplex);
415 return lpdm->dmDuplex;
417 case DC_EMF_COMPLIANT:
418 FIXME("DC_EMF_COMPLIANT: stub.\n");
419 return -1; /* simulate that the driver do not support EMF */
421 case DC_EXTRA:
422 return lpdm->dmDriverExtra;
424 case DC_FIELDS:
425 return lpdm->dmFields;
427 case DC_FILEDEPENDENCIES:
428 FIXME("DC_FILEDEPENDENCIES: stub.\n");
429 return 0;
431 case DC_MAXEXTENT:
433 PAGESIZE *ps;
434 int i;
435 POINT ptMax;
436 ptMax.x = ptMax.y = 0;
438 if(lpszOutput == NULL)
439 return -1;
441 i = 0;
442 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++) {
443 if(ps->PaperDimension->x > ptMax.x)
444 ptMax.x = ps->PaperDimension->x;
445 if(ps->PaperDimension->y > ptMax.y)
446 ptMax.y = ps->PaperDimension->y;
448 *((POINT*)lpszOutput) = ptMax;
449 return 1;
452 case DC_MINEXTENT:
454 PAGESIZE *ps;
455 int i;
456 POINT ptMax;
457 ptMax.x = ptMax.y = 0;
459 if(lpszOutput == NULL)
460 return -1;
462 i = 0;
463 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++) {
464 if(ps->PaperDimension->x > ptMax.x)
465 ptMax.x = ps->PaperDimension->x;
466 if(ps->PaperDimension->y > ptMax.y)
467 ptMax.y = ps->PaperDimension->y;
469 *((POINT*)lpszOutput) = ptMax;
470 return 1;
473 case DC_SIZE:
474 return lpdm->dmSize;
476 case DC_TRUETYPE:
477 FIXME("DC_TRUETYPE: stub\n");
478 return DCTT_SUBDEV;
480 case DC_VERSION:
481 return lpdm->dmSpecVersion;
483 default:
484 FIXME("Unsupported capability %d\n", fwCapability);
486 return -1;
489 /**************************************************************
491 * PSDRV_DeviceCapabilities
493 DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice,
494 LPCSTR lpszPort, WORD fwCapability,
495 LPSTR lpszOutput, LPDEVMODEA lpdm)
497 return PSDRV_DeviceCapabilities16(lpszDevice, lpszPort, fwCapability,
498 lpszOutput, lpdm);
501 /***************************************************************
503 * PSDRV_DeviceMode16 [WINEPS.13]
506 void WINAPI PSDRV_DeviceMode16(HWND16 hwnd, HANDLE16 hDriver,
507 LPSTR lpszDevice, LPSTR lpszPort)
509 PSDRV_ExtDeviceMode16( hwnd, hDriver, NULL, lpszDevice, lpszPort, NULL,
510 NULL, DM_PROMPT );
511 return;