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.

489 lines
16 KiB

  1. /*++
  2. Copyright (c) 1996 - 1999 Microsoft Corporation
  3. Module Name:
  4. devmode.h
  5. Abstract:
  6. DEVMODE related declarations and definitions
  7. [Environment:]
  8. Win32 subsystem, printer drivers
  9. Revision History:
  10. 02/04/07 -davidx-
  11. Devmode changes to support OEM plugins.
  12. 07/31/96 -davidx-
  13. Add BValidateDevmodeFormFields.
  14. 07/31/96 -amandan-
  15. Updated for UI Module
  16. 07/22/96 -srinivac-
  17. Updated for PSCRIPT5
  18. 07/25/95 -davidx-
  19. Created it.
  20. --*/
  21. #ifndef _DEVMODE_H_
  22. #define _DEVMODE_H_
  23. //
  24. // Maximum scale factor and maximum copy count
  25. //
  26. #define MIN_SCALE 1
  27. #define MAX_SCALE 1000
  28. #define MIN_COPIES 1
  29. #define MAX_COPIES 9999
  30. //
  31. // PostScript driver private devmode flags
  32. //
  33. #define PSDEVMODE_EPS 0x00000001 // outputting EPS file
  34. #define PSDEVMODE_EHANDLER 0x00000002 // download error handler
  35. #define PSDEVMODE_MIRROR 0x00000004 // mirror image
  36. #define PSDEVMODE_BLACK 0x00000008 // all colors set to black
  37. #define PSDEVMODE_NEG 0x00000010 // negative image
  38. #define PSDEVMODE_FONTSUBST 0x00000020 // font substitution enabled
  39. #define PSDEVMODE_COMPRESSBMP 0x00000040 // bitmap compr. is enabled
  40. #define PSDEVMODE_ENUMPRINTERFONTS 0x00000080 // use printer fonts
  41. #define PSDEVMODE_INDEPENDENT 0x00000100 // do page independence
  42. #define PSDEVMODE_LSROTATE 0x00000200 // rotated landscape
  43. #define PSDEVMODE_NO_LEVEL2 0x00000400 // don't use level 2 features
  44. #define PSDEVMODE_CTRLD_BEFORE 0x00000800 // send ^D before job - obsolete
  45. #define PSDEVMODE_CTRLD_AFTER 0x00001000 // send ^D after job - obsolete
  46. #define PSDEVMODE_METAFILE_SPOOL 0x00002000 // enable metafile spooling
  47. #define PSDEVMODE_NO_JOB_CONTROL 0x00004000 // don't send job control code
  48. //
  49. // The following flags are obsolete and are used for compatibility. When
  50. // a devmode comes into the driver or a devmode leaves the driver, these
  51. // fields are checked or updated respectively. Internally the driver
  52. // uses new fields to mainatain these values. The obsolete flags are:
  53. //
  54. // PSDEVMODE_EPS
  55. // PSDEVMODE_INDEPENDENT
  56. // PSDEVMODE_NO_LEVEL2
  57. // PSDEVMODE_FONTSUBST
  58. //
  59. //
  60. // Nup values
  61. //
  62. typedef enum {
  63. ONE_UP,
  64. TWO_UP,
  65. FOUR_UP,
  66. SIX_UP,
  67. NINE_UP,
  68. SIXTEEN_UP,
  69. BOOKLET_UP,
  70. } LAYOUT;
  71. //
  72. // Output dialect values
  73. //
  74. typedef enum {
  75. SPEED, // optimize for speed
  76. PORTABILITY, // optimize for portability
  77. EPS, // generate eps output
  78. ARCHIVE, // output for archival
  79. } DIALECT;
  80. //
  81. // TT font downloading formats
  82. //
  83. typedef enum {
  84. TT_DEFAULT, // download in default format
  85. TYPE_1, // download as Type 1 outlines
  86. TYPE_3, // download as Type 3 bitmaps
  87. TYPE_42, // download as Type 42 fonts
  88. TRUEIMAGE, // download as TrueType
  89. TT_NODOWNLOAD, // do not download TT fonts
  90. } TTDLFMT;
  91. //
  92. // Custom page size feed directions
  93. // Use #define instead of enums because they're used in resource file.
  94. //
  95. #define LONGEDGEFIRST 0 // long edge first
  96. #define SHORTEDGEFIRST 1 // short edge first
  97. #define LONGEDGEFIRST_FLIPPED 2 // long edge first, upside down
  98. #define SHORTEDGEFIRST_FLIPPED 3 // short edge first, upside down
  99. #define MAX_FEEDDIRECTION 4
  100. //
  101. // PostScript driver devmode
  102. //
  103. typedef struct _CUSTOMSIZEDATA { // custom page size parameters
  104. DWORD dwX; // logical paper width (in microns)
  105. DWORD dwY; // logical paper height
  106. DWORD dwWidthOffset; // offset perpendicular to feed direction
  107. DWORD dwHeightOffset; // offset parallel to feed direction
  108. WORD wFeedDirection; // paper feed direction
  109. WORD wCutSheet; // use cut-sheet behavior or not
  110. } CUSTOMSIZEDATA, *PCUSTOMSIZEDATA;
  111. typedef struct _PSDRVEXTRA {
  112. DWORD dwSignature; // private devmode signature
  113. DWORD dwFlags; // flag bits
  114. WCHAR wchEPSFile[40]; // EPS file name
  115. COLORADJUSTMENT coloradj; // structure for halftoning
  116. WORD wReserved1; // old PPD checksum set to 0
  117. WORD wSize; // size of PRIVATEDEVMODE
  118. FIX_24_8 fxScrFreq; // halftone screen frequency
  119. FIX_24_8 fxScrAngle; // halftone screen angle
  120. DIALECT iDialect; // output dialect
  121. TTDLFMT iTTDLFmt; // download TT fonts as
  122. BOOL bReversePrint; // print in reverse order?
  123. LAYOUT iLayout; // nup value
  124. INT iPSLevel; // Language level (1, 2 or 3)
  125. DWORD dwReserved2; // reserved
  126. WORD wOEMExtra; // size of OEM private data
  127. WORD wVer; // DRIVEREXTRA version
  128. CUSTOMSIZEDATA csdata; // custom page size parameters
  129. DWORD dwReserved3[4]; // reserved for future use
  130. DWORD dwChecksum32; // checksum for option array
  131. DWORD dwOptions; // number of doc-sticky features
  132. OPTSELECT aOptions[MAX_PRINTER_OPTIONS]; // printer options
  133. } PSDRVEXTRA, *PPSDRVEXTRA;
  134. //
  135. // Constants for PSDRVEXTRA.dwSignature and PSDRVEXTRA.wVer
  136. //
  137. #define PSDEVMODE_SIGNATURE 0x56495250
  138. #define PSDRVEXTRA_VERSION 0x0010
  139. //
  140. // Declarations of earlier version DEVMODEs
  141. //
  142. #define PSDRIVER_VERSION_351 0x350 // 3.51 driver version number
  143. typedef struct _PSDRVEXTRA351 {
  144. DWORD dwSignature;
  145. DWORD dwFlags;
  146. WCHAR wchEPSFile[40];
  147. COLORADJUSTMENT coloradj;
  148. } PSDRVEXTRA351;
  149. #define PSDRIVER_VERSION_400 0x400 // 4.00 driver version number
  150. typedef struct _PSDRVEXTRA400 {
  151. DWORD dwSignature;
  152. DWORD dwFlags;
  153. WCHAR wchEPSFile[40];
  154. COLORADJUSTMENT coloradj;
  155. WORD wChecksum;
  156. WORD wOptions;
  157. BYTE aubOptions[64];
  158. } PSDRVEXTRA400;
  159. //
  160. // We have changed PSDRIVER_VERSION number from Win2K's 0x501 to XP's 0x502.
  161. // We must use Win2K's 0x501 here. (see PConvertToCurrentVersionDevmodeWithOemPlugins)
  162. //
  163. #define PSDRIVER_VERSION_500 0x501 // 5.00 driver version number
  164. typedef struct _PSDRVEXTRA500 {
  165. DWORD dwSignature; // private devmode signature
  166. DWORD dwFlags; // flag bits
  167. WCHAR wchEPSFile[40]; // EPS file name
  168. COLORADJUSTMENT coloradj; // structure for halftoning
  169. WORD wReserved1; // old PPD checksum set to 0
  170. WORD wSize; // size of PRIVATEDEVMODE
  171. FIX_24_8 fxScrFreq; // halftone screen frequency
  172. FIX_24_8 fxScrAngle; // halftone screen angle
  173. DIALECT iDialect; // output dialect
  174. TTDLFMT iTTDLFmt; // download TT fonts as
  175. BOOL bReversePrint; // print in reverse order?
  176. LAYOUT iLayout; // nup value
  177. INT iPSLevel; // Language level (1, 2 or 3)
  178. DWORD dwReserved2; // reserved
  179. WORD wOEMExtra; // size of OEM private data
  180. WORD wVer; // DRIVEREXTRA version
  181. CUSTOMSIZEDATA csdata; // custom page size parameters
  182. DWORD dwReserved3[4]; // reserved for future use
  183. DWORD dwChecksum32; // checksum for option array
  184. DWORD dwOptions; // number of doc-sticky features
  185. OPTSELECT aOptions[MAX_PRINTER_OPTIONS]; // printer options
  186. } PSDRVEXTRA500;
  187. //
  188. // Unidrv driver devmode
  189. //
  190. //
  191. // Quality macro definitions to be saved in DEVMODE.dmDitherType
  192. //
  193. #define MAX_QUALITY_SETTINGS 3
  194. #define MIN_QUALITY_SETTINGS 1
  195. #define QUALITY_MACRO_START DMDITHER_USER // 256
  196. #define QUALITY_MACRO_BEST QUALITY_MACRO_START + QS_BEST
  197. #define QUALITY_MACRO_BETTER QUALITY_MACRO_START + QS_BETTER
  198. #define QUALITY_MACRO_DRAFT QUALITY_MACRO_START + QS_DRAFT
  199. #define QUALITY_MACRO_END QUALITY_MACRO_START + MAX_QUALITY_SETTINGS
  200. #define QUALITY_MACRO_CUSTOM 0xFFFFFFFF
  201. //
  202. // Used for bits in the dwFlags field below.
  203. //
  204. #define DXF_TEXTASGRAPHICS 0x0002 // Set to disable font cacheing in printer
  205. #define DXF_JOBSEP 0x0004 // Enable Job Separator operation on printer
  206. #define DXF_PAGEPROT 0x0008 // Page memory protected: PCL 5
  207. #define DXF_NOEMFSPOOL 0x0010 // Set to disable EMF spooling; default off
  208. #define DXF_VECTOR 0x0020 // Set to indicate user selected vector mode
  209. #define DXF_DOWNLOADTT 0x0040 // Set to indicate printer supports tt downloading
  210. #define DXF_CUSTOM_QUALITY 0x0080 // Set to indicate Custom quality is selected
  211. typedef struct _UNIDRVEXTRA {
  212. DWORD dwSignature;
  213. WORD wVer;
  214. WORD sPadding;
  215. WORD wSize; // was dmDefaultDest
  216. WORD wOEMExtra; // was dmTextQuality
  217. DWORD dwChecksum32;
  218. DWORD dwFlags;
  219. BOOL bReversePrint; // print in reverse order?
  220. LAYOUT iLayout; // nup value
  221. QUALITYSETTING iQuality; // quality settings
  222. WORD wReserved[6];
  223. DWORD dwOptions; // number of doc-sticky features
  224. OPTSELECT aOptions[MAX_PRINTER_OPTIONS];
  225. DWORD dwEndingPad; // padding DWORD to make size of public devmode
  226. // plus Unidrv private devmode multiple of 8-bytes.
  227. } UNIDRVEXTRA, *PUNIDRVEXTRA;
  228. //
  229. // Constants for UNIDRVEXTRA.dwSignature and UNIDRVEXTRA.wVersion
  230. //
  231. #define UNIDEVMODE_SIGNATURE 'UNID'
  232. #define UNIDRVEXTRA_VERSION 0x0022
  233. #define MAXHE 30
  234. #define MAXCART 4
  235. #define UNIDRIVER_VERSION_351 0x301
  236. #define UNIDRIVER_VERSION_400 0x301
  237. #define UNIDRIVER_VERSION_500 0x500
  238. typedef struct _UNIDRVEXTRA351 {
  239. SHORT sVer; // Version for validity testing
  240. SHORT sDefaultDest;
  241. SHORT sTextQuality;
  242. WORD wMiniVer; // Minidriver Version
  243. SHORT sBrush; // type of dithering brush
  244. SHORT sCTT; // CTT value for txtonly
  245. SHORT sNumCarts; // # of cartridges selected.
  246. SHORT aFontCarts[MAXCART];
  247. SHORT sMemory; // current printer memory configuration.
  248. SHORT aIndex[MAXHE];
  249. // Following are NT additions
  250. SHORT sFlags; // Miscellaneous flags; defined below
  251. SHORT sPadding;
  252. COLORADJUSTMENT ca; // Halftoning information. (see wingdi.h)
  253. } UNIDRVEXTRA351, UNIDRVEXTRA400;
  254. typedef struct _UNIDRVEXTRA500 {
  255. DWORD dwSignature;
  256. WORD wVer;
  257. WORD sPadding;
  258. WORD wSize; // was dmDefaultDest
  259. WORD wOEMExtra; // was dmTextQuality
  260. DWORD dwChecksum32;
  261. DWORD dwFlags;
  262. BOOL bReversePrint; // print in reverse order?
  263. LAYOUT iLayout; // nup value
  264. QUALITYSETTING iQuality; // quality settings
  265. WORD wReserved[6];
  266. DWORD dwOptions; // number of doc-sticky features
  267. OPTSELECT aOptions[MAX_PRINTER_OPTIONS];
  268. //
  269. // See PConvertToCurrentVersionDevmodeWithOemPlugins() for the reason
  270. // why dwEndingPad field is not here.
  271. //
  272. } UNIDRVEXTRA500;
  273. //
  274. // Default halftone parameters
  275. //
  276. extern DEVHTINFO gDefaultDevHTInfo;
  277. extern COLORADJUSTMENT gDefaultHTColorAdjustment;
  278. //
  279. // Validate the form-related fields in the input devmode and
  280. // make sure they're consistent with each other.
  281. //
  282. BOOL
  283. BValidateDevmodeFormFields(
  284. HANDLE hPrinter,
  285. PDEVMODE pDevmode,
  286. PRECTL prcImageArea,
  287. FORM_INFO_1 *pForms,
  288. DWORD dwForms
  289. );
  290. //
  291. // Initialized the form-related devmode fields with their default values
  292. //
  293. #define LETTER_FORMNAME TEXT("Letter")
  294. #define A4_FORMNAME TEXT("A4")
  295. VOID
  296. VDefaultDevmodeFormFields(
  297. PUIINFO pUIInfo,
  298. PDEVMODE pDevmode,
  299. BOOL bMetric
  300. );
  301. //
  302. // Unit for DEVMODE.dmPaperWidth and DEVMODE.dmPaperLength fields
  303. // 0.1mm = 100 microns
  304. //
  305. #define DEVMODE_PAPER_UNIT 100
  306. //
  307. // Allocate memory and initialize it with default devmode information
  308. // This include public devmode, driver private devmode, as well as
  309. // private devmode for any OEM plugins.
  310. //
  311. // NOTE: type POEM_PLUGINS is defined in oemutil.h. To avoid unnecessarily
  312. // include that header file everywhere (which includes winddiui.h, compstui.h, ...)
  313. // we declare the type here as well.
  314. typedef struct _OEM_PLUGINS *POEM_PLUGINS;
  315. PDEVMODE
  316. PGetDefaultDevmodeWithOemPlugins(
  317. IN LPCTSTR ptstrPrinterName,
  318. IN PUIINFO pUIInfo,
  319. IN PRAWBINARYDATA pRawData,
  320. IN BOOL bMetric,
  321. IN OUT POEM_PLUGINS pOemPlugins,
  322. IN HANDLE hPrinter
  323. );
  324. //
  325. // Valicate input devmode and merge it into the output devmode.
  326. // This include public devmode, driver private devmode, as well as
  327. // private devmode for any OEM plugins.
  328. //
  329. // The output devmode must be valid when this function is called.
  330. //
  331. BOOL
  332. BValidateAndMergeDevmodeWithOemPlugins(
  333. IN OUT PDEVMODE pdmOutput,
  334. IN PUIINFO pUIInfo,
  335. IN PRAWBINARYDATA pRawData,
  336. IN PDEVMODE pdmInput,
  337. IN OUT POEM_PLUGINS pOemPlugins,
  338. IN HANDLE hPrinter
  339. );
  340. //
  341. // These functions are implemented in driver-specific libraries
  342. // lib\ps and lib\uni.
  343. //
  344. BOOL
  345. BInitDriverDefaultDevmode(
  346. OUT PDEVMODE pdmOut,
  347. IN LPCTSTR ptstrPrinterName,
  348. IN PUIINFO pUIInfo,
  349. IN PRAWBINARYDATA pRawData,
  350. IN BOOL bMetric
  351. );
  352. BOOL
  353. BMergeDriverDevmode(
  354. IN OUT PDEVMODE pdmOut,
  355. IN PUIINFO pUIInfo,
  356. IN PRAWBINARYDATA pRawData,
  357. IN PDEVMODE pdmIn
  358. );
  359. //
  360. // Information about driver private devmode
  361. //
  362. typedef struct _DRIVER_DEVMODE_INFO {
  363. WORD dmDriverVersion; // current driver version
  364. WORD dmDriverExtra; // size of current version private devmode
  365. WORD dmDriverVersion500; // 5.0 driver version
  366. WORD dmDriverExtra500; // size of 5.0 private devmode
  367. WORD dmDriverVersion400; // 4.0 driver version
  368. WORD dmDriverExtra400; // size of 4.0 private devmode
  369. WORD dmDriverVersion351; // 3.51 driver version
  370. WORD dmDriverExtra351; // size of 3.51 private devmode
  371. } DRIVER_DEVMODE_INFO;
  372. extern CONST DRIVER_DEVMODE_INFO gDriverDMInfo;
  373. extern CONST DWORD gdwDriverDMSignature;
  374. //
  375. // Given a pointer to a public devmode, return
  376. // a pointer to the driver private portion.
  377. //
  378. #define GET_DRIVER_PRIVATE_DEVMODE(pdm) ((PBYTE) (pdm) + (pdm)->dmSize)
  379. #endif // !_DEVMODE_H_