author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Mon, 23 Jan 2017 12:42:33 +0000 | |
branch | jv |
changeset 3855 | 1db7742d33ad |
parent 3731 | 5d985849d597 |
child 4132 | 7e5528572373 |
permissions | -rw-r--r-- |
2184 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
3 |
All Rights Reserved |
2184 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
15 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
16 |
DeviceGraphicsContext subclass:#PrinterContext |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
17 |
instanceVariableNames:'abort jobid printerInfo textAlign' |
2143 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
20 |
category:'Interface-Printing' |
|
21 |
! |
|
22 |
||
2184 | 23 |
!PrinterContext class methodsFor:'documentation'! |
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
28 |
All Rights Reserved |
2184 | 29 |
|
30 |
This software is furnished under a license and may be used |
|
31 |
only in accordance with the terms of that license and with the |
|
32 |
inclusion of the above copyright notice. This software may not |
|
33 |
be provided or otherwise made available to, or used by, any |
|
34 |
other person. No title to or ownership of the software is |
|
35 |
hereby transferred. |
|
36 |
" |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
37 |
! |
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 |
documentation |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
40 |
" |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
41 |
I am the mediator between the smalltalk printing protocol |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
42 |
(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
|
43 |
windows printer. |
3730 | 44 |
When you open a printer, you will typically talk to me, and I will |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
45 |
forward the graphics commands to my printer. |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
46 |
|
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
47 |
[author:] |
3730 | 48 |
Felix Madrid (fm@exept.de) |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
49 |
" |
2184 | 50 |
! ! |
2143 | 51 |
|
52 |
!PrinterContext class methodsFor:'instance creation'! |
|
53 |
||
54 |
fromPrinterInfo: aPrinterInfo |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
55 |
self subclassResponsibility |
2143 | 56 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
57 |
"Modified: / 16-04-2007 / 12:56:56 / cg" |
2143 | 58 |
! ! |
59 |
||
60 |
!PrinterContext class methodsFor:'accessing'! |
|
61 |
||
62 |
default |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
63 |
"Answer the default Printer, or nil if none." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
64 |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
65 |
|defaultName| |
2143 | 66 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
67 |
^ (defaultName := self defaultPrinterName) isNil |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
68 |
ifTrue:[ nil ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
69 |
ifFalse:[ self named:defaultName ] |
2143 | 70 |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
71 |
" |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
72 |
self default |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
73 |
" |
2143 | 74 |
|
75 |
"Created: / 27-07-2006 / 17:51:43 / fm" |
|
76 |
"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
|
77 |
"Modified: / 10-10-2006 / 17:30:31 / cg" |
2143 | 78 |
! |
79 |
||
80 |
defaultMargins |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
81 |
"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
|
82 |
margins for a page (units in inches)." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
83 |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
84 |
^ 0.5 @ 0.75 |
2143 | 85 |
|
86 |
"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
|
87 |
"Modified: / 10-10-2006 / 17:30:49 / cg" |
2143 | 88 |
! |
89 |
||
90 |
defaultPrinterName |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
91 |
"Answer the name of the default printer, or nil if none." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
92 |
|
2303 | 93 |
|printerInfo printerName| |
94 |
||
95 |
printerInfo := OperatingSystem getDefaultPrinterName. |
|
96 |
printerName := (printerInfo copyFrom:1 to:(printerInfo indexOf:$,) - 1) trimBlanks. |
|
97 |
^ printerName size == 0 ifTrue:[ nil ] ifFalse:[ printerName ] |
|
2143 | 98 |
|
2303 | 99 |
" |
100 |
PrinterContext defaultPrinterName |
|
101 |
" |
|
102 |
||
103 |
"Modified: / 02-08-2006 / 17:26:09 / fm" |
|
104 |
"Modified: / 10-10-2006 / 17:32:45 / cg" |
|
2143 | 105 |
! |
106 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
107 |
getPrinterInformation:printerNameString |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
108 |
" Answer the printer information for the printer named printerNameString. If no name is specified, |
2237 | 109 |
answer the information for the default printer." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
110 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
111 |
self subclassResponsibility |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
112 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
113 |
"Modified: / 16-04-2007 / 12:56:31 / cg" |
2143 | 114 |
! |
115 |
||
116 |
named: aName |
|
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
117 |
"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
|
118 |
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
|
119 |
Control Panel." |
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
120 |
|
2143 | 121 |
aName isNil ifTrue: [ ^self default ]. |
2235
0df6bda4b353
pretty printed & added some documentation and examples
Claus Gittinger <cg@exept.de>
parents:
2184
diff
changeset
|
122 |
^self new printerInfoWithName: aName |
2143 | 123 |
|
124 |
"Created: / 27-07-2006 / 17:51:27 / fm" |
|
125 |
"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
|
126 |
"Modified: / 10-10-2006 / 17:33:29 / cg" |
2143 | 127 |
! |
128 |
||
129 |
printerNames |
|
2237 | 130 |
"Answer a collection of all known printer names." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
131 |
|
2237 | 132 |
^ OperatingSystem getPrintersNames |
2143 | 133 |
|
134 |
"Created: / 27-07-2006 / 17:54:45 / fm" |
|
2237 | 135 |
"Modified: / 10-10-2006 / 18:57:51 / cg" |
2143 | 136 |
! ! |
137 |
||
138 |
!PrinterContext methodsFor:'abort handling'! |
|
139 |
||
140 |
abortPrintJob |
|
2236 | 141 |
"Abort the current print job." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
142 |
|
2143 | 143 |
abort := true. |
144 |
jobid := nil. |
|
145 |
||
146 |
"Modified: / 02-08-2006 / 15:40:26 / fm" |
|
2236 | 147 |
"Modified: / 10-10-2006 / 18:13:45 / cg" |
2143 | 148 |
! |
149 |
||
150 |
aborted |
|
2236 | 151 |
"Answer whether the user aborted from PrintAbortDialog." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
152 |
|
2236 | 153 |
^ abort |
2143 | 154 |
|
155 |
"Created: / 27-07-2006 / 10:20:10 / fm" |
|
2236 | 156 |
"Modified: / 10-10-2006 / 18:13:50 / cg" |
2143 | 157 |
! ! |
158 |
||
159 |
!PrinterContext methodsFor:'accessing'! |
|
160 |
||
2272 | 161 |
container |
162 |
||
163 |
^self |
|
164 |
! |
|
165 |
||
2143 | 166 |
getCharHeight |
2236 | 167 |
"Private - answer the height of the font selected in the receiver's |
168 |
device context." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
169 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
170 |
self subclassResponsibility |
2143 | 171 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
172 |
"Modified: / 16-04-2007 / 12:50:06 / cg" |
2143 | 173 |
! |
174 |
||
2272 | 175 |
horizontalPixelsPerMeter |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
176 |
"Answer horizontal pixels per meter on the screen." |
2272 | 177 |
^self pixelsPerInchOfScreenWidth * 39.3700787 |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
178 |
|
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
179 |
"Modified: / 16-04-2007 / 12:55:21 / cg" |
2272 | 180 |
! |
181 |
||
2236 | 182 |
name |
183 |
"Answer the receiver's name from the current printerInfo." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
184 |
|
2236 | 185 |
^ self printerInfo printerName |
2143 | 186 |
|
187 |
"Modified: / 02-08-2006 / 16:55:03 / fm" |
|
2236 | 188 |
"Modified: / 10-10-2006 / 18:15:33 / cg" |
2143 | 189 |
! |
190 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
191 |
name:aName |
2236 | 192 |
"Set the receiver's printer name to aName." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
193 |
|
2236 | 194 |
self printerInfo:(self class getPrinterInformation:aName) |
2143 | 195 |
|
2236 | 196 |
"Modified: / 10-10-2006 / 18:15:36 / cg" |
2143 | 197 |
! |
198 |
||
199 |
numberOfColorBitsPerPixel |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
200 |
self subclassResponsibility |
2143 | 201 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
202 |
"Modified: / 16-04-2007 / 12:51:15 / cg" |
2143 | 203 |
! |
204 |
||
2272 | 205 |
physicalOffsetX |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
206 |
self subclassResponsibility |
2272 | 207 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
208 |
"Modified: / 16-04-2007 / 12:54:23 / cg" |
2272 | 209 |
! |
210 |
||
211 |
physicalOffsetY |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
212 |
self subclassResponsibility |
2272 | 213 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
214 |
"Modified: / 16-04-2007 / 12:52:17 / cg" |
2272 | 215 |
! |
216 |
||
2143 | 217 |
pixelsPerInchOfScreenHeight |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
218 |
self subclassResponsibility |
2143 | 219 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
220 |
"Modified: / 16-04-2007 / 12:54:17 / cg" |
2143 | 221 |
! |
222 |
||
223 |
pixelsPerInchOfScreenWidth |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
224 |
self subclassResponsibility |
2143 | 225 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
226 |
"Modified: / 16-04-2007 / 12:54:15 / cg" |
2143 | 227 |
! |
228 |
||
2272 | 229 |
printerHeightArea |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
230 |
self subclassResponsibility |
2272 | 231 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
232 |
"Modified: / 16-04-2007 / 12:52:28 / cg" |
2272 | 233 |
! |
234 |
||
2143 | 235 |
printerInfo |
2236 | 236 |
^ printerInfo |
2143 | 237 |
|
238 |
"Created: / 02-08-2006 / 16:55:17 / fm" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
239 |
"Modified: / 16-04-2007 / 12:52:36 / cg" |
2143 | 240 |
! |
241 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
242 |
printerInfo:aPrinterInfo |
2143 | 243 |
printerInfo := aPrinterInfo |
244 |
||
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
245 |
"Modified: / 16-04-2007 / 12:54:07 / cg" |
2143 | 246 |
! |
247 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
248 |
printerInfoWithName:aName |
2236 | 249 |
self printerInfo:(self class getPrinterInformation:aName). |
2143 | 250 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
251 |
"Modified: / 16-04-2007 / 12:54:04 / cg" |
2143 | 252 |
! |
253 |
||
2272 | 254 |
printerPhysicalHeight |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
255 |
self subclassResponsibility |
2272 | 256 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
257 |
"Modified: / 16-04-2007 / 12:54:00 / cg" |
2272 | 258 |
! |
259 |
||
260 |
printerPhysicalWidth |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
261 |
self subclassResponsibility |
2272 | 262 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
263 |
"Modified: / 16-04-2007 / 12:53:56 / cg" |
2272 | 264 |
! |
265 |
||
2143 | 266 |
printerUserFriendlyName |
2236 | 267 |
"Answer the receiver's name from the current printerInfo." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
268 |
|
2236 | 269 |
^ self printerInfo userFriendlyName |
2143 | 270 |
|
271 |
"Created: / 03-08-2006 / 12:55:57 / fm" |
|
2236 | 272 |
"Modified: / 10-10-2006 / 18:18:55 / cg" |
2272 | 273 |
! |
274 |
||
275 |
printerWidthArea |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
276 |
self subclassResponsibility |
2272 | 277 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
278 |
"Modified: / 16-04-2007 / 12:53:51 / cg" |
2272 | 279 |
! |
280 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
281 |
setPrinterFont:aFont |
2273 | 282 |
|
283 |
self font: aFont |
|
284 |
||
285 |
"Created: / 27-11-2006 / 14:50:55 / User" |
|
286 |
! |
|
287 |
||
2272 | 288 |
setTextAlign:aNumber |
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
289 |
textAlign :=aNumber. |
2272 | 290 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
291 |
"Modified: / 16-04-2007 / 12:53:26 / cg" |
2272 | 292 |
! |
293 |
||
294 |
setViewportOrg: aPoint |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
295 |
self subclassResponsibility |
2272 | 296 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
297 |
"Modified: / 16-04-2007 / 12:53:44 / cg" |
2272 | 298 |
! |
299 |
||
300 |
verticalPixelsPerMeter |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
301 |
"Answer vertical pixels per meter on the screen." |
2272 | 302 |
|
303 |
^self pixelsPerInchOfScreenHeight * 39.3700787 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
304 |
|
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
305 |
"Modified: / 16-04-2007 / 12:54:43 / cg" |
2143 | 306 |
! ! |
307 |
||
308 |
!PrinterContext methodsFor:'initialization & release'! |
|
309 |
||
310 |
buildPrinter |
|
2236 | 311 |
"Private - create all the operating system resources needed." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
312 |
|
2236 | 313 |
self |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
314 |
createDC; |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
315 |
initExtent |
2143 | 316 |
|
317 |
"Created: / 27-07-2006 / 10:20:36 / fm" |
|
318 |
"Modified: / 01-08-2006 / 15:57:49 / fm" |
|
2236 | 319 |
"Modified: / 10-10-2006 / 18:14:04 / cg" |
2143 | 320 |
! |
321 |
||
322 |
createDC |
|
2236 | 323 |
"Private - Create a device context for the receiver" |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
324 |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
325 |
self subclassResponsibility |
2143 | 326 |
|
327 |
"Created: / 27-07-2006 / 10:21:05 / fm" |
|
328 |
"Modified: / 02-08-2006 / 17:30:47 / fm" |
|
2300
4f9a576ecdc6
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2275
diff
changeset
|
329 |
"Modified: / 16-04-2007 / 12:49:22 / cg" |
2143 | 330 |
! |
331 |
||
332 |
initExtent |
|
333 |
"Private - init the width and height of GraphicsTool for the receiver." |
|
2272 | 334 |
|
3628
577364da51bb
Replace all `self graphicsDevice` with `device`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3315
diff
changeset
|
335 |
device |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
336 |
width:self printerWidthArea; |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
337 |
height:self printerHeightArea. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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" |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
345 |
|
2314 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
355 |
print:aString font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
2236 | 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." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
363 |
|
2247 | 364 |
|lines linesPerPage totalPage marginsRect firstPage abortDialog| |
2143 | 365 |
|
2236 | 366 |
jobid isNil ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
367 |
self startPrintJob:aTitle |
2236 | 368 |
]. |
369 |
abortDialog := PrintAbortDialog new open:aTitle printer:self. |
|
370 |
self font:aFont. |
|
371 |
marginsRect := self marginsRectangleFor:aMarginsRect. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
372 |
lines := self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
373 |
asArrayOfStringLines:aString |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
374 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
375 |
wordWrap:wordWrapBoolean. |
2247 | 376 |
linesPerPage := self linesPerPageFor: marginsRect. |
2236 | 377 |
totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
2143 | 378 |
firstPage := true. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
379 |
|
2143 | 380 |
"/ collateBoolean |
381 |
"/ ifTrue: [ |
|
382 |
"/ copiesInteger timesRepeat: [ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
383 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
384 |
1 to:totalPage do:[:page | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
385 |
abort ifTrue:[ ^ self ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
386 |
firstPage ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
387 |
self formFeed |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
388 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
389 |
abortDialog |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
390 |
updatePrintingPageInfo:(self class classResources |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
391 |
string:'Page %1/%2' |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
392 |
with:page printString |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
393 |
with:totalPage printString). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
394 |
|
2143 | 395 |
"/ self device font: printerFont. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
396 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
397 |
self font:aFont. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
398 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
399 |
printPage:page |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
400 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
401 |
lines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
402 |
linesPerPage:linesPerPage. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
403 |
firstPage := false |
2236 | 404 |
]. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
405 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
406 |
"/ ] |
2143 | 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. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
414 |
"/ firstPage := false |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
415 |
"/ ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
416 |
"/ ] |
2143 | 417 |
"/ ]. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
418 |
|
2236 | 419 |
jobid notNil ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
420 |
self endPrintJob. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
421 |
abortDialog close. |
2236 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
441 |
"Private - Answer the receiver. Output the receiver string to |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
442 |
the printer using aFont. A Print abort dialog box will be opened |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
443 |
with aTitle. If collateBoolean is true, collate output, otherwise |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
444 |
do not. Print copiesInteger copies of the specified string. If |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
445 |
wordWrapBoolean is true, word wrap the lines, otherwise do not. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
446 |
Left, top, right & bottom margins are specified in inches in |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
447 |
aMarginsRect. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
448 |
Mg: Erweitert um pageHeader" |
2274 | 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 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
461 |
ifFalse: |
3730 | 462 |
[Dialog information: 'Der Dokumentenkopf ist zu groß; wird ignoriert!!'. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
463 |
headerLines := #(). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
464 |
] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
465 |
ifTrue: [linesPerPage := linesPerPage - headerLines size]. |
2274 | 466 |
totalPage := lines size + linesPerPage - 1 // linesPerPage. |
467 |
firstPage := true. |
|
468 |
||
469 |
"/ collateBoolean |
|
470 |
"/ ifTrue: [ |
|
471 |
"/ copiesInteger timesRepeat: [ |
|
472 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
473 |
1 to: totalPage do: [ :page | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
474 |
abort ifTrue: [ ^self endPrintJob ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
475 |
firstPage ifFalse: [ self formFeed ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
476 |
self "pen" font: aFont "printerFont". |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
477 |
self printPage: page in: marginsRect lines: lines headerLines: headerLines linesPerPage: linesPerPage. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
478 |
firstPage := false ] |
2274 | 479 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
480 |
"/ ] |
2274 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
494 |
print:aString pageHeader:aString2 font:aFont title:aTitle wordWrap:wordWrapBoolean marginsRect:aMarginsRect |
2236 | 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." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
502 |
|
2236 | 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. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
508 |
lines := self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
509 |
asArrayOfStringLines:aString |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
510 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
511 |
wordWrap:wordWrapBoolean. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
512 |
headerLines := self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
513 |
asArrayOfStringLines:aString2 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
514 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
515 |
wordWrap:wordWrapBoolean. |
2236 | 516 |
linesPerPage := (marginsRect bottom - marginsRect top) // charHeight. |
517 |
linesPerPage > headerLines size ifFalse:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
518 |
Dialog information:(self class classResources |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
519 |
string:'The header is too large - ignored!!'). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
520 |
headerLines := #(). |
2236 | 521 |
] ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
522 |
linesPerPage := linesPerPage - headerLines size |
2236 | 523 |
]. |
524 |
totalPage := (lines size + linesPerPage - 1) // linesPerPage. |
|
2143 | 525 |
firstPage := true. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
526 |
|
2143 | 527 |
"/ collateBoolean |
528 |
"/ ifTrue: [ |
|
529 |
"/ copiesInteger timesRepeat: [ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
530 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
531 |
1 to:totalPage do:[:page | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
532 |
abort ifTrue:[ ^ self ]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
533 |
firstPage ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
534 |
self formFeed |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
535 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
536 |
self font:printerFont. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
537 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
538 |
printPage:page |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
539 |
in:marginsRect |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
540 |
lines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
541 |
headerLines:headerLines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
542 |
linesPerPage:linesPerPage. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
543 |
firstPage := false |
2236 | 544 |
] |
2143 | 545 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
546 |
"/ ] |
2236 | 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. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
554 |
"/ firstPage := false |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
555 |
"/ ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
556 |
"/ ] |
2236 | 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." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 " |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
596 |
|
2143 | 597 |
self |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
598 |
endPage; |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
599 |
startPage |
2143 | 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." |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
616 |
|
2236 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
623 |
startPrintJob:aString |
2236 | 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." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
627 |
|
2236 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
634 |
startPrintJob:aString fileName:aFileName |
2236 | 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." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
667 |
asArrayOfStringLines:aString in:aRectangle wordWrap:wordWrapBoolean |
2236 | 668 |
"Private - convert aString into an array of lines; if wordWrapBoolean |
669 |
is true, also perform word wrapping on the lines, within aRectangle." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
670 |
|
2236 | 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:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
676 |
leftMargin := aRectangle left. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
677 |
rightMargin := aRectangle right |
2236 | 678 |
]. |
679 |
[ stream atEnd ] whileFalse:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
680 |
line := stream nextLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
681 |
wordWrapBoolean ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
682 |
lines add:line |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
683 |
] ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
684 |
x0 := x1 := 1. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
685 |
1 to:line size do:[:i | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
686 |
((line at:i) = Character space "32" |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
687 |
and:[ (partialLine := line copyFrom:x0 to:i) trimBlanks notEmpty ]) |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
688 |
ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
689 |
partialLineWidth := self stringWidthOf:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
690 |
(leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
691 |
partialLine := line copyFrom:x0 to:x1. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
692 |
lines add:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
693 |
x0 := x1 + 1 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
694 |
] ifFalse:[ x1 := i ] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
695 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
696 |
index := i |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
697 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
698 |
line isEmpty ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
699 |
lines add:line |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
700 |
] ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
701 |
partialLine := line copyFrom:x0 to:index. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
702 |
partialLineWidth := self stringWidthOf:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
703 |
(leftMargin + partialLineWidth) > rightMargin ifTrue:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
704 |
partialLine := line copyFrom:x0 to:x1. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
705 |
lines add:partialLine. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
706 |
partialLine := line copyFrom:x1 + 1 to:index |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
707 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
708 |
lines add:partialLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
709 |
] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
724 |
self displayString:aString at:aPoint. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
725 |
^ self |
2272 | 726 |
]. |
727 |
(textAlign == 8 "TaBottom") ifTrue:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
728 |
y := aPoint y - (self container font ascent) "container font ascent". |
2272 | 729 |
] ifFalse:[ (textAlign == 6 "TaCenter") ifTrue:[ |
730 |
"/ x := aRect left + ((aRect width-(container font widthOf:aString))//2). |
|
731 |
] ifFalse:[ (textAlign == 2 "TaRight") ifTrue:[ |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
735 |
y := aRect bottom - self getCharHeight "container font ascent". |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
736 |
x := aRect left + ((aRect width-(self "container font widthOf:" stringWidthOf:aString))//2). |
2272 | 737 |
] ifFalse:[ (textAlign == 10) ifTrue:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
738 |
x := aRect right - (self "container font widthof:" stringWidthOf:aString). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
756 |
displayStringLines:anIndexedCollection from:startIndex to:endIndex in:aRectangle |
2236 | 757 |
"Private - display Strings in anIndexedCollection starting at startIndex and |
758 |
ending at endIndex, clipped within the bounds of aRectangle." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
759 |
|
3315
c51703ef04b6
Access graphicsDevice via method send instead of instVar access
Stefan Vogel <sv@exept.de>
parents:
3287
diff
changeset
|
760 |
|charHeight ascent| |
2236 | 761 |
|
2147 | 762 |
charHeight := self getCharHeight. |
2236 | 763 |
ascent := self font ascentOn:self device. |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
764 |
startIndex to:endIndex do:[:i | |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
765 |
|lineToPrint| |
2236 | 766 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
767 |
lineToPrint := (anIndexedCollection at:i). |
3628
577364da51bb
Replace all `self graphicsDevice` with `device`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3315
diff
changeset
|
768 |
device |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
769 |
displayString:lineToPrint |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
770 |
from:1 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
771 |
to:lineToPrint size |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
772 |
x:aRectangle left |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
773 |
y:(aRectangle top + ((i - startIndex) * charHeight)) |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
774 |
in:nil |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
775 |
with:self gcId |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
776 |
opaque:false |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
795 |
displayStringLines:anIndexedCollection in:aRectangle |
2236 | 796 |
"Private - display anIndexedCollection of Strings clipped within |
797 |
the bounds of aRectangle." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
798 |
|
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
799 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
800 |
displayStringLines:anIndexedCollection |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
801 |
from:1 |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
802 |
to:anIndexedCollection size |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
818 |
marginsRect := aRectangle isNil |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
819 |
ifTrue:[self marginsRectangleFor: nil] |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
820 |
ifFalse:[aRectangle]. |
2247 | 821 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
822 |
charHeight := self getCharHeight. |
2247 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
829 |
marginsRectangleFor:aRectangle |
2147 | 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)." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
833 |
|
2147 | 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:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
842 |
horzRes := self printerWidthArea. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
843 |
vertRes := self printerHeightArea. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
844 |
inset := self class defaultMargins. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
845 |
left := (inset x * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
846 |
top := (inset y * pixelsPerInchY) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
847 |
right := horzRes - (inset x * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
848 |
bottom := vertRes - (inset y * pixelsPerInchY) asInteger |
2147 | 849 |
] ifFalse:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
850 |
left := (aRectangle left * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
851 |
top := (aRectangle top * pixelsPerInchY) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
852 |
right := (aRectangle right * pixelsPerInchX) asInteger. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
853 |
bottom := (aRectangle bottom * pixelsPerInchY) asInteger |
2147 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
863 |
printPage:pageIndex in:aRectangle lines:lines headerLines:headerLines linesPerPage:linesPerPage |
2236 | 864 |
"Private - print page # pageIndex from lines, assuming |
865 |
the given number of linesPerPage." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
866 |
|
2236 | 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:[ |
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
874 |
l := hLines first. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
875 |
p := l indexOfSubCollection: "indexOfString:"'#P'. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
876 |
p = 0 ifFalse:[ |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
877 |
indexString := pageIndex printString , ' '. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
878 |
l := (l copyFrom:1 to:p - 1) , indexString , (l copyFrom:p + 2 to:l size). |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
879 |
hLines at:1 put:l. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
880 |
]. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
881 |
cHeight := self getCharHeight. |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
882 |
rect top:rect top + (hLines size * cHeight). |
2236 | 883 |
]. |
884 |
self displayStringLines:hLines in:aRectangle. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
885 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
886 |
displayStringLines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
887 |
from:firstLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
888 |
to:lastLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
897 |
printPage:pageIndex in:aRectangle lines:lines linesPerPage:linesPerPage |
2236 | 898 |
"Private - print page # pageIndex from lines, assuming |
899 |
the given number of linesPerPage." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
900 |
|
2236 | 901 |
|firstLine lastLine| |
902 |
||
903 |
firstLine := (pageIndex - 1) * linesPerPage + 1. |
|
904 |
lastLine := (firstLine + linesPerPage - 1) min:lines size. |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
905 |
self |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
906 |
displayStringLines:lines |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
907 |
from:firstLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
908 |
to:lastLine |
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
916 |
stringWidthOf:aString |
2236 | 917 |
"Return the width of aString |
918 |
when written using the current font." |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
919 |
|
2236 | 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 |
||
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
926 |
stringWidthOf:aString at:index |
2236 | 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" |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
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 |
|
3709
ae76cdc6787a
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
3315
diff
changeset
|
957 |
^ '$Header$' |
2143 | 958 |
! ! |
3287 | 959 |