author | Claus Gittinger <cg@exept.de> |
Tue, 13 May 2008 14:33:24 +0200 | |
changeset 1990 | 9594087e3a0a |
parent 1906 | ba10f3f4e6e0 |
child 1991 | d0d1eb17e990 |
permissions | -rw-r--r-- |
0 | 1 |
" |
4 | 2 |
COPYRIGHT (c) 1990 by Claus Gittinger |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
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 |
" |
|
913
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
12 |
"{ Package: 'stx:libbasic2' }" |
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
13 |
|
1317 | 14 |
Stream subclass:#PrinterStream |
15 |
instanceVariableNames:'stream native pageFormat underline strikeout' |
|
1220 | 16 |
classVariableNames:'DefaultPageFormat' |
17 |
poolDictionaries:'' |
|
1652 | 18 |
category:'Interface-Printing' |
0 | 19 |
! |
20 |
||
1317 | 21 |
PrinterStream class instanceVariableNames:'PrintCommand PrintFilename DefaultCommands PageFormat DefaultPageFormats |
22 |
Landscape PrintDevice DefaultDevices' |
|
627 | 23 |
|
24 |
" |
|
879 | 25 |
No other class instance variables are inherited by this class. |
627 | 26 |
" |
370 | 27 |
! |
28 |
||
456 | 29 |
!PrinterStream class methodsFor:'documentation'! |
31 | 30 |
|
31 |
copyright |
|
32 |
" |
|
33 |
COPYRIGHT (c) 1990 by Claus Gittinger |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
34 |
All Rights Reserved |
0 | 35 |
|
31 | 36 |
This software is furnished under a license and may be used |
37 |
only in accordance with the terms of that license and with the |
|
38 |
inclusion of the above copyright notice. This software may not |
|
39 |
be provided or otherwise made available to, or used by, any |
|
40 |
other person. No title to or ownership of the software is |
|
41 |
hereby transferred. |
|
42 |
" |
|
43 |
! |
|
0 | 44 |
|
31 | 45 |
documentation |
46 |
" |
|
47 |
a stream for printing; this (concrete or abstract) class can handle only |
|
348 | 48 |
very dumb printers. |
49 |
No attributes (italic, bold etc) and no multiple fonts are supported |
|
50 |
- just plain single font text printing. |
|
179
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
160
diff
changeset
|
51 |
|
38773360f4b7
more on printing (printerType-query)
Claus Gittinger <cg@exept.de>
parents:
160
diff
changeset
|
52 |
More intelligence is added by subclasses (see PostscriptPrinterStream among others.) |
211 | 53 |
|
1906 | 54 |
These classes do not support graphics printing - they are only for text; |
55 |
although some limited font functionality (such as bold or italic printing) |
|
211 | 56 |
may be supported by some subclasses. |
57 |
||
348 | 58 |
|
59 |
[usage:] |
|
60 |
||
211 | 61 |
The concrete printer class is bound to the global variable Printer, |
235 | 62 |
which is either set to PrinterStream (for dumb printers) or to one of |
211 | 63 |
the subclasses (PostscriptPrinterStream etc.). |
64 |
||
65 |
To print: |
|
66 |
||
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
67 |
|p| |
211 | 68 |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
69 |
p := Printer new. |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
70 |
p notNil ifTrue:[ |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
71 |
p nextPutAll:'hello world'; cr. |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
72 |
p nextPutAll:' ...'; cr. |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
73 |
p close |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
74 |
]. |
211 | 75 |
|
76 |
See users of the Printer global variable for more examples. |
|
259 | 77 |
|
348 | 78 |
[class variables:] |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
79 |
PrintCommand <String> UNIX only: the operatingSystem command for printing. |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
80 |
Usually something like 'lp' or 'lpr' |
348 | 81 |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
82 |
PrintDevice <String> VMS only: the printers device. |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
83 |
Usually something like 'sys$print:' |
571 | 84 |
|
259 | 85 |
[author:] |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
86 |
Claus Gittinger |
31 | 87 |
" |
88 |
! ! |
|
0 | 89 |
|
456 | 90 |
!PrinterStream class methodsFor:'initialization'! |
0 | 91 |
|
92 |
initialize |
|
93 |
"this is usually redefined by the startup-file" |
|
94 |
||
569 | 95 |
OperatingSystem isUNIXlike ifTrue:[ |
96 |
DefaultCommands isNil ifTrue:[ |
|
97 |
DefaultCommands := #( |
|
98 |
'lpr' |
|
99 |
'lpr -P<your-printer>' |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
100 |
'rsh <printHost> lpr -h' |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
101 |
'cat >preview.ps ; gv preview.ps' |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
102 |
'cat >printfile' |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
103 |
'gs -q -DNOPAUSE -sDEVICE=pdfwrite -sOutputFile=/tmp/preview.pdf -' |
569 | 104 |
'a2ps' |
105 |
'a2ps | rsh <printHost> lpr -h' |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
106 |
'a2ps >printfile' |
569 | 107 |
). |
108 |
]. |
|
370 | 109 |
|
569 | 110 |
PrintCommand isNil ifTrue:[ |
111 |
(OperatingSystem canExecuteCommand:'lpr') ifTrue:[ |
|
112 |
PrintCommand := 'lpr' |
|
113 |
] ifFalse:[ |
|
114 |
PrintCommand := 'lp' |
|
115 |
] |
|
1107 | 116 |
] |
0 | 117 |
]. |
571 | 118 |
OperatingSystem isVMSlike ifTrue:[ |
119 |
DefaultDevices isNil ifTrue:[ |
|
120 |
DefaultDevices := #( |
|
121 |
'sys$print:' |
|
122 |
). |
|
123 |
]. |
|
124 |
||
125 |
PrintDevice isNil ifTrue:[ |
|
126 |
PrintDevice := 'sys$print:' |
|
127 |
] |
|
128 |
]. |
|
367 | 129 |
|
130 |
DefaultPageFormats isNil ifTrue:[ |
|
571 | 131 |
"/ UnitConverter must support all of them. |
442 | 132 |
self defaultPageFormats:#( |
133 |
'a3' |
|
134 |
'a4' |
|
135 |
'a5' |
|
136 |
'a6' |
|
137 |
'b5' |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
138 |
'letter' |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
139 |
'legal' |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
140 |
'ledger' |
442 | 141 |
). |
367 | 142 |
]. |
143 |
||
144 |
Landscape isNil ifTrue:[ |
|
442 | 145 |
Landscape := false |
367 | 146 |
]. |
147 |
||
148 |
PageFormat isNil ifTrue:[ |
|
442 | 149 |
Language == #us ifTrue:[ |
150 |
PageFormat := #letter |
|
151 |
] ifFalse:[ |
|
152 |
PageFormat := #a4 |
|
153 |
] |
|
0 | 154 |
] |
367 | 155 |
|
156 |
" |
|
386 | 157 |
DefaultPageFormats := nil. |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
158 |
DefaultCommands := nil. |
442 | 159 |
PrintCommand := nil. |
367 | 160 |
PrinterStream initialize |
161 |
" |
|
370 | 162 |
|
386 | 163 |
"Modified: 4.6.1996 / 17:16:32 / cg" |
373 | 164 |
! |
165 |
||
166 |
reInitPage |
|
167 |
"nothing done here" |
|
168 |
||
169 |
"Created: 1.6.1996 / 00:49:40 / cg" |
|
2 | 170 |
! ! |
171 |
||
456 | 172 |
!PrinterStream class methodsFor:'instance creation'! |
0 | 173 |
|
174 |
new |
|
1317 | 175 |
"return a new stream for printing. |
176 |
If printFilename is nonNil, printOut goes into that file. |
|
177 |
otherwise, it is piped through the printCommand OS-command." |
|
178 |
||
179 |
^ self newForFile:(self printFilename). |
|
180 |
! |
|
181 |
||
182 |
newForFile:aFileNameOrNil |
|
183 |
"return a new stream for printing into aFileName" |
|
184 |
||
185 |
|str printer| |
|
186 |
||
187 |
printer := self basicNew initialize. |
|
0 | 188 |
|
1317 | 189 |
aFileNameOrNil notNil ifTrue:[ |
190 |
str := aFileNameOrNil asFilename writeStream. |
|
191 |
printer stream:str. |
|
192 |
]. |
|
193 |
printer startPrint. |
|
194 |
^ printer |
|
195 |
||
196 |
" |
|
197 |
|p| |
|
198 |
||
199 |
p := PostscriptPrinterStream newForFile:'/tmp/out.ps'. |
|
200 |
True printOutOn:p. |
|
201 |
p close. |
|
202 |
" |
|
160 | 203 |
! |
204 |
||
205 |
newNative |
|
206 |
"return a new stream for untranslated printing |
|
1317 | 207 |
(i.e. text should be sent via nextPutUntranslated in the printers native format). |
208 |
For example, this is used with PostScriptPrinterStream, |
|
209 |
if the application generates postscript." |
|
160 | 210 |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
211 |
^ self basicNew initialize setNative; startPrint. |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
212 |
! ! |
0 | 213 |
|
1220 | 214 |
!PrinterStream class methodsFor:'accessing-defaults'! |
0 | 215 |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
216 |
bottomMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
217 |
"return the bottomMargin (in inches). Here, no margin is supported, |
378 | 218 |
but its redefined in some printer classes" |
219 |
||
220 |
^ 0 |
|
221 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
222 |
"Created: 5.9.1996 / 21:37:49 / cg" |
378 | 223 |
! |
224 |
||
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
225 |
defaultCommands |
571 | 226 |
"UNIX only: |
227 |
return a list presented as possible commands for printing |
|
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
228 |
(in the launchers printer configuration). |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
229 |
This list can be set from the startup script with: |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
230 |
PrinterStream defaultCommands:#( ... )" |
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
231 |
|
370 | 232 |
DefaultCommands isNil ifTrue:[ |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
233 |
self == PrinterStream ifFalse:[ |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
234 |
^ self superclass defaultCommands |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
235 |
] |
370 | 236 |
]. |
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
237 |
^ DefaultCommands |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
238 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
239 |
"Created: 23.4.1996 / 18:25:18 / cg" |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
240 |
! |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
241 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
242 |
defaultCommands:collectionOfCommandStrings |
571 | 243 |
"UNIX only: |
244 |
set the list which will be presented as possible commands for printing. |
|
367 | 245 |
(shown in in the launchers printer configuration). |
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
246 |
This can be done from the startup script with: |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
247 |
PrinterStream defaultCommands:#( ... )" |
247
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
248 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
249 |
DefaultCommands := collectionOfCommandStrings |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
250 |
|
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
251 |
"Created: 23.4.1996 / 18:26:06 / cg" |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
252 |
! |
d1e5c0187e59
keep defaultCommands in a classVar
Claus Gittinger <cg@exept.de>
parents:
235
diff
changeset
|
253 |
|
571 | 254 |
defaultDevices |
255 |
"VMS only: |
|
256 |
return a list presented as possible devices for printers. |
|
257 |
(in the launchers printer configuration). |
|
258 |
This list can be set from the startup script with: |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
259 |
PrinterStream defaultDevices:#( ... )" |
571 | 260 |
|
261 |
DefaultDevices isNil ifTrue:[ |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
262 |
self == PrinterStream ifFalse:[ |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
263 |
^ self superclass defaultDevices |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
264 |
] |
571 | 265 |
]. |
266 |
^ DefaultDevices |
|
267 |
! |
|
268 |
||
269 |
defaultDevices:collectionOfDeviceNameStrings |
|
270 |
"VMS only: |
|
271 |
set the list which will be presented as possible devices for printing. |
|
272 |
(shown in in the launchers printer configuration). |
|
273 |
This can be done from the startup script with: |
|
274 |
PrinterStream defaultDevices:#( ... )" |
|
275 |
||
276 |
DefaultDevices := collectionOfDeviceNameStrings |
|
277 |
! |
|
278 |
||
367 | 279 |
defaultPageFormats |
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
280 |
"return a list of supported page formats. |
367 | 281 |
This list can be set from the startup script with: |
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
282 |
PrinterStream defaultPageFormats:#( ... )" |
367 | 283 |
|
370 | 284 |
DefaultPageFormats isNil ifTrue:[ |
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
285 |
self == PrinterStream ifFalse:[ |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
286 |
^ self superclass defaultPageFormats |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
287 |
] |
370 | 288 |
]. |
367 | 289 |
^ DefaultPageFormats |
290 |
||
291 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
292 |
"Modified: 11.9.1996 / 11:17:44 / stefan" |
367 | 293 |
! |
294 |
||
295 |
defaultPageFormats:aList |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
296 |
"set the list of supported page formats. |
367 | 297 |
(shown in in the launchers printer configuration). |
298 |
This list can be set from the startup script with: |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
299 |
PrinterStream defaultPageFormats:#( ... ). |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
300 |
All symbols must be known by UnitConverter" |
367 | 301 |
|
302 |
DefaultPageFormats := aList. |
|
303 |
||
304 |
"/ validate the list |
|
305 |
aList do:[:name | |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
306 |
|unit ok| |
367 | 307 |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
308 |
ok := true. |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
309 |
#('W' 'H' 'lW' 'lH') do:[:what | |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
310 |
unit := (name , what) asSymbolIfInterned. |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
311 |
(unit isNil |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
312 |
or:[(UnitConverter convert:1 from:unit to:#millimeter) isNil]) ifTrue:[ |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
313 |
ok := false |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
314 |
] |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
315 |
]. |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
316 |
ok ifFalse:[ |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
317 |
('PRINTER: UnitConverter has no size-info for ''' , name , '''-format') errorPrintCR |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
318 |
] |
367 | 319 |
]. |
320 |
||
321 |
" |
|
322 |
PrinterStream |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
323 |
defaultPageFormats:#( |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
324 |
'letter' |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
325 |
'a4' |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
326 |
'a5' |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
327 |
'a6' |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
328 |
) |
367 | 329 |
" |
330 |
||
331 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
332 |
"Modified: 11.9.1996 / 11:19:01 / stefan" |
367 | 333 |
! |
334 |
||
1779 | 335 |
defaultPrinter |
336 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
337 |
WinPrinterStream notNil ifTrue:[ |
|
338 |
^ WinPrinterStream |
|
339 |
]. |
|
340 |
]. |
|
341 |
||
342 |
^ PrinterStream |
|
343 |
||
344 |
" |
|
345 |
self defaultPrinter |
|
346 |
" |
|
347 |
||
348 |
"Created: / 25-10-2006 / 17:36:21 / cg" |
|
349 |
! |
|
350 |
||
367 | 351 |
landscape |
352 |
"return the landscape setting" |
|
353 |
||
370 | 354 |
Landscape isNil ifTrue:[ |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
355 |
self == PrinterStream ifFalse:[ |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
356 |
^ self superclass landscape |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
357 |
] |
370 | 358 |
]. |
367 | 359 |
^ Landscape |
360 |
! |
|
361 |
||
362 |
landscape:aBoolean |
|
363 |
"set/clear landscape printing" |
|
364 |
||
373 | 365 |
Landscape := aBoolean. |
366 |
self reInitPage. |
|
367 |
||
368 |
"Modified: 1.6.1996 / 00:49:22 / cg" |
|
367 | 369 |
! |
370 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
371 |
leftMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
372 |
"return the leftMargin (in inches). Here, no margin is supported, |
378 | 373 |
but its redefined in some printer classes" |
374 |
||
375 |
^ 0 |
|
376 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
377 |
"Created: 5.9.1996 / 21:37:49 / cg" |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
378 |
"Modified: 5.9.1996 / 21:39:55 / cg" |
0 | 379 |
! |
380 |
||
367 | 381 |
pageFormat |
382 |
"return a symbol describing the default page format. |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
383 |
This can be set from the startup script with: |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
384 |
PrinterStream pageFormat:#... |
367 | 385 |
or via the launchers settings menu." |
386 |
||
370 | 387 |
PageFormat isNil ifTrue:[ |
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
388 |
self == PrinterStream ifFalse:[ |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
389 |
^ self superclass pageFormat |
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
390 |
] |
370 | 391 |
]. |
367 | 392 |
^ PageFormat |
393 |
||
394 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
395 |
"Modified: 11.9.1996 / 11:16:51 / stefan" |
367 | 396 |
! |
397 |
||
398 |
pageFormat:aSymbol |
|
399 |
"set the the default page format to be aSymbol. |
|
400 |
Valid symbols are #letter, #a4, #a5 etc. |
|
401 |
The UnitConverter must contain width/height information on |
|
402 |
that symbol, in order for printing to be correct. |
|
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
403 |
" |
367 | 404 |
|
373 | 405 |
PageFormat := aSymbol. |
406 |
self reInitPage. |
|
367 | 407 |
|
408 |
"Created: 23.4.1996 / 18:25:18 / cg" |
|
373 | 409 |
"Modified: 1.6.1996 / 00:49:06 / cg" |
443
2c85dbf33207
Fix documentation (mostly typos).
Stefan Vogel <sv@exept.de>
parents:
442
diff
changeset
|
410 |
"Modified: 11.9.1996 / 11:16:04 / stefan" |
367 | 411 |
! |
412 |
||
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
413 |
printCommand |
571 | 414 |
"UNIX only: |
415 |
return the command used for printing (usually 'lp' or 'lpr'). |
|
367 | 416 |
This is either set from the startup file, or via the launchers |
417 |
settings menu." |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
418 |
|
370 | 419 |
PrintCommand isNil ifTrue:[ |
1317 | 420 |
self ~~ PrinterStream ifTrue:[ |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
421 |
^ self superclass printCommand |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
422 |
] |
370 | 423 |
]. |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
424 |
^ PrintCommand |
348 | 425 |
|
426 |
"Modified: 18.5.1996 / 09:12:35 / cg" |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
427 |
! |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
428 |
|
126 | 429 |
printCommand:aString |
571 | 430 |
"UNIX only: |
431 |
set the command for printing (usually 'lp' or 'lpr'). |
|
367 | 432 |
This is either set from the startup file, or via the launchers |
433 |
settings menu." |
|
126 | 434 |
|
435 |
PrintCommand := aString |
|
139 | 436 |
|
437 |
" |
|
438 |
PrinterStream printCommand:'lpr' |
|
439 |
PrinterStream printCommand:'lpr -h' |
|
440 |
PrinterStream printCommand:'rsh ibm lpr -h' |
|
441 |
PrinterStream printCommand:'gs -sDEVICE=djet500 -sOutputFile=/tmp/stx.ps -sPAPERSIZE=a4 -q -; cat /tmp/stx.ps | rsh ibm lpr -h' |
|
442 |
" |
|
348 | 443 |
|
444 |
"Modified: 18.5.1996 / 09:12:48 / cg" |
|
378 | 445 |
! |
446 |
||
571 | 447 |
printDevice |
448 |
"VMS only: return the device for printing (usually 'sys$print:') |
|
449 |
This is either set from the startup file, or via the launchers |
|
450 |
settings menu." |
|
451 |
||
452 |
PrintDevice isNil ifTrue:[ |
|
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
453 |
self == PrinterStream ifFalse:[ |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
454 |
^ self superclass printDevice |
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
455 |
] |
571 | 456 |
]. |
457 |
^ PrintDevice |
|
458 |
! |
|
459 |
||
460 |
printDevice:aString |
|
461 |
"VMS only: |
|
462 |
set the device for printing (usually 'sys$print:'). |
|
463 |
This is either set from the startup file, or via the launchers |
|
464 |
settings menu." |
|
465 |
||
466 |
PrintCommand := aString |
|
467 |
||
468 |
" |
|
469 |
PrinterStream printDevice:'lta1739:' |
|
470 |
" |
|
471 |
! |
|
472 |
||
1317 | 473 |
printFilename |
474 |
"UNIX only: |
|
475 |
return the file into which the print-document should be generated. |
|
476 |
If nil (the default), printOut is piped through printCommand, |
|
477 |
which is usually a variant of the lpr-command." |
|
478 |
||
479 |
^ PrintFilename |
|
480 |
||
481 |
" |
|
482 |
PrinterStream printFilename |
|
483 |
" |
|
484 |
! |
|
485 |
||
486 |
printFilename:aString |
|
487 |
"UNIX only: |
|
488 |
set the output file for printing. If non nil, printout goes into that file. |
|
489 |
If nil, it is piped through printCommand. |
|
490 |
This is either set from the startup file, or via the launchers settings menu." |
|
491 |
||
492 |
PrintFilename := aString |
|
493 |
||
494 |
" |
|
495 |
PrinterStream printFilename:'/tmp/out.ps' |
|
496 |
" |
|
497 |
! |
|
498 |
||
456 | 499 |
rightMargin |
500 |
"return the rightMargin (in inches). Here, no margin is supported, |
|
501 |
but its redefined in some printer classes" |
|
502 |
||
503 |
^ 0 |
|
504 |
||
505 |
"Modified: 5.9.1996 / 21:39:55 / cg" |
|
506 |
"Created: 6.11.1996 / 15:40:12 / cg" |
|
507 |
! |
|
508 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
509 |
topMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
510 |
"return the topMargin (in inches). Here, no margin is supported, |
378 | 511 |
but its redefined in some printer classes" |
512 |
||
513 |
^ 0 |
|
514 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
515 |
"Created: 5.9.1996 / 21:40:13 / cg" |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
516 |
! ! |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
517 |
|
456 | 518 |
!PrinterStream class methodsFor:'queries'! |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
519 |
|
1774 | 520 |
isDrivenByCommand |
521 |
"return true if this printer is driven via an OS-command |
|
522 |
(as opposed to writing a file or using a native printing API)" |
|
523 |
||
524 |
^ true |
|
525 |
||
526 |
"Created: / 10-10-2006 / 18:12:47 / cg" |
|
527 |
! |
|
528 |
||
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
529 |
printerTypeName |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
530 |
"return a descriptive name" |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
531 |
|
1906 | 532 |
^ 'Dumb Printer (or Filter Program)' |
533 |
"/ ^ 'dumb printer (or print filter)' |
|
235 | 534 |
|
1906 | 535 |
"Modified: / 08-11-2007 / 12:09:16 / cg" |
139 | 536 |
! |
537 |
||
383 | 538 |
supportsColor |
539 |
"return true if this is a color printer" |
|
540 |
||
541 |
^ false |
|
542 |
||
543 |
"Created: 3.6.1996 / 18:00:36 / cg" |
|
544 |
! |
|
545 |
||
378 | 546 |
supportsMargins |
383 | 547 |
"return true if this printer supports margin settings (in inches) |
548 |
if not, it supports at least a leftMargin to be specified in columns." |
|
378 | 549 |
|
550 |
^ false |
|
551 |
||
552 |
"Created: 3.6.1996 / 10:47:54 / cg" |
|
383 | 553 |
"Modified: 3.6.1996 / 18:24:20 / cg" |
378 | 554 |
! |
555 |
||
368
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
556 |
supportsPageSizes |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
557 |
"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
|
558 |
|
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
559 |
^ false |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
560 |
|
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
561 |
"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
|
562 |
! |
423cf3f4e522
added query if printer supports pages at all (only PS does)
Claus Gittinger <cg@exept.de>
parents:
367
diff
changeset
|
563 |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
564 |
supportsPostscript |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
565 |
"return true if this is a postscript printer" |
139 | 566 |
|
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
567 |
^ false |
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
568 |
|
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
569 |
"Created: 10.2.1996 / 16:23:07 / cg" |
1774 | 570 |
! |
571 |
||
1990
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
572 |
supportsPrintingToCommand |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
573 |
^ true |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
574 |
! |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
575 |
|
1774 | 576 |
supportsPrintingToFile |
577 |
^ true |
|
578 |
||
579 |
"Created: / 10-10-2006 / 18:27:10 / cg" |
|
126 | 580 |
! ! |
0 | 581 |
|
879 | 582 |
!PrinterStream methodsFor:'access-writing'! |
126 | 583 |
|
1318 | 584 |
flush |
585 |
stream flush |
|
586 |
! |
|
587 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
588 |
next:count put:aCharacter |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
589 |
"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
|
590 |
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
|
591 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
592 |
count timesRepeat:[ |
1109
3dd9d0a420a1
Default entry for pdf file generation.
Stefan Vogel <sv@exept.de>
parents:
1107
diff
changeset
|
593 |
self nextPut:aCharacter |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
594 |
] |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
595 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
596 |
"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
|
597 |
"Modified: 10.4.1996 / 13:09:06 / cg" |
126 | 598 |
! |
599 |
||
1317 | 600 |
nextPut:aCharacter |
601 |
"send a character to the printer" |
|
602 |
||
1622 | 603 |
self nextPutUntranslated:aCharacter |
1317 | 604 |
! |
605 |
||
126 | 606 |
nextPutAll:aCollection |
348 | 607 |
"send some characters to the printer - translate as needed. |
608 |
The argument, aCollection can be a Text (i.e. include emphasis)" |
|
126 | 609 |
|
381
9afd4993bc24
avoid #emphasis: messages if there is no change
Claus Gittinger <cg@exept.de>
parents:
379
diff
changeset
|
610 |
|lastE| |
9afd4993bc24
avoid #emphasis: messages if there is no change
Claus Gittinger <cg@exept.de>
parents:
379
diff
changeset
|
611 |
|
913
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
612 |
native == true ifTrue:[ |
1317 | 613 |
stream nextPutAll:aCollection. |
614 |
^ self. |
|
913
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
615 |
]. |
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
616 |
|
348 | 617 |
aCollection hasChangeOfEmphasis ifTrue:[ |
392 | 618 |
aCollection keysAndValuesDo:[:idx :aChar | |
619 |
|e| |
|
381
9afd4993bc24
avoid #emphasis: messages if there is no change
Claus Gittinger <cg@exept.de>
parents:
379
diff
changeset
|
620 |
|
392 | 621 |
e := aCollection emphasisAt:idx. |
622 |
(idx == 1 |
|
623 |
or:[lastE ~~ e]) ifTrue:[ |
|
624 |
self emphasis:e. |
|
625 |
lastE := e. |
|
626 |
]. |
|
627 |
self nextPut:aChar. |
|
628 |
]. |
|
629 |
self emphasis:nil. |
|
348 | 630 |
] ifFalse:[ |
392 | 631 |
aCollection do:[:aChar | |
632 |
self nextPut:aChar |
|
633 |
] |
|
126 | 634 |
] |
348 | 635 |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
636 |
"Modified: 3.6.1996 / 17:12:31 / cg" |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
637 |
! |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
638 |
|
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
639 |
nextPutAll:aCollection startingAt:first to:last |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
640 |
"append the elements with index from first to last |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
641 |
of the argument, aCollection onto the receiver. |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
642 |
This is only allowed, if the receiver supports writing." |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
643 |
|
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
644 |
aCollection from:first to:last do:[:element | |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
645 |
self nextPut:element |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
646 |
]. |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
647 |
^ aCollection |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
648 |
! |
126 | 649 |
|
650 |
nextPutAllUntranslated:aCollection |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
651 |
"send some raw characters to the printer - even if not in native mode" |
126 | 652 |
|
1317 | 653 |
stream nextPutAll:aCollection |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
654 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
655 |
"Modified: 10.4.1996 / 13:08:35 / cg" |
126 | 656 |
! |
657 |
||
468 | 658 |
nextPutLine:aCollection |
659 |
self nextPutAll:aCollection. |
|
660 |
self cr |
|
661 |
||
662 |
"Created: 3.1.1997 / 19:43:56 / cg" |
|
663 |
! |
|
664 |
||
126 | 665 |
nextPutUntranslated:aCharacter |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
666 |
"send a raw character to the printer - even if not in native mode" |
126 | 667 |
|
1317 | 668 |
stream nextPut:aCharacter |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
669 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
670 |
"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
|
671 |
! ! |
0 | 672 |
|
348 | 673 |
!PrinterStream methodsFor:'emphasis change'! |
674 |
||
675 |
bold |
|
676 |
"set emphasis to bold |
|
677 |
- ignore here, since this class does not know anything about the printer" |
|
678 |
||
679 |
^ self |
|
680 |
||
681 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
682 |
! |
|
683 |
||
684 |
boldItalic |
|
685 |
"set emphasis to boldItalic |
|
686 |
- ignore here, since this class does not know anything about the printer" |
|
687 |
||
688 |
^ self |
|
689 |
||
690 |
"Created: 14.5.1996 / 18:53:43 / cg" |
|
691 |
"Modified: 18.5.1996 / 08:55:14 / cg" |
|
692 |
! |
|
693 |
||
694 |
emphasis:anEmphasis |
|
695 |
"change the emphasis" |
|
696 |
||
392 | 697 |
|b i| |
698 |
||
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
699 |
(Text emphasis:anEmphasis includes:#underline) ifTrue:[ |
392 | 700 |
underline ifFalse:[ |
701 |
self underline |
|
702 |
] |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
703 |
] ifFalse:[ |
392 | 704 |
underline ifTrue:[ |
705 |
self noUnderline |
|
706 |
] |
|
348 | 707 |
]. |
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
708 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
709 |
(Text emphasis:anEmphasis includes:#strikeout) ifTrue:[ |
392 | 710 |
strikeout ifFalse:[ |
711 |
self strikeout |
|
712 |
] |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
713 |
] ifFalse:[ |
392 | 714 |
strikeout ifTrue:[ |
715 |
self noStrikeout |
|
716 |
] |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
717 |
]. |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
718 |
|
392 | 719 |
b := (Text emphasis:anEmphasis includes:#bold). |
720 |
i := (Text emphasis:anEmphasis includes:#italic). |
|
721 |
||
722 |
b ifTrue:[ |
|
723 |
i ifTrue:[ |
|
724 |
^ self boldItalic |
|
725 |
] ifFalse:[ |
|
726 |
^ self bold |
|
727 |
] |
|
728 |
] ifFalse:[ |
|
729 |
i ifTrue:[ |
|
730 |
^ self italic |
|
731 |
] |
|
349 | 732 |
]. |
348 | 733 |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
734 |
^ self normal |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
735 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
736 |
"Modified: 8.6.1996 / 08:15:00 / cg" |
348 | 737 |
! |
738 |
||
739 |
italic |
|
740 |
"set emphasis to italic |
|
741 |
- ignore here, since this class does not know anything about the printer" |
|
742 |
||
743 |
^ self |
|
744 |
||
745 |
"Modified: 18.5.1996 / 08:55:18 / cg" |
|
746 |
! |
|
747 |
||
392 | 748 |
noStrikeout |
749 |
"set emphasis to no strikeout |
|
750 |
- ignore here, since this class does not know anything about the printer" |
|
751 |
||
752 |
^ self |
|
753 |
||
754 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
755 |
"Created: 8.6.1996 / 08:15:20 / cg" |
|
756 |
! |
|
757 |
||
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
758 |
noUnderline |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
759 |
"set emphasis to no underline |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
760 |
- ignore here, since this class does not know anything about the printer" |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
761 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
762 |
^ self |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
763 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
764 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
765 |
"Created: 8.6.1996 / 08:15:12 / cg" |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
766 |
! |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
767 |
|
348 | 768 |
normal |
769 |
"set emphasis to normal (non-bold, non-italic) |
|
770 |
- ignore here, since this class does not know anything about the printer" |
|
771 |
||
772 |
^ self |
|
773 |
||
774 |
"Modified: 18.5.1996 / 08:55:21 / cg" |
|
775 |
! |
|
776 |
||
777 |
strikeout |
|
778 |
"set emphasis to strikeout |
|
779 |
- ignore here, since this class does not know anything about the printer" |
|
780 |
||
781 |
^ self |
|
782 |
||
783 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
784 |
"Created: 18.5.1996 / 08:56:13 / cg" |
|
785 |
! |
|
786 |
||
787 |
underline |
|
788 |
"set emphasis to underline |
|
789 |
- ignore here, since this class does not know anything about the printer" |
|
790 |
||
791 |
^ self |
|
792 |
||
793 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
794 |
"Created: 18.5.1996 / 08:56:24 / cg" |
|
795 |
! ! |
|
796 |
||
797 |
!PrinterStream methodsFor:'font change'! |
|
798 |
||
799 |
courier |
|
800 |
"set font to courier |
|
801 |
- ignore here, since this class does not know anything about the printer" |
|
802 |
||
803 |
^ self |
|
804 |
! |
|
805 |
||
806 |
helvetica |
|
807 |
"set font to helvetic |
|
808 |
- ignore here, since this class does not know anything about the printer" |
|
809 |
||
810 |
^ self |
|
811 |
! |
|
812 |
||
813 |
times |
|
814 |
"set font to times |
|
815 |
- ignore here, since this class does not know anything about the printer" |
|
816 |
||
817 |
^ self |
|
818 |
! ! |
|
819 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
820 |
!PrinterStream methodsFor:'helpers writing'! |
6 | 821 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
822 |
escape:aCharacter |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
823 |
"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
|
824 |
|
1317 | 825 |
stream nextPut:(Character esc); nextPut:aCharacter |
126 | 826 |
! |
827 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
828 |
escapeAll:aString |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
829 |
"since its so common, this method sends escape followed by aString" |
126 | 830 |
|
1317 | 831 |
stream nextPut:(Character esc); nextPutAll:aString |
0 | 832 |
! ! |
126 | 833 |
|
367 | 834 |
!PrinterStream methodsFor:'initialization'! |
835 |
||
836 |
initialize |
|
914 | 837 |
pageFormat := DefaultPageFormat. |
367 | 838 |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
839 |
"Created: 31.5.1996 / 20:14:36 / cg" |
1317 | 840 |
! |
841 |
||
842 |
printCommand |
|
843 |
^ self class printCommand |
|
844 |
! |
|
845 |
||
1774 | 846 |
printJobName:aString |
847 |
"ignored here - some subclass might implement this" |
|
848 |
||
849 |
"Created: / 10-10-2006 / 18:52:29 / cg" |
|
850 |
! |
|
851 |
||
1317 | 852 |
stream:aStream |
853 |
stream notNil ifTrue:[ |
|
854 |
self error |
|
855 |
]. |
|
856 |
stream := aStream. |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
857 |
! ! |
367 | 858 |
|
126 | 859 |
!PrinterStream methodsFor:'open/close'! |
860 |
||
160 | 861 |
basicClose |
1317 | 862 |
stream close |
160 | 863 |
! |
864 |
||
126 | 865 |
close |
866 |
self endPrint. |
|
1777 | 867 |
stream notNil ifTrue:[ stream close ] |
868 |
||
869 |
"Modified: / 12-10-2006 / 14:58:43 / User" |
|
126 | 870 |
! |
871 |
||
872 |
endPrint |
|
873 |
^ self |
|
874 |
! |
|
875 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
876 |
setNative |
913
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
877 |
self setNative:true |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
878 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
879 |
! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
880 |
|
362 | 881 |
setNative:aBoolean |
882 |
native := aBoolean |
|
883 |
||
884 |
"Created: 30.5.1996 / 17:49:09 / cg" |
|
885 |
! |
|
886 |
||
126 | 887 |
startPrint |
1317 | 888 |
stream isNil ifTrue:[ |
889 |
stream := PipeStream basicNew. |
|
890 |
||
891 |
stream |
|
892 |
openPipeFor:(self class printCommand) |
|
893 |
withMode:'w' |
|
894 |
errorDisposition:#stderr |
|
895 |
inDirectory:nil. |
|
896 |
]. |
|
370 | 897 |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
898 |
"Modified: / 26.5.1999 / 16:14:57 / cg" |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
899 |
! ! |
126 | 900 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
901 |
!PrinterStream methodsFor:'queries'! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
902 |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
903 |
bottomMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
904 |
^ self class bottomMargin |
383 | 905 |
|
906 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
907 |
"Created: 5.9.1996 / 21:37:26 / cg" |
383 | 908 |
! |
909 |
||
379 | 910 |
isPrinterStream |
911 |
"return true, if this is a printerStream. |
|
912 |
Always true here." |
|
913 |
||
914 |
^ true |
|
915 |
||
916 |
"Created: 3.6.1996 / 12:06:21 / cg" |
|
917 |
! |
|
918 |
||
627 | 919 |
landscape |
920 |
^ self class landscape |
|
921 |
||
922 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
923 |
"Created: 5.9.1996 / 21:38:23 / cg" |
|
924 |
! |
|
925 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
926 |
leftMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
927 |
^ self class leftMargin |
383 | 928 |
|
929 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
930 |
"Created: 5.9.1996 / 21:38:23 / cg" |
383 | 931 |
! |
932 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
933 |
lineLength |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
934 |
"the printer pages width (in characters)" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
935 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
936 |
^ 80 |
383 | 937 |
! |
938 |
||
939 |
pageFormat |
|
940 |
^ self class pageFormat |
|
941 |
||
942 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
943 |
! |
|
944 |
||
437 | 945 |
rightMargin |
946 |
^ self class rightMargin |
|
947 |
||
948 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
949 |
"Created: 5.9.1996 / 21:38:23 / cg" |
|
950 |
! |
|
951 |
||
383 | 952 |
supportsColor |
953 |
"return true if this is a color printer" |
|
954 |
||
955 |
^ self class supportsColor |
|
956 |
||
957 |
"Created: 3.6.1996 / 18:00:27 / cg" |
|
958 |
! |
|
959 |
||
960 |
supportsMargins |
|
961 |
"return true if this printer supports margin settings (in inches) |
|
962 |
if not, it supports at least a leftMargin to be specified in columns." |
|
963 |
||
964 |
^ self class supportsMargins |
|
965 |
||
966 |
"Created: 3.6.1996 / 17:59:35 / cg" |
|
967 |
"Modified: 3.6.1996 / 18:24:04 / cg" |
|
968 |
! |
|
969 |
||
970 |
supportsPostscript |
|
971 |
"return true if this is a postscript printer" |
|
972 |
||
973 |
^ self class supportsPostscript |
|
974 |
||
975 |
"Created: 3.6.1996 / 17:59:58 / cg" |
|
976 |
! |
|
977 |
||
1990
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
978 |
supportsPrintingToCommand |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
979 |
^ self class supportsPrintingToCommand |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
980 |
! |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
981 |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
982 |
topMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
983 |
^ self class topMargin |
383 | 984 |
|
985 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
986 |
"Created: 5.9.1996 / 21:40:32 / cg" |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
987 |
! ! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
988 |
|
456 | 989 |
!PrinterStream class methodsFor:'documentation'! |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
990 |
|
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
991 |
version |
1990
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
992 |
^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.67 2008-05-13 12:33:24 cg Exp $' |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
993 |
! ! |
1107 | 994 |
|
126 | 995 |
PrinterStream initialize! |