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