author | Claus Gittinger <cg@exept.de> |
Mon, 16 Apr 2007 13:04:45 +0200 | |
changeset 2304 | f39eb95d4d48 |
parent 2301 | 135f21a3d127 |
child 2313 | a3fa5abef172 |
permissions | -rw-r--r-- |
2299 | 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 |
" |
|
12 |
"{ Package: 'stx:libview2' }" |
|
13 |
||
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
14 |
PrinterContext subclass:#WinPrinterContext |
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
15 |
instanceVariableNames:'' |
2299 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Interface-Printing' |
|
19 |
! |
|
20 |
||
21 |
!WinPrinterContext 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 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
39 |
I am the mediator between the smalltalk printing protocol |
|
40 |
(which is the same as the graphics drawing protocol) and the |
|
41 |
windows printer. |
|
42 |
When youopena printer, you will typically talk to me, and I will |
|
43 |
forward the graphics commands to my printer. |
|
44 |
||
45 |
[author:] |
|
46 |
Felix Madrid (fm@exept.de) |
|
47 |
" |
|
48 |
! ! |
|
49 |
||
50 |
!WinPrinterContext class methodsFor:'instance creation'! |
|
51 |
||
52 |
fromPrinterInfo: aPrinterInfo |
|
53 |
| aPrinter hDC| |
|
54 |
||
55 |
hDC := aPrinterInfo createDC. |
|
56 |
hDC = 0 ifTrue: [ ^self error: 'Error while opening printer.' ]. |
|
57 |
||
58 |
aPrinter := self new. |
|
59 |
aPrinter printerInfo: aPrinterInfo. |
|
60 |
aPrinter setDevice:(WinPrinter on: aPrinterInfo) id:nil gcId:hDC. |
|
61 |
aPrinter initExtent. |
|
62 |
^aPrinter |
|
63 |
||
64 |
"Created: / 03-08-2006 / 12:53:52 / fm" |
|
65 |
"Modified: / 04-08-2006 / 12:55:01 / fm" |
|
66 |
"Modified: / 16-04-2007 / 12:36:26 / cg" |
|
67 |
! ! |
|
68 |
||
69 |
!WinPrinterContext class methodsFor:'accessing'! |
|
70 |
||
71 |
getPrinterInformation:printerNameString |
|
72 |
" Answer the printer information for the printer named printerNameString. If no name is specified, |
|
73 |
answer the information for the default printer." |
|
74 |
||
75 |
|h| |
|
76 |
||
77 |
h := OperatingSystem openPrinter:printerNameString. |
|
78 |
^ OperatingSystem |
|
79 |
getDocumentProperties:nil |
|
80 |
hPrinter:h |
|
81 |
pDeviceName:printerNameString. |
|
82 |
||
83 |
"Created: / 27-07-2006 / 10:22:32 / fm" |
|
84 |
"Modified: / 01-08-2006 / 16:01:44 / fm" |
|
85 |
"Modified: / 10-10-2006 / 18:57:45 / cg" |
|
86 |
! |
|
87 |
||
88 |
named: aName |
|
89 |
"Answer a new instance of Printer which represents |
|
90 |
the printer named aName as specified in the host |
|
91 |
Control Panel." |
|
92 |
||
93 |
aName isNil ifTrue: [ ^self default ]. |
|
94 |
^self new printerInfoWithName: aName |
|
95 |
||
96 |
"Created: / 27-07-2006 / 17:51:27 / fm" |
|
97 |
"Modified: / 02-08-2006 / 17:26:29 / fm" |
|
98 |
"Modified: / 10-10-2006 / 17:33:29 / cg" |
|
99 |
! ! |
|
100 |
||
101 |
!WinPrinterContext class methodsFor:'testing & examples'! |
|
102 |
||
103 |
print: aString font: aFont title: aTitle |
|
104 |
"Open a print dialog to allow printing of the given string |
|
105 |
using the given title & font." |
|
106 |
||
107 |
self print: aString font: aFont title: aTitle wordWrap: false |
|
108 |
||
109 |
" |
|
110 |
PrinterContext print: 'Holaaaa!! (from: PrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test' |
|
111 |
PrinterContext print: self printingTestString font: nil title: 'Printing Test String' |
|
112 |
PrinterContext print: self printingTestString font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String' |
|
113 |
" |
|
114 |
||
115 |
"Created: / 27-07-2006 / 17:52:33 / fm" |
|
116 |
"Modified: / 03-08-2006 / 18:52:31 / fm" |
|
117 |
"Modified: / 10-10-2006 / 17:37:49 / cg" |
|
118 |
! |
|
119 |
||
120 |
print: aString font: aFont title: aTitle wordWrap: wordWrap |
|
121 |
"Open a print dialog to allow printing of the given string |
|
122 |
using the given title & font." |
|
123 |
||
124 |
| printerInfo printer | |
|
125 |
||
126 |
printerInfo := PrintingDialog getPrinterInfo. |
|
127 |
printerInfo isNil ifTrue:[^self]. |
|
128 |
||
129 |
printer := self fromPrinterInfo: printerInfo. |
|
130 |
[ |
|
131 |
printer |
|
132 |
print: aString |
|
133 |
font: aFont |
|
134 |
title: aTitle |
|
135 |
wordWrap: wordWrap |
|
136 |
marginsRect: nil |
|
137 |
] forkAt: 3 |
|
138 |
||
139 |
" |
|
140 |
PrinterContext print: 'Holaaaa!! (from: PrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test' wordWrap: true |
|
141 |
PrinterContext print: (PrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font:nil title:'Printing Test String' wordWrap:true |
|
142 |
PrinterContext print: (PrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String' wordWrap: true |
|
143 |
" |
|
144 |
||
145 |
"Created: / 03-08-2006 / 18:51:53 / fm" |
|
146 |
"Modified: / 10-10-2006 / 17:42:06 / cg" |
|
147 |
! |
|
148 |
||
149 |
printCircles: arrayOfPointsAndRadius |
|
150 |
"Opens a print dialog and prints the given circles" |
|
151 |
||
152 |
| printerInfo printer | |
|
153 |
||
154 |
printerInfo := PrintingDialog getPrinterInfo. |
|
155 |
printerInfo isNil ifTrue:[^self]. |
|
156 |
||
157 |
printer := self fromPrinterInfo: printerInfo. |
|
158 |
[ |
|
159 |
printer startPrintJob: 'Circles'. |
|
160 |
arrayOfPointsAndRadius |
|
161 |
do:[:pointAndRadius | |
|
162 |
printer displayCircle:(pointAndRadius at:1) |
|
163 |
radius:(pointAndRadius at:2). |
|
164 |
]. |
|
165 |
printer endPrintJob. |
|
166 |
] forkAt: 3 |
|
167 |
||
168 |
" |
|
169 |
PrinterContext printCircles: |
|
170 |
(Array with: (Array with: 800@800 with: 600) |
|
171 |
with: (Array with: 1500@1500 with: 1000) |
|
172 |
with: (Array with: 4000@2500 with: 2000)) |
|
173 |
" |
|
174 |
||
175 |
"Created: / 07-08-2006 / 11:46:52 / fm" |
|
176 |
"Modified: / 10-10-2006 / 17:36:23 / cg" |
|
177 |
! |
|
178 |
||
179 |
printCirclesIn: rectangles |
|
180 |
"Opens a print dialog and prints the given circles" |
|
181 |
||
182 |
| printerInfo printer | |
|
183 |
||
184 |
printerInfo := PrintingDialog getPrinterInfo. |
|
185 |
printerInfo isNil ifTrue:[^self]. |
|
186 |
||
187 |
printer := self fromPrinterInfo: printerInfo. |
|
188 |
[ |
|
189 |
printer startPrintJob: 'Circles In Rectangles'. |
|
190 |
rectangles |
|
191 |
do:[:rectangle | |
|
192 |
printer displayCircleIn: rectangle. |
|
193 |
]. |
|
194 |
printer endPrintJob. |
|
195 |
] forkAt: 3 |
|
196 |
||
197 |
" |
|
198 |
PrinterContext printCirclesIn: |
|
199 |
(Array with: (Rectangle left:20 top:20 width:400 height:600) |
|
200 |
with: (Rectangle left:40 top:40 width:600 height:400) |
|
201 |
) |
|
202 |
" |
|
203 |
||
204 |
"Created: / 07-08-2006 / 11:48:46 / fm" |
|
205 |
"Modified: / 10-10-2006 / 17:38:28 / cg" |
|
206 |
! |
|
207 |
||
208 |
printLines: pairOfPointsArray |
|
209 |
"Opens a print dialog and prints the given lines" |
|
210 |
||
211 |
| printerInfo printer | |
|
212 |
||
213 |
printerInfo := PrintingDialog getPrinterInfo. |
|
214 |
printerInfo isNil ifTrue:[^self]. |
|
215 |
||
216 |
printer := self fromPrinterInfo: printerInfo. |
|
217 |
[ |
|
218 |
printer startPrintJob: 'Lines'. |
|
219 |
printer foreground:Color black background:Color white. |
|
220 |
pairOfPointsArray |
|
221 |
do:[:pairOfPoints | |
|
222 |
printer displayLineFrom: (pairOfPoints at:1) to: (pairOfPoints at:2). |
|
223 |
]. |
|
224 |
printer endPrintJob. |
|
225 |
] forkAt: 3 |
|
226 |
||
227 |
" |
|
228 |
PrinterContext printLines: |
|
229 |
(Array with: (Array with:10@10 with:100@10) |
|
230 |
with: (Array with:10@10 with:35@200)) |
|
231 |
" |
|
232 |
||
233 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
234 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
235 |
"Modified: / 10-10-2006 / 17:38:44 / cg" |
|
236 |
! |
|
237 |
||
238 |
printPolygons: polygons |
|
239 |
"Opens a print dialog and prints the given polygons" |
|
240 |
||
241 |
| printerInfo printer | |
|
242 |
||
243 |
printerInfo := PrintingDialog getPrinterInfo. |
|
244 |
printerInfo isNil ifTrue:[^self]. |
|
245 |
||
246 |
printer := self fromPrinterInfo: printerInfo. |
|
247 |
[ |
|
248 |
printer startPrintJob: 'Polygons'. |
|
249 |
printer foreground:Color black background:Color white. |
|
250 |
polygons |
|
251 |
do:[:aPolygon | |
|
252 |
aPolygon displayStrokedOn: printer. |
|
253 |
]. |
|
254 |
printer endPrintJob. |
|
255 |
] forkAt: 3 |
|
256 |
||
257 |
" |
|
258 |
PrinterContext printPolygons: |
|
259 |
(Array with: (Polygon vertices:( |
|
260 |
Array |
|
261 |
with:10@10 |
|
262 |
with:60@10 |
|
263 |
with:35@60))) |
|
264 |
" |
|
265 |
||
266 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
267 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
268 |
"Modified: / 10-10-2006 / 17:39:23 / cg" |
|
269 |
! |
|
270 |
||
271 |
printRectangles: rectangles |
|
272 |
"Opens a print dialog and prints the given rectangles" |
|
273 |
||
274 |
| printerInfo printer | |
|
275 |
||
276 |
printerInfo := PrintingDialog getPrinterInfo. |
|
277 |
printerInfo isNil ifTrue:[^self]. |
|
278 |
||
279 |
printer := self fromPrinterInfo: printerInfo. |
|
280 |
[ |
|
281 |
printer startPrintJob: 'Rectangles'. |
|
282 |
rectangles |
|
283 |
do:[:rectangle | |
|
284 |
printer displayRectangleX: rectangle origin x |
|
285 |
y: rectangle origin y |
|
286 |
width: rectangle width |
|
287 |
height: rectangle height. |
|
288 |
]. |
|
289 |
printer endPrintJob. |
|
290 |
] forkAt: 3 |
|
291 |
||
292 |
" |
|
293 |
PrinterContext printRectangles: |
|
294 |
(Array with: (Rectangle left:20 top:20 width:400 height:600) |
|
295 |
with: (Rectangle left:40 top:40 width:600 height:400) |
|
296 |
) |
|
297 |
" |
|
298 |
||
299 |
"Created: / 07-08-2006 / 11:40:48 / fm" |
|
300 |
"Modified: / 10-10-2006 / 17:39:51 / cg" |
|
301 |
! |
|
302 |
||
303 |
printStrings: stringAndPositionsArray |
|
304 |
"Opens a print dialog and prints the given strings" |
|
305 |
||
306 |
| printerInfo printer | |
|
307 |
||
308 |
printerInfo := PrintingDialog getPrinterInfo. |
|
309 |
printerInfo isNil ifTrue:[^self]. |
|
310 |
||
311 |
printer := self fromPrinterInfo: printerInfo. |
|
312 |
[ |
|
313 |
printer startPrintJob: 'Strings with Position'. |
|
314 |
printer foreground:Color black background:Color white. |
|
315 |
stringAndPositionsArray |
|
316 |
do:[:pairOfPointsAndPosition | |
|
317 |
printer displayString:(pairOfPointsAndPosition at: 1) |
|
318 |
x:(pairOfPointsAndPosition at: 2) x |
|
319 |
y:(pairOfPointsAndPosition at: 2) y |
|
320 |
]. |
|
321 |
printer endPrintJob. |
|
322 |
] forkAt: 3 |
|
323 |
||
324 |
" |
|
325 |
PrinterContext printStrings: |
|
326 |
(Array with: (Array with:'Testing printing with standart method' with:10@10) |
|
327 |
with: (Array with:'Another test string to print' with:80@200)) |
|
328 |
" |
|
329 |
||
330 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
331 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
332 |
"Modified: / 10-10-2006 / 17:40:07 / cg" |
|
333 |
! ! |
|
334 |
||
335 |
!WinPrinterContext methodsFor:'accessing'! |
|
336 |
||
337 |
getCharHeight |
|
338 |
"Private - answer the height of the font selected in the receiver's |
|
339 |
device context." |
|
340 |
||
341 |
|textMetrics answer| |
|
342 |
||
343 |
||
344 |
textMetrics := Win32OperatingSystem::TextMetricsStructure new. |
|
345 |
"/ (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ]. |
|
346 |
"/ Transcript showCR: 'CHAR HEIGHT PRIM ******* ', ' ', (textMetrics tmHeight + textMetrics tmExternalLeading) printString. |
|
347 |
"/ Transcript showCR: 'CHAR HEIGHT DEVICE ***** ', ' ', (self font heightOf:'PQWEXCZ' on:self device) printString. |
|
348 |
answer := (self font heightOf:'PQWEXCZ' on:self device). |
|
349 |
"/ answer := textMetrics tmHeight + textMetrics tmExternalLeading. |
|
350 |
^answer |
|
351 |
||
352 |
"Created: / 02-08-2006 / 17:47:20 / fm" |
|
353 |
"Modified: / 03-08-2006 / 10:09:01 / fm" |
|
354 |
"Modified: / 10-10-2006 / 18:15:17 / cg" |
|
355 |
! |
|
356 |
||
357 |
numberOfColorBitsPerPixel |
|
358 |
^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel" |
|
359 |
||
360 |
"Created: / 03-08-2006 / 09:58:18 / fm" |
|
361 |
"Modified: / 10-10-2006 / 18:15:40 / cg" |
|
362 |
! |
|
363 |
||
364 |
physicalOffsetX |
|
365 |
^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX" |
|
366 |
||
367 |
"Created: / 01-08-2006 / 16:28:34 / fm" |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
368 |
"Modified: / 16-04-2007 / 12:52:06 / cg" |
2299 | 369 |
! |
370 |
||
371 |
physicalOffsetY |
|
372 |
^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY" |
|
373 |
||
374 |
"Created: / 01-08-2006 / 16:28:34 / fm" |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
375 |
"Modified: / 16-04-2007 / 12:52:01 / cg" |
2299 | 376 |
! |
377 |
||
378 |
pixelsPerInchOfScreenHeight |
|
379 |
^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy" |
|
380 |
||
381 |
"Created: / 01-08-2006 / 16:29:16 / fm" |
|
382 |
! |
|
383 |
||
384 |
pixelsPerInchOfScreenWidth |
|
385 |
^ OperatingSystem getDeviceCaps:gcId index:88 "Logpixelsx" |
|
386 |
||
387 |
"Created: / 01-08-2006 / 16:28:34 / fm" |
|
388 |
! |
|
389 |
||
390 |
printerHeightArea |
|
391 |
^ (OperatingSystem getDeviceCaps:gcId index:10) |
|
392 |
||
393 |
"Modified: / 10-10-2006 / 18:18:31 / cg" |
|
394 |
! |
|
395 |
||
396 |
printerPhysicalHeight |
|
397 |
^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:111 "PhysicalHeight" |
|
398 |
||
399 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
400 |
! |
|
401 |
||
402 |
printerPhysicalWidth |
|
403 |
^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:110 "PhysicalWidth" |
|
404 |
||
405 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
406 |
! |
|
407 |
||
408 |
printerWidthArea |
|
409 |
^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres" |
|
410 |
||
411 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
412 |
! |
|
413 |
||
414 |
setViewportOrg: aPoint |
|
415 |
||
416 |
^ OperatingSystem |
|
417 |
setViewportOrg: gcId "deviceContext" |
|
418 |
x: aPoint x |
|
419 |
y: aPoint y |
|
420 |
oldOrigin: nil |
|
421 |
||
422 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
423 |
! ! |
|
424 |
||
425 |
!WinPrinterContext methodsFor:'initialization & release'! |
|
426 |
||
427 |
createDC |
|
428 |
"Private - Create a device context for the receiver" |
|
429 |
||
430 |
gcId := printerInfo createDC |
|
431 |
||
432 |
"Created: / 27-07-2006 / 10:21:05 / fm" |
|
433 |
"Modified: / 02-08-2006 / 17:30:47 / fm" |
|
434 |
"Modified: / 10-10-2006 / 18:14:28 / cg" |
|
435 |
! |
|
436 |
||
437 |
executor |
|
438 |
|aCopy| |
|
439 |
||
440 |
aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew. |
|
441 |
aCopy setDevice:device id:nil gcId:gcId. |
|
442 |
^ aCopy |
|
443 |
||
444 |
"Created: / 16-04-2007 / 12:39:02 / cg" |
|
445 |
! ! |
|
446 |
||
447 |
!WinPrinterContext methodsFor:'printing process'! |
|
448 |
||
449 |
endPage |
|
450 |
"Informs device that we are finished writing to a page." |
|
451 |
||
452 |
(OperatingSystem endPage:gcId) > 0 ifFalse:[ |
|
453 |
self error |
|
454 |
] |
|
455 |
||
456 |
"Created: / 27-07-2006 / 18:20:48 / fm" |
|
457 |
"Modified: / 01-08-2006 / 16:01:34 / fm" |
|
458 |
"Modified: / 10-10-2006 / 18:14:44 / cg" |
|
459 |
! |
|
460 |
||
461 |
endPrintJob |
|
462 |
"End the print job. Everything drawn between startPrintJob |
|
463 |
and endPrintJob will become one entry in the print queue." |
|
464 |
||
465 |
|result| |
|
466 |
||
467 |
self endPage. |
|
468 |
result := OperatingSystem endDoc:gcId. |
|
469 |
device close. |
|
470 |
gcId := nil. |
|
471 |
jobid := nil. |
|
472 |
result >= 0 ifFalse:[ self error ] |
|
473 |
||
474 |
"Created: / 27-07-2006 / 18:21:04 / fm" |
|
475 |
"Modified: / 01-08-2006 / 16:01:38 / fm" |
|
476 |
"Modified: / 10-10-2006 / 18:50:43 / cg" |
|
477 |
! |
|
478 |
||
479 |
startPage |
|
480 |
"Starts a page." |
|
481 |
||
482 |
(OperatingSystem startPage:gcId) > 0 ifFalse:[ |
|
483 |
^ self error |
|
484 |
]. |
|
485 |
||
486 |
"Created: / 27-07-2006 / 18:25:55 / fm" |
|
487 |
"Modified: / 28-07-2006 / 18:19:04 / fm" |
|
488 |
"Modified: / 10-10-2006 / 18:19:02 / cg" |
|
489 |
! |
|
490 |
||
491 |
startPrintJob:aString fileName:aFileName |
|
492 |
"Start a print job, using aString as the job title; everything |
|
493 |
drawn between startPrintJob and endPrintJob will become |
|
494 |
one entry in the print queue." |
|
495 |
||
496 |
|docInfoStruct nameAddress title fileNameAddress| |
|
497 |
||
498 |
gcId isNil ifTrue:[ |
|
499 |
self buildPrinter |
|
500 |
]. |
|
501 |
abort := false. |
|
502 |
title := aString ? 'Smalltalk/X'. |
|
503 |
nameAddress := title asExternalBytes unprotectFromGC. |
|
504 |
aFileName isNil ifFalse:[ |
|
505 |
fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC |
|
506 |
]. |
|
507 |
docInfoStruct := Win32OperatingSystem::DocInfoStructure new. |
|
508 |
docInfoStruct |
|
509 |
cbSize:docInfoStruct sizeInBytes; |
|
510 |
lpszDocName:nameAddress address. |
|
511 |
fileNameAddress isNil ifFalse:[ |
|
512 |
docInfoStruct lpszOutput:fileNameAddress address |
|
513 |
]. |
|
514 |
jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct. |
|
515 |
jobid > 0 ifFalse:[ |
|
516 |
jobid = -1 ifTrue:[ |
|
517 |
abort := true. |
|
518 |
^ nil |
|
519 |
]. |
|
520 |
^ self error |
|
521 |
]. |
|
522 |
self startPage |
|
523 |
||
524 |
"Created: / 27-07-2006 / 18:19:31 / fm" |
|
525 |
"Modified: / 03-08-2006 / 15:11:19 / fm" |
|
526 |
"Modified: / 10-10-2006 / 18:20:01 / cg" |
|
527 |
! ! |
|
528 |
||
529 |
!WinPrinterContext methodsFor:'queries'! |
|
530 |
||
531 |
supportsColor |
|
532 |
||
533 |
"/ | retVal info | |
|
534 |
"/ |
|
535 |
"/ info := (self class getPrinterInformation: self name) asUppercase. |
|
536 |
"/ (info includesSubstring: ',PSCRIPT,') |
|
537 |
"/ ifTrue: [ |
|
538 |
"/ retVal := (DAPASX::DapasSystemInfo getYesNoInfoApp: 'Printer' profile: 'PostScriptBlackWhite') not. |
|
539 |
"/ ] |
|
540 |
"/ ifFalse: [ |
|
541 |
"/ retVal := (info includesSubstring: 'PDF') |
|
542 |
"/ ifTrue: [true] |
|
543 |
"/ ifFalse: [self numberOfColorBitsPerPixel > 1]. |
|
544 |
"/ ]. |
|
545 |
"/ |
|
546 |
"/ ^retVal |
|
547 |
||
548 |
^ false. |
|
549 |
||
550 |
"Created: / 03-08-2006 / 09:55:26 / fm" |
|
551 |
"Modified: / 04-08-2006 / 13:20:40 / fm" |
|
552 |
"Modified: / 10-10-2006 / 18:21:07 / cg" |
|
553 |
! |
|
554 |
||
555 |
supportsGraphics |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
556 |
^(OperatingSystem getDeviceCaps: gcId index: 2 "Technology") ~= 4 |
2299 | 557 |
|
558 |
"Created: / 03-08-2006 / 10:07:43 / fm" |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
559 |
"Modified: / 16-04-2007 / 12:44:03 / cg" |
2299 | 560 |
! ! |
561 |
||
562 |
!WinPrinterContext methodsFor:'text printing'! |
|
563 |
||
564 |
stringWidthOf:aString at:index |
|
565 |
"Return the width of aString up to index |
|
566 |
when written using the current font; expand tabs out |
|
567 |
to 4 spaces for calculations" |
|
568 |
||
569 |
|answer str size spaceWidth| |
|
570 |
||
571 |
index <= 0 ifTrue:[ ^ 0 ]. |
|
572 |
str := index >= aString size ifTrue:[ aString ] ifFalse:[ aString copyFrom:1 to:index ]. |
|
573 |
true "self font isNil" ifTrue:[ |
|
574 |
"if font not set yet, calculate based on default font" |
|
575 |
"/ extString := str asExternalString. |
|
576 |
size := Win32OperatingSystem::WinPointStructure new. |
|
577 |
(OperatingSystem |
|
578 |
getTextExtentPoint:gcId |
|
579 |
string:str |
|
580 |
size:size) ifFalse:[ ^ self error ]. |
|
581 |
answer := size x. |
|
582 |
"/ Transcript showCR: 'FROM PRIM ******* ', str, ' ', answer printString. |
|
583 |
"/ Transcript showCR: 'FROM DEVICE ***** ', str, ' ',(self font widthOf:str on:self device) printString. |
|
584 |
#TODO. |
|
585 |
] ifFalse:[ |
|
586 |
answer := self font widthOf:str on:self device |
|
587 |
]. |
|
588 |
index > aString size ifTrue:[ |
|
589 |
spaceWidth := self font widthOf:Character space on:self device. |
|
590 |
answer := answer + ((index - aString size) * spaceWidth) |
|
591 |
]. |
|
592 |
^ answer. |
|
593 |
||
594 |
"Created: / 03-08-2006 / 10:27:20 / fm" |
|
595 |
"Modified: / 04-08-2006 / 12:27:26 / fm" |
|
596 |
"Modified: / 10-10-2006 / 18:20:43 / cg" |
|
597 |
! ! |
|
598 |
||
599 |
!WinPrinterContext class methodsFor:'documentation'! |
|
600 |
||
601 |
version |
|
2304 | 602 |
^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.3 2007-04-16 11:04:45 cg Exp $' |
2299 | 603 |
! ! |