|
Class: PrinterStream
Object
|
+--Stream
|
+--PrinterStream
|
+--EpsonFX1PrinterStream
|
+--HPLjetIIPrinterStream
|
+--HTMLPrinterStream
|
+--PostscriptPrinterStream
- Package:
- stx:libbasic2
- Category:
- Interface-Printing
- Version:
- rev:
1.90
date: 2023/07/27 15:50:29
- user: cg
- file: PrinterStream.st directory: libbasic2
- module: stx stc-classLibrary: libbasic2
a stream for printing; this (concrete or abstract) class can handle only
very dumb printers.
No attributes (italic, bold etc) and no multiple fonts are supported
- just plain single font text printing.
More intelligence is added by subclasses (see PostscriptPrinterStream among others.)
These classes do not support graphics printing - they are only for text;
although some limited font functionality (such as bold or italic printing)
may be supported by some subclasses.
[usage:]
The concrete printer class is bound to the global variable Printer,
which is either set to PrinterStream (for dumb printers) or to one of
the subclasses (PostscriptPrinterStream etc.).
To print:
|p|
p := Printer new.
p notNil ifTrue:[
p nextPutAll:'hello world'; cr.
p nextPutAll:' ...'; cr.
p close
].
See users of the Printer global variable for more examples.
[class variables:]
PrintCommand <String> UNIX only: the operatingSystem command for printing.
Usually something like 'lp' or 'lpr'
PrintDevice <String> VMS only: the printers device.
Usually something like 'sys$print:'
copyrightCOPYRIGHT (c) 1990 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
accessing-defaults
-
bottomMargin
-
return the bottomMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes
-
defaultCommands
-
UNIX only:
return a list presented as possible commands for printing
(in the launchers printer configuration).
This list can be set from the startup script with:
PrinterStream defaultCommands:#( ... )
-
defaultCommands: collectionOfCommandStrings
-
UNIX only:
set the list which will be presented as possible commands for printing.
(shown in in the launchers printer configuration).
This can be done from the startup script with:
PrinterStream defaultCommands:#( ... )
-
defaultDevices
-
VMS only:
return a list presented as possible devices for printers.
(in the launchers printer configuration).
This list can be set from the startup script with:
PrinterStream defaultDevices:#( ... )
-
defaultDevices: collectionOfDeviceNameStrings
-
VMS only:
set the list which will be presented as possible devices for printing.
(shown in in the launchers printer configuration).
This can be done from the startup script with:
PrinterStream defaultDevices:#( ... )
-
defaultPageFormats
-
return a list of supported page formats.
This list can be set from the startup script with:
PrinterStream defaultPageFormats:#( ... )
-
defaultPageFormats: aList
-
set the list of supported page formats.
(shown in in the launchers printer configuration).
This list can be set from the startup script with:
PrinterStream defaultPageFormats:#( ... ).
All symbols must be known by UnitConverter
Usage example(s):
PrinterStream
defaultPageFormats:#(
'letter'
'a4'
'a5'
'a6'
)
|
-
defaultPrinter
-
self defaultPrinter
-
landscape
-
return the landscape setting
-
landscape: aBoolean
-
set/clear landscape printing
-
leftMargin
-
return the leftMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes
-
pageFormat
-
return a symbol describing the default page format.
This can be set from the startup script with:
PrinterStream pageFormat:#...
or via the launchers settings menu.
-
pageFormat: aSymbol
-
set the default page format to be aSymbol.
Valid symbols are #letter, #a4, #a5 etc.
The UnitConverter must contain width/height information on
that symbol, in order for printing to be correct.
-
printCommand
-
UNIX only:
return the command used for printing (usually 'lp' or 'lpr').
This is either set from the startup file, or via the launchers
settings menu.
-
printCommand: aString
-
UNIX only:
set the command for printing (usually 'lp' or 'lpr').
This is either set from the startup file, or via the launchers
settings menu.
Usage example(s):
PrinterStream printCommand:'lpr'
PrinterStream printCommand:'lpr -h'
PrinterStream printCommand:'rsh ibm lpr -h'
PrinterStream printCommand:'gs -sDEVICE=djet500 -sOutputFile=/tmp/stx.ps -sPAPERSIZE=a4 -q -; cat /tmp/stx.ps | rsh ibm lpr -h'
|
-
printDevice
-
VMS only: return the device for printing (usually 'sys$print:')
This is either set from the startup file, or via the launchers
settings menu.
-
printDevice: aString
-
VMS only:
set the device for printing (usually 'sys$print:').
This is either set from the startup file, or via the launchers
settings menu.
Usage example(s):
PrinterStream printDevice:'lta1739:'
|
-
printFilename
-
UNIX only:
return the file into which the print-document should be generated.
If nil (the default), printOut is piped through printCommand,
which is usually a variant of the lpr-command.
Usage example(s):
PrinterStream printFilename
Printer printFilename
|
-
printFilename: aString
-
UNIX only:
set the output file for printing. If non nil, printout goes into that file.
If nil, it is piped through printCommand.
This is either set from the startup file, or via the launcher's settings menu.
Usage example(s):
PrinterStream printFilename:'/tmp/out.ps'
|
-
rightMargin
-
return the rightMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes
-
topMargin
-
return the topMargin (in inches). Here, no margin is supported,
but its redefined in some printer classes
initialization
-
initialize
-
this is usually redefined by the startup-file
Usage example(s):
self initializePrintParameters -- now done lazily
|
-
initializePrintParameters
-
this is usually redefined by the startup-file
-
reInitPage
-
nothing done here
instance creation
-
new
-
return a new stream for printing.
If printFilename is nonNil, printOut goes into that file.
otherwise, it is piped through the printCommand OS-command.
-
newForFile: aFileNameOrNil
-
return a new stream for printing into aFileName
Usage example(s):
|p|
p := PostscriptPrinterStream newForFile:'/tmp/out.ps'.
True printOutOn:p.
p close.
|
-
newForFile: aFileNameOrNil native: nativePrinting
-
return a new stream for printing into aFileName
Usage example(s):
|p|
p := PostscriptPrinterStream newForFile:'/tmp/out.ps'.
True printOutOn:p.
p close.
|
-
newForStream: aStream
-
return a new stream for printing into aStream
Usage example(s):
|s p|
s := WriteStream on:String new.
p := HTMLPrinterStream newForStream:s.
True printOutOn:p.
p close.
s contents
|
-
newForStream: aStream native: nativePrinting
-
return a new stream for printing into aStream
Usage example(s):
|s p|
s := WriteStream on:String new.
p := PostscriptPrinterStream newForStream:s native:false.
True printOutOn:p.
p close.
s contents
|
Usage example(s):
|s p|
s := WriteStream on:String new.
p := HTMLPrinterStream newForStream:s native:false.
True printOutOn:p.
p close.
s contents
|
-
newNative
-
return a new stream for untranslated printing
(i.e. text should be sent via nextPutUntranslated in the printer's native format).
For example, this is used with PostScriptPrinterStream,
if the application generates postscript.
-
newWarnOnError
-
queries
-
isDrivenByCommand
-
return true if this printer is driven via an OS-command
(as opposed to writing a file or using a native printing API)
-
printerTypeName
-
return a descriptive name
-
supportsColor
-
return true if this is a color printer
-
supportsContext
-
return true if this printer supports a graphicContext (fonts, colors etc.)
-
supportsGrayscale
-
assume false by default
-
supportsGreyscale
-
marked as obsolete by exept MBP at 20-09-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
supportsMargins
-
return true if this printer supports margin settings (in inches)
if not, it supports at least a leftMargin to be specified in columns.
-
supportsPageSizes
-
return true if this printer supports different page sizes
-
supportsPostscript
-
return true if this is a postscript printer
-
supportsPrintingToCommand
-
-
supportsPrintingToFile
-
emphasis
-
bold
-
set emphasis to bold
- ignore here, since this class does not know anything about the printer
-
boldItalic
-
set emphasis to boldItalic
- ignore here, since this class does not know anything about the printer
-
emphasis: anEmphasis
-
change the emphasis
-
italic
-
set emphasis to italic
- ignore here, since this class does not know anything about the printer
-
normal
-
set emphasis to normal (non-bold, non-italic)
- ignore here, since this class does not know anything about the printer
-
strikeout
-
set emphasis to strikeout
- ignore here, since this class does not know anything about the printer
-
underline
-
set emphasis to underline
- ignore here, since this class does not know anything about the printer
emphasis change
-
noStrikeout
-
set emphasis to no strikeout
- ignore here, since this class does not know anything about the printer
-
noUnderline
-
set emphasis to no underline
- ignore here, since this class does not know anything about the printer
font change
-
courier
-
set font to courier
- ignore here, since this class does not know anything about the printer
-
helvetica
-
set font to helvetic
- ignore here, since this class does not know anything about the printer
-
times
-
set font to times
- ignore here, since this class does not know anything about the printer
helpers writing
-
escape: aCharacter
-
since its so common, this method sends escape followed by aCharacter
-
escapeAll: aString
-
since its so common, this method sends escape followed by aString
initialization
-
initialize
-
(comment from inherited method)
just to ignore initialize to objects which do not need it
-
printCommand
-
-
printJobName: aString
-
ignored here - some subclass might implement this
-
stream: aStream
-
open & close
-
basicClose
-
-
close
-
(comment from inherited method)
close the stream - nothing done here.
Added for compatibility with external streams.
-
endPrint
-
-
setNative
-
-
setNative: aBoolean
-
-
startPrint
-
queries
-
bottomMargin
-
-
landscape
-
-
leftMargin
-
-
lineLength
-
the printer pages width (in characters)
-
pageFormat
-
(comment from inherited method)
return the pageFormat - nil here.
This has NO meaning whatsoever to regular streams;
however, it has been added for protocol compatibility with printerStreams
-
printerContext
-
-
rightMargin
-
-
supportsColor
-
return true if this is a color printer
-
supportsContext
-
-
supportsGrayscale
-
ask my class (by default)
-
supportsGreyscale
-
marked as obsolete by exept MBP at 20-09-2021
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
supportsMargins
-
return true if this printer supports margin settings (in inches)
if not, it supports at least a leftMargin to be specified in columns.
-
supportsPostscript
-
return true if this is a postscript printer
-
supportsPrintingToCommand
-
-
supportsPrintingToFile
-
-
topMargin
-
testing
-
isPrinterStream
-
return true, if this is a printerStream.
Always true here.
writing
-
flush
-
(comment from inherited method)
write out all buffered data - ignored here, but added
to make internalStreams protocol compatible with externalStreams
-
next: count put: aCharacter
-
send some character multiple times to the printer - translate as needed.
Redefined to allow individual character translation in subclasses
-
nextPut: aCharacter
-
send a character to the printer.
Answer aCharacter
-
nextPutAll: aCollection
-
send some characters to the printer - translate as needed.
The argument, aCollection can be a Text (i.e. include emphasis)
-
nextPutAllText: aText
-
send some characters to the printer - translate as needed.
The argument is a String or Text (i.e. includes emphasis)
-
nextPutAllUntranslated: aCollection
-
send some raw characters to the printer - even if not in native mode
-
nextPutUntranslated: aCharacter
-
send a raw character to the printer - even if not in native mode
|