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