"{ Package: 'stx:libview2' }"
PrinterStream subclass:#WinPrinterStream
instanceVariableNames:'printerContext printJobName printFileName currentLineBuffer
currentPageBuffer'
classVariableNames:'PrinterInfo'
poolDictionaries:''
category:'Interface-Printing'
!
!WinPrinterStream class methodsFor:'instance creation'!
new
| printerInfo printerContext |
PrinterInfo := PrintingDialog getPrinterInfo.
PrinterInfo isNil ifTrue:[^self].
printerContext := PrinterContext fromPrinterInfo: PrinterInfo.
^ self basicNew printerContext:printerContext.
"Modified: / 10-10-2006 / 18:47:18 / cg"
!
newForFile:aFileNameOrNil
"return a new stream for printing into aFileName"
|printer|
printer := self basicNew initialize.
printer setPrintFileName:aFileNameOrNil.
printer startPrint.
^ printer
"Modified: / 10-10-2006 / 19:08:52 / cg"
!
newNative
self halt
"Created: / 10-10-2006 / 18:41:39 / cg"
! !
!WinPrinterStream class methodsFor:'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)"
^ false
"Created: / 10-10-2006 / 18:22:13 / cg"
!
printerTypeName
"return a descriptive name"
^ 'windows printer'
"Created: / 10-10-2006 / 18:26:22 / cg"
!
supportsPrintingToFile
^ false
"Created: / 10-10-2006 / 18:27:16 / cg"
! !
!WinPrinterStream methodsFor:'accessing'!
printerContext:something
printerContext := something.
! !
!WinPrinterStream methodsFor:'open/close'!
endPrint
printerContext endPrintJob.
"Created: / 10-10-2006 / 18:50:05 / cg"
!
startPrint
printerContext isNil ifTrue:[
PrinterInfo isNil ifTrue:[
PrinterInfo := PrintingDialog getPrinterInfo.
PrinterInfo isNil ifTrue:[^self].
].
printerContext := PrinterContext fromPrinterInfo: PrinterInfo.
].
printerContext startPrintJob: (printJobName ? 'ST/X PrintJob') fileName:printFileName.
printerContext foreground:(Color black) background:(Color white).
"Created: / 10-10-2006 / 18:49:55 / cg"
! !
!WinPrinterStream methodsFor:'private'!
setPrintFileName:something
printFileName := something.
"Created: / 10-10-2006 / 19:07:16 / cg"
! !
!WinPrinterStream methodsFor:'writing'!
cr
|line|
currentLineBuffer notNil ifTrue:[
line := currentLineBuffer contents.
currentLineBuffer := nil.
].
currentPageBuffer isNil ifTrue:[
currentPageBuffer := OrderedCollection new.
].
currentPageBuffer add:line.
"Created: / 10-10-2006 / 20:19:46 / cg"
!
nextPut:aCharacter
currentLineBuffer isNil ifTrue:[
currentLineBuffer := WriteStream on:String new.
].
currentLineBuffer nextPut:aCharacter
"Created: / 10-10-2006 / 20:18:09 / cg"
!
nextPutAll:aString
currentLineBuffer isNil ifTrue:[
currentLineBuffer := WriteStream on:String new.
].
currentLineBuffer nextPutAll:aString
"Created: / 10-10-2006 / 20:18:33 / cg"
! !
!WinPrinterStream class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview2/WinPrinterStream.st,v 1.1 2006-10-10 18:26:19 cg Exp $'
! !