author | Stefan Vogel <sv@exept.de> |
Tue, 19 Jul 2016 21:45:55 +0200 | |
changeset 3709 | ae76cdc6787a |
parent 3315 | c51703ef04b6 |
child 3720 | f27814c1b52a |
child 3730 | 74c5a7f7a679 |
permissions | -rw-r--r-- |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
1 |
"{ Encoding: utf8 }" |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
2 |
|
2184 | 3 |
" |
4 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
5 |
All Rights Reserved |
2184 | 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 |
" |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
14 |
'From Smalltalk/X, Version:7.1.0.0 on 18-07-2016 at 13:47:02' ! |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
15 |
|
2143 | 16 |
"{ Package: 'stx:libview2' }" |
17 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
18 |
"{ NameSpace: Smalltalk }" |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
19 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
20 |
DeviceGraphicsContext subclass:#PrinterContext |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
21 |
instanceVariableNames:'abort jobid printerInfo textAlign' |
2143 | 22 |
classVariableNames:'' |
23 |
poolDictionaries:'' |
|
24 |
category:'Interface-Printing' |
|
25 |
! |
|
26 |
||
2184 | 27 |
!PrinterContext class methodsFor:'documentation'! |
28 |
||
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
32 |
All Rights Reserved |
2184 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
41 |
! |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
42 |
|
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
43 |
documentation |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
44 |
" |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
45 |
I am the mediator between the smalltalk printing protocol |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
46 |
(which is the same as the graphics drawing protocol) and the |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
47 |
windows printer. |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
48 |
When youopena printer, you will typically talk to me, and I will |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
49 |
forward the graphics commands to my printer. |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
50 |
|
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
51 |
[author:] |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
52 |
Felix Madrid (fm@exept.de) |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
53 |
" |
2184 | 54 |
! ! |
2143 | 55 |
|
56 |
!PrinterContext class methodsFor:'instance creation'! |
|
57 |
||
58 |
fromPrinterInfo: aPrinterInfo |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
59 |
self subclassResponsibility |
2143 | 60 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
61 |
"Modified: / 16-04-2007 / 12:56:56 / cg" |
2143 | 62 |
! ! |
63 |
||
64 |
!PrinterContext class methodsFor:'accessing'! |
|
65 |
||
66 |
default |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
67 |
"Answer the default Printer, or nil if none." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
68 |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
69 |
|defaultName| |
2143 | 70 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
71 |
^ (defaultName := self defaultPrinterName) isNil |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
72 |
ifTrue:[ nil ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
73 |
ifFalse:[ self named:defaultName ] |
2143 | 74 |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
75 |
" |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
76 |
self default |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
77 |
" |
2143 | 78 |
|
79 |
"Created: / 27-07-2006 / 17:51:43 / fm" |
|
80 |
"Modified: / 02-08-2006 / 17:27:09 / fm" |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
81 |
"Modified: / 10-10-2006 / 17:30:31 / cg" |
2143 | 82 |
! |
83 |
||
84 |
defaultMargins |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
85 |
"Private - answer aPoint containing the default horizontal and vertical |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
86 |
margins for a page (units in inches)." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
87 |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
88 |
^ 0.5 @ 0.75 |
2143 | 89 |
|
90 |
"Created: / 01-08-2006 / 16:09:31 / fm" |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
91 |
"Modified: / 10-10-2006 / 17:30:49 / cg" |
2143 | 92 |
! |
93 |
||
94 |
defaultPrinterName |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
95 |
"Answer the name of the default printer, or nil if none." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
96 |
|
2303 | 97 |
|printerInfo printerName| |
98 |
||
99 |
printerInfo := OperatingSystem getDefaultPrinterName. |
|
100 |
printerName := (printerInfo copyFrom:1 to:(printerInfo indexOf:$,) - 1) trimBlanks. |
|
101 |
^ printerName size == 0 ifTrue:[ nil ] ifFalse:[ printerName ] |
|
2143 | 102 |
|
2303 | 103 |
" |
104 |
PrinterContext defaultPrinterName |
|
105 |
" |
|
106 |
||
107 |
"Modified: / 02-08-2006 / 17:26:09 / fm" |
|
108 |
"Modified: / 10-10-2006 / 17:32:45 / cg" |
|
2143 | 109 |
! |
110 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
111 |
getPrinterInformation:printerNameString |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
112 |
" Answer the printer information for the printer named printerNameString. If no name is specified, |
2237 | 113 |
answer the information for the default printer." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
114 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
115 |
self subclassResponsibility |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
116 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
117 |
"Modified: / 16-04-2007 / 12:56:31 / cg" |
2143 | 118 |
! |
119 |
||
120 |
named: aName |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
121 |
"Answer a new instance of Printer which represents |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
122 |
the printer named aName as specified in the host |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
123 |
Control Panel." |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
124 |
|
2143 | 125 |
aName isNil ifTrue: [ ^self default ]. |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
126 |
^self new printerInfoWithName: aName |
2143 | 127 |
|
128 |
"Created: / 27-07-2006 / 17:51:27 / fm" |
|
129 |
"Modified: / 02-08-2006 / 17:26:29 / fm" |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
130 |
"Modified: / 10-10-2006 / 17:33:29 / cg" |
2143 | 131 |
! |
132 |
||
133 |
printerNames |
|
2237 | 134 |
"Answer a collection of all known printer names." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
135 |
|
2237 | 136 |
^ OperatingSystem getPrintersNames |
2143 | 137 |
|
138 |
"Created: / 27-07-2006 / 17:54:45 / fm" |
|
2237 | 139 |
"Modified: / 10-10-2006 / 18:57:51 / cg" |
2143 | 140 |
! ! |
141 |
||
142 |
!PrinterContext methodsFor:'abort handling'! |
|
143 |
||
144 |
abortPrintJob |
|
2236 | 145 |
"Abort the current print job." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
146 |
|
2143 | 147 |
abort := true. |
148 |
jobid := nil. |
|
149 |
||
150 |
"Modified: / 02-08-2006 / 15:40:26 / fm" |
|
2236 | 151 |
"Modified: / 10-10-2006 / 18:13:45 / cg" |
2143 | 152 |
! |
153 |
||
154 |
aborted |
|
2236 | 155 |
"Answer whether the user aborted from PrintAbortDialog." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
156 |
|
2236 | 157 |
^ abort |
2143 | 158 |
|
159 |
"Created: / 27-07-2006 / 10:20:10 / fm" |
|
2236 | 160 |
"Modified: / 10-10-2006 / 18:13:50 / cg" |
2143 | 161 |
! ! |
162 |
||
163 |
!PrinterContext methodsFor:'accessing'! |
|
164 |
||
2272 | 165 |
container |
166 |
||
167 |
^self |
|
168 |
! |
|
169 |
||
2143 | 170 |
getCharHeight |
2236 | 171 |
"Private - answer the height of the font selected in the receiver's |
172 |
device context." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
173 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
174 |
self subclassResponsibility |
2143 | 175 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
176 |
"Modified: / 16-04-2007 / 12:50:06 / cg" |
2143 | 177 |
! |
178 |
||
2272 | 179 |
horizontalPixelsPerMeter |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
180 |
"Answer horizontal pixels per meter on the screen." |
2272 | 181 |
^self pixelsPerInchOfScreenWidth * 39.3700787 |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
182 |
|
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
183 |
"Modified: / 16-04-2007 / 12:55:21 / cg" |
2272 | 184 |
! |
185 |
||
2236 | 186 |
name |
187 |
"Answer the receiver's name from the current printerInfo." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
188 |
|
2236 | 189 |
^ self printerInfo printerName |
2143 | 190 |
|
191 |
"Modified: / 02-08-2006 / 16:55:03 / fm" |
|
2236 | 192 |
"Modified: / 10-10-2006 / 18:15:33 / cg" |
2143 | 193 |
! |
194 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
195 |
name:aName |
2236 | 196 |
"Set the receiver's printer name to aName." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
197 |
|
2236 | 198 |
self printerInfo:(self class getPrinterInformation:aName) |
2143 | 199 |
|
2236 | 200 |
"Modified: / 10-10-2006 / 18:15:36 / cg" |
2143 | 201 |
! |
202 |
||
203 |
numberOfColorBitsPerPixel |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
204 |
self subclassResponsibility |
2143 | 205 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
206 |
"Modified: / 16-04-2007 / 12:51:15 / cg" |
2143 | 207 |
! |
208 |
||
2272 | 209 |
physicalOffsetX |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
210 |
self subclassResponsibility |
2272 | 211 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
212 |
"Modified: / 16-04-2007 / 12:54:23 / cg" |
2272 | 213 |
! |
214 |
||
215 |
physicalOffsetY |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
216 |
self subclassResponsibility |
2272 | 217 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
218 |
"Modified: / 16-04-2007 / 12:52:17 / cg" |
2272 | 219 |
! |
220 |
||
2143 | 221 |
pixelsPerInchOfScreenHeight |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
222 |
self subclassResponsibility |
2143 | 223 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
224 |
"Modified: / 16-04-2007 / 12:54:17 / cg" |
2143 | 225 |
! |
226 |
||
227 |
pixelsPerInchOfScreenWidth |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
228 |
self subclassResponsibility |
2143 | 229 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
230 |
"Modified: / 16-04-2007 / 12:54:15 / cg" |
2143 | 231 |
! |
232 |
||
2272 | 233 |
printerHeightArea |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
234 |
self subclassResponsibility |
2272 | 235 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
236 |
"Modified: / 16-04-2007 / 12:52:28 / cg" |
2272 | 237 |
! |
238 |
||
2143 | 239 |
printerInfo |
2236 | 240 |
^ printerInfo |
2143 | 241 |
|
242 |
"Created: / 02-08-2006 / 16:55:17 / fm" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
243 |
"Modified: / 16-04-2007 / 12:52:36 / cg" |
2143 | 244 |
! |
245 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
246 |
printerInfo:aPrinterInfo |
2143 | 247 |
printerInfo := aPrinterInfo |
248 |
||
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
249 |
"Modified: / 16-04-2007 / 12:54:07 / cg" |
2143 | 250 |
! |
251 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
252 |
printerInfoWithName:aName |
2236 | 253 |
self printerInfo:(self class getPrinterInformation:aName). |
2143 | 254 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
255 |
"Modified: / 16-04-2007 / 12:54:04 / cg" |
2143 | 256 |
! |
257 |
||
2272 | 258 |
printerPhysicalHeight |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
259 |
self subclassResponsibility |
2272 | 260 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
261 |
"Modified: / 16-04-2007 / 12:54:00 / cg" |
2272 | 262 |
! |
263 |
||
264 |
printerPhysicalWidth |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
265 |
self subclassResponsibility |
2272 | 266 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
267 |
"Modified: / 16-04-2007 / 12:53:56 / cg" |
2272 | 268 |
! |
269 |
||
2143 | 270 |
printerUserFriendlyName |
2236 | 271 |
"Answer the receiver's name from the current printerInfo." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
272 |
|
2236 | 273 |
^ self printerInfo userFriendlyName |
2143 | 274 |
|
275 |
"Created: / 03-08-2006 / 12:55:57 / fm" |
|
2236 | 276 |
"Modified: / 10-10-2006 / 18:18:55 / cg" |
2272 | 277 |
! |
278 |
||
279 |
printerWidthArea |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
280 |
self subclassResponsibility |
2272 | 281 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
282 |
"Modified: / 16-04-2007 / 12:53:51 / cg" |
2272 | 283 |
! |
284 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
285 |
setPrinterFont:aFont |
2273 | 286 |
|
287 |
self font: aFont |
|
288 |
||
289 |
"Created: / 27-11-2006 / 14:50:55 / User" |
|
290 |
! |
|
291 |
||
2272 | 292 |
setTextAlign:aNumber |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
293 |
textAlign :=aNumber. |
2272 | 294 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
295 |
"Modified: / 16-04-2007 / 12:53:26 / cg" |
2272 | 296 |
! |
297 |
||
298 |
setViewportOrg: aPoint |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
299 |
self subclassResponsibility |
2272 | 300 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
301 |
"Modified: / 16-04-2007 / 12:53:44 / cg" |
2272 | 302 |
! |
303 |
||
304 |
verticalPixelsPerMeter |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
305 |
"Answer vertical pixels per meter on the screen." |
2272 | 306 |
|
307 |
^self pixelsPerInchOfScreenHeight * 39.3700787 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
308 |
|
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
309 |
"Modified: / 16-04-2007 / 12:54:43 / cg" |
2143 | 310 |
! ! |
311 |
||
312 |
!PrinterContext methodsFor:'initialization & release'! |
|
313 |
||
314 |
buildPrinter |
|
2236 | 315 |
"Private - create all the operating system resources needed." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
316 |
|
2236 | 317 |
self |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
318 |
createDC; |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
319 |
initExtent |
2143 | 320 |
|
321 |
"Created: / 27-07-2006 / 10:20:36 / fm" |
|
322 |
"Modified: / 01-08-2006 / 15:57:49 / fm" |
|
2236 | 323 |
"Modified: / 10-10-2006 / 18:14:04 / cg" |
2143 | 324 |
! |
325 |
||
326 |
createDC |
|
2236 | 327 |
"Private - Create a device context for the receiver" |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
328 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
329 |
self subclassResponsibility |
2143 | 330 |
|
331 |
"Created: / 27-07-2006 / 10:21:05 / fm" |
|
332 |
"Modified: / 02-08-2006 / 17:30:47 / fm" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
333 |
"Modified: / 16-04-2007 / 12:49:22 / cg" |
2143 | 334 |
! |
335 |
||
336 |
initExtent |
|
337 |
"Private - init the width and height of GraphicsTool for the receiver." |
|
2272 | 338 |
|
3287 | 339 |
self graphicsDevice |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
340 |
width:self printerWidthArea; |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
341 |
height:self printerHeightArea. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
342 |
|
2143 | 343 |
|
344 |
"Modified: / 01-08-2006 / 16:14:49 / fm" |
|
2314 | 345 |
! |
346 |
||
347 |
releaseDC |
|
348 |
"Private - Closes the device context of the receiver" |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
349 |
|
2314 | 350 |
self subclassResponsibility |
351 |
||
352 |
"Created: / 27-07-2006 / 10:21:05 / fm" |
|
353 |
"Modified: / 02-08-2006 / 17:30:47 / fm" |
|
354 |
"Modified: / 16-04-2007 / 12:49:22 / cg" |
|
2143 | 355 |
! ! |
356 |
||
357 |
!PrinterContext methodsFor:'printing'! |
|
358 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
359 |
print:aString font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
2236 | 360 |
"Answer the receiver. Output the receiver string to |
361 |
the printer using aFont. A Print abort dialog box will be opened |
|
362 |
with aTitle. If collateBoolean is true, collate output, otherwise |
|
363 |
do not. Print copiesInteger copies of the specified string. If |
|
364 |
wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
365 |
Left, top, right & bottom margins are specified in inches in |
|
366 |
aMarginsRect." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
367 |
|
2247 | 368 |
|lines linesPerPage totalPage marginsRect firstPage abortDialog| |
2143 | 369 |
|
2236 | 370 |
jobid isNil ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
371 |
self startPrintJob:aTitle |
2236 | 372 |
]. |
373 |
abortDialog := PrintAbortDialog new open:aTitle printer:self. |
|
374 |
self font:aFont. |
|
375 |
marginsRect := self marginsRectangleFor:aMarginsRect. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
376 |
lines := self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
377 |
asArrayOfStringLines:aString |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
378 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
379 |
wordWrap:wordWrapBoolean. |
2247 | 380 |
linesPerPage := self linesPerPageFor: marginsRect. |
2236 | 381 |
totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
2143 | 382 |
firstPage := true. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
383 |
|
2143 | 384 |
"/ collateBoolean |
385 |
"/ ifTrue: [ |
|
386 |
"/ copiesInteger timesRepeat: [ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
387 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
388 |
1 to:totalPage do:[:page | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
389 |
abort ifTrue:[ ^ self ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
390 |
firstPage ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
391 |
self formFeed |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
392 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
393 |
abortDialog |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
394 |
updatePrintingPageInfo:(self class classResources |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
395 |
string:'Page %1/%2' |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
396 |
with:page printString |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
397 |
with:totalPage printString). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
398 |
|
2143 | 399 |
"/ self device font: printerFont. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
400 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
401 |
self font:aFont. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
402 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
403 |
printPage:page |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
404 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
405 |
lines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
406 |
linesPerPage:linesPerPage. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
407 |
firstPage := false |
2236 | 408 |
]. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
409 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
410 |
"/ ] |
2143 | 411 |
"/ ] ifFalse: [ |
412 |
"/ 1 to: totalPage do: [ :page | |
|
413 |
"/ copiesInteger timesRepeat: [ |
|
414 |
"/ abort ifTrue: [ ^self endPrintJob ]. |
|
415 |
"/ firstPage ifFalse: [ self formFeed ]. |
|
416 |
"/ self device font: printerFont. |
|
417 |
"/ self printPage: page in: marginsRect lines: lines linesPerPage: linesPerPage. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
418 |
"/ firstPage := false |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
419 |
"/ ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
420 |
"/ ] |
2143 | 421 |
"/ ]. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
422 |
|
2236 | 423 |
jobid notNil ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
424 |
self endPrintJob. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
425 |
abortDialog close. |
2236 | 426 |
]. |
2143 | 427 |
|
2236 | 428 |
"/ abort ifFalse: [ abortDialog close ] |
2143 | 429 |
|
430 |
"Created: / 03-08-2006 / 16:13:33 / fm" |
|
431 |
"Modified: / 04-08-2006 / 13:40:02 / fm" |
|
2236 | 432 |
"Modified: / 10-10-2006 / 18:16:54 / cg" |
2247 | 433 |
"Modified: / 12-10-2006 / 11:50:37 / User" |
2143 | 434 |
! |
435 |
||
2274 | 436 |
print: aString |
437 |
pageHeader: aString2 |
|
438 |
font: aFont |
|
439 |
title: aTitle |
|
440 |
collate: collateBoolean |
|
441 |
copies: copiesInteger |
|
442 |
wordWrap: wordWrapBoolean |
|
443 |
marginsRect: aMarginsRect |
|
444 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
445 |
"Private - Answer the receiver. Output the receiver string to |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
446 |
the printer using aFont. A Print abort dialog box will be opened |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
447 |
with aTitle. If collateBoolean is true, collate output, otherwise |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
448 |
do not. Print copiesInteger copies of the specified string. If |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
449 |
wordWrapBoolean is true, word wrap the lines, otherwise do not. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
450 |
Left, top, right & bottom margins are specified in inches in |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
451 |
aMarginsRect. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
452 |
Mg: Erweitert um pageHeader" |
2274 | 453 |
"Changed by K3/EES5-Mg, 08.01.96" |
454 |
||
455 |
| lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines| |
|
456 |
||
457 |
printerFont := self setPrinterFont: aFont. |
|
458 |
charHeight := self "pen" getCharHeight. |
|
459 |
marginsRect := self marginsRectangleFor: aMarginsRect. |
|
460 |
lines := self "pen" asArrayOfStringLines: aString in: marginsRect wordWrap: wordWrapBoolean. |
|
461 |
headerLines := self "pen" asArrayOfStringLines: aString2 in: marginsRect wordWrap: wordWrapBoolean. |
|
462 |
linesPerPage := marginsRect bottom - marginsRect top // charHeight. |
|
463 |
||
464 |
linesPerPage > headerLines size |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
465 |
ifFalse: |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
466 |
[Dialog information: 'Der Dokumentenkopf ist zu groß; wird ignoriert!!'. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
467 |
headerLines := #(). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
468 |
] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
469 |
ifTrue: [linesPerPage := linesPerPage - headerLines size]. |
2274 | 470 |
totalPage := lines size + linesPerPage - 1 // linesPerPage. |
471 |
firstPage := true. |
|
472 |
||
473 |
"/ collateBoolean |
|
474 |
"/ ifTrue: [ |
|
475 |
"/ copiesInteger timesRepeat: [ |
|
476 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
477 |
1 to: totalPage do: [ :page | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
478 |
abort ifTrue: [ ^self endPrintJob ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
479 |
firstPage ifFalse: [ self formFeed ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
480 |
self "pen" font: aFont "printerFont". |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
481 |
self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
482 |
firstPage := false ] |
2274 | 483 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
484 |
"/ ] |
2274 | 485 |
"/ ] |
486 |
"/ ifFalse: [ |
|
487 |
"/ 1 to: totalPage do: [ :page | |
|
488 |
"/ copiesInteger timesRepeat: [ |
|
489 |
"/ abort ifTrue: [ ^self endPrintJob ]. |
|
490 |
"/ firstPage ifFalse: [ self formFeed ]. |
|
491 |
"/ self "pen" font: printerFont. |
|
492 |
"/ self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
493 |
"/ firstPage := false ] ] ]. |
|
494 |
||
495 |
"Created: / 30-11-2006 / 13:19:06 / User" |
|
496 |
! |
|
497 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
498 |
print:aString pageHeader:aString2 font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
2236 | 499 |
"Private - Answer the receiver. Output the receiver string to |
500 |
the printer using aFont. A Print abort dialog box will be opened |
|
501 |
with aTitle. If collateBoolean is true, collate output, otherwise |
|
502 |
do not. Print copiesInteger copies of the specified string. If |
|
503 |
wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
504 |
Left, top, right & bottom margins are specified in inches in |
|
505 |
aMarginsRect." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
506 |
|
2236 | 507 |
|lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines| |
2143 | 508 |
|
2236 | 509 |
self font:aFont. |
2143 | 510 |
charHeight := self getCharHeight. |
2236 | 511 |
marginsRect := self marginsRectangleFor:aMarginsRect. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
512 |
lines := self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
513 |
asArrayOfStringLines:aString |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
514 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
515 |
wordWrap:wordWrapBoolean. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
516 |
headerLines := self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
517 |
asArrayOfStringLines:aString2 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
518 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
519 |
wordWrap:wordWrapBoolean. |
2236 | 520 |
linesPerPage := (marginsRect bottom - marginsRect top) // charHeight. |
521 |
linesPerPage > headerLines size ifFalse:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
522 |
Dialog information:(self class classResources |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
523 |
string:'The header is too large - ignored!!'). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
524 |
headerLines := #(). |
2236 | 525 |
] ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
526 |
linesPerPage := linesPerPage - headerLines size |
2236 | 527 |
]. |
528 |
totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
|
2143 | 529 |
firstPage := true. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
530 |
|
2143 | 531 |
"/ collateBoolean |
532 |
"/ ifTrue: [ |
|
533 |
"/ copiesInteger timesRepeat: [ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
534 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
535 |
1 to:totalPage do:[:page | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
536 |
abort ifTrue:[ ^ self ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
537 |
firstPage ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
538 |
self formFeed |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
539 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
540 |
self font:printerFont. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
541 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
542 |
printPage:page |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
543 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
544 |
lines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
545 |
headerLines:headerLines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
546 |
linesPerPage:linesPerPage. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
547 |
firstPage := false |
2236 | 548 |
] |
2143 | 549 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
550 |
"/ ] |
2236 | 551 |
"/ ] ifFalse: [ |
552 |
"/ 1 to: totalPage do: [ :page | |
|
553 |
"/ copiesInteger timesRepeat: [ |
|
554 |
"/ abort ifTrue: [ ^self endPrintJob ]. |
|
555 |
"/ firstPage ifFalse: [ self formFeed ]. |
|
556 |
"/ self device font: printerFont. |
|
557 |
"/ self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
558 |
"/ firstPage := false |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
559 |
"/ ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
560 |
"/ ] |
2236 | 561 |
"/ ]. |
2143 | 562 |
|
563 |
"Created: / 03-08-2006 / 16:14:10 / fm" |
|
2236 | 564 |
"Modified: / 10-10-2006 / 18:18:03 / cg" |
2143 | 565 |
! ! |
566 |
||
2147 | 567 |
!PrinterContext methodsFor:'printing process'! |
2143 | 568 |
|
569 |
endPage |
|
2236 | 570 |
"Informs device that we are finished writing to a page." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
571 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
572 |
self subclassResponsibility |
2143 | 573 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
574 |
"Modified: / 16-04-2007 / 12:47:31 / cg" |
2143 | 575 |
! |
576 |
||
577 |
endPrintJob |
|
2236 | 578 |
"End the print job. Everything drawn between startPrintJob |
2314 | 579 |
and endPrintJob will become one entry in the print queue. |
580 |
Close and clean the device context of the receiver" |
|
581 |
||
582 |
self endPrintJobWithoutRelease. |
|
583 |
self releaseDC. |
|
584 |
||
585 |
"Modified: / 16-04-2007 / 12:47:28 / cg" |
|
586 |
! |
|
587 |
||
588 |
endPrintJobWithoutRelease |
|
589 |
"End the print job. Everything drawn between startPrintJob |
|
590 |
and endPrintJob will become one entry in the print queue. |
|
591 |
Won't close the DC " |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
592 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
593 |
self subclassResponsibility |
2143 | 594 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
595 |
"Modified: / 16-04-2007 / 12:47:28 / cg" |
2143 | 596 |
! |
597 |
||
598 |
formFeed |
|
2236 | 599 |
"Send a form feed to the printer." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
600 |
|
2143 | 601 |
self |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
602 |
endPage; |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
603 |
startPage |
2143 | 604 |
|
605 |
"Created: / 27-07-2006 / 18:25:40 / fm" |
|
2236 | 606 |
"Modified: / 10-10-2006 / 18:15:07 / cg" |
2143 | 607 |
! |
608 |
||
609 |
startPage |
|
2236 | 610 |
"Starts a page." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
611 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
612 |
self subclassResponsibility |
2143 | 613 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
614 |
"Modified: / 16-04-2007 / 12:47:13 / cg" |
2143 | 615 |
! |
616 |
||
617 |
startPrintJob |
|
2236 | 618 |
"Start a print job. Everything drawn between startPrintJob |
619 |
and endPrintJob will become one entry in the print queue." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
620 |
|
2236 | 621 |
self startPrintJob:nil |
2143 | 622 |
|
623 |
"Created: / 27-07-2006 / 18:18:52 / fm" |
|
2236 | 624 |
"Modified: / 10-10-2006 / 18:19:05 / cg" |
2143 | 625 |
! |
626 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
627 |
startPrintJob:aString |
2236 | 628 |
"Start a print job, using aString as the job title; everything |
629 |
drawn between startPrintJob and endPrintJob will become |
|
630 |
one entry in the print queue." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
631 |
|
2236 | 632 |
^ self startPrintJob:aString fileName:nil |
2143 | 633 |
|
634 |
"Created: / 27-07-2006 / 18:19:09 / fm" |
|
2236 | 635 |
"Modified: / 10-10-2006 / 18:19:12 / cg" |
2143 | 636 |
! |
637 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
638 |
startPrintJob:aString fileName:aFileName |
2236 | 639 |
"Start a print job, using aString as the job title; everything |
640 |
drawn between startPrintJob and endPrintJob will become |
|
641 |
one entry in the print queue." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
642 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
643 |
self subclassResponsibility |
2143 | 644 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
645 |
"Modified: / 16-04-2007 / 12:46:58 / cg" |
2147 | 646 |
! ! |
647 |
||
648 |
!PrinterContext methodsFor:'queries'! |
|
649 |
||
650 |
supportsColor |
|
2236 | 651 |
^ false. |
652 |
||
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
653 |
"Modified: / 16-04-2007 / 12:44:19 / cg" |
2147 | 654 |
! |
655 |
||
656 |
supportsGraphics |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
657 |
^ false |
2147 | 658 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
659 |
"Modified: / 16-04-2007 / 12:44:29 / cg" |
2147 | 660 |
! ! |
661 |
||
2322 | 662 |
!PrinterContext methodsFor:'testing'! |
663 |
||
664 |
isPrinterContext |
|
665 |
||
666 |
^true |
|
667 |
! ! |
|
668 |
||
2147 | 669 |
!PrinterContext methodsFor:'text printing'! |
670 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
671 |
asArrayOfStringLines:aString in:aRectangle wordWrap:wordWrapBoolean |
2236 | 672 |
"Private - convert aString into an array of lines; if wordWrapBoolean |
673 |
is true, also perform word wrapping on the lines, within aRectangle." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
674 |
|
2236 | 675 |
|line lines stream x0 x1 partialLine leftMargin rightMargin partialLineWidth index| |
676 |
||
677 |
stream := ReadStream on:aString. |
|
2147 | 678 |
lines := OrderedCollection new. |
2236 | 679 |
wordWrapBoolean ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
680 |
leftMargin := aRectangle left. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
681 |
rightMargin := aRectangle right |
2236 | 682 |
]. |
683 |
[ stream atEnd ] whileFalse:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
684 |
line := stream nextLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
685 |
wordWrapBoolean ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
686 |
lines add:line |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
687 |
] ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
688 |
x0 := x1 := 1. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
689 |
1 to:line size do:[:i | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
690 |
((line at:i) = Character space "32" |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
691 |
and:[ (partialLine := line copyFrom:x0 to:i) trimBlanks notEmpty ]) |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
692 |
ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
693 |
partialLineWidth := self stringWidthOf:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
694 |
(leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
695 |
partialLine := line copyFrom:x0 to:x1. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
696 |
lines add:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
697 |
x0 := x1 + 1 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
698 |
] ifFalse:[ x1 := i ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
699 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
700 |
index := i |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
701 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
702 |
line isEmpty ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
703 |
lines add:line |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
704 |
] ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
705 |
partialLine := line copyFrom:x0 to:index. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
706 |
partialLineWidth := self stringWidthOf:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
707 |
(leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
708 |
partialLine := line copyFrom:x0 to:x1. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
709 |
lines add:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
710 |
partialLine := line copyFrom:x1 + 1 to:index |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
711 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
712 |
lines add:partialLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
713 |
] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
714 |
] |
2147 | 715 |
]. |
2236 | 716 |
^ lines asArray |
2147 | 717 |
|
718 |
"Created: / 02-08-2006 / 17:56:51 / fm" |
|
719 |
"Modified: / 04-08-2006 / 13:39:50 / fm" |
|
2236 | 720 |
"Modified: / 10-10-2006 / 18:14:00 / cg" |
2147 | 721 |
! |
722 |
||
2272 | 723 |
displayString:aString at:aPoint in:aRect options:ignoredForNow adx:unknownForNow |
724 |
|x y| |
|
725 |
x := aPoint x. |
|
726 |
y := aPoint y. |
|
727 |
(textAlign isNil or:[textAlign == 0 ]) ifTrue:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
728 |
self displayString:aString at:aPoint. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
729 |
^ self |
2272 | 730 |
]. |
731 |
(textAlign == 8 "TaBottom") ifTrue:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
732 |
y := aPoint y - (self container font ascent) "container font ascent". |
2272 | 733 |
] ifFalse:[ (textAlign == 6 "TaCenter") ifTrue:[ |
734 |
"/ x := aRect left + ((aRect width-(container font widthOf:aString))//2). |
|
735 |
] ifFalse:[ (textAlign == 2 "TaRight") ifTrue:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
736 |
x := aRect right - (self "container font widthof:" stringWidthOf:aString). |
2449 | 737 |
"/ y := self "container font ascent" getCharHeight + aPoint y . |
2272 | 738 |
] ifFalse:[ (textAlign == 14 "TaCenterBottom") ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
739 |
y := aRect bottom - self getCharHeight "container font ascent". |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
740 |
x := aRect left + ((aRect width-(self "container font widthOf:" stringWidthOf:aString))//2). |
2272 | 741 |
] ifFalse:[ (textAlign == 10) ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
742 |
x := aRect right - (self "container font widthof:" stringWidthOf:aString). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
743 |
y := aPoint y - (self container font ascent)"aRect bottom - self getCharHeight". |
2272 | 744 |
]]]]]. |
2565 | 745 |
|
746 |
"/aString = '3' ifTrue:[ |
|
747 |
"/self halt. |
|
2275 | 748 |
"/ Transcript showCR: 'Original Pos: ', aPoint x printString, '@', aPoint y printString, |
749 |
"/ ' Pos: ', x printString, '@', y printString, |
|
2565 | 750 |
"/ ' Text: ', aString, |
751 |
"/ ' Align: ', textAlign printString. |
|
752 |
"/ self displayString:aString at:(aPoint x@ aPoint y). |
|
753 |
"/]. |
|
754 |
||
2272 | 755 |
self displayString:aString at:(x@y). |
756 |
||
2275 | 757 |
"Modified: / 14-12-2006 / 12:29:13 / User" |
2272 | 758 |
! |
759 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
760 |
displayStringLines:anIndexedCollection from:startIndex to:endIndex in:aRectangle |
2236 | 761 |
"Private - display Strings in anIndexedCollection starting at startIndex and |
762 |
ending at endIndex, clipped within the bounds of aRectangle." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
763 |
|
3315
c51703ef04b6
Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents:
3287
diff
changeset
|
764 |
|charHeight ascent| |
2236 | 765 |
|
2147 | 766 |
charHeight := self getCharHeight. |
2236 | 767 |
ascent := self font ascentOn:self device. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
768 |
startIndex to:endIndex do:[:i | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
769 |
|lineToPrint| |
2236 | 770 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
771 |
lineToPrint := (anIndexedCollection at:i). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
772 |
self graphicsDevice |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
773 |
displayString:lineToPrint |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
774 |
from:1 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
775 |
to:lineToPrint size |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
776 |
x:aRectangle left |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
777 |
y:(aRectangle top + ((i - startIndex) * charHeight)) |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
778 |
in:nil |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
779 |
with:self gcId |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
780 |
opaque:false |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
781 |
fontAscent:ascent. |
2147 | 782 |
]. |
783 |
||
2236 | 784 |
"/ region := self setClipRect: aRectangle. |
785 |
"/ ta := self getTextAlign. |
|
786 |
"/ self setTextAlign: TaTop. |
|
787 |
"/ startIndex to: endIndex do: [ :i | |
|
788 |
"/ self |
|
789 |
"/ displayText: ( anIndexedCollection at: i ) |
|
790 |
"/ at: aRectangle left @ ( aRectangle top + ( i - startIndex * charHeight ) ) ]. |
|
791 |
"/ self setTextAlign: ta. |
|
792 |
"/ self destroyRegion: region |
|
2147 | 793 |
|
794 |
"Created: / 03-08-2006 / 11:37:52 / fm" |
|
795 |
"Modified: / 03-08-2006 / 12:38:43 / fm" |
|
2236 | 796 |
"Modified: / 10-10-2006 / 18:14:36 / cg" |
2147 | 797 |
! |
798 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
799 |
displayStringLines:anIndexedCollection in:aRectangle |
2236 | 800 |
"Private - display anIndexedCollection of Strings clipped within |
801 |
the bounds of aRectangle." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
802 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
803 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
804 |
displayStringLines:anIndexedCollection |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
805 |
from:1 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
806 |
to:anIndexedCollection size |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
807 |
in:aRectangle |
2147 | 808 |
|
809 |
"Created: / 03-08-2006 / 16:03:07 / fm" |
|
2236 | 810 |
"Modified: / 10-10-2006 / 18:14:40 / cg" |
2147 | 811 |
! |
812 |
||
2272 | 813 |
displayText: aString at: aPoint |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
814 |
self displayString:aString x:aPoint x y:aPoint y |
2272 | 815 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
816 |
"Modified: / 16-04-2007 / 12:44:43 / cg" |
2272 | 817 |
! |
818 |
||
2247 | 819 |
linesPerPageFor: aRectangle |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
820 |
|marginsRect charHeight| |
2247 | 821 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
822 |
marginsRect := aRectangle isNil |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
823 |
ifTrue:[self marginsRectangleFor: nil] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
824 |
ifFalse:[aRectangle]. |
2247 | 825 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
826 |
charHeight := self getCharHeight. |
2247 | 827 |
^(marginsRect bottom - marginsRect top) // charHeight |
828 |
||
829 |
"Created: / 12-10-2006 / 11:52:57 / User" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
830 |
"Modified: / 16-04-2007 / 12:44:56 / cg" |
2247 | 831 |
! |
832 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
833 |
marginsRectangleFor:aRectangle |
2147 | 834 |
"Private - Answer a Rectangle defining margins based on aRectangle. |
835 |
Units for aRectangle are in inches, returned margins rectangle is |
|
836 |
in device units (pixels)." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
837 |
|
2147 | 838 |
|left top right bottom pixelsPerInchX pixelsPerInchY horzRes vertRes inset rectangle| |
2236 | 839 |
|
2147 | 840 |
pixelsPerInchX := self pixelsPerInchOfScreenWidth. |
2552
071be7d5a9b5
changed #marginsRectangleFor:
Claus Gittinger <cg@exept.de>
parents:
2449
diff
changeset
|
841 |
pixelsPerInchX == 0 ifTrue:[self halt:'invalid definitions for screen resolution']. |
2147 | 842 |
pixelsPerInchY := self pixelsPerInchOfScreenHeight. |
2552
071be7d5a9b5
changed #marginsRectangleFor:
Claus Gittinger <cg@exept.de>
parents:
2449
diff
changeset
|
843 |
pixelsPerInchY == 0 ifTrue:[self halt:'invalid definitions for screen resolution']. |
071be7d5a9b5
changed #marginsRectangleFor:
Claus Gittinger <cg@exept.de>
parents:
2449
diff
changeset
|
844 |
|
2147 | 845 |
aRectangle isNil ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
846 |
horzRes := self printerWidthArea. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
847 |
vertRes := self printerHeightArea. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
848 |
inset := self class defaultMargins. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
849 |
left := (inset x * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
850 |
top := (inset y * pixelsPerInchY) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
851 |
right := horzRes - (inset x * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
852 |
bottom := vertRes - (inset y * pixelsPerInchY) asInteger |
2147 | 853 |
] ifFalse:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
854 |
left := (aRectangle left * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
855 |
top := (aRectangle top * pixelsPerInchY) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
856 |
right := (aRectangle right * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
857 |
bottom := (aRectangle bottom * pixelsPerInchY) asInteger |
2147 | 858 |
]. |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
859 |
rectangle := left @ top corner:right @ bottom. |
2147 | 860 |
^ rectangle |
861 |
||
862 |
"Created: / 27-07-2006 / 18:22:57 / fm" |
|
863 |
"Modified: / 04-08-2006 / 13:39:45 / fm" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
864 |
"Modified: / 16-04-2007 / 11:57:21 / cg" |
2147 | 865 |
! |
866 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
867 |
printPage:pageIndex in:aRectangle lines:lines headerLines:headerLines linesPerPage:linesPerPage |
2236 | 868 |
"Private - print page # pageIndex from lines, assuming |
869 |
the given number of linesPerPage." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
870 |
|
2236 | 871 |
|firstLine lastLine l indexString p cHeight rect hLines| |
2147 | 872 |
|
2236 | 873 |
firstLine := (pageIndex - 1) * linesPerPage + 1. |
874 |
lastLine := (firstLine + linesPerPage - 1) min:lines size. |
|
2147 | 875 |
rect := aRectangle deepCopy. |
876 |
hLines := headerLines deepCopy. |
|
2236 | 877 |
headerLines size > 0 ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
878 |
l := hLines first. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
879 |
p := l indexOfSubCollection: "indexOfString:"'#P'. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
880 |
p = 0 ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
881 |
indexString := pageIndex printString , ' '. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
882 |
l := (l copyFrom:1 to:p - 1) , indexString , (l copyFrom:p + 2 to:l size). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
883 |
hLines at:1 put:l. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
884 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
885 |
cHeight := self getCharHeight. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
886 |
rect top:rect top + (hLines size * cHeight). |
2236 | 887 |
]. |
888 |
self displayStringLines:hLines in:aRectangle. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
889 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
890 |
displayStringLines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
891 |
from:firstLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
892 |
to:lastLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
893 |
in:rect. |
2147 | 894 |
|
895 |
"Created: / 27-07-2006 / 18:28:00 / fm" |
|
896 |
"Modified: / 03-08-2006 / 16:03:15 / fm" |
|
2236 | 897 |
"Modified: / 10-10-2006 / 18:18:15 / cg" |
2274 | 898 |
"Modified: / 30-11-2006 / 13:34:44 / User" |
2147 | 899 |
! |
900 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
901 |
printPage:pageIndex in:aRectangle lines:lines linesPerPage:linesPerPage |
2236 | 902 |
"Private - print page # pageIndex from lines, assuming |
903 |
the given number of linesPerPage." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
904 |
|
2236 | 905 |
|firstLine lastLine| |
906 |
||
907 |
firstLine := (pageIndex - 1) * linesPerPage + 1. |
|
908 |
lastLine := (firstLine + linesPerPage - 1) min:lines size. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
909 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
910 |
displayStringLines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
911 |
from:firstLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
912 |
to:lastLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
913 |
in:aRectangle |
2147 | 914 |
|
915 |
"Created: / 27-07-2006 / 18:24:59 / fm" |
|
916 |
"Modified: / 03-08-2006 / 12:47:24 / fm" |
|
2236 | 917 |
"Modified: / 10-10-2006 / 18:18:22 / cg" |
2143 | 918 |
! |
919 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
920 |
stringWidthOf:aString |
2236 | 921 |
"Return the width of aString |
922 |
when written using the current font." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
923 |
|
2236 | 924 |
^ self stringWidthOf:aString at:aString size. |
2143 | 925 |
|
926 |
"Modified: / 03-08-2006 / 10:18:23 / fm" |
|
2236 | 927 |
"Modified: / 10-10-2006 / 18:20:08 / cg" |
2143 | 928 |
! |
929 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
930 |
stringWidthOf:aString at:index |
2236 | 931 |
"Return the width of aString up to index |
932 |
when written using the current font; expand tabs out |
|
933 |
to 4 spaces for calculations" |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
934 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
935 |
self subclassResponsibility |
2236 | 936 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
937 |
"Modified: / 16-04-2007 / 12:45:42 / cg" |
2272 | 938 |
! |
939 |
||
940 |
withLineStyle:aSymbol lineWidth:lw paint:paintColor do:aBlock |
|
941 |
|savStyle savWidth savPaint| |
|
942 |
||
943 |
savStyle := self lineStyle. |
|
944 |
savWidth := self lineWidth. |
|
945 |
savPaint := self paint. |
|
946 |
||
947 |
self lineStyle:aSymbol. |
|
948 |
self lineWidth:lw. |
|
949 |
self paint:paintColor. |
|
950 |
aBlock value. |
|
951 |
self paint:savPaint. |
|
952 |
self lineWidth:savWidth. |
|
953 |
self lineStyle:savStyle. |
|
954 |
||
955 |
"Created: / 13-09-2006 / 15:38:56 / User" |
|
2143 | 956 |
! ! |
957 |
||
958 |
!PrinterContext class methodsFor:'documentation'! |
|
959 |
||
960 |
version |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
961 |
^ '$Header$' |
2143 | 962 |
! ! |
3287 | 963 |