# HG changeset patch # User Claus Gittinger # Date 833571607 -7200 # Node ID 647af479888f57d1d61adb50166722d4bb9ae3ea # Parent 087a147a5e01315940bd423a52bbd40d8956b86d added stuff for pageFormat diff -r 087a147a5e01 -r 647af479888f PrinterStream.st --- a/PrinterStream.st Fri May 31 19:47:30 1996 +0200 +++ b/PrinterStream.st Fri May 31 21:40:07 1996 +0200 @@ -11,8 +11,9 @@ " PipeStream subclass:#PrinterStream - instanceVariableNames:'native' - classVariableNames:'PrintCommand LeftMargin DefaultCommands' + instanceVariableNames:'native pageFormat' + classVariableNames:'PrintCommand LeftMargin DefaultCommands PageFormat + DefaultPageFormats Landscape' poolDictionaries:'' category:'Streams-External' ! @@ -85,15 +86,41 @@ "this is usually redefined by the startup-file" PrintCommand isNil ifTrue:[ - OperatingSystem isBSDlike ifTrue:[ - PrintCommand := 'lpr' - ] ifFalse:[ - PrintCommand := 'lp' - ] + OperatingSystem isBSDlike ifTrue:[ + PrintCommand := 'lpr' + ] ifFalse:[ + PrintCommand := 'lp' + ] ]. LeftMargin isNil ifTrue:[ - LeftMargin := 0 + LeftMargin := 0 + ]. + + DefaultPageFormats isNil ifTrue:[ + "/ UnitConverter must support all of them. + self defaultPageFormats:#( + 'letter' + 'a4' + 'a5' + 'a6' + ). + ]. + + Landscape isNil ifTrue:[ + Landscape := false + ]. + + PageFormat isNil ifTrue:[ + Language == #us ifTrue:[ + PageFormat := #letter + ] ifFalse:[ + PageFormat := #a4 + ] ] + + " + PrinterStream initialize + " ! ! !PrinterStream class methodsFor:'instance creation'! @@ -101,7 +128,7 @@ new "return a new stream for printing" - ^ self basicNew startPrint + ^ self basicNew initialize startPrint ! newNative @@ -109,10 +136,10 @@ (i.e. text should be sent via nextPutUntranslated in the printers native format)" - ^ self basicNew setNative; writingTo:(self printCommand) + ^ self basicNew initialize setNative; writingTo:(self printCommand) ! ! -!PrinterStream class methodsFor:'accessing'! +!PrinterStream class methodsFor:'accessing - defaults'! defaultCommands "return a list presented as possible commands for printed @@ -127,7 +154,7 @@ defaultCommands:collectionOfCommandStrings "set the list which will be presented as possible commands for printing. - (in the launchers printer configuration). + (shown in in the launchers printer configuration). This can be done from the startup script with: PrinterStream defaultCommands:#( ... )" @@ -136,14 +163,108 @@ "Created: 23.4.1996 / 18:26:06 / cg" ! +defaultPageFormats + "return a list of supported pae formats. + This list can be set from the startup script with: + PrinterStream defaultPageFormats:#..." + + ^ DefaultPageFormats + + "Created: 23.4.1996 / 18:25:18 / cg" +! + +defaultPageFormats:aList + "set the list of supported pae formats. + (shown in in the launchers printer configuration). + This list can be set from the startup script with: + PrinterStream defaultPageFormats:#..." + + DefaultPageFormats := aList. + + "/ validate the list + aList do:[:name | + |unit ok| + + ok := true. + #('W' 'H' 'lW' 'lH') do:[:what | + unit := (name , what) asSymbolIfInterned. + (unit isNil + or:[(UnitConverter convert:1 from:unit to:#millimeter) isNil]) ifTrue:[ + ok := false + ] + ]. + ok ifFalse:[ + ('PRINTER: UnitConverter has no size-info for ''' , name , '''-format') errorPrintCR + ] + ]. + + " + PrinterStream + defaultPageFormats:#( + 'letter' + 'a4' + 'a5' + 'a6' + ) + " + + "Created: 23.4.1996 / 18:25:18 / cg" +! + +landscape + "return the landscape setting" + + ^ Landscape +! + +landscape:aBoolean + "set/clear landscape printing" + + Landscape := aBoolean +! + +leftMargin + "return the number of blanks for the left margin" + + ^ LeftMargin +! + leftMargin:aNumber "set the number of blanks for the left margin" LeftMargin := aNumber ! +pageFormat + "return a symbol describing the default page format. + This list can be set from the startup script with: + PrinterStream defaultPageFormat:#... + or via the launchers settings menu." + + ^ PageFormat + + "Created: 23.4.1996 / 18:25:18 / cg" +! + +pageFormat:aSymbol + "set the 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. + + This list can be set from the startup script with: + PrinterStream defaultPageFormat:#... + or via the launchers settings menu." + + PageFormat := aSymbol + + "Created: 23.4.1996 / 18:25:18 / cg" +! + printCommand - "return the command used for printing (usually 'lp' or 'lpr')" + "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 @@ -151,7 +272,9 @@ ! printCommand:aString - "set the command for printing (usually 'lp' or 'lpr')" + "set the command for printing (usually 'lp' or 'lpr'). + This is either set from the startup file, or via the launchers + settings menu." PrintCommand := aString @@ -373,6 +496,14 @@ super nextPut:(Character escape); nextPutAll:aString ! ! +!PrinterStream methodsFor:'initialization'! + +initialize + pageFormat := DefaultPageFormat + + "Created: 31.5.1996 / 20:14:36 / cg" +! ! + !PrinterStream methodsFor:'open/close'! basicClose @@ -416,6 +547,6 @@ !PrinterStream class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.25 1996-05-30 15:49:49 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.26 1996-05-31 19:40:07 cg Exp $' ! ! PrinterStream initialize!