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