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:'native' |
14 instanceVariableNames:'native pageFormat' |
15 classVariableNames:'PrintCommand LeftMargin DefaultCommands' |
15 classVariableNames:'PrintCommand LeftMargin DefaultCommands PageFormat |
|
16 DefaultPageFormats Landscape' |
16 poolDictionaries:'' |
17 poolDictionaries:'' |
17 category:'Streams-External' |
18 category:'Streams-External' |
18 ! |
19 ! |
19 |
20 |
20 !PrinterStream class methodsFor:'documentation'! |
21 !PrinterStream class methodsFor:'documentation'! |
83 |
84 |
84 initialize |
85 initialize |
85 "this is usually redefined by the startup-file" |
86 "this is usually redefined by the startup-file" |
86 |
87 |
87 PrintCommand isNil ifTrue:[ |
88 PrintCommand isNil ifTrue:[ |
88 OperatingSystem isBSDlike ifTrue:[ |
89 OperatingSystem isBSDlike ifTrue:[ |
89 PrintCommand := 'lpr' |
90 PrintCommand := 'lpr' |
90 ] ifFalse:[ |
91 ] ifFalse:[ |
91 PrintCommand := 'lp' |
92 PrintCommand := 'lp' |
92 ] |
93 ] |
93 ]. |
94 ]. |
94 LeftMargin isNil ifTrue:[ |
95 LeftMargin isNil ifTrue:[ |
95 LeftMargin := 0 |
96 LeftMargin := 0 |
|
97 ]. |
|
98 |
|
99 DefaultPageFormats isNil ifTrue:[ |
|
100 "/ UnitConverter must support all of them. |
|
101 self defaultPageFormats:#( |
|
102 'letter' |
|
103 'a4' |
|
104 'a5' |
|
105 'a6' |
|
106 ). |
|
107 ]. |
|
108 |
|
109 Landscape isNil ifTrue:[ |
|
110 Landscape := false |
|
111 ]. |
|
112 |
|
113 PageFormat isNil ifTrue:[ |
|
114 Language == #us ifTrue:[ |
|
115 PageFormat := #letter |
|
116 ] ifFalse:[ |
|
117 PageFormat := #a4 |
|
118 ] |
96 ] |
119 ] |
|
120 |
|
121 " |
|
122 PrinterStream initialize |
|
123 " |
97 ! ! |
124 ! ! |
98 |
125 |
99 !PrinterStream class methodsFor:'instance creation'! |
126 !PrinterStream class methodsFor:'instance creation'! |
100 |
127 |
101 new |
128 new |
102 "return a new stream for printing" |
129 "return a new stream for printing" |
103 |
130 |
104 ^ self basicNew startPrint |
131 ^ self basicNew initialize startPrint |
105 ! |
132 ! |
106 |
133 |
107 newNative |
134 newNative |
108 "return a new stream for untranslated printing |
135 "return a new stream for untranslated printing |
109 (i.e. text should be sent via nextPutUntranslated in the printers |
136 (i.e. text should be sent via nextPutUntranslated in the printers |
110 native format)" |
137 native format)" |
111 |
138 |
112 ^ self basicNew setNative; writingTo:(self printCommand) |
139 ^ self basicNew initialize setNative; writingTo:(self printCommand) |
113 ! ! |
140 ! ! |
114 |
141 |
115 !PrinterStream class methodsFor:'accessing'! |
142 !PrinterStream class methodsFor:'accessing - defaults'! |
116 |
143 |
117 defaultCommands |
144 defaultCommands |
118 "return a list presented as possible commands for printed |
145 "return a list presented as possible commands for printed |
119 (in the launchers printer configuration). |
146 (in the launchers printer configuration). |
120 This list can be set from the startup script with: |
147 This list can be set from the startup script with: |
125 "Created: 23.4.1996 / 18:25:18 / cg" |
152 "Created: 23.4.1996 / 18:25:18 / cg" |
126 ! |
153 ! |
127 |
154 |
128 defaultCommands:collectionOfCommandStrings |
155 defaultCommands:collectionOfCommandStrings |
129 "set the list which will be presented as possible commands for printing. |
156 "set the list which will be presented as possible commands for printing. |
130 (in the launchers printer configuration). |
157 (shown in in the launchers printer configuration). |
131 This can be done from the startup script with: |
158 This can be done from the startup script with: |
132 PrinterStream defaultCommands:#( ... )" |
159 PrinterStream defaultCommands:#( ... )" |
133 |
160 |
134 DefaultCommands := collectionOfCommandStrings |
161 DefaultCommands := collectionOfCommandStrings |
135 |
162 |
136 "Created: 23.4.1996 / 18:26:06 / cg" |
163 "Created: 23.4.1996 / 18:26:06 / cg" |
137 ! |
164 ! |
138 |
165 |
|
166 defaultPageFormats |
|
167 "return a list of supported pae formats. |
|
168 This list can be set from the startup script with: |
|
169 PrinterStream defaultPageFormats:#..." |
|
170 |
|
171 ^ DefaultPageFormats |
|
172 |
|
173 "Created: 23.4.1996 / 18:25:18 / cg" |
|
174 ! |
|
175 |
|
176 defaultPageFormats:aList |
|
177 "set the list of supported pae formats. |
|
178 (shown in in the launchers printer configuration). |
|
179 This list can be set from the startup script with: |
|
180 PrinterStream defaultPageFormats:#..." |
|
181 |
|
182 DefaultPageFormats := aList. |
|
183 |
|
184 "/ validate the list |
|
185 aList do:[:name | |
|
186 |unit ok| |
|
187 |
|
188 ok := true. |
|
189 #('W' 'H' 'lW' 'lH') do:[:what | |
|
190 unit := (name , what) asSymbolIfInterned. |
|
191 (unit isNil |
|
192 or:[(UnitConverter convert:1 from:unit to:#millimeter) isNil]) ifTrue:[ |
|
193 ok := false |
|
194 ] |
|
195 ]. |
|
196 ok ifFalse:[ |
|
197 ('PRINTER: UnitConverter has no size-info for ''' , name , '''-format') errorPrintCR |
|
198 ] |
|
199 ]. |
|
200 |
|
201 " |
|
202 PrinterStream |
|
203 defaultPageFormats:#( |
|
204 'letter' |
|
205 'a4' |
|
206 'a5' |
|
207 'a6' |
|
208 ) |
|
209 " |
|
210 |
|
211 "Created: 23.4.1996 / 18:25:18 / cg" |
|
212 ! |
|
213 |
|
214 landscape |
|
215 "return the landscape setting" |
|
216 |
|
217 ^ Landscape |
|
218 ! |
|
219 |
|
220 landscape:aBoolean |
|
221 "set/clear landscape printing" |
|
222 |
|
223 Landscape := aBoolean |
|
224 ! |
|
225 |
|
226 leftMargin |
|
227 "return the number of blanks for the left margin" |
|
228 |
|
229 ^ LeftMargin |
|
230 ! |
|
231 |
139 leftMargin:aNumber |
232 leftMargin:aNumber |
140 "set the number of blanks for the left margin" |
233 "set the number of blanks for the left margin" |
141 |
234 |
142 LeftMargin := aNumber |
235 LeftMargin := aNumber |
143 ! |
236 ! |
144 |
237 |
|
238 pageFormat |
|
239 "return a symbol describing the default page format. |
|
240 This list can be set from the startup script with: |
|
241 PrinterStream defaultPageFormat:#... |
|
242 or via the launchers settings menu." |
|
243 |
|
244 ^ PageFormat |
|
245 |
|
246 "Created: 23.4.1996 / 18:25:18 / cg" |
|
247 ! |
|
248 |
|
249 pageFormat:aSymbol |
|
250 "set the the default page format to be aSymbol. |
|
251 Valid symbols are #letter, #a4, #a5 etc. |
|
252 The UnitConverter must contain width/height information on |
|
253 that symbol, in order for printing to be correct. |
|
254 |
|
255 This list can be set from the startup script with: |
|
256 PrinterStream defaultPageFormat:#... |
|
257 or via the launchers settings menu." |
|
258 |
|
259 PageFormat := aSymbol |
|
260 |
|
261 "Created: 23.4.1996 / 18:25:18 / cg" |
|
262 ! |
|
263 |
145 printCommand |
264 printCommand |
146 "return the command used for printing (usually 'lp' or 'lpr')" |
265 "return the command used for printing (usually 'lp' or 'lpr'). |
|
266 This is either set from the startup file, or via the launchers |
|
267 settings menu." |
147 |
268 |
148 ^ PrintCommand |
269 ^ PrintCommand |
149 |
270 |
150 "Modified: 18.5.1996 / 09:12:35 / cg" |
271 "Modified: 18.5.1996 / 09:12:35 / cg" |
151 ! |
272 ! |
152 |
273 |
153 printCommand:aString |
274 printCommand:aString |
154 "set the command for printing (usually 'lp' or 'lpr')" |
275 "set the command for printing (usually 'lp' or 'lpr'). |
|
276 This is either set from the startup file, or via the launchers |
|
277 settings menu." |
155 |
278 |
156 PrintCommand := aString |
279 PrintCommand := aString |
157 |
280 |
158 " |
281 " |
159 PrinterStream printCommand:'lpr' |
282 PrinterStream printCommand:'lpr' |