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