Support mapping non page-aligned binaries for SEC_IMAGE mappings.
[wine.git] / dlls / wineps / driver.c
blobce237c68b3f6ed30b51e700d2e368f982d8741b0
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
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #define NONAMELESSUNION
26 #define NONAMELESSSTRUCT
28 #include "config.h"
30 #include <string.h>
32 #include "wine/debug.h"
33 #include "psdlg.h"
34 #include "psdrv.h"
36 #include "winuser.h"
37 #include "wownt32.h"
38 #include "winspool.h"
39 #include "prsht.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
44 /************************************************************************
46 * PSDRV_MergeDevmodes
48 * Updates dm1 with some fields from dm2
51 void PSDRV_MergeDevmodes(PSDRV_DEVMODEA *dm1, PSDRV_DEVMODEA *dm2,
52 PRINTERINFO *pi)
54 /* some sanity checks here on dm2 */
56 if(dm2->dmPublic.dmFields & DM_ORIENTATION) {
57 dm1->dmPublic.u1.s1.dmOrientation = dm2->dmPublic.u1.s1.dmOrientation;
58 TRACE("Changing orientation to %d (%s)\n",
59 dm1->dmPublic.u1.s1.dmOrientation,
60 dm1->dmPublic.u1.s1.dmOrientation == DMORIENT_PORTRAIT ?
61 "Portrait" :
62 (dm1->dmPublic.u1.s1.dmOrientation == DMORIENT_LANDSCAPE ?
63 "Landscape" : "unknown"));
66 /* NB PaperWidth is always < PaperLength */
67 if(dm2->dmPublic.dmFields & DM_PAPERSIZE) {
68 PAGESIZE *page;
70 for(page = pi->ppd->PageSizes; page; page = page->next) {
71 if(page->WinPage == dm2->dmPublic.u1.s1.dmPaperSize)
72 break;
74 if(page) {
75 dm1->dmPublic.u1.s1.dmPaperSize = dm2->dmPublic.u1.s1.dmPaperSize;
76 dm1->dmPublic.u1.s1.dmPaperWidth = page->PaperDimension->x *
77 254.0 / 72.0;
78 dm1->dmPublic.u1.s1.dmPaperLength = page->PaperDimension->y *
79 254.0 / 72.0;
80 dm1->dmPublic.dmFields &= ~(DM_PAPERLENGTH | DM_PAPERWIDTH);
81 dm1->dmPublic.dmFields |= DM_PAPERSIZE;
82 TRACE("Changing page to %s %d x %d\n", page->FullName,
83 dm1->dmPublic.u1.s1.dmPaperWidth,
84 dm1->dmPublic.u1.s1.dmPaperLength );
85 } else {
86 TRACE("Trying to change to unsupported pagesize %d\n",
87 dm2->dmPublic.u1.s1.dmPaperSize);
89 } else if((dm2->dmPublic.dmFields & DM_PAPERLENGTH) &&
90 (dm2->dmPublic.dmFields & DM_PAPERWIDTH)) {
91 dm1->dmPublic.u1.s1.dmPaperLength = dm2->dmPublic.u1.s1.dmPaperLength;
92 dm1->dmPublic.u1.s1.dmPaperWidth = dm2->dmPublic.u1.s1.dmPaperWidth;
93 TRACE("Changing PaperLength|Width to %dx%d\n",
94 dm2->dmPublic.u1.s1.dmPaperLength,
95 dm2->dmPublic.u1.s1.dmPaperWidth);
96 dm1->dmPublic.dmFields &= ~DM_PAPERSIZE;
97 dm1->dmPublic.dmFields |= (DM_PAPERLENGTH | DM_PAPERWIDTH);
98 } else if(dm2->dmPublic.dmFields & (DM_PAPERLENGTH | DM_PAPERWIDTH)) {
99 /* You might think that this would be allowed if dm1 is in custom size
100 mode, but apparently Windows reverts to standard paper mode even in
101 this case */
102 FIXME("Trying to change only paperlength or paperwidth\n");
103 dm1->dmPublic.dmFields &= ~(DM_PAPERLENGTH | DM_PAPERWIDTH);
104 dm1->dmPublic.dmFields |= DM_PAPERSIZE;
107 if(dm2->dmPublic.dmFields & DM_SCALE) {
108 dm1->dmPublic.dmScale = dm2->dmPublic.dmScale;
109 TRACE("Changing Scale to %d\n", dm2->dmPublic.dmScale);
112 if(dm2->dmPublic.dmFields & DM_COPIES) {
113 dm1->dmPublic.dmCopies = dm2->dmPublic.dmCopies;
114 TRACE("Changing Copies to %d\n", dm2->dmPublic.dmCopies);
117 if(dm2->dmPublic.dmFields & DM_DEFAULTSOURCE) {
118 INPUTSLOT *slot;
120 for(slot = pi->ppd->InputSlots; slot; slot = slot->next) {
121 if(slot->WinBin == dm2->dmPublic.dmDefaultSource)
122 break;
124 if(slot) {
125 dm1->dmPublic.dmDefaultSource = dm2->dmPublic.dmDefaultSource;
126 TRACE("Changing bin to '%s'\n", slot->FullName);
127 } else {
128 TRACE("Trying to change to unsupported bin %d\n",
129 dm2->dmPublic.dmDefaultSource);
133 if (dm2->dmPublic.dmFields & DM_DEFAULTSOURCE )
134 dm1->dmPublic.dmDefaultSource = dm2->dmPublic.dmDefaultSource;
135 if (dm2->dmPublic.dmFields & DM_PRINTQUALITY )
136 dm1->dmPublic.dmPrintQuality = dm2->dmPublic.dmPrintQuality;
137 if (dm2->dmPublic.dmFields & DM_COLOR )
138 dm1->dmPublic.dmColor = dm2->dmPublic.dmColor;
139 if (dm2->dmPublic.dmFields & DM_DUPLEX && pi->ppd->DefaultDuplex && pi->ppd->DefaultDuplex->WinDuplex != 0)
140 dm1->dmPublic.dmDuplex = dm2->dmPublic.dmDuplex;
141 if (dm2->dmPublic.dmFields & DM_YRESOLUTION )
142 dm1->dmPublic.dmYResolution = dm2->dmPublic.dmYResolution;
143 if (dm2->dmPublic.dmFields & DM_TTOPTION )
144 dm1->dmPublic.dmTTOption = dm2->dmPublic.dmTTOption;
145 if (dm2->dmPublic.dmFields & DM_COLLATE )
146 dm1->dmPublic.dmCollate = dm2->dmPublic.dmCollate;
147 if (dm2->dmPublic.dmFields & DM_FORMNAME )
148 lstrcpynA(dm1->dmPublic.dmFormName, dm2->dmPublic.dmFormName, CCHFORMNAME);
149 if (dm2->dmPublic.dmFields & DM_BITSPERPEL )
150 dm1->dmPublic.dmBitsPerPel = dm2->dmPublic.dmBitsPerPel;
151 if (dm2->dmPublic.dmFields & DM_PELSWIDTH )
152 dm1->dmPublic.dmPelsWidth = dm2->dmPublic.dmPelsWidth;
153 if (dm2->dmPublic.dmFields & DM_PELSHEIGHT )
154 dm1->dmPublic.dmPelsHeight = dm2->dmPublic.dmPelsHeight;
155 if (dm2->dmPublic.dmFields & DM_DISPLAYFLAGS )
156 dm1->dmPublic.dmDisplayFlags = dm2->dmPublic.dmDisplayFlags;
157 if (dm2->dmPublic.dmFields & DM_DISPLAYFREQUENCY )
158 dm1->dmPublic.dmDisplayFrequency = dm2->dmPublic.dmDisplayFrequency;
159 if (dm2->dmPublic.dmFields & DM_POSITION )
160 dm1->dmPublic.u1.dmPosition = dm2->dmPublic.u1.dmPosition;
161 if (dm2->dmPublic.dmFields & DM_LOGPIXELS )
162 dm1->dmPublic.dmLogPixels = dm2->dmPublic.dmLogPixels;
163 if (dm2->dmPublic.dmFields & DM_ICMMETHOD )
164 dm1->dmPublic.dmICMMethod = dm2->dmPublic.dmICMMethod;
165 if (dm2->dmPublic.dmFields & DM_ICMINTENT )
166 dm1->dmPublic.dmICMIntent = dm2->dmPublic.dmICMIntent;
167 if (dm2->dmPublic.dmFields & DM_MEDIATYPE )
168 dm1->dmPublic.dmMediaType = dm2->dmPublic.dmMediaType;
169 if (dm2->dmPublic.dmFields & DM_DITHERTYPE )
170 dm1->dmPublic.dmDitherType = dm2->dmPublic.dmDitherType;
171 if (dm2->dmPublic.dmFields & DM_PANNINGWIDTH )
172 dm1->dmPublic.dmPanningWidth = dm2->dmPublic.dmPanningWidth;
173 if (dm2->dmPublic.dmFields & DM_PANNINGHEIGHT )
174 dm1->dmPublic.dmPanningHeight = dm2->dmPublic.dmPanningHeight;
176 return;
180 /**************************************************************
181 * AdvancedSetupDialog [WINEPS16.93]
184 WORD WINAPI PSDRV_AdvancedSetupDialog16(HWND16 hwnd, HANDLE16 hDriver,
185 LPDEVMODEA devin, LPDEVMODEA devout)
188 TRACE("hwnd = %04x, hDriver = %04x devin=%p devout=%p\n", hwnd,
189 hDriver, devin, devout);
190 return IDCANCEL;
193 /****************************************************************
194 * PSDRV_PaperDlgProc
196 * Dialog proc for 'Paper' propsheet
198 INT_PTR CALLBACK PSDRV_PaperDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
199 lParam)
201 PSDRV_DLGINFO *di;
202 int i, Cursel = 0;
203 PAGESIZE *ps;
204 DUPLEX *duplex;
206 switch(msg) {
207 case WM_INITDIALOG:
208 di = (PSDRV_DLGINFO*)((PROPSHEETPAGEA*)lParam)->lParam;
209 SetWindowLongA(hwnd, DWL_USER, (LONG)di);
211 for(ps = di->pi->ppd->PageSizes, i = 0; ps; ps = ps->next, i++) {
212 SendDlgItemMessageA(hwnd, IDD_PAPERS, LB_INSERTSTRING, i,
213 (LPARAM)ps->FullName);
214 if(di->pi->Devmode->dmPublic.u1.s1.dmPaperSize == ps->WinPage)
215 Cursel = i;
217 SendDlgItemMessageA(hwnd, IDD_PAPERS, LB_SETCURSEL, Cursel, 0);
219 CheckRadioButton(hwnd, IDD_ORIENT_PORTRAIT, IDD_ORIENT_LANDSCAPE,
220 di->pi->Devmode->dmPublic.u1.s1.dmOrientation ==
221 DMORIENT_PORTRAIT ? IDD_ORIENT_PORTRAIT :
222 IDD_ORIENT_LANDSCAPE);
224 if(!di->pi->ppd->Duplexes) {
225 ShowWindow(GetDlgItem(hwnd, IDD_DUPLEX), SW_HIDE);
226 ShowWindow(GetDlgItem(hwnd, IDD_DUPLEX_NAME), SW_HIDE);
227 } else {
228 Cursel = 0;
229 for(duplex = di->pi->ppd->Duplexes, i = 0; duplex; duplex = duplex->next, i++) {
230 SendDlgItemMessageA(hwnd, IDD_DUPLEX, CB_INSERTSTRING, i,
231 (LPARAM)(duplex->FullName ? duplex->FullName : duplex->Name));
232 if(di->pi->Devmode->dmPublic.dmDuplex == duplex->WinDuplex)
233 Cursel = i;
235 SendDlgItemMessageA(hwnd, IDD_DUPLEX, CB_SETCURSEL, Cursel, 0);
237 break;
239 case WM_COMMAND:
240 di = (PSDRV_DLGINFO *)GetWindowLongA(hwnd, DWL_USER);
241 switch(LOWORD(wParam)) {
242 case IDD_PAPERS:
243 if(HIWORD(wParam) == LBN_SELCHANGE) {
244 Cursel = SendDlgItemMessageA(hwnd, LOWORD(wParam), LB_GETCURSEL, 0, 0);
245 for(i = 0, ps = di->pi->ppd->PageSizes; i < Cursel; i++, ps = ps->next)
247 TRACE("Setting pagesize to item %d Winpage = %d\n", Cursel,
248 ps->WinPage);
249 di->dlgdm->dmPublic.u1.s1.dmPaperSize = ps->WinPage;
251 break;
252 case IDD_ORIENT_PORTRAIT:
253 case IDD_ORIENT_LANDSCAPE:
254 TRACE("Setting orientation to %s\n", wParam == IDD_ORIENT_PORTRAIT ?
255 "portrait" : "landscape");
256 di->dlgdm->dmPublic.u1.s1.dmOrientation = wParam == IDD_ORIENT_PORTRAIT ?
257 DMORIENT_PORTRAIT : DMORIENT_LANDSCAPE;
258 break;
259 case IDD_DUPLEX:
260 if(HIWORD(wParam) == CBN_SELCHANGE) {
261 Cursel = SendDlgItemMessageA(hwnd, LOWORD(wParam), CB_GETCURSEL, 0, 0);
262 for(i = 0, duplex = di->pi->ppd->Duplexes; i < Cursel; i++, duplex = duplex->next)
264 TRACE("Setting duplex to item %d Winduplex = %d\n", Cursel,
265 duplex->WinDuplex);
266 di->dlgdm->dmPublic.dmDuplex = duplex->WinDuplex;
268 break;
270 break;
272 case WM_NOTIFY:
274 NMHDR *nmhdr = (NMHDR *)lParam;
275 di = (PSDRV_DLGINFO *)GetWindowLongA(hwnd, DWL_USER);
276 switch(nmhdr->code) {
277 case PSN_APPLY:
278 memcpy(di->pi->Devmode, di->dlgdm, sizeof(PSDRV_DEVMODEA));
279 SetWindowLongA(hwnd, DWL_MSGRESULT, PSNRET_NOERROR);
280 return TRUE;
281 break;
283 default:
284 return FALSE;
285 break;
287 break;
290 default:
291 return FALSE;
293 return TRUE;
297 static void (WINAPI *pInitCommonControls) (void);
298 static HPROPSHEETPAGE (WINAPI *pCreatePropertySheetPage) (LPCPROPSHEETPAGEW);
299 static int (WINAPI *pPropertySheet) (LPCPROPSHEETHEADERW);
302 /******************************************************************
303 * PSDRV_ExtDeviceMode
305 * Retrieves or modifies device-initialization information for the PostScript
306 * driver, or displays a driver-supplied dialog box for configuring the driver.
308 * PARAMETERS
309 * lpszDriver -- Driver name
310 * hwnd -- Parent window for the dialog box
311 * lpdmOutput -- Address of a DEVMODE structure for writing initialization information
312 * lpszDevice -- Device name
313 * lpszPort -- Port name
314 * lpdmInput -- Address of a DEVMODE structure for reading initialization information
315 * lpProfile -- Name of initialization file, defaults to WIN.INI if NULL
316 * wMode -- Operation to perform. Can be a combination if > 0.
317 * (0) -- Returns number of bytes required by DEVMODE structure
318 * DM_UPDATE (1) -- Write current settings to environment and initialization file
319 * DM_COPY (2) -- Write current settings to lpdmOutput
320 * DM_PROMPT (4) -- Presents the driver's modal dialog box (USER.240)
321 * DM_MODIFY (8) -- Changes current settings according to lpdmInput before any other operation
323 * RETURNS
324 * Returns size of DEVMODE structure if wMode is 0. Otherwise, IDOK is returned for success
325 * for both dialog and non-dialog operations. IDCANCEL is returned if the dialog box was cancelled.
326 * A return value less than zero is returned if a non-dialog operation fails.
328 * BUGS
330 * Just returns default devmode at the moment. No use of initialization file.
332 INT PSDRV_ExtDeviceMode(LPSTR lpszDriver, HWND hwnd, LPDEVMODEA lpdmOutput,
333 LPSTR lpszDevice, LPSTR lpszPort, LPDEVMODEA lpdmInput,
334 LPSTR lpszProfile, DWORD dwMode)
336 PRINTERINFO *pi = PSDRV_FindPrinterInfo(lpszDevice);
337 if(!pi) return -1;
339 TRACE("(Driver=%s, hwnd=%p, devOut=%p, Device='%s', Port='%s', devIn=%p, Profile='%s', Mode=%04lx)\n",
340 lpszDriver, hwnd, lpdmOutput, lpszDevice, lpszPort, lpdmInput, lpszProfile, dwMode);
342 /* If dwMode == 0, return size of DEVMODE structure */
343 if(!dwMode)
344 return pi->Devmode->dmPublic.dmSize + pi->Devmode->dmPublic.dmDriverExtra;
346 /* If DM_MODIFY is set, change settings in accordance with lpdmInput */
347 if((dwMode & DM_MODIFY) && lpdmInput) {
348 TRACE("DM_MODIFY set. devIn->dmFields = %08lx\n", lpdmInput->dmFields);
349 PSDRV_MergeDevmodes(pi->Devmode, (PSDRV_DEVMODEA *)lpdmInput, pi);
352 /* If DM_PROMPT is set, present modal dialog box */
353 if(dwMode & DM_PROMPT) {
354 HINSTANCE hinstComctl32, hinstWineps32 = LoadLibraryA("WINEPS");
355 HPROPSHEETPAGE hpsp[1];
356 PROPSHEETPAGEW psp;
357 PROPSHEETHEADERW psh;
358 PSDRV_DLGINFO *di;
359 PSDRV_DEVMODEA *dlgdm;
360 static const WCHAR PAPERW[] = {'P','A','P','E','R','\0'};
361 static const WCHAR SetupW[] = {'S','e','t','u','p','\0'};
363 hinstComctl32 = LoadLibraryA("comctl32.dll");
364 pInitCommonControls = (void*)GetProcAddress(hinstComctl32,
365 "InitCommonControls");
366 pCreatePropertySheetPage = (void*)GetProcAddress(hinstComctl32,
367 "CreatePropertySheetPageW");
368 pPropertySheet = (void*)GetProcAddress(hinstComctl32, "PropertySheetW");
369 memset(&psp,0,sizeof(psp));
370 dlgdm = HeapAlloc( PSDRV_Heap, 0, sizeof(*dlgdm) );
371 memcpy(dlgdm, pi->Devmode, sizeof(*dlgdm));
372 di = HeapAlloc( PSDRV_Heap, 0, sizeof(*di) );
373 di->pi = pi;
374 di->dlgdm = dlgdm;
375 psp.dwSize = sizeof(psp);
376 psp.hInstance = hinstWineps32;
377 psp.u.pszTemplate = PAPERW;
378 psp.u2.pszIcon = NULL;
379 psp.pfnDlgProc = PSDRV_PaperDlgProc;
380 psp.lParam = (LPARAM)di;
381 hpsp[0] = pCreatePropertySheetPage(&psp);
383 memset(&psh, 0, sizeof(psh));
384 psh.dwSize = sizeof(psh);
385 psh.pszCaption = SetupW;
386 psh.nPages = 1;
387 psh.hwndParent = HWND_32(hwnd);
388 psh.u3.phpage = hpsp;
390 pPropertySheet(&psh);
394 /* If DM_UPDATE is set, should write settings to environment and initialization file */
395 if(dwMode & DM_UPDATE)
396 FIXME("Mode DM_UPDATE. Just do the same as DM_COPY\n");
398 /* If DM_COPY is set, should write settings to lpdmOutput */
399 if((dwMode & DM_COPY) || (dwMode & DM_UPDATE)) {
400 if (lpdmOutput)
401 memcpy(lpdmOutput, pi->Devmode, pi->Devmode->dmPublic.dmSize + pi->Devmode->dmPublic.dmDriverExtra );
402 else
403 FIXME("lpdmOutput is NULL what should we do??\n");
405 return IDOK;
407 /***************************************************************
408 * ExtDeviceMode [WINEPS16.90]
412 INT16 WINAPI PSDRV_ExtDeviceMode16(HWND16 hwnd, HANDLE16 hDriver,
413 LPDEVMODEA lpdmOutput, LPSTR lpszDevice,
414 LPSTR lpszPort, LPDEVMODEA lpdmInput,
415 LPSTR lpszProfile, WORD fwMode)
418 return PSDRV_ExtDeviceMode(NULL, HWND_32(hwnd), lpdmOutput, lpszDevice,
419 lpszPort, lpdmInput, lpszProfile, (DWORD) fwMode);
422 /***********************************************************************
423 * PSDRV_DeviceCapabilities
425 * Retrieves the capabilities of a printer device driver.
427 * Parameters
428 * lpszDriver -- printer driver name
429 * lpszDevice -- printer name
430 * lpszPort -- port name
431 * fwCapability -- device capability
432 * lpszOutput -- output buffer
433 * lpDevMode -- device data buffer
435 * Returns
436 * Result depends on the setting of fwCapability. -1 indicates failure.
438 DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice, LPCSTR lpszPort,
439 WORD fwCapability, LPSTR lpszOutput,
440 LPDEVMODEA lpDevMode)
442 PRINTERINFO *pi;
443 DEVMODEA *lpdm;
444 DWORD ret;
445 pi = PSDRV_FindPrinterInfo(lpszDevice);
447 TRACE("Cap=%d. Got PrinterInfo = %p\n", fwCapability, pi);
450 if (!pi) {
451 ERR("no printerinfo for %s, return 0!\n",lpszDevice);
452 return 0;
456 lpdm = lpDevMode ? lpDevMode : (DEVMODEA *)pi->Devmode;
458 switch(fwCapability) {
460 case DC_PAPERS:
462 PAGESIZE *ps;
463 WORD *wp = (WORD *)lpszOutput;
464 int i = 0;
466 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++)
467 if(lpszOutput != NULL)
468 *wp++ = ps->WinPage;
469 return i;
472 case DC_PAPERSIZE:
474 PAGESIZE *ps;
475 POINT16 *pt = (POINT16 *)lpszOutput;
476 int i = 0;
478 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++)
479 if(lpszOutput != NULL) {
480 pt->x = ps->PaperDimension->x * 254.0 / 72.0;
481 pt->y = ps->PaperDimension->y * 254.0 / 72.0;
482 pt++;
484 return i;
487 case DC_PAPERNAMES:
489 PAGESIZE *ps;
490 char *cp = lpszOutput;
491 int i = 0;
493 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++)
494 if(lpszOutput != NULL) {
495 lstrcpynA(cp, ps->FullName, 64);
496 cp += 64;
498 return i;
501 case DC_ORIENTATION:
502 return pi->ppd->LandscapeOrientation ? pi->ppd->LandscapeOrientation : 90;
504 case DC_BINS:
506 INPUTSLOT *slot;
507 WORD *wp = (WORD *)lpszOutput;
508 int i = 0;
510 for(slot = pi->ppd->InputSlots; slot; slot = slot->next, i++)
511 if(lpszOutput != NULL)
512 *wp++ = slot->WinBin;
513 return i;
516 case DC_BINNAMES:
518 INPUTSLOT *slot;
519 char *cp = lpszOutput;
520 int i = 0;
522 for(slot = pi->ppd->InputSlots; slot; slot = slot->next, i++)
523 if(lpszOutput != NULL) {
524 lstrcpynA(cp, slot->FullName, 24);
525 cp += 24;
527 return i;
530 case DC_BINADJUST:
531 FIXME("DC_BINADJUST: stub.\n");
532 return DCBA_FACEUPNONE;
534 case DC_ENUMRESOLUTIONS:
536 LONG *lp = (LONG*)lpszOutput;
538 if(lpszOutput != NULL) {
539 lp[0] = (LONG)pi->ppd->DefaultResolution;
540 lp[1] = (LONG)pi->ppd->DefaultResolution;
542 return 1;
545 /* Windows returns 9999 too */
546 case DC_COPIES:
547 TRACE("DC_COPIES: returning 9999\n");
548 return 9999;
550 case DC_DRIVER:
551 return lpdm->dmDriverVersion;
553 case DC_DATATYPE_PRODUCED:
554 FIXME("DATA_TYPE_PRODUCED: stub.\n");
555 return -1; /* simulate that the driver supports 'RAW' */
557 case DC_DUPLEX:
558 ret = 0;
559 if(pi->ppd->DefaultDuplex && pi->ppd->DefaultDuplex->WinDuplex != 0)
560 ret = 1;
561 TRACE("DC_DUPLEX: returning %ld\n", ret);
562 return ret;
564 case DC_EMF_COMPLIANT:
565 FIXME("DC_EMF_COMPLIANT: stub.\n");
566 return -1; /* simulate that the driver do not support EMF */
568 case DC_EXTRA:
569 return lpdm->dmDriverExtra;
571 case DC_FIELDS:
572 return lpdm->dmFields;
574 case DC_FILEDEPENDENCIES:
575 FIXME("DC_FILEDEPENDENCIES: stub.\n");
576 return 0;
578 case DC_MAXEXTENT:
580 PAGESIZE *ps;
581 int i;
582 POINT ptMax;
583 ptMax.x = ptMax.y = 0;
585 if(lpszOutput == NULL)
586 return -1;
588 i = 0;
589 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++) {
590 if(ps->PaperDimension->x > ptMax.x)
591 ptMax.x = ps->PaperDimension->x;
592 if(ps->PaperDimension->y > ptMax.y)
593 ptMax.y = ps->PaperDimension->y;
595 *((POINT*)lpszOutput) = ptMax;
596 return 1;
599 case DC_MINEXTENT:
601 PAGESIZE *ps;
602 int i;
603 POINT ptMax;
604 ptMax.x = ptMax.y = 0;
606 if(lpszOutput == NULL)
607 return -1;
609 i = 0;
610 for(ps = pi->ppd->PageSizes; ps; ps = ps->next, i++) {
611 if(ps->PaperDimension->x > ptMax.x)
612 ptMax.x = ps->PaperDimension->x;
613 if(ps->PaperDimension->y > ptMax.y)
614 ptMax.y = ps->PaperDimension->y;
616 *((POINT*)lpszOutput) = ptMax;
617 return 1;
620 case DC_SIZE:
621 return lpdm->dmSize;
623 case DC_TRUETYPE:
624 FIXME("DC_TRUETYPE: stub\n");
625 return DCTT_SUBDEV;
627 case DC_VERSION:
628 return lpdm->dmSpecVersion;
630 /* We'll just return false here, very few printers can collate anyway */
631 case DC_COLLATE:
632 TRACE("DC_COLLATE: returning FALSE\n");
633 return FALSE;
635 /* Printer supports colour printing - 1 if yes, 0 if no (Win2k/XP only) */
636 case DC_COLORDEVICE:
637 return pi->ppd->ColorDevice;
639 /* Identification number of the printer manufacturer for use with ICM (Win9x only) */
640 case DC_MANUFACTURER:
641 FIXME("DC_MANUFACTURER: stub\n");
642 return -1;
644 /* Identification number of the printer model for use with ICM (Win9x only) */
645 case DC_MODEL:
646 FIXME("DC_MODEL: stub\n");
647 return -1;
649 /* Nonzero if the printer supports stapling, zero otherwise (Win2k/XP only) */
650 case DC_STAPLE: /* WINVER >= 0x0500 */
651 FIXME("DC_STAPLE: stub\n");
652 return -1;
654 /* Returns an array of 64-character string buffers containing the names of the paper forms
655 * available for use, unless pOutput is NULL. The return value is the number of paper forms.
656 * (Win2k/XP only)
658 case DC_MEDIAREADY: /* WINVER >= 0x0500 */
659 FIXME("DC_MEDIAREADY: stub\n");
660 return -1;
662 /* Returns an array of 64-character string buffers containing the names of the supported
663 * media types, unless pOutput is NULL. The return value is the number of supported.
664 * media types (XP only)
666 case DC_MEDIATYPENAMES: /* WINVER >= 0x0501 */
667 FIXME("DC_MEDIATYPENAMES: stub\n");
668 return -1;
670 /* Returns an array of DWORD values which represent the supported media types, unless
671 * pOutput is NULL. The return value is the number of supported media types. (XP only)
673 case DC_MEDIATYPES: /* WINVER >= 0x0501 */
674 FIXME("DC_MEDIATYPES: stub\n");
675 return -1;
677 /* Returns an array of DWORD values, each representing a supported number of document
678 * pages per printed page, unless pOutput is NULL. The return value is the number of
679 * array entries. (Win2k/XP only)
681 case DC_NUP:
682 FIXME("DC_NUP: stub\n");
683 return -1;
685 /* Returns an array of 32-character string buffers containing a list of printer description
686 * languages supported by the printer, unless pOutput is NULL. The return value is
687 * number of array entries. (Win2k/XP only)
690 case DC_PERSONALITY: /* WINVER >= 0x0500 */
691 FIXME("DC_PERSONALITY: stub\n");
692 return -1;
694 /* Returns the amount of printer memory in kilobytes. (Win2k/XP only) */
695 case DC_PRINTERMEM: /* WINVER >= 0x0500 */
696 FIXME("DC_PRINTERMEM: stub\n");
697 return -1;
699 /* Returns the printer's print rate in PRINTRATEUNIT units. (Win2k/XP only) */
700 case DC_PRINTRATE: /* WINVER >= 0x0500 */
701 FIXME("DC_PRINTRATE: stub\n");
702 return -1;
704 /* Returns the printer's print rate in pages per minute. (Win2k/XP only) */
705 case DC_PRINTRATEPPM: /* WINVER >= 0x0500 */
706 FIXME("DC_PRINTRATEPPM: stub\n");
707 return -1;
709 /* Returns the printer rate unit used for DC_PRINTRATE, which is one of
710 * PRINTRATEUNIT_{CPS,IPM,LPM,PPM} (Win2k/XP only)
712 case DC_PRINTRATEUNIT: /* WINVER >= 0x0500 */
713 FIXME("DC_PRINTRATEUNIT: stub\n");
714 return -1;
716 default:
717 FIXME("Unsupported capability %d\n", fwCapability);
719 return -1;
722 /**************************************************************
723 * DeviceCapabilities [WINEPS16.91]
725 DWORD WINAPI PSDRV_DeviceCapabilities16(LPCSTR lpszDevice,
726 LPCSTR lpszPort, WORD fwCapability,
727 LPSTR lpszOutput, LPDEVMODEA lpdm)
729 return PSDRV_DeviceCapabilities(NULL, lpszDevice, lpszPort, fwCapability,
730 lpszOutput, lpdm);
733 /***************************************************************
734 * DeviceMode [WINEPS16.13]
737 void WINAPI PSDRV_DeviceMode16(HWND16 hwnd, HANDLE16 hDriver,
738 LPSTR lpszDevice, LPSTR lpszPort)
740 PSDRV_ExtDeviceMode16( hwnd, hDriver, NULL, lpszDevice, lpszPort, NULL,
741 NULL, DM_PROMPT );
742 return;
745 #if 0
746 typedef struct {
747 DWORD nPages;
748 DWORD Unknown;
749 HPROPSHEETPAGE hPages[10];
750 } EDMPS;
752 INT PSDRV_ExtDeviceModePropSheet(HWND hwnd, LPSTR lpszDevice, LPSTR lpszPort,
753 LPVOID pPropSheet)
755 EDMPS *ps = pPropSheet;
756 PROPSHEETPAGE psp;
758 psp->dwSize = sizeof(psp);
759 psp->hInstance = 0x1234;
761 ps->nPages = 1;
765 #endif