0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
84
|
3 |
All Rights Reserved
|
0
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
PipeStream subclass:#PrinterStream
|
126
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:'PrintCommand LeftMargin'
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Streams-External'
|
0
|
18 |
!
|
|
19 |
|
31
|
20 |
!PrinterStream class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
84
|
25 |
All Rights Reserved
|
0
|
26 |
|
31
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
0
|
35 |
|
31
|
36 |
documentation
|
|
37 |
"
|
|
38 |
a stream for printing; this (concrete or abstract) class can handle only
|
|
39 |
very dumb printers. More intelligence is added by subclasses (see
|
|
40 |
PostscriptPrinterStream among others.)
|
|
41 |
"
|
126
|
42 |
!
|
|
43 |
|
|
44 |
version
|
|
45 |
^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.12 1995-11-23 01:51:39 cg Exp $'
|
31
|
46 |
! !
|
0
|
47 |
|
|
48 |
!PrinterStream class methodsFor:'initialization'!
|
|
49 |
|
|
50 |
initialize
|
|
51 |
"this is usually redefined by the startup-file"
|
|
52 |
|
10
|
53 |
PrintCommand isNil ifTrue:[
|
84
|
54 |
OperatingSystem isBSDlike ifTrue:[
|
|
55 |
PrintCommand := 'lpr'
|
|
56 |
] ifFalse:[
|
|
57 |
PrintCommand := 'lp'
|
|
58 |
]
|
0
|
59 |
].
|
10
|
60 |
LeftMargin isNil ifTrue:[
|
84
|
61 |
LeftMargin := 0
|
0
|
62 |
]
|
2
|
63 |
! !
|
|
64 |
|
0
|
65 |
!PrinterStream class methodsFor:'instance creation'!
|
|
66 |
|
|
67 |
new
|
|
68 |
"return a new stream for printing"
|
|
69 |
|
|
70 |
^ self basicNew startPrint
|
|
71 |
! !
|
|
72 |
|
126
|
73 |
!PrinterStream class methodsFor:'accessing'!
|
0
|
74 |
|
126
|
75 |
leftMargin:aNumber
|
|
76 |
"set the number of blanks for the left margin"
|
|
77 |
|
|
78 |
LeftMargin := aNumber
|
0
|
79 |
!
|
|
80 |
|
126
|
81 |
printCommand
|
|
82 |
"return the command for printing (usually lp or lpr)"
|
|
83 |
|
|
84 |
^ PrintCommand
|
0
|
85 |
!
|
|
86 |
|
126
|
87 |
printCommand:aString
|
|
88 |
"set the command for printing (usually lp or lpr)"
|
|
89 |
|
|
90 |
PrintCommand := aString
|
|
91 |
! !
|
0
|
92 |
|
|
93 |
!PrinterStream methodsFor:'access writing'!
|
|
94 |
|
126
|
95 |
bold
|
|
96 |
"set font to bold
|
|
97 |
- ignore here, since this class does not know anything about the printer"
|
6
|
98 |
|
126
|
99 |
^ self
|
0
|
100 |
!
|
|
101 |
|
|
102 |
courier
|
6
|
103 |
"set font to courier
|
|
104 |
- ignore here, since this class does not know anything about the printer"
|
|
105 |
|
0
|
106 |
^ self
|
|
107 |
!
|
|
108 |
|
126
|
109 |
cr
|
|
110 |
"send a carriage-return to the printer"
|
6
|
111 |
|
126
|
112 |
super nextPut:(Character cr).
|
|
113 |
self spaces:LeftMargin
|
0
|
114 |
!
|
|
115 |
|
|
116 |
helvetica
|
6
|
117 |
"set font to helvetic
|
|
118 |
- ignore here, since this class does not know anything about the printer"
|
|
119 |
|
0
|
120 |
^ self
|
|
121 |
!
|
|
122 |
|
|
123 |
italic
|
6
|
124 |
"set font to italic
|
|
125 |
- ignore here, since this class does not know anything about the printer"
|
|
126 |
|
0
|
127 |
^ self
|
|
128 |
!
|
|
129 |
|
126
|
130 |
lineLength
|
|
131 |
"the printer pages width (in characters)"
|
|
132 |
|
|
133 |
^ 80
|
|
134 |
!
|
|
135 |
|
|
136 |
nextPut:aCharacter
|
|
137 |
"send some characters to the printer - translate as needed"
|
|
138 |
|
|
139 |
(aCharacter == Character cr) ifTrue:[
|
|
140 |
super nextPut:(Character cr).
|
|
141 |
self spaces:LeftMargin
|
|
142 |
] ifFalse:[
|
|
143 |
super nextPut:aCharacter
|
|
144 |
]
|
|
145 |
!
|
6
|
146 |
|
126
|
147 |
nextPutAll:aCollection
|
|
148 |
"send some characters to the printer - translate as needed"
|
|
149 |
|
|
150 |
aCollection do:[:aChar |
|
|
151 |
self nextPut:aChar
|
|
152 |
]
|
|
153 |
!
|
|
154 |
|
|
155 |
nextPutAllUntranslated:aCollection
|
|
156 |
"send some raw characters to the printer"
|
|
157 |
|
|
158 |
super nextPutAll:aCollection
|
|
159 |
!
|
|
160 |
|
|
161 |
nextPutUntranslated:aCharacter
|
|
162 |
"send a raw character to the printer"
|
|
163 |
|
|
164 |
super nextPut:aCharacter
|
0
|
165 |
!
|
|
166 |
|
|
167 |
normal
|
6
|
168 |
"set font to normal (non-bold, non-italic)
|
|
169 |
- ignore here, since this class does not know anything about the printer"
|
|
170 |
|
0
|
171 |
^ self
|
126
|
172 |
!
|
|
173 |
|
|
174 |
spaces:aNumber
|
|
175 |
"send some spaces to the printer"
|
|
176 |
|
|
177 |
aNumber timesRepeat:[
|
|
178 |
super nextPut:(Character space)
|
|
179 |
]
|
|
180 |
!
|
|
181 |
|
|
182 |
times
|
|
183 |
"set font to times
|
|
184 |
- ignore here, since this class does not know anything about the printer"
|
|
185 |
|
|
186 |
^ self
|
0
|
187 |
! !
|
126
|
188 |
|
|
189 |
!PrinterStream methodsFor:'open/close'!
|
|
190 |
|
|
191 |
close
|
|
192 |
self endPrint.
|
|
193 |
super close
|
|
194 |
!
|
|
195 |
|
|
196 |
endPrint
|
|
197 |
^ self
|
|
198 |
!
|
|
199 |
|
|
200 |
startPrint
|
|
201 |
super writingTo:PrintCommand.
|
|
202 |
self spaces:LeftMargin
|
|
203 |
! !
|
|
204 |
|
|
205 |
PrinterStream initialize!
|