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