author | Stefan Vogel <sv@exept.de> |
Tue, 24 Nov 2009 19:06:40 +0100 | |
changeset 2808 | 6c77d010f103 |
parent 2565 | 961d9cb4a31c |
child 3287 | 11a9d55d663c |
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" |
|
2314 | 341 |
! |
342 |
||
343 |
releaseDC |
|
344 |
"Private - Closes the device context of the receiver" |
|
345 |
||
346 |
self subclassResponsibility |
|
347 |
||
348 |
"Created: / 27-07-2006 / 10:21:05 / fm" |
|
349 |
"Modified: / 02-08-2006 / 17:30:47 / fm" |
|
350 |
"Modified: / 16-04-2007 / 12:49:22 / cg" |
|
2143 | 351 |
! ! |
352 |
||
353 |
!PrinterContext methodsFor:'printing'! |
|
354 |
||
2236 | 355 |
print:aString font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
356 |
"Answer the receiver. Output the receiver string to |
|
357 |
the printer using aFont. A Print abort dialog box will be opened |
|
358 |
with aTitle. If collateBoolean is true, collate output, otherwise |
|
359 |
do not. Print copiesInteger copies of the specified string. If |
|
360 |
wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
361 |
Left, top, right & bottom margins are specified in inches in |
|
362 |
aMarginsRect." |
|
363 |
||
2247 | 364 |
|lines linesPerPage totalPage marginsRect firstPage abortDialog| |
2143 | 365 |
|
2236 | 366 |
jobid isNil ifTrue:[ |
367 |
self startPrintJob:aTitle |
|
368 |
]. |
|
369 |
abortDialog := PrintAbortDialog new open:aTitle printer:self. |
|
370 |
self font:aFont. |
|
371 |
marginsRect := self marginsRectangleFor:aMarginsRect. |
|
372 |
lines := self |
|
373 |
asArrayOfStringLines:aString |
|
374 |
in:marginsRect |
|
375 |
wordWrap:wordWrapBoolean. |
|
2247 | 376 |
linesPerPage := self linesPerPageFor: marginsRect. |
2236 | 377 |
totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
2143 | 378 |
firstPage := true. |
2236 | 379 |
|
2143 | 380 |
"/ collateBoolean |
381 |
"/ ifTrue: [ |
|
382 |
"/ copiesInteger timesRepeat: [ |
|
2236 | 383 |
|
384 |
1 to:totalPage do:[:page | |
|
385 |
abort ifTrue:[ ^ self ]. |
|
386 |
firstPage ifFalse:[ |
|
387 |
self formFeed |
|
388 |
]. |
|
389 |
abortDialog |
|
390 |
updatePrintingPageInfo:(self class classResources |
|
391 |
string:'Page %1/%2' |
|
392 |
with:page printString |
|
393 |
with:totalPage printString). |
|
394 |
||
2143 | 395 |
"/ self device font: printerFont. |
2236 | 396 |
|
397 |
self font:aFont. |
|
398 |
self |
|
399 |
printPage:page |
|
400 |
in:marginsRect |
|
401 |
lines:lines |
|
402 |
linesPerPage:linesPerPage. |
|
403 |
firstPage := false |
|
404 |
]. |
|
405 |
||
2143 | 406 |
"/ ] |
407 |
"/ ] ifFalse: [ |
|
408 |
"/ 1 to: totalPage do: [ :page | |
|
409 |
"/ copiesInteger timesRepeat: [ |
|
410 |
"/ abort ifTrue: [ ^self endPrintJob ]. |
|
411 |
"/ firstPage ifFalse: [ self formFeed ]. |
|
412 |
"/ self device font: printerFont. |
|
413 |
"/ self printPage: page in: marginsRect lines: lines linesPerPage: linesPerPage. |
|
414 |
"/ firstPage := false |
|
415 |
"/ ] |
|
416 |
"/ ] |
|
417 |
"/ ]. |
|
2236 | 418 |
|
419 |
jobid notNil ifTrue:[ |
|
420 |
self endPrintJob. |
|
421 |
abortDialog close. |
|
422 |
]. |
|
2143 | 423 |
|
2236 | 424 |
"/ abort ifFalse: [ abortDialog close ] |
2143 | 425 |
|
426 |
"Created: / 03-08-2006 / 16:13:33 / fm" |
|
427 |
"Modified: / 04-08-2006 / 13:40:02 / fm" |
|
2236 | 428 |
"Modified: / 10-10-2006 / 18:16:54 / cg" |
2247 | 429 |
"Modified: / 12-10-2006 / 11:50:37 / User" |
2143 | 430 |
! |
431 |
||
2274 | 432 |
print: aString |
433 |
pageHeader: aString2 |
|
434 |
font: aFont |
|
435 |
title: aTitle |
|
436 |
collate: collateBoolean |
|
437 |
copies: copiesInteger |
|
438 |
wordWrap: wordWrapBoolean |
|
439 |
marginsRect: aMarginsRect |
|
440 |
||
441 |
"Private - Answer the receiver. Output the receiver string to |
|
442 |
the printer using aFont. A Print abort dialog box will be opened |
|
443 |
with aTitle. If collateBoolean is true, collate output, otherwise |
|
444 |
do not. Print copiesInteger copies of the specified string. If |
|
445 |
wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
446 |
Left, top, right & bottom margins are specified in inches in |
|
447 |
aMarginsRect. |
|
448 |
Mg: Erweitert um pageHeader" |
|
449 |
"Changed by K3/EES5-Mg, 08.01.96" |
|
450 |
||
451 |
| lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines| |
|
452 |
||
453 |
printerFont := self setPrinterFont: aFont. |
|
454 |
charHeight := self "pen" getCharHeight. |
|
455 |
marginsRect := self marginsRectangleFor: aMarginsRect. |
|
456 |
lines := self "pen" asArrayOfStringLines: aString in: marginsRect wordWrap: wordWrapBoolean. |
|
457 |
headerLines := self "pen" asArrayOfStringLines: aString2 in: marginsRect wordWrap: wordWrapBoolean. |
|
458 |
linesPerPage := marginsRect bottom - marginsRect top // charHeight. |
|
459 |
||
460 |
linesPerPage > headerLines size |
|
461 |
ifFalse: |
|
462 |
[Dialog information: 'Der Dokumentenkopf ist zu groß; wird ignoriert!!'. |
|
463 |
headerLines := #(). |
|
464 |
] |
|
465 |
ifTrue: [linesPerPage := linesPerPage - headerLines size]. |
|
466 |
totalPage := lines size + linesPerPage - 1 // linesPerPage. |
|
467 |
firstPage := true. |
|
468 |
||
469 |
"/ collateBoolean |
|
470 |
"/ ifTrue: [ |
|
471 |
"/ copiesInteger timesRepeat: [ |
|
472 |
||
473 |
1 to: totalPage do: [ :page | |
|
474 |
abort ifTrue: [ ^self endPrintJob ]. |
|
475 |
firstPage ifFalse: [ self formFeed ]. |
|
476 |
self "pen" font: aFont "printerFont". |
|
477 |
self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
478 |
firstPage := false ] |
|
479 |
||
480 |
"/ ] |
|
481 |
"/ ] |
|
482 |
"/ ifFalse: [ |
|
483 |
"/ 1 to: totalPage do: [ :page | |
|
484 |
"/ copiesInteger timesRepeat: [ |
|
485 |
"/ abort ifTrue: [ ^self endPrintJob ]. |
|
486 |
"/ firstPage ifFalse: [ self formFeed ]. |
|
487 |
"/ self "pen" font: printerFont. |
|
488 |
"/ self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
489 |
"/ firstPage := false ] ] ]. |
|
490 |
||
491 |
"Created: / 30-11-2006 / 13:19:06 / User" |
|
492 |
! |
|
493 |
||
2236 | 494 |
print:aString pageHeader:aString2 font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
495 |
"Private - Answer the receiver. Output the receiver string to |
|
496 |
the printer using aFont. A Print abort dialog box will be opened |
|
497 |
with aTitle. If collateBoolean is true, collate output, otherwise |
|
498 |
do not. Print copiesInteger copies of the specified string. If |
|
499 |
wordWrapBoolean is true, word wrap the lines, otherwise do not. |
|
500 |
Left, top, right & bottom margins are specified in inches in |
|
501 |
aMarginsRect." |
|
502 |
||
503 |
|lines linesPerPage totalPage marginsRect firstPage charHeight printerFont headerLines| |
|
2143 | 504 |
|
2236 | 505 |
self font:aFont. |
2143 | 506 |
charHeight := self getCharHeight. |
2236 | 507 |
marginsRect := self marginsRectangleFor:aMarginsRect. |
508 |
lines := self |
|
509 |
asArrayOfStringLines:aString |
|
510 |
in:marginsRect |
|
511 |
wordWrap:wordWrapBoolean. |
|
512 |
headerLines := self |
|
513 |
asArrayOfStringLines:aString2 |
|
514 |
in:marginsRect |
|
515 |
wordWrap:wordWrapBoolean. |
|
516 |
linesPerPage := (marginsRect bottom - marginsRect top) // charHeight. |
|
517 |
linesPerPage > headerLines size ifFalse:[ |
|
518 |
Dialog information:(self class classResources |
|
519 |
string:'The header is too large - ignored!!'). |
|
520 |
headerLines := #(). |
|
521 |
] ifTrue:[ |
|
522 |
linesPerPage := linesPerPage - headerLines size |
|
523 |
]. |
|
524 |
totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
|
2143 | 525 |
firstPage := true. |
2236 | 526 |
|
2143 | 527 |
"/ collateBoolean |
528 |
"/ ifTrue: [ |
|
529 |
"/ copiesInteger timesRepeat: [ |
|
2236 | 530 |
|
531 |
1 to:totalPage do:[:page | |
|
532 |
abort ifTrue:[ ^ self ]. |
|
533 |
firstPage ifFalse:[ |
|
534 |
self formFeed |
|
535 |
]. |
|
536 |
self font:printerFont. |
|
537 |
self |
|
538 |
printPage:page |
|
539 |
in:marginsRect |
|
540 |
lines:lines |
|
541 |
headerLines:headerLines |
|
542 |
linesPerPage:linesPerPage. |
|
543 |
firstPage := false |
|
544 |
] |
|
2143 | 545 |
|
2236 | 546 |
"/ ] |
547 |
"/ ] ifFalse: [ |
|
548 |
"/ 1 to: totalPage do: [ :page | |
|
549 |
"/ copiesInteger timesRepeat: [ |
|
550 |
"/ abort ifTrue: [ ^self endPrintJob ]. |
|
551 |
"/ firstPage ifFalse: [ self formFeed ]. |
|
552 |
"/ self device font: printerFont. |
|
553 |
"/ self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
|
554 |
"/ firstPage := false |
|
555 |
"/ ] |
|
556 |
"/ ] |
|
557 |
"/ ]. |
|
2143 | 558 |
|
559 |
"Created: / 03-08-2006 / 16:14:10 / fm" |
|
2236 | 560 |
"Modified: / 10-10-2006 / 18:18:03 / cg" |
2143 | 561 |
! ! |
562 |
||
2147 | 563 |
!PrinterContext methodsFor:'printing process'! |
2143 | 564 |
|
565 |
endPage |
|
2236 | 566 |
"Informs device that we are finished writing to a page." |
567 |
||
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
568 |
self subclassResponsibility |
2143 | 569 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
570 |
"Modified: / 16-04-2007 / 12:47:31 / cg" |
2143 | 571 |
! |
572 |
||
573 |
endPrintJob |
|
2236 | 574 |
"End the print job. Everything drawn between startPrintJob |
2314 | 575 |
and endPrintJob will become one entry in the print queue. |
576 |
Close and clean the device context of the receiver" |
|
577 |
||
578 |
self endPrintJobWithoutRelease. |
|
579 |
self releaseDC. |
|
580 |
||
581 |
"Modified: / 16-04-2007 / 12:47:28 / cg" |
|
582 |
! |
|
583 |
||
584 |
endPrintJobWithoutRelease |
|
585 |
"End the print job. Everything drawn between startPrintJob |
|
586 |
and endPrintJob will become one entry in the print queue. |
|
587 |
Won't close the DC " |
|
2236 | 588 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
589 |
self subclassResponsibility |
2143 | 590 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
591 |
"Modified: / 16-04-2007 / 12:47:28 / cg" |
2143 | 592 |
! |
593 |
||
594 |
formFeed |
|
2236 | 595 |
"Send a form feed to the printer." |
596 |
||
2143 | 597 |
self |
598 |
endPage; |
|
599 |
startPage |
|
600 |
||
601 |
"Created: / 27-07-2006 / 18:25:40 / fm" |
|
2236 | 602 |
"Modified: / 10-10-2006 / 18:15:07 / cg" |
2143 | 603 |
! |
604 |
||
605 |
startPage |
|
2236 | 606 |
"Starts a page." |
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:47:13 / cg" |
2143 | 611 |
! |
612 |
||
613 |
startPrintJob |
|
2236 | 614 |
"Start a print job. Everything drawn between startPrintJob |
615 |
and endPrintJob will become one entry in the print queue." |
|
616 |
||
617 |
self startPrintJob:nil |
|
2143 | 618 |
|
619 |
"Created: / 27-07-2006 / 18:18:52 / fm" |
|
2236 | 620 |
"Modified: / 10-10-2006 / 18:19:05 / cg" |
2143 | 621 |
! |
622 |
||
2236 | 623 |
startPrintJob:aString |
624 |
"Start a print job, using aString as the job title; everything |
|
625 |
drawn between startPrintJob and endPrintJob will become |
|
626 |
one entry in the print queue." |
|
627 |
||
628 |
^ self startPrintJob:aString fileName:nil |
|
2143 | 629 |
|
630 |
"Created: / 27-07-2006 / 18:19:09 / fm" |
|
2236 | 631 |
"Modified: / 10-10-2006 / 18:19:12 / cg" |
2143 | 632 |
! |
633 |
||
2236 | 634 |
startPrintJob:aString fileName:aFileName |
635 |
"Start a print job, using aString as the job title; everything |
|
636 |
drawn between startPrintJob and endPrintJob will become |
|
637 |
one entry in the print queue." |
|
638 |
||
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
639 |
self subclassResponsibility |
2143 | 640 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
641 |
"Modified: / 16-04-2007 / 12:46:58 / cg" |
2147 | 642 |
! ! |
643 |
||
644 |
!PrinterContext methodsFor:'queries'! |
|
645 |
||
646 |
supportsColor |
|
2236 | 647 |
^ false. |
648 |
||
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
649 |
"Modified: / 16-04-2007 / 12:44:19 / cg" |
2147 | 650 |
! |
651 |
||
652 |
supportsGraphics |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
653 |
^ false |
2147 | 654 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
655 |
"Modified: / 16-04-2007 / 12:44:29 / cg" |
2147 | 656 |
! ! |
657 |
||
2322 | 658 |
!PrinterContext methodsFor:'testing'! |
659 |
||
660 |
isPrinterContext |
|
661 |
||
662 |
^true |
|
663 |
! ! |
|
664 |
||
2147 | 665 |
!PrinterContext methodsFor:'text printing'! |
666 |
||
2236 | 667 |
asArrayOfStringLines:aString in:aRectangle wordWrap:wordWrapBoolean |
668 |
"Private - convert aString into an array of lines; if wordWrapBoolean |
|
669 |
is true, also perform word wrapping on the lines, within aRectangle." |
|
670 |
||
671 |
|line lines stream x0 x1 partialLine leftMargin rightMargin partialLineWidth index| |
|
672 |
||
673 |
stream := ReadStream on:aString. |
|
2147 | 674 |
lines := OrderedCollection new. |
2236 | 675 |
wordWrapBoolean ifTrue:[ |
2147 | 676 |
leftMargin := aRectangle left. |
2236 | 677 |
rightMargin := aRectangle right |
678 |
]. |
|
679 |
[ stream atEnd ] whileFalse:[ |
|
2147 | 680 |
line := stream nextLine. |
2236 | 681 |
wordWrapBoolean ifFalse:[ |
682 |
lines add:line |
|
683 |
] ifTrue:[ |
|
684 |
x0 := x1 := 1. |
|
685 |
1 to:line size do:[:i | |
|
686 |
((line at:i) = Character space "32" |
|
687 |
and:[ (partialLine := line copyFrom:x0 to:i) trimBlanks notEmpty ]) |
|
688 |
ifTrue:[ |
|
689 |
partialLineWidth := self stringWidthOf:partialLine. |
|
690 |
(leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
|
691 |
partialLine := line copyFrom:x0 to:x1. |
|
692 |
lines add:partialLine. |
|
693 |
x0 := x1 + 1 |
|
694 |
] ifFalse:[ x1 := i ] |
|
2147 | 695 |
]. |
2236 | 696 |
index := i |
697 |
]. |
|
698 |
line isEmpty ifTrue:[ |
|
699 |
lines add:line |
|
700 |
] ifFalse:[ |
|
701 |
partialLine := line copyFrom:x0 to:index. |
|
702 |
partialLineWidth := self stringWidthOf:partialLine. |
|
703 |
(leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
|
704 |
partialLine := line copyFrom:x0 to:x1. |
|
705 |
lines add:partialLine. |
|
706 |
partialLine := line copyFrom:x1 + 1 to:index |
|
707 |
]. |
|
708 |
lines add:partialLine |
|
709 |
] |
|
710 |
] |
|
2147 | 711 |
]. |
2236 | 712 |
^ lines asArray |
2147 | 713 |
|
714 |
"Created: / 02-08-2006 / 17:56:51 / fm" |
|
715 |
"Modified: / 04-08-2006 / 13:39:50 / fm" |
|
2236 | 716 |
"Modified: / 10-10-2006 / 18:14:00 / cg" |
2147 | 717 |
! |
718 |
||
2272 | 719 |
displayString:aString at:aPoint in:aRect options:ignoredForNow adx:unknownForNow |
720 |
|x y| |
|
721 |
x := aPoint x. |
|
722 |
y := aPoint y. |
|
723 |
(textAlign isNil or:[textAlign == 0 ]) ifTrue:[ |
|
724 |
self displayString:aString at:aPoint. |
|
725 |
^ self |
|
726 |
]. |
|
727 |
(textAlign == 8 "TaBottom") ifTrue:[ |
|
728 |
y := aPoint y - (self container font ascent) "container font ascent". |
|
729 |
] ifFalse:[ (textAlign == 6 "TaCenter") ifTrue:[ |
|
730 |
"/ x := aRect left + ((aRect width-(container font widthOf:aString))//2). |
|
731 |
] ifFalse:[ (textAlign == 2 "TaRight") ifTrue:[ |
|
732 |
x := aRect right - (self "container font widthof:" stringWidthOf:aString). |
|
2449 | 733 |
"/ y := self "container font ascent" getCharHeight + aPoint y . |
2272 | 734 |
] ifFalse:[ (textAlign == 14 "TaCenterBottom") ifTrue:[ |
735 |
y := aRect bottom - self getCharHeight "container font ascent". |
|
736 |
x := aRect left + ((aRect width-(self "container font widthOf:" stringWidthOf:aString))//2). |
|
737 |
] ifFalse:[ (textAlign == 10) ifTrue:[ |
|
738 |
x := aRect right - (self "container font widthof:" stringWidthOf:aString). |
|
2565 | 739 |
y := aPoint y - (self container font ascent)"aRect bottom - self getCharHeight". |
2272 | 740 |
]]]]]. |
2565 | 741 |
|
742 |
"/aString = '3' ifTrue:[ |
|
743 |
"/self halt. |
|
2275 | 744 |
"/ Transcript showCR: 'Original Pos: ', aPoint x printString, '@', aPoint y printString, |
745 |
"/ ' Pos: ', x printString, '@', y printString, |
|
2565 | 746 |
"/ ' Text: ', aString, |
747 |
"/ ' Align: ', textAlign printString. |
|
748 |
"/ self displayString:aString at:(aPoint x@ aPoint y). |
|
749 |
"/]. |
|
750 |
||
2272 | 751 |
self displayString:aString at:(x@y). |
752 |
||
2275 | 753 |
"Modified: / 14-12-2006 / 12:29:13 / User" |
2272 | 754 |
! |
755 |
||
2236 | 756 |
displayStringLines:anIndexedCollection from:startIndex to:endIndex in:aRectangle |
757 |
"Private - display Strings in anIndexedCollection starting at startIndex and |
|
758 |
ending at endIndex, clipped within the bounds of aRectangle." |
|
759 |
||
760 |
|charHeight ta region ascent| |
|
761 |
||
2147 | 762 |
charHeight := self getCharHeight. |
2236 | 763 |
ascent := self font ascentOn:self device. |
764 |
startIndex to:endIndex do:[:i | |
|
2147 | 765 |
|lineToPrint| |
2236 | 766 |
|
767 |
lineToPrint := (anIndexedCollection at:i). |
|
768 |
self device |
|
769 |
displayString:lineToPrint |
|
770 |
from:1 |
|
771 |
to:lineToPrint size |
|
772 |
x:aRectangle left |
|
773 |
y:(aRectangle top + ((i - startIndex) * charHeight)) |
|
774 |
in:nil |
|
775 |
with:gcId |
|
776 |
opaque:false |
|
777 |
fontAscent:ascent. |
|
2147 | 778 |
]. |
779 |
||
2236 | 780 |
"/ region := self setClipRect: aRectangle. |
781 |
"/ ta := self getTextAlign. |
|
782 |
"/ self setTextAlign: TaTop. |
|
783 |
"/ startIndex to: endIndex do: [ :i | |
|
784 |
"/ self |
|
785 |
"/ displayText: ( anIndexedCollection at: i ) |
|
786 |
"/ at: aRectangle left @ ( aRectangle top + ( i - startIndex * charHeight ) ) ]. |
|
787 |
"/ self setTextAlign: ta. |
|
788 |
"/ self destroyRegion: region |
|
2147 | 789 |
|
790 |
"Created: / 03-08-2006 / 11:37:52 / fm" |
|
791 |
"Modified: / 03-08-2006 / 12:38:43 / fm" |
|
2236 | 792 |
"Modified: / 10-10-2006 / 18:14:36 / cg" |
2147 | 793 |
! |
794 |
||
2236 | 795 |
displayStringLines:anIndexedCollection in:aRectangle |
796 |
"Private - display anIndexedCollection of Strings clipped within |
|
797 |
the bounds of aRectangle." |
|
798 |
||
799 |
self |
|
800 |
displayStringLines:anIndexedCollection |
|
801 |
from:1 |
|
802 |
to:anIndexedCollection size |
|
803 |
in:aRectangle |
|
2147 | 804 |
|
805 |
"Created: / 03-08-2006 / 16:03:07 / fm" |
|
2236 | 806 |
"Modified: / 10-10-2006 / 18:14:40 / cg" |
2147 | 807 |
! |
808 |
||
2272 | 809 |
displayText: aString at: aPoint |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
810 |
self displayString:aString x:aPoint x y:aPoint y |
2272 | 811 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
812 |
"Modified: / 16-04-2007 / 12:44:43 / cg" |
2272 | 813 |
! |
814 |
||
2247 | 815 |
linesPerPageFor: aRectangle |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
816 |
|marginsRect charHeight| |
2247 | 817 |
|
818 |
marginsRect := aRectangle isNil |
|
819 |
ifTrue:[self marginsRectangleFor: nil] |
|
820 |
ifFalse:[aRectangle]. |
|
821 |
||
822 |
charHeight := self getCharHeight. |
|
823 |
^(marginsRect bottom - marginsRect top) // charHeight |
|
824 |
||
825 |
"Created: / 12-10-2006 / 11:52:57 / User" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
826 |
"Modified: / 16-04-2007 / 12:44:56 / cg" |
2247 | 827 |
! |
828 |
||
2147 | 829 |
marginsRectangleFor:aRectangle |
830 |
"Private - Answer a Rectangle defining margins based on aRectangle. |
|
831 |
Units for aRectangle are in inches, returned margins rectangle is |
|
832 |
in device units (pixels)." |
|
833 |
||
834 |
|left top right bottom pixelsPerInchX pixelsPerInchY horzRes vertRes inset rectangle| |
|
2236 | 835 |
|
2147 | 836 |
pixelsPerInchX := self pixelsPerInchOfScreenWidth. |
2552
071be7d5a9b5
changed #marginsRectangleFor:
Claus Gittinger <cg@exept.de>
parents:
2449
diff
changeset
|
837 |
pixelsPerInchX == 0 ifTrue:[self halt:'invalid definitions for screen resolution']. |
2147 | 838 |
pixelsPerInchY := self pixelsPerInchOfScreenHeight. |
2552
071be7d5a9b5
changed #marginsRectangleFor:
Claus Gittinger <cg@exept.de>
parents:
2449
diff
changeset
|
839 |
pixelsPerInchY == 0 ifTrue:[self halt:'invalid definitions for screen resolution']. |
071be7d5a9b5
changed #marginsRectangleFor:
Claus Gittinger <cg@exept.de>
parents:
2449
diff
changeset
|
840 |
|
2147 | 841 |
aRectangle isNil ifTrue:[ |
842 |
horzRes := self printerWidthArea. |
|
843 |
vertRes := self printerHeightArea. |
|
844 |
inset := self class defaultMargins. |
|
845 |
left := (inset x * pixelsPerInchX) asInteger. |
|
846 |
top := (inset y * pixelsPerInchY) asInteger. |
|
847 |
right := horzRes - (inset x * pixelsPerInchX) asInteger. |
|
848 |
bottom := vertRes - (inset y * pixelsPerInchY) asInteger |
|
849 |
] ifFalse:[ |
|
850 |
left := (aRectangle left * pixelsPerInchX) asInteger. |
|
851 |
top := (aRectangle top * pixelsPerInchY) asInteger. |
|
852 |
right := (aRectangle right * pixelsPerInchX) asInteger. |
|
853 |
bottom := (aRectangle bottom * pixelsPerInchY) asInteger |
|
854 |
]. |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
855 |
rectangle := left @ top corner:right @ bottom. |
2147 | 856 |
^ rectangle |
857 |
||
858 |
"Created: / 27-07-2006 / 18:22:57 / fm" |
|
859 |
"Modified: / 04-08-2006 / 13:39:45 / fm" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
860 |
"Modified: / 16-04-2007 / 11:57:21 / cg" |
2147 | 861 |
! |
862 |
||
2236 | 863 |
printPage:pageIndex in:aRectangle lines:lines headerLines:headerLines linesPerPage:linesPerPage |
864 |
"Private - print page # pageIndex from lines, assuming |
|
865 |
the given number of linesPerPage." |
|
866 |
||
867 |
|firstLine lastLine l indexString p cHeight rect hLines| |
|
2147 | 868 |
|
2236 | 869 |
firstLine := (pageIndex - 1) * linesPerPage + 1. |
870 |
lastLine := (firstLine + linesPerPage - 1) min:lines size. |
|
2147 | 871 |
rect := aRectangle deepCopy. |
872 |
hLines := headerLines deepCopy. |
|
2236 | 873 |
headerLines size > 0 ifTrue:[ |
874 |
l := hLines first. |
|
2274 | 875 |
p := l indexOfSubCollection: "indexOfString:"'#P'. |
876 |
p = 0 ifFalse:[ |
|
2236 | 877 |
indexString := pageIndex printString , ' '. |
878 |
l := (l copyFrom:1 to:p - 1) , indexString , (l copyFrom:p + 2 to:l size). |
|
879 |
hLines at:1 put:l. |
|
880 |
]. |
|
881 |
cHeight := self getCharHeight. |
|
882 |
rect top:rect top + (hLines size * cHeight). |
|
883 |
]. |
|
884 |
self displayStringLines:hLines in:aRectangle. |
|
885 |
self |
|
886 |
displayStringLines:lines |
|
887 |
from:firstLine |
|
888 |
to:lastLine |
|
889 |
in:rect. |
|
2147 | 890 |
|
891 |
"Created: / 27-07-2006 / 18:28:00 / fm" |
|
892 |
"Modified: / 03-08-2006 / 16:03:15 / fm" |
|
2236 | 893 |
"Modified: / 10-10-2006 / 18:18:15 / cg" |
2274 | 894 |
"Modified: / 30-11-2006 / 13:34:44 / User" |
2147 | 895 |
! |
896 |
||
2236 | 897 |
printPage:pageIndex in:aRectangle lines:lines linesPerPage:linesPerPage |
898 |
"Private - print page # pageIndex from lines, assuming |
|
899 |
the given number of linesPerPage." |
|
900 |
||
901 |
|firstLine lastLine| |
|
902 |
||
903 |
firstLine := (pageIndex - 1) * linesPerPage + 1. |
|
904 |
lastLine := (firstLine + linesPerPage - 1) min:lines size. |
|
905 |
self |
|
906 |
displayStringLines:lines |
|
907 |
from:firstLine |
|
908 |
to:lastLine |
|
909 |
in:aRectangle |
|
2147 | 910 |
|
911 |
"Created: / 27-07-2006 / 18:24:59 / fm" |
|
912 |
"Modified: / 03-08-2006 / 12:47:24 / fm" |
|
2236 | 913 |
"Modified: / 10-10-2006 / 18:18:22 / cg" |
2143 | 914 |
! |
915 |
||
2236 | 916 |
stringWidthOf:aString |
917 |
"Return the width of aString |
|
918 |
when written using the current font." |
|
919 |
||
920 |
^ self stringWidthOf:aString at:aString size. |
|
2143 | 921 |
|
922 |
"Modified: / 03-08-2006 / 10:18:23 / fm" |
|
2236 | 923 |
"Modified: / 10-10-2006 / 18:20:08 / cg" |
2143 | 924 |
! |
925 |
||
2236 | 926 |
stringWidthOf:aString at:index |
927 |
"Return the width of aString up to index |
|
928 |
when written using the current font; expand tabs out |
|
929 |
to 4 spaces for calculations" |
|
930 |
||
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
931 |
self subclassResponsibility |
2236 | 932 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
933 |
"Modified: / 16-04-2007 / 12:45:42 / cg" |
2272 | 934 |
! |
935 |
||
936 |
withLineStyle:aSymbol lineWidth:lw paint:paintColor do:aBlock |
|
937 |
|savStyle savWidth savPaint| |
|
938 |
||
939 |
savStyle := self lineStyle. |
|
940 |
savWidth := self lineWidth. |
|
941 |
savPaint := self paint. |
|
942 |
||
943 |
self lineStyle:aSymbol. |
|
944 |
self lineWidth:lw. |
|
945 |
self paint:paintColor. |
|
946 |
aBlock value. |
|
947 |
self paint:savPaint. |
|
948 |
self lineWidth:savWidth. |
|
949 |
self lineStyle:savStyle. |
|
950 |
||
951 |
"Created: / 13-09-2006 / 15:38:56 / User" |
|
2143 | 952 |
! ! |
953 |
||
954 |
!PrinterContext class methodsFor:'documentation'! |
|
955 |
||
956 |
version |
|
2565 | 957 |
^ '$Header: /cvs/stx/stx/libview2/PrinterContext.st,v 1.19 2008-11-20 08:52:38 fm Exp $' |
2143 | 958 |
! ! |