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