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
14 #include "debugtools.h"
18 DEFAULT_DEBUG_CHANNEL(psdrv
)
21 /************************************************************************
25 * Updates dm1 with some fields from dm2
28 void PSDRV_MergeDevmodes(PSDRV_DEVMODEA
*dm1
, PSDRV_DEVMODEA
*dm2
,
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
) {
41 for(page
= pi
->ppd
->PageSizes
; page
; page
= page
->next
) {
42 if(page
->WinPage
== dm2
->dmPublic
.u1
.s1
.dmPaperSize
)
46 dm1
->dmPublic
.u1
.s1
.dmPaperSize
= dm2
->dmPublic
.u1
.s1
.dmPaperSize
;
47 dm1
->dmPublic
.u1
.s1
.dmPaperWidth
= page
->PaperDimension
->x
*
49 dm1
->dmPublic
.u1
.s1
.dmPaperLength
= page
->PaperDimension
->y
*
51 TRACE("Changing page to %s %d x %d\n", page
->FullName
,
52 dm1
->dmPublic
.u1
.s1
.dmPaperWidth
,
53 dm1
->dmPublic
.u1
.s1
.dmPaperLength
);
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
) {
87 for(slot
= pi
->ppd
->InputSlots
; slot
; slot
= slot
->next
) {
88 if(slot
->WinBin
== dm2
->dmPublic
.dmDefaultSource
)
92 dm1
->dmPublic
.dmDefaultSource
= dm2
->dmPublic
.dmDefaultSource
;
93 TRACE("Changing bin to '%s'\n", slot
->FullName
);
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
;
148 /*******************************************************************
150 * PSDRV_NewPrinterDlgProc32
154 LRESULT WINAPI
PSDRV_NewPrinterDlgProc(HWND hWnd
, UINT wMsg
,
155 WPARAM wParam
, LPARAM lParam
)
159 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
160 ShowWindow(hWnd
, SW_SHOWNORMAL
);
164 switch (LOWORD(wParam
)) {
166 EndDialog(hWnd
, TRUE
);
170 EndDialog(hWnd
, FALSE
);
182 LRESULT WINAPI
PSDRV_AdvancedSetupDlgProc(HWND hWnd
, UINT wMsg
,
183 WPARAM wParam
, LPARAM lParam
)
187 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
188 SendDlgItemMessageA(hWnd
, 99, CB_ADDSTRING
, 0,
189 (LPARAM
)"Default Tray");
190 ShowWindow(hWnd
, SW_SHOWNORMAL
);
194 switch (LOWORD(wParam
)) {
196 EndDialog(hWnd
, TRUE
);
200 EndDialog(hWnd
, FALSE
);
204 DialogBoxIndirectParamA( GetWindowLongA( hWnd
, GWL_HINSTANCE
),
205 SYSRES_GetResPtr( SYSRES_DIALOG_PSDRV_NEWPRINTER
),
206 hWnd
, PSDRV_NewPrinterDlgProc
, (LPARAM
) NULL
);
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
);
234 return DialogBoxIndirectParamA( GetWindowLongA( hwnd
, GWL_HINSTANCE
),
235 SYSRES_GetResPtr( SYSRES_DIALOG_PSDRV_ADVANCEDSETUP
),
236 hwnd
, PSDRV_AdvancedSetupDlgProc
, (LPARAM
) NULL
);
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
,
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
));
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
)
302 pi
= PSDRV_FindPrinterInfo(lpszDevice
);
304 TRACE("Cap=%d. Got PrinterInfo = %p\n", fwCapability
, pi
);
308 ERR("no printerinfo for %s, return 0!\n",lpszDevice
);
313 lpdm
= lpDevMode
? lpDevMode
: (DEVMODEA
*)pi
->Devmode
;
315 switch(fwCapability
) {
320 WORD
*wp
= (WORD
*)lpszOutput
;
323 for(ps
= pi
->ppd
->PageSizes
; ps
; ps
= ps
->next
, i
++)
324 if(lpszOutput
!= NULL
)
332 POINT16
*pt
= (POINT16
*)lpszOutput
;
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;
347 char *cp
= lpszOutput
;
350 for(ps
= pi
->ppd
->PageSizes
; ps
; ps
= ps
->next
, i
++)
351 if(lpszOutput
!= NULL
) {
352 lstrcpynA(cp
, ps
->FullName
, 64);
359 return pi
->ppd
->LandscapeOrientation
? pi
->ppd
->LandscapeOrientation
: 90;
364 WORD
*wp
= (WORD
*)lpszOutput
;
367 for(slot
= pi
->ppd
->InputSlots
; slot
; slot
= slot
->next
, i
++)
368 if(lpszOutput
!= NULL
)
369 *wp
++ = slot
->WinBin
;
376 char *cp
= lpszOutput
;
379 for(slot
= pi
->ppd
->InputSlots
; slot
; slot
= slot
->next
, i
++)
380 if(lpszOutput
!= NULL
) {
381 lstrcpynA(cp
, slot
->FullName
, 24);
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
;
403 FIXME("DC_COPIES: returning %d. Is this correct?\n", lpdm
->dmCopies
);
404 return lpdm
->dmCopies
;
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' */
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 */
422 return lpdm
->dmDriverExtra
;
425 return lpdm
->dmFields
;
427 case DC_FILEDEPENDENCIES
:
428 FIXME("DC_FILEDEPENDENCIES: stub.\n");
436 ptMax
.x
= ptMax
.y
= 0;
438 if(lpszOutput
== NULL
)
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
;
457 ptMax
.x
= ptMax
.y
= 0;
459 if(lpszOutput
== NULL
)
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
;
477 FIXME("DC_TRUETYPE: stub\n");
481 return lpdm
->dmSpecVersion
;
484 FIXME("Unsupported capability %d\n", fwCapability
);
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
,
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
,