author | Claus Gittinger <cg@exept.de> |
Sat, 01 Jun 1996 00:28:00 +0200 | |
changeset 371 | 8033851303de |
parent 370 | 705453f00711 |
child 373 | 6834d6a61ea9 |
permissions | -rw-r--r-- |
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 |
|
367 | 14 |
instanceVariableNames:'native pageFormat' |
370 | 15 |
classVariableNames:'' |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
16 |
poolDictionaries:'' |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
17 |
category:'Streams-External' |
0 | 18 |
! |
19 |
||
370 | 20 |
PrinterStream class instanceVariableNames:'PrintCommand DefaultCommands PageFormat LeftMargin DefaultPageFormats |
21 |
Landscape' |
|
22 |
! |
|
23 |
||
31 | 24 |
!PrinterStream class methodsFor:'documentation'! |
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
84 | 29 |
All Rights Reserved |
0 | 30 |
|
31 | 31 |
This software is furnished under a license and may be used |
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
0 | 39 |
|
31 | 40 |
documentation |
41 |
" |
|
42 |
a stream for printing; this (concrete or abstract) class can handle only |
|
348 | 43 |
very dumb printers. |
44 |
No attributes (italic, bold etc) and no multiple fonts are supported |
|
45 |
- just plain single font text printing. |
|
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
160
diff
changeset
|
46 |
|
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
160
diff
changeset
|
47 |
More intelligence is added by subclasses (see PostscriptPrinterStream among others.) |
211 | 48 |
|
49 |
These classes do not support graphics printing - they are only for |
|
50 |
text; although some limited font functionality (such as bold or italic printing) |
|
51 |
may be supported by some subclasses. |
|
52 |
||
348 | 53 |
|
54 |
[usage:] |
|
55 |
||
211 | 56 |
The concrete printer class is bound to the global variable Printer, |
235 | 57 |
which is either set to PrinterStream (for dumb printers) or to one of |
211 | 58 |
the subclasses (PostscriptPrinterStream etc.). |
59 |
||
60 |
To print: |
|
61 |
||
371 | 62 |
|p| |
211 | 63 |
|
370 | 64 |
p := Printer new. |
65 |
p notNil ifTrue:[ |
|
66 |
p nextPutAll:'hello world'; cr. |
|
67 |
p nextPutAll:' ...'; cr. |
|
68 |
p close |
|
69 |
]. |
|
211 | 70 |
|
71 |
See users of the Printer global variable for more examples. |
|
259 | 72 |
|
348 | 73 |
[class variables:] |
370 | 74 |
PrintCommand <String> the operatingSystem command for printing. |
75 |
Usually something like 'lp' or 'lpr' |
|
348 | 76 |
|
370 | 77 |
LeftMargin <Integer> optional default left margin. |
78 |
Defaults to 0. |
|
348 | 79 |
|
80 |
||
259 | 81 |
[author:] |
370 | 82 |
Claus Gittinger |
31 | 83 |
" |
84 |
! ! |
|
0 | 85 |
|
86 |
!PrinterStream class methodsFor:'initialization'! |
|
87 |
||
88 |
initialize |
|
89 |
"this is usually redefined by the startup-file" |
|
90 |
||
370 | 91 |
DefaultCommands isNil ifTrue:[ |
92 |
DefaultCommands := #('lpr' |
|
93 |
'lpr -P<your-printer>' |
|
94 |
'cat | rsh <printHost> lpr -h' |
|
95 |
'cat >xxx ; ghostview xxx' |
|
96 |
'cat > printfile' |
|
97 |
'a2ps' |
|
98 |
'a2ps | rsh <printHost> lpr -h' |
|
99 |
'a2ps > printfile' |
|
100 |
). |
|
101 |
]. |
|
102 |
||
10 | 103 |
PrintCommand isNil ifTrue:[ |
371 | 104 |
OperatingSystem isBSDlike ifTrue:[ |
105 |
PrintCommand := 'lpr' |
|
106 |
] ifFalse:[ |
|
107 |
PrintCommand := 'lp' |
|
108 |
] |
|
0 | 109 |
]. |
10 | 110 |
LeftMargin isNil ifTrue:[ |
371 | 111 |
LeftMargin := 0 |
367 | 112 |
]. |
113 |
||
114 |
DefaultPageFormats isNil ifTrue:[ |
|
115 |
"/ UnitConverter must support all of them. |
|
371 | 116 |
self defaultPageFormats:#( |
117 |
'letter' |
|
118 |
'a4' |
|
119 |
'a5' |
|
120 |
'a6' |
|
121 |
). |
|
367 | 122 |
]. |
123 |
||
124 |
Landscape isNil ifTrue:[ |
|
371 | 125 |
Landscape := false |
367 | 126 |
]. |
127 |
||
128 |
PageFormat isNil ifTrue:[ |
|
371 | 129 |
Language == #us ifTrue:[ |
130 |
PageFormat := #letter |
|
131 |
] ifFalse:[ |
|
132 |
PageFormat := #a4 |
|
133 |
] |
|
0 | 134 |
] |
367 | 135 |
|
136 |
" |
|
137 |
PrinterStream initialize |
|
138 |
" |
|
370 | 139 |
|
140 |
"Modified: 1.6.1996 / 00:20:15 / cg" |
|
2 | 141 |
! ! |
142 |
||
0 | 143 |
!PrinterStream class methodsFor:'instance creation'! |
144 |
||
145 |
new |
|
146 |
"return a new stream for printing" |
|
147 |
||
367 | 148 |
^ self basicNew initialize startPrint |
160 | 149 |
! |
150 |
||
151 |
newNative |
|
152 |
"return a new stream for untranslated printing |
|
153 |
(i.e. text should be sent via nextPutUntranslated in the printers |
|
154 |
native format)" |
|
155 |
||
367 | 156 |
^ self basicNew initialize setNative; writingTo:(self printCommand) |
0 | 157 |
! ! |
158 |
||
367 | 159 |
!PrinterStream class methodsFor:'accessing - defaults'! |
0 | 160 |
|
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
161 |
defaultCommands |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
162 |
"return a list presented as possible commands for printed |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
163 |
(in the launchers printer configuration). |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
164 |
This list can be set from the startup script with: |
371 | 165 |
PrinterStream defaultCommands:#( ... )" |
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
166 |
|
370 | 167 |
DefaultCommands isNil ifTrue:[ |
168 |
self == PrinterStream ifFalse:[ |
|
371 | 169 |
^ self superclass defaultCommands |
370 | 170 |
] |
171 |
]. |
|
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
172 |
^ DefaultCommands |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
173 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
174 |
"Created: 23.4.1996 / 18:25:18 / cg" |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
175 |
! |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
176 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
177 |
defaultCommands:collectionOfCommandStrings |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
178 |
"set the list which will be presented as possible commands for printing. |
367 | 179 |
(shown in in the launchers printer configuration). |
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
180 |
This can be done from the startup script with: |
370 | 181 |
PrinterStream defaultCommands:#( ... )" |
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
182 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
183 |
DefaultCommands := collectionOfCommandStrings |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
184 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
185 |
"Created: 23.4.1996 / 18:26:06 / cg" |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
186 |
! |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
187 |
|
367 | 188 |
defaultPageFormats |
189 |
"return a list of supported pae formats. |
|
190 |
This list can be set from the startup script with: |
|
371 | 191 |
PrinterStream defaultPageFormats:#..." |
367 | 192 |
|
370 | 193 |
DefaultPageFormats isNil ifTrue:[ |
194 |
self == PrinterStream ifFalse:[ |
|
371 | 195 |
^ self superclass defaultPageFormats |
370 | 196 |
] |
197 |
]. |
|
367 | 198 |
^ DefaultPageFormats |
199 |
||
200 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
201 |
! |
|
202 |
||
203 |
defaultPageFormats:aList |
|
204 |
"set the list of supported pae formats. |
|
205 |
(shown in in the launchers printer configuration). |
|
206 |
This list can be set from the startup script with: |
|
370 | 207 |
PrinterStream defaultPageFormats:#..." |
367 | 208 |
|
209 |
DefaultPageFormats := aList. |
|
210 |
||
211 |
"/ validate the list |
|
212 |
aList do:[:name | |
|
370 | 213 |
|unit ok| |
367 | 214 |
|
370 | 215 |
ok := true. |
216 |
#('W' 'H' 'lW' 'lH') do:[:what | |
|
217 |
unit := (name , what) asSymbolIfInterned. |
|
218 |
(unit isNil |
|
219 |
or:[(UnitConverter convert:1 from:unit to:#millimeter) isNil]) ifTrue:[ |
|
220 |
ok := false |
|
221 |
] |
|
222 |
]. |
|
223 |
ok ifFalse:[ |
|
224 |
('PRINTER: UnitConverter has no size-info for ''' , name , '''-format') errorPrintCR |
|
225 |
] |
|
367 | 226 |
]. |
227 |
||
228 |
" |
|
229 |
PrinterStream |
|
370 | 230 |
defaultPageFormats:#( |
231 |
'letter' |
|
232 |
'a4' |
|
233 |
'a5' |
|
234 |
'a6' |
|
235 |
) |
|
367 | 236 |
" |
237 |
||
238 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
239 |
! |
|
240 |
||
241 |
landscape |
|
242 |
"return the landscape setting" |
|
243 |
||
370 | 244 |
Landscape isNil ifTrue:[ |
245 |
self == PrinterStream ifFalse:[ |
|
371 | 246 |
^ self superclass landscape |
370 | 247 |
] |
248 |
]. |
|
367 | 249 |
^ Landscape |
250 |
! |
|
251 |
||
252 |
landscape:aBoolean |
|
253 |
"set/clear landscape printing" |
|
254 |
||
255 |
Landscape := aBoolean |
|
256 |
! |
|
257 |
||
258 |
leftMargin |
|
259 |
"return the number of blanks for the left margin" |
|
260 |
||
370 | 261 |
LeftMargin isNil ifTrue:[ |
262 |
self == PrinterStream ifFalse:[ |
|
371 | 263 |
^ self superclass leftMargin |
370 | 264 |
] |
265 |
]. |
|
367 | 266 |
^ LeftMargin |
267 |
! |
|
268 |
||
126 | 269 |
leftMargin:aNumber |
270 |
"set the number of blanks for the left margin" |
|
271 |
||
272 |
LeftMargin := aNumber |
|
0 | 273 |
! |
274 |
||
367 | 275 |
pageFormat |
276 |
"return a symbol describing the default page format. |
|
277 |
This list can be set from the startup script with: |
|
371 | 278 |
PrinterStream defaultPageFormat:#... |
367 | 279 |
or via the launchers settings menu." |
280 |
||
370 | 281 |
PageFormat isNil ifTrue:[ |
282 |
self == PrinterStream ifFalse:[ |
|
371 | 283 |
^ self superclass pageFormat |
370 | 284 |
] |
285 |
]. |
|
367 | 286 |
^ PageFormat |
287 |
||
288 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
289 |
! |
|
290 |
||
291 |
pageFormat:aSymbol |
|
292 |
"set the the default page format to be aSymbol. |
|
293 |
Valid symbols are #letter, #a4, #a5 etc. |
|
294 |
The UnitConverter must contain width/height information on |
|
295 |
that symbol, in order for printing to be correct. |
|
296 |
||
297 |
This list can be set from the startup script with: |
|
370 | 298 |
PrinterStream defaultPageFormat:#... |
367 | 299 |
or via the launchers settings menu." |
300 |
||
301 |
PageFormat := aSymbol |
|
302 |
||
303 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
304 |
! |
|
305 |
||
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
306 |
printCommand |
367 | 307 |
"return the command used for printing (usually 'lp' or 'lpr'). |
308 |
This is either set from the startup file, or via the launchers |
|
309 |
settings menu." |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
310 |
|
370 | 311 |
PrintCommand isNil ifTrue:[ |
312 |
self == PrinterStream ifFalse:[ |
|
371 | 313 |
^ self superclass printCommand |
370 | 314 |
] |
315 |
]. |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
316 |
^ PrintCommand |
348 | 317 |
|
318 |
"Modified: 18.5.1996 / 09:12:35 / cg" |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
319 |
! |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
320 |
|
126 | 321 |
printCommand:aString |
367 | 322 |
"set the command for printing (usually 'lp' or 'lpr'). |
323 |
This is either set from the startup file, or via the launchers |
|
324 |
settings menu." |
|
126 | 325 |
|
326 |
PrintCommand := aString |
|
139 | 327 |
|
328 |
" |
|
329 |
PrinterStream printCommand:'lpr' |
|
330 |
PrinterStream printCommand:'lpr -h' |
|
331 |
PrinterStream printCommand:'rsh ibm lpr -h' |
|
332 |
PrinterStream printCommand:'gs -sDEVICE=djet500 -sOutputFile=/tmp/stx.ps -sPAPERSIZE=a4 -q -; cat /tmp/stx.ps | rsh ibm lpr -h' |
|
333 |
" |
|
348 | 334 |
|
335 |
"Modified: 18.5.1996 / 09:12:48 / cg" |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
336 |
! ! |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
337 |
|
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
338 |
!PrinterStream class methodsFor:'queries'! |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
339 |
|
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
340 |
printerTypeName |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
341 |
"return a descriptive name" |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
342 |
|
235 | 343 |
^ 'dumb printer' |
344 |
||
345 |
"Modified: 18.4.1996 / 20:04:12 / cg" |
|
139 | 346 |
! |
347 |
||
368
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
348 |
supportsPageSizes |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
349 |
"return true if this printer supports different page sizes" |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
350 |
|
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
351 |
^ false |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
352 |
|
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
353 |
"Created: 31.5.1996 / 22:35:26 / cg" |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
354 |
! |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
355 |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
356 |
supportsPostscript |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
357 |
"return true if this is a postscript printer" |
139 | 358 |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
359 |
^ false |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
360 |
|
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
361 |
"Created: 10.2.1996 / 16:23:07 / cg" |
126 | 362 |
! ! |
0 | 363 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
364 |
!PrinterStream methodsFor:'access writing'! |
126 | 365 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
366 |
cr |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
367 |
"send a carriage-return to the printer" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
368 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
369 |
super nextPut:(Character cr). |
370 | 370 |
self spaces:(self class leftMargin) |
371 |
||
372 |
"Modified: 1.6.1996 / 00:13:44 / cg" |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
373 |
! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
374 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
375 |
next:count put:aCharacter |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
376 |
"send some character multiple times to the printer - translate as needed. |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
377 |
Redefined to allow individual character translation in subclasses" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
378 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
379 |
count timesRepeat:[ |
370 | 380 |
self nextPut:aCharacter |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
381 |
] |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
382 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
383 |
"Created: 10.4.1996 / 13:08:13 / cg" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
384 |
"Modified: 10.4.1996 / 13:09:06 / cg" |
126 | 385 |
! |
386 |
||
387 |
nextPut:aCharacter |
|
388 |
"send some characters to the printer - translate as needed" |
|
389 |
||
390 |
(aCharacter == Character cr) ifTrue:[ |
|
370 | 391 |
super nextPut:(Character cr). |
392 |
self spaces:(self class leftMargin) |
|
126 | 393 |
] ifFalse:[ |
370 | 394 |
super nextPut:aCharacter |
126 | 395 |
] |
370 | 396 |
|
397 |
"Modified: 1.6.1996 / 00:13:48 / cg" |
|
126 | 398 |
! |
6 | 399 |
|
126 | 400 |
nextPutAll:aCollection |
348 | 401 |
"send some characters to the printer - translate as needed. |
402 |
The argument, aCollection can be a Text (i.e. include emphasis)" |
|
126 | 403 |
|
348 | 404 |
aCollection hasChangeOfEmphasis ifTrue:[ |
370 | 405 |
aCollection keysAndValuesDo:[:idx :aChar | |
406 |
self emphasis:(aCollection emphasisAt:idx). |
|
407 |
self nextPut:aChar. |
|
408 |
]. |
|
409 |
self normal. |
|
348 | 410 |
] ifFalse:[ |
370 | 411 |
aCollection do:[:aChar | |
412 |
self nextPut:aChar |
|
413 |
] |
|
126 | 414 |
] |
348 | 415 |
|
349 | 416 |
"Modified: 18.5.1996 / 09:43:45 / cg" |
126 | 417 |
! |
418 |
||
419 |
nextPutAllUntranslated:aCollection |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
420 |
"send some raw characters to the printer - even if not in native mode" |
126 | 421 |
|
422 |
super nextPutAll:aCollection |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
423 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
424 |
"Modified: 10.4.1996 / 13:08:35 / cg" |
126 | 425 |
! |
426 |
||
427 |
nextPutUntranslated:aCharacter |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
428 |
"send a raw character to the printer - even if not in native mode" |
126 | 429 |
|
430 |
super nextPut:aCharacter |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
431 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
432 |
"Modified: 10.4.1996 / 13:08:28 / cg" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
433 |
! ! |
0 | 434 |
|
348 | 435 |
!PrinterStream methodsFor:'emphasis change'! |
436 |
||
437 |
bold |
|
438 |
"set emphasis to bold |
|
439 |
- ignore here, since this class does not know anything about the printer" |
|
440 |
||
441 |
^ self |
|
442 |
||
443 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
444 |
! |
|
445 |
||
446 |
boldItalic |
|
447 |
"set emphasis to boldItalic |
|
448 |
- ignore here, since this class does not know anything about the printer" |
|
449 |
||
450 |
^ self |
|
451 |
||
452 |
"Created: 14.5.1996 / 18:53:43 / cg" |
|
453 |
"Modified: 18.5.1996 / 08:55:14 / cg" |
|
454 |
! |
|
455 |
||
456 |
emphasis:anEmphasis |
|
457 |
"change the emphasis" |
|
458 |
||
459 |
anEmphasis isNil ifTrue:[ |
|
370 | 460 |
^ self normal |
348 | 461 |
]. |
462 |
anEmphasis == #bold ifTrue:[ |
|
370 | 463 |
^ self bold |
348 | 464 |
]. |
465 |
anEmphasis == #italic ifTrue:[ |
|
370 | 466 |
^ self italic |
348 | 467 |
]. |
349 | 468 |
(anEmphasis = #(bold italic) |
469 |
or:[anEmphasis = #(italic bold)]) ifTrue:[ |
|
370 | 470 |
^ self boldItalic |
349 | 471 |
]. |
348 | 472 |
anEmphasis == #underline ifTrue:[ |
370 | 473 |
^ self underline |
348 | 474 |
]. |
475 |
anEmphasis == #strikeout ifTrue:[ |
|
370 | 476 |
^ self strikeout |
348 | 477 |
]. |
478 |
||
479 |
"Created: 14.5.1996 / 18:53:54 / cg" |
|
349 | 480 |
"Modified: 18.5.1996 / 09:42:49 / cg" |
348 | 481 |
! |
482 |
||
483 |
italic |
|
484 |
"set emphasis to italic |
|
485 |
- ignore here, since this class does not know anything about the printer" |
|
486 |
||
487 |
^ self |
|
488 |
||
489 |
"Modified: 18.5.1996 / 08:55:18 / cg" |
|
490 |
! |
|
491 |
||
492 |
normal |
|
493 |
"set emphasis to normal (non-bold, non-italic) |
|
494 |
- ignore here, since this class does not know anything about the printer" |
|
495 |
||
496 |
^ self |
|
497 |
||
498 |
"Modified: 18.5.1996 / 08:55:21 / cg" |
|
499 |
! |
|
500 |
||
501 |
strikeout |
|
502 |
"set emphasis to strikeout |
|
503 |
- ignore here, since this class does not know anything about the printer" |
|
504 |
||
505 |
^ self |
|
506 |
||
507 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
508 |
"Created: 18.5.1996 / 08:56:13 / cg" |
|
509 |
! |
|
510 |
||
511 |
underline |
|
512 |
"set emphasis to underline |
|
513 |
- ignore here, since this class does not know anything about the printer" |
|
514 |
||
515 |
^ self |
|
516 |
||
517 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
518 |
"Created: 18.5.1996 / 08:56:24 / cg" |
|
519 |
! ! |
|
520 |
||
521 |
!PrinterStream methodsFor:'font change'! |
|
522 |
||
523 |
courier |
|
524 |
"set font to courier |
|
525 |
- ignore here, since this class does not know anything about the printer" |
|
526 |
||
527 |
^ self |
|
528 |
! |
|
529 |
||
530 |
helvetica |
|
531 |
"set font to helvetic |
|
532 |
- ignore here, since this class does not know anything about the printer" |
|
533 |
||
534 |
^ self |
|
535 |
! |
|
536 |
||
537 |
times |
|
538 |
"set font to times |
|
539 |
- ignore here, since this class does not know anything about the printer" |
|
540 |
||
541 |
^ self |
|
542 |
! ! |
|
543 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
544 |
!PrinterStream methodsFor:'helpers writing'! |
6 | 545 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
546 |
escape:aCharacter |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
547 |
"since its so common, this method sends escape followed by aCharacter" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
548 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
549 |
super nextPut:(Character escape); nextPut:aCharacter |
126 | 550 |
! |
551 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
552 |
escapeAll:aString |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
553 |
"since its so common, this method sends escape followed by aString" |
126 | 554 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
555 |
super nextPut:(Character escape); nextPutAll:aString |
0 | 556 |
! ! |
126 | 557 |
|
367 | 558 |
!PrinterStream methodsFor:'initialization'! |
559 |
||
560 |
initialize |
|
561 |
pageFormat := DefaultPageFormat |
|
562 |
||
563 |
"Created: 31.5.1996 / 20:14:36 / cg" |
|
564 |
! ! |
|
565 |
||
126 | 566 |
!PrinterStream methodsFor:'open/close'! |
567 |
||
160 | 568 |
basicClose |
569 |
super close |
|
570 |
! |
|
571 |
||
126 | 572 |
close |
573 |
self endPrint. |
|
574 |
super close |
|
575 |
! |
|
576 |
||
577 |
endPrint |
|
578 |
^ self |
|
579 |
! |
|
580 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
581 |
setNative |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
582 |
native := true |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
583 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
584 |
"Created: 10.4.1996 / 13:05:01 / cg" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
585 |
! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
586 |
|
362 | 587 |
setNative:aBoolean |
588 |
native := aBoolean |
|
589 |
||
590 |
"Created: 30.5.1996 / 17:49:09 / cg" |
|
591 |
! |
|
592 |
||
126 | 593 |
startPrint |
370 | 594 |
super writingTo:(self class printCommand). |
595 |
self spaces:(self class leftMargin) |
|
596 |
||
597 |
"Modified: 1.6.1996 / 00:13:23 / cg" |
|
126 | 598 |
! ! |
599 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
600 |
!PrinterStream methodsFor:'queries'! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
601 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
602 |
lineLength |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
603 |
"the printer pages width (in characters)" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
604 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
605 |
^ 80 |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
606 |
! ! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
607 |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
608 |
!PrinterStream class methodsFor:'documentation'! |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
609 |
|
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
610 |
version |
371 | 611 |
^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.29 1996-05-31 22:28:00 cg Exp $' |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
612 |
! ! |
126 | 613 |
PrinterStream initialize! |