PrinterStream.st
changeset 348 e4790af5d077
parent 341 1e28fd1604ba
child 349 e2806ca1c634
equal deleted inserted replaced
347:6f50e1be3ba4 348:e4790af5d077
    34 !
    34 !
    35 
    35 
    36 documentation
    36 documentation
    37 "
    37 "
    38     a stream for printing; this (concrete or abstract) class can handle only
    38     a stream for printing; this (concrete or abstract) class can handle only
    39     very dumb printers. No attributes (italic, bold etc) and no multiple fonts
    39     very dumb printers. 
    40     are supported - just plain single font text printing.
    40     No attributes (italic, bold etc) and no multiple fonts are supported 
       
    41     - just plain single font text printing.
    41 
    42 
    42     More intelligence is added by subclasses (see PostscriptPrinterStream among others.)
    43     More intelligence is added by subclasses (see PostscriptPrinterStream among others.)
    43 
    44 
    44     These classes do not support graphics printing - they are only for
    45     These classes do not support graphics printing - they are only for
    45     text; although some limited font functionality (such as bold or italic printing)
    46     text; although some limited font functionality (such as bold or italic printing)
    46     may be supported by some subclasses.
    47     may be supported by some subclasses.
       
    48 
       
    49 
       
    50     [usage:]
    47 
    51 
    48     The concrete printer class is bound to the global variable Printer,
    52     The concrete printer class is bound to the global variable Printer,
    49     which is either set to PrinterStream (for dumb printers) or to one of
    53     which is either set to PrinterStream (for dumb printers) or to one of
    50     the subclasses (PostscriptPrinterStream etc.).
    54     the subclasses (PostscriptPrinterStream etc.).
    51 
    55 
    60             p close
    64             p close
    61         ].
    65         ].
    62 
    66 
    63     See users of the Printer global variable for more examples.
    67     See users of the Printer global variable for more examples.
    64 
    68 
       
    69     [class variables:]
       
    70         PrintCommand    <String>        the operatingSystem command for printing.
       
    71                                         Usually something like 'lp' or 'lpr'
       
    72 
       
    73         LeftMargin      <Integer>       optional default left margin.
       
    74                                         Defaults to 0.
       
    75 
       
    76 
    65     [author:]
    77     [author:]
    66         Claus Gittinger
    78         Claus Gittinger
    67 "
    79 "
    68 ! !
    80 ! !
    69 
    81 
   129 
   141 
   130     LeftMargin := aNumber
   142     LeftMargin := aNumber
   131 !
   143 !
   132 
   144 
   133 printCommand
   145 printCommand
   134     "return command used for printing (usually lp or lpr)"
   146     "return the command used for printing (usually 'lp' or 'lpr')"
   135 
   147 
   136     ^ PrintCommand
   148     ^ PrintCommand
       
   149 
       
   150     "Modified: 18.5.1996 / 09:12:35 / cg"
   137 !
   151 !
   138 
   152 
   139 printCommand:aString
   153 printCommand:aString
   140     "set the command for printing (usually lp or lpr)"
   154     "set the command for printing (usually 'lp' or 'lpr')"
   141 
   155 
   142     PrintCommand := aString
   156     PrintCommand := aString
   143 
   157 
   144     "
   158     "
   145      PrinterStream printCommand:'lpr'
   159      PrinterStream printCommand:'lpr'
   146      PrinterStream printCommand:'lpr -h'
   160      PrinterStream printCommand:'lpr -h'
   147      PrinterStream printCommand:'rsh ibm lpr -h'
   161      PrinterStream printCommand:'rsh ibm lpr -h'
   148      PrinterStream printCommand:'gs -sDEVICE=djet500 -sOutputFile=/tmp/stx.ps -sPAPERSIZE=a4 -q -; cat /tmp/stx.ps | rsh ibm lpr -h'
   162      PrinterStream printCommand:'gs -sDEVICE=djet500 -sOutputFile=/tmp/stx.ps -sPAPERSIZE=a4 -q -; cat /tmp/stx.ps | rsh ibm lpr -h'
   149     "
   163     "
       
   164 
       
   165     "Modified: 18.5.1996 / 09:12:48 / cg"
   150 ! !
   166 ! !
   151 
   167 
   152 !PrinterStream class methodsFor:'queries'!
   168 !PrinterStream class methodsFor:'queries'!
   153 
   169 
   154 printerTypeName
   170 printerTypeName
   163     "return true if this is a postscript printer"
   179     "return true if this is a postscript printer"
   164 
   180 
   165     ^ false
   181     ^ false
   166 
   182 
   167     "Created: 10.2.1996 / 16:23:07 / cg"
   183     "Created: 10.2.1996 / 16:23:07 / cg"
   168 ! !
       
   169 
       
   170 !PrinterStream methodsFor:'access font change'!
       
   171 
       
   172 bold
       
   173     "set font to bold
       
   174      - ignore here, since this class does not know anything about the printer"
       
   175 
       
   176     ^ self
       
   177 !
       
   178 
       
   179 boldItalic
       
   180     "set font to boldItalic
       
   181      - ignore here, since this class does not know anything about the printer"
       
   182 
       
   183     ^ self
       
   184 
       
   185     "Created: 14.5.1996 / 18:53:43 / cg"
       
   186 !
       
   187 
       
   188 courier
       
   189     "set font to courier 
       
   190      - ignore here, since this class does not know anything about the printer"
       
   191 
       
   192     ^ self
       
   193 !
       
   194 
       
   195 emphasis:anEmphasis
       
   196     "change the emphasis"
       
   197 
       
   198     anEmphasis isNil ifTrue:[
       
   199         ^ self normal
       
   200     ].
       
   201     anEmphasis == #bold ifTrue:[
       
   202         ^ self bold
       
   203     ].
       
   204     anEmphasis == #italic ifTrue:[
       
   205         ^ self italic
       
   206     ].
       
   207     anEmphasis == #underline ifTrue:[
       
   208         ^ self underline
       
   209     ].
       
   210     anEmphasis == #strikeout ifTrue:[
       
   211         ^ self strikeout
       
   212     ].
       
   213 
       
   214     "Created: 14.5.1996 / 18:53:54 / cg"
       
   215 !
       
   216 
       
   217 helvetica
       
   218     "set font to helvetic
       
   219      - ignore here, since this class does not know anything about the printer"
       
   220 
       
   221     ^ self
       
   222 !
       
   223 
       
   224 italic
       
   225     "set font to italic
       
   226      - ignore here, since this class does not know anything about the printer"
       
   227 
       
   228     ^ self
       
   229 !
       
   230 
       
   231 normal
       
   232     "set font to normal (non-bold, non-italic)
       
   233      - ignore here, since this class does not know anything about the printer"
       
   234 
       
   235     ^ self
       
   236 !
       
   237 
       
   238 times
       
   239     "set font to times 
       
   240      - ignore here, since this class does not know anything about the printer"
       
   241 
       
   242     ^ self
       
   243 ! !
   184 ! !
   244 
   185 
   245 !PrinterStream methodsFor:'access writing'!
   186 !PrinterStream methodsFor:'access writing'!
   246 
   187 
   247 cr
   188 cr
   273 	super nextPut:aCharacter
   214 	super nextPut:aCharacter
   274     ]
   215     ]
   275 !
   216 !
   276 
   217 
   277 nextPutAll:aCollection
   218 nextPutAll:aCollection
   278     "send some characters to the printer - translate as needed"
   219     "send some characters to the printer - translate as needed.
   279 
   220      The argument, aCollection can be a Text (i.e. include emphasis)"
   280     aCollection do:[:aChar |
   221 
   281 	self nextPut:aChar
   222     aCollection hasChangeOfEmphasis ifTrue:[
       
   223         aCollection keysAndValuesDo:[:idx :aChar |
       
   224             self emphasis:(aCollection emphasisAt:idx).
       
   225             self nextPut:aChar.
       
   226         ]
       
   227     ] ifFalse:[
       
   228         aCollection do:[:aChar |
       
   229             self nextPut:aChar
       
   230         ]
   282     ]
   231     ]
       
   232 
       
   233     "Modified: 18.5.1996 / 09:01:00 / cg"
   283 !
   234 !
   284 
   235 
   285 nextPutAllUntranslated:aCollection
   236 nextPutAllUntranslated:aCollection
   286     "send some raw characters to the printer - even if not in native mode"
   237     "send some raw characters to the printer - even if not in native mode"
   287 
   238 
   294     "send a raw character to the printer - even if not in native mode"
   245     "send a raw character to the printer - even if not in native mode"
   295 
   246 
   296     super nextPut:aCharacter
   247     super nextPut:aCharacter
   297 
   248 
   298     "Modified: 10.4.1996 / 13:08:28 / cg"
   249     "Modified: 10.4.1996 / 13:08:28 / cg"
       
   250 ! !
       
   251 
       
   252 !PrinterStream methodsFor:'emphasis change'!
       
   253 
       
   254 bold
       
   255     "set emphasis to bold
       
   256      - ignore here, since this class does not know anything about the printer"
       
   257 
       
   258     ^ self
       
   259 
       
   260     "Modified: 18.5.1996 / 08:55:10 / cg"
       
   261 !
       
   262 
       
   263 boldItalic
       
   264     "set emphasis to boldItalic
       
   265      - ignore here, since this class does not know anything about the printer"
       
   266 
       
   267     ^ self
       
   268 
       
   269     "Created: 14.5.1996 / 18:53:43 / cg"
       
   270     "Modified: 18.5.1996 / 08:55:14 / cg"
       
   271 !
       
   272 
       
   273 emphasis:anEmphasis
       
   274     "change the emphasis"
       
   275 
       
   276     anEmphasis isNil ifTrue:[
       
   277         ^ self normal
       
   278     ].
       
   279     anEmphasis == #bold ifTrue:[
       
   280         ^ self bold
       
   281     ].
       
   282     anEmphasis == #italic ifTrue:[
       
   283         ^ self italic
       
   284     ].
       
   285     anEmphasis == #underline ifTrue:[
       
   286         ^ self underline
       
   287     ].
       
   288     anEmphasis == #strikeout ifTrue:[
       
   289         ^ self strikeout
       
   290     ].
       
   291 
       
   292     "Created: 14.5.1996 / 18:53:54 / cg"
       
   293 !
       
   294 
       
   295 italic
       
   296     "set emphasis to italic
       
   297      - ignore here, since this class does not know anything about the printer"
       
   298 
       
   299     ^ self
       
   300 
       
   301     "Modified: 18.5.1996 / 08:55:18 / cg"
       
   302 !
       
   303 
       
   304 normal
       
   305     "set emphasis to normal (non-bold, non-italic)
       
   306      - ignore here, since this class does not know anything about the printer"
       
   307 
       
   308     ^ self
       
   309 
       
   310     "Modified: 18.5.1996 / 08:55:21 / cg"
       
   311 !
       
   312 
       
   313 strikeout
       
   314     "set emphasis to strikeout
       
   315      - ignore here, since this class does not know anything about the printer"
       
   316 
       
   317     ^ self
       
   318 
       
   319     "Modified: 18.5.1996 / 08:55:10 / cg"
       
   320     "Created: 18.5.1996 / 08:56:13 / cg"
       
   321 !
       
   322 
       
   323 underline
       
   324     "set emphasis to underline
       
   325      - ignore here, since this class does not know anything about the printer"
       
   326 
       
   327     ^ self
       
   328 
       
   329     "Modified: 18.5.1996 / 08:55:10 / cg"
       
   330     "Created: 18.5.1996 / 08:56:24 / cg"
       
   331 ! !
       
   332 
       
   333 !PrinterStream methodsFor:'font change'!
       
   334 
       
   335 courier
       
   336     "set font to courier 
       
   337      - ignore here, since this class does not know anything about the printer"
       
   338 
       
   339     ^ self
       
   340 !
       
   341 
       
   342 helvetica
       
   343     "set font to helvetic
       
   344      - ignore here, since this class does not know anything about the printer"
       
   345 
       
   346     ^ self
       
   347 !
       
   348 
       
   349 times
       
   350     "set font to times 
       
   351      - ignore here, since this class does not know anything about the printer"
       
   352 
       
   353     ^ self
   299 ! !
   354 ! !
   300 
   355 
   301 !PrinterStream methodsFor:'helpers writing'!
   356 !PrinterStream methodsFor:'helpers writing'!
   302 
   357 
   303 escape:aCharacter
   358 escape:aCharacter
   347 ! !
   402 ! !
   348 
   403 
   349 !PrinterStream class methodsFor:'documentation'!
   404 !PrinterStream class methodsFor:'documentation'!
   350 
   405 
   351 version
   406 version
   352     ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.22 1996-05-14 16:54:02 cg Exp $'
   407     ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.23 1996-05-18 07:14:51 cg Exp $'
   353 ! !
   408 ! !
   354 PrinterStream initialize!
   409 PrinterStream initialize!