author | Stefan Vogel <sv@exept.de> |
Thu, 06 Nov 2008 11:59:07 +0100 | |
changeset 2050 | bf12f977da5f |
parent 1991 | d0d1eb17e990 |
child 2108 | f97621cb3cf7 |
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 |
|
2050 | 610 |
native ifTrue:[ |
1317 | 611 |
stream nextPutAll:aCollection. |
612 |
^ self. |
|
913
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
613 |
]. |
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
614 |
|
348 | 615 |
aCollection hasChangeOfEmphasis ifTrue:[ |
2050 | 616 |
self nextPutAllText:aCollection. |
348 | 617 |
] ifFalse:[ |
2050 | 618 |
aCollection do:[:eachChar | |
619 |
self nextPut:eachChar |
|
392 | 620 |
] |
126 | 621 |
] |
348 | 622 |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
623 |
"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
|
624 |
! |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
625 |
|
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
626 |
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
|
627 |
"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
|
628 |
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
|
629 |
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
|
630 |
|
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
631 |
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
|
632 |
self nextPut:element |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
633 |
]. |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
634 |
^ aCollection |
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
635 |
! |
126 | 636 |
|
2050 | 637 |
nextPutAllText:aText |
638 |
"send some characters to the printer - translate as needed. |
|
639 |
The argument is a String or Text (i.e. includes emphasis)" |
|
640 |
||
641 |
|lastE| |
|
642 |
||
643 |
native ifTrue:[ |
|
644 |
stream nextPutAllText:aText. |
|
645 |
^ self. |
|
646 |
]. |
|
647 |
||
648 |
lastE := 42. "initialize to something that is not a valid emphasis" |
|
649 |
||
650 |
aText keysAndValuesDo:[:idx :aChar | |
|
651 |
|e| |
|
652 |
||
653 |
e := aText emphasisAt:idx. |
|
654 |
lastE ~~ e ifTrue:[ |
|
655 |
self emphasis:e. |
|
656 |
lastE := e. |
|
657 |
]. |
|
658 |
self nextPut:aChar. |
|
659 |
]. |
|
660 |
self emphasis:nil. |
|
661 |
||
662 |
"Modified: 3.6.1996 / 17:12:31 / cg" |
|
663 |
! |
|
664 |
||
126 | 665 |
nextPutAllUntranslated:aCollection |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
666 |
"send some raw characters to the printer - even if not in native mode" |
126 | 667 |
|
1317 | 668 |
stream nextPutAll:aCollection |
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:35 / cg" |
126 | 671 |
! |
672 |
||
468 | 673 |
nextPutLine:aCollection |
674 |
self nextPutAll:aCollection. |
|
675 |
self cr |
|
676 |
||
677 |
"Created: 3.1.1997 / 19:43:56 / cg" |
|
678 |
! |
|
679 |
||
126 | 680 |
nextPutUntranslated:aCharacter |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
681 |
"send a raw character to the printer - even if not in native mode" |
126 | 682 |
|
1317 | 683 |
stream nextPut:aCharacter |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
684 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
685 |
"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
|
686 |
! ! |
0 | 687 |
|
348 | 688 |
!PrinterStream methodsFor:'emphasis change'! |
689 |
||
690 |
bold |
|
691 |
"set emphasis to bold |
|
692 |
- ignore here, since this class does not know anything about the printer" |
|
693 |
||
694 |
^ self |
|
695 |
||
696 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
697 |
! |
|
698 |
||
699 |
boldItalic |
|
700 |
"set emphasis to boldItalic |
|
701 |
- ignore here, since this class does not know anything about the printer" |
|
702 |
||
703 |
^ self |
|
704 |
||
705 |
"Created: 14.5.1996 / 18:53:43 / cg" |
|
706 |
"Modified: 18.5.1996 / 08:55:14 / cg" |
|
707 |
! |
|
708 |
||
709 |
emphasis:anEmphasis |
|
710 |
"change the emphasis" |
|
711 |
||
392 | 712 |
|b i| |
713 |
||
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
714 |
(Text emphasis:anEmphasis includes:#underline) ifTrue:[ |
392 | 715 |
underline ifFalse:[ |
716 |
self underline |
|
717 |
] |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
718 |
] ifFalse:[ |
392 | 719 |
underline ifTrue:[ |
720 |
self noUnderline |
|
721 |
] |
|
348 | 722 |
]. |
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
723 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
724 |
(Text emphasis:anEmphasis includes:#strikeout) ifTrue:[ |
392 | 725 |
strikeout ifFalse:[ |
726 |
self strikeout |
|
727 |
] |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
728 |
] ifFalse:[ |
392 | 729 |
strikeout ifTrue:[ |
730 |
self noStrikeout |
|
731 |
] |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
732 |
]. |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
733 |
|
392 | 734 |
b := (Text emphasis:anEmphasis includes:#bold). |
735 |
i := (Text emphasis:anEmphasis includes:#italic). |
|
736 |
||
737 |
b ifTrue:[ |
|
738 |
i ifTrue:[ |
|
739 |
^ self boldItalic |
|
740 |
] ifFalse:[ |
|
741 |
^ self bold |
|
742 |
] |
|
743 |
] ifFalse:[ |
|
744 |
i ifTrue:[ |
|
745 |
^ self italic |
|
746 |
] |
|
349 | 747 |
]. |
348 | 748 |
|
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
749 |
^ self normal |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
750 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
751 |
"Modified: 8.6.1996 / 08:15:00 / cg" |
348 | 752 |
! |
753 |
||
754 |
italic |
|
755 |
"set emphasis to italic |
|
756 |
- ignore here, since this class does not know anything about the printer" |
|
757 |
||
758 |
^ self |
|
759 |
||
760 |
"Modified: 18.5.1996 / 08:55:18 / cg" |
|
761 |
! |
|
762 |
||
392 | 763 |
noStrikeout |
764 |
"set emphasis to no strikeout |
|
765 |
- ignore here, since this class does not know anything about the printer" |
|
766 |
||
767 |
^ self |
|
768 |
||
769 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
770 |
"Created: 8.6.1996 / 08:15:20 / cg" |
|
771 |
! |
|
772 |
||
390
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
773 |
noUnderline |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
774 |
"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
|
775 |
- 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
|
776 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
777 |
^ self |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
778 |
|
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
779 |
"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
|
780 |
"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
|
781 |
! |
3f22865fa873
fixed handling of underline; no longer affects bold/italic setting.
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
782 |
|
348 | 783 |
normal |
784 |
"set emphasis to normal (non-bold, non-italic) |
|
785 |
- ignore here, since this class does not know anything about the printer" |
|
786 |
||
787 |
^ self |
|
788 |
||
789 |
"Modified: 18.5.1996 / 08:55:21 / cg" |
|
790 |
! |
|
791 |
||
792 |
strikeout |
|
793 |
"set emphasis to strikeout |
|
794 |
- ignore here, since this class does not know anything about the printer" |
|
795 |
||
796 |
^ self |
|
797 |
||
798 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
799 |
"Created: 18.5.1996 / 08:56:13 / cg" |
|
800 |
! |
|
801 |
||
802 |
underline |
|
803 |
"set emphasis to underline |
|
804 |
- ignore here, since this class does not know anything about the printer" |
|
805 |
||
806 |
^ self |
|
807 |
||
808 |
"Modified: 18.5.1996 / 08:55:10 / cg" |
|
809 |
"Created: 18.5.1996 / 08:56:24 / cg" |
|
810 |
! ! |
|
811 |
||
812 |
!PrinterStream methodsFor:'font change'! |
|
813 |
||
814 |
courier |
|
815 |
"set font to courier |
|
816 |
- ignore here, since this class does not know anything about the printer" |
|
817 |
||
818 |
^ self |
|
819 |
! |
|
820 |
||
821 |
helvetica |
|
822 |
"set font to helvetic |
|
823 |
- ignore here, since this class does not know anything about the printer" |
|
824 |
||
825 |
^ self |
|
826 |
! |
|
827 |
||
828 |
times |
|
829 |
"set font to times |
|
830 |
- ignore here, since this class does not know anything about the printer" |
|
831 |
||
832 |
^ self |
|
833 |
! ! |
|
834 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
835 |
!PrinterStream methodsFor:'helpers writing'! |
6 | 836 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
837 |
escape:aCharacter |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
838 |
"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
|
839 |
|
1317 | 840 |
stream nextPut:(Character esc); nextPut:aCharacter |
126 | 841 |
! |
842 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
843 |
escapeAll:aString |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
844 |
"since its so common, this method sends escape followed by aString" |
126 | 845 |
|
1317 | 846 |
stream nextPut:(Character esc); nextPutAll:aString |
0 | 847 |
! ! |
126 | 848 |
|
367 | 849 |
!PrinterStream methodsFor:'initialization'! |
850 |
||
851 |
initialize |
|
2050 | 852 |
native := false. |
914 | 853 |
pageFormat := DefaultPageFormat. |
367 | 854 |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
855 |
"Created: 31.5.1996 / 20:14:36 / cg" |
1317 | 856 |
! |
857 |
||
858 |
printCommand |
|
859 |
^ self class printCommand |
|
860 |
! |
|
861 |
||
1774 | 862 |
printJobName:aString |
863 |
"ignored here - some subclass might implement this" |
|
864 |
||
865 |
"Created: / 10-10-2006 / 18:52:29 / cg" |
|
866 |
! |
|
867 |
||
1317 | 868 |
stream:aStream |
869 |
stream notNil ifTrue:[ |
|
870 |
self error |
|
871 |
]. |
|
872 |
stream := aStream. |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
873 |
! ! |
367 | 874 |
|
126 | 875 |
!PrinterStream methodsFor:'open/close'! |
876 |
||
160 | 877 |
basicClose |
1317 | 878 |
stream close |
160 | 879 |
! |
880 |
||
126 | 881 |
close |
882 |
self endPrint. |
|
1777 | 883 |
stream notNil ifTrue:[ stream close ] |
884 |
||
885 |
"Modified: / 12-10-2006 / 14:58:43 / User" |
|
126 | 886 |
! |
887 |
||
888 |
endPrint |
|
889 |
^ self |
|
890 |
! |
|
891 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
892 |
setNative |
913
99228537653d
Speed up native printing: #nextPutAll
Stefan Vogel <sv@exept.de>
parents:
879
diff
changeset
|
893 |
self setNative:true |
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
894 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
895 |
! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
896 |
|
362 | 897 |
setNative:aBoolean |
898 |
native := aBoolean |
|
899 |
||
900 |
"Created: 30.5.1996 / 17:49:09 / cg" |
|
901 |
! |
|
902 |
||
126 | 903 |
startPrint |
1317 | 904 |
stream isNil ifTrue:[ |
905 |
stream := PipeStream basicNew. |
|
906 |
||
907 |
stream |
|
908 |
openPipeFor:(self class printCommand) |
|
909 |
withMode:'w' |
|
910 |
errorDisposition:#stderr |
|
911 |
inDirectory:nil. |
|
912 |
]. |
|
370 | 913 |
|
1076
4bb0e9411317
Define #nextPutAll:startingAt:to: to fix Text>>printOn:aPrinterStream
Stefan Vogel <sv@exept.de>
parents:
914
diff
changeset
|
914 |
"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
|
915 |
! ! |
126 | 916 |
|
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
917 |
!PrinterStream methodsFor:'queries'! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
918 |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
919 |
bottomMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
920 |
^ self class bottomMargin |
383 | 921 |
|
922 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
923 |
"Created: 5.9.1996 / 21:37:26 / cg" |
383 | 924 |
! |
925 |
||
379 | 926 |
isPrinterStream |
927 |
"return true, if this is a printerStream. |
|
928 |
Always true here." |
|
929 |
||
930 |
^ true |
|
931 |
||
932 |
"Created: 3.6.1996 / 12:06:21 / cg" |
|
933 |
! |
|
934 |
||
627 | 935 |
landscape |
936 |
^ self class landscape |
|
937 |
||
938 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
939 |
"Created: 5.9.1996 / 21:38:23 / cg" |
|
940 |
! |
|
941 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
942 |
leftMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
943 |
^ self class leftMargin |
383 | 944 |
|
945 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
946 |
"Created: 5.9.1996 / 21:38:23 / cg" |
383 | 947 |
! |
948 |
||
221
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
949 |
lineLength |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
950 |
"the printer pages width (in characters)" |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
951 |
|
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
952 |
^ 80 |
383 | 953 |
! |
954 |
||
955 |
pageFormat |
|
956 |
^ self class pageFormat |
|
957 |
||
958 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
959 |
! |
|
960 |
||
437 | 961 |
rightMargin |
962 |
^ self class rightMargin |
|
963 |
||
964 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
965 |
"Created: 5.9.1996 / 21:38:23 / cg" |
|
966 |
! |
|
967 |
||
383 | 968 |
supportsColor |
969 |
"return true if this is a color printer" |
|
970 |
||
971 |
^ self class supportsColor |
|
972 |
||
973 |
"Created: 3.6.1996 / 18:00:27 / cg" |
|
974 |
! |
|
975 |
||
976 |
supportsMargins |
|
977 |
"return true if this printer supports margin settings (in inches) |
|
978 |
if not, it supports at least a leftMargin to be specified in columns." |
|
979 |
||
980 |
^ self class supportsMargins |
|
981 |
||
982 |
"Created: 3.6.1996 / 17:59:35 / cg" |
|
983 |
"Modified: 3.6.1996 / 18:24:04 / cg" |
|
984 |
! |
|
985 |
||
986 |
supportsPostscript |
|
987 |
"return true if this is a postscript printer" |
|
988 |
||
989 |
^ self class supportsPostscript |
|
990 |
||
991 |
"Created: 3.6.1996 / 17:59:58 / cg" |
|
992 |
! |
|
993 |
||
1990
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
994 |
supportsPrintingToCommand |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
995 |
^ self class supportsPrintingToCommand |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
996 |
! |
9594087e3a0a
+supportsPrintingToCommand query
Claus Gittinger <cg@exept.de>
parents:
1906
diff
changeset
|
997 |
|
1991 | 998 |
supportsPrintingToFile |
999 |
^ self class supportsPrintingToFile |
|
1000 |
! |
|
1001 |
||
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
1002 |
topMargin |
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
1003 |
^ self class topMargin |
383 | 1004 |
|
1005 |
"Modified: 3.6.1996 / 10:27:45 / cg" |
|
433
2b5b9df0981c
renamed *Inset to *Margin; cleanup.
Claus Gittinger <cg@exept.de>
parents:
392
diff
changeset
|
1006 |
"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
|
1007 |
! ! |
7bc2c2d89ede
added native setting (suppress trailer in PS-subclass)
Claus Gittinger <cg@exept.de>
parents:
211
diff
changeset
|
1008 |
|
456 | 1009 |
!PrinterStream class methodsFor:'documentation'! |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
1010 |
|
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
1011 |
version |
2050 | 1012 |
^ '$Header: /cvs/stx/stx/libbasic2/PrinterStream.st,v 1.69 2008-11-06 10:59:07 stefan Exp $' |
186
bc1b056b097c
added #supportsPostscript query
Claus Gittinger <cg@exept.de>
parents:
179
diff
changeset
|
1013 |
! ! |
1107 | 1014 |
|
126 | 1015 |
PrinterStream initialize! |