Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1058 lines
26 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. driverui.h
  5. Abstract:
  6. Header file for driverui.c
  7. Environment:
  8. Win32 subsystem, DriverUI module, user mode
  9. Revision History:
  10. 02/09/97 -davidx-
  11. Consistent handling of common printer info (COMMONINFO)
  12. 02/04/97 -davidx-
  13. Reorganize driver UI to separate ps and uni DLLs.
  14. 07/17/96 -amandan-
  15. Created it.
  16. --*/
  17. #ifndef _DRIVERUI_H_
  18. #define _DRIVERUI_H_
  19. //
  20. // Global critical section used when accessing shared data
  21. //
  22. // extern CRITICAL_SECTION gCriticalSection;
  23. // #define ENTER_CRITICAL_SECTION() EnterCriticalSection(&gCriticalSection)
  24. // #define LEAVE_CRITICAL_SECTION() LeaveCriticalSection(&gCriticalSection)
  25. //
  26. // Allocate zero-filled memory from a heap
  27. //
  28. #define HEAPALLOC(hheap,size) HeapAlloc(hheap, HEAP_ZERO_MEMORY, size)
  29. #define HEAPREALLOC(hheap, pOrig, size) HeapReAlloc(hheap, HEAP_ZERO_MEMORY, pOrig, size)
  30. //
  31. // Various hardcoded limits
  32. //
  33. #define CCHBINNAME 24 // max length for bin names
  34. #define CCHPAPERNAME 64 // max length for form names
  35. #define CCHMEDIATYPENAME 64 // max length for mediatype names
  36. #define CCHLANGNAME 32 // max length for language strings
  37. #define MIN_OPTIONS_ALLOWED 2
  38. #define UNUSED_PARAM 0xFFFFFFFF
  39. //
  40. // PostScript and UniDriver driver private devmode
  41. //
  42. #ifdef PSCRIPT
  43. #define PDRIVEREXTRA PPSDRVEXTRA
  44. #endif
  45. #ifdef UNIDRV
  46. #define PDRIVEREXTRA PUNIDRVEXTRA
  47. typedef struct _WINRESDATA WINRESDATA;
  48. #endif
  49. #define PGetDevmodeOptionsArray(pdm) \
  50. (((PDRIVEREXTRA) GET_DRIVER_PRIVATE_DEVMODE(pdm))->aOptions)
  51. #define GETUSERDATASIZE(UserData) \
  52. ( ((PUSERDATA)(UserData))->dwSize )
  53. #define GETUSERDATAITEM(UserData) \
  54. ( ((PUSERDATA)(UserData))->dwItemID )
  55. #define GETUSERDATAKEYWORDNAME(UserData) \
  56. ( ((PUSERDATA)(UserData))->pKeyWordName )
  57. #define SETUSERDATAID(pOptItem, dwID) \
  58. ( ((PUSERDATA)((pOptItem)->UserData))->dwItemID = dwID)
  59. #define SETUSERDATA_SIZE(pOptItem, dwSize) \
  60. ( ((PUSERDATA)((pOptItem)->UserData))->dwSize = dwSize)
  61. #define SETUSERDATA_KEYWORDNAME(ci, pOptItem, pFeature) \
  62. ((PUSERDATA)((pOptItem)->UserData))->pKeyWordName = \
  63. OFFSET_TO_POINTER(ci.pUIInfo->pubResourceData, pFeature->loKeywordName)
  64. //
  65. // Common data structure which is needed whether UI comes up or not
  66. //
  67. typedef struct _COMMONINFO {
  68. OEMUIOBJ oemuiobj; // support info for OEM plugins
  69. PVOID pvStartSign; // signature
  70. PTSTR pPrinterName; // current printer name
  71. HANDLE hPrinter; // handle to current printer
  72. DWORD dwFlags; // miscellaneous flag bits
  73. PDRIVER_INFO_3 pDriverInfo3; // driver info level 3
  74. PRAWBINARYDATA pRawData; // raw printer description data
  75. PINFOHEADER pInfoHeader; // current printer description data instance
  76. PUIINFO pUIInfo; // UIINFO structure inside above instance
  77. POEM_PLUGINS pOemPlugins; // OEM plugin information
  78. PDEVMODE pdm; // devmode information
  79. PDRIVEREXTRA pdmPrivate; // driver private devmode fields
  80. PPRINTERDATA pPrinterData; // printer-sticky property data
  81. POPTSELECT pCombinedOptions; // combined options array
  82. PFORM_INFO_1 pSplForms; // spooler forms
  83. DWORD dwSplForms; // number of spooler forms
  84. HANDLE hHeap; // heap used to display UI
  85. #ifdef UNIDRV
  86. WINRESDATA *pWinResData;
  87. #endif
  88. } COMMONINFO, *PCOMMONINFO;
  89. //
  90. // Flag constants for COMMONINFO.dwFlags field
  91. //
  92. #define FLAG_OPENPRINTER_NORMAL 0x0001
  93. #define FLAG_OPEN_CONDITIONAL 0x0002
  94. #define FLAG_OPENPRINTER_ADMIN 0x0004
  95. #define FLAG_INIT_PRINTER 0x0008
  96. #define FLAG_ALLOCATE_UIDATA 0x0010
  97. #define FLAG_PROCESS_INIFILE 0x0020
  98. #define FLAG_REFRESH_PARSED_DATA 0x0040
  99. #define FLAG_WITHIN_PLUGINCALL 0x0080
  100. #define FLAG_APPLYNOW_CALLED 0x0100
  101. #define FLAG_PLUGIN_CHANGED_OPTITEM 0x0200
  102. #define FLAG_USER_CHANGED_FREEMEM 0x0400
  103. #define FLAG_PROPSHEET_SESSION 0x0800
  104. #define FLAG_UPGRADE_PRINTER 0x1000
  105. #define IS_WITHIN_PROPSHEET_SESSION(pci) ((pci)->dwFlags & FLAG_PROPSHEET_SESSION)
  106. //
  107. // Special entry point for getting around EnumForm bug in spooler
  108. //
  109. DWORD
  110. DrvSplDeviceCaps(
  111. HANDLE hPrinter,
  112. PWSTR pDeviceName,
  113. WORD wCapability,
  114. PVOID pOutput,
  115. DWORD dwOutputSize,
  116. PDEVMODE pdmSrc
  117. );
  118. //
  119. // Load basic information needed by the driver UI
  120. //
  121. PCOMMONINFO
  122. PLoadCommonInfo(
  123. IN HANDLE hPrinter,
  124. IN PTSTR ptstrPrinterName,
  125. IN DWORD dwFlags
  126. );
  127. //
  128. // Release common information used by the driver UI
  129. //
  130. VOID
  131. VFreeCommonInfo(
  132. IN PCOMMONINFO pci
  133. );
  134. //
  135. // Populate the devmode fields in the COMMONINFO structure
  136. //
  137. BOOL
  138. BFillCommonInfoDevmode(
  139. IN OUT PCOMMONINFO pci,
  140. IN PDEVMODE pdmPrinter,
  141. IN PDEVMODE pdmInput
  142. );
  143. //
  144. // Populate the printer-sticky property data field
  145. //
  146. BOOL
  147. BFillCommonInfoPrinterData(
  148. IN OUT PCOMMONINFO pci
  149. );
  150. //
  151. // Combined document-sticky feature selections and printer-sticky
  152. // feature selection into a single options array
  153. //
  154. BOOL
  155. BCombineCommonInfoOptionsArray(
  156. IN OUT PCOMMONINFO pci
  157. );
  158. //
  159. // Get an updated printer description data instance
  160. // using the combined options array
  161. //
  162. BOOL
  163. BUpdateUIInfo(
  164. IN OUT PCOMMONINFO pci
  165. );
  166. //
  167. // Fix up combined options array with information from public devmode fields
  168. //
  169. VOID
  170. VFixOptionsArrayWithDevmode(
  171. IN OUT PCOMMONINFO pci
  172. );
  173. //
  174. // Convert option array setting into public devmode fields
  175. //
  176. VOID
  177. VOptionsToDevmodeFields(
  178. IN OUT PCOMMONINFO pci,
  179. IN BOOL bUpdateFormFields
  180. );
  181. #ifndef WINNT_40
  182. //
  183. // Notify DS of update
  184. //
  185. VOID
  186. VNotifyDSOfUpdate(
  187. IN HANDLE hPrinter
  188. );
  189. #endif
  190. //
  191. // Get a read-only copy of a display name:
  192. // 1) if the display name is in the binary printer description data,
  193. // then we simply return a pointer to that data.
  194. // 2) otherwise, the display name is in the resource DLL.
  195. // we allocate memory out of the driver's heap and
  196. // load the string.
  197. //
  198. // Caller should NOT free the returned pointer. The memory
  199. // will go away when the binary printer description data is unloaded
  200. // or when the driver's heap is destroyed.
  201. //
  202. // Since PSCRIPT currently doesn't have any resource DLL,
  203. // we define this as a macro to save a function call.
  204. //
  205. #ifdef PSCRIPT
  206. #define PGetReadOnlyDisplayName(pci, loOffset) \
  207. OFFSET_TO_POINTER((pci)->pUIInfo->pubResourceData, (loOffset))
  208. #else
  209. PWSTR
  210. PGetReadOnlyDisplayName(
  211. PCOMMONINFO pci,
  212. PTRREF loOffset
  213. );
  214. #endif
  215. //
  216. // This macro is defined as a convenience to get a read-only
  217. // copy of the display name for an option.
  218. //
  219. #define GET_OPTION_DISPLAY_NAME(pci, pOption) \
  220. PGetReadOnlyDisplayName(pci, ((POPTION) (pOption))->loDisplayName)
  221. //
  222. // This function is similar to PGetReadOnlyDisplayName
  223. // but the caller must provide the buffer for loading the string.
  224. //
  225. BOOL
  226. BLoadDisplayNameString(
  227. PCOMMONINFO pci,
  228. PTRREF loOffset,
  229. PWSTR pwstrBuf,
  230. INT iMaxChars
  231. );
  232. BOOL
  233. BLoadPageSizeNameString(
  234. PCOMMONINFO pci,
  235. PTRREF loOffset,
  236. PWSTR pwstrBuf,
  237. INT iMaxChars,
  238. INT iStdID
  239. );
  240. //
  241. // Convenience macro for loading the display name of an option
  242. // into a caller-provided buffer.
  243. //
  244. #define LOAD_STRING_OPTION_NAME(pci, pOption, pwch, maxsize) \
  245. BLoadDisplayNameString(pci, ((POPTION) (pOption))->loDisplayName, pwch, maxsize)
  246. #define LOAD_STRING_PAGESIZE_NAME(pci, pPageSize, pwch, maxsize) \
  247. BLoadPageSizeNameString(pci, (pPageSize)->GenericOption.loDisplayName, pwch, maxsize, (pPageSize)->dwPaperSizeID)
  248. //
  249. // Load icon resource from the resource DLL
  250. //
  251. ULONG_PTR
  252. HLoadIconFromResourceDLL(
  253. PCOMMONINFO pci,
  254. DWORD dwIconID
  255. );
  256. //
  257. // Data structure which is used only when UI is displayed
  258. // IMPORTANT: The first field must be a COMMONINFO structure.
  259. //
  260. typedef struct _UIDATA {
  261. COMMONINFO ci;
  262. INT iMode;
  263. HWND hDlg;
  264. BOOL bPermission;
  265. BOOL bIgnoreConflict;
  266. BOOL bEMFSpooling;
  267. PFNCOMPROPSHEET pfnComPropSheet;
  268. HANDLE hComPropSheet;
  269. PCOMPROPSHEETUI pCompstui;
  270. //
  271. // These fields are valid only when a dialog is presented
  272. //
  273. DWORD dwFormNames;
  274. PWSTR pFormNames;
  275. PWORD pwPapers;
  276. PWORD pwPaperFeatures;
  277. DWORD dwBinNames;
  278. PWSTR pBinNames;
  279. //
  280. // Used for helper functions
  281. //
  282. BOOL abEnabledOptions[MAX_PRINTER_OPTIONS];
  283. //
  284. // Fields for keeping track of various option items
  285. //
  286. DWORD dwDrvOptItem;
  287. POPTITEM pDrvOptItem;
  288. DWORD dwFormTrayItem;
  289. POPTITEM pFormTrayItems;
  290. DWORD dwTTFontItem;
  291. POPTITEM pTTFontItems;
  292. DWORD dwFeatureItem;
  293. POPTITEM pFeatureItems;
  294. POPTITEM pFeatureHdrItem;
  295. //
  296. // These fields are used for packing option items
  297. //
  298. DWORD dwOptItem;
  299. POPTITEM pOptItem;
  300. DWORD dwOptType;
  301. POPTTYPE pOptType;
  302. //
  303. // UniDriver specific fields
  304. //
  305. #ifdef UNIDRV
  306. //
  307. // Font Cart Table
  308. //
  309. DWORD dwFontCart;
  310. POPTITEM pFontCart;
  311. //
  312. // Device halftone setup info
  313. //
  314. PDEVHTINFO pDevHTInfo;
  315. #endif // UNIDRV
  316. DWORD dwHideFlags;
  317. PVOID pvEndSign;
  318. } UIDATA, *PUIDATA;
  319. //
  320. // Flag constants for UIDATA.dwHideFlags field
  321. //
  322. #define HIDEFLAG_HIDE_STD_DOCPROP 0x0001
  323. #define HIDEFLAG_HIDE_STD_PRNPROP 0x0002
  324. #define IS_HIDING_STD_UI(pUiData) \
  325. ((((pUiData)->iMode == MODE_DOCUMENT_STICKY) && \
  326. ((pUiData)->dwHideFlags & HIDEFLAG_HIDE_STD_DOCPROP)) || \
  327. (((pUiData)->iMode == MODE_PRINTER_STICKY) && \
  328. ((pUiData)->dwHideFlags & HIDEFLAG_HIDE_STD_PRNPROP)))
  329. #define VALIDUIDATA(pUiData) ((pUiData) && \
  330. (pUiData) == (pUiData)->ci.pvStartSign && \
  331. (pUiData) == (pUiData)->pvEndSign)
  332. #define HASPERMISSION(pUiData) ((pUiData)->bPermission)
  333. //
  334. // This function is called by DrvDocumentPropertySheets and
  335. // DrvPrinterPropertySheets. It allocates and initializes
  336. // a UIDATA structure that's used to display property pages.
  337. //
  338. PUIDATA
  339. PFillUiData(
  340. IN HANDLE hPrinter,
  341. IN PTSTR pPrinterName,
  342. IN PDEVMODE pdmInput,
  343. IN INT iMode
  344. );
  345. //
  346. // Dispose of a UIDATA structure -
  347. // Just disposed of the embedded COMMONINFO structure
  348. //
  349. #define VFreeUiData(pUiData) VFreeCommonInfo((PCOMMONINFO) (pUiData))
  350. //
  351. // Data structure used to pass parameters to "Conflicts" dialog
  352. //
  353. typedef struct _DLGPARAM {
  354. PFNCOMPROPSHEET pfnComPropSheet;
  355. HANDLE hComPropSheet;
  356. PUIDATA pUiData;
  357. BOOL bFinal;
  358. POPTITEM pOptItem;
  359. DWORD dwResult;
  360. } DLGPARAM, *PDLGPARAM;
  361. #define CONFLICT_NONE IDOK
  362. #define CONFLICT_RESOLVE IDC_RESOLVE
  363. #define CONFLICT_CANCEL IDC_CANCEL
  364. #define CONFLICT_IGNORE IDC_IGNORE
  365. //
  366. // Functions used to implement DeviceCapabilities:
  367. // calculate minimum or maximum paper size extent
  368. // get list of supported paper size names, indices, and dimensions
  369. // get list of supported paper bin names and indices
  370. // get list of supported resolutions
  371. //
  372. DWORD
  373. DwCalcMinMaxExtent(
  374. IN PCOMMONINFO pci,
  375. OUT PPOINT pptOutput,
  376. IN WORD wCapability
  377. );
  378. DWORD
  379. DwEnumPaperSizes(
  380. IN OUT PCOMMONINFO pci,
  381. OUT PWSTR pPaperNames,
  382. OUT PWORD pPapers,
  383. OUT PPOINT pPaperSizes,
  384. IN PWORD pPaperFeatures,
  385. IN LONG cchPaperNamesBufSize
  386. );
  387. DWORD
  388. DwEnumBinNames(
  389. IN PCOMMONINFO pci,
  390. OUT PWSTR pBinNames
  391. );
  392. DWORD
  393. DwEnumBins(
  394. IN PCOMMONINFO pci,
  395. OUT PWORD pBins
  396. );
  397. DWORD
  398. DwEnumResolutions(
  399. IN PCOMMONINFO pci,
  400. OUT PLONG pResolutions
  401. );
  402. DWORD
  403. DwEnumNupOptions(
  404. PCOMMONINFO pci,
  405. PDWORD pdwOutput
  406. );
  407. DWORD
  408. DwGetAvailablePrinterMem(
  409. IN PCOMMONINFO pci
  410. );
  411. DWORD
  412. DwEnumMediaReady(
  413. IN OUT FORM_TRAY_TABLE pFormTrayTable,
  414. OUT PDWORD pdwResultSize
  415. );
  416. #ifndef WINNT_40
  417. //
  418. // DC_MEDIATYPENAMES and DC_MEDIATYPES are added in Whistler.
  419. // We need to do following so the driver can also be built with
  420. // Win2K SDK/DDK.
  421. //
  422. #ifndef DC_MEDIATYPENAMES
  423. #define DC_MEDIATYPENAMES 34
  424. #endif
  425. #ifndef DC_MEDIATYPES
  426. #define DC_MEDIATYPES 35
  427. #endif
  428. #endif // !WINNT_40
  429. DWORD
  430. DwEnumMediaTypes(
  431. IN PCOMMONINFO pci,
  432. OUT PTSTR pMediaTypeNames,
  433. OUT PDWORD pMediaTypes
  434. );
  435. //
  436. // Functions for dealing with forms
  437. //
  438. BOOL
  439. BFormSupportedOnPrinter(
  440. IN PCOMMONINFO pci,
  441. IN PFORM_INFO_1 pFormInfo,
  442. OUT PDWORD pdwOptionIndex
  443. );
  444. BOOL
  445. BPackItemFormTrayTable(
  446. IN OUT PUIDATA pUiData
  447. );
  448. BOOL
  449. BUnpackItemFormTrayTable(
  450. IN OUT PUIDATA pUiData
  451. );
  452. VOID
  453. VSetupFormTrayAssignments(
  454. IN PUIDATA pUiData
  455. );
  456. DWORD
  457. DwFindFormNameIndex(
  458. IN PUIDATA pUiData,
  459. IN PWSTR pFormName,
  460. OUT PBOOL pbSupported
  461. );
  462. ULONG_PTR
  463. HLoadFormIconResource(
  464. PUIDATA pUiData,
  465. DWORD dwIndex
  466. );
  467. DWORD
  468. DwGuessFormIconID(
  469. PWSTR pFormName
  470. );
  471. //
  472. // Functions prototypes for commonui related items.
  473. //
  474. PCOMPROPSHEETUI
  475. PPrepareDataForCommonUI(
  476. IN OUT PUIDATA pUiData,
  477. IN PDLGPAGE pDlgPage
  478. );
  479. BOOL
  480. BPackPrinterPropertyItems(
  481. IN OUT PUIDATA pUiData
  482. );
  483. BOOL
  484. BPackDocumentPropertyItems(
  485. IN OUT PUIDATA pUiData
  486. );
  487. VOID
  488. VPackOptItemGroupHeader(
  489. IN OUT PUIDATA pUiData,
  490. IN DWORD dwTitleId,
  491. IN DWORD dwIconId,
  492. IN DWORD dwHelpIndex
  493. );
  494. BOOL
  495. BPackOptItemTemplate(
  496. IN OUT PUIDATA pUiData,
  497. IN CONST WORD pwItemInfo[],
  498. IN DWORD dwSelection,
  499. IN PFEATURE pFeature
  500. );
  501. #define ITEM_INFO_SIGNATURE 0xCAFE
  502. BOOL
  503. BPackUDArrowItemTemplate(
  504. IN OUT PUIDATA pUiData,
  505. IN CONST WORD pwItemInfo[],
  506. IN DWORD dwSelection,
  507. IN DWORD dwMaxVal,
  508. IN PFEATURE pFeature
  509. );
  510. POPTPARAM
  511. PFillOutOptType(
  512. OUT POPTTYPE pOptType,
  513. IN DWORD dwType,
  514. IN DWORD dwParams,
  515. IN HANDLE hHeap
  516. );
  517. PFEATURE
  518. PGetFeatureFromItem(
  519. IN PUIINFO pUIInfo,
  520. IN OUT POPTITEM pOptItem,
  521. OUT PDWORD pdwFeatureIndex
  522. );
  523. BOOL
  524. BPackItemGenericOptions(
  525. IN OUT PUIDATA pUiData
  526. );
  527. BOOL
  528. BPackItemPrinterFeature(
  529. IN OUT PUIDATA pUiData,
  530. IN PFEATURE pFeature,
  531. IN DWORD dwLevel,
  532. IN DWORD dwPub,
  533. IN ULONG_PTR dwUserData,
  534. IN DWORD dwHelpIndex
  535. );
  536. DWORD
  537. DwCountDisplayableGenericFeature(
  538. IN PUIDATA pUiData,
  539. BOOL bPrinterSticky
  540. );
  541. BOOL
  542. BShouldDisplayGenericFeature(
  543. IN PFEATURE pFeature,
  544. IN BOOL bPrinterSticky
  545. );
  546. BOOL
  547. BOptItemSelectionsChanged(
  548. IN OUT POPTITEM pItems,
  549. IN DWORD dwItems
  550. );
  551. POPTITEM
  552. PFindOptItem(
  553. IN PUIDATA pUiData,
  554. IN DWORD dwItemId
  555. );
  556. BOOL
  557. BPackItemFontSubstTable(
  558. IN PUIDATA pUiData
  559. );
  560. BOOL
  561. BUnpackItemFontSubstTable(
  562. IN PUIDATA pUiData
  563. );
  564. PTSTR
  565. PtstrDuplicateStringFromHeap(
  566. IN PTSTR ptstrSrc,
  567. IN HANDLE hHeap
  568. );
  569. VOID
  570. VUpdateOptionsArrayWithSelection(
  571. IN OUT PUIDATA pUiData,
  572. IN POPTITEM pOptItem
  573. );
  574. VOID
  575. VUnpackDocumentPropertiesItems(
  576. IN OUT PUIDATA pUiData,
  577. IN OUT POPTITEM pOptItem,
  578. IN DWORD dwCound);
  579. BOOL
  580. BGetPageOrderFlag(
  581. IN PCOMMONINFO pci
  582. );
  583. VOID
  584. VPropShowConstraints(
  585. IN PUIDATA pUiData,
  586. IN INT iMode
  587. );
  588. INT
  589. ICheckConstraintsDlg(
  590. IN OUT PUIDATA pUiData,
  591. IN OUT POPTITEM pOptItem,
  592. IN DWORD dwOptItem,
  593. IN BOOL bFinal
  594. );
  595. #define CONSTRAINED_FLAG OPTPF_OVERLAY_WARNING_ICON
  596. #define IS_CONSTRAINED(pitem, sel) ((pitem)->pOptType->pOptParam[sel].Flags & CONSTRAINED_FLAG)
  597. //
  598. // This function copy a source devmode to an output devmode buffer.
  599. // It should be called by the driver just before the driver returns
  600. // to the caller of DrvDocumentPropertySheets.
  601. //
  602. BOOL
  603. BConvertDevmodeOut(
  604. IN PDEVMODE pdmSrc,
  605. IN PDEVMODE pdmIn,
  606. OUT PDEVMODE pdmOut
  607. );
  608. //
  609. // Find the OPTITEM with UserData's pKeywordName matching given keyword name
  610. //
  611. POPTITEM
  612. PFindOptItemWithKeyword(
  613. IN PUIDATA pUiData,
  614. IN PCSTR pKeywordName
  615. );
  616. //
  617. // Find the OPTITEM containing the specified UserData value
  618. //
  619. POPTITEM
  620. PFindOptItemWithUserData(
  621. IN PUIDATA pUiData,
  622. IN DWORD UserData
  623. );
  624. //
  625. // Sync up OPTITEM list with the updated options array
  626. //
  627. VOID
  628. VUpdateOptItemList(
  629. IN OUT PUIDATA pUiData,
  630. IN POPTSELECT pOldCombinedOptions,
  631. IN POPTSELECT pNewCombinedOptions
  632. );
  633. //
  634. // Display an error message box
  635. //
  636. INT
  637. IDisplayErrorMessageBox(
  638. HWND hwndParent,
  639. UINT uType,
  640. INT iTitleStrId,
  641. INT iFormatStrId,
  642. ...
  643. );
  644. BOOL
  645. BPrepareForLoadingResource(
  646. PCOMMONINFO pci,
  647. BOOL bNeedHeap
  648. );
  649. //
  650. // Fill out an OPTITEM structure
  651. //
  652. #define FILLOPTITEM(poptitem,popttype,name,sel,level,dmpub,userdata,help) \
  653. (poptitem)->cbSize = sizeof(OPTITEM); \
  654. (poptitem)->Flags |= OPTIF_CALLBACK; \
  655. (poptitem)->pOptType = (popttype); \
  656. (poptitem)->pName = (PWSTR) (name); \
  657. (poptitem)->pSel = (PVOID) (sel); \
  658. (poptitem)->Level = (BYTE) (level); \
  659. (poptitem)->DMPubID = (BYTE) (dmpub); \
  660. SETUSERDATAID(poptitem, userdata); \
  661. (poptitem)->HelpIndex = (help)
  662. //
  663. // Tree view item level
  664. //
  665. #define TVITEM_LEVEL1 1
  666. #define TVITEM_LEVEL2 2
  667. #define TVITEM_LEVEL3 3
  668. enum {
  669. UNKNOWN_ITEM,
  670. FONT_SUBST_ITEM,
  671. FONTSLOT_ITEM,
  672. PRINTER_VM_ITEM,
  673. HALFTONE_SETUP_ITEM,
  674. IGNORE_DEVFONT_ITEM,
  675. PSPROTOCOL_ITEM,
  676. JOB_TIMEOUT_ITEM,
  677. WAIT_TIMEOUT_ITEM,
  678. COPIES_COLLATE_ITEM,
  679. SCALE_ITEM,
  680. COLOR_ITEM,
  681. ICMMETHOD_ITEM,
  682. ICMINTENT_ITEM,
  683. TTOPTION_ITEM,
  684. METASPOOL_ITEM,
  685. NUP_ITEM,
  686. REVPRINT_ITEM,
  687. MIRROR_ITEM,
  688. NEGATIVE_ITEM,
  689. COMPRESSBMP_ITEM,
  690. CTRLD_BEFORE_ITEM,
  691. CTRLD_AFTER_ITEM,
  692. TEXT_ASGRX_ITEM,
  693. PAGE_PROTECT_ITEM,
  694. PSOUTPUT_OPTION_ITEM,
  695. PSTT_DLFORMAT_ITEM,
  696. PSLEVEL_ITEM,
  697. PSERROR_HANDLER_ITEM,
  698. PSMINOUTLINE_ITEM,
  699. PSMAXBITMAP_ITEM,
  700. PSHALFTONE_FREQ_ITEM,
  701. PSHALFTONE_ANGLE_ITEM,
  702. QUALITY_SETTINGS_ITEM,
  703. SOFTFONT_SETTINGS_ITEM,
  704. TRUE_GRAY_TEXT_ITEM,
  705. TRUE_GRAY_GRAPH_ITEM,
  706. ADD_EURO_ITEM,
  707. //
  708. // !!! Only items whose UserData value is larger than
  709. // CONSTRAINABLE_ITEM can have constraints.
  710. //
  711. CONSTRAINABLE_ITEM = 0x8000,
  712. ORIENTATION_ITEM = CONSTRAINABLE_ITEM,
  713. DUPLEX_ITEM,
  714. RESOLUTION_ITEM,
  715. INPUTSLOT_ITEM,
  716. FORMNAME_ITEM,
  717. MEDIATYPE_ITEM,
  718. COLORMODE_ITEM,
  719. HALFTONING_ITEM,
  720. FORM_TRAY_ITEM,
  721. };
  722. //
  723. // Interpretation of OPTITEM.UserData: If it's less than 0x10000
  724. // then it's one of the constants defined above. Otherwise, it's
  725. // a pointer to a FEATURE object.
  726. //
  727. #define DRIVERUI_MAX_ITEM 0x10000
  728. #define ISPRINTERFEATUREITEM(userData) (GETUSERDATAITEM(userData) >= DRIVERUI_MAX_ITEM)
  729. #define ISCONSTRAINABLEITEM(userData) (GETUSERDATAITEM(userData) >= CONSTRAINABLE_ITEM)
  730. #define ISFORMTRAYITEM(userData) (GETUSERDATAITEM(userData) == FORM_TRAY_ITEM)
  731. #define ISFONTSUBSTITEM(userData) (GETUSERDATAITEM(userData) == FONT_SUBST_ITEM)
  732. //
  733. // Determine whether certain features are supported on the printer
  734. //
  735. #ifdef UNIDRV
  736. #define SUPPORTS_DUPLEX(pci) \
  737. ((!_BFeatureDisabled(pci, 0xFFFFFFFF, GID_DUPLEX)) && \
  738. (GET_PREDEFINED_FEATURE((pci)->pUIInfo, GID_DUPLEX) != NULL))
  739. #else
  740. #define SUPPORTS_DUPLEX(pci) \
  741. ((_BSupportFeature(pci, GID_DUPLEX, NULL)) && \
  742. (GET_PREDEFINED_FEATURE(pci->pUIInfo, GID_DUPLEX) != NULL))
  743. #endif // UNIDRV
  744. #define SUPPORTS_PAGE_PROTECT(pUIInfo) \
  745. (GET_PREDEFINED_FEATURE(pUIInfo, GID_PAGEPROTECTION) != NULL)
  746. #ifdef UNIDRV
  747. #define PRINTER_SUPPORTS_COLLATE(pci) \
  748. ((!_BFeatureDisabled(pci, 0xFFFFFFFF, GID_COLLATE)) && \
  749. (GET_PREDEFINED_FEATURE((pci)->pUIInfo, GID_COLLATE) != NULL))
  750. #else
  751. #define PRINTER_SUPPORTS_COLLATE(pci) \
  752. ((_BSupportFeature(pci, GID_COLLATE, NULL)) && \
  753. (GET_PREDEFINED_FEATURE(pci->pUIInfo, GID_COLLATE) != NULL))
  754. #endif // UNIDRV
  755. #ifdef WINNT_40
  756. #define DRIVER_SUPPORTS_COLLATE(pci) PRINTER_SUPPORTS_COLLATE(pci)
  757. #else
  758. #define DRIVER_SUPPORTS_COLLATE(pci) TRUE
  759. #endif
  760. //
  761. // Data structure containing information about cached driver files
  762. //
  763. typedef struct _CACHEDFILE {
  764. HANDLE hRemoteFile; // open handle to remote file on the server
  765. PWSTR pRemoteDir; // remote directory on the server
  766. PWSTR pLocalDir; // local directory
  767. PWSTR pFilename; // name of the cached file
  768. } CACHEDFILE, *PCACHEDFILE;
  769. //
  770. // Functions for copying files over during point and print
  771. //
  772. BOOL _BPrepareToCopyCachedFile(HANDLE, PCACHEDFILE, PWSTR);
  773. BOOL _BCopyCachedFile(PCOMMONINFO, PCACHEDFILE);
  774. VOID _VDisposeCachedFileInfo(PCACHEDFILE);
  775. //
  776. // Driver specific functions (implemented in ps and uni subdirectories)
  777. //
  778. DWORD _DwEnumPersonalities(PCOMMONINFO, PWSTR);
  779. DWORD _DwGetOrientationAngle(PUIINFO, PDEVMODE);
  780. BOOL _BPackDocumentOptions(PUIDATA);
  781. VOID _VUnpackDocumentOptions(POPTITEM, PDEVMODE);
  782. BOOL _BPackPrinterOptions(PUIDATA);
  783. BOOL _BPackOrientationItem(PUIDATA);
  784. INT _IListDevFontNames(HDC, PWSTR, INT);
  785. INT_PTR CALLBACK _AboutDlgProc(HWND, UINT, WPARAM, LPARAM);
  786. #define FREE_DEFAULT_FONTSUB_TABLE(pTTSubstTable) MemFree(pTTSubstTable)
  787. #ifdef PSCRIPT
  788. #define _PwstrGetCallerName() ((PWSTR) IDS_POSTSCRIPT)
  789. #define _DwGetFontCap(pUIInfo) (DCTT_DOWNLOAD | DCTT_SUBDEV)
  790. #define _DwGetDefaultResolution() DEFAULT_RESOLUTION
  791. #define _DwGetPrinterIconID() IDI_CPSUI_POSTSCRIPT
  792. #define _BUnpackPrinterOptions(pUiData) TRUE
  793. BOOL _BSupportStapling(PCOMMONINFO);
  794. VOID _VUnpackDriverPrnPropItem(PUIDATA, POPTITEM);
  795. BOOL _BPackItemScale(PUIDATA);
  796. BOOL _BPackFontSubstItems(PUIDATA);
  797. BOOL _BSupportFeature(PCOMMONINFO, DWORD, PFEATURE);
  798. BOOL BDisplayPSCustomPageSizeDialog(PUIDATA);
  799. BOOL BUpdateModelNtfFilename(PCOMMONINFO);
  800. VOID VSyncRevPrintAndOutputOrder(PUIDATA, POPTITEM);
  801. #ifdef WINNT_40
  802. BOOL BUpdateVMErrorMessageID(PCOMMONINFO);
  803. #endif // WINNT_40
  804. #define ISSET_MFSPOOL_FLAG(pdmExtra) ((pdmExtra)->dwFlags & PSDEVMODE_METAFILE_SPOOL)
  805. #define SET_MFSPOOL_FLAG(pdmExtra) ((pdmExtra)->dwFlags |= PSDEVMODE_METAFILE_SPOOL)
  806. #define CLEAR_MFSPOOL_FLAG(pdmExtra) ((pdmExtra)->dwFlags &= ~PSDEVMODE_METAFILE_SPOOL)
  807. #define NUPOPTION(pdmExtra) ((pdmExtra)->iLayout)
  808. #define REVPRINTOPTION(pdmExtra) ((pdmExtra)->bReversePrint)
  809. #define GET_DEFAULT_FONTSUB_TABLE(pci, pUIInfo) PtstrGetDefaultTTSubstTable(pUIInfo)
  810. #define NOT_UNUSED_ITEM(bOrderReversed) TRUE
  811. #define ILOADSTRING(pci, id, wchbuf, size) 0
  812. #endif // PSCRIPT
  813. #ifdef UNIDRV
  814. #define _PwstrGetCallerName() ((PWSTR) IDS_UNIDRV)
  815. #define _DwGetDefaultResolution() 300
  816. #define _BPackItemScale(pUiData) TRUE
  817. #define _BPackFontSubstItems(pUiData) BPackItemFontSubstTable(pUiData)
  818. #define _DwGetPrinterIconID() IDI_CPSUI_PRINTER2
  819. #define BValidateDevmodeCustomPageSizeFields(pRawData, pUIInfo, pdm, prclImageArea) FALSE
  820. #define _VUnpackDriverPrnPropItem(pUiData, pOptItem)
  821. DWORD _DwGetFontCap(PUIINFO);
  822. BOOL _BUnpackPrinterOptions(PUIDATA);
  823. BOOL _BSupportStapling(PCOMMONINFO);
  824. BOOL _BFeatureDisabled(PCOMMONINFO, DWORD, WORD);
  825. VOID VSyncColorInformation(PUIDATA, POPTITEM);
  826. VOID VMakeMacroSelections(PUIDATA, POPTITEM);
  827. VOID VUpdateMacroSelection(PUIDATA, POPTITEM);
  828. PTSTR PtstrUniGetDefaultTTSubstTable(PCOMMONINFO, PUIINFO);
  829. BOOL BOkToChangeColorToMono(PCOMMONINFO, PDEVMODE, SHORT * , SHORT *);
  830. #define ISSET_MFSPOOL_FLAG(pdmExtra) (((pdmExtra)->dwFlags & DXF_NOEMFSPOOL) == 0)
  831. #define SET_MFSPOOL_FLAG(pdmExtra) ((pdmExtra)->dwFlags &= ~DXF_NOEMFSPOOL)
  832. #define CLEAR_MFSPOOL_FLAG(pdmExtra) ((pdmExtra)->dwFlags |= DXF_NOEMFSPOOL)
  833. #define NUPOPTION(pdmExtra) ((pdmExtra)->iLayout)
  834. #define REVPRINTOPTION(pdmExtra) ((pdmExtra)->bReversePrint)
  835. #define GET_DEFAULT_FONTSUB_TABLE(pci, pUIInfo) PtstrUniGetDefaultTTSubstTable(pci, pUIInfo)
  836. #define NOT_UNUSED_ITEM(bOrderReversed) (bOrderReversed != UNUSED_ITEM)
  837. #define ILOADSTRING(pci, id, wchbuf, size) \
  838. ILoadStringW(((pci)->pWinResData), id, wchbuf, size)
  839. #endif // UNIDRV
  840. #endif //!_DRIVERUI_H_