amigaprinter.pas 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998-2003 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit amigaprinter;
  13. INTERFACE
  14. uses exec, graphics,utility,intuition,prefs;
  15. Const
  16. { V34-V40 commands }
  17. PRD_RAWWRITE = CMD_NONSTD + 0;
  18. PRD_PRTCOMMAND = CMD_NONSTD + 1;
  19. PRD_DUMPRPORT = CMD_NONSTD + 2;
  20. PRD_QUERY = CMD_NONSTD + 3;
  21. { V44 commands }
  22. PRD_RESETPREFS = (CMD_NONSTD+4); { PRIVATE: do not use! }
  23. PRD_LOADPREFS = (CMD_NONSTD+5); { PRIVATE: do not use! }
  24. PRD_USEPREFS = (CMD_NONSTD+6); { PRIVATE: do not use! }
  25. PRD_SAVEPREFS = (CMD_NONSTD+7); { PRIVATE: do not use! }
  26. PRD_READPREFS = (CMD_NONSTD+8);
  27. PRD_WRITEPREFS = (CMD_NONSTD+9);
  28. PRD_EDITPREFS = (CMD_NONSTD+10);
  29. PRD_SETERRHOOK = (CMD_NONSTD+11);
  30. PRD_DUMPRPORTTAGS = (CMD_NONSTD+12);
  31. { printer command definitions }
  32. aRIS = 0; { ESCc reset ISO }
  33. aRIN = 1; { ESC#1 initialize +++ }
  34. aIND = 2; { ESCD lf ISO }
  35. aNEL = 3; { ESCE return,lf ISO }
  36. aRI = 4; { ESCM reverse lf ISO }
  37. aSGR0 = 5; { ESC[0m normal char set ISO }
  38. aSGR3 = 6; { ESC[3m italics on ISO }
  39. aSGR23 = 7; { ESC[23m italics off ISO }
  40. aSGR4 = 8; { ESC[4m underline on ISO }
  41. aSGR24 = 9; { ESC[24m underline off ISO }
  42. aSGR1 = 10; { ESC[1m boldface on ISO }
  43. aSGR22 = 11; { ESC[22m boldface off ISO }
  44. aSFC = 12; { SGR30-39 set foreground color ISO }
  45. aSBC = 13; { SGR40-49 set background color ISO }
  46. aSHORP0 = 14; { ESC[0w normal pitch DEC }
  47. aSHORP2 = 15; { ESC[2w elite on DEC }
  48. aSHORP1 = 16; { ESC[1w elite off DEC }
  49. aSHORP4 = 17; { ESC[4w condensed fine on DEC }
  50. aSHORP3 = 18; { ESC[3w condensed off DEC }
  51. aSHORP6 = 19; { ESC[6w enlarged on DEC }
  52. aSHORP5 = 20; { ESC[5w enlarged off DEC }
  53. aDEN6 = 21; { ESC[6"z shadow print on DEC (sort of) }
  54. aDEN5 = 22; { ESC[5"z shadow print off DEC }
  55. aDEN4 = 23; { ESC[4"z doublestrike on DEC }
  56. aDEN3 = 24; { ESC[3"z doublestrike off DEC }
  57. aDEN2 = 25; { ESC[2"z NLQ on DEC }
  58. aDEN1 = 26; { ESC[1"z NLQ off DEC }
  59. aSUS2 = 27; { ESC[2v superscript on +++ }
  60. aSUS1 = 28; { ESC[1v superscript off +++ }
  61. aSUS4 = 29; { ESC[4v subscript on +++ }
  62. aSUS3 = 30; { ESC[3v subscript off +++ }
  63. aSUS0 = 31; { ESC[0v normalize the line +++ }
  64. aPLU = 32; { ESCL partial line up ISO }
  65. aPLD = 33; { ESCK partial line down ISO }
  66. aFNT0 = 34; { ESC(B US char set or Typeface 0 (default) }
  67. aFNT1 = 35; { ESC(R French char set or Typeface 1 }
  68. aFNT2 = 36; { ESC(K German char set or Typeface 2 }
  69. aFNT3 = 37; { ESC(A UK char set or Typeface 3 }
  70. aFNT4 = 38; { ESC(E Danish I char set or Typeface 4 }
  71. aFNT5 = 39; { ESC(H Sweden char set or Typeface 5 }
  72. aFNT6 = 40; { ESC(Y Italian char set or Typeface 6 }
  73. aFNT7 = 41; { ESC(Z Spanish char set or Typeface 7 }
  74. aFNT8 = 42; { ESC(J Japanese char set or Typeface 8 }
  75. aFNT9 = 43; { ESC(6 Norweign char set or Typeface 9 }
  76. aFNT10 = 44; { ESC(C Danish II char set or Typeface 10 }
  77. {
  78. Suggested typefaces are:
  79. 0 - default typeface.
  80. 1 - Line Printer or equiv.
  81. 2 - Pica or equiv.
  82. 3 - Elite or equiv.
  83. 4 - Helvetica or equiv.
  84. 5 - Times Roman or equiv.
  85. 6 - Gothic or equiv.
  86. 7 - Script or equiv.
  87. 8 - Prestige or equiv.
  88. 9 - Caslon or equiv.
  89. 10 - Orator or equiv.
  90. }
  91. aPROP2 = 45; { ESC[2p proportional on +++ }
  92. aPROP1 = 46; { ESC[1p proportional off +++ }
  93. aPROP0 = 47; { ESC[0p proportional clear +++ }
  94. aTSS = 48; { ESC[n E set proportional offset ISO }
  95. aJFY5 = 49; { ESC[5 F auto left justify ISO }
  96. aJFY7 = 50; { ESC[7 F auto right justify ISO }
  97. aJFY6 = 51; { ESC[6 F auto full justify ISO }
  98. aJFY0 = 52; { ESC[0 F auto justify off ISO }
  99. aJFY3 = 53; { ESC[3 F letter space (justify) ISO (special) }
  100. aJFY1 = 54; { ESC[1 F word fill(auto center) ISO (special) }
  101. aVERP0 = 55; { ESC[0z 1/8" line spacing +++ }
  102. aVERP1 = 56; { ESC[1z 1/6" line spacing +++ }
  103. aSLPP = 57; { ESC[nt set form length n DEC }
  104. aPERF = 58; { ESC[nq perf skip n (n>0) +++ }
  105. aPERF0 = 59; { ESC[0q perf skip off +++ }
  106. aLMS = 60; { ESC#9 Left margin set +++ }
  107. aRMS = 61; { ESC#0 Right margin set +++ }
  108. aTMS = 62; { ESC#8 Top margin set +++ }
  109. aBMS = 63; { ESC#2 Bottom marg set +++ }
  110. aSTBM = 64; { ESC[Pn1;Pn2r T&B margins DEC }
  111. aSLRM = 65; { ESC[Pn1;Pn2s L&R margin DEC }
  112. aCAM = 66; { ESC#3 Clear margins +++ }
  113. aHTS = 67; { ESCH Set horiz tab ISO }
  114. aVTS = 68; { ESCJ Set vertical tabs ISO }
  115. aTBC0 = 69; { ESC[0g Clr horiz tab ISO }
  116. aTBC3 = 70; { ESC[3g Clear all h tab ISO }
  117. aTBC1 = 71; { ESC[1g Clr vertical tabs ISO }
  118. aTBC4 = 72; { ESC[4g Clr all v tabs ISO }
  119. aTBCALL = 73; { ESC#4 Clr all h & v tabs +++ }
  120. aTBSALL = 74; { ESC#5 Set default tabs +++ }
  121. aEXTEND = 75; { ESC[Pn"x extended commands +++ }
  122. aRAW = 76; { ESC[Pn"r Next 'Pn' chars are raw +++ }
  123. Type
  124. pIOPrtCmdReq = ^tIOPrtCmdReq;
  125. tIOPrtCmdReq = record
  126. io_Message : tMessage;
  127. io_Device : pDevice; { (DevicePtr) device node pointer }
  128. io_Unit : pUnit; { (UnitPtr) unit (driver private)}
  129. io_Command : Word; { device command }
  130. io_Flags : Byte;
  131. io_Error : Shortint; { error or warning num }
  132. io_PrtCommand : Word; { printer command }
  133. io_Parm0 : Byte; { first command parameter }
  134. io_Parm1 : Byte; { second command parameter }
  135. io_Parm2 : Byte; { third command parameter }
  136. io_Parm3 : Byte; { fourth command parameter }
  137. end;
  138. pIODRPReq = ^tIODRPReq;
  139. tIODRPReq = record
  140. io_Message : tMessage;
  141. io_Device : pDevice; { (DevicePtr) device node pointer }
  142. io_Unit : pUnit; { (UnitPtr) unit (driver private)}
  143. io_Command : Word; { device command }
  144. io_Flags : Byte;
  145. io_Error : Shortint; { error or warning num }
  146. io_RastPort : pRastPort; { (RastPortPtr) raster port }
  147. io_ColorMap : pColorMap; { (ColorMapPtr) color map }
  148. io_Modes : ULONG; { graphics viewport modes }
  149. io_SrcX : Word; { source x origin }
  150. io_SrcY : Word; { source y origin }
  151. io_SrcWidth : Word; { source x width }
  152. io_SrcHeight : Word; { source x height }
  153. io_DestCols : Longint; { destination x width }
  154. io_DestRows : Longint; { destination y height }
  155. io_Special : Word; { option flags }
  156. end;
  157. { For PRD_DUMPRPORTTAGS (V44) }
  158. PIODRPTagsReq = ^tIODRPTagsReq;
  159. tIODRPTagsReq = record
  160. io_Message : tMessage;
  161. io_Device : PDevice; { device node pointer }
  162. io_Unit : PUnit; { unit (driver private)}
  163. io_Command : UWORD; { device command }
  164. io_Flags : UBYTE;
  165. io_Error : BYTE; { error or warning num }
  166. io_RastPort : PRastPort; { raster port }
  167. io_ColorMap : PColorMap; { color map }
  168. io_Modes : ULONG; { graphics viewport modes }
  169. io_SrcX : UWORD; { source x origin }
  170. io_SrcY : UWORD; { source y origin }
  171. io_SrcWidth : UWORD; { source x width }
  172. io_SrcHeight : UWORD; { source x height }
  173. io_DestCols : LONG; { destination x width }
  174. io_DestRows : LONG; { destination y height }
  175. io_Special : UWORD; { option flags }
  176. io_TagList : PTagItem; { tag list with additional info }
  177. end;
  178. Const
  179. SPECIAL_MILCOLS = $0001; { DestCols specified in 1/1000" }
  180. SPECIAL_MILROWS = $0002; { DestRows specified in 1/1000" }
  181. SPECIAL_FULLCOLS = $0004; { make DestCols maximum possible }
  182. SPECIAL_FULLROWS = $0008; { make DestRows maximum possible }
  183. SPECIAL_FRACCOLS = $0010; { DestCols is fraction of FULLCOLS }
  184. SPECIAL_FRACROWS = $0020; { DestRows is fraction of FULLROWS }
  185. SPECIAL_CENTER = $0040; { center image on paper }
  186. SPECIAL_ASPECT = $0080; { ensure correct aspect ratio }
  187. SPECIAL_DENSITY1 = $0100; { lowest resolution (dpi) }
  188. SPECIAL_DENSITY2 = $0200; { next res }
  189. SPECIAL_DENSITY3 = $0300; { next res }
  190. SPECIAL_DENSITY4 = $0400; { next res }
  191. SPECIAL_DENSITY5 = $0500; { next res }
  192. SPECIAL_DENSITY6 = $0600; { next res }
  193. SPECIAL_DENSITY7 = $0700; { highest res }
  194. SPECIAL_NOFORMFEED = $0800; { don't eject paper on gfx prints }
  195. SPECIAL_TRUSTME = $1000; { don't reset on gfx prints }
  196. {
  197. Compute print size, set 'io_DestCols' and 'io_DestRows' in the calling
  198. program's 'IODRPReq' structure and exit, DON'T PRINT. This allows the
  199. calling program to see what the final print size would be in printer
  200. pixels. Note that it modifies the 'io_DestCols' and 'io_DestRows'
  201. fields of your 'IODRPReq' structure. Also, set the print density and
  202. update the 'MaxXDots', 'MaxYDots', 'XDotsInch', and 'YDotsInch' fields
  203. of the 'PrinterExtendedData' structure.
  204. }
  205. SPECIAL_NOPRINT = $2000; { see above }
  206. PDERR_NOERR = 0; { clean exit, no errors }
  207. PDERR_CANCEL = 1; { user cancelled print }
  208. PDERR_NOTGRAPHICS = 2; { printer cannot output graphics }
  209. PDERR_INVERTHAM = 3; { OBSOLETE }
  210. PDERR_BADDIMENSION = 4; { print dimensions illegal }
  211. PDERR_DIMENSIONOVFLOW = 5; { OBSOLETE }
  212. PDERR_INTERNALMEMORY = 6; { no memory for internal variables }
  213. PDERR_BUFFERMEMORY = 7; { no memory for print buffer }
  214. {
  215. Note : this is an internal error that can be returned from the render
  216. function to the printer device. It is NEVER returned to the user.
  217. If the printer device sees this error it converts it 'PDERR_NOERR'
  218. and exits gracefully. Refer to the document on
  219. 'How to Write a Graphics Printer Driver' for more info.
  220. }
  221. PDERR_TOOKCONTROL = 8; { Took control in case 0 of render }
  222. PDERR_BADPREFERENCES = 9; { preferences file corrupt }
  223. {
  224. Note: all error codes < 32 are reserved for printer.device.
  225. All error codes >= 32 and < 127 are reserved for driver specific
  226. errors. Negative errors are reserved for system use (standard I/O
  227. errors) and error code 127 is reserved for future expansion.
  228. }
  229. PDERR_LASTSTANDARD = 31;
  230. PDERR_FIRSTCUSTOM = 32;
  231. PDERR_LASTCUSTOM = 126;
  232. { internal use }
  233. SPECIAL_DENSITYMASK = $0700; { masks out density values }
  234. SPECIAL_DIMENSIONSMASK = SPECIAL_MILCOLS + SPECIAL_MILROWS +
  235. SPECIAL_FULLCOLS + SPECIAL_FULLROWS + SPECIAL_FRACCOLS +
  236. SPECIAL_FRACROWS + SPECIAL_ASPECT;
  237. {**************************************************************************}
  238. { The following tags are used for PRD_DUMPRPORTTAGS }
  239. DRPA_Dummy = (TAG_USER + $60000);
  240. {**************************************************************************}
  241. { The following tags are not implemented but reserved for future use. }
  242. DRPA_ICCProfile = (DRPA_Dummy+1); { APTR }
  243. DRPA_ICCName = (DRPA_Dummy+2); { STRPTR }
  244. DRPA_NoColCorrect = (DRPA_Dummy+3); { LBOOL }
  245. {**************************************************************************}
  246. { If the following tag is used io_RastPort and io_ColorMap are
  247. ignored.
  248. }
  249. DRPA_SourceHook = (DRPA_Dummy+4); { struct Hook * }
  250. { The source hook (DRPA_SourceHook) is called with object NULL and
  251. message is a pointer to the following struct.
  252. VOID hook(struct Hook * hook,
  253. APTR dummy,
  254. struct DRPSourceMsg * drpm);
  255. }
  256. type
  257. PDRPSourceMsg = ^tDRPSourceMsg;
  258. tDRPSourceMsg = record
  259. x : LONG;
  260. y : LONG;
  261. width : LONG;
  262. height : LONG;
  263. buf : PULONG; { fill this buffer with 0x00RRGGBB pixels }
  264. end;
  265. const
  266. {**************************************************************************}
  267. { If these tags are used io_Modes is ignored for aspect ratio }
  268. DRPA_AspectX = (DRPA_Dummy+5); { ULONG }
  269. DRPA_AspectY = (DRPA_Dummy+6); { ULONG }
  270. {**************************************************************************}
  271. { The following tags are used for PRD_EDITPREFS }
  272. PPRA_Dummy = (TAG_USER + $70000);
  273. {**************************************************************************}
  274. { Request to edit prefs (for PRD_EDITPREFS; V44) }
  275. type
  276. PIOPrtPrefsReq = ^tIOPrtPrefsReq;
  277. tIOPrtPrefsReq = record
  278. io_Message : tMessage;
  279. io_Device : PDevice; { device node pointer }
  280. io_Unit : PUnit; { unit (driver private)}
  281. io_Command : UWORD; { device command }
  282. io_Flags : UBYTE;
  283. io_Error : BYTE; { error or warning num }
  284. io_TagList : PTagItem; { requester tag list }
  285. end;
  286. const
  287. PPRA_Window = (PPRA_Dummy+1); { struct Window * }
  288. PPRA_Screen = (PPRA_Dummy+2); { struct Screen * }
  289. PPRA_PubScreen = (PPRA_Dummy+3); { STRPTR }
  290. {**************************************************************************}
  291. { Request to set error hook (for PRD_SETERRHOOK; V44)}
  292. {
  293. #define PDHOOK_NONE ((struct Hook *) NULL)
  294. #define PDHOOK_STD ((struct Hook *) 1)
  295. }
  296. type
  297. PIOPrtErrReq = ^tIOPrtErrReq;
  298. tIOPrtErrReq = record
  299. io_Message : tMessage;
  300. io_Device : PDevice; { device node pointer }
  301. io_Unit : PUnit; { unit (driver private)}
  302. io_Command : UWORD; { device command }
  303. io_Flags : UBYTE;
  304. io_Error : BYTE; { error or warning num }
  305. io_Hook : PHook;
  306. end;
  307. {**************************************************************************}
  308. {
  309. The error hook is called with the IORequest that caused the error as
  310. object (2nd Parameter) and a pointer to struct PrtErrMsg as message
  311. (3rd Parameter):
  312. VOID hook(struct Hook * hook,
  313. struct printerIO * ior,
  314. struct PrtErrMsg * pem);
  315. }
  316. PPrtErrMsg = ^tPrtErrMsg;
  317. tPrtErrMsg = record
  318. pe_Version : ULONG;
  319. pe_ErrorLevel : ULONG;
  320. pe_Window : PWindow;
  321. pe_ES : PEasyStruct;
  322. pe_IDCMP : PULONG;
  323. pe_ArgList : APTR;
  324. end;
  325. const
  326. PDHOOK_VERSION = 1;
  327. type
  328. PIOPrefsReq = ^IOPrefsReq;
  329. IOPrefsReq = record
  330. io_Message : tMessage;
  331. io_Device : PDevice; { device node pointer }
  332. io_Unit : PUnit; { unit (driver private)}
  333. io_Command : UWORD; { device command }
  334. io_Flags : UBYTE;
  335. io_Error : BYTE; { error or warning num }
  336. io_TxtPrefs : PPrinterTxtPrefs;
  337. io_UnitPrefs : PPrinterUnitPrefs;
  338. io_DevUnitPrefs : PPrinterDeviceUnitPrefs;
  339. io_GfxPrefs : PPrinterGfxPrefs;
  340. end;
  341. IMPLEMENTATION
  342. end.