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