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