author | ca |
Fri, 23 Nov 2007 14:06:49 +0100 | |
changeset 2357 | 918859a27b27 |
parent 2356 | a4128a41b721 |
child 2384 | 1c53fc6edb39 |
permissions | -rw-r--r-- |
2299 | 1 |
" |
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
2344 | 3 |
All Rights Reserved |
2299 | 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 |
2344 | 15 |
instanceVariableNames:'deviceFonts hatch supportsColor' |
2348 | 16 |
classVariableNames:'PostScriptBlackWhite' |
2344 | 17 |
poolDictionaries:'' |
18 |
category:'Interface-Printing' |
|
2299 | 19 |
! |
20 |
||
2351 | 21 |
WinPrinterContext subclass:#WinPrinterGraphicContext |
2356 | 22 |
instanceVariableNames:'fontScale printPageNumbers pageNumberFormat pageCounter |
23 |
needsEndOfPage titleFont' |
|
2351 | 24 |
classVariableNames:'' |
25 |
poolDictionaries:'' |
|
26 |
privateIn:WinPrinterContext |
|
27 |
! |
|
28 |
||
2317 | 29 |
!WinPrinterContext primitiveDefinitions! |
30 |
%{ |
|
31 |
#undef INT |
|
32 |
#define INT WIN_INT |
|
33 |
#undef Array |
|
34 |
#define Array WIN_Array |
|
35 |
#undef Number |
|
36 |
#define Number WIN_Number |
|
37 |
#undef Method |
|
38 |
#define Method WIN_Method |
|
39 |
#undef Point |
|
40 |
#define Point WIN_Point |
|
41 |
#undef Rectangle |
|
42 |
/* #define Rectangle WIN_Rectangle */ |
|
43 |
#undef True |
|
44 |
#define True WIN_True |
|
45 |
#undef False |
|
46 |
#define False WIN_False |
|
47 |
#undef Block |
|
48 |
#define Block WIN_Block |
|
49 |
#undef Context |
|
50 |
#define Context WIN_Context |
|
51 |
#undef Date |
|
52 |
#define Date WIN_Date |
|
53 |
#undef Time |
|
54 |
#define Time WIN_Time |
|
55 |
#undef Delay |
|
56 |
#define Delay WIN_Delay |
|
57 |
#undef Signal |
|
58 |
#define Signal WIN_Signal |
|
59 |
#undef Set |
|
60 |
#define Set WIN_Set |
|
61 |
#undef Process |
|
62 |
#define Process WIN_Process |
|
63 |
#undef Processor |
|
64 |
#define Processor WIN_Processor |
|
65 |
#undef Message |
|
66 |
#define Message WIN_Message |
|
67 |
||
68 |
#include <stdio.h> |
|
69 |
#include <errno.h> |
|
70 |
||
71 |
#ifdef __BORLANDC__ |
|
72 |
# define NOATOM |
|
73 |
# define NOGDICAPMASKS |
|
74 |
# define NOMETAFILE |
|
75 |
# define NOMINMAX |
|
76 |
# define NOOPENFILE |
|
77 |
# define NOSOUND |
|
78 |
# define NOWH |
|
79 |
# define NOCOMM |
|
80 |
# define NOKANJI |
|
81 |
# define NOCRYPT |
|
82 |
# define NOMCX |
|
83 |
# define WIN32_LEAN_AND_MEAN |
|
84 |
# include <windows.h> |
|
85 |
# include <shellapi.h> |
|
86 |
# include <sys\timeb.h> |
|
87 |
# include <dir.h> |
|
88 |
#else |
|
89 |
# define _USERENTRY /**/ |
|
90 |
# define NOATOM |
|
91 |
# define NOGDICAPMASKS |
|
92 |
# define NOMETAFILE |
|
93 |
# define NOMINMAX |
|
94 |
# define NOOPENFILE |
|
95 |
# define NOSOUND |
|
96 |
# define NOWH |
|
97 |
# define NOCOMM |
|
98 |
# define NOKANJI |
|
99 |
# define NOCRYPT |
|
100 |
# define NOMCX |
|
101 |
# define WIN32_LEAN_AND_MEAN |
|
102 |
# include <windows.h> |
|
103 |
# include <sys\timeb.h> |
|
104 |
#endif |
|
105 |
||
106 |
#include <process.h> |
|
107 |
||
108 |
#ifdef __DEF_Array |
|
109 |
# undef Array |
|
110 |
# define Array __DEF_Array |
|
111 |
#endif |
|
112 |
#ifdef __DEF_Number |
|
113 |
# undef Number |
|
114 |
# define Number __DEF_Number |
|
115 |
#endif |
|
116 |
#ifdef __DEF_Method |
|
117 |
# undef Method |
|
118 |
# define Method __DEF_Method |
|
119 |
#endif |
|
120 |
#ifdef __DEF_Point |
|
121 |
# undef Point |
|
122 |
# define Point __DEF_Point |
|
123 |
#endif |
|
124 |
#ifdef __DEF_Rectangle |
|
125 |
# undef Rectangle |
|
126 |
# define Rectangle __DEF_Rectangle |
|
127 |
#else |
|
128 |
# undef Rectangle |
|
129 |
#endif |
|
130 |
#ifdef __DEF_Block |
|
131 |
# undef Block |
|
132 |
# define Block __DEF_Block |
|
133 |
#endif |
|
134 |
#ifdef __DEF_Context |
|
135 |
# undef Context |
|
136 |
# define Context __DEF_Context |
|
137 |
#endif |
|
138 |
#ifdef __DEF_Date |
|
139 |
# undef Date |
|
140 |
# define Date __DEF_Date |
|
141 |
#endif |
|
142 |
#ifdef __DEF_Time |
|
143 |
# undef Time |
|
144 |
# define Time __DEF_Time |
|
145 |
#endif |
|
146 |
# ifdef __DEF_Set |
|
147 |
# undef Set |
|
148 |
# define Set __DEF_Set |
|
149 |
# endif |
|
150 |
# ifdef __DEF_Signal |
|
151 |
# undef Signal |
|
152 |
# define Signal __DEF_Signal |
|
153 |
# endif |
|
154 |
# ifdef __DEF_Delay |
|
155 |
# undef Delay |
|
156 |
# define Delay __DEF_Delay |
|
157 |
# endif |
|
158 |
# ifdef __DEF_Process |
|
159 |
# undef Process |
|
160 |
# define Process __DEF_Process |
|
161 |
# endif |
|
162 |
# ifdef __DEF_Processor |
|
163 |
# undef Processor |
|
164 |
# define Processor __DEF_Processor |
|
165 |
# endif |
|
166 |
# ifdef __DEF_Message |
|
167 |
# undef Message |
|
168 |
# define Message __DEF_Message |
|
169 |
# endif |
|
170 |
||
171 |
#undef INT |
|
172 |
#define INT int |
|
173 |
||
174 |
/* |
|
175 |
* some defines - tired of typing ... |
|
176 |
*/ |
|
177 |
#define _HANDLEVal(o) (HANDLE)(__MKCP(o)) |
|
178 |
#define _HBITMAPVAL(o) (HBITMAP)(__MKCP(o)) |
|
179 |
#define _HWNDVal(o) (HWND)(__MKCP(o)) |
|
180 |
#define _HPALETTEVal(o) (HPALETTE)(__MKCP(o)) |
|
181 |
#define _HCURSORVal(o) (HCURSOR)(__MKCP(o)) |
|
182 |
#define _HGDIOBJVal(o) (HGDIOBJ)(__MKCP(o)) |
|
183 |
#define _LOGPALETTEVal(o) (LOGPALETTE *)(__MKCP(o)) |
|
184 |
#define _COLORREFVal(o) (COLORREF)(__MKCP(o)) |
|
185 |
||
186 |
#define WIDECHAR unsigned short |
|
187 |
||
188 |
#define WIN32PADDING 32 |
|
189 |
||
190 |
#ifdef DEBUG |
|
2325 | 191 |
# define DPRINTF(x) /* printf x */ |
192 |
# define DFPRINTF(x) /* fprintf x */ |
|
2317 | 193 |
#else |
194 |
# define DPRINTF(x) /* */ |
|
195 |
# define DFPRINTF(x) /* */ |
|
196 |
#endif |
|
197 |
||
198 |
typedef int (*intf)(int); |
|
199 |
%} |
|
200 |
! ! |
|
201 |
||
2299 | 202 |
!WinPrinterContext class methodsFor:'documentation'! |
203 |
||
204 |
copyright |
|
205 |
" |
|
206 |
COPYRIGHT (c) 2006 by eXept Software AG |
|
2344 | 207 |
All Rights Reserved |
2299 | 208 |
|
209 |
This software is furnished under a license and may be used |
|
210 |
only in accordance with the terms of that license and with the |
|
211 |
inclusion of the above copyright notice. This software may not |
|
212 |
be provided or otherwise made available to, or used by, any |
|
213 |
other person. No title to or ownership of the software is |
|
214 |
hereby transferred. |
|
215 |
" |
|
216 |
! |
|
217 |
||
218 |
documentation |
|
219 |
" |
|
2317 | 220 |
I am the mediator between the smalltalk printing protocol |
2299 | 221 |
(which is the same as the graphics drawing protocol) and the |
222 |
windows printer. |
|
2317 | 223 |
When you open a printer, you will typically talk to me. |
2299 | 224 |
|
225 |
[author:] |
|
2344 | 226 |
Felix Madrid (fm@exept.de) |
2299 | 227 |
" |
228 |
! ! |
|
229 |
||
230 |
!WinPrinterContext class methodsFor:'instance creation'! |
|
231 |
||
232 |
fromPrinterInfo: aPrinterInfo |
|
2317 | 233 |
| printerContext printerDevice hDC| |
2299 | 234 |
|
235 |
hDC := aPrinterInfo createDC. |
|
236 |
hDC = 0 ifTrue: [ ^self error: 'Error while opening printer.' ]. |
|
237 |
||
2316 | 238 |
printerContext := self new. |
2323 | 239 |
|
240 |
printerDevice := printerContext. |
|
241 |
"/ printerDevice := WinPrinter on: aPrinterInfo. |
|
242 |
"/ printerDevice printerDC:hDC. |
|
243 |
||
2316 | 244 |
printerContext printerInfo: aPrinterInfo. |
245 |
printerContext setDevice:printerDevice id:nil gcId:hDC. |
|
246 |
printerContext initExtent. |
|
247 |
^printerContext |
|
2299 | 248 |
|
249 |
"Created: / 03-08-2006 / 12:53:52 / fm" |
|
250 |
"Modified: / 04-08-2006 / 12:55:01 / fm" |
|
251 |
"Modified: / 16-04-2007 / 12:36:26 / cg" |
|
2351 | 252 |
! |
253 |
||
254 |
openGraphicContext |
|
255 |
|printerInfo gc| |
|
256 |
||
257 |
printerInfo := PrintingDialog getPrinterInfo. |
|
258 |
printerInfo isNil ifTrue:[^ nil]. |
|
2352 | 259 |
gc := WinPrinterGraphicContext fromPrinterInfo:printerInfo. |
2351 | 260 |
|
261 |
gc notNil ifTrue:[ |
|
262 |
gc startPrintJob |
|
263 |
]. |
|
264 |
^ gc |
|
2299 | 265 |
! ! |
266 |
||
267 |
!WinPrinterContext class methodsFor:'accessing'! |
|
268 |
||
2317 | 269 |
getPrinterInformation:printerNameString |
2299 | 270 |
" Answer the printer information for the printer named printerNameString. If no name is specified, |
271 |
answer the information for the default printer." |
|
2317 | 272 |
|
2299 | 273 |
|h| |
274 |
||
275 |
h := OperatingSystem openPrinter:printerNameString. |
|
2317 | 276 |
^ OperatingSystem |
2344 | 277 |
getDocumentProperties:nil |
278 |
hPrinter:h |
|
279 |
pDeviceName:printerNameString. |
|
2299 | 280 |
|
281 |
"Created: / 27-07-2006 / 10:22:32 / fm" |
|
282 |
"Modified: / 01-08-2006 / 16:01:44 / fm" |
|
283 |
"Modified: / 10-10-2006 / 18:57:45 / cg" |
|
284 |
! |
|
285 |
||
2330 | 286 |
getPrinterInformationString: printerNameString |
287 |
" Answer the printer information string from the WIN.INI file |
|
288 |
for the printer named printerNameString. If no name is specified, |
|
289 |
answer the information for the default printer. " |
|
290 |
| printerInfo result | |
|
291 |
printerInfo := ( String new: 80 ). |
|
292 |
result := OperatingSystem primGetProfileString: 'windows' |
|
293 |
keyName: 'device' |
|
294 |
default: ( printerNameString isNil ifTrue: [ '' ] ifFalse: [ printerNameString ] ) |
|
295 |
returnedString: printerInfo |
|
296 |
size: printerInfo size. |
|
297 |
^result > 0 |
|
298 |
ifTrue: [printerInfo copyFrom: 1 to: result] |
|
299 |
ifFalse: [''] |
|
300 |
! |
|
301 |
||
2299 | 302 |
named: aName |
303 |
"Answer a new instance of Printer which represents |
|
304 |
the printer named aName as specified in the host |
|
305 |
Control Panel." |
|
306 |
||
307 |
aName isNil ifTrue: [ ^self default ]. |
|
308 |
^self new printerInfoWithName: aName |
|
309 |
||
310 |
"Created: / 27-07-2006 / 17:51:27 / fm" |
|
311 |
"Modified: / 02-08-2006 / 17:26:29 / fm" |
|
312 |
"Modified: / 10-10-2006 / 17:33:29 / cg" |
|
2348 | 313 |
! |
314 |
||
315 |
postScriptBlackWhite |
|
316 |
"Returns true if the postscript is b&w or returns false if the postscript is color" |
|
317 |
||
318 |
^ PostScriptBlackWhite ? false |
|
319 |
! |
|
320 |
||
321 |
postScriptBlackWhite: aBoolean |
|
322 |
||
323 |
PostScriptBlackWhite := aBoolean |
|
2299 | 324 |
! ! |
325 |
||
2323 | 326 |
!WinPrinterContext class methodsFor:'not supported yet'! |
327 |
||
328 |
printAdvancedLines: pairOfPointsArray |
|
329 |
"Opens a print dialog and prints the given lines" |
|
330 |
||
331 |
| printerInfo printer | |
|
332 |
||
333 |
printerInfo := PrintingDialog getPrinterInfo. |
|
334 |
printerInfo isNil ifTrue:[^self]. |
|
335 |
||
336 |
printer := self fromPrinterInfo: printerInfo. |
|
337 |
[ |
|
2344 | 338 |
printer startPrintJob: 'Advanced Lines'. |
339 |
printer foreground:Color red background:Color white. |
|
340 |
pairOfPointsArray |
|
341 |
do:[:pairOfPointsAndContext | |
|
342 |
|pairOfPoints| |
|
343 |
pairOfPoints := pairOfPointsAndContext at:1. |
|
344 |
printer |
|
345 |
lineWidth: (pairOfPointsAndContext at:2); |
|
346 |
lineStyle: (pairOfPointsAndContext at:3); |
|
347 |
capStyle: (pairOfPointsAndContext at:4); |
|
348 |
joinStyle: (pairOfPointsAndContext at:5); |
|
349 |
foreground: (pairOfPointsAndContext at:6); |
|
350 |
||
351 |
displayAdvanceLineFrom: (pairOfPoints at:1) to: (pairOfPoints at:2). |
|
352 |
]. |
|
353 |
printer endPrintJob. |
|
2323 | 354 |
] forkAt: 3 |
355 |
||
356 |
" |
|
357 |
WinPrinterContext printAdvancedLines: |
|
2344 | 358 |
(Array with: (Array with: (Array with:10@10 with:1000@5000) with: 3 with:#dashed with: #butt with: #miter with: Color green) |
359 |
with: (Array with: (Array with:10@10 with:3500@2000) with: 2 with:#solid with: #butt with: #miter with: Color yellow) |
|
360 |
with: (Array with: (Array with:1000@800 with:6000@5000) with: 8 with:#dashed with: #butt with: #miter with: Color black) |
|
361 |
with: (Array with: (Array with:2000@2800 with:2000@5000) with: 1 with:#dashed with: #butt with: #miter with: Color red) |
|
362 |
) |
|
2323 | 363 |
" |
364 |
||
365 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
366 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
367 |
"Modified: / 16-04-2007 / 15:37:41 / cg" |
|
368 |
! ! |
|
369 |
||
2343 | 370 |
!WinPrinterContext class methodsFor:'testing'! |
371 |
||
372 |
computeScaleForPrinter:aPrinter |
|
373 |
^ Point x:(aPrinter pixelsPerInchOfScreenWidth / Screen current horizontalPixelPerInch) |
|
374 |
y:(aPrinter pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch) |
|
375 |
! |
|
376 |
||
377 |
testPrintingDo:anOneArgBlock |
|
378 |
||
379 |
"Opens a print dialog and invokes the action with the printer" |
|
380 |
||
381 |
| printerInfo printer | |
|
382 |
||
383 |
printerInfo := PrintingDialog getPrinterInfo. |
|
384 |
printerInfo isNil ifTrue:[^self]. |
|
385 |
||
386 |
printer := self fromPrinterInfo: printerInfo. |
|
387 |
||
388 |
printer startPrintJob: 'Testing'. |
|
389 |
anOneArgBlock value:printer. |
|
390 |
printer endPrintJob. |
|
391 |
||
392 |
||
393 |
" |
|
394 |
self testPrintingDo:[:aPrinter| |icon| |
|
395 |
aPrinter scale:(self computeScaleForPrinter:aPrinter). |
|
396 |
||
397 |
aPrinter displayLineFrom:10@10 to:100@10. |
|
398 |
aPrinter displayLineFrom:100@10 to:100@100. |
|
399 |
aPrinter displayLineFrom:100@100 to:10@100. |
|
400 |
aPrinter displayLineFrom:10@100 to:10@10. |
|
401 |
||
402 |
icon := XPToolbarIconLibrary eraseXP28x28Icon. |
|
403 |
icon displayOn:aPrinter x:10 y:10. |
|
404 |
||
405 |
]. |
|
406 |
||
407 |
self testPrintingDo:[:aPrinter| |scale| |
|
408 |
scale := self computeScaleForPrinter:aPrinter. |
|
409 |
aPrinter scale:(1 * scale). |
|
410 |
||
411 |
aPrinter font:(Font family:'Arial' face:'medium' size:8). |
|
412 |
aPrinter displayLineFrom:8@16 to:100@16. |
|
413 |
aPrinter displayLineFrom:8@16 to:8@128. |
|
414 |
||
415 |
'hallo' displayOn:aPrinter x:8 y:16. |
|
416 |
aPrinter scale:(2 * scale). |
|
417 |
'hallo' displayOn:aPrinter x:4 y:32. |
|
418 |
||
419 |
aPrinter scale:(4 * scale). |
|
420 |
'hallo' displayOn:aPrinter x:2 y:32. |
|
421 |
]. |
|
422 |
" |
|
423 |
! ! |
|
424 |
||
2299 | 425 |
!WinPrinterContext class methodsFor:'testing & examples'! |
426 |
||
2323 | 427 |
fillCircles: arrayOfPointsAndRadiusWithContextArray |
428 |
"Opens a print dialog and prints the given circles" |
|
429 |
||
430 |
| printerInfo printer | |
|
431 |
||
432 |
printerInfo := PrintingDialog getPrinterInfo. |
|
433 |
printerInfo isNil ifTrue:[^self]. |
|
434 |
||
435 |
printer := self fromPrinterInfo: printerInfo. |
|
436 |
[ |
|
2344 | 437 |
printer startPrintJob: 'Fill Circles'. |
438 |
arrayOfPointsAndRadiusWithContextArray |
|
439 |
do:[:pointsAndRadiusWithContextArray | |
|
440 |
printer foreground:(pointsAndRadiusWithContextArray at:3). |
|
441 |
printer fillCircle:(pointsAndRadiusWithContextArray at:1) |
|
442 |
radius:(pointsAndRadiusWithContextArray at:2). |
|
443 |
]. |
|
444 |
printer endPrintJob. |
|
2323 | 445 |
] forkAt: 3 |
446 |
||
447 |
" |
|
448 |
WinPrinterContext fillCircles: |
|
2344 | 449 |
(Array with: (Array with: 800@800 with: 600 with:Color red) |
450 |
with: (Array with: 1500@1500 with: 1000 with:Color blue) |
|
451 |
with: (Array with: 4000@2500 with: 2000 with:Color gray)) |
|
2323 | 452 |
" |
453 |
||
454 |
"Created: / 07-08-2006 / 11:46:52 / fm" |
|
455 |
"Modified: / 16-04-2007 / 15:37:34 / cg" |
|
456 |
! |
|
457 |
||
2330 | 458 |
fillHatchCircles: arrayOfPointsAndRadiusWithContextArray |
459 |
"Opens a print dialog and prints the given circles" |
|
460 |
||
461 |
| printerInfo printer | |
|
462 |
||
463 |
printerInfo := PrintingDialog getPrinterInfo. |
|
464 |
printerInfo isNil ifTrue:[^self]. |
|
465 |
||
466 |
printer := self fromPrinterInfo: printerInfo. |
|
467 |
[ |
|
468 |
printer startPrintJob: 'Fill Hatch Circles'. |
|
469 |
arrayOfPointsAndRadiusWithContextArray |
|
470 |
do:[:pointsAndRadiusWithContextArray | |
|
471 |
| point radius color hatch| |
|
472 |
point := (pointsAndRadiusWithContextArray at:1). |
|
473 |
radius := (pointsAndRadiusWithContextArray at:2). |
|
474 |
color := (pointsAndRadiusWithContextArray at:3). |
|
475 |
hatch := (pointsAndRadiusWithContextArray at:4). |
|
476 |
printer foreground: color; |
|
477 |
hatch: hatch. |
|
478 |
printer fillCircle:point |
|
479 |
radius:radius. |
|
480 |
]. |
|
481 |
printer endPrintJob. |
|
482 |
] forkAt: 3 |
|
483 |
||
484 |
" |
|
485 |
WinPrinterContext fillHatchCircles: |
|
486 |
(Array with: (Array with: 800@800 with: 600 with:Color red with: #diagonalCross) |
|
487 |
with: (Array with: 1500@1500 with: 1000 with:Color blue with: #vertical) |
|
488 |
with: (Array with: 4000@2500 with: 2000 with:Color gray with: #bDiagonal)) |
|
489 |
" |
|
490 |
||
491 |
"Created: / 07-08-2006 / 11:46:52 / fm" |
|
492 |
"Modified: / 16-04-2007 / 15:37:34 / cg" |
|
493 |
! |
|
494 |
||
495 |
fillHatchPolygons: polygonsWithContextArray |
|
496 |
"Opens a print dialog and prints the given polygons" |
|
497 |
||
498 |
| printerInfo printer | |
|
499 |
||
500 |
printerInfo := PrintingDialog getPrinterInfo. |
|
501 |
printerInfo isNil ifTrue:[^self]. |
|
502 |
||
503 |
printer := self fromPrinterInfo: printerInfo. |
|
504 |
[ |
|
505 |
printer startPrintJob: 'Fill Hatch Polygons'. |
|
506 |
polygonsWithContextArray |
|
507 |
do:[:polygonWithContextArray | |
|
508 |
|aPolygon color hatch| |
|
509 |
aPolygon := polygonWithContextArray at: 1. |
|
510 |
color := (polygonWithContextArray at: 2). |
|
511 |
hatch := (polygonWithContextArray at: 3). |
|
512 |
printer foreground: color; |
|
513 |
hatch: hatch. |
|
514 |
aPolygon displayFilledOn: printer. |
|
515 |
]. |
|
516 |
printer endPrintJob. |
|
517 |
] forkAt: 3 |
|
518 |
||
519 |
" |
|
520 |
WinPrinterContext fillHatchPolygons: |
|
521 |
(Array with: (Array with: (Polygon vertices:( |
|
522 |
Array |
|
523 |
with:100@100 |
|
524 |
with:600@1000 |
|
525 |
with:3500@4000 |
|
526 |
with:100@4000 |
|
527 |
with:100@100)) |
|
528 |
with: Color red |
|
529 |
with: #cross) |
|
530 |
with: (Array with: (Polygon vertices:( |
|
531 |
Array |
|
532 |
with:1000@1000 |
|
533 |
with:1000@2000 |
|
534 |
with:2000@1000)) |
|
535 |
with: Color blue |
|
536 |
with: #none) |
|
537 |
) |
|
538 |
" |
|
539 |
||
540 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
541 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
542 |
"Modified: / 16-04-2007 / 15:37:43 / cg" |
|
543 |
! |
|
544 |
||
545 |
fillHatchRectangles: rectanglesWithHatch |
|
546 |
"Opens a print dialog and prints the given rectangles" |
|
547 |
||
548 |
| printerInfo printer | |
|
549 |
||
550 |
printerInfo := PrintingDialog getPrinterInfo. |
|
551 |
printerInfo isNil ifTrue:[^self]. |
|
552 |
||
553 |
printer := self fromPrinterInfo: printerInfo. |
|
554 |
[ |
|
555 |
printer startPrintJob: 'Fill Hatch Rectangles'. |
|
556 |
printer foreground:Color blue background:Color white. |
|
557 |
rectanglesWithHatch |
|
558 |
do:[:rectangleWithHatch | |
|
559 |
|rectangle hatch| |
|
560 |
rectangle := rectangleWithHatch at: 1. |
|
561 |
hatch := rectangleWithHatch at: 2. |
|
562 |
printer hatch: hatch. |
|
563 |
printer fillRectangleX: rectangle origin x |
|
564 |
y: rectangle origin y |
|
565 |
width: rectangle width |
|
566 |
height: rectangle height. |
|
567 |
]. |
|
568 |
printer endPrintJob. |
|
569 |
] forkAt: 3 |
|
570 |
||
571 |
" |
|
572 |
WinPrinterContext fillHatchRectangles: |
|
573 |
(Array with: (Array with: (Rectangle left:20 top:20 width:400 height:600) with: #horizontal) |
|
574 |
with: (Array with: (Rectangle left:500 top:700 width:600 height:400) with: #vertical) |
|
575 |
with: (Array with: (Rectangle left:800 top:1000 width:1600 height:2000) with: #cross) |
|
576 |
with: (Array with: (Rectangle left:1040 top:1240 width:3000 height:3000) with: #bDiagonal) |
|
577 |
) |
|
578 |
" |
|
579 |
||
580 |
"Created: / 07-08-2006 / 11:40:48 / fm" |
|
581 |
"Modified: / 16-04-2007 / 15:37:46 / cg" |
|
582 |
! |
|
583 |
||
2323 | 584 |
fillPolygons: polygonsWithContextArray |
585 |
"Opens a print dialog and prints the given polygons" |
|
586 |
||
587 |
| printerInfo printer | |
|
588 |
||
589 |
printerInfo := PrintingDialog getPrinterInfo. |
|
590 |
printerInfo isNil ifTrue:[^self]. |
|
591 |
||
592 |
printer := self fromPrinterInfo: printerInfo. |
|
593 |
[ |
|
2344 | 594 |
printer startPrintJob: 'Fill Polygons'. |
595 |
polygonsWithContextArray |
|
596 |
do:[:polygonWithContextArray | |
|
597 |
|aPolygon| |
|
598 |
aPolygon := polygonWithContextArray at: 1. |
|
599 |
printer foreground:(polygonWithContextArray at: 2). |
|
600 |
aPolygon displayFilledOn: printer. |
|
601 |
]. |
|
602 |
printer endPrintJob. |
|
2323 | 603 |
] forkAt: 3 |
604 |
||
605 |
" |
|
606 |
WinPrinterContext fillPolygons: |
|
2344 | 607 |
(Array with: (Array with: (Polygon vertices:( |
608 |
Array |
|
609 |
with:100@100 |
|
610 |
with:600@1000 |
|
611 |
with:3500@4000 |
|
612 |
with:100@4000 |
|
613 |
with:100@100)) |
|
614 |
with: Color red) |
|
615 |
with: (Array with: (Polygon vertices:( |
|
616 |
Array |
|
617 |
with:1000@1000 |
|
618 |
with:1000@2000 |
|
619 |
with:2000@1000)) |
|
620 |
with: Color blue) |
|
2323 | 621 |
) |
622 |
" |
|
623 |
||
624 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
625 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
626 |
"Modified: / 16-04-2007 / 15:37:43 / cg" |
|
627 |
! |
|
628 |
||
2316 | 629 |
fillRectangles: rectangles |
630 |
"Opens a print dialog and prints the given rectangles" |
|
631 |
||
632 |
| printerInfo printer | |
|
633 |
||
634 |
printerInfo := PrintingDialog getPrinterInfo. |
|
635 |
printerInfo isNil ifTrue:[^self]. |
|
636 |
||
637 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 638 |
[ |
2344 | 639 |
printer startPrintJob: 'Fill Rectangles'. |
640 |
printer foreground:Color blue background:Color white. |
|
641 |
rectangles |
|
642 |
do:[:rectangle | |
|
643 |
printer fillRectangleX: rectangle origin x |
|
644 |
y: rectangle origin y |
|
645 |
width: rectangle width |
|
646 |
height: rectangle height. |
|
647 |
]. |
|
648 |
printer endPrintJob. |
|
2316 | 649 |
] forkAt: 3 |
650 |
||
651 |
" |
|
2317 | 652 |
WinPrinterContext fillRectangles: |
2344 | 653 |
(Array with: (Rectangle left:20 top:20 width:400 height:600) |
654 |
with: (Rectangle left:500 top:700 width:600 height:400) |
|
655 |
with: (Rectangle left:800 top:1000 width:1600 height:2000) |
|
656 |
with: (Rectangle left:1040 top:1240 width:3000 height:3000) |
|
657 |
) |
|
2316 | 658 |
" |
659 |
||
660 |
"Created: / 07-08-2006 / 11:40:48 / fm" |
|
661 |
"Modified: / 16-04-2007 / 15:37:46 / cg" |
|
662 |
! |
|
663 |
||
2299 | 664 |
print: aString font: aFont title: aTitle |
665 |
"Open a print dialog to allow printing of the given string |
|
666 |
using the given title & font." |
|
667 |
||
2317 | 668 |
self print: aString font: aFont title: aTitle wordWrap: false |
2299 | 669 |
|
670 |
" |
|
2313 | 671 |
WinPrinterContext print: 'Holaaaa!! (from: WinPrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test' |
2315 | 672 |
WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: nil title: 'Printing Test String' |
673 |
WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String' |
|
2299 | 674 |
" |
675 |
||
676 |
"Created: / 27-07-2006 / 17:52:33 / fm" |
|
677 |
"Modified: / 03-08-2006 / 18:52:31 / fm" |
|
2313 | 678 |
"Modified: / 16-04-2007 / 13:54:40 / cg" |
2299 | 679 |
! |
680 |
||
681 |
print: aString font: aFont title: aTitle wordWrap: wordWrap |
|
682 |
"Open a print dialog to allow printing of the given string |
|
683 |
using the given title & font." |
|
684 |
||
685 |
| printerInfo printer | |
|
686 |
||
687 |
printerInfo := PrintingDialog getPrinterInfo. |
|
688 |
printerInfo isNil ifTrue:[^self]. |
|
689 |
||
690 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 691 |
[ |
2338 | 692 |
printer |
693 |
print: aString |
|
694 |
font: aFont |
|
695 |
title: aTitle |
|
696 |
wordWrap: wordWrap |
|
697 |
marginsRect: nil |
|
2299 | 698 |
] forkAt: 3 |
699 |
||
700 |
" |
|
2313 | 701 |
WinPrinterContext print: 'Holaaaa!! (from: PrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test' wordWrap: true |
2315 | 702 |
WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font:nil title:'Printing Test String' wordWrap:true |
703 |
WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String' wordWrap: true |
|
2299 | 704 |
" |
705 |
||
706 |
"Created: / 03-08-2006 / 18:51:53 / fm" |
|
2313 | 707 |
"Modified: / 16-04-2007 / 15:37:31 / cg" |
2299 | 708 |
! |
709 |
||
710 |
printCircles: arrayOfPointsAndRadius |
|
711 |
"Opens a print dialog and prints the given circles" |
|
712 |
||
713 |
| printerInfo printer | |
|
714 |
||
715 |
printerInfo := PrintingDialog getPrinterInfo. |
|
716 |
printerInfo isNil ifTrue:[^self]. |
|
717 |
||
718 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 719 |
[ |
2344 | 720 |
printer startPrintJob: 'Circles'. |
721 |
printer foreground:Color green background:Color white. |
|
722 |
arrayOfPointsAndRadius |
|
723 |
do:[:pointAndRadius | |
|
724 |
printer displayCircle:(pointAndRadius at:1) |
|
725 |
radius:(pointAndRadius at:2). |
|
726 |
]. |
|
727 |
printer endPrintJob. |
|
2299 | 728 |
] forkAt: 3 |
729 |
||
730 |
" |
|
2317 | 731 |
WinPrinterContext printCircles: |
2344 | 732 |
(Array with: (Array with: 800@800 with: 600) |
733 |
with: (Array with: 1500@1500 with: 1000) |
|
734 |
with: (Array with: 4000@2500 with: 2000)) |
|
2299 | 735 |
" |
736 |
||
737 |
"Created: / 07-08-2006 / 11:46:52 / fm" |
|
2313 | 738 |
"Modified: / 16-04-2007 / 15:37:34 / cg" |
2299 | 739 |
! |
740 |
||
741 |
printCirclesIn: rectangles |
|
742 |
"Opens a print dialog and prints the given circles" |
|
743 |
||
744 |
| printerInfo printer | |
|
745 |
||
746 |
printerInfo := PrintingDialog getPrinterInfo. |
|
747 |
printerInfo isNil ifTrue:[^self]. |
|
748 |
||
749 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 750 |
[ |
2344 | 751 |
printer startPrintJob: 'Circles In Rectangles'. |
752 |
rectangles |
|
753 |
do:[:rectangle | |
|
754 |
printer displayCircleIn: rectangle. |
|
755 |
]. |
|
2299 | 756 |
printer endPrintJob. |
757 |
] forkAt: 3 |
|
758 |
||
759 |
" |
|
2317 | 760 |
WinPrinterContext printCirclesIn: |
2344 | 761 |
(Array with: (Rectangle left:20 top:20 width:400 height:600) |
762 |
with: (Rectangle left:40 top:40 width:600 height:400) |
|
763 |
) |
|
2299 | 764 |
" |
765 |
||
766 |
"Created: / 07-08-2006 / 11:48:46 / fm" |
|
2313 | 767 |
"Modified: / 16-04-2007 / 15:37:38 / cg" |
2299 | 768 |
! |
769 |
||
2338 | 770 |
printImage: anImage |
771 |
"Opens a print dialog and prints the given image" |
|
772 |
||
773 |
| printerInfo printer | |
|
774 |
||
775 |
printerInfo := PrintingDialog getPrinterInfo. |
|
776 |
printerInfo isNil ifTrue:[^self]. |
|
777 |
||
778 |
printer := self fromPrinterInfo: printerInfo. |
|
779 |
[ |
|
780 |
printer startPrintJob: 'Image'. |
|
781 |
printer background:Color white. |
|
782 |
anImage displayOn:printer x:1000 y:1000. |
|
783 |
printer endPrintJob. |
|
784 |
] forkAt: 3 |
|
785 |
||
786 |
" |
|
787 |
WinPrinterContext printImage: (Image fromFile:'C:\vsw311\pavheadr.gif'). |
|
788 |
WinPrinterContext printImage: XPToolbarIconLibrary help32x32Icon. |
|
789 |
WinPrinterContext printImage: XPToolbarIconLibrary eraseXP28x28Icon. |
|
790 |
WinPrinterContext printImage: XPToolbarIconLibrary saveImageBlack22x22Icon. |
|
791 |
WinPrinterContext printImage: XPToolbarIconLibrary changesBrowser18x22Icon. |
|
792 |
" |
|
793 |
||
794 |
"Created: / 07-08-2006 / 11:46:52 / fm" |
|
795 |
"Modified: / 16-04-2007 / 15:37:34 / cg" |
|
796 |
! |
|
797 |
||
2323 | 798 |
printLines: pairOfPointsWithContextArray |
2299 | 799 |
"Opens a print dialog and prints the given lines" |
800 |
||
801 |
| printerInfo printer | |
|
802 |
||
803 |
printerInfo := PrintingDialog getPrinterInfo. |
|
804 |
printerInfo isNil ifTrue:[^self]. |
|
805 |
||
806 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 807 |
[ |
2344 | 808 |
printer startPrintJob: 'Lines'. |
809 |
pairOfPointsWithContextArray |
|
810 |
do:[:pairOfPointsAndContext | |
|
811 |
|pairOfPoints| |
|
812 |
pairOfPoints := pairOfPointsAndContext at: 1. |
|
813 |
printer |
|
814 |
foreground:(pairOfPointsAndContext at:2); |
|
815 |
lineWidth: (pairOfPointsAndContext at:3); |
|
816 |
lineStyle: (pairOfPointsAndContext at:4); |
|
817 |
displayLineFrom: (pairOfPoints at:1) to: (pairOfPoints at:2). |
|
818 |
]. |
|
819 |
printer endPrintJob. |
|
2299 | 820 |
] forkAt: 3 |
821 |
||
822 |
" |
|
2317 | 823 |
WinPrinterContext printLines: |
2344 | 824 |
(Array with: (Array with:(Array with:10@10 with:1000@5000) with: Color red with:4 with: #solid) |
825 |
with: (Array with:(Array with:10@10 with:3500@2000) with: Color blue with:1 with: #dashed) |
|
826 |
with: (Array with:(Array with:1000@800 with:6000@5000) with: Color black with: 1 with:#dotted) |
|
827 |
with: (Array with: (Array with:2000@2800 with:2000@5000) with: Color green with:8 with: nil)) |
|
2299 | 828 |
" |
829 |
||
830 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
831 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
2313 | 832 |
"Modified: / 16-04-2007 / 15:37:41 / cg" |
2299 | 833 |
! |
834 |
||
2316 | 835 |
printPoints: aCollectionOfPoints |
836 |
"Opens a print dialog and prints the given points" |
|
837 |
||
838 |
| printerInfo printer | |
|
839 |
||
840 |
printerInfo := PrintingDialog getPrinterInfo. |
|
841 |
printerInfo isNil ifTrue:[^self]. |
|
842 |
||
843 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 844 |
[ |
2344 | 845 |
printer startPrintJob: 'Points'. |
846 |
aCollectionOfPoints do:[:each | |
|
847 |
printer displayPointX: each x y: each y. |
|
848 |
]. |
|
849 |
printer endPrintJob. |
|
2316 | 850 |
] forkAt: 3 |
851 |
||
852 |
" |
|
2317 | 853 |
WinPrinterContext printPoints: |
2344 | 854 |
(Array with: (10 @ 10) |
855 |
with: (500 @ 700) |
|
856 |
with: (900 @ 1000) |
|
857 |
with: (1500 @ 1700) |
|
858 |
with: (2100 @ 2000) |
|
859 |
with: (2500 @ 2700) |
|
860 |
) |
|
2316 | 861 |
" |
862 |
! |
|
863 |
||
2299 | 864 |
printPolygons: polygons |
865 |
"Opens a print dialog and prints the given polygons" |
|
866 |
||
867 |
| printerInfo printer | |
|
868 |
||
869 |
printerInfo := PrintingDialog getPrinterInfo. |
|
870 |
printerInfo isNil ifTrue:[^self]. |
|
871 |
||
872 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 873 |
[ |
2344 | 874 |
printer startPrintJob: 'Polygons'. |
875 |
printer foreground:Color black background:Color white. |
|
876 |
polygons |
|
877 |
do:[:aPolygon | |
|
878 |
aPolygon displayStrokedOn: printer. |
|
879 |
]. |
|
880 |
printer endPrintJob. |
|
2299 | 881 |
] forkAt: 3 |
882 |
||
883 |
" |
|
2317 | 884 |
WinPrinterContext printPolygons: |
2344 | 885 |
(Array with: (Polygon vertices:( |
886 |
Array |
|
887 |
with:100@100 |
|
888 |
with:600@1000 |
|
889 |
with:3500@4000 |
|
890 |
with:100@4000 |
|
891 |
with:100@100)) |
|
892 |
with: (Polygon vertices:( |
|
893 |
Array |
|
894 |
with:1000@1000 |
|
895 |
with:1000@2000 |
|
896 |
with:2000@1000))) |
|
2299 | 897 |
" |
898 |
||
899 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
900 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
2313 | 901 |
"Modified: / 16-04-2007 / 15:37:43 / cg" |
2299 | 902 |
! |
903 |
||
2316 | 904 |
printPolylines: evenCollectionOfPoints |
905 |
"Opens a print dialog and prints the given rectangles" |
|
906 |
||
907 |
| printerInfo printer | |
|
908 |
||
909 |
printerInfo := PrintingDialog getPrinterInfo. |
|
910 |
printerInfo isNil ifTrue:[^self]. |
|
911 |
||
912 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 913 |
[ |
2344 | 914 |
printer startPrintJob: 'Polylines'. |
915 |
printer displayPolylines:evenCollectionOfPoints. |
|
916 |
printer endPrintJob. |
|
2316 | 917 |
] forkAt: 3 |
918 |
||
919 |
" |
|
2317 | 920 |
WinPrinterContext printPolylines: |
2344 | 921 |
(Array with: (10 @ 10) |
922 |
with: (500 @ 700) |
|
923 |
with: (900 @ 1000) |
|
924 |
with: (1500 @ 1700) |
|
925 |
with: (2100 @ 2000) |
|
926 |
with: (2500 @ 2700) |
|
927 |
) |
|
2316 | 928 |
" |
929 |
||
930 |
"Created: / 07-08-2006 / 11:40:48 / fm" |
|
931 |
"Modified: / 16-04-2007 / 15:37:46 / cg" |
|
932 |
! |
|
933 |
||
2323 | 934 |
printRectangles: rectanglesWithContextArray |
2299 | 935 |
"Opens a print dialog and prints the given rectangles" |
936 |
||
937 |
| printerInfo printer | |
|
938 |
||
939 |
printerInfo := PrintingDialog getPrinterInfo. |
|
940 |
printerInfo isNil ifTrue:[^self]. |
|
941 |
||
942 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 943 |
[ |
2344 | 944 |
printer startPrintJob: 'Rectangles'. |
945 |
printer foreground:Color red background:Color white. |
|
946 |
rectanglesWithContextArray do:[:rectangleWithContextArray | |
|
947 |
|rectangle| |
|
948 |
rectangle := rectangleWithContextArray at: 1. |
|
949 |
printer |
|
950 |
foreground:(rectangleWithContextArray at:2); |
|
951 |
lineWidth: (rectangleWithContextArray at:3); |
|
952 |
lineStyle: (rectangleWithContextArray at:4); |
|
953 |
displayRectangleX: rectangle origin x |
|
954 |
y: rectangle origin y |
|
955 |
width: rectangle width |
|
956 |
height: rectangle height. |
|
957 |
]. |
|
958 |
printer endPrintJob. |
|
2299 | 959 |
] forkAt: 3 |
960 |
||
961 |
" |
|
2317 | 962 |
WinPrinterContext printRectangles: |
2344 | 963 |
(Array with: (Array with: (Rectangle left:30 top:10 width:400 height:600) with: Color red with:4 with: #solid) |
964 |
with: (Array with: (Rectangle left:100 top:140 width:700 height:800) with: Color blue with:1 with: #dashed) |
|
965 |
with: (Array with: (Rectangle left:800 top:1500 width:2600 height:3400) with: Color green with:1 with: #dotted) |
|
966 |
with: (Array with: (Rectangle left:1000 top:1200 width:1400 height:1600) with: Color gray with:8 with: #dashed) |
|
967 |
with: (Array with: (Rectangle left:2600 top:1200 width:1400 height:1600) with: Color darkGray with:1 with: #dashDotDot) |
|
968 |
) |
|
2299 | 969 |
" |
970 |
||
971 |
"Created: / 07-08-2006 / 11:40:48 / fm" |
|
2313 | 972 |
"Modified: / 16-04-2007 / 15:37:46 / cg" |
2299 | 973 |
! |
974 |
||
975 |
printStrings: stringAndPositionsArray |
|
976 |
"Opens a print dialog and prints the given strings" |
|
977 |
||
978 |
| printerInfo printer | |
|
979 |
||
980 |
printerInfo := PrintingDialog getPrinterInfo. |
|
981 |
printerInfo isNil ifTrue:[^self]. |
|
982 |
||
983 |
printer := self fromPrinterInfo: printerInfo. |
|
2317 | 984 |
[ |
2344 | 985 |
printer startPrintJob: 'Strings with Position'. |
986 |
printer foreground:Color black background:Color white. |
|
987 |
stringAndPositionsArray |
|
988 |
do:[:pairOfPointsAndPosition | |
|
989 |
printer displayString:(pairOfPointsAndPosition at: 1) |
|
990 |
x:(pairOfPointsAndPosition at: 2) x |
|
991 |
y:(pairOfPointsAndPosition at: 2) y |
|
992 |
]. |
|
993 |
printer endPrintJob. |
|
2299 | 994 |
] forkAt: 3 |
995 |
||
996 |
" |
|
2317 | 997 |
WinPrinterContext printStrings: |
2344 | 998 |
(Array with: (Array with:'Testing printing with standart method' with:10@10) |
999 |
with: (Array with:'Another test string to print' with:80@200)) |
|
2299 | 1000 |
" |
1001 |
||
1002 |
"Created: / 07-08-2006 / 12:09:48 / fm" |
|
1003 |
"Modified: / 07-08-2006 / 14:11:17 / fm" |
|
2313 | 1004 |
"Modified: / 16-04-2007 / 15:37:49 / cg" |
2299 | 1005 |
! ! |
1006 |
||
1007 |
!WinPrinterContext methodsFor:'accessing'! |
|
1008 |
||
2323 | 1009 |
depth |
1010 |
^ 24 |
|
1011 |
! |
|
1012 |
||
1013 |
deviceColors |
|
1014 |
||
1015 |
^#() |
|
1016 |
! |
|
1017 |
||
1018 |
deviceFonts |
|
1019 |
||
1020 |
deviceFonts isNil ifTrue:[deviceFonts := CachingRegistry new cacheSize:10.]. |
|
1021 |
^deviceFonts |
|
1022 |
! |
|
1023 |
||
2299 | 1024 |
getCharHeight |
1025 |
"Private - answer the height of the font selected in the receiver's |
|
1026 |
device context." |
|
2317 | 1027 |
|
2299 | 1028 |
|textMetrics answer| |
1029 |
||
2317 | 1030 |
|
2299 | 1031 |
textMetrics := Win32OperatingSystem::TextMetricsStructure new. |
1032 |
"/ (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ]. |
|
1033 |
"/ Transcript showCR: 'CHAR HEIGHT PRIM ******* ', ' ', (textMetrics tmHeight + textMetrics tmExternalLeading) printString. |
|
1034 |
"/ Transcript showCR: 'CHAR HEIGHT DEVICE ***** ', ' ', (self font heightOf:'PQWEXCZ' on:self device) printString. |
|
1035 |
answer := (self font heightOf:'PQWEXCZ' on:self device). |
|
1036 |
"/ answer := textMetrics tmHeight + textMetrics tmExternalLeading. |
|
2317 | 1037 |
^answer |
2299 | 1038 |
|
1039 |
"Created: / 02-08-2006 / 17:47:20 / fm" |
|
1040 |
"Modified: / 03-08-2006 / 10:09:01 / fm" |
|
1041 |
"Modified: / 10-10-2006 / 18:15:17 / cg" |
|
1042 |
! |
|
1043 |
||
2323 | 1044 |
getLogicalPixelSizeX |
1045 |
^ printerInfo printQuality ? 600 |
|
1046 |
! |
|
1047 |
||
1048 |
getLogicalPixelSizeY |
|
1049 |
^ printerInfo printQuality ? 600 |
|
1050 |
! |
|
1051 |
||
2299 | 1052 |
numberOfColorBitsPerPixel |
1053 |
^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel" |
|
1054 |
||
1055 |
"Created: / 03-08-2006 / 09:58:18 / fm" |
|
1056 |
"Modified: / 10-10-2006 / 18:15:40 / cg" |
|
1057 |
! |
|
1058 |
||
1059 |
physicalOffsetX |
|
1060 |
^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX" |
|
1061 |
||
1062 |
"Created: / 01-08-2006 / 16:28:34 / fm" |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
1063 |
"Modified: / 16-04-2007 / 12:52:06 / cg" |
2299 | 1064 |
! |
1065 |
||
1066 |
physicalOffsetY |
|
1067 |
^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY" |
|
1068 |
||
1069 |
"Created: / 01-08-2006 / 16:28:34 / fm" |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
1070 |
"Modified: / 16-04-2007 / 12:52:01 / cg" |
2299 | 1071 |
! |
1072 |
||
1073 |
pixelsPerInchOfScreenHeight |
|
1074 |
^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy" |
|
1075 |
||
1076 |
"Created: / 01-08-2006 / 16:29:16 / fm" |
|
1077 |
! |
|
1078 |
||
1079 |
pixelsPerInchOfScreenWidth |
|
1080 |
^ OperatingSystem getDeviceCaps:gcId index:88 "Logpixelsx" |
|
1081 |
||
1082 |
"Created: / 01-08-2006 / 16:28:34 / fm" |
|
1083 |
! |
|
1084 |
||
1085 |
printerHeightArea |
|
1086 |
^ (OperatingSystem getDeviceCaps:gcId index:10) |
|
1087 |
||
1088 |
"Modified: / 10-10-2006 / 18:18:31 / cg" |
|
1089 |
! |
|
1090 |
||
1091 |
printerPhysicalHeight |
|
1092 |
^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:111 "PhysicalHeight" |
|
1093 |
||
1094 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
1095 |
! |
|
1096 |
||
1097 |
printerPhysicalWidth |
|
1098 |
^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:110 "PhysicalWidth" |
|
1099 |
||
1100 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
1101 |
! |
|
1102 |
||
1103 |
printerWidthArea |
|
1104 |
^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres" |
|
1105 |
||
1106 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
1107 |
! |
|
1108 |
||
2323 | 1109 |
supportedImageFormats |
1110 |
"return an array with supported image formats; each array entry |
|
1111 |
is another array, consisting of depth and bitsPerPixel values." |
|
1112 |
||
1113 |
|info| |
|
1114 |
||
1115 |
info := IdentityDictionary new. |
|
1116 |
info at:#depth put:self depth. |
|
1117 |
info at:#bitsPerPixel put:self depth. |
|
1118 |
info at:#padding put:32. |
|
1119 |
^ Array with:info |
|
1120 |
||
1121 |
" |
|
1122 |
Disply supportedImageFormats |
|
1123 |
" |
|
1124 |
||
1125 |
"Modified: / 10.9.1998 / 23:14:05 / cg" |
|
1126 |
! |
|
1127 |
||
1128 |
visualType |
|
1129 |
^ #TrueColor |
|
1130 |
! ! |
|
1131 |
||
1132 |
!WinPrinterContext methodsFor:'color stuff'! |
|
1133 |
||
1134 |
colorScaledRed:r scaledGreen:g scaledBlue:b |
|
1135 |
"allocate a color with rgb values (0..16rFFFF) - return the color index |
|
1136 |
(i.e. colorID)" |
|
1137 |
||
1138 |
%{ /* NOCONTEXT */ |
|
1139 |
int id, ir, ig, ib; |
|
1140 |
||
1141 |
if (__bothSmallInteger(r, g) && __isSmallInteger(b)) { |
|
2344 | 1142 |
ir = (__intVal(r) >> 8) & 0xff; |
1143 |
ig = (__intVal(g) >> 8) & 0xff; |
|
1144 |
ib = (__intVal(b) >> 8) & 0xff; |
|
1145 |
||
1146 |
id = RGB( ir, ig, ib); |
|
1147 |
||
1148 |
RETURN ( __MKSMALLINT(id) ); |
|
2323 | 1149 |
} |
1150 |
%}. |
|
1151 |
self primitiveFailed. |
|
1152 |
^ nil |
|
1153 |
! |
|
1154 |
||
1155 |
setBackground:bgColorIndex in:aDC |
|
1156 |
"set background color to be drawn with" |
|
1157 |
||
1158 |
%{ /* NOCONTEXT */ |
|
1159 |
||
1160 |
HDC hDC; |
|
1161 |
||
1162 |
if (__isExternalAddressLike(aDC)) { |
|
2344 | 1163 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1164 |
COLORREF bg, oldBg; |
|
1165 |
||
1166 |
oldBg = GetBkColor(hDC); |
|
1167 |
||
1168 |
bg = __intVal(bgColorIndex) & 0xffffff; |
|
2323 | 1169 |
/* bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData); */ |
1170 |
||
2344 | 1171 |
if (bg != oldBg) { |
1172 |
SetBkColor(hDC, bg); |
|
1173 |
} |
|
1174 |
||
1175 |
RETURN (self); |
|
2323 | 1176 |
} |
1177 |
%} |
|
1178 |
! |
|
1179 |
||
1180 |
setBackgroundColor:color in:aGCId |
|
1181 |
"set background color to be drawn with" |
|
1182 |
||
1183 |
|colorId deviceColor| |
|
1184 |
||
1185 |
(color isOnDevice:self) ifTrue:[ |
|
2344 | 1186 |
colorId := color colorId. |
2323 | 1187 |
] ifFalse:[ |
2344 | 1188 |
deviceColor := color onDevice:self. |
1189 |
deviceColor notNil ifTrue:[ |
|
1190 |
colorId := deviceColor colorId. |
|
1191 |
] |
|
2323 | 1192 |
]. |
1193 |
colorId isNil ifTrue:[ |
|
2344 | 1194 |
'DeviceWorkstation [warning]: could not set bg color' infoPrintCR. |
2323 | 1195 |
] ifFalse:[ |
2344 | 1196 |
self setBackground:colorId in:aGCId. |
2323 | 1197 |
] |
1198 |
! |
|
1199 |
||
1200 |
setForeground:fgColorIndex background:bgColorIndex in:aDC |
|
1201 |
"set foreground and background colors to be drawn with" |
|
1202 |
||
1203 |
%{ /* NOCONTEXT */ |
|
1204 |
||
1205 |
if (__isExternalAddressLike(aDC)) { |
|
2344 | 1206 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1207 |
COLORREF fg, bg, oldFg, oldBg; |
|
2323 | 1208 |
|
1209 |
/* fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData); */ |
|
2344 | 1210 |
fg = __intVal(fgColorIndex) & 0xffffff; |
2323 | 1211 |
/* bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData); */ |
2344 | 1212 |
bg = __intVal(bgColorIndex) & 0xffffff; |
1213 |
||
1214 |
oldFg = GetTextColor(hDC); |
|
1215 |
oldBg = GetBkColor(hDC); |
|
1216 |
||
1217 |
if ((fg != oldFg) || (bg != oldBg)) { |
|
1218 |
/* Pen only depends upon fg-color */ |
|
1219 |
if (fg != oldFg) { |
|
1220 |
SetTextColor(hDC, fg); |
|
1221 |
} |
|
1222 |
if (bg != oldBg) { |
|
1223 |
SetBkColor(hDC, bg); |
|
1224 |
} |
|
1225 |
} |
|
1226 |
RETURN (self); |
|
2323 | 1227 |
} |
1228 |
%} |
|
1229 |
! |
|
1230 |
||
1231 |
setForeground:fgColorIndex in:aDC |
|
1232 |
"set foreground color to be drawn with" |
|
1233 |
||
1234 |
%{ /* NOCONTEXT */ |
|
1235 |
||
1236 |
HDC hDC; |
|
1237 |
||
1238 |
if (__isExternalAddressLike(aDC)) { |
|
2344 | 1239 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1240 |
COLORREF fg, oldFg; |
|
1241 |
||
1242 |
oldFg = GetTextColor(hDC); |
|
1243 |
||
1244 |
fg = __intVal(fgColorIndex) & 0xffffff; |
|
2323 | 1245 |
/* fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData); */ |
1246 |
||
2344 | 1247 |
if (fg != oldFg) { |
1248 |
SetTextColor(hDC, fg); |
|
1249 |
} |
|
1250 |
||
1251 |
RETURN (self); |
|
2323 | 1252 |
} |
1253 |
%} |
|
1254 |
! |
|
1255 |
||
1256 |
setForegroundColor:color in:aGCId |
|
1257 |
"set the foreground color to be drawn with" |
|
1258 |
||
1259 |
|colorId deviceColor| |
|
1260 |
||
1261 |
(color isOnDevice:self) ifTrue:[ |
|
2344 | 1262 |
colorId := color colorId. |
2323 | 1263 |
] ifFalse:[ |
2344 | 1264 |
deviceColor := color onDevice:self. |
1265 |
deviceColor notNil ifTrue:[ |
|
1266 |
colorId := deviceColor colorId. |
|
1267 |
] |
|
2323 | 1268 |
]. |
1269 |
colorId isNil ifTrue:[ |
|
2344 | 1270 |
'DeviceWorkstation [warning]: could not set fg color' infoPrintCR. |
2323 | 1271 |
] ifFalse:[ |
2344 | 1272 |
self setForeground:colorId in:aGCId. |
2323 | 1273 |
] |
1274 |
! ! |
|
1275 |
||
1276 |
!WinPrinterContext methodsFor:'context stuff'! |
|
1277 |
||
1278 |
getPenFor:aDC |
|
1279 |
"set line attributes" |
|
1280 |
||
1281 |
%{ /* NOCONTEXT */ |
|
1282 |
||
1283 |
if (__isExternalAddressLike(aDC) |
|
1284 |
&& __isSmallInteger(__INST(lineWidth))) { |
|
2344 | 1285 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1286 |
COLORREF fgColor; |
|
1287 |
HANDLE hPen, prevPen; |
|
1288 |
int lineStyleInt, capStyleInt, joinStyleInt, lineWidth; |
|
1289 |
||
1290 |
lineWidth= __INST(lineWidth); |
|
1291 |
||
1292 |
if (__INST(lineStyle) == @symbol(solid)) { |
|
1293 |
lineStyleInt= PS_SOLID; |
|
1294 |
} else if (__INST(lineStyle) == @symbol(dashed)) { |
|
1295 |
lineStyleInt= PS_DASH; |
|
1296 |
} else if (__INST(lineStyle) == @symbol(dotted)) { |
|
1297 |
lineStyleInt= PS_DOT; |
|
1298 |
} else if (__INST(lineStyle) == @symbol(dashDot)) { |
|
1299 |
lineStyleInt= PS_DASHDOT; |
|
1300 |
} else if (__INST(lineStyle) == @symbol(dashDotDot)) { |
|
1301 |
lineStyleInt= PS_DASHDOTDOT; |
|
1302 |
} else |
|
1303 |
lineStyleInt= PS_SOLID; |
|
1304 |
||
1305 |
if (__INST(capStyle) == @symbol(round)) { |
|
1306 |
capStyleInt= PS_ENDCAP_ROUND; |
|
1307 |
} else if (__INST(capStyle) == @symbol(square)) { |
|
1308 |
capStyleInt= PS_ENDCAP_SQUARE; |
|
1309 |
} else if (__INST(capStyle) == @symbol(flat)) { |
|
1310 |
capStyleInt= PS_ENDCAP_FLAT; |
|
1311 |
} else |
|
1312 |
capStyleInt= PS_ENDCAP_FLAT; |
|
1313 |
||
1314 |
if (__INST(joinStyle) == @symbol(bevel)) { |
|
1315 |
joinStyleInt= PS_JOIN_BEVEL; |
|
1316 |
} else if (__INST(joinStyle) == @symbol(miter)) { |
|
1317 |
joinStyleInt= PS_JOIN_MITER; |
|
1318 |
} else if (__INST(joinStyle) == @symbol(round)) { |
|
1319 |
joinStyleInt= PS_JOIN_ROUND; |
|
1320 |
} else |
|
1321 |
joinStyleInt= PS_JOIN_MITER; |
|
1322 |
||
1323 |
||
1324 |
fgColor = GetTextColor(hDC); |
|
1325 |
||
1326 |
hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor); |
|
1327 |
prevPen = SelectObject(hDC, hPen); |
|
1328 |
||
1329 |
||
1330 |
RETURN (self); |
|
2323 | 1331 |
} |
1332 |
%}. |
|
1333 |
self primitiveFailed |
|
1334 |
! |
|
1335 |
||
1336 |
getPenForContext |
|
1337 |
"set line attributes" |
|
1338 |
||
1339 |
%{ /* NOCONTEXT */ |
|
1340 |
||
1341 |
if (__isExternalAddressLike(__INST(gcId)) |
|
1342 |
&& __isSmallInteger(__INST(lineWidth))) { |
|
2344 | 1343 |
HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId))); |
1344 |
COLORREF fgColor; |
|
1345 |
HANDLE hPen; |
|
1346 |
int lineStyleInt, capStyleInt, joinStyleInt, lineWidth; |
|
1347 |
||
1348 |
lineWidth= __INST(lineWidth); |
|
1349 |
||
1350 |
if (__INST(lineStyle) == @symbol(solid)) { |
|
1351 |
lineStyleInt= PS_SOLID; |
|
1352 |
} else if (__INST(lineStyle) == @symbol(dashed)) { |
|
1353 |
lineStyleInt= PS_DASH; |
|
1354 |
} else if (__INST(lineStyle) == @symbol(dotted)) { |
|
1355 |
lineStyleInt= PS_DOT; |
|
1356 |
} else if (__INST(lineStyle) == @symbol(dashDot)) { |
|
1357 |
lineStyleInt= PS_DASHDOT; |
|
1358 |
} else if (__INST(lineStyle) == @symbol(dashDotDot)) { |
|
1359 |
lineStyleInt= PS_DASHDOTDOT; |
|
1360 |
} else |
|
1361 |
lineStyleInt= PS_SOLID; |
|
1362 |
||
1363 |
if (__INST(capStyle) == @symbol(round)) { |
|
1364 |
capStyleInt= PS_ENDCAP_ROUND; |
|
1365 |
} else if (__INST(capStyle) == @symbol(square)) { |
|
1366 |
capStyleInt= PS_ENDCAP_SQUARE; |
|
1367 |
} else if (__INST(capStyle) == @symbol(flat)) { |
|
1368 |
capStyleInt= PS_ENDCAP_FLAT; |
|
1369 |
} else |
|
1370 |
capStyleInt= PS_ENDCAP_FLAT; |
|
1371 |
||
1372 |
if (__INST(joinStyle) == @symbol(bevel)) { |
|
1373 |
joinStyleInt= PS_JOIN_BEVEL; |
|
1374 |
} else if (__INST(joinStyle) == @symbol(miter)) { |
|
1375 |
joinStyleInt= PS_JOIN_MITER; |
|
1376 |
} else if (__INST(joinStyle) == @symbol(round)) { |
|
1377 |
joinStyleInt= PS_JOIN_ROUND; |
|
1378 |
} else |
|
1379 |
joinStyleInt= PS_JOIN_MITER; |
|
1380 |
||
1381 |
||
1382 |
fgColor = GetTextColor(hDC); |
|
1383 |
||
1384 |
hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor); |
|
1385 |
||
1386 |
RETURN (self); |
|
2323 | 1387 |
} |
1388 |
%}. |
|
1389 |
self primitiveFailed |
|
1390 |
! |
|
1391 |
||
2330 | 1392 |
hatch |
1393 |
||
1394 |
"The hatch style will define a hatched brush between these patterns: |
|
1395 |
||
1396 |
#none |
|
1397 |
#horizontal ----- HS_HORIZONTAL = 0 |
|
1398 |
#vertical ||||| HS_VERTICAL = 1 |
|
1399 |
#fDiagonal \\\\\ HS_FDIAGONAL = 2 |
|
1400 |
#bDiagonal ///// HS_BDIAGONAL = 3 |
|
1401 |
#cross +++++ HS_CROSS = 4 |
|
1402 |
#diagonalCross xxxxx HS_DIAGCROSS = 5 |
|
1403 |
" |
|
1404 |
||
1405 |
hatch isNil ifTrue:[^#none]. |
|
1406 |
^ hatch |
|
1407 |
! |
|
1408 |
||
1409 |
hatch: aSymbol |
|
1410 |
||
1411 |
"The hatch style will define a hatched brush between these patterns: |
|
1412 |
||
1413 |
#none |
|
1414 |
#horizontal ----- HS_HORIZONTAL = 0 |
|
1415 |
#vertical ||||| HS_VERTICAL = 1 |
|
1416 |
#fDiagonal \\\\\ HS_FDIAGONAL = 2 |
|
1417 |
#bDiagonal ///// HS_BDIAGONAL = 3 |
|
1418 |
#cross +++++ HS_CROSS = 4 |
|
1419 |
#diagonalCross xxxxx HS_DIAGCROSS = 5 |
|
1420 |
" |
|
1421 |
||
1422 |
hatch := aSymbol |
|
1423 |
! |
|
1424 |
||
2323 | 1425 |
noClipIn:aWindowId gc:aDC |
1426 |
"disable clipping rectangle" |
|
1427 |
||
1428 |
%{ /* NOCONTEXT */ |
|
1429 |
||
1430 |
if (__isExternalAddressLike(aDC)) { |
|
2344 | 1431 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1432 |
||
1433 |
SelectClipRgn(hDC, NULL); |
|
1434 |
RETURN (self); |
|
2323 | 1435 |
} |
1436 |
%} |
|
1437 |
! |
|
1438 |
||
1439 |
setBitmapMask:aBitmapId in:aDC |
|
1440 |
"set or clear the drawing mask - a bitmap mask using current fg/bg" |
|
1441 |
||
1442 |
%{ /* NOCONTEXT */ |
|
1443 |
||
1444 |
if (__isExternalAddressLike(aDC)) { |
|
2344 | 1445 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1446 |
HBITMAP oldM; |
|
2323 | 1447 |
|
1448 |
/* oldM = gcData->hMask; |
|
2344 | 1449 |
if (__isExternalAddress(aBitmapId)) |
1450 |
gcData->hMask = _HBITMAPVAL(aBitmapId); |
|
1451 |
else |
|
1452 |
gcData->hMask = 0; |
|
1453 |
||
1454 |
if (oldM != gcData->hMask) { |
|
1455 |
FLUSH_CACHED_DC(gcData); |
|
1456 |
CPRINTF(("masks set to %x\n",gcData->hMask)); |
|
1457 |
} */ |
|
1458 |
RETURN (self); |
|
2323 | 1459 |
} |
1460 |
%} |
|
1461 |
! |
|
1462 |
||
1463 |
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:ignoredDrawableId gc:aDC |
|
1464 |
"clip to a rectangle" |
|
1465 |
||
1466 |
" |
|
1467 |
p--w--- |
|
1468 |
| | |
|
1469 |
h | the clipping rectangle |
|
1470 |
| | |
|
1471 |
------- |
|
2344 | 1472 |
where p = ( clipX, clipY ), w = clipWidth, h = clipHeight |
2323 | 1473 |
" |
1474 |
||
1475 |
%{ /* NOCONTEXT */ |
|
1476 |
||
1477 |
if (__isExternalAddressLike(aDC) |
|
1478 |
&& __bothSmallInteger(clipX, clipY) |
|
1479 |
&& __bothSmallInteger(clipWidth, clipHeight) ) { |
|
2344 | 1480 |
HANDLE hDC; |
1481 |
int cX, cY, cW, cH; |
|
1482 |
POINT ptOrg; |
|
1483 |
||
1484 |
||
1485 |
hDC = (HANDLE)(__externalAddressVal(aDC)); |
|
1486 |
||
1487 |
GetViewportOrgEx(hDC,&ptOrg); |
|
1488 |
||
1489 |
// set the clip rectangle |
|
1490 |
// and offset the rectangle by the viewport origin |
|
1491 |
||
1492 |
cX = __intVal(clipX) + ptOrg.x; |
|
1493 |
cY = __intVal(clipY) + ptOrg.y; |
|
1494 |
cW = __intVal(clipWidth)+ ptOrg.x; |
|
1495 |
cH = __intVal(clipHeight)+ ptOrg.y; |
|
1496 |
||
1497 |
{ |
|
1498 |
HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH); |
|
1499 |
||
1500 |
if (region == NULL ) { |
|
1501 |
console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n"); |
|
1502 |
} else { |
|
1503 |
if (SelectClipRgn(hDC, region) == ERROR ) { |
|
1504 |
console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n"); |
|
1505 |
} |
|
1506 |
DeleteObject(region); |
|
1507 |
} |
|
1508 |
} |
|
1509 |
RETURN (self); |
|
2323 | 1510 |
} |
1511 |
%}. |
|
1512 |
self primitiveFailed |
|
1513 |
! |
|
1514 |
||
1515 |
setDashes:dashList dashOffset:offset in:aGCId |
|
1516 |
"set line attributes" |
|
1517 |
||
1518 |
%{ /* NOCONTEXT */ |
|
1519 |
||
1520 |
if (__isExternalAddressLike(aGCId)) { |
|
2344 | 1521 |
DPRINTF(("WinWorkstat [warning]: dashes not (yet) implemented\n")); |
2323 | 1522 |
} |
1523 |
%} |
|
1524 |
! |
|
1525 |
||
1526 |
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aDC |
|
1527 |
"set line attributes" |
|
1528 |
||
1529 |
%{ /* NOCONTEXT */ |
|
1530 |
||
1531 |
HDC hDC; |
|
1532 |
||
1533 |
if (__isExternalAddressLike(aDC) |
|
1534 |
&& __isSmallInteger(aNumber)) { |
|
2344 | 1535 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1536 |
int style; |
|
1537 |
||
1538 |
if (lineStyle == @symbol(solid)) { |
|
1539 |
style = PS_SOLID; |
|
1540 |
} else if (lineStyle == @symbol(dashed)) { |
|
1541 |
style= PS_DASH; |
|
1542 |
} else if (lineStyle == @symbol(dotted)) { |
|
1543 |
style= PS_DOT; |
|
1544 |
} else if (lineStyle == @symbol(dashDot)) { |
|
1545 |
style= PS_DASHDOT; |
|
1546 |
} else if (lineStyle == @symbol(dashDotDot)) { |
|
1547 |
style= PS_DASHDOTDOT; |
|
1548 |
} else |
|
1549 |
style= PS_SOLID; |
|
1550 |
||
1551 |
if (capStyle == @symbol(round)) { |
|
1552 |
style = PS_ENDCAP_ROUND; |
|
1553 |
} else if (capStyle == @symbol(square)) { |
|
1554 |
style = PS_ENDCAP_SQUARE; |
|
1555 |
} else if (capStyle == @symbol(flat)) { |
|
1556 |
style = PS_ENDCAP_FLAT; |
|
1557 |
} else |
|
1558 |
style = PS_ENDCAP_FLAT; |
|
1559 |
||
1560 |
if (joinStyle == @symbol(bevel)) { |
|
1561 |
style = PS_JOIN_BEVEL; |
|
1562 |
} else if (joinStyle == @symbol(miter)) { |
|
1563 |
style = PS_JOIN_MITER; |
|
1564 |
} else if (joinStyle == @symbol(round)) { |
|
1565 |
style = PS_JOIN_ROUND; |
|
1566 |
} else |
|
1567 |
style = PS_JOIN_MITER; |
|
1568 |
||
1569 |
||
1570 |
RETURN (self); |
|
2323 | 1571 |
} |
1572 |
%}. |
|
1573 |
self primitiveFailed |
|
1574 |
! |
|
1575 |
||
1576 |
setMaskOriginX:orgX y:orgY in:aDC |
|
1577 |
"set the mask origin" |
|
1578 |
||
1579 |
%{ /* NOCONTEXT */ |
|
1580 |
||
1581 |
if (__isExternalAddress(aDC) |
|
1582 |
&& __bothSmallInteger(orgX,orgY)) { |
|
2344 | 1583 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1584 |
int oX, oY, maskOrgX, maskOrgY; |
|
1585 |
||
1586 |
oX = __intVal(orgX); |
|
1587 |
oY = __intVal(orgY); |
|
1588 |
if ((oX != maskOrgX) |
|
1589 |
|| (oY != maskOrgY)) { |
|
1590 |
maskOrgX = __intVal(orgX); |
|
1591 |
maskOrgY = __intVal(orgY);; |
|
1592 |
} |
|
1593 |
RETURN (self); |
|
2323 | 1594 |
} |
1595 |
%} |
|
1596 |
! |
|
1597 |
||
2299 | 1598 |
setViewportOrg: aPoint |
1599 |
||
2323 | 1600 |
"Sets the viewport origin (LOGICAL point (0,0)) of the device context" |
1601 |
||
2317 | 1602 |
^ OperatingSystem |
2344 | 1603 |
setViewportOrg: gcId "deviceContext" |
1604 |
x: aPoint x |
|
1605 |
y: aPoint y |
|
1606 |
oldOrigin: nil |
|
2299 | 1607 |
|
1608 |
"Created: / 01-08-2006 / 16:14:08 / fm" |
|
1609 |
! ! |
|
1610 |
||
2316 | 1611 |
!WinPrinterContext methodsFor:'drawing'! |
1612 |
||
2323 | 1613 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:ignoredDrawableId with:aDC |
1614 |
"draw an arc. If any of x,y, w or h is not an integer, an error is triggered. |
|
1615 |
The angles may be floats or integer - they are given in degrees." |
|
1616 |
||
1617 |
%{ |
|
1618 |
int __x, __y, w, h; |
|
1619 |
float angle1, angle2; |
|
1620 |
double f; |
|
1621 |
||
1622 |
if (__isSmallInteger(startAngle)) |
|
2344 | 1623 |
angle1 = (float)(__intVal(startAngle)); |
2323 | 1624 |
else if (__isFloat(startAngle)) { |
2344 | 1625 |
angle1 = (float) __floatVal(startAngle); |
2323 | 1626 |
} else if (__isShortFloat(startAngle)) { |
2344 | 1627 |
angle1 = __shortFloatVal(startAngle); |
2323 | 1628 |
} else goto bad; |
1629 |
||
1630 |
if (__isSmallInteger(angle)) |
|
2344 | 1631 |
angle2 = (float)(__intVal(angle)); |
2323 | 1632 |
else if (__isFloat(angle)) { |
2344 | 1633 |
angle2 = (float) __floatVal(angle); |
2323 | 1634 |
} else if (__isShortFloat(angle)) { |
2344 | 1635 |
angle2 = __shortFloatVal(angle); |
2323 | 1636 |
} else goto bad; |
1637 |
||
1638 |
if (angle2 <= 0) { |
|
2344 | 1639 |
RETURN (self); |
2323 | 1640 |
} |
1641 |
||
1642 |
if (__isExternalAddressLike(aDC) |
|
1643 |
&& __bothSmallInteger(x, y) |
|
1644 |
&& __bothSmallInteger(width, height)) |
|
1645 |
{ |
|
2344 | 1646 |
POINT p; |
1647 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
|
1648 |
DWORD clr = 0 /* 0xFFFFFFFF */; |
|
1649 |
HANDLE prevPen, hPen; |
|
1650 |
double xB, yB, xE, yE, xR, yR; |
|
1651 |
COLORREF fgColor; |
|
1652 |
int lStyleSymbol, lStyleInt; |
|
1653 |
int lw; |
|
1654 |
||
1655 |
lw= __intVal(__INST(lineWidth)); |
|
1656 |
lStyleSymbol= __INST(lineStyle); |
|
1657 |
||
1658 |
/* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
|
1659 |
only works with lineWidth = 1 */ |
|
1660 |
||
1661 |
if (lStyleSymbol == @symbol(solid)) { |
|
1662 |
lStyleInt= PS_SOLID; |
|
1663 |
} else if (lStyleSymbol == @symbol(dashed)) { |
|
1664 |
lStyleInt= PS_DASH; |
|
1665 |
} else if (lStyleSymbol == @symbol(dotted)) { |
|
1666 |
lStyleInt= PS_DOT; |
|
1667 |
} else if (lStyleSymbol == @symbol(dashDot)) { |
|
1668 |
lStyleInt= PS_DASHDOT; |
|
1669 |
} else if (lStyleSymbol == @symbol(dashDotDot)) { |
|
1670 |
lStyleInt= PS_DASHDOTDOT; |
|
1671 |
} else if (lStyleSymbol == @symbol(insideFrame)) { |
|
1672 |
lStyleInt= PS_INSIDEFRAME; |
|
1673 |
} else |
|
1674 |
lStyleInt= PS_SOLID; |
|
1675 |
||
1676 |
fgColor = GetTextColor(hDC); |
|
1677 |
hPen = CreatePen(lStyleInt, lw, fgColor); |
|
1678 |
||
1679 |
w = __intVal(width); |
|
1680 |
h = __intVal(height); |
|
1681 |
__x = __intVal(x); |
|
1682 |
__y = __intVal(y); |
|
1683 |
||
1684 |
xR = w / 2; |
|
1685 |
yR = h / 2; |
|
1686 |
if (angle2 - angle1 >= 360) { |
|
1687 |
xB = xE = __x + xR + 0.5; |
|
1688 |
yB = yE = __y /*+ yR + 0.5*/; |
|
1689 |
} else { |
|
1690 |
double sin(), cos(); |
|
1691 |
float rad1, rad2; |
|
1692 |
||
1693 |
if (angle1 <= 180) |
|
1694 |
angle1 = 180 - angle1; |
|
1695 |
else |
|
1696 |
angle1 = 360 + 180 - angle1; |
|
1697 |
angle2 = angle1 - angle2; |
|
1698 |
/* sigh - compute the intersections ... */ |
|
1699 |
rad1 = (angle1 * 3.14159265359) / 180.0; |
|
1700 |
rad2 = (angle2 * 3.14159265359) / 180.0; |
|
1701 |
xB = cos(rad1) * xR; |
|
1702 |
yB = sin(rad1) * yR; |
|
1703 |
xE = cos(rad2) * xR; |
|
1704 |
yE = sin(rad2) * yR; |
|
1705 |
xB = __x + xR - xB + 0.5; |
|
1706 |
yB = __y + yR - yB + 0.5; |
|
1707 |
xE = __x + xR - xE + 0.5; |
|
1708 |
yE = __y + yR - yE + 0.5; |
|
1709 |
} |
|
1710 |
prevPen = SelectObject(hDC, hPen); |
|
1711 |
DPRINTF(("Arc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2)); |
|
1712 |
Arc(hDC, |
|
1713 |
__x, __y, |
|
1714 |
__x + w, __y + h, |
|
1715 |
(int)xB, (int)yB, |
|
1716 |
(int)xE, (int)yE); |
|
1717 |
||
1718 |
SelectObject(hDC, prevPen); |
|
1719 |
DeleteObject(hPen); |
|
1720 |
||
1721 |
RETURN ( self ); |
|
2323 | 1722 |
} |
1723 |
bad: ; |
|
1724 |
%}. |
|
1725 |
self primitiveFailed |
|
1726 |
||
1727 |
"Created: / 07-08-2006 / 10:40:27 / fm" |
|
1728 |
"Modified: / 07-08-2006 / 14:44:21 / fm" |
|
1729 |
! |
|
1730 |
||
1731 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC |
|
1732 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
1733 |
||
1734 |
%{ /* NOCONTEXT */ |
|
1735 |
if (__isExternalAddressLike(aDC) |
|
1736 |
&& __bothSmallInteger(x0, y0) |
|
1737 |
&& __bothSmallInteger(x1, y1)) { |
|
2342 | 1738 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1739 |
COLORREF fgColor; |
|
1740 |
HANDLE prevPen, hPen; |
|
1741 |
int __x1 = __intVal(x1), __y1 = __intVal(y1); |
|
1742 |
int lStyleSymbol, lStyleInt; |
|
1743 |
int lw; |
|
2323 | 1744 |
|
1745 |
/* DPRINTF(("displayLine: %d/%d -> %d/%d\n", |
|
2342 | 1746 |
__intVal(x0), __intVal(y0), |
1747 |
__x1, __y1)); |
|
2323 | 1748 |
*/ |
1749 |
||
2342 | 1750 |
lw= __intVal(__INST(lineWidth)); |
1751 |
lStyleSymbol= __INST(lineStyle); |
|
1752 |
||
1753 |
/* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
|
1754 |
only works with lineWidth = 1 */ |
|
1755 |
||
1756 |
if (lStyleSymbol == @symbol(solid)) { |
|
1757 |
lStyleInt= PS_SOLID; |
|
1758 |
} else if (lStyleSymbol == @symbol(dashed)) { |
|
1759 |
lStyleInt= PS_DASH; |
|
1760 |
} else if (lStyleSymbol == @symbol(dotted)) { |
|
1761 |
lStyleInt= PS_DOT; |
|
1762 |
} else if (lStyleSymbol == @symbol(dashDot)) { |
|
1763 |
lStyleInt= PS_DASHDOT; |
|
1764 |
} else if (lStyleSymbol == @symbol(dashDotDot)) { |
|
1765 |
lStyleInt= PS_DASHDOTDOT; |
|
1766 |
} else if (lStyleSymbol == @symbol(insideFrame)) { |
|
1767 |
lStyleInt= PS_INSIDEFRAME; |
|
1768 |
} else |
|
1769 |
lStyleInt= PS_SOLID; |
|
1770 |
||
1771 |
fgColor = GetTextColor(hDC); |
|
1772 |
hPen = CreatePen(lStyleInt, lw, fgColor); |
|
1773 |
prevPen = SelectObject(hDC, hPen); |
|
1774 |
MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL); |
|
1775 |
LineTo(hDC, __x1, __y1); |
|
1776 |
/* |
|
1777 |
* end-point ... |
|
1778 |
*/ |
|
1779 |
// LineTo(hDC, __x1+1, __y1); |
|
1780 |
||
1781 |
SelectObject(hDC, prevPen); |
|
1782 |
DeleteObject(hPen); |
|
1783 |
||
1784 |
RETURN ( self ); |
|
2323 | 1785 |
} |
1786 |
%} |
|
1787 |
! |
|
1788 |
||
1789 |
displayPointX:px y:py in:ignoredDrawableId with:aDC |
|
1790 |
"draw a point. If x/y are not integers, an error is triggered." |
|
1791 |
||
1792 |
%{ /* NOCONTEXT */ |
|
1793 |
if (__isExternalAddressLike(aDC) |
|
1794 |
&& __bothSmallInteger(px, py)) { |
|
2344 | 1795 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1796 |
POINT p; |
|
1797 |
COLORREF fgColor; |
|
1798 |
||
1799 |
int __x = __intVal(px), __y = __intVal(py); |
|
1800 |
||
1801 |
fgColor = GetTextColor(hDC); |
|
1802 |
SetPixelV(hDC, __x, __y, fgColor); |
|
1803 |
||
1804 |
RETURN ( self ); |
|
2323 | 1805 |
} |
1806 |
%} |
|
1807 |
! |
|
1808 |
||
1809 |
displayPolygon:aPolygon in:aDrawableId with:aDC |
|
1810 |
"draw a polygon, the argument aPolygon is a Collection of individual points, |
|
1811 |
which define the polygon. |
|
1812 |
If any coordinate is not integer, an error is triggered." |
|
1813 |
||
1814 |
|numberOfPoints| |
|
1815 |
||
1816 |
numberOfPoints := aPolygon size. |
|
1817 |
%{ |
|
1818 |
OBJ point, px, py; |
|
1819 |
int i, num; |
|
1820 |
||
1821 |
if (__isExternalAddressLike(aDC) |
|
1822 |
/* && __isExternalAddress(aDrawableId) */ |
|
1823 |
&& __isSmallInteger(numberOfPoints)) { |
|
2344 | 1824 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1825 |
POINT p; |
|
1826 |
DWORD clr = 0 /* 0xFFFFFFFF */; |
|
1827 |
HANDLE prevPen, hPen; |
|
1828 |
int lw; |
|
1829 |
COLORREF fgColor; |
|
1830 |
int lStyleSymbol, lStyleInt; |
|
1831 |
||
1832 |
lw= __intVal(__INST(lineWidth)); |
|
1833 |
lStyleSymbol= __INST(lineStyle); |
|
1834 |
||
1835 |
/* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
|
1836 |
only works with lineWidth = 1 */ |
|
1837 |
||
1838 |
if (lStyleSymbol == @symbol(solid)) { |
|
1839 |
lStyleInt= PS_SOLID; |
|
1840 |
} else if (lStyleSymbol == @symbol(dashed)) { |
|
1841 |
lStyleInt= PS_DASH; |
|
1842 |
} else if (lStyleSymbol == @symbol(dotted)) { |
|
1843 |
lStyleInt= PS_DOT; |
|
1844 |
} else if (lStyleSymbol == @symbol(dashDot)) { |
|
1845 |
lStyleInt= PS_DASHDOT; |
|
1846 |
} else if (lStyleSymbol == @symbol(dashDotDot)) { |
|
1847 |
lStyleInt= PS_DASHDOTDOT; |
|
1848 |
} else if (lStyleSymbol == @symbol(insideFrame)) { |
|
1849 |
lStyleInt= PS_INSIDEFRAME; |
|
1850 |
} else |
|
1851 |
lStyleInt= PS_SOLID; |
|
1852 |
||
1853 |
num = __intVal(numberOfPoints); |
|
1854 |
||
1855 |
for (i=0; i<num; i++) { |
|
1856 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
1857 |
if (! __isPoint(point)) goto fail; |
|
1858 |
px = _point_X(point); |
|
1859 |
py = _point_Y(point); |
|
1860 |
if (! __bothSmallInteger(px, py)) { |
|
1861 |
goto fail; |
|
1862 |
} |
|
1863 |
} |
|
1864 |
||
1865 |
fgColor = GetTextColor(hDC); |
|
1866 |
||
1867 |
hPen = CreatePen(lStyleInt, lw, fgColor); |
|
1868 |
prevPen = SelectObject(hDC, hPen); |
|
1869 |
||
1870 |
for (i=0; i<num; i++) { |
|
1871 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
1872 |
px = _point_X(point); |
|
1873 |
py = _point_Y(point); |
|
1874 |
p.x = __intVal(px); |
|
1875 |
p.y = __intVal(py); |
|
1876 |
if (i == 0) { |
|
1877 |
MoveToEx(hDC, p.x, p.y, NULL); |
|
1878 |
} else { |
|
1879 |
if (i == (num-1)) { |
|
1880 |
PolylineTo(hDC, &p, 1); |
|
1881 |
} else { |
|
1882 |
LineTo(hDC, p.x, p.y); |
|
2323 | 1883 |
#ifdef PRE_04_JUN_04 |
2344 | 1884 |
/* |
1885 |
* end-point ... |
|
1886 |
*/ |
|
1887 |
LineTo(hDC, p.x+1, p.y); |
|
2323 | 1888 |
#endif |
2344 | 1889 |
} |
1890 |
} |
|
1891 |
} |
|
1892 |
SelectObject(hDC, prevPen); |
|
1893 |
DeleteObject(hPen); |
|
1894 |
||
1895 |
||
1896 |
RETURN ( self ); |
|
2323 | 1897 |
} |
1898 |
fail: ; |
|
1899 |
%} |
|
1900 |
||
1901 |
"Created: / 07-08-2006 / 14:46:55 / fm" |
|
1902 |
! |
|
1903 |
||
2317 | 1904 |
displayPolylines:arrayOfPoints |
2316 | 1905 |
|
1906 |
device displayPolylines:arrayOfPoints in:nil with:gcId |
|
2323 | 1907 |
! |
1908 |
||
1909 |
displayPolylines:aPolyline in:ignoredDrawableId with:aDC |
|
1910 |
"draw a polyline, the argument aPolyline is a collection of individual points, |
|
1911 |
which define the lines (p1/p2 pairs); must be even in size. |
|
1912 |
If any coordinate is not integer, an error is triggered." |
|
1913 |
||
1914 |
|numberOfPoints| |
|
1915 |
||
1916 |
numberOfPoints := aPolyline size. |
|
1917 |
||
1918 |
%{ |
|
1919 |
OBJ point, px, py; |
|
1920 |
int i, num; |
|
1921 |
||
1922 |
if (__isExternalAddressLike(aDC) |
|
1923 |
&& __isSmallInteger(numberOfPoints)) { |
|
1924 |
||
2344 | 1925 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
1926 |
POINT p; |
|
1927 |
HANDLE prevPen, hPen; |
|
1928 |
COLORREF fgColor; |
|
1929 |
int lw; |
|
1930 |
int lStyleSymbol, lStyleInt; |
|
1931 |
||
1932 |
||
1933 |
lw= __intVal(__INST(lineWidth)); |
|
1934 |
lStyleSymbol= __INST(lineStyle); |
|
1935 |
||
1936 |
/* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
|
1937 |
only works with lineWidth = 1 */ |
|
1938 |
||
1939 |
if (lStyleSymbol == @symbol(solid)) { |
|
1940 |
lStyleInt= PS_SOLID; |
|
1941 |
} else if (lStyleSymbol == @symbol(dashed)) { |
|
1942 |
lStyleInt= PS_DASH; |
|
1943 |
} else if (lStyleSymbol == @symbol(dotted)) { |
|
1944 |
lStyleInt= PS_DOT; |
|
1945 |
} else if (lStyleSymbol == @symbol(dashDot)) { |
|
1946 |
lStyleInt= PS_DASHDOT; |
|
1947 |
} else if (lStyleSymbol == @symbol(dashDotDot)) { |
|
1948 |
lStyleInt= PS_DASHDOTDOT; |
|
1949 |
} else if (lStyleSymbol == @symbol(insideFrame)) { |
|
1950 |
lStyleInt= PS_INSIDEFRAME; |
|
1951 |
} else |
|
1952 |
lStyleInt= PS_SOLID; |
|
1953 |
||
1954 |
fgColor = GetTextColor(hDC); |
|
1955 |
||
1956 |
num = __intVal(numberOfPoints); |
|
1957 |
||
1958 |
for (i=0; i<num; i++) { |
|
1959 |
point = __AT_(aPolyline, __MKSMALLINT(i+1)); |
|
1960 |
if (! __isPoint(point)) goto fail; |
|
1961 |
px = _point_X(point); |
|
1962 |
py = _point_Y(point); |
|
1963 |
if (! __bothSmallInteger(px, py)) { |
|
1964 |
goto fail; |
|
1965 |
} |
|
1966 |
} |
|
1967 |
||
1968 |
hPen = CreatePen(lStyleInt, lw, fgColor); |
|
1969 |
prevPen = SelectObject(hDC, hPen); |
|
1970 |
||
1971 |
for (i=0; i<num; i++) { |
|
1972 |
point = __AT_(aPolyline, __MKSMALLINT(i+1)); |
|
1973 |
px = _point_X(point); |
|
1974 |
py = _point_Y(point); |
|
1975 |
p.x = __intVal(px); |
|
1976 |
p.y = __intVal(py); |
|
1977 |
DPRINTF(("printing point")); |
|
1978 |
DPRINTF(("displayPolygon: no pen\n")); |
|
1979 |
||
1980 |
if ((i & 1) == 0) { |
|
1981 |
MoveToEx(hDC, p.x, p.y, NULL); |
|
1982 |
} else { |
|
1983 |
LineTo(hDC, p.x, p.y); |
|
1984 |
/* |
|
1985 |
* end-point ... |
|
1986 |
*/ |
|
1987 |
LineTo(hDC, p.x+1, p.y); |
|
1988 |
} |
|
1989 |
} |
|
1990 |
SelectObject(hDC, prevPen); |
|
1991 |
DeleteObject(hPen); |
|
1992 |
RETURN ( self ); |
|
2323 | 1993 |
} |
1994 |
fail: ; |
|
1995 |
%} |
|
1996 |
! |
|
1997 |
||
1998 |
displayRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC |
|
1999 |
"draw a rectangle. If the coordinates are not integers, an error is triggered." |
|
2000 |
||
2001 |
%{ |
|
2002 |
int w, h; |
|
2003 |
int xL, yT; |
|
2004 |
if (__isExternalAddressLike(aDC) |
|
2005 |
&& __bothSmallInteger(x, y) |
|
2006 |
&& __bothSmallInteger(width, height)) { |
|
2007 |
||
2342 | 2008 |
xL = __intVal(x); |
2009 |
yT = __intVal(y); |
|
2010 |
w = __intVal(width); |
|
2011 |
h = __intVal(height); |
|
2012 |
||
2013 |
DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h)); |
|
2014 |
||
2015 |
if ((w >= 0) && (h >= 0)) { |
|
2016 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
|
2017 |
COLORREF fgColor; |
|
2018 |
HANDLE prevPen, hPen; |
|
2019 |
int lStyleSymbol, lStyleInt; |
|
2020 |
||
2021 |
int lw; |
|
2022 |
||
2023 |
lw= __intVal(__INST(lineWidth)); |
|
2024 |
lStyleSymbol= __INST(lineStyle); |
|
2025 |
||
2026 |
/* PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT |
|
2027 |
only works with lineWidth = 1 */ |
|
2028 |
||
2029 |
if (lStyleSymbol == @symbol(solid)) { |
|
2030 |
lStyleInt= PS_SOLID; |
|
2031 |
} else if (lStyleSymbol == @symbol(dashed)) { |
|
2032 |
lStyleInt= PS_DASH; |
|
2033 |
} else if (lStyleSymbol == @symbol(dotted)) { |
|
2034 |
lStyleInt= PS_DOT; |
|
2035 |
} else if (lStyleSymbol == @symbol(dashDot)) { |
|
2036 |
lStyleInt= PS_DASHDOT; |
|
2037 |
} else if (lStyleSymbol == @symbol(dashDotDot)) { |
|
2038 |
lStyleInt= PS_DASHDOTDOT; |
|
2039 |
} else if (lStyleSymbol == @symbol(insideFrame)) { |
|
2040 |
lStyleInt= PS_INSIDEFRAME; |
|
2041 |
} else |
|
2042 |
lStyleInt= PS_SOLID; |
|
2043 |
||
2044 |
fgColor = GetTextColor(hDC); |
|
2045 |
hPen = CreatePen(lStyleInt, lw, fgColor); |
|
2046 |
||
2047 |
prevPen = SelectObject(hDC, hPen); |
|
2048 |
MoveToEx(hDC, xL, yT, NULL); |
|
2049 |
LineTo(hDC, xL+w, yT); // to top-right |
|
2050 |
LineTo(hDC, xL+w, yT+h); // to bot-right |
|
2051 |
MoveToEx(hDC, xL, yT, NULL); // back to top-left |
|
2052 |
LineTo(hDC, xL, yT+h); // to bot-left |
|
2053 |
// LineTo(hDC, xL+w+1, yT+h); // move pen one pixel more |
|
2054 |
LineTo(hDC, xL+w, yT+h); // move pen one pixel more |
|
2055 |
||
2056 |
SelectObject(hDC, prevPen); |
|
2057 |
DeleteObject(hPen); |
|
2058 |
||
2059 |
} |
|
2060 |
RETURN ( self ); |
|
2323 | 2061 |
} |
2062 |
%}. |
|
2063 |
self primitiveFailed |
|
2064 |
||
2065 |
"Created: / 28-07-2006 / 20:18:25 / fm" |
|
2066 |
! |
|
2067 |
||
2068 |
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId |
|
2069 |
"draw a sub-string - draw foreground only. |
|
2070 |
If the coordinates are not integers, retry with rounded." |
|
2071 |
||
2072 |
self |
|
2344 | 2073 |
displayString:aString |
2074 |
from:index1 |
|
2075 |
to:index2 |
|
2076 |
x:x |
|
2077 |
y:y |
|
2078 |
in:aDrawableId |
|
2079 |
with:aGCId |
|
2080 |
opaque:false |
|
2323 | 2081 |
! |
2082 |
||
2083 |
displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aDC opaque:opaque |
|
2084 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2085 |
foreground and background characters. |
|
2086 |
If the coordinates are not integers, an error is triggered." |
|
2087 |
||
2088 |
%{ /* NOCONTEXT */ |
|
2089 |
unsigned char *cp; |
|
2090 |
OBJ cls; |
|
2091 |
int i1, i2, l, n; |
|
2092 |
int nInstBytes; |
|
2093 |
||
2094 |
if (__isExternalAddressLike(aDC) |
|
2095 |
&& __isNonNilObject(aString) |
|
2096 |
&& __bothSmallInteger(index1, index2) |
|
2097 |
&& __bothSmallInteger(x, y)) |
|
2098 |
{ |
|
2327 | 2099 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2100 |
int pX, pY; |
|
2101 |
COLORREF fgColor; |
|
2102 |
||
2103 |
pX = __intVal(x); |
|
2104 |
pY = __intVal(y); |
|
2105 |
||
2106 |
if (opaque == true) { |
|
2107 |
SetBkMode(hDC, OPAQUE); |
|
2108 |
} else { |
|
2109 |
SetBkMode(hDC, TRANSPARENT); |
|
2110 |
} |
|
2111 |
fgColor = GetTextColor(hDC); |
|
2112 |
SetTextColor(hDC, fgColor); |
|
2113 |
SetBkColor(hDC, 0xFFFFFFFF); |
|
2114 |
||
2115 |
cls = __qClass(aString); |
|
2116 |
||
2117 |
i1 = __intVal(index1) - 1; |
|
2118 |
if (i1 >= 0) { |
|
2119 |
i2 = __intVal(index2) - 1; |
|
2120 |
if (i2 < i1) { |
|
2121 |
goto ret; |
|
2122 |
} |
|
2123 |
||
2124 |
cp = _stringVal(aString); |
|
2125 |
l = i2 - i1 + 1; |
|
2126 |
||
2127 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2128 |
n = _stringSize(aString); |
|
2129 |
if (i2 < n) { |
|
2130 |
cp += i1; |
|
2131 |
DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC)); |
|
2132 |
||
2133 |
if (l > 32767) { |
|
2134 |
l = 32767; |
|
2135 |
} |
|
2136 |
if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
|
2137 |
DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
|
2138 |
} |
|
2139 |
goto ret; |
|
2140 |
} |
|
2141 |
} |
|
2142 |
||
2143 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2144 |
cp += nInstBytes; |
|
2145 |
n = __byteArraySize(aString) - nInstBytes; |
|
2146 |
||
2147 |
if (__isBytes(aString)) { |
|
2148 |
if (i2 < n) { |
|
2149 |
cp += i1; |
|
2150 |
DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
|
2151 |
if (l > 32767) { |
|
2152 |
l = 32767; |
|
2153 |
} |
|
2154 |
if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
|
2155 |
DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
|
2156 |
} |
|
2157 |
goto ret; |
|
2158 |
} |
|
2159 |
} |
|
2160 |
||
2161 |
/* Unicode */ |
|
2162 |
if (__isWords(aString)) { |
|
2163 |
n = n / 2; |
|
2164 |
if (i2 < n) { |
|
2165 |
WIDECHAR *w_cp = (WIDECHAR *)cp; |
|
2166 |
||
2167 |
w_cp += i1; |
|
2168 |
||
2169 |
if (! TextOutW(hDC, pX, pY, w_cp, l)) { |
|
2170 |
DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError())); |
|
2171 |
} |
|
2172 |
goto ret; |
|
2173 |
} |
|
2174 |
} |
|
2175 |
} |
|
2323 | 2176 |
ret: |
2327 | 2177 |
RETURN ( self ); |
2323 | 2178 |
} |
2179 |
%}. |
|
2180 |
self primitiveFailed |
|
2181 |
||
2182 |
"Created: / 28-07-2006 / 20:35:19 / fm" |
|
2183 |
! |
|
2184 |
||
2185 |
displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aDC opaque:opaque fontAscent:fontAscent |
|
2186 |
"draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both |
|
2187 |
foreground and background characters. |
|
2188 |
If the coordinates are not integers, an error is triggered." |
|
2189 |
||
2190 |
%{ /* NOCONTEXT */ |
|
2191 |
unsigned char *cp; |
|
2192 |
OBJ cls; |
|
2193 |
int i1, i2, l, n; |
|
2194 |
int nInstBytes; |
|
2195 |
||
2196 |
if (__isExternalAddressLike(aDC) |
|
2197 |
&& __isNonNilObject(aString) |
|
2198 |
&& __bothSmallInteger(index1, index2) |
|
2199 |
&& __bothSmallInteger(x, y)) |
|
2200 |
{ |
|
2327 | 2201 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2202 |
int pX, pY; |
|
2203 |
COLORREF fgColor; |
|
2204 |
||
2205 |
pX = __intVal(x); |
|
2206 |
pY = __intVal(y); |
|
2207 |
pY -= __intVal(fontAscent); |
|
2208 |
||
2209 |
if (opaque == true) { |
|
2210 |
SetBkMode(hDC, OPAQUE); |
|
2211 |
} else { |
|
2212 |
SetBkMode(hDC, TRANSPARENT); |
|
2213 |
} |
|
2214 |
fgColor = GetTextColor(hDC); |
|
2215 |
SetTextColor(hDC, fgColor); |
|
2216 |
SetBkColor(hDC, 0xFFFFFFFF); |
|
2217 |
||
2218 |
cls = __qClass(aString); |
|
2219 |
||
2220 |
i1 = __intVal(index1) - 1; |
|
2221 |
if (i1 >= 0) { |
|
2222 |
i2 = __intVal(index2) - 1; |
|
2223 |
if (i2 < i1) { |
|
2224 |
goto ret; |
|
2225 |
} |
|
2226 |
||
2227 |
cp = _stringVal(aString); |
|
2228 |
l = i2 - i1 + 1; |
|
2229 |
||
2230 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
2231 |
n = _stringSize(aString); |
|
2232 |
if (i2 < n) { |
|
2233 |
cp += i1; |
|
2234 |
DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC)); |
|
2235 |
||
2236 |
if (l > 32767) { |
|
2237 |
l = 32767; |
|
2238 |
} |
|
2239 |
if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
|
2240 |
DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
|
2241 |
} |
|
2242 |
goto ret; |
|
2243 |
} |
|
2244 |
} |
|
2245 |
||
2246 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
2247 |
cp += nInstBytes; |
|
2248 |
n = __byteArraySize(aString) - nInstBytes; |
|
2249 |
||
2250 |
if (__isBytes(aString)) { |
|
2251 |
if (i2 < n) { |
|
2252 |
cp += i1; |
|
2253 |
DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY)); |
|
2254 |
if (l > 32767) { |
|
2255 |
l = 32767; |
|
2256 |
} |
|
2257 |
if (! TextOut(hDC, pX, pY, (char *)cp, l)) { |
|
2258 |
DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError())); |
|
2259 |
} |
|
2260 |
goto ret; |
|
2261 |
} |
|
2262 |
} |
|
2263 |
||
2264 |
/* Unicode */ |
|
2265 |
if (__isWords(aString)) { |
|
2266 |
n = n / 2; |
|
2267 |
if (i2 < n) { |
|
2268 |
WIDECHAR *w_cp = (WIDECHAR *)cp; |
|
2269 |
||
2270 |
w_cp += i1; |
|
2271 |
||
2272 |
if (! TextOutW(hDC, pX, pY, w_cp, l)) { |
|
2273 |
DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError())); |
|
2274 |
} |
|
2275 |
goto ret; |
|
2276 |
} |
|
2277 |
} |
|
2278 |
} |
|
2323 | 2279 |
ret: |
2327 | 2280 |
RETURN ( self ); |
2323 | 2281 |
} |
2282 |
%}. |
|
2283 |
self primitiveFailed |
|
2284 |
||
2285 |
"Created: / 28-07-2006 / 20:35:19 / fm" |
|
2286 |
! |
|
2287 |
||
2288 |
displayString:aString x:x y:y in:aDrawableId with:aDC |
|
2289 |
"draw a string - draw foreground only. |
|
2290 |
If the coordinates are not integers, retry with rounded." |
|
2291 |
||
2292 |
self |
|
2344 | 2293 |
displayString:aString |
2294 |
x:x |
|
2295 |
y:y |
|
2296 |
in:aDrawableId |
|
2297 |
with:aDC |
|
2298 |
opaque:false |
|
2323 | 2299 |
! |
2300 |
||
2301 |
displayString:aString x:x y:y in:aDrawableId with:aDC opaque:opaque |
|
2302 |
"draw a string" |
|
2303 |
||
2304 |
self displayString:aString |
|
2344 | 2305 |
from:1 |
2306 |
to:aString size |
|
2307 |
x:x |
|
2308 |
y:y |
|
2309 |
in:aDrawableId |
|
2310 |
with:aDC |
|
2311 |
opaque:opaque |
|
2323 | 2312 |
! |
2313 |
||
2314 |
fillArcX:x y:y width:width height:height from:startAngle angle:angle |
|
2330 | 2315 |
in:ignoredDrawableId with:aDC |
2323 | 2316 |
"fill an arc. If any coordinate is not integer, an error is triggered. |
2317 |
The angles may be floats or integer - they are given in degrees." |
|
2318 |
||
2330 | 2319 |
| hatchSymbol | |
2320 |
||
2321 |
hatchSymbol := self hatch. |
|
2322 |
||
2323 | 2323 |
%{ |
2324 |
int __x, __y, w, h; |
|
2325 |
float angle1, angle2; |
|
2326 |
||
2327 |
if (__isSmallInteger(startAngle)) |
|
2330 | 2328 |
angle1 = (float)(__intVal(startAngle)); |
2323 | 2329 |
else if (__isFloat(startAngle)) { |
2330 | 2330 |
angle1 = __floatVal(startAngle); |
2323 | 2331 |
} else if (__isShortFloat(startAngle)) { |
2330 | 2332 |
angle1 = __shortFloatVal(startAngle); |
2323 | 2333 |
} else goto bad; |
2334 |
||
2335 |
if (__isSmallInteger(angle)) |
|
2330 | 2336 |
angle2 = (float)(__intVal(angle)); |
2323 | 2337 |
else if (__isFloat(angle)) { |
2330 | 2338 |
angle2 = __floatVal(angle); |
2323 | 2339 |
} else if (__isShortFloat(angle)) { |
2330 | 2340 |
angle2 = __shortFloatVal(angle); |
2323 | 2341 |
} else goto bad; |
2342 |
||
2343 |
if (angle2 <= 0) { |
|
2330 | 2344 |
RETURN (self); |
2323 | 2345 |
} |
2346 |
||
2347 |
if (__isExternalAddressLike(aDC) |
|
2348 |
&& __bothSmallInteger(x, y) |
|
2349 |
&& __bothSmallInteger(width, height)) |
|
2350 |
{ |
|
2330 | 2351 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2352 |
HBRUSH hBrush, prevBrush; |
|
2353 |
HPEN prevPen = 0; |
|
2354 |
COLORREF fgColor; |
|
2355 |
int hatch, hasHatch; |
|
2356 |
||
2357 |
w = __intVal(width); |
|
2358 |
h = __intVal(height); |
|
2359 |
__x = __intVal(x); |
|
2360 |
__y = __intVal(y); |
|
2361 |
||
2362 |
fgColor = GetTextColor(hDC); |
|
2363 |
||
2364 |
hasHatch= 1; |
|
2365 |
||
2366 |
if (hatchSymbol == @symbol(none)) { |
|
2367 |
hasHatch= 0; |
|
2368 |
} else if (hatchSymbol == @symbol(horizontal)) { |
|
2369 |
hatch= HS_HORIZONTAL; |
|
2370 |
} else if (hatchSymbol == @symbol(vertical)) { |
|
2371 |
hatch= HS_VERTICAL; |
|
2372 |
} else if (hatchSymbol == @symbol(cross)) { |
|
2373 |
hatch= HS_CROSS; |
|
2374 |
} else if (hatchSymbol == @symbol(bDiagonal)) { |
|
2375 |
hatch= HS_BDIAGONAL; |
|
2376 |
} else if (hatchSymbol == @symbol(fDiagonal)) { |
|
2377 |
hatch= HS_FDIAGONAL; |
|
2378 |
} else if (hatchSymbol == @symbol(diagonalCross)) { |
|
2379 |
hatch= HS_DIAGCROSS; |
|
2380 |
} else |
|
2381 |
hasHatch= 0; |
|
2382 |
||
2383 |
if (hasHatch) { |
|
2384 |
hBrush = CreateHatchBrush(hatch, fgColor); |
|
2385 |
} else { |
|
2386 |
hBrush = CreateSolidBrush(fgColor); |
|
2387 |
} |
|
2388 |
||
2389 |
prevBrush = SelectObject(hDC, hBrush); |
|
2390 |
if (hBrush == 0) { |
|
2391 |
DPRINTF(("fillArc: no brush\n")); |
|
2392 |
} else { |
|
2393 |
HPEN hPen = 0; |
|
2394 |
||
2395 |
if (0 /* __isWinNT */) { |
|
2396 |
fgColor = GetTextColor(hDC); |
|
2397 |
hPen = CreatePen(PS_SOLID, 1, fgColor); |
|
2398 |
prevPen = SelectObject(hDC, hPen); |
|
2399 |
if (hPen == 0) { |
|
2400 |
DPRINTF(("fillArc: no pen\n")); |
|
2401 |
goto failpen; |
|
2402 |
} |
|
2403 |
} else { |
|
2404 |
prevPen = SelectObject(hDC, GetStockObject(NULL_PEN)); |
|
2405 |
w++; |
|
2406 |
h++; |
|
2407 |
} |
|
2408 |
||
2409 |
{ |
|
2410 |
double xB, yB, xE, yE, xR, yR; |
|
2411 |
||
2412 |
xR = w / 2; |
|
2413 |
yR = h / 2; |
|
2414 |
if (angle2 - angle1 >= 360) { |
|
2415 |
xB = xE = __x + xR + 0.5; |
|
2416 |
yB = yE = __y /*+ yR + 0.5*/; |
|
2417 |
} else { |
|
2418 |
double sin(), cos(); |
|
2419 |
float rad1, rad2; |
|
2420 |
||
2421 |
if (angle1 <= 180) |
|
2422 |
angle1 = 180 - angle1; |
|
2423 |
else |
|
2424 |
angle1 = 360 + 180 - angle1; |
|
2425 |
angle2 = angle1 - angle2; |
|
2426 |
/* sigh - compute the intersections ... */ |
|
2427 |
rad1 = (angle1 * 3.14159265359) / 180.0; |
|
2428 |
rad2 = (angle2 * 3.14159265359) / 180.0; |
|
2429 |
xB = cos(rad1) * xR; |
|
2430 |
yB = sin(rad1) * yR; |
|
2431 |
xE = cos(rad2) * xR; |
|
2432 |
yE = sin(rad2) * yR; |
|
2433 |
xB = __x + xR - xB + 0.5; |
|
2434 |
yB = __y + yR - yB + 0.5; |
|
2435 |
xE = __x + xR - xE + 0.5; |
|
2436 |
yE = __y + yR - yE + 0.5; |
|
2437 |
} |
|
2438 |
DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2)); |
|
2439 |
||
2440 |
Pie(hDC, |
|
2441 |
__x, __y, |
|
2442 |
__x + w + 1, __y + h + 1, |
|
2443 |
(int)xB, (int)yB, |
|
2444 |
(int)xE, (int)yE); |
|
2445 |
||
2446 |
if (hPen) { |
|
2447 |
DeleteObject(hPen); |
|
2448 |
} |
|
2449 |
} |
|
2323 | 2450 |
failpen: |
2330 | 2451 |
if (prevPen) SelectObject(hDC, prevPen); |
2452 |
DeleteObject(hPen); |
|
2453 |
||
2454 |
SelectObject(hDC, prevBrush); |
|
2455 |
DeleteObject(hBrush); |
|
2456 |
} |
|
2457 |
RETURN ( self ); |
|
2323 | 2458 |
} |
2459 |
bad: ; |
|
2460 |
%}. |
|
2461 |
self primitiveFailed |
|
2462 |
! |
|
2463 |
||
2464 |
fillPolygon:aPolygon in:ignoredDrawableId with:aGCId |
|
2465 |
"fill a polygon given by its points. |
|
2466 |
If any coordinate is not integer, an error is triggered." |
|
2467 |
||
2468 |
|numberOfPoints| |
|
2469 |
||
2470 |
numberOfPoints := aPolygon size. |
|
2471 |
self |
|
2344 | 2472 |
primFillPolygon:aPolygon n:numberOfPoints |
2473 |
in:ignoredDrawableId with:aGCId |
|
2323 | 2474 |
! |
2475 |
||
2476 |
fillRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC |
|
2477 |
"fill a rectangle. If any coordinate is not integer, an error is triggered." |
|
2478 |
||
2330 | 2479 |
|hatchSymbol| |
2480 |
||
2481 |
hatchSymbol := self hatch. |
|
2482 |
||
2323 | 2483 |
%{ /* NOCONTEXT */ |
2484 |
||
2485 |
int w, h; |
|
2486 |
if (__isExternalAddressLike(aDC) |
|
2487 |
&& __bothSmallInteger(x, y) |
|
2488 |
&& __bothSmallInteger(width, height)) { |
|
2326 | 2489 |
w = __intVal(width); |
2490 |
h = __intVal(height); |
|
2491 |
||
2492 |
if ((w >= 0) && (h >= 0)) { |
|
2493 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
|
2494 |
HBRUSH hBrush, prevBrush; |
|
2495 |
RECT rct; |
|
2496 |
COLORREF fgColor; |
|
2330 | 2497 |
int hatch, hasHatch; |
2326 | 2498 |
|
2499 |
fgColor = GetTextColor(hDC); |
|
2330 | 2500 |
hasHatch= 1; |
2501 |
||
2502 |
if (hatchSymbol == @symbol(none)) { |
|
2503 |
hasHatch= 0; |
|
2504 |
} else if (hatchSymbol == @symbol(horizontal)) { |
|
2505 |
hatch= HS_HORIZONTAL; |
|
2506 |
} else if (hatchSymbol == @symbol(vertical)) { |
|
2507 |
hatch= HS_VERTICAL; |
|
2508 |
} else if (hatchSymbol == @symbol(cross)) { |
|
2509 |
hatch= HS_CROSS; |
|
2510 |
} else if (hatchSymbol == @symbol(bDiagonal)) { |
|
2511 |
hatch= HS_BDIAGONAL; |
|
2512 |
} else if (hatchSymbol == @symbol(fDiagonal)) { |
|
2513 |
hatch= HS_FDIAGONAL; |
|
2514 |
} else if (hatchSymbol == @symbol(diagonalCross)) { |
|
2515 |
hatch= HS_DIAGCROSS; |
|
2516 |
} else |
|
2517 |
hasHatch= 0; |
|
2518 |
||
2519 |
if (hasHatch) { |
|
2520 |
hBrush = CreateHatchBrush(hatch, fgColor); |
|
2521 |
} else { |
|
2522 |
hBrush = CreateSolidBrush(fgColor); |
|
2523 |
} |
|
2524 |
||
2326 | 2525 |
rct.left = __intVal(x); |
2526 |
rct.top = __intVal(y); |
|
2342 | 2527 |
rct.right = rct.left + w; // + 1; |
2528 |
rct.bottom = rct.top + h; // + 1; |
|
2326 | 2529 |
|
2530 |
prevBrush = SelectObject(hDC, hBrush); |
|
2531 |
FillRect(hDC, &rct, hBrush); |
|
2532 |
SelectObject(hDC, prevBrush); |
|
2533 |
DeleteObject(hBrush); |
|
2534 |
||
2535 |
} |
|
2536 |
} |
|
2537 |
RETURN ( self ); |
|
2327 | 2538 |
|
2539 |
||
2323 | 2540 |
%} |
2541 |
! |
|
2542 |
||
2543 |
primFillPolygon:aPolygon n:numberOfPoints in:ignoredDrawableId with:aDC |
|
2544 |
||
2330 | 2545 |
|hatchSymbol| |
2546 |
||
2547 |
hatchSymbol := self hatch. |
|
2548 |
||
2323 | 2549 |
%{ |
2550 |
OBJ point, px, py; |
|
2551 |
int i, num; |
|
2552 |
||
2553 |
if (__isExternalAddressLike(aDC) |
|
2554 |
&& __isSmallInteger(numberOfPoints)) { |
|
2330 | 2555 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
2556 |
POINT p; |
|
2557 |
HBRUSH hBrush, prevBrush; |
|
2558 |
COLORREF fgColor; |
|
2559 |
int hatch, hasHatch; |
|
2560 |
||
2561 |
num = __intVal(numberOfPoints); |
|
2562 |
if (num < 3) { |
|
2563 |
RETURN ( self ); |
|
2564 |
} |
|
2565 |
for (i=0; i<num; i++) { |
|
2566 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2567 |
if (! __isPoint(point)) goto fail; |
|
2568 |
px = _point_X(point); |
|
2569 |
py = _point_Y(point); |
|
2570 |
if (! __bothSmallInteger(px, py)) |
|
2571 |
goto fail; |
|
2572 |
} |
|
2573 |
||
2574 |
fgColor = GetTextColor(hDC); |
|
2575 |
hasHatch= 1; |
|
2576 |
||
2577 |
if (hatchSymbol == @symbol(none)) { |
|
2578 |
hasHatch= 0; |
|
2579 |
} else if (hatchSymbol == @symbol(horizontal)) { |
|
2580 |
hatch= HS_HORIZONTAL; |
|
2581 |
} else if (hatchSymbol == @symbol(vertical)) { |
|
2582 |
hatch= HS_VERTICAL; |
|
2583 |
} else if (hatchSymbol == @symbol(cross)) { |
|
2584 |
hatch= HS_CROSS; |
|
2585 |
} else if (hatchSymbol == @symbol(bDiagonal)) { |
|
2586 |
hatch= HS_BDIAGONAL; |
|
2587 |
} else if (hatchSymbol == @symbol(fDiagonal)) { |
|
2588 |
hatch= HS_FDIAGONAL; |
|
2589 |
} else if (hatchSymbol == @symbol(diagonalCross)) { |
|
2590 |
hatch= HS_DIAGCROSS; |
|
2591 |
} else |
|
2592 |
hasHatch= 0; |
|
2593 |
||
2594 |
if (hasHatch) { |
|
2595 |
hBrush = CreateHatchBrush(hatch, fgColor); |
|
2596 |
} else { |
|
2597 |
hBrush = CreateSolidBrush(fgColor); |
|
2598 |
} |
|
2599 |
||
2600 |
if (hBrush == 0) { |
|
2601 |
DPRINTF(("fillPolygon: no brush\n")); |
|
2602 |
} else { |
|
2603 |
HPEN prevPen; |
|
2604 |
||
2605 |
prevBrush = SelectObject(hDC, hBrush); |
|
2606 |
prevPen = SelectObject(hDC, GetStockObject(NULL_PEN)); |
|
2607 |
||
2608 |
BeginPath(hDC); |
|
2609 |
||
2610 |
for (i=0; i<num; i++) { |
|
2611 |
point = __AT_(aPolygon, __MKSMALLINT(i+1)); |
|
2612 |
px = _point_X(point); |
|
2613 |
py = _point_Y(point); |
|
2614 |
if (i == 0) { |
|
2615 |
MoveToEx(hDC, __intVal(px), __intVal(py), NULL); |
|
2616 |
} else { |
|
2617 |
if (i == (num-1)) { |
|
2618 |
p.x = __intVal(px); |
|
2619 |
p.y = __intVal(py); |
|
2620 |
PolylineTo(hDC, &p, 1); |
|
2621 |
} else { |
|
2622 |
LineTo(hDC, __intVal(px), __intVal(py)); |
|
2623 |
} |
|
2624 |
} |
|
2625 |
} |
|
2626 |
||
2627 |
EndPath(hDC); |
|
2628 |
FillPath(hDC); |
|
2629 |
SelectObject(hDC, prevPen); |
|
2630 |
SelectObject(hDC, prevBrush); |
|
2631 |
DeleteObject(hBrush); |
|
2632 |
} |
|
2633 |
RETURN ( self ); |
|
2323 | 2634 |
|
2635 |
fail: ; |
|
2636 |
} |
|
2637 |
%} |
|
2343 | 2638 |
! |
2639 |
||
2640 |
scaleTest_displayString:aString x:x y:y |
|
2641 |
"draw a string at the coordinate x/y - |
|
2642 |
draw foreground-pixels only (in current paint-color), |
|
2643 |
leaving background as-is. If the transformation involves scaling, |
|
2644 |
the fonts point-size is scaled as appropriate." |
|
2645 |
||
2646 |
|id pX pY fontUsed sz s fontsEncoding| |
|
2647 |
||
2648 |
"hook for non-strings (i.e. attributed text)" |
|
2649 |
(aString isString not |
|
2650 |
or:[aString isText]) ifTrue:[ |
|
2651 |
^ aString displayOn:self x:x y:y |
|
2652 |
]. |
|
2653 |
||
2654 |
gcId isNil ifTrue:[ |
|
2655 |
self initGC |
|
2656 |
]. |
|
2657 |
||
2658 |
fontUsed := font. |
|
2659 |
transformation notNil ifTrue:[ |
|
2660 |
pX := transformation applyToX:x. |
|
2661 |
pY := transformation applyToY:y. |
|
2662 |
transformation noScale ifFalse:[ |
|
2663 |
sz := font size. |
|
2664 |
sz isNil ifTrue:[ |
|
2665 |
"/ oops - not a real font; use original font |
|
2666 |
fontUsed := font |
|
2667 |
] ifFalse:[ |yS| |
|
2668 |
yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch. |
|
2669 |
yS := self scale y / yS. |
|
2670 |
fontUsed := font size:(sz * yS) rounded. |
|
2671 |
] |
|
2672 |
] |
|
2673 |
] ifFalse:[ |
|
2674 |
pX := x. |
|
2675 |
pY := y. |
|
2676 |
]. |
|
2677 |
pX := pX rounded. |
|
2678 |
pY := pY rounded. |
|
2679 |
||
2680 |
s := aString. |
|
2681 |
fontUsed := fontUsed onDevice:device. |
|
2682 |
fontsEncoding := fontUsed encoding. |
|
2683 |
(characterEncoding ~~ fontsEncoding) ifTrue:[ |
|
2684 |
[ |
|
2685 |
s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding. |
|
2686 |
] on:CharacterEncoderError do:[:ex| |
|
2687 |
"substitute a default value for codes that cannot be represented |
|
2688 |
in the new character set" |
|
2689 |
ex proceedWith:ex defaultValue. |
|
2690 |
]. |
|
2691 |
]. |
|
2692 |
||
2693 |
id := fontUsed fontId. |
|
2694 |
id isNil ifTrue:[ |
|
2695 |
"hook for alien fonts" |
|
2696 |
fontUsed displayString:s x:x y:y in:self |
|
2697 |
] ifFalse:[ |
|
2698 |
deviceFont ~~ fontUsed ifTrue:[ |
|
2699 |
device setFont:id in:gcId. |
|
2700 |
deviceFont := fontUsed |
|
2701 |
]. |
|
2702 |
device displayString:s x:pX y:pY in:drawableId with:gcId |
|
2703 |
] |
|
2704 |
||
2705 |
"Modified: 1.7.1997 / 17:08:35 / cg" |
|
2323 | 2706 |
! ! |
2707 |
||
2708 |
!WinPrinterContext methodsFor:'drawing bitmaps'! |
|
2709 |
||
2710 |
bitsBlue |
|
2711 |
"return the number of valid bits in the red component." |
|
2712 |
||
2713 |
"/ bitsRed isNil ifTrue:[ |
|
2714 |
"/ "/ not a truecolor display |
|
2715 |
"/ ^ bitsPerRGB |
|
2716 |
"/ ]. |
|
2717 |
"/ ^ bitsRed |
|
2718 |
||
2719 |
^Display bitsBlue |
|
2720 |
! |
|
2721 |
||
2722 |
bitsGreen |
|
2723 |
"return the number of valid bits in the red component." |
|
2724 |
||
2725 |
"/ bitsRed isNil ifTrue:[ |
|
2726 |
"/ "/ not a truecolor display |
|
2727 |
"/ ^ bitsPerRGB |
|
2728 |
"/ ]. |
|
2729 |
"/ ^ bitsRed |
|
2730 |
||
2731 |
^Display bitsGreen |
|
2732 |
! |
|
2733 |
||
2734 |
bitsRed |
|
2735 |
"return the number of valid bits in the red component." |
|
2736 |
||
2737 |
"/ bitsRed isNil ifTrue:[ |
|
2738 |
"/ "/ not a truecolor display |
|
2739 |
"/ ^ bitsPerRGB |
|
2740 |
"/ ]. |
|
2741 |
"/ ^ bitsRed |
|
2742 |
||
2743 |
^Display bitsRed |
|
2744 |
! |
|
2745 |
||
2338 | 2746 |
compressColorMapImage: image |
2747 |
"calculates a new color map for the image, using only used colors" |
|
2748 |
||
2749 |
|depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
|
2750 |
||
2751 |
oldImage := image. |
|
2752 |
depth := oldImage depth. |
|
2753 |
||
2754 |
oldImage photometric ~~ #palette ifTrue:[ |
|
2755 |
Transcript showCR:'Compress colorMap: Only palette images have colormaps.'. |
|
2756 |
^ image |
|
2757 |
]. |
|
2758 |
||
2759 |
usedColors := oldImage realUsedColors. |
|
2760 |
usedColors size == (1 bitShift:depth) ifTrue:[ |
|
2761 |
Transcript showCR:'Compress colorMap: All colors are used - no compression.'. |
|
2762 |
^ image |
|
2763 |
]. |
|
2764 |
usedColors size == oldImage colorMap size ifTrue:[ |
|
2765 |
Transcript showCR:'Compress colorMap: Colormap already compressed - no compression.'. |
|
2766 |
^ image |
|
2767 |
]. |
|
2768 |
||
2769 |
"/ translation table |
|
2770 |
oldToNew := ByteArray new:(1 bitShift:depth). |
|
2771 |
newColorMap := usedColors asArray. |
|
2772 |
newColorMap sort:self sortBlockForColors. |
|
2773 |
||
2774 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
|
2775 |
|newPixel| |
|
2776 |
||
2777 |
(usedColors includes:clr) ifTrue:[ |
|
2778 |
newPixel := newColorMap indexOf:clr. |
|
2779 |
oldToNew at:oldIdx put:newPixel-1. |
|
2780 |
] |
|
2781 |
]. |
|
2782 |
||
2783 |
oldBits := oldImage bits. |
|
2784 |
newBits := ByteArray new:(oldBits size). |
|
2785 |
depth ~~ 8 ifTrue:[ |
|
2786 |
"/ expand/compress can only handle 8bits |
|
2787 |
tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
|
2788 |
oldBits |
|
2789 |
expandPixels:depth |
|
2790 |
width:oldImage width |
|
2791 |
height:oldImage height |
|
2792 |
into:tmpBits |
|
2793 |
mapping:oldToNew. |
|
2794 |
tmpBits |
|
2795 |
compressPixels:depth |
|
2796 |
width:oldImage width |
|
2797 |
height:oldImage height |
|
2798 |
into:newBits |
|
2799 |
mapping:nil |
|
2800 |
] ifFalse:[ |
|
2801 |
oldBits |
|
2802 |
expandPixels:depth |
|
2803 |
width:oldImage width |
|
2804 |
height:oldImage height |
|
2805 |
into:newBits |
|
2806 |
mapping:oldToNew. |
|
2807 |
]. |
|
2808 |
||
2809 |
newImage := oldImage species new |
|
2810 |
width:oldImage width |
|
2811 |
height:oldImage height |
|
2812 |
depth:depth |
|
2813 |
fromArray:newBits. |
|
2814 |
||
2815 |
newImage colorMap:newColorMap. |
|
2816 |
newImage fileName:oldImage fileName. |
|
2817 |
newImage mask:(oldImage mask copy). |
|
2818 |
||
2819 |
^ newImage |
|
2820 |
||
2821 |
"Created: / 28.7.1998 / 20:03:11 / cg" |
|
2822 |
"Modified: / 15.9.1998 / 17:53:32 / cg" |
|
2823 |
! |
|
2824 |
||
2323 | 2825 |
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId |
2338 | 2826 |
width:w height:h |
2323 | 2827 |
"do a bit-blt; copy bits from the rectangle defined by |
2828 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2829 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2830 |
argument is not integer." |
|
2831 |
||
2832 |
%{ |
|
2833 |
int dstGcOwnerThreadID; |
|
2834 |
HWND dstGcHWIN; |
|
2835 |
HBITMAP dstGcHBITMAP; |
|
2836 |
||
2837 |
if (! __isExternalAddressLike(srcGCId) |
|
2838 |
|| ! __isExternalAddressLike(dstGCId)) { |
|
2338 | 2839 |
goto fail; |
2323 | 2840 |
} |
2841 |
||
2842 |
if (__bothSmallInteger(w, h) |
|
2843 |
&& __bothSmallInteger(srcX, srcY) |
|
2844 |
&& __bothSmallInteger(dstX, dstY)) { |
|
2338 | 2845 |
HANDLE srcDC = (HANDLE)(__externalAddressVal(srcGCId)); |
2846 |
HANDLE dstDC = (HANDLE)(__externalAddressVal(dstGCId)); |
|
2847 |
||
2848 |
int fun, aFunctionSymbol; |
|
2849 |
int src_fg, src_bg, dst_fg, dst_bg; |
|
2850 |
char buf[5]; |
|
2323 | 2851 |
|
2852 |
// fun = dstGcData->bitbltrop2; |
|
2853 |
||
2338 | 2854 |
aFunctionSymbol= __INST(function); |
2855 |
||
2856 |
if (aFunctionSymbol == @symbol(copy)) { |
|
2857 |
fun = SRCCOPY /* R2_COPYPEN */ ; |
|
2323 | 2858 |
/* bfun = BITBLT_COPY; */ |
2338 | 2859 |
} else if (aFunctionSymbol == @symbol(copyInverted)) { |
2860 |
fun = NOTSRCCOPY /* R2_NOTCOPYPEN */; |
|
2323 | 2861 |
/* bfun = BITBLT_COPYINVERTED; */ |
2338 | 2862 |
} else if (aFunctionSymbol == @symbol(xor)) { |
2863 |
fun = SRCINVERT /* R2_XORPEN */; |
|
2323 | 2864 |
/* bfun = BITBLT_XOR; */ |
2338 | 2865 |
} else if (aFunctionSymbol == @symbol(and)) { |
2866 |
fun = SRCAND /* R2_MASKPEN */ ; |
|
2323 | 2867 |
/* bfun = BITBLT_AND; */ |
2338 | 2868 |
} else if (aFunctionSymbol == @symbol(or)) { |
2869 |
fun = MERGECOPY /* R2_MERGEPEN */ ; |
|
2323 | 2870 |
/* bfun = BITBLT_OR; */ |
2338 | 2871 |
} |
2323 | 2872 |
|
2873 |
// convert 123 to string [buf] |
|
2324 | 2874 |
// itoa(fun, buf, 10); |
2875 |
||
2876 |
// console_printf(" ", buf); |
|
2323 | 2877 |
|
2878 |
/* |
|
2879 |
#if 0 |
|
2338 | 2880 |
switch (fun) { |
2881 |
case BITBLT_COPY: |
|
2882 |
console_printf("BITBLT_COPY\n"); |
|
2883 |
break; |
|
2884 |
case BITBLT_COPYINVERTED: |
|
2885 |
console_printf("BITBLT_COPYINVERTED\n"); |
|
2886 |
break; |
|
2887 |
case BITBLT_XOR: |
|
2888 |
console_printf("BITBLT_XOR\n"); |
|
2889 |
break; |
|
2890 |
case BITBLT_AND: |
|
2891 |
console_printf("BITBLT_AND\n"); |
|
2892 |
break; |
|
2893 |
case BITBLT_OR: |
|
2894 |
console_printf("BITBLT_OR\n"); |
|
2895 |
break; |
|
2896 |
} |
|
2323 | 2897 |
#endif |
2898 |
*/ |
|
2899 |
||
2900 |
// fun = dstGcData->bitbltrop2; |
|
2901 |
||
2338 | 2902 |
if (0 /* fun == BITBLT_COPY */) { |
2903 |
src_fg = dst_fg = 0xFFFFFF; |
|
2904 |
src_bg = dst_bg = 0x000000; |
|
2905 |
} else { |
|
2906 |
src_fg = GetTextColor(srcDC) /* srcGcData->fgColor */; |
|
2907 |
src_bg = GetBkColor(dstDC) /* srcGcData->bgColor */; |
|
2908 |
dst_fg = GetTextColor(srcDC) /* dstGcData->fgColor */; |
|
2909 |
dst_bg = GetBkColor(dstDC) /* dstGcData->bgColor */; |
|
2910 |
} |
|
2911 |
||
2912 |
SetBkColor(dstDC, dst_fg); |
|
2913 |
SetTextColor(dstDC, dst_bg); |
|
2914 |
||
2915 |
SetBkColor(srcDC, src_fg); |
|
2916 |
SetTextColor(srcDC, src_bg); |
|
2323 | 2917 |
|
2918 |
/* |
|
2338 | 2919 |
CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC))); |
2920 |
CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC))); |
|
2323 | 2921 |
*/ |
2338 | 2922 |
if (BitBlt(dstDC, |
2923 |
__intVal(dstX), __intVal(dstY), |
|
2924 |
__intVal(w), __intVal(h), |
|
2925 |
srcDC, |
|
2926 |
__intVal(srcX), __intVal(srcY), |
|
2927 |
fun) |
|
2928 |
== 0 |
|
2929 |
) { |
|
2930 |
console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n"); |
|
2931 |
} |
|
2323 | 2932 |
|
2933 |
/* |
|
2338 | 2934 |
if (dstGcData != srcGcData) { |
2935 |
SetBkColor(dstDC, dstGcData->bgColor); |
|
2936 |
SetTextColor(dstDC, dstGcData->fgColor); |
|
2937 |
} |
|
2938 |
SetBkColor(srcDC, srcGcData->bgColor); |
|
2939 |
SetTextColor(srcDC, srcGcData->fgColor); |
|
2323 | 2940 |
*/ |
2941 |
||
2942 |
/* |
|
2338 | 2943 |
if (srcGcData != dstGcData) { |
2944 |
_releaseDC(srcGcData); |
|
2945 |
} |
|
2946 |
_releaseDC(dstGcData); |
|
2323 | 2947 |
*/ |
2338 | 2948 |
RETURN ( self ); |
2323 | 2949 |
} |
2950 |
||
2951 |
fail: ; |
|
2952 |
%}. |
|
2953 |
self primitiveFailed. |
|
2954 |
^ nil |
|
2955 |
! |
|
2956 |
||
2957 |
copyFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
|
2958 |
"do a bit-blt from a pix- or bitmap. |
|
2959 |
Here, fall back into copyFromId:, which should also work. |
|
2960 |
Subclasses may redefine this for more performance or if required" |
|
2961 |
||
2962 |
^ self copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
|
2963 |
! |
|
2964 |
||
2965 |
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcDCId to:destId x:dstX y:dstY gc:dstDCId |
|
2344 | 2966 |
width:w height:h |
2323 | 2967 |
"do a bit-blt, but only copy the low-bit plane; |
2968 |
copy bits from the rectangle defined by |
|
2969 |
srcX/srcY and w/h from the sourceId drawable to the rectangle |
|
2970 |
below dstX/dstY in the destId drawable. Trigger an error if any |
|
2971 |
argument is not integer." |
|
2972 |
||
2973 |
^ self |
|
2344 | 2974 |
copyFromId:sourceId |
2975 |
x:srcX y:srcY gc:srcDCId |
|
2976 |
to:destId x:dstX y:dstY gc:dstDCId |
|
2977 |
width:w height:h |
|
2323 | 2978 |
! |
2979 |
||
2980 |
copyPlaneFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
|
2981 |
"do a bit-blt from a pix- or bitmap, using the low-bit plane of the source only. |
|
2982 |
Here, fall back into copyPlaneFromId:, which should also work. |
|
2983 |
Subclasses may redefine this for more performance or if required" |
|
2984 |
||
2985 |
^ self copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h |
|
2986 |
! |
|
2987 |
||
2988 |
createBitmapFromArray:anArray width:w height:h |
|
2989 |
|bitmapId| |
|
2990 |
||
2325 | 2991 |
|
2323 | 2992 |
bitmapId := self primCreateBitmapFromArray:anArray width:w height:h. |
2993 |
||
2994 |
bitmapId isNil ifTrue:[ |
|
2344 | 2995 |
'WINWORKSTATION: cannot create bitmap' errorPrintCR. |
2323 | 2996 |
]. |
2997 |
^ bitmapId |
|
2998 |
! |
|
2999 |
||
2324 | 3000 |
createPixmapWidth:w height:h depth:d |
3001 |
"allocate a pixmap on the Xserver, the contents is undefined |
|
3002 |
(i.e. random). Return a bitmap id or nil" |
|
3003 |
||
3004 |
%{ |
|
3005 |
HANDLE newBitmapHandle; |
|
3006 |
HANDLE rootDC = CreateDC("DISPLAY", NULL, NULL, NULL); |
|
3007 |
||
3008 |
/*console_printf("CreateBitmap Color\n");*/ |
|
3009 |
if (__bothSmallInteger(w, h) && __isSmallInteger(d) /*&& ISCONNECTED */) { |
|
2344 | 3010 |
if (__intVal(d) == 1) { |
3011 |
newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL); |
|
3012 |
} else { |
|
2324 | 3013 |
#if 0 |
2344 | 3014 |
if (__intVal(d) != __depth) { |
3015 |
console_printf("invalid depth\n"); |
|
3016 |
RETURN (nil); |
|
3017 |
} |
|
2324 | 3018 |
#endif |
2344 | 3019 |
newBitmapHandle = CreateCompatibleBitmap(rootDC, __intVal(w), __intVal(h) ); |
3020 |
} |
|
3021 |
||
3022 |
if (newBitmapHandle) { |
|
3023 |
RETURN ( __MKOBJ(newBitmapHandle)); |
|
3024 |
} |
|
2324 | 3025 |
/* |
2344 | 3026 |
DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle)); |
2324 | 3027 |
*/ |
3028 |
} |
|
3029 |
RETURN (nil); |
|
3030 |
%} |
|
3031 |
! |
|
3032 |
||
2323 | 3033 |
destroyPixmap:aDrawableId |
3034 |
||
3035 |
%{ /* NOCONTEXT */ |
|
3036 |
if (__isExternalAddress(aDrawableId) /* && ISCONNECTED */ ) { |
|
2344 | 3037 |
HANDLE bitmapHandle = _HANDLEVal(aDrawableId); |
3038 |
||
3039 |
if (bitmapHandle) { |
|
3040 |
DeleteObject(bitmapHandle); |
|
3041 |
/* _DeleteObject(bitmapHandle, __LINE__); */ |
|
3042 |
} |
|
2323 | 3043 |
} |
3044 |
%} |
|
3045 |
! |
|
3046 |
||
2329 | 3047 |
displayDeviceForm:aForm x:x y:y |
2338 | 3048 |
|
2343 | 3049 |
|sortedImage formMask bitsWithTransparency redVector greenVector blueVector| |
2338 | 3050 |
|
3051 |
sortedImage := aForm. |
|
2341 | 3052 |
|
2344 | 3053 |
"Image 16 bits" |
3054 |
aForm depth = 16 ifTrue:[ |
|
3055 |
bitsWithTransparency := aForm bits. |
|
2341 | 3056 |
]. |
2344 | 3057 |
"Image 24 and 32 bits" |
3058 |
aForm depth >= 24 ifTrue:[ |
|
3059 |
|bestFormat| |
|
3060 |
bestFormat := aForm bestSupportedImageFormatFor: Display. |
|
3061 |
bitsWithTransparency := aForm rgbImageBitsOn: Display bestFormat: bestFormat. |
|
3062 |
]. |
|
3063 |
"Image up to 8 bits" |
|
2343 | 3064 |
aForm depth <= 8 ifTrue:[ |
3065 |
aForm depth < 8 ifTrue:[ |
|
3066 |
sortedImage := aForm asImageWithDepth: 8. |
|
3067 |
]. |
|
3068 |
"/ sortedImage := self sortColorMapImage: aForm. |
|
3069 |
sortedImage := self compressColorMapImage: sortedImage. |
|
3070 |
||
3071 |
formMask := sortedImage mask. |
|
3072 |
formMask isNil |
|
3073 |
ifTrue:[bitsWithTransparency := sortedImage bits ] |
|
3074 |
ifFalse:[ |
|
3075 |
|bitsWithTransparencySize| |
|
3076 |
formMask := formMask asImageWithDepth: sortedImage depth. |
|
3077 |
bitsWithTransparency := sortedImage bits copy. |
|
3078 |
bitsWithTransparencySize := bitsWithTransparency size. |
|
3079 |
formMask bits doWithIndex:[:maskBit :index | |
|
3080 |
bitsWithTransparencySize >= index ifTrue:[ |
|
3081 |
maskBit == 0 ifTrue:[bitsWithTransparency at: index put: 255 "60" "bitClearAt: index"]. |
|
3082 |
"/ maskBit == 1 ifTrue:[bitsWithTransparency at: index put: (bitsWithTransparency at: index)]. |
|
3083 |
]. |
|
2338 | 3084 |
]. |
2343 | 3085 |
]. |
3086 |
||
3087 |
redVector := sortedImage colorMap redVector. |
|
3088 |
greenVector := sortedImage colorMap greenVector. |
|
3089 |
blueVector := sortedImage colorMap blueVector. |
|
2338 | 3090 |
]. |
3091 |
||
3092 |
self |
|
2343 | 3093 |
drawBits: bitsWithTransparency |
3094 |
redVector: redVector |
|
3095 |
greenVector: greenVector |
|
3096 |
blueVector: blueVector |
|
2338 | 3097 |
bitsPerPixel: sortedImage bitsPerPixel |
3098 |
depth: sortedImage depth |
|
3099 |
width: sortedImage width |
|
3100 |
height: sortedImage height |
|
3101 |
into: self id |
|
3102 |
x: x |
|
3103 |
y: y |
|
3104 |
width: sortedImage width |
|
3105 |
height: sortedImage height |
|
3106 |
with: gcId. |
|
2329 | 3107 |
! |
3108 |
||
2323 | 3109 |
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd |
2342 | 3110 |
width:imageWidth height:imageHeight |
3111 |
x:srcx y:srcy |
|
3112 |
into:ignoredDrawableId |
|
3113 |
x:dstx y:dsty |
|
3114 |
width:w height:h |
|
3115 |
with:aGCId |
|
2323 | 3116 |
|
3117 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3118 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3119 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
3120 |
depth and pixel-units to be different. |
|
3121 |
It has to be checked elsewhere, that the server can do it with the given |
|
3122 |
depth - otherwise, primitive failure will be signalled. |
|
3123 |
Also it is assumed, that the colormap is setup correctly and the |
|
3124 |
colors are allocated - otherwise the colors may be wrong." |
|
3125 |
||
3126 |
" |
|
3127 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
3128 |
an unlimited stack, and thus cannot send primitiveFailed |
|
3129 |
" |
|
3130 |
(self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd |
|
2342 | 3131 |
width:imageWidth height:imageHeight |
3132 |
x:srcx y:srcy |
|
3133 |
into:ignoredDrawableId |
|
3134 |
x:(dstx rounded) y:(dsty rounded) |
|
3135 |
width:w height:h |
|
3136 |
with:aGCId) |
|
2323 | 3137 |
ifFalse:[ |
2342 | 3138 |
" |
3139 |
also happens, if a segmentation violation occurs in the |
|
3140 |
XPutImage ... |
|
3141 |
" |
|
3142 |
self primitiveFailed |
|
2323 | 3143 |
]. |
3144 |
! |
|
3145 |
||
2338 | 3146 |
drawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
3147 |
width:imageWidth height:imageHeight |
|
3148 |
into:ignoredDrawableId |
|
3149 |
x:dstx y:dsty |
|
3150 |
width:w height:h |
|
3151 |
with:aGCId |
|
3152 |
||
3153 |
"draw a bitImage which has depth id, width iw and height ih into |
|
3154 |
the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty. |
|
3155 |
Individual source pixels have bitsPerPixel bits, allowing to draw |
|
3156 |
depth and pixel-units to be different. |
|
3157 |
It has to be checked elsewhere, that the server can do it with the given |
|
3158 |
depth - otherwise, primitive failure will be signalled. |
|
3159 |
Also it is assumed, that the colormap is setup correctly and the |
|
3160 |
colors are allocated - otherwise the colors may be wrong." |
|
3161 |
||
3162 |
" |
|
3163 |
sorry; I had to separate it into 2 methods, since XPutImage needs |
|
3164 |
an unlimited stack, and thus cannot send primitiveFailed |
|
3165 |
" |
|
3166 |
(self primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
|
3167 |
width:imageWidth height:imageHeight |
|
3168 |
into:ignoredDrawableId |
|
2342 | 3169 |
x:(dstx rounded) y:(dsty rounded) |
2338 | 3170 |
width:w height:h |
3171 |
with:aGCId) |
|
3172 |
ifFalse:[ |
|
3173 |
self primitiveFailed |
|
3174 |
]. |
|
3175 |
! |
|
3176 |
||
2324 | 3177 |
primCreateBitmapFromArray:anArray width:w height:h |
3178 |
%{ |
|
3179 |
||
3180 |
HBITMAP newBitmapHandle; |
|
3181 |
int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding; |
|
3182 |
int row, col; |
|
3183 |
unsigned char *cp, *bPits; |
|
3184 |
unsigned char *b_bits = 0; |
|
3185 |
int index; |
|
3186 |
OBJ num; |
|
3187 |
unsigned char *allocatedBits = 0; |
|
3188 |
unsigned char fastBits[10000]; |
|
3189 |
||
3190 |
if (__bothSmallInteger(w, h) |
|
3191 |
&& _isNonNilObject(anArray)) { |
|
2344 | 3192 |
OBJ cls = __qClass(anArray); |
3193 |
||
3194 |
b_width = __intVal(w); |
|
3195 |
b_height = __intVal(h); |
|
3196 |
bytesPerRowST = (b_width + 7) / 8; |
|
3197 |
bytesPerRowWN = ((b_width + 15) / 16) * 2; |
|
3198 |
padding = bytesPerRowWN - bytesPerRowST; |
|
3199 |
||
3200 |
if ((padding == 0) && (cls == @global(ByteArray))) { |
|
3201 |
b_bits = __ByteArrayInstPtr(anArray)->ba_element; |
|
3202 |
cp = 0; |
|
3203 |
} else { |
|
3204 |
int nBytes = b_height * bytesPerRowWN; |
|
3205 |
||
3206 |
if (nBytes < sizeof(fastBits)) { |
|
3207 |
cp = b_bits = fastBits; |
|
3208 |
} else { |
|
3209 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
3210 |
if (! cp) goto fail; |
|
3211 |
} |
|
3212 |
} |
|
3213 |
if (cp) { |
|
3214 |
if (cls == @global(Array)) { |
|
3215 |
OBJ *op; |
|
3216 |
||
3217 |
index = 1; |
|
3218 |
op = &(__ArrayInstPtr(anArray)->a_element[index - 1]); |
|
3219 |
for (row = b_height; row; row--) { |
|
3220 |
for (col = bytesPerRowST; col; col--) { |
|
3221 |
num = *op++; |
|
3222 |
if (! __isSmallInteger(num)) |
|
3223 |
goto fail; |
|
3224 |
*cp++ = __intVal(num); |
|
3225 |
} |
|
3226 |
cp += padding; |
|
3227 |
} |
|
3228 |
} else if (cls == @global(ByteArray)) { |
|
3229 |
unsigned char *pBits; |
|
3230 |
||
3231 |
pBits = __ByteArrayInstPtr(anArray)->ba_element; |
|
3232 |
for (row = b_height; row; row--) { |
|
3233 |
for (col = bytesPerRowST; col; col--) { |
|
3234 |
*cp++ = ( *pBits++ /*^ 0xFF*/ ); |
|
3235 |
} |
|
3236 |
cp += padding; |
|
3237 |
} |
|
3238 |
} else { |
|
3239 |
goto fail; |
|
3240 |
} |
|
3241 |
} |
|
2324 | 3242 |
/* |
2344 | 3243 |
CPRINTF(("create bitmap ...\n")); |
2324 | 3244 |
*/ |
2344 | 3245 |
newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits ); |
3246 |
||
3247 |
if (newBitmapHandle ) { |
|
2324 | 3248 |
/* |
2344 | 3249 |
DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle)); |
2324 | 3250 |
*/ |
2344 | 3251 |
if (allocatedBits) { |
3252 |
free(allocatedBits); |
|
3253 |
} |
|
3254 |
RETURN ( __MKOBJ(newBitmapHandle)); |
|
3255 |
} |
|
2324 | 3256 |
} |
3257 |
fail: ; |
|
3258 |
/* |
|
3259 |
DDPRINTF(("create bitmap FAILED!!!\n")); |
|
3260 |
*/ |
|
3261 |
if (allocatedBits) { |
|
3262 |
/* |
|
2344 | 3263 |
CPRINTF(("freeing up bitmap bits ...\n")); |
2324 | 3264 |
*/ |
2344 | 3265 |
free(allocatedBits); |
2324 | 3266 |
} |
3267 |
/* |
|
3268 |
CPRINTF(("returning nil ...\n")); |
|
3269 |
*/ |
|
3270 |
RETURN ( nil ); |
|
3271 |
%} |
|
3272 |
! |
|
3273 |
||
2323 | 3274 |
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd |
2338 | 3275 |
width:imageWidth height:imageHeight |
3276 |
x:srcx y:srcy |
|
3277 |
into:ignoredDrawableId |
|
3278 |
x:dstx y:dsty |
|
3279 |
width:w height:h |
|
3280 |
with:aGCId |
|
2323 | 3281 |
|
3282 |
"since XPutImage may allocate huge amount of stack space |
|
3283 |
(some implementations use alloca), this must run with unlimited stack." |
|
3284 |
||
3285 |
%{ |
|
3286 |
unsigned char fastBits[10000]; |
|
3287 |
unsigned char *b_bits = 0; |
|
3288 |
unsigned char *allocatedBits = 0; |
|
3289 |
unsigned char *__imageBits = 0; |
|
3290 |
||
3291 |
if (__isByteArray(imageBits)) { |
|
2338 | 3292 |
__imageBits = __ByteArrayInstPtr(imageBits)->ba_element; |
2323 | 3293 |
} else if (__isExternalBytesLike(imageBits)) { |
2338 | 3294 |
__imageBits = (unsigned char *)(__externalBytesAddress(imageBits)); |
2323 | 3295 |
} |
3296 |
||
3297 |
if (/* ISCONNECTED |
|
3298 |
&& */ __isExternalAddressLike(aGCId) |
|
3299 |
&& __bothSmallInteger(srcx, srcy) |
|
3300 |
&& __bothSmallInteger(dstx, dsty) |
|
3301 |
&& __bothSmallInteger(w, h) |
|
3302 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3303 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
3304 |
&& __isSmallInteger(padd) |
|
3305 |
&& __imageBits) |
|
3306 |
{ |
|
2338 | 3307 |
struct |
3308 |
{ |
|
3309 |
BITMAPINFOHEADER bmiHeader; |
|
3310 |
DWORD r; |
|
3311 |
DWORD g; |
|
3312 |
DWORD b; |
|
3313 |
} bitmap; |
|
3314 |
||
3315 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
|
3316 |
HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
|
2323 | 3317 |
|
3318 |
/* |
|
2338 | 3319 |
DDPRINTF(("hDC = %x\n", hDC)); |
2323 | 3320 |
*/ |
2338 | 3321 |
if (__intVal(padd) != WIN32PADDING) { |
3322 |
int row, col; |
|
3323 |
unsigned char *cp; |
|
3324 |
unsigned char *pBits; |
|
3325 |
int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
|
3326 |
int bi = __intVal(bitsPerPixel); |
|
3327 |
||
3328 |
b_width = __intVal(w); |
|
3329 |
b_height = __intVal(h); |
|
3330 |
bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd); |
|
3331 |
bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
|
3332 |
padding = bytesPerRowWN - bytesPerRowST; |
|
3333 |
nBytes = b_height * bytesPerRowWN; |
|
3334 |
/*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
|
3335 |
if (padding) { |
|
3336 |
if (nBytes < sizeof(fastBits)) { |
|
3337 |
cp = b_bits = fastBits; |
|
3338 |
} else { |
|
3339 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
3340 |
} |
|
3341 |
if (cp) { |
|
3342 |
pBits = __imageBits; |
|
3343 |
for (row = b_height; row; row--) { |
|
3344 |
for (col = bytesPerRowST; col; col--) { |
|
3345 |
*cp++ = *pBits++; |
|
3346 |
} |
|
3347 |
cp += padding; |
|
3348 |
} |
|
3349 |
} else |
|
3350 |
goto fail; |
|
3351 |
} |
|
3352 |
} |
|
3353 |
||
3354 |
if (b_bits == 0) { |
|
3355 |
b_bits = __imageBits; |
|
3356 |
} |
|
3357 |
||
3358 |
bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
|
3359 |
bitmap.bmiHeader.biPlanes = 1; |
|
3360 |
if (__intVal(imageDepth) == 24) { |
|
3361 |
/*bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
|
3362 |
bitmap.r = 0xff0000; |
|
3363 |
bitmap.g = 0x00ff00; |
|
3364 |
bitmap.b = 0x0000ff;*/ |
|
3365 |
bitmap.bmiHeader.biCompression = BI_RGB; |
|
3366 |
} else if (__intVal(imageDepth) == 16) { |
|
3367 |
/*bitmap.bmiHeader.biCompression = BI_RGB; |
|
3368 |
bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
|
3369 |
bitmap.b = 0x001f; |
|
3370 |
bitmap.g = 0x07e0; |
|
3371 |
bitmap.r = 0xf800;*/ |
|
3372 |
bitmap.b = 0; |
|
3373 |
bitmap.g = 0; |
|
3374 |
bitmap.r = 0; |
|
3375 |
bitmap.bmiHeader.biCompression = BI_RGB; |
|
3376 |
} |
|
3377 |
bitmap.bmiHeader.biSizeImage = 0; |
|
3378 |
bitmap.bmiHeader.biXPelsPerMeter = 0; |
|
3379 |
bitmap.bmiHeader.biYPelsPerMeter = 0; |
|
3380 |
bitmap.bmiHeader.biClrUsed = 0; |
|
3381 |
bitmap.bmiHeader.biClrImportant = 0; |
|
3382 |
bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
|
3383 |
bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
|
3384 |
bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
|
3385 |
/*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
|
3386 |
||
3387 |
SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
|
3388 |
__intVal(w), __intVal(h), |
|
3389 |
__intVal(srcx), __intVal(srcy), |
|
3390 |
0,__intVal(h), |
|
3391 |
(void *)b_bits, |
|
3392 |
(BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
|
2324 | 3393 |
|
3394 |
/* |
|
2338 | 3395 |
SetDIBits(hDC,hBitmap, |
3396 |
0,__intVal(h), |
|
3397 |
(void *)b_bits, |
|
3398 |
(BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
|
2324 | 3399 |
*/ |
2323 | 3400 |
/* |
2338 | 3401 |
StretchDIBits(hDC, |
3402 |
__intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
|
3403 |
__intVal(w), __intVal(h), // width & height of destination rectangle |
|
3404 |
__intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
|
3405 |
__intVal(w), __intVal(h), // width & height of source rectangle |
|
3406 |
(void *)b_bits, // bitmap bits |
|
3407 |
(BITMAPINFO*)&bitmap, // bitmap data |
|
3408 |
DIB_RGB_COLORS, // usage options |
|
3409 |
SRCCOPY // raster operation code |
|
3410 |
); |
|
2323 | 3411 |
*/ |
2338 | 3412 |
if (allocatedBits) { |
3413 |
free(allocatedBits); |
|
3414 |
} |
|
2323 | 3415 |
/* |
3416 |
#ifndef CACHE_LAST_DC |
|
2338 | 3417 |
_releaseDC(gcData); |
2323 | 3418 |
#endif |
3419 |
*/ |
|
2338 | 3420 |
RETURN ( true ); |
2323 | 3421 |
} |
3422 |
||
3423 |
fail: ; |
|
3424 |
/* |
|
3425 |
PRINTF(("create temp bitmap FAILED!!!\n")); |
|
3426 |
*/ |
|
3427 |
if (allocatedBits) { |
|
3428 |
/* |
|
2338 | 3429 |
PRINTF(("freeing up temp bitmap bits ...\n")); |
2323 | 3430 |
*/ |
2338 | 3431 |
free(allocatedBits); |
2323 | 3432 |
} |
3433 |
/* |
|
3434 |
#ifndef CACHE_LAST_DC |
|
3435 |
if (hDC) { |
|
2338 | 3436 |
_releaseDC(gcData); |
3437 |
} |
|
3438 |
#endif |
|
3439 |
*/ |
|
3440 |
%} |
|
3441 |
. |
|
3442 |
^ false |
|
3443 |
! |
|
3444 |
||
3445 |
primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
|
3446 |
width:imageWidth height:imageHeight |
|
3447 |
into:ignoredDrawableId |
|
3448 |
x:dstx y:dsty |
|
3449 |
width:w height:h |
|
3450 |
with:aGCId |
|
3451 |
||
3452 |
"since XPutImage may allocate huge amount of stack space |
|
3453 |
(some implementations use alloca), this must run with unlimited stack." |
|
3454 |
||
3455 |
%{ |
|
3456 |
unsigned char fastBits[10000]; |
|
3457 |
unsigned char *b_bits = 0; |
|
3458 |
unsigned char *allocatedBits = 0; |
|
3459 |
unsigned char *__imageBits = 0; |
|
3460 |
unsigned char *__redVector = 0; |
|
3461 |
unsigned char *__greenVector = 0; |
|
3462 |
unsigned char *__blueVector = 0; |
|
3463 |
int padd = 8; |
|
3464 |
||
3465 |
if (__isByteArray(imageBits)) { |
|
3466 |
__imageBits = __ByteArrayInstPtr(imageBits)->ba_element; |
|
3467 |
} else if (__isExternalBytesLike(imageBits)) { |
|
3468 |
__imageBits = (unsigned char *)(__externalBytesAddress(imageBits)); |
|
3469 |
} |
|
3470 |
||
3471 |
if (__isByteArray(redVector)) { |
|
3472 |
__redVector = __ByteArrayInstPtr(redVector)->ba_element; |
|
3473 |
} else if (__isExternalBytesLike(redVector)) { |
|
3474 |
__redVector = (unsigned char *)(__externalBytesAddress(redVector)); |
|
3475 |
} |
|
3476 |
||
3477 |
if (__isByteArray(greenVector)) { |
|
3478 |
__greenVector = __ByteArrayInstPtr(greenVector)->ba_element; |
|
3479 |
} else if (__isExternalBytesLike(greenVector)) { |
|
3480 |
__greenVector = (unsigned char *)(__externalBytesAddress(greenVector)); |
|
3481 |
} |
|
3482 |
||
3483 |
if (__isByteArray(blueVector)) { |
|
3484 |
__blueVector = __ByteArrayInstPtr(blueVector)->ba_element; |
|
3485 |
} else if (__isExternalBytesLike(blueVector)) { |
|
3486 |
__blueVector = (unsigned char *)(__externalBytesAddress(blueVector)); |
|
3487 |
} |
|
3488 |
||
3489 |
if (/* ISCONNECTED |
|
3490 |
&& */ __isExternalAddressLike(aGCId) |
|
3491 |
// && __bothSmallInteger(srcx, srcy) |
|
3492 |
&& __bothSmallInteger(dstx, dsty) |
|
3493 |
&& __bothSmallInteger(w, h) |
|
3494 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3495 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
2343 | 3496 |
&& __imageBits) |
2338 | 3497 |
{ |
3498 |
struct |
|
3499 |
{ |
|
3500 |
BITMAPINFOHEADER bmiHeader; |
|
3501 |
RGBQUAD bmiColors[256]; |
|
3502 |
} bitmap; |
|
3503 |
||
3504 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
|
3505 |
HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
|
3506 |
int col; |
|
3507 |
/* |
|
3508 |
DDPRINTF(("hDC = %x\n", hDC)); |
|
3509 |
*/ |
|
3510 |
||
3511 |
if (padd != WIN32PADDING) { |
|
3512 |
||
3513 |
int row, col; |
|
3514 |
unsigned char *cp; |
|
3515 |
unsigned char *pBits; |
|
3516 |
int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
|
3517 |
int bi = __intVal(bitsPerPixel); |
|
3518 |
||
2340
7aada47a2ec0
changed #primDrawBits:redVector:greenVector:blueVector:bitsPerPixel:depth:width:height:into:x:y:width:height:with:
fm
parents:
2339
diff
changeset
|
3519 |
// console_fprintf(stderr, "Non WIN32PADDING"); |
2338 | 3520 |
|
3521 |
b_width = __intVal(w); |
|
3522 |
b_height = __intVal(h); |
|
3523 |
bytesPerRowST = (b_width * bi + (padd - 1 )) / padd; |
|
3524 |
bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
|
3525 |
padding = bytesPerRowWN - bytesPerRowST; |
|
3526 |
nBytes = b_height * bytesPerRowWN; |
|
3527 |
/*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
|
3528 |
if (padding) { |
|
3529 |
if (nBytes < sizeof(fastBits)) { |
|
3530 |
cp = b_bits = fastBits; |
|
3531 |
} else { |
|
3532 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
3533 |
} |
|
3534 |
if (cp) { |
|
3535 |
pBits = __imageBits; |
|
3536 |
for (row = b_height; row; row--) { |
|
3537 |
for (col = bytesPerRowST; col; col--) { |
|
3538 |
*cp++ = *pBits++; |
|
3539 |
} |
|
3540 |
cp += padding; |
|
3541 |
} |
|
3542 |
} else |
|
3543 |
goto fail; |
|
3544 |
} |
|
3545 |
} |
|
3546 |
||
3547 |
if (b_bits == 0) { |
|
3548 |
b_bits = __imageBits; |
|
3549 |
} |
|
3550 |
||
3551 |
bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
|
3552 |
bitmap.bmiHeader.biPlanes = 1; |
|
3553 |
bitmap.bmiHeader.biCompression = BI_RGB; |
|
3554 |
bitmap.bmiHeader.biSizeImage = 0; |
|
3555 |
bitmap.bmiHeader.biXPelsPerMeter = 0; |
|
3556 |
bitmap.bmiHeader.biYPelsPerMeter = 0; |
|
3557 |
bitmap.bmiHeader.biClrUsed = 0; |
|
3558 |
bitmap.bmiHeader.biClrImportant = 0; |
|
3559 |
bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
|
3560 |
bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
|
3561 |
bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
|
3562 |
/*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
|
3563 |
||
2343 | 3564 |
if (__intVal(imageDepth) <= 8) { |
2338 | 3565 |
for(col=0;col<256;col++) |
3566 |
{ |
|
3567 |
bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed |
|
3568 |
bitmap.bmiColors[col].rgbGreen = __greenVector[col]; |
|
3569 |
bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue |
|
3570 |
bitmap.bmiColors[col].rgbReserved = 0; |
|
3571 |
||
3572 |
} |
|
2343 | 3573 |
} |
2338 | 3574 |
|
3575 |
bitmap.bmiColors[255].rgbBlue=255; |
|
3576 |
bitmap.bmiColors[255].rgbGreen=255; |
|
3577 |
bitmap.bmiColors[255].rgbRed =255; |
|
3578 |
||
3579 |
SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
|
3580 |
__intVal(w), __intVal(h), |
|
3581 |
0, 0, /* __intVal(srcx), __intVal(srcy), */ |
|
3582 |
0,__intVal(h), |
|
3583 |
(void *)b_bits, |
|
3584 |
(BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
|
3585 |
/* |
|
3586 |
SetDIBits(hDC,hBitmap, |
|
3587 |
0,__intVal(h), |
|
3588 |
(void *)b_bits, |
|
3589 |
(BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
|
3590 |
*/ |
|
3591 |
/* |
|
3592 |
StretchDIBits(hDC, |
|
3593 |
__intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
|
3594 |
__intVal(w), __intVal(h), // width & height of destination rectangle |
|
3595 |
__intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
|
3596 |
__intVal(w), __intVal(h), // width & height of source rectangle |
|
3597 |
(void *)b_bits, // bitmap bits |
|
3598 |
(BITMAPINFO*)&bitmap, // bitmap data |
|
3599 |
DIB_RGB_COLORS, // usage options |
|
3600 |
SRCCOPY // raster operation code |
|
3601 |
); |
|
3602 |
*/ |
|
3603 |
if (allocatedBits) { |
|
3604 |
free(allocatedBits); |
|
3605 |
} |
|
3606 |
/* |
|
3607 |
#ifndef CACHE_LAST_DC |
|
3608 |
_releaseDC(gcData); |
|
3609 |
#endif |
|
3610 |
*/ |
|
3611 |
RETURN ( true ); |
|
3612 |
} |
|
3613 |
||
3614 |
fail: ; |
|
3615 |
/* |
|
3616 |
PRINTF(("create temp bitmap FAILED!!!\n")); |
|
3617 |
*/ |
|
3618 |
if (allocatedBits) { |
|
3619 |
/* |
|
3620 |
PRINTF(("freeing up temp bitmap bits ...\n")); |
|
3621 |
*/ |
|
3622 |
free(allocatedBits); |
|
3623 |
} |
|
3624 |
/* |
|
3625 |
#ifndef CACHE_LAST_DC |
|
3626 |
if (hDC) { |
|
3627 |
_releaseDC(gcData); |
|
2323 | 3628 |
} |
3629 |
#endif |
|
3630 |
*/ |
|
3631 |
%} |
|
3632 |
. |
|
3633 |
^ false |
|
3634 |
! |
|
3635 |
||
3636 |
setFunction:aFunctionSymbol in:aGCId |
|
3637 |
"set alu function to be drawn with" |
|
3638 |
||
3639 |
Transcript showCR: aFunctionSymbol printString. |
|
3640 |
function := aFunctionSymbol. |
|
3641 |
||
3642 |
"/%{ /* NOCONTEXT */ |
|
3643 |
"/ |
|
3644 |
"/ if (__isExternalAddress(aGCId)) { |
|
3645 |
"/ struct gcData *gcData = _GCDATA(aGCId); |
|
3646 |
"/ int fun = -1; |
|
3647 |
"/ int bfun = -1; |
|
3648 |
"/ |
|
3649 |
"/ if (aFunctionSymbol == @symbol(copy)) { |
|
3650 |
"/ fun = R2_COPYPEN; |
|
3651 |
"/ bfun = BITBLT_COPY; |
|
3652 |
"/ } else if (aFunctionSymbol == @symbol(copyInverted)) { |
|
3653 |
"/ fun = R2_NOTCOPYPEN; |
|
3654 |
"/ bfun = BITBLT_COPYINVERTED; |
|
3655 |
"/ } else if (aFunctionSymbol == @symbol(xor)) { |
|
3656 |
"/ fun = R2_XORPEN; |
|
3657 |
"/ bfun = BITBLT_XOR; |
|
3658 |
"/ } else if (aFunctionSymbol == @symbol(and)) { |
|
3659 |
"/ fun = R2_MASKPEN; |
|
3660 |
"/ bfun = BITBLT_AND; |
|
3661 |
"/ } else if (aFunctionSymbol == @symbol(or)) { |
|
3662 |
"/ fun = R2_MERGEPEN; |
|
3663 |
"/ bfun = BITBLT_OR; |
|
3664 |
"/ } |
|
3665 |
"/ |
|
2325 | 3666 |
"/ if (fun |
2323 | 3667 |
! |
3668 |
||
3669 |
setGraphicsExposures:aBoolean in:aGCId |
|
3670 |
"set or clear the graphics exposures flag" |
|
3671 |
! |
|
3672 |
||
3673 |
shiftBlue |
|
3674 |
"return the number of valid bits in the red component." |
|
3675 |
||
3676 |
"/ bitsRed isNil ifTrue:[ |
|
3677 |
"/ "/ not a truecolor display |
|
3678 |
"/ ^ bitsPerRGB |
|
3679 |
"/ ]. |
|
3680 |
"/ ^ bitsRed |
|
3681 |
||
3682 |
^Display shiftBlue |
|
3683 |
! |
|
3684 |
||
3685 |
shiftGreen |
|
3686 |
"return the number of valid bits in the red component." |
|
3687 |
||
3688 |
"/ bitsRed isNil ifTrue:[ |
|
3689 |
"/ "/ not a truecolor display |
|
3690 |
"/ ^ bitsPerRGB |
|
3691 |
"/ ]. |
|
3692 |
"/ ^ bitsRed |
|
3693 |
||
3694 |
^Display shiftGreen |
|
3695 |
! |
|
3696 |
||
3697 |
shiftRed |
|
3698 |
"return the number of valid bits in the red component." |
|
3699 |
||
3700 |
"/ bitsRed isNil ifTrue:[ |
|
3701 |
"/ "/ not a truecolor display |
|
3702 |
"/ ^ bitsPerRGB |
|
3703 |
"/ ]. |
|
3704 |
"/ ^ bitsRed |
|
3705 |
||
3706 |
^Display shiftRed |
|
2338 | 3707 |
! |
3708 |
||
3709 |
sortBlockForColors |
|
3710 |
||
3711 |
^ [:a :b | |
|
3712 |
a redByte == b redByte ifTrue:[ |
|
3713 |
a greenByte == b greenByte ifTrue:[ |
|
3714 |
a blueByte < b blueByte |
|
3715 |
] ifFalse:[ |
|
3716 |
a greenByte < b greenByte |
|
3717 |
] |
|
3718 |
] ifFalse:[ |
|
3719 |
a redByte < b redByte |
|
3720 |
] |
|
3721 |
]. |
|
3722 |
! |
|
3723 |
||
3724 |
sortColorMapImage: image |
|
3725 |
"calculates a new color map for the image, sorting colors" |
|
3726 |
||
3727 |
|sortBlock depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| |
|
3728 |
||
3729 |
sortBlock := self sortBlockForColors. |
|
3730 |
oldImage := image. |
|
3731 |
depth := oldImage depth. |
|
3732 |
||
3733 |
oldImage photometric ~~ #palette ifTrue:[ |
|
3734 |
Transcript showCR:'Compress colorMap: Only palette images have colormaps.'. |
|
3735 |
^ image |
|
3736 |
]. |
|
3737 |
||
3738 |
usedColors := oldImage realColorMap. |
|
3739 |
||
3740 |
||
3741 |
"/ translation table |
|
3742 |
oldToNew := ByteArray new:(1 bitShift:depth). |
|
3743 |
newColorMap := usedColors asArray. |
|
3744 |
newColorMap sort:sortBlock. |
|
3745 |
||
3746 |
oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr | |
|
3747 |
|newPixel| |
|
3748 |
||
3749 |
(usedColors includes:clr) ifTrue:[ |
|
3750 |
newPixel := newColorMap indexOf:clr. |
|
3751 |
oldToNew at:oldIdx put:newPixel-1. |
|
3752 |
] |
|
3753 |
]. |
|
3754 |
||
3755 |
oldBits := oldImage bits. |
|
3756 |
newBits := ByteArray new:(oldBits size). |
|
3757 |
depth ~~ 8 ifTrue:[ |
|
3758 |
"/ expand/compress can only handle 8bits |
|
3759 |
tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height). |
|
3760 |
oldBits |
|
3761 |
expandPixels:depth |
|
3762 |
width:oldImage width |
|
3763 |
height:oldImage height |
|
3764 |
into:tmpBits |
|
3765 |
mapping:oldToNew. |
|
3766 |
tmpBits |
|
3767 |
compressPixels:depth |
|
3768 |
width:oldImage width |
|
3769 |
height:oldImage height |
|
3770 |
into:newBits |
|
3771 |
mapping:nil |
|
3772 |
] ifFalse:[ |
|
3773 |
oldBits |
|
3774 |
expandPixels:depth |
|
3775 |
width:oldImage width |
|
3776 |
height:oldImage height |
|
3777 |
into:newBits |
|
3778 |
mapping:oldToNew. |
|
3779 |
]. |
|
3780 |
||
3781 |
newImage := oldImage species new |
|
3782 |
width:oldImage width |
|
3783 |
height:oldImage height |
|
3784 |
depth:depth |
|
3785 |
fromArray:newBits. |
|
3786 |
||
3787 |
newImage colorMap:newColorMap. |
|
3788 |
newImage fileName:oldImage fileName. |
|
3789 |
newImage mask:(oldImage mask copy). |
|
3790 |
||
3791 |
^newImage |
|
2343 | 3792 |
! |
3793 |
||
3794 |
transparencyTest_primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth |
|
3795 |
width:imageWidth height:imageHeight |
|
3796 |
into:ignoredDrawableId |
|
3797 |
x:dstx y:dsty |
|
3798 |
width:w height:h |
|
3799 |
with:aGCId |
|
3800 |
||
3801 |
"since XPutImage may allocate huge amount of stack space |
|
3802 |
(some implementations use alloca), this must run with unlimited stack." |
|
3803 |
||
3804 |
%{ |
|
3805 |
unsigned char fastBits[10000]; |
|
3806 |
unsigned char *b_bits = 0; |
|
3807 |
unsigned char *allocatedBits = 0; |
|
3808 |
unsigned char *__imageBits = 0; |
|
3809 |
unsigned char *__redVector = 0; |
|
3810 |
unsigned char *__greenVector = 0; |
|
3811 |
unsigned char *__blueVector = 0; |
|
3812 |
int padd = 8; |
|
3813 |
||
3814 |
if (__isByteArray(imageBits)) { |
|
3815 |
__imageBits = __ByteArrayInstPtr(imageBits)->ba_element; |
|
3816 |
} else if (__isExternalBytesLike(imageBits)) { |
|
3817 |
__imageBits = (unsigned char *)(__externalBytesAddress(imageBits)); |
|
3818 |
} |
|
3819 |
||
3820 |
if (__isByteArray(redVector)) { |
|
3821 |
__redVector = __ByteArrayInstPtr(redVector)->ba_element; |
|
3822 |
} else if (__isExternalBytesLike(redVector)) { |
|
3823 |
__redVector = (unsigned char *)(__externalBytesAddress(redVector)); |
|
3824 |
} |
|
3825 |
||
3826 |
if (__isByteArray(greenVector)) { |
|
3827 |
__greenVector = __ByteArrayInstPtr(greenVector)->ba_element; |
|
3828 |
} else if (__isExternalBytesLike(greenVector)) { |
|
3829 |
__greenVector = (unsigned char *)(__externalBytesAddress(greenVector)); |
|
3830 |
} |
|
3831 |
||
3832 |
if (__isByteArray(blueVector)) { |
|
3833 |
__blueVector = __ByteArrayInstPtr(blueVector)->ba_element; |
|
3834 |
} else if (__isExternalBytesLike(blueVector)) { |
|
3835 |
__blueVector = (unsigned char *)(__externalBytesAddress(blueVector)); |
|
3836 |
} |
|
3837 |
||
3838 |
if (/* ISCONNECTED |
|
3839 |
&& */ __isExternalAddressLike(aGCId) |
|
3840 |
// && __bothSmallInteger(srcx, srcy) |
|
3841 |
&& __bothSmallInteger(dstx, dsty) |
|
3842 |
&& __bothSmallInteger(w, h) |
|
3843 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
3844 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
3845 |
&& __imageBits) |
|
3846 |
{ |
|
3847 |
struct |
|
3848 |
{ |
|
3849 |
BITMAPINFOHEADER bmiHeader; |
|
3850 |
RGBQUAD bmiColors[256]; |
|
3851 |
} bitmap; |
|
3852 |
||
3853 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId)); |
|
3854 |
HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId)); |
|
3855 |
int col; |
|
3856 |
/* |
|
3857 |
DDPRINTF(("hDC = %x\n", hDC)); |
|
3858 |
*/ |
|
3859 |
||
3860 |
if (padd != WIN32PADDING) { |
|
3861 |
||
3862 |
int row, col; |
|
3863 |
unsigned char *cp; |
|
3864 |
unsigned char *pBits; |
|
3865 |
int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
|
3866 |
int bi = __intVal(bitsPerPixel); |
|
3867 |
||
3868 |
// console_fprintf(stderr, "Non WIN32PADDING"); |
|
3869 |
||
3870 |
b_width = __intVal(w); |
|
3871 |
b_height = __intVal(h); |
|
3872 |
bytesPerRowST = (b_width * bi + (padd - 1 )) / padd; |
|
3873 |
bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
|
3874 |
padding = bytesPerRowWN - bytesPerRowST; |
|
3875 |
nBytes = b_height * bytesPerRowWN; |
|
3876 |
/*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
|
3877 |
if (padding) { |
|
3878 |
if (nBytes < sizeof(fastBits)) { |
|
3879 |
cp = b_bits = fastBits; |
|
3880 |
} else { |
|
3881 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
3882 |
} |
|
3883 |
if (cp) { |
|
3884 |
pBits = __imageBits; |
|
3885 |
for (row = b_height; row; row--) { |
|
3886 |
for (col = bytesPerRowST; col; col--) { |
|
3887 |
*cp++ = *pBits++; |
|
3888 |
} |
|
3889 |
cp += padding; |
|
3890 |
} |
|
3891 |
} else |
|
3892 |
goto fail; |
|
3893 |
} |
|
3894 |
} |
|
3895 |
||
3896 |
if (b_bits == 0) { |
|
3897 |
b_bits = __imageBits; |
|
3898 |
} |
|
3899 |
||
3900 |
bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
|
3901 |
bitmap.bmiHeader.biPlanes = 1; |
|
3902 |
bitmap.bmiHeader.biCompression = BI_RGB; |
|
3903 |
bitmap.bmiHeader.biSizeImage = 0; |
|
3904 |
bitmap.bmiHeader.biXPelsPerMeter = 0; |
|
3905 |
bitmap.bmiHeader.biYPelsPerMeter = 0; |
|
3906 |
bitmap.bmiHeader.biClrUsed = 0; |
|
3907 |
bitmap.bmiHeader.biClrImportant = 0; |
|
3908 |
bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
|
3909 |
bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
|
3910 |
bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
|
3911 |
/*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
|
3912 |
||
3913 |
if (__intVal(imageDepth) <= 8) { |
|
3914 |
for(col=0;col<256;col++) |
|
3915 |
{ |
|
3916 |
bitmap.bmiColors[col].rgbBlue = 0; |
|
3917 |
bitmap.bmiColors[col].rgbGreen = 0; |
|
3918 |
bitmap.bmiColors[col].rgbRed = 0; |
|
3919 |
bitmap.bmiColors[col].rgbReserved = 0; |
|
3920 |
||
3921 |
} |
|
3922 |
} |
|
3923 |
||
3924 |
bitmap.bmiColors[255].rgbBlue=255; |
|
3925 |
bitmap.bmiColors[255].rgbGreen=255; |
|
3926 |
bitmap.bmiColors[255].rgbRed =255; |
|
3927 |
bitmap.bmiColors[255].rgbReserved = 0; |
|
3928 |
StretchDIBits(hDC, |
|
3929 |
__intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
|
3930 |
__intVal(w), __intVal(h), // width & height of destination rectangle |
|
3931 |
0, 0, /* __intVal(srcx), __intVal(srcy), */ // x & y coord of source upper-left corner |
|
3932 |
__intVal(w), __intVal(h), // width & height of source rectangle |
|
3933 |
(void *)b_bits, // bitmap bits |
|
3934 |
(BITMAPINFO*)&bitmap, // bitmap data |
|
3935 |
DIB_RGB_COLORS, // usage options |
|
3936 |
SRCAND // raster operation code |
|
3937 |
); |
|
3938 |
/* |
|
3939 |
if (__intVal(imageDepth) <= 8) { |
|
3940 |
for(col=0;col<256;col++) |
|
3941 |
{ |
|
3942 |
bitmap.bmiColors[col].rgbBlue = __blueVector[col]; // Microsoft idea: change rgbBlue to rgbRed |
|
3943 |
bitmap.bmiColors[col].rgbGreen = __greenVector[col]; |
|
3944 |
bitmap.bmiColors[col].rgbRed = __redVector[col]; // Microsoft idea: change rgbRed to rgbBlue |
|
3945 |
bitmap.bmiColors[col].rgbReserved = 0; |
|
3946 |
||
3947 |
} |
|
3948 |
} |
|
3949 |
||
3950 |
bitmap.bmiColors[255].rgbBlue=0; |
|
3951 |
bitmap.bmiColors[255].rgbGreen=0; |
|
3952 |
bitmap.bmiColors[255].rgbRed =0; |
|
3953 |
bitmap.bmiColors[255].rgbReserved = 0; |
|
3954 |
StretchDIBits(hDC, |
|
3955 |
__intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
|
3956 |
__intVal(w), __intVal(h), // width & height of destination rectangle |
|
3957 |
0, 0, // x & y coord of source upper-left corner |
|
3958 |
__intVal(w), __intVal(h), // width & height of source rectangle |
|
3959 |
(void *)b_bits, // bitmap bits |
|
3960 |
(BITMAPINFO*)&bitmap, // bitmap data |
|
3961 |
DIB_RGB_COLORS, // usage options |
|
3962 |
SRCPAINT // raster operation code |
|
3963 |
); |
|
3964 |
*/ |
|
3965 |
/* |
|
3966 |
SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
|
3967 |
__intVal(w), __intVal(h), |
|
3968 |
0, 0, |
|
3969 |
0,__intVal(h), |
|
3970 |
(void *)b_bits, |
|
3971 |
(BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
|
3972 |
*/ |
|
3973 |
/* |
|
3974 |
SetDIBits(hDC,hBitmap, |
|
3975 |
0,__intVal(h), |
|
3976 |
(void *)b_bits, |
|
3977 |
(BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
|
3978 |
*/ |
|
3979 |
/* |
|
3980 |
StretchDIBits(hDC, |
|
3981 |
__intVal(dstx),(__intVal(dsty)), // x & y coord of destination upper-left corner |
|
3982 |
__intVal(w), __intVal(h), // width & height of destination rectangle |
|
3983 |
__intVal(srcx), __intVal(srcy), // x & y coord of source upper-left corner |
|
3984 |
__intVal(w), __intVal(h), // width & height of source rectangle |
|
3985 |
(void *)b_bits, // bitmap bits |
|
3986 |
(BITMAPINFO*)&bitmap, // bitmap data |
|
3987 |
DIB_RGB_COLORS, // usage options |
|
3988 |
SRCCOPY // raster operation code |
|
3989 |
); |
|
3990 |
*/ |
|
3991 |
if (allocatedBits) { |
|
3992 |
free(allocatedBits); |
|
3993 |
} |
|
3994 |
/* |
|
3995 |
#ifndef CACHE_LAST_DC |
|
3996 |
_releaseDC(gcData); |
|
3997 |
#endif |
|
3998 |
*/ |
|
3999 |
RETURN ( true ); |
|
4000 |
} |
|
4001 |
||
4002 |
fail: ; |
|
4003 |
/* |
|
4004 |
PRINTF(("create temp bitmap FAILED!!!\n")); |
|
4005 |
*/ |
|
4006 |
if (allocatedBits) { |
|
4007 |
/* |
|
4008 |
PRINTF(("freeing up temp bitmap bits ...\n")); |
|
4009 |
*/ |
|
4010 |
free(allocatedBits); |
|
4011 |
} |
|
4012 |
/* |
|
4013 |
#ifndef CACHE_LAST_DC |
|
4014 |
if (hDC) { |
|
4015 |
_releaseDC(gcData); |
|
4016 |
} |
|
4017 |
#endif |
|
4018 |
*/ |
|
4019 |
%} |
|
4020 |
. |
|
4021 |
^ false |
|
2323 | 4022 |
! ! |
4023 |
||
4024 |
!WinPrinterContext methodsFor:'font stuff'! |
|
4025 |
||
4026 |
createFontFor:aFontName |
|
4027 |
"a basic method for font allocation; this method allows |
|
4028 |
any font to be aquired (even those not conforming to |
|
4029 |
standard naming conventions, such as cursor, fixed or k14)" |
|
4030 |
||
4031 |
%{ |
|
4032 |
HGDIOBJ hFont; |
|
4033 |
char *fn; |
|
4034 |
||
4035 |
if (__isString(aFontName) || __isSymbol(aFontName)) { |
|
2344 | 4036 |
fn = __stringVal(aFontName); |
4037 |
if ((strcmp(fn, "fixed") == 0) || (strcmp(fn, "ANSI_FIXED_FONT") == 0)) { |
|
4038 |
hFont = GetStockObject(ANSI_FIXED_FONT); |
|
4039 |
} else if ((strcmp(fn, "variable") == 0) || (strcmp(fn, "ANSI_VAR_FONT") == 0)) { |
|
4040 |
hFont = GetStockObject(ANSI_VAR_FONT); |
|
4041 |
} else if ((strcmp(fn, "system") == 0) || (strcmp(fn, "SYSTEM_FONT") == 0)) { |
|
4042 |
hFont = GetStockObject(SYSTEM_FONT); |
|
4043 |
} else if ((strcmp(fn, "systemFixed") == 0) || (strcmp(fn, "SYSTEM_FIXED_FONT") == 0)) { |
|
4044 |
hFont = GetStockObject(SYSTEM_FIXED_FONT); |
|
4045 |
} else if ((strcmp(fn, "deviceDefault") == 0) || (strcmp(fn, "DEVICE_DEFAULT_FONT") == 0)) { |
|
4046 |
hFont = GetStockObject(DEVICE_DEFAULT_FONT); |
|
4047 |
} else { |
|
4048 |
hFont = GetStockObject(ANSI_FIXED_FONT); |
|
4049 |
} |
|
4050 |
if (hFont) { |
|
4051 |
DPRINTF(("createFontFor:%s -> %x\n", fn, hFont)); |
|
4052 |
RETURN ( __MKOBJ(hFont) ); |
|
4053 |
} |
|
2323 | 4054 |
} |
4055 |
%}. |
|
4056 |
^ nil |
|
4057 |
! |
|
4058 |
||
4059 |
fontMetricsOf:fontId |
|
4060 |
"return a fonts metrics info object" |
|
4061 |
||
4062 |
|rawData info| |
|
4063 |
||
4064 |
rawData := Array new:15. |
|
4065 |
(self primFontMetricsOf:fontId hdc:gcId intoArray:rawData) isNil ifTrue:[ |
|
2344 | 4066 |
self primitiveFailed. |
4067 |
^ self |
|
2323 | 4068 |
]. |
4069 |
||
4070 |
rawData at:11 put:#'ms-ansi'. |
|
4071 |
||
4072 |
info := DeviceWorkstation::DeviceFontMetrics new. |
|
4073 |
info |
|
4074 |
ascent:(rawData at:1) |
|
4075 |
descent:(rawData at:2) |
|
4076 |
maxAscent:(rawData at:3) |
|
4077 |
maxDescent:(rawData at:4) |
|
4078 |
minWidth:(rawData at:5) |
|
4079 |
maxWidth:(rawData at:6) |
|
4080 |
avgWidth:(rawData at:7) |
|
4081 |
minCode:(rawData at:8) |
|
4082 |
maxCode:16rFFFF "(rawData at:9)" |
|
4083 |
direction:nil |
|
4084 |
encoding:(rawData at:11). |
|
4085 |
||
4086 |
||
4087 |
^ info |
|
4088 |
! |
|
4089 |
||
4090 |
getDefaultFont |
|
4091 |
"return a default font id - used when class Font cannot |
|
4092 |
find anything usable" |
|
4093 |
||
4094 |
^ self createFontFor:'fixed' |
|
4095 |
! |
|
4096 |
||
4097 |
getFontWithFamily:familyString face:faceString |
|
2344 | 4098 |
style:styleArgString size:sizeArg encoding:encodingSym |
2323 | 4099 |
|
4100 |
"try to get the specified font, if not available, try the next smaller |
|
4101 |
font." |
|
4102 |
||
4103 |
|styleString theName theId xlatedStyle id spacing| |
|
4104 |
||
4105 |
styleString := styleArgString. |
|
4106 |
||
4107 |
"special: if face is nil, allow access to X-fonts" |
|
4108 |
faceString isNil ifTrue:[ |
|
2344 | 4109 |
sizeArg notNil ifTrue:[ |
4110 |
theName := familyString , '-' , sizeArg printString |
|
4111 |
] ifFalse:[ |
|
4112 |
theName := familyString |
|
4113 |
]. |
|
4114 |
theName isNil ifTrue:[ |
|
4115 |
" |
|
4116 |
mhmh - fall back to the default font |
|
4117 |
" |
|
4118 |
theName := 'fixed' |
|
4119 |
]. |
|
4120 |
theId := self createFontFor:theName. |
|
4121 |
theId isNil ifTrue:[ |
|
4122 |
theId := self getDefaultFont |
|
4123 |
]. |
|
4124 |
^ theId |
|
2323 | 4125 |
]. |
4126 |
||
4127 |
"/ spacing other than 'normal' is contained as last component |
|
4128 |
"/ in style |
|
4129 |
styleString notNil ifTrue:[ |
|
2344 | 4130 |
((styleString endsWith:'-narrow') |
4131 |
or:[styleString endsWith:'-semicondensed']) ifTrue:[ |
|
4132 |
|i| |
|
4133 |
i := styleString lastIndexOf:$-. |
|
4134 |
spacing := styleString copyFrom:(i+1). |
|
4135 |
styleString := styleString copyTo:(i-1). |
|
4136 |
] ifFalse:[ |
|
4137 |
spacing := 'normal'. |
|
4138 |
]. |
|
2323 | 4139 |
]. |
4140 |
||
4141 |
xlatedStyle := styleString. |
|
4142 |
xlatedStyle notNil ifTrue:[ |
|
2344 | 4143 |
xlatedStyle := xlatedStyle first asString |
2323 | 4144 |
]. |
4145 |
||
4146 |
id := self |
|
2344 | 4147 |
getFontWithFoundry:'*' |
4148 |
family:familyString asLowercase |
|
4149 |
weight:faceString |
|
4150 |
slant:styleString "/ xlatedStyle |
|
4151 |
spacing:spacing |
|
4152 |
pixelSize:nil |
|
4153 |
size:sizeArg |
|
4154 |
registry:'*' |
|
4155 |
encoding:encodingSym. |
|
2323 | 4156 |
|
4157 |
id isNil ifTrue:[ |
|
2344 | 4158 |
(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[ |
4159 |
"/ too stupid: encodings come in both cases |
|
4160 |
"/ |
|
4161 |
id := self |
|
4162 |
getFontWithFoundry:'*' |
|
4163 |
family:familyString asLowercase |
|
4164 |
weight:faceString |
|
4165 |
slant:styleString "/ xlatedStyle |
|
4166 |
spacing:spacing |
|
4167 |
pixelSize:nil |
|
4168 |
size:sizeArg |
|
4169 |
registry:'*' |
|
4170 |
encoding:encodingSym asUppercase. |
|
4171 |
id isNil ifTrue:[ |
|
4172 |
id := self |
|
4173 |
getFontWithFoundry:'*' |
|
4174 |
family:familyString asLowercase |
|
4175 |
weight:faceString |
|
4176 |
slant:styleString "/ xlatedStyle |
|
4177 |
spacing:spacing |
|
4178 |
pixelSize:nil |
|
4179 |
size:sizeArg |
|
4180 |
registry:'*' |
|
4181 |
encoding:encodingSym asLowercase. |
|
4182 |
||
4183 |
id isNil ifTrue:[ |
|
4184 |
id := self |
|
4185 |
getFontWithFoundry:'*' |
|
4186 |
family:familyString asLowercase |
|
4187 |
weight:faceString asLowercase |
|
4188 |
slant:styleString asLowercase |
|
4189 |
spacing:spacing |
|
4190 |
pixelSize:nil |
|
4191 |
size:sizeArg |
|
4192 |
registry:'*' |
|
4193 |
encoding:encodingSym asLowercase. |
|
4194 |
] |
|
4195 |
] |
|
4196 |
] |
|
2323 | 4197 |
]. |
4198 |
^ id |
|
4199 |
||
4200 |
"Modified: 24.2.1996 / 22:37:24 / cg" |
|
4201 |
"Modified: 4.7.1996 / 11:38:47 / stefan" |
|
4202 |
! |
|
4203 |
||
4204 |
getFontWithFoundry:foundry family:family weight:weight |
|
2344 | 4205 |
slant:slant spacing:spc pixelSize:pixelSize size:pointSize |
4206 |
registry:registry encoding:encoding |
|
2323 | 4207 |
|
4208 |
"get the specified font, if not available, return nil. |
|
4209 |
For now, this is a poor (incomplete) emulation of the X code ... |
|
4210 |
Individual attributes can be left empty (i.e. '') or nil to match any. |
|
4211 |
||
4212 |
foundry: 'adobe', 'misc', 'dec', 'schumacher' ... usually '*' |
|
4213 |
family: 'helvetica' 'courier' 'times' ... |
|
4214 |
weight: 'bold' 'medium' 'demi' ... |
|
4215 |
slant: 'r(oman)' 'i(talic)' 'o(blique)' |
|
4216 |
spacing: 'narrow' 'normal' semicondensed' ... usually '*' |
|
4217 |
pixelSize: 16,18 ... usually left empty |
|
4218 |
size: size in point (1/72th of an inch) |
|
4219 |
registry: iso8859, sgi ... '*' |
|
4220 |
encoding: vendor specific encoding (usually '*') |
|
4221 |
" |
|
4222 |
||
4223 |
" |
|
4224 |
Windows-NT/95 allows the creation of a font with the following parameters |
|
4225 |
||
2344 | 4226 |
nHeight |
4227 |
nWidth |
|
4228 |
nEscapement |
|
4229 |
nOrientation |
|
4230 |
fnWeight FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ... |
|
4231 |
fdwItalic TRUE or FALSE |
|
4232 |
fdwUnderline TRUE or FALSE |
|
4233 |
fdwStrikeOut TRUE or FALSE |
|
4234 |
fdwCharSet ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,... |
|
4235 |
fdwOutputPrecision DEFAULT, STRING, CHAR, ... |
|
4236 |
fdwClipPrecision DEFAULT, CHAR, STROKE, MASK, ... |
|
4237 |
fdwQuality DEFAULT, DRAFT, or PROOF. |
|
4238 |
fdwPitchAndFamily |
|
4239 |
DEFAULT, FIXED or VARIABLE pitch |
|
4240 |
DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS. |
|
4241 |
lpszFace |
|
4242 |
Typeface Name |
|
2323 | 4243 |
|
4244 |
These two above descriptions will be matched as follows: |
|
4245 |
||
2344 | 4246 |
foundry - ignored |
4247 |
family - mapped to type face name. |
|
4248 |
weight - mapped to fnWeight |
|
4249 |
slant - used for style |
|
4250 |
spacing - NOT USED INITIALLY |
|
4251 |
pixelSize - NOT USED INITIALLY |
|
4252 |
size - mapped to nHeight |
|
4253 |
registry - NOT USED INITIALLY |
|
4254 |
encoding - mapped to fdwCharSet |
|
2323 | 4255 |
" |
4256 |
||
4257 |
|logSize| |
|
4258 |
||
4259 |
pixelSize notNil ifTrue:[ |
|
2344 | 4260 |
logSize := pixelSize |
2323 | 4261 |
] ifFalse:[ |
2344 | 4262 |
logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded. |
2323 | 4263 |
]. |
4264 |
%{ |
|
4265 |
HGDIOBJ hFont; |
|
4266 |
int pointSize, nHeight, nWidth, nEscapement, nOrientation; |
|
4267 |
char* work; |
|
4268 |
char* work2; |
|
4269 |
DWORD fnWeight; |
|
4270 |
DWORD fdwItalic; |
|
4271 |
DWORD fdwUnderline; |
|
4272 |
DWORD fdwStrikeOut; |
|
4273 |
DWORD fdwCharSet; |
|
4274 |
DWORD fdwOutputPrecision; |
|
4275 |
DWORD fdwClipPrecision; |
|
4276 |
DWORD fdwQuality; |
|
4277 |
DWORD fdwPitchAndFamily; |
|
4278 |
static char faceName[256]; |
|
4279 |
||
4280 |
/* INITIALIZE */ |
|
4281 |
strcpy( faceName, "NULL" ); |
|
4282 |
nHeight = 0; |
|
4283 |
nWidth = 0; |
|
4284 |
nEscapement = 0; |
|
4285 |
nOrientation = 0; |
|
4286 |
fnWeight = FW_NORMAL; |
|
4287 |
fdwItalic = FALSE; |
|
4288 |
fdwUnderline = FALSE; |
|
4289 |
fdwStrikeOut = FALSE; |
|
4290 |
fdwOutputPrecision = OUT_DEFAULT_PRECIS; |
|
4291 |
fdwClipPrecision = CLIP_DEFAULT_PRECIS; |
|
4292 |
fdwQuality = DEFAULT_QUALITY; |
|
4293 |
fdwPitchAndFamily = FF_DONTCARE; |
|
4294 |
||
4295 |
fdwCharSet = ANSI_CHARSET; |
|
4296 |
if ((encoding == @symbol('ms-ansi'))) { |
|
2344 | 4297 |
fdwCharSet = ANSI_CHARSET; |
2323 | 4298 |
} else if (encoding == @symbol('ms-default')) { |
2344 | 4299 |
fdwCharSet = DEFAULT_CHARSET; |
2323 | 4300 |
} else if ((encoding == @symbol('ms-symbol')) |
2344 | 4301 |
|| (encoding == @symbol('misc-fontspecific'))) { |
4302 |
fdwCharSet = SYMBOL_CHARSET; |
|
2323 | 4303 |
} else if ((encoding == @symbol('ms-shiftjis')) |
2344 | 4304 |
|| (encoding == @symbol('jisx0208.1983-0'))){ |
4305 |
fdwCharSet = SHIFTJIS_CHARSET; |
|
2323 | 4306 |
} else if ((encoding == @symbol('ms-gb2312')) |
2344 | 4307 |
|| (encoding == @symbol('gb2312.1980-0'))) { |
4308 |
fdwCharSet = GB2312_CHARSET; |
|
2323 | 4309 |
} else if ((encoding == @symbol('ms-hangeul')) |
2344 | 4310 |
|| (encoding == @symbol('ksc5601.1987-0'))) { |
4311 |
fdwCharSet = HANGEUL_CHARSET; |
|
2323 | 4312 |
} else if ((encoding == @symbol('ms-chinesebig5')) |
2344 | 4313 |
|| (encoding == @symbol('big5'))) { |
4314 |
fdwCharSet = CHINESEBIG5_CHARSET; |
|
2323 | 4315 |
} else if (encoding == @symbol('ms-oem')) { |
2344 | 4316 |
fdwCharSet = OEM_CHARSET; |
2323 | 4317 |
} else if (encoding == @symbol('ms-johab')) { |
2344 | 4318 |
fdwCharSet = JOHAB_CHARSET; |
2323 | 4319 |
} else if ((encoding == @symbol('ms-hebrew')) |
2344 | 4320 |
|| (encoding == @symbol('ms-cp1255'))) { |
4321 |
fdwCharSet = HEBREW_CHARSET; |
|
2323 | 4322 |
} else if ((encoding == @symbol('ms-arabic')) |
2344 | 4323 |
|| (encoding == @symbol('ms-cp1256'))) { |
4324 |
fdwCharSet = ARABIC_CHARSET; |
|
2323 | 4325 |
} else if ((encoding == @symbol('ms-greek')) |
2344 | 4326 |
|| (encoding == @symbol('ms-cp1253'))) { |
4327 |
fdwCharSet = GREEK_CHARSET; |
|
2323 | 4328 |
} else if ((encoding == @symbol('ms-turkish')) |
2344 | 4329 |
|| (encoding == @symbol('ms-cp1254'))) { |
4330 |
fdwCharSet = TURKISH_CHARSET; |
|
2323 | 4331 |
} else if ((encoding == @symbol('ms-russian')) |
2344 | 4332 |
|| (encoding == @symbol('ms-cp1251'))) { |
4333 |
fdwCharSet = RUSSIAN_CHARSET; |
|
2323 | 4334 |
} else if ((encoding == @symbol('ms-easteurope')) |
2344 | 4335 |
|| (encoding == @symbol('ms-cp1250'))) { |
4336 |
fdwCharSet = EASTEUROPE_CHARSET; |
|
2323 | 4337 |
} else if ((encoding == @symbol('ms-baltic')) |
2344 | 4338 |
|| (encoding == @symbol('ms-cp1257'))) { |
4339 |
fdwCharSet = BALTIC_CHARSET; |
|
2323 | 4340 |
} else if ((encoding == @symbol('ms-vietnamese'))) { |
2344 | 4341 |
fdwCharSet = VIETNAMESE_CHARSET; |
2323 | 4342 |
} else if ((encoding == @symbol('ms-thai'))) { |
2344 | 4343 |
fdwCharSet = THAI_CHARSET; |
2323 | 4344 |
} else if ((encoding == @symbol('ms-mac'))) { |
2344 | 4345 |
fdwCharSet = MAC_CHARSET; |
2323 | 4346 |
#ifdef UNICODE_CHARSET |
4347 |
} else if ((encoding == @symbol('ms-unicode'))) { |
|
2344 | 4348 |
fdwCharSet = UNICODE_CHARSET; |
2323 | 4349 |
#endif |
4350 |
} |
|
4351 |
||
4352 |
if ( __isString( family ) ) { |
|
2344 | 4353 |
work = __stringVal( family ); |
4354 |
if (strcmp( work, "nil" ) != 0 ) { |
|
4355 |
strncpy( faceName, work, sizeof(faceName)-1 ); |
|
4356 |
} |
|
2323 | 4357 |
} |
4358 |
||
4359 |
/* Q: should we allow those ? (they make ST/X programs less portable to X */ |
|
4360 |
if( __isString( weight ) ) { |
|
2344 | 4361 |
work = __stringVal( weight ); |
4362 |
if (strcmp( work, "bold" ) == 0 ) { |
|
4363 |
fnWeight = FW_BOLD; |
|
4364 |
} else if (strcmp( work, "medium" ) == 0 ) { |
|
4365 |
fnWeight = FW_MEDIUM; |
|
4366 |
} else if (strcmp( work, "normal" ) == 0 ) { |
|
4367 |
fnWeight = FW_NORMAL; |
|
4368 |
} else if (strcmp( work, "light" ) == 0 ) { |
|
4369 |
fnWeight = FW_LIGHT; |
|
4370 |
} else if (strcmp( work, "demi" ) == 0 ) { |
|
4371 |
fnWeight = FW_LIGHT; |
|
4372 |
} else if (strcmp( work, "heavy" ) == 0 ) { |
|
4373 |
fnWeight = FW_HEAVY; |
|
4374 |
} else if (strcmp( work, "extraBold" ) == 0 ) { |
|
4375 |
fnWeight = FW_EXTRABOLD; |
|
4376 |
} else if (strcmp( work, "semiBold" ) == 0 ) { |
|
4377 |
fnWeight = FW_SEMIBOLD; |
|
4378 |
} else if (strcmp( work, "thin" ) == 0 ) { |
|
4379 |
fnWeight = FW_THIN; |
|
4380 |
} else if (strcmp( work, "extraLight" ) == 0 ) { |
|
4381 |
fnWeight = FW_EXTRALIGHT; |
|
4382 |
} |
|
2323 | 4383 |
} else if (__isSmallInteger(weight)) { |
2344 | 4384 |
fnWeight = __intVal(weight); |
2323 | 4385 |
} |
4386 |
||
4387 |
if(__isSmallInteger( logSize )) { |
|
2344 | 4388 |
nHeight = __intVal( logSize ); |
2323 | 4389 |
} |
4390 |
||
4391 |
if (__isString(slant)) { |
|
2344 | 4392 |
work2 = __stringVal( slant ); |
4393 |
work = __stringVal( slant ); |
|
4394 |
||
4395 |
if (strncmp(work2, "italic", 6) == 0) { |
|
4396 |
fdwItalic = TRUE; |
|
4397 |
if ( work2[6] == '-' ) |
|
4398 |
strncpy( work, &work2[7], ( strlen( work2) - 7) ); |
|
4399 |
} else { |
|
4400 |
if (strncmp(work2, "oblique", 7) == 0) { |
|
4401 |
fdwItalic = TRUE; |
|
4402 |
if ( work2[7] == '-' ) |
|
4403 |
strncpy( work, &work2[8], ( strlen( work2) - 8) ); |
|
4404 |
} |
|
4405 |
} |
|
4406 |
if (strncmp( work, "underline", 9 ) == 0 ) { |
|
4407 |
fdwUnderline = TRUE; |
|
4408 |
if( work[10] == '-' ) |
|
4409 |
strncpy( work2, &work[11], ( strlen( work ) - 10 ) ); |
|
4410 |
} |
|
4411 |
if (strncmp( work2, "strikeOut", 9 ) == 0 ) { |
|
4412 |
fdwStrikeOut = TRUE; |
|
4413 |
} |
|
2323 | 4414 |
} |
4415 |
||
4416 |
DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n", |
|
2344 | 4417 |
faceName, nHeight, nWidth, fnWeight)); |
2323 | 4418 |
|
4419 |
hFont = CreateFont( -nHeight, /* character height - not cell height */ |
|
2344 | 4420 |
nWidth, |
4421 |
nEscapement, |
|
4422 |
nOrientation, |
|
4423 |
fnWeight, |
|
4424 |
fdwItalic, |
|
4425 |
fdwUnderline, |
|
4426 |
fdwStrikeOut, |
|
4427 |
fdwCharSet, |
|
4428 |
fdwOutputPrecision, |
|
4429 |
fdwClipPrecision, |
|
4430 |
fdwQuality, |
|
4431 |
fdwPitchAndFamily, |
|
4432 |
faceName ); |
|
2323 | 4433 |
|
4434 |
if (hFont != NULL) { |
|
2344 | 4435 |
DPRINTF(("createFont: %x\n", hFont)); |
2323 | 4436 |
/* |
4437 |
#ifdef COUNT_RESOURCES |
|
2344 | 4438 |
__cnt_font++; |
4439 |
RES1PRINTF(("CreateFont %d\n", __cnt_font)); |
|
2323 | 4440 |
#endif |
4441 |
*/ |
|
2344 | 4442 |
RETURN ( __MKOBJ(hFont) ); |
2323 | 4443 |
} |
4444 |
||
4445 |
DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" )); |
|
4446 |
%}. |
|
4447 |
^ nil |
|
4448 |
||
4449 |
" |
|
4450 |
Display getFontWithFoundry:'*' |
|
2344 | 4451 |
family:'courier' |
4452 |
weight:'medium' |
|
4453 |
slant:'r' |
|
4454 |
spacing:nil |
|
4455 |
pixelSize:nil |
|
4456 |
size:13 |
|
4457 |
registry:'iso8859' |
|
4458 |
encoding:'*' |
|
2323 | 4459 |
" |
4460 |
||
4461 |
"new NT Version: 20.2.1997 / 22:33:29 / dq" |
|
4462 |
! |
|
4463 |
||
4464 |
primFontMetricsOf:fontId hdc:aDC intoArray:rawData |
|
4465 |
"evaluate aBlock, passing a fonts metrics as arguments. |
|
4466 |
fill passed array as: |
|
4467 |
ascent -> (data at:1) |
|
4468 |
descent -> (data at:2) |
|
4469 |
maxAscent -> (data at:3) |
|
4470 |
maxDescent -> (data at:4) |
|
4471 |
minWidth -> (data at:5) |
|
4472 |
maxWidth -> (data at:6) |
|
4473 |
avgWidth -> (data at:7). |
|
4474 |
minChar -> (data at:8). |
|
4475 |
maxChar -> (data at:9). |
|
4476 |
defaultChar-> (data at:10). |
|
4477 |
charSet -> (data at:11). |
|
4478 |
" |
|
4479 |
||
4480 |
%{ |
|
4481 |
||
4482 |
if (__isExternalAddress(fontId) |
|
4483 |
&& __isExternalAddressLike(aDC) |
|
4484 |
&& __isArray(rawData) |
|
4485 |
&& (__arraySize(rawData) >= 11)) { |
|
2344 | 4486 |
SIZE size; |
4487 |
int avgWidth; |
|
4488 |
HGDIOBJ hFont; |
|
4489 |
HGDIOBJ prevFont; |
|
4490 |
TEXTMETRIC tmet; |
|
4491 |
static char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
|
4492 |
static int len; |
|
4493 |
OBJ t; |
|
4494 |
HANDLE hDC; |
|
4495 |
||
4496 |
hFont = _HGDIOBJVal(fontId); |
|
4497 |
hDC = (HANDLE)(__externalAddressVal(aDC)); |
|
4498 |
||
4499 |
/* |
|
4500 |
* temporarily set this font in the tmpDC (root-) context |
|
4501 |
*/ |
|
4502 |
||
4503 |
prevFont = SelectObject(hDC, hFont); |
|
4504 |
||
4505 |
GetTextMetricsW(hDC, &tmet); |
|
4506 |
if (len == 0) { |
|
4507 |
len = strlen(s); |
|
4508 |
} |
|
2323 | 4509 |
#if 0 |
2344 | 4510 |
GetTextExtentPoint32(hDC, s, len, &size); |
4511 |
avgWidth = (size.cx / (len / 2) + 1) / 2; |
|
2323 | 4512 |
#else |
2344 | 4513 |
avgWidth = tmet.tmAveCharWidth; |
2323 | 4514 |
#endif |
4515 |
||
2344 | 4516 |
__ArrayInstPtr(rawData)->a_element[0] = __MKSMALLINT(tmet.tmAscent); /* ascent -> (data at:1) */ |
4517 |
__ArrayInstPtr(rawData)->a_element[1] = __MKSMALLINT(tmet.tmDescent); /* descent -> (data at:2) */ |
|
4518 |
__ArrayInstPtr(rawData)->a_element[2] = __MKSMALLINT(tmet.tmAscent); /* maxAscent -> (data at:3) */ |
|
4519 |
__ArrayInstPtr(rawData)->a_element[3] = __MKSMALLINT(tmet.tmDescent); /* maxDescent -> (data at:4) */ |
|
4520 |
__ArrayInstPtr(rawData)->a_element[4] = __MKSMALLINT(avgWidth); /* minWidth -> (data at:5) */ |
|
4521 |
__ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth); /* maxWidth -> (data at:6) */ |
|
4522 |
__ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth); /* avgWidth -> (data at:7) */ |
|
4523 |
__ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar); /* min -> (data at:8) */ |
|
4524 |
__ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar); /* max -> (data at:9) */ |
|
4525 |
__ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar); /* default -> (data at:10) */ |
|
2323 | 4526 |
#if 0 |
2344 | 4527 |
t = __charSetSymbolFor(tmet.tmCharSet); |
4528 |
__ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t); /* charSet -> (data at:11) */ |
|
2323 | 4529 |
#endif |
4530 |
||
2344 | 4531 |
DPRINTF(("textMetrics h=%x avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n", |
4532 |
hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth, |
|
4533 |
tmet.tmAveCharWidth)); |
|
4534 |
||
4535 |
SelectObject(hDC, prevFont); |
|
4536 |
RETURN (self); |
|
2323 | 4537 |
} |
4538 |
RETURN (nil); |
|
4539 |
%} |
|
4540 |
! |
|
4541 |
||
4542 |
releaseFont:aFontId |
|
4543 |
||
4544 |
%{ /* NOCONTEXT */ |
|
4545 |
if (__isExternalAddress(aFontId)) { |
|
2344 | 4546 |
HGDIOBJ hFont = _HGDIOBJVal(aFontId); |
4547 |
||
4548 |
if (hFont) { |
|
4549 |
DPRINTF(("ReleaseFont: %x\n", hFont)); |
|
4550 |
DeleteObject(hFont); |
|
4551 |
} |
|
2323 | 4552 |
} |
4553 |
%} |
|
4554 |
! |
|
4555 |
||
4556 |
setFont:aFontId in:aDC |
|
4557 |
"set font to be drawn in" |
|
4558 |
||
4559 |
%{ /* NOCONTEXT */ |
|
4560 |
||
4561 |
if (__isExternalAddressLike(aDC) |
|
4562 |
&& __isExternalAddress(aFontId)) |
|
4563 |
{ |
|
2344 | 4564 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
4565 |
HGDIOBJ prevFont, hFont; |
|
4566 |
||
4567 |
hFont = _HGDIOBJVal(aFontId); |
|
4568 |
prevFont = SelectObject(hDC, hFont); |
|
4569 |
||
4570 |
RETURN ( self ); |
|
2323 | 4571 |
} |
4572 |
%}. |
|
4573 |
self primitiveFailed |
|
4574 |
||
4575 |
"Created: / 04-08-2006 / 12:32:53 / fm" |
|
4576 |
! |
|
4577 |
||
4578 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
|
4579 |
||
4580 |
%{ /* NOCONTEXT */ |
|
4581 |
unsigned char *cp; |
|
4582 |
int len, n, i1, i2, l; |
|
4583 |
OBJ cls; |
|
4584 |
int nInstBytes; |
|
4585 |
||
4586 |
if (__bothSmallInteger(index1, index2) |
|
4587 |
&& __isExternalAddress(aFontId) |
|
4588 |
&& __isExternalAddressLike(__INST(gcId)) |
|
4589 |
&& __isNonNilObject(aString)) { |
|
2344 | 4590 |
HGDIOBJ hFont,prevFont; |
4591 |
HANDLE hDC; |
|
4592 |
SIZE tsize; |
|
2323 | 4593 |
|
4594 |
#ifndef PRE_22_FEP_2007 |
|
4595 |
# define N_QUICK_CHARS 1024 |
|
2344 | 4596 |
unsigned short quickWchars[N_QUICK_CHARS]; |
4597 |
unsigned short *wcharPtr; |
|
4598 |
int mustFree = 0; |
|
4599 |
int i; |
|
2323 | 4600 |
#endif |
4601 |
||
2344 | 4602 |
hFont = _HGDIOBJVal(aFontId); |
4603 |
hDC = (HANDLE)(__externalAddressVal(__INST(gcId))); |
|
4604 |
||
4605 |
prevFont = SelectObject(hDC, hFont); |
|
4606 |
||
4607 |
i1 = __intVal(index1) - 1; |
|
4608 |
cls = __qClass(aString); |
|
4609 |
||
4610 |
if (i1 >= 0) { |
|
4611 |
i2 = __intVal(index2) - 1; |
|
4612 |
if (i2 < i1) { |
|
4613 |
RETURN ( __MKSMALLINT( 0 ) ); |
|
4614 |
} |
|
4615 |
||
4616 |
cp = (char *) _stringVal(aString); |
|
4617 |
l = i2 - i1 + 1; |
|
4618 |
||
4619 |
if ((cls == @global(String)) || (cls == @global(Symbol))) { |
|
4620 |
n = _stringSize(aString); |
|
2323 | 4621 |
commonWidthChars: |
2344 | 4622 |
if (i2 < n) { |
4623 |
cp += i1; |
|
2323 | 4624 |
|
4625 |
#ifdef PRE_22_FEP_2007 |
|
2344 | 4626 |
GetTextExtentPoint32(hDC, cp, l, &tsize); |
2323 | 4627 |
#else |
2344 | 4628 |
if (l <= N_QUICK_CHARS) { |
4629 |
wcharPtr = quickWchars; |
|
4630 |
mustFree = 0; |
|
4631 |
} else { |
|
4632 |
wcharPtr = malloc(sizeof(short)*l); |
|
4633 |
if (! wcharPtr) RETURN (__MKSMALLINT(0)); |
|
4634 |
mustFree = 1; |
|
4635 |
} |
|
4636 |
for (i=0; i<l; i++) wcharPtr[i] = ((unsigned char *)cp)[i]; |
|
4637 |
GetTextExtentPoint32W(hDC, wcharPtr, l, &tsize); |
|
4638 |
if (mustFree) free(wcharPtr); |
|
2323 | 4639 |
#endif |
4640 |
||
4641 |
#ifdef SUPERDEBUG |
|
2344 | 4642 |
if (__debug__) { |
4643 |
char buf[80]; |
|
4644 |
||
4645 |
GetTextFace(hDC,80,buf); |
|
4646 |
console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx); |
|
4647 |
} |
|
2323 | 4648 |
#endif |
2344 | 4649 |
SelectObject(hDC, prevFont); |
4650 |
RETURN ( __MKSMALLINT(tsize.cx) ); |
|
4651 |
} |
|
4652 |
RETURN (__MKSMALLINT(0)); |
|
4653 |
} |
|
4654 |
||
4655 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
|
4656 |
cp += nInstBytes; |
|
4657 |
n = __byteArraySize(aString) - nInstBytes; |
|
4658 |
||
4659 |
if (__isBytes(aString)) { |
|
4660 |
goto commonWidthChars; |
|
4661 |
} |
|
4662 |
||
4663 |
/* Unicode */ |
|
4664 |
if (__isWords(aString)) { |
|
4665 |
n = n / 2; |
|
4666 |
if (i2 < n) { |
|
4667 |
WIDECHAR *w_cp = (WIDECHAR *)cp; |
|
4668 |
||
4669 |
w_cp += i1; |
|
4670 |
||
4671 |
GetTextExtentPoint32W(hDC, w_cp, l, &tsize); |
|
4672 |
SelectObject(hDC, prevFont); |
|
4673 |
RETURN ( __MKSMALLINT(tsize.cx) ); |
|
4674 |
} |
|
4675 |
RETURN (__MKSMALLINT(0)); |
|
4676 |
} |
|
4677 |
} |
|
2323 | 4678 |
} |
4679 |
%}. |
|
4680 |
self primitiveFailed. |
|
4681 |
^ 0 |
|
4682 |
! |
|
4683 |
||
4684 |
widthOf:aString inFont:aFontId |
|
4685 |
"return the width in pixels of a string in a specific font" |
|
4686 |
||
4687 |
^ self widthOf:aString from:1 to:(aString size) inFont:aFontId |
|
2316 | 4688 |
! ! |
4689 |
||
2299 | 4690 |
!WinPrinterContext methodsFor:'initialization & release'! |
4691 |
||
4692 |
createDC |
|
4693 |
"Private - Create a device context for the receiver" |
|
2317 | 4694 |
|
2299 | 4695 |
gcId := printerInfo createDC |
4696 |
||
4697 |
"Created: / 27-07-2006 / 10:21:05 / fm" |
|
4698 |
"Modified: / 02-08-2006 / 17:30:47 / fm" |
|
4699 |
"Modified: / 10-10-2006 / 18:14:28 / cg" |
|
4700 |
! |
|
4701 |
||
2315 | 4702 |
deleteDC |
4703 |
"Private - Delete a device context for the receiver" |
|
4704 |
||
4705 |
OperatingSystem deletePrinterDC: gcId. |
|
4706 |
! |
|
4707 |
||
2323 | 4708 |
destroy |
4709 |
"Destroy the GC." |
|
4710 |
||
4711 |
|id| |
|
4712 |
||
4713 |
id := gcId. |
|
4714 |
id notNil ifTrue:[ |
|
2344 | 4715 |
gcId := nil. |
4716 |
self deleteDC. |
|
2323 | 4717 |
]. |
4718 |
"/ Lobby unregister:self. |
|
4719 |
! |
|
4720 |
||
4721 |
destroyGC:aDC |
|
4722 |
%{ |
|
4723 |
if (__isExternalAddressLike(aDC)) { |
|
2344 | 4724 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
4725 |
||
4726 |
DeleteDC(hDC); |
|
2323 | 4727 |
|
4728 |
/* |
|
4729 |
#ifdef CACHE_LAST_DC |
|
2344 | 4730 |
if (lastGcData == gcData) { |
4731 |
_releaseDC(gcData); |
|
4732 |
} |
|
2323 | 4733 |
#endif |
4734 |
*/ |
|
4735 |
||
4736 |
} |
|
4737 |
%} |
|
4738 |
! |
|
4739 |
||
2299 | 4740 |
executor |
4741 |
|aCopy| |
|
4742 |
||
4743 |
aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew. |
|
4744 |
aCopy setDevice:device id:nil gcId:gcId. |
|
4745 |
^ aCopy |
|
4746 |
||
4747 |
"Created: / 16-04-2007 / 12:39:02 / cg" |
|
2315 | 4748 |
! |
4749 |
||
2323 | 4750 |
initialize |
4751 |
super initialize. |
|
4752 |
"/ deviceForms := Registry new. |
|
4753 |
"/ deviceColors := Registry new. |
|
4754 |
deviceFonts := CachingRegistry new cacheSize:10. |
|
4755 |
! |
|
4756 |
||
2315 | 4757 |
releaseDC |
4758 |
"Private - Delete and clear the device context of the receiver." |
|
4759 |
||
4760 |
self deleteDC. |
|
2316 | 4761 |
"/ device close. |
2323 | 4762 |
gcId := nil. |
4763 |
self releaseDeviceFonts |
|
4764 |
! |
|
4765 |
||
4766 |
releaseDeviceFonts |
|
4767 |
deviceFonts isEmptyOrNil ifFalse:[ |
|
2344 | 4768 |
deviceFonts do:[:afont | |
4769 |
afont releaseFromDevice. |
|
4770 |
]. |
|
2323 | 4771 |
]. |
4772 |
deviceFonts := CachingRegistry new cacheSize:10. |
|
4773 |
! ! |
|
4774 |
||
2328 | 4775 |
!WinPrinterContext methodsFor:'non standard methods'! |
4776 |
||
4777 |
stringWidthOf:aString at:index |
|
4778 |
"Return the width of aString up to index |
|
4779 |
when written using the current font; expand tabs out |
|
4780 |
to 4 spaces for calculations" |
|
4781 |
||
4782 |
|answer str size spaceWidth| |
|
4783 |
||
4784 |
index <= 0 ifTrue:[ ^ 0 ]. |
|
4785 |
str := index >= aString size ifTrue:[ aString ] ifFalse:[ aString copyFrom:1 to:index ]. |
|
4786 |
true "self font isNil" ifTrue:[ |
|
2344 | 4787 |
"if font not set yet, calculate based on default font" |
4788 |
"/ extString := str asExternalString. |
|
4789 |
size := Win32OperatingSystem::WinPointStructure new. |
|
4790 |
(OperatingSystem |
|
4791 |
getTextExtentPoint:gcId |
|
4792 |
string:str |
|
4793 |
size:size) ifFalse:[ ^ self error ]. |
|
4794 |
answer := size x. |
|
2328 | 4795 |
"/ Transcript showCR: 'FROM PRIM ******* ', str, ' ', answer printString. |
4796 |
"/ Transcript showCR: 'FROM DEVICE ***** ', str, ' ',(self font widthOf:str on:self device) printString. |
|
2344 | 4797 |
#TODO. |
2328 | 4798 |
] ifFalse:[ |
2344 | 4799 |
answer := self font widthOf:str on:self device |
2328 | 4800 |
]. |
4801 |
index > aString size ifTrue:[ |
|
2344 | 4802 |
spaceWidth := self font widthOf:Character space on:self device. |
4803 |
answer := answer + ((index - aString size) * spaceWidth) |
|
2328 | 4804 |
]. |
4805 |
^ answer. |
|
4806 |
||
4807 |
"Created: / 03-08-2006 / 10:27:20 / fm" |
|
4808 |
"Modified: / 04-08-2006 / 12:27:26 / fm" |
|
4809 |
"Modified: / 10-10-2006 / 18:20:43 / cg" |
|
4810 |
! ! |
|
4811 |
||
2323 | 4812 |
!WinPrinterContext methodsFor:'not supported yet'! |
4813 |
||
4814 |
displayAdvanceLineFrom:point1 to:point2 |
|
4815 |
"draw a line" |
|
4816 |
||
4817 |
self displayAdvanceLineFromX:(point1 x) y:(point1 y) |
|
2344 | 4818 |
toX:(point2 x) y:(point2 y) |
2323 | 4819 |
! |
4820 |
||
4821 |
displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1 |
|
4822 |
"draw a line (with current paint-color); apply transformation if nonNil" |
|
4823 |
||
4824 |
|pX0 pY0 pX1 pY1 easy fgId bgId| |
|
4825 |
||
4826 |
gcId isNil ifTrue:[ |
|
2344 | 4827 |
self initGC |
2323 | 4828 |
]. |
4829 |
||
4830 |
lineStyle == #doubleDashed ifTrue:[ |
|
2344 | 4831 |
" |
4832 |
if bgPaint or paint is not a real color, we have to do it the hard way ... |
|
4833 |
" |
|
4834 |
easy := true. |
|
4835 |
paint isColor ifFalse:[ |
|
4836 |
easy := false |
|
4837 |
] ifTrue:[ |
|
4838 |
fgId := paint colorId. |
|
4839 |
fgId isNil ifTrue:[ |
|
4840 |
easy := false |
|
4841 |
] |
|
4842 |
]. |
|
4843 |
bgPaint isColor ifFalse:[ |
|
4844 |
easy := false |
|
4845 |
] ifTrue:[ |
|
4846 |
bgId := bgPaint colorId. |
|
4847 |
bgId isNil ifTrue:[ |
|
4848 |
easy := false |
|
4849 |
] |
|
4850 |
]. |
|
4851 |
||
4852 |
easy ifTrue:[ |
|
4853 |
((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ |
|
4854 |
device setForeground:fgId background:bgId in:gcId. |
|
4855 |
foreground := paint. |
|
4856 |
background := bgPaint. |
|
4857 |
]. |
|
4858 |
] ifFalse:[ |
|
4859 |
'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR |
|
4860 |
]. |
|
2323 | 4861 |
]. |
4862 |
||
4863 |
transformation notNil ifTrue:[ |
|
2344 | 4864 |
pX0 := transformation applyToX:x0. |
4865 |
pY0 := transformation applyToY:y0. |
|
4866 |
pX1 := transformation applyToX:x1. |
|
4867 |
pY1 := transformation applyToY:y1. |
|
2323 | 4868 |
] ifFalse:[ |
2344 | 4869 |
pX0 := x0. |
4870 |
pY0 := y0. |
|
4871 |
pX1 := x1. |
|
4872 |
pY1 := y1 |
|
2323 | 4873 |
]. |
4874 |
||
4875 |
pX0 := pX0 rounded. |
|
4876 |
pY0 := pY0 rounded. |
|
4877 |
pX1 := pX1 rounded. |
|
4878 |
pY1 := pY1 rounded. |
|
4879 |
||
4880 |
device displayAdvanceLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId |
|
4881 |
||
4882 |
"Modified: 10.1.1997 / 17:46:32 / cg" |
|
4883 |
! |
|
4884 |
||
4885 |
displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC |
|
4886 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
4887 |
||
4888 |
self getPenForMyContext. |
|
4889 |
||
4890 |
%{ /* NOCONTEXT */ |
|
4891 |
if (__isExternalAddressLike(aDC) |
|
4892 |
&& __bothSmallInteger(x0, y0) |
|
4893 |
&& __bothSmallInteger(x1, y1)) { |
|
2344 | 4894 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
4895 |
COLORREF fgColor; |
|
4896 |
int __x1 = __intVal(x1), __y1 = __intVal(y1); |
|
2323 | 4897 |
|
4898 |
||
4899 |
/* DPRINTF(("displayLine: %d/%d -> %d/%d\n", |
|
2344 | 4900 |
__intVal(x0), __intVal(y0), |
4901 |
__x1, __y1)); |
|
2323 | 4902 |
*/ |
4903 |
||
4904 |
/* fgColor = GetTextColor(hDC); |
|
4905 |
* hPen = CreatePen(PS_SOLID, 1, fgColor); |
|
4906 |
*/ |
|
4907 |
||
2344 | 4908 |
MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL); |
4909 |
||
4910 |
LineTo(hDC, __x1, __y1); |
|
4911 |
||
4912 |
/* |
|
4913 |
* end-point ... |
|
4914 |
*/ |
|
4915 |
LineTo(hDC, __x1+1, __y1); |
|
4916 |
||
4917 |
||
4918 |
||
4919 |
RETURN ( self ); |
|
2323 | 4920 |
} |
4921 |
%} |
|
4922 |
! |
|
4923 |
||
2328 | 4924 |
gcForBitmap:aDrawableId |
4925 |
||
4926 |
%{ /* NOCONTEXT */ |
|
4927 |
||
4928 |
if (__isExternalAddress(aDrawableId)){ |
|
2338 | 4929 |
BITMAP bitmap; |
4930 |
HBITMAP hBitmap = _HBITMAPVAL(aDrawableId); |
|
4931 |
HBITMAP memBM; |
|
4932 |
HANDLE compatibleDC, rootDC, hdcScreen; |
|
2328 | 4933 |
// HANDLE printerDC = (HANDLE)(__externalAddressVal(__INST(gcId))); |
4934 |
||
2338 | 4935 |
if (! hBitmap) { |
4936 |
RETURN (nil); |
|
4937 |
} |
|
4938 |
||
4939 |
if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) { |
|
2328 | 4940 |
/* |
2338 | 4941 |
DDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel)); |
2328 | 4942 |
*/ |
2338 | 4943 |
} else { |
2328 | 4944 |
/* |
2338 | 4945 |
DPRINTF(("noinfo returned for bitmap\n")); |
2328 | 4946 |
*/ |
2338 | 4947 |
/* mhmh - can this happen ? */ |
4948 |
bitmap.bmBitsPixel = 1; |
|
4949 |
} |
|
2328 | 4950 |
/* |
2338 | 4951 |
gcData->hBitmap = hBitmap; |
4952 |
gcData->bitmapColorBitCount = bitmap.bmBitsPixel; |
|
2328 | 4953 |
*/ |
4954 |
||
2338 | 4955 |
rootDC = CreateDC("DISPLAY", NULL, NULL, NULL); |
4956 |
compatibleDC = CreateCompatibleDC(rootDC); |
|
4957 |
SelectObject(compatibleDC, hBitmap); |
|
2328 | 4958 |
|
4959 |
// hdcScreen= CreateDC("NULL", NULL, NULL, NULL); |
|
4960 |
// compatibleDC = rootDC; |
|
4961 |
// compatibleDC = CreateCompatibleDC(printerDC); |
|
4962 |
// compatibleDC = CreateCompatibleDC(0); |
|
2338 | 4963 |
|
2328 | 4964 |
// memBM = CreateCompatibleBitmap ( compatibleDC, bitmap.bmWidth, bitmap.bmHeight ); |
4965 |
// SelectObject ( compatibleDC, memBM ); |
|
4966 |
||
2338 | 4967 |
RETURN (__MKOBJ(compatibleDC)); |
2328 | 4968 |
|
4969 |
/* |
|
2338 | 4970 |
RETURN ( __MKOBJ(gcData) ); |
2328 | 4971 |
*/ |
4972 |
} |
|
4973 |
RETURN (nil); |
|
4974 |
%} |
|
4975 |
! |
|
4976 |
||
2324 | 4977 |
getPenForMyContext |
4978 |
"Get a pen for my context" |
|
4979 |
||
4980 |
|maskOriginX maskOriginY| |
|
4981 |
||
4982 |
self maskOrigin isNil ifFalse:[ |
|
2344 | 4983 |
maskOriginX := self maskOrigin x. |
4984 |
maskOriginY := self maskOrigin y. |
|
2324 | 4985 |
]. |
4986 |
||
2325 | 4987 |
%{ |
2324 | 4988 |
HPEN hPen = 0; |
4989 |
HPEN prevPen; |
|
4990 |
LOGBRUSH Brush; |
|
4991 |
COLORREF fgColor; |
|
4992 |
HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId))); |
|
4993 |
int lStyle, bkMode, hMask, maskOrgX, maskOrgY; |
|
4994 |
int style, lineStyle, capStyle, joinStyle; |
|
4995 |
int lw; |
|
4996 |
int BK_TRANSPARENT; |
|
4997 |
||
4998 |
BK_TRANSPARENT = 1; |
|
4999 |
||
5000 |
lw= __INST(lineWidth); |
|
5001 |
/* fgColor = __intVal(__INST(foreground)) & 0xffffff; */ |
|
5002 |
||
2325 | 5003 |
fgColor = GetTextColor(hDC); |
2324 | 5004 |
lineStyle=__INST(lineStyle); |
5005 |
capStyle=__INST(capStyle); |
|
5006 |
joinStyle=__INST(joinStyle); |
|
5007 |
hMask= __INST(mask); |
|
5008 |
maskOrgX=__intVal(maskOriginX); |
|
5009 |
maskOrgY=__intVal(maskOriginY); |
|
5010 |
||
5011 |
if (lineStyle == @symbol(solid)) { |
|
2344 | 5012 |
style = PS_SOLID; |
2324 | 5013 |
} else if (lineStyle == @symbol(dashed)) { |
2344 | 5014 |
style= PS_DASH; |
2324 | 5015 |
} else if (lineStyle == @symbol(dotted)) { |
2344 | 5016 |
style= PS_DOT; |
2324 | 5017 |
} else if (lineStyle == @symbol(dashDot)) { |
2344 | 5018 |
style= PS_DASHDOT; |
2324 | 5019 |
} else if (lineStyle == @symbol(dashDotDot)) { |
2344 | 5020 |
style= PS_DASHDOTDOT; |
2324 | 5021 |
} else |
2344 | 5022 |
style= PS_SOLID; |
2324 | 5023 |
lStyle &= ~PS_STYLE_MASK; |
5024 |
lStyle |= style; |
|
5025 |
||
5026 |
||
5027 |
if (capStyle == @symbol(round)) { |
|
2344 | 5028 |
style = PS_ENDCAP_ROUND; |
2324 | 5029 |
} else if (capStyle == @symbol(square)) { |
2344 | 5030 |
style = PS_ENDCAP_SQUARE; |
2324 | 5031 |
} else if (capStyle == @symbol(flat)) { |
2344 | 5032 |
style = PS_ENDCAP_FLAT; |
2324 | 5033 |
} else |
2344 | 5034 |
style = PS_ENDCAP_FLAT; |
2324 | 5035 |
lStyle &= ~PS_ENDCAP_MASK; |
5036 |
lStyle |= style; |
|
5037 |
||
5038 |
if (joinStyle == @symbol(bevel)) { |
|
2344 | 5039 |
style = PS_JOIN_BEVEL; |
2324 | 5040 |
} else if (joinStyle == @symbol(miter)) { |
2344 | 5041 |
style = PS_JOIN_MITER; |
2324 | 5042 |
} else if (joinStyle == @symbol(round)) { |
2344 | 5043 |
style = PS_JOIN_ROUND; |
2324 | 5044 |
} else |
2344 | 5045 |
style = PS_JOIN_MITER; |
2324 | 5046 |
lStyle &= ~PS_JOIN_MASK; |
5047 |
lStyle |= style; |
|
5048 |
||
5049 |
||
5050 |
if (((lStyle & PS_STYLE_MASK) == PS_SOLID) |
|
5051 |
&& (hMask == 0) |
|
5052 |
&& (lw /* lineWidth */ <= 1)) { |
|
2344 | 5053 |
if (fgColor == 0 /* BlackPixel */ ) { |
5054 |
hPen = GetStockObject(BLACK_PEN); |
|
5055 |
prevPen = SelectObject(hDC, hPen); |
|
5056 |
RETURN( hPen ); |
|
5057 |
} |
|
5058 |
if (fgColor == 1 /* WhitePixel */) { |
|
5059 |
hPen = GetStockObject(WHITE_PEN); |
|
5060 |
prevPen = SelectObject(hDC, hPen); |
|
5061 |
RETURN( hPen ); |
|
5062 |
} |
|
2324 | 5063 |
} |
5064 |
||
5065 |
hPen = (HPEN) 0; |
|
5066 |
||
5067 |
if (0 /* __isWinNT */) { |
|
5068 |
||
2344 | 5069 |
if (lw == 0) { |
5070 |
lw = 1; |
|
5071 |
} |
|
5072 |
/* |
|
5073 |
* NT supports masked drawing with any lineStyle, |
|
5074 |
* and also non-solid lines with any lineWidth. |
|
5075 |
*/ |
|
5076 |
if (hMask) { |
|
5077 |
Brush.lbStyle = BS_PATTERN; |
|
5078 |
Brush.lbHatch = (DWORD)hMask; |
|
5079 |
Brush.lbColor = fgColor; |
|
5080 |
} else { |
|
2324 | 5081 |
|
5082 |
#ifndef PRE_07_APR_04 |
|
5083 |
||
2344 | 5084 |
hPen = CreatePen((lStyle & PS_STYLE_MASK), lw, fgColor); |
2324 | 5085 |
|
5086 |
/* RESPRINTF(("CreatePen %x %d(%d) %x %x\n", |
|
5087 |
* lStyle, |
|
5088 |
* lw, __INST(lineWidth), |
|
5089 |
* fgColor, hMask)); |
|
5090 |
*/ |
|
5091 |
||
2344 | 5092 |
SetBkMode(hDC, TRANSPARENT); |
5093 |
bkMode = BK_TRANSPARENT; |
|
2324 | 5094 |
|
5095 |
#else |
|
2344 | 5096 |
Brush.lbStyle = BS_SOLID; |
5097 |
Brush.lbHatch = 0; |
|
5098 |
Brush.lbColor = fgColor; |
|
2324 | 5099 |
#endif |
2344 | 5100 |
} |
5101 |
||
5102 |
if (! hPen) |
|
5103 |
{ |
|
5104 |
hPen = ExtCreatePen(PS_GEOMETRIC | lStyle, |
|
5105 |
lw, /* lineWidth, */ |
|
5106 |
&Brush, |
|
5107 |
0, 0); |
|
2324 | 5108 |
|
5109 |
/* RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n", |
|
5110 |
* lStyle, |
|
5111 |
* lw, __INST(lineWidth), |
|
5112 |
* fgColor, hMask)); |
|
5113 |
*/ |
|
2344 | 5114 |
if (hMask) { |
5115 |
SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0); |
|
5116 |
} |
|
5117 |
} |
|
2324 | 5118 |
} else { |
2344 | 5119 |
/* |
5120 |
* W95 only supports masked drawing with SOLID lines |
|
5121 |
* also, we should use COSMETIC pens if possible |
|
5122 |
* with non-solid lineStyles. |
|
5123 |
*/ |
|
5124 |
if ((lStyle & PS_STYLE_MASK) == PS_SOLID) { |
|
5125 |
int ps = PS_GEOMETRIC; |
|
5126 |
||
5127 |
if (hMask) { |
|
5128 |
Brush.lbStyle = BS_PATTERN; |
|
5129 |
Brush.lbHatch = (DWORD)hMask; |
|
5130 |
Brush.lbColor = fgColor; |
|
5131 |
} else { |
|
5132 |
Brush.lbStyle = BS_SOLID; |
|
5133 |
Brush.lbHatch = 0; |
|
5134 |
Brush.lbColor = fgColor; |
|
5135 |
if (lw /* lineWidth */ <= 1) { |
|
5136 |
ps = PS_COSMETIC; |
|
5137 |
} |
|
5138 |
} |
|
5139 |
||
5140 |
hPen = ExtCreatePen(ps | lStyle, |
|
5141 |
lw, /* lineWidth */ |
|
5142 |
&Brush, |
|
5143 |
0, 0); |
|
2324 | 5144 |
|
5145 |
/* RESPRINTF(("ExtCreatePen1 %x %d %x %x\n", |
|
5146 |
* lStyle, |
|
2325 | 5147 |
* lw, |
2324 | 5148 |
* fgColor, hMask)); |
5149 |
*/ |
|
2344 | 5150 |
if (hMask) { |
5151 |
SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0); |
|
5152 |
} |
|
5153 |
} else { |
|
5154 |
||
5155 |
if (lw == 1) { |
|
5156 |
lw = 0; |
|
5157 |
} |
|
5158 |
||
5159 |
/* |
|
5160 |
* dashes only supported with lineWidth 0 |
|
5161 |
*/ |
|
5162 |
||
5163 |
hPen = CreatePen((lStyle & PS_STYLE_MASK), |
|
5164 |
lw, |
|
5165 |
fgColor); |
|
2324 | 5166 |
|
5167 |
/* RESPRINTF(("CreatePen %x %d %x\n", |
|
5168 |
* (lStyle & PS_STYLE_MASK), |
|
2325 | 5169 |
* lw, |
2324 | 5170 |
* fgColor)); |
5171 |
*/ |
|
2344 | 5172 |
// |
5173 |
// CG: wrong; must set to opaque, if doubleDashed |
|
5174 |
// |
|
5175 |
SetBkMode(hDC, TRANSPARENT); |
|
5176 |
bkMode = BK_TRANSPARENT; |
|
5177 |
} |
|
2324 | 5178 |
} |
5179 |
||
5180 |
prevPen = SelectObject(hDC, hPen); |
|
5181 |
||
5182 |
RETURN (hPen); |
|
5183 |
||
5184 |
%} |
|
5185 |
! |
|
5186 |
||
2328 | 5187 |
xprimDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd width:imageWidth height:imageHeight |
2344 | 5188 |
x:srcx y:srcy |
5189 |
into:ignoredDrawableId |
|
5190 |
x:dstx y:dsty |
|
5191 |
width:w height:h |
|
5192 |
with:aDC |
|
2328 | 5193 |
|
5194 |
"since XPutImage may allocate huge amount of stack space |
|
5195 |
(some implementations use alloca), this must run with unlimited stack." |
|
5196 |
||
5197 |
%{ |
|
5198 |
unsigned char fastBits[10000]; |
|
5199 |
unsigned char *b_bits = 0; |
|
5200 |
unsigned char *allocatedBits = 0; |
|
5201 |
unsigned char *__imageBits = 0; |
|
5202 |
||
5203 |
if (__isByteArray(imageBits)) { |
|
2344 | 5204 |
__imageBits = __ByteArrayInstPtr(imageBits)->ba_element; |
2328 | 5205 |
} else if (__isExternalBytesLike(imageBits)) { |
2344 | 5206 |
__imageBits = (unsigned char *)(__externalBytesAddress(imageBits)); |
2328 | 5207 |
} |
5208 |
||
5209 |
if (/* ISCONNECTED |
|
5210 |
&& */ __isExternalAddressLike(aDC) |
|
5211 |
&& __bothSmallInteger(srcx, srcy) |
|
5212 |
&& __bothSmallInteger(dstx, dsty) |
|
5213 |
&& __bothSmallInteger(w, h) |
|
5214 |
&& __bothSmallInteger(imageWidth, imageHeight) |
|
5215 |
&& __bothSmallInteger(imageDepth, bitsPerPixel) |
|
5216 |
&& __isSmallInteger(padd) |
|
5217 |
&& __imageBits) |
|
5218 |
{ |
|
2344 | 5219 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
5220 |
struct |
|
5221 |
{ |
|
5222 |
BITMAPINFOHEADER bmiHeader; |
|
5223 |
DWORD r; |
|
5224 |
DWORD g; |
|
5225 |
DWORD b; |
|
5226 |
} bitmap; |
|
5227 |
||
5228 |
if (__intVal(padd) != WIN32PADDING) { |
|
5229 |
int row, col; |
|
5230 |
unsigned char *cp; |
|
5231 |
unsigned char *pBits; |
|
5232 |
int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes; |
|
5233 |
int bi = __intVal(bitsPerPixel); |
|
5234 |
||
5235 |
b_width = __intVal(w); |
|
5236 |
b_height = __intVal(h); |
|
5237 |
bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd); |
|
5238 |
bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8); |
|
5239 |
padding = bytesPerRowWN - bytesPerRowST; |
|
5240 |
nBytes = b_height * bytesPerRowWN; |
|
5241 |
/*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/ |
|
5242 |
if (padding) { |
|
5243 |
if (nBytes < sizeof(fastBits)) { |
|
5244 |
cp = b_bits = fastBits; |
|
5245 |
} else { |
|
5246 |
cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes); |
|
5247 |
} |
|
5248 |
if (cp) { |
|
5249 |
pBits = __imageBits; |
|
5250 |
for (row = b_height; row; row--) { |
|
5251 |
for (col = bytesPerRowST; col; col--) { |
|
5252 |
*cp++ = *pBits++; |
|
5253 |
} |
|
5254 |
cp += padding; |
|
5255 |
} |
|
5256 |
} else |
|
5257 |
goto fail; |
|
5258 |
} |
|
5259 |
} |
|
5260 |
||
5261 |
if (b_bits == 0) { |
|
5262 |
b_bits = __imageBits; |
|
5263 |
} |
|
5264 |
||
5265 |
bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
|
5266 |
bitmap.bmiHeader.biPlanes = 1; |
|
5267 |
if (__intVal(imageDepth) == 24) { |
|
5268 |
/*bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
|
5269 |
bitmap.r = 0xff0000; |
|
5270 |
bitmap.g = 0x00ff00; |
|
5271 |
bitmap.b = 0x0000ff;*/ |
|
5272 |
bitmap.bmiHeader.biCompression = BI_RGB; |
|
5273 |
} else if (__intVal(imageDepth) == 16) { |
|
5274 |
/*bitmap.bmiHeader.biCompression = BI_RGB; |
|
5275 |
bitmap.bmiHeader.biCompression = BI_BITFIELDS; |
|
5276 |
bitmap.b = 0x001f; |
|
5277 |
bitmap.g = 0x07e0; |
|
5278 |
bitmap.r = 0xf800;*/ |
|
5279 |
bitmap.b = 0; |
|
5280 |
bitmap.g = 0; |
|
5281 |
bitmap.r = 0; |
|
5282 |
bitmap.bmiHeader.biCompression = BI_RGB; |
|
5283 |
} |
|
5284 |
bitmap.bmiHeader.biSizeImage = 0; |
|
5285 |
bitmap.bmiHeader.biXPelsPerMeter = 0; |
|
5286 |
bitmap.bmiHeader.biYPelsPerMeter = 0; |
|
5287 |
bitmap.bmiHeader.biClrUsed = 0; |
|
5288 |
bitmap.bmiHeader.biClrImportant = 0; |
|
5289 |
bitmap.bmiHeader.biWidth = __intVal(imageWidth); |
|
5290 |
bitmap.bmiHeader.biHeight = -(__intVal(imageHeight)); |
|
5291 |
bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel); |
|
5292 |
/*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/ |
|
5293 |
SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty), |
|
5294 |
__intVal(w), __intVal(h), |
|
5295 |
__intVal(srcx), __intVal(srcy), |
|
5296 |
0,__intVal(h), |
|
5297 |
(void *)b_bits, |
|
5298 |
(BITMAPINFO*)&bitmap,DIB_RGB_COLORS); |
|
5299 |
if (allocatedBits) { |
|
5300 |
free(allocatedBits); |
|
5301 |
} |
|
5302 |
RETURN ( true ); |
|
2328 | 5303 |
} |
5304 |
||
5305 |
fail: ; |
|
5306 |
/* |
|
5307 |
PRINTF(("create temp bitmap FAILED!!!\n")); |
|
5308 |
*/ |
|
5309 |
if (allocatedBits) { |
|
5310 |
/* |
|
2344 | 5311 |
PRINTF(("freeing up temp bitmap bits ...\n")); |
2328 | 5312 |
*/ |
2344 | 5313 |
free(allocatedBits); |
2328 | 5314 |
} |
5315 |
%} |
|
5316 |
. |
|
5317 |
^ false |
|
5318 |
! |
|
5319 |
||
2323 | 5320 |
xxxdisplayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC |
5321 |
"draw a line. If the coordinates are not integers, an error is triggered." |
|
5322 |
||
5323 |
|penHandle| |
|
5324 |
||
5325 |
penHandle := ExternalBytes address: self getPenForMyContext. |
|
5326 |
||
5327 |
%{ /* NOCONTEXT */ |
|
5328 |
if (__isExternalAddressLike(aDC) |
|
5329 |
&& __isExternalAddressLike(penHandle) |
|
5330 |
&& __bothSmallInteger(x0, y0) |
|
5331 |
&& __bothSmallInteger(x1, y1)) { |
|
2344 | 5332 |
HANDLE hDC = (HANDLE)(__externalAddressVal(aDC)); |
5333 |
HANDLE hPen = (HANDLE)(__externalAddressVal(penHandle)); |
|
5334 |
COLORREF fgColor; |
|
5335 |
HANDLE prevPen; |
|
5336 |
int __x1 = __intVal(x1), __y1 = __intVal(y1); |
|
2323 | 5337 |
|
5338 |
||
5339 |
/* DPRINTF(("displayLine: %d/%d -> %d/%d\n", |
|
2344 | 5340 |
__intVal(x0), __intVal(y0), |
5341 |
__x1, __y1)); |
|
2323 | 5342 |
*/ |
5343 |
||
5344 |
/* fgColor = GetTextColor(hDC); |
|
5345 |
* hPen = CreatePen(PS_SOLID, 1, fgColor); |
|
5346 |
*/ |
|
5347 |
||
2344 | 5348 |
prevPen = SelectObject(hDC, hPen); |
5349 |
||
5350 |
MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL); |
|
5351 |
||
5352 |
LineTo(hDC, __x1, __y1); |
|
5353 |
||
5354 |
/* |
|
5355 |
* end-point ... |
|
5356 |
*/ |
|
5357 |
LineTo(hDC, __x1+1, __y1); |
|
5358 |
||
5359 |
SelectObject(hDC, prevPen); |
|
5360 |
||
5361 |
||
5362 |
RETURN ( self ); |
|
2323 | 5363 |
} |
5364 |
%} |
|
2299 | 5365 |
! ! |
5366 |
||
5367 |
!WinPrinterContext methodsFor:'printing process'! |
|
5368 |
||
5369 |
endPage |
|
5370 |
"Informs device that we are finished writing to a page." |
|
2317 | 5371 |
|
2299 | 5372 |
(OperatingSystem endPage:gcId) > 0 ifFalse:[ |
2344 | 5373 |
self error |
2299 | 5374 |
] |
5375 |
||
5376 |
"Created: / 27-07-2006 / 18:20:48 / fm" |
|
5377 |
"Modified: / 01-08-2006 / 16:01:34 / fm" |
|
5378 |
"Modified: / 10-10-2006 / 18:14:44 / cg" |
|
5379 |
! |
|
5380 |
||
2315 | 5381 |
endPrintJobWithoutRelease |
2299 | 5382 |
"End the print job. Everything drawn between startPrintJob |
5383 |
and endPrintJob will become one entry in the print queue." |
|
2317 | 5384 |
|
2299 | 5385 |
|result| |
5386 |
||
5387 |
self endPage. |
|
5388 |
result := OperatingSystem endDoc:gcId. |
|
5389 |
jobid := nil. |
|
5390 |
result >= 0 ifFalse:[ self error ] |
|
5391 |
||
5392 |
"Created: / 27-07-2006 / 18:21:04 / fm" |
|
5393 |
"Modified: / 01-08-2006 / 16:01:38 / fm" |
|
5394 |
"Modified: / 10-10-2006 / 18:50:43 / cg" |
|
5395 |
! |
|
5396 |
||
2330 | 5397 |
getSupportsColor |
5398 |
||
5399 |
| retVal info | |
|
5400 |
||
5401 |
info := (self class getPrinterInformationString: self name) asUppercase. |
|
5402 |
(info includesSubString: ',PSCRIPT,') |
|
5403 |
ifTrue: [ |
|
2348 | 5404 |
retVal := self class postScriptBlackWhite not. |
2347 | 5405 |
"/ retVal := (DAPASX::DapasSystemInfo getYesNoInfoApp: 'Printer' profile: 'PostScriptBlackWhite') not. |
2330 | 5406 |
] |
5407 |
ifFalse: [ |
|
5408 |
retVal := (info includesSubString: 'PDF') |
|
5409 |
ifTrue: [true] |
|
5410 |
ifFalse: [self numberOfColorBitsPerPixel > 1]. |
|
5411 |
]. |
|
5412 |
||
5413 |
^retVal |
|
5414 |
! |
|
5415 |
||
2299 | 5416 |
startPage |
5417 |
"Starts a page." |
|
2317 | 5418 |
|
2299 | 5419 |
(OperatingSystem startPage:gcId) > 0 ifFalse:[ |
2344 | 5420 |
^ self error |
2299 | 5421 |
]. |
5422 |
||
5423 |
"Created: / 27-07-2006 / 18:25:55 / fm" |
|
5424 |
"Modified: / 28-07-2006 / 18:19:04 / fm" |
|
5425 |
"Modified: / 10-10-2006 / 18:19:02 / cg" |
|
5426 |
! |
|
5427 |
||
2317 | 5428 |
startPrintJob:aString fileName:aFileName |
2299 | 5429 |
"Start a print job, using aString as the job title; everything |
5430 |
drawn between startPrintJob and endPrintJob will become |
|
5431 |
one entry in the print queue." |
|
2317 | 5432 |
|
2299 | 5433 |
|docInfoStruct nameAddress title fileNameAddress| |
5434 |
||
5435 |
gcId isNil ifTrue:[ |
|
2344 | 5436 |
self buildPrinter |
2299 | 5437 |
]. |
5438 |
abort := false. |
|
5439 |
title := aString ? 'Smalltalk/X'. |
|
5440 |
nameAddress := title asExternalBytes unprotectFromGC. |
|
5441 |
aFileName isNil ifFalse:[ |
|
2344 | 5442 |
fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC |
2299 | 5443 |
]. |
5444 |
docInfoStruct := Win32OperatingSystem::DocInfoStructure new. |
|
5445 |
docInfoStruct |
|
2344 | 5446 |
cbSize:docInfoStruct sizeInBytes; |
5447 |
lpszDocName:nameAddress address. |
|
2299 | 5448 |
fileNameAddress isNil ifFalse:[ |
2344 | 5449 |
docInfoStruct lpszOutput:fileNameAddress address |
2299 | 5450 |
]. |
5451 |
jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct. |
|
5452 |
jobid > 0 ifFalse:[ |
|
2344 | 5453 |
jobid = -1 ifTrue:[ |
5454 |
abort := true. |
|
5455 |
^ nil |
|
5456 |
]. |
|
5457 |
^ self error |
|
2299 | 5458 |
]. |
5459 |
self startPage |
|
5460 |
||
5461 |
"Created: / 27-07-2006 / 18:19:31 / fm" |
|
5462 |
"Modified: / 03-08-2006 / 15:11:19 / fm" |
|
5463 |
"Modified: / 10-10-2006 / 18:20:01 / cg" |
|
5464 |
! ! |
|
5465 |
||
5466 |
!WinPrinterContext methodsFor:'queries'! |
|
5467 |
||
2323 | 5468 |
hasGrayscales |
5469 |
"return true, if this workstation supports grayscales |
|
5470 |
(also true for color displays)" |
|
5471 |
||
5472 |
^ true |
|
5473 |
! |
|
5474 |
||
5475 |
isOpen |
|
5476 |
||
5477 |
^ gcId notNil |
|
5478 |
! |
|
5479 |
||
2324 | 5480 |
isPersistentInSnapshot |
5481 |
"return true, if resources on this device are to be made |
|
5482 |
persistent in a snapshot image." |
|
5483 |
||
5484 |
^ false |
|
5485 |
! |
|
5486 |
||
2299 | 5487 |
supportsColor |
5488 |
||
2330 | 5489 |
supportsColor isNil ifTrue:[supportsColor := self getSupportsColor]. |
5490 |
^supportsColor |
|
2299 | 5491 |
! |
5492 |
||
5493 |
supportsGraphics |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
5494 |
^(OperatingSystem getDeviceCaps: gcId index: 2 "Technology") ~= 4 |
2299 | 5495 |
|
5496 |
"Created: / 03-08-2006 / 10:07:43 / fm" |
|
2301
135f21a3d127
refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents:
2299
diff
changeset
|
5497 |
"Modified: / 16-04-2007 / 12:44:03 / cg" |
2299 | 5498 |
! ! |
5499 |
||
2323 | 5500 |
!WinPrinterContext methodsFor:'registration'! |
5501 |
||
5502 |
registerFont:aFont |
|
5503 |
deviceFonts register:aFont. |
|
5504 |
! |
|
5505 |
||
5506 |
unregisterFont:aFont |
|
5507 |
deviceFonts unregister:aFont. |
|
5508 |
! ! |
|
5509 |
||
2351 | 5510 |
!WinPrinterContext::WinPrinterGraphicContext class methodsFor:'documentation'! |
5511 |
||
5512 |
documentation |
|
5513 |
" |
|
5514 |
The class is simular to the PSGraphicsContext. It implements a |
|
5515 |
'what you see is what you get' interface - all is scaled dependent |
|
5516 |
on the current screen resolution |
|
5517 |
||
2354 | 5518 |
supports margin, clipping ... |
2351 | 5519 |
" |
5520 |
! |
|
5521 |
||
5522 |
examples |
|
5523 |
" |
|
5524 |
[exBegin] |
|
5525 |
|gc font| |
|
5526 |
||
5527 |
gc := WinPrinterContext openGraphicContext. |
|
5528 |
gc isNil ifTrue:[^ self ]. |
|
5529 |
||
5530 |
[ |
|
5531 |
gc startPrintJob:'Test'. |
|
5532 |
gc paint:(Color black). |
|
5533 |
gc displayLineFromX:10 y:40 toX:100 y:40. |
|
5534 |
font := (Font family:'helvetica' face:'roman' style:'bold' size:16) onDevice:(gc device). |
|
5535 |
||
5536 |
gc font:font. |
|
5537 |
gc paint:(Color red). |
|
5538 |
gc displayString:'hallo' x:10 y:(40 + font ascent). |
|
5539 |
||
5540 |
gc paint:(Color black). |
|
5541 |
gc displayLineFromX:10 y:(40 + font height) toX:100 y:(40 + font height). |
|
5542 |
] ensure:[ |
|
5543 |
gc close. |
|
5544 |
]. |
|
5545 |
[exEnd] |
|
5546 |
||
5547 |
" |
|
5548 |
! ! |
|
5549 |
||
2353 | 5550 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'accessing dimensions'! |
5551 |
||
5552 |
bottomMargin |
|
2354 | 5553 |
"return the papers bottom margin measured in pixels" |
5554 |
||
5555 |
^ 50 |
|
2353 | 5556 |
! |
5557 |
||
5558 |
leftMargin |
|
2354 | 5559 |
"return the papers left margin measured in pixels" |
5560 |
||
5561 |
^ 50 |
|
2353 | 5562 |
! |
5563 |
||
5564 |
rightMargin |
|
2354 | 5565 |
"return the papers right margin measured in pixels" |
5566 |
||
5567 |
^ 50 |
|
2353 | 5568 |
! |
5569 |
||
5570 |
topMargin |
|
2354 | 5571 |
"return the papers top margin measured in pixels" |
5572 |
||
5573 |
^ 50 |
|
2353 | 5574 |
! ! |
5575 |
||
2356 | 5576 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'accessing-hooks'! |
5577 |
||
2357
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5578 |
pageCounter |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5579 |
"answer the current page number" |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5580 |
|
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5581 |
pageCounter ~~ 0 ifTrue:[^ pageCounter]. |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5582 |
^ 1 |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5583 |
! |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5584 |
|
2356 | 5585 |
pageNumberFormat:aFormatString |
5586 |
"set the pageNumber format - the default is 'page %1'" |
|
5587 |
||
5588 |
pageNumberFormat := aFormatString ? '' |
|
5589 |
! |
|
5590 |
||
5591 |
printPageNumbers:aBoolean |
|
5592 |
"enable/disable printing of page numbers - the default is on" |
|
5593 |
||
5594 |
printPageNumbers := aBoolean. |
|
5595 |
! ! |
|
5596 |
||
2351 | 5597 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'accessing-transformation'! |
5598 |
||
2354 | 5599 |
clippingRectangle:aRectangle |
5600 |
|tranlate extent lft rgt top bot| |
|
5601 |
||
5602 |
tranlate := self translation negated asPoint. |
|
5603 |
extent := self extent. |
|
5604 |
||
5605 |
lft := tranlate x. |
|
5606 |
top := tranlate y. |
|
5607 |
rgt := lft + extent x. |
|
5608 |
bot := top + extent y. |
|
5609 |
||
5610 |
aRectangle notNil ifTrue:[ |
|
5611 |
lft := lft max:aRectangle left. |
|
5612 |
top := top max:aRectangle top. |
|
5613 |
rgt := rgt min:aRectangle right. |
|
5614 |
bot := bot min:aRectangle bottom. |
|
5615 |
]. |
|
5616 |
super clippingRectangle:(Rectangle left:lft top:top right:rgt bottom:bot). |
|
5617 |
! |
|
5618 |
||
2351 | 5619 |
scale |
5620 |
"answer the scale excluding the fontScale factor" |
|
5621 |
||
5622 |
^ super scale / fontScale |
|
5623 |
! |
|
5624 |
||
5625 |
scale:aScale |
|
5626 |
"set the scale and add the fontScale factor" |
|
5627 |
||
5628 |
super scale:(fontScale * (aScale ? 1.0)). |
|
5629 |
! |
|
5630 |
||
5631 |
transformation |
|
5632 |
"answer the transformation excluding the fontScale factor" |
|
5633 |
||
5634 |
^ WindowingTransformation scale:(self scale) |
|
5635 |
translation:(self translation). |
|
5636 |
! |
|
5637 |
||
5638 |
transformation:aTransformation |
|
5639 |
"set the transformation and add the fontScale factor" |
|
5640 |
||
5641 |
|s t| |
|
5642 |
||
5643 |
aTransformation notNil ifTrue:[ |
|
5644 |
s := aTransformation scale. |
|
5645 |
t := aTransformation translation. |
|
5646 |
]. |
|
5647 |
self scale:s. |
|
5648 |
self translation:t. |
|
5649 |
! |
|
5650 |
||
5651 |
translateBy:aTranslation |
|
5652 |
"set the translation and add the fontScale factor" |
|
5653 |
||
5654 |
aTranslation isNil ifTrue:[^ self]. |
|
5655 |
self translation:( self translation + (self scale * aTranslation)). |
|
5656 |
! |
|
5657 |
||
5658 |
translation |
|
5659 |
"answer the translation excluding the fontScale factor" |
|
5660 |
||
2354 | 5661 |
|margin trans| |
5662 |
||
5663 |
margin := Point x:(self leftMargin) y:(self topMargin). |
|
5664 |
trans := (super translation / fontScale) rounded. |
|
5665 |
||
5666 |
^ trans - margin |
|
2351 | 5667 |
! |
5668 |
||
5669 |
translation:aTranslation |
|
5670 |
"set the translation and add the fontScale factor" |
|
5671 |
||
2354 | 5672 |
|trans| |
5673 |
||
5674 |
trans := Point x:(self leftMargin) y:(self topMargin). |
|
5675 |
||
5676 |
aTranslation notNil ifTrue:[ |
|
5677 |
trans := trans + aTranslation. |
|
5678 |
]. |
|
5679 |
||
5680 |
super translation:((trans * fontScale) rounded). |
|
2351 | 5681 |
! ! |
5682 |
||
5683 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'drawing strings'! |
|
5684 |
||
5685 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y |
|
5686 |
self displayString:aString from:index1 to:index2 x:x y:y. |
|
5687 |
! |
|
5688 |
||
5689 |
displayOpaqueString:aString x:x y:y |
|
5690 |
|end| |
|
5691 |
||
5692 |
end := aString size. |
|
5693 |
||
5694 |
end ~~ 0 ifTrue:[ |
|
5695 |
self displayOpaqueString:aString from:1 to:end x:x y:y. |
|
5696 |
]. |
|
5697 |
! |
|
5698 |
||
5699 |
displayString:aString from:index1 to:index2 x:x y:y |
|
5700 |
"setup the special scale for strings before drawing" |
|
5701 |
||
5702 |
|tscale fscale yFont xFont| |
|
5703 |
||
5704 |
index2 < index1 ifTrue:[^ self]. |
|
5705 |
||
5706 |
transformation isNil ifTrue:[ |
|
2354 | 5707 |
self initTransformation. |
2351 | 5708 |
]. |
5709 |
tscale := transformation scale. |
|
5710 |
fscale := tscale / fontScale. |
|
5711 |
||
5712 |
xFont := x * fontScale x. |
|
5713 |
yFont := (y - font ascent) * fontScale y. "/ MM_TEXT - Ursprung liegt oben links |
|
5714 |
||
5715 |
transformation scale:fscale. |
|
5716 |
||
5717 |
super displayString:aString from:index1 to:index2 |
|
5718 |
x:xFont truncated |
|
5719 |
y:yFont truncated. |
|
5720 |
||
5721 |
transformation scale:tscale. |
|
5722 |
! |
|
5723 |
||
5724 |
displayString:aString x:x y:y |
|
5725 |
|end| |
|
5726 |
||
5727 |
end := aString size. |
|
5728 |
||
5729 |
end ~~ 0 ifTrue:[ |
|
5730 |
self displayString:aString from:1 to:end x:x y:y. |
|
5731 |
]. |
|
5732 |
! |
|
5733 |
||
5734 |
displayString:aString x:x y:y angle:drawAngle opaque:opaque |
|
5735 |
"angles other than 0 is not yet supported" |
|
5736 |
||
5737 |
|angle| |
|
5738 |
||
5739 |
angle := drawAngle. |
|
5740 |
||
5741 |
angle >= 360 ifTrue:[ |
|
5742 |
angle := angle - (((angle // 360)) * 360) |
|
5743 |
] ifFalse:[ |
|
5744 |
angle < 0 ifTrue:[ |
|
5745 |
angle := angle - (((angle // 360)) * 360). |
|
5746 |
angle := angle + 360. |
|
5747 |
angle >= 360 ifTrue:[ |
|
5748 |
angle := angle - (((angle // 360)) * 360) |
|
5749 |
] |
|
5750 |
]. |
|
5751 |
]. |
|
5752 |
angle == 0 ifTrue:[ |
|
5753 |
super displayString:aString x:x y:y angle:drawAngle opaque:opaque. |
|
5754 |
]. |
|
5755 |
! ! |
|
5756 |
||
5757 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'font stuff'! |
|
5758 |
||
5759 |
fontMetricsOf:fontId |
|
5760 |
"after retrieving the metrics, we have to scale the information" |
|
5761 |
||
5762 |
|metrics| |
|
5763 |
||
5764 |
metrics := super fontMetricsOf:fontId. |
|
5765 |
metrics isNil ifTrue:[^ nil ]. |
|
5766 |
||
5767 |
metrics ascent:((metrics ascent / fontScale y) rounded) |
|
5768 |
descent:((metrics descent / fontScale y) rounded + 1) |
|
5769 |
maxAscent:((metrics maxAscent / fontScale y) rounded) |
|
5770 |
maxDescent:((metrics maxDescent / fontScale y) rounded + 1) |
|
5771 |
minWidth:((metrics minWidth / fontScale x) rounded) |
|
5772 |
maxWidth:((metrics maxWidth / fontScale x) rounded) |
|
5773 |
avgWidth:((metrics averageWidth / fontScale x) rounded). |
|
5774 |
||
5775 |
^ metrics |
|
5776 |
! |
|
5777 |
||
5778 |
getFontWithFoundry:foundry family:family weight:weight |
|
5779 |
slant:slant spacing:spc pixelSize:pixelSize size:pointSize |
|
5780 |
registry:registry encoding:encoding |
|
5781 |
||
5782 |
"compute the pixels dependent on the Screen current resolution" |
|
5783 |
||
5784 |
|psize| |
|
5785 |
||
5786 |
psize := pixelSize. |
|
5787 |
||
5788 |
psize isNil ifTrue:[ |
|
5789 |
psize := (pointSize * (self getLogicalPixelSizeY) / (Screen current getLogicalPixelSizeY)) rounded. |
|
5790 |
]. |
|
5791 |
||
5792 |
^ super getFontWithFoundry:foundry family:family weight:weight |
|
5793 |
slant:slant spacing:spc pixelSize:psize size:pointSize |
|
5794 |
registry:registry encoding:encoding |
|
5795 |
! |
|
5796 |
||
2356 | 5797 |
titleFont |
2357
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5798 |
"answer the font used for displaying page numbers..." |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5799 |
|
2356 | 5800 |
titleFont isNil ifTrue:[ |
5801 |
titleFont := Font family:'helvetica' face:'medium' style:'roman' size:10. |
|
5802 |
titleFont := titleFont onDevice:(self device). |
|
5803 |
]. |
|
5804 |
^ titleFont |
|
5805 |
! |
|
5806 |
||
2357
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5807 |
titleFont:aFont |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5808 |
"set the font used for displaying page numbers..." |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5809 |
|
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5810 |
(aFont notNil and:[aFont ~= titleFont]) ifTrue:[ |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5811 |
titleFont := aFont onDevice:(self device). |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5812 |
]. |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5813 |
! |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5814 |
|
2351 | 5815 |
widthOf:aString from:index1 to:index2 inFont:aFontId |
5816 |
"after retrieving the width, we have to scale the width" |
|
5817 |
||
5818 |
|w| |
|
5819 |
||
5820 |
w := super widthOf:aString from:index1 to:index2 inFont:aFontId. |
|
5821 |
w := (w / fontScale x) rounded. |
|
5822 |
^ w |
|
5823 |
! ! |
|
5824 |
||
5825 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'initialization & release'! |
|
5826 |
||
5827 |
close |
|
5828 |
"compatible with PSGraphicsContext" |
|
5829 |
||
5830 |
self endPrintJob. |
|
5831 |
! |
|
5832 |
||
5833 |
initExtent |
|
5834 |
"scale the extent" |
|
5835 |
||
2354 | 5836 |
fontScale := self resolution / Screen current resolution. |
5837 |
||
5838 |
width := (self printerWidthArea / fontScale x) rounded. |
|
5839 |
width := width - self leftMargin - self rightMargin. |
|
5840 |
||
5841 |
height := (self printerHeightArea / fontScale y) rounded. |
|
5842 |
height := height - self topMargin - self bottomMargin. |
|
5843 |
||
5844 |
self initTransformation. |
|
5845 |
! |
|
5846 |
||
5847 |
initTransformation |
|
5848 |
|margin| |
|
5849 |
||
5850 |
transformation isNil ifTrue:[ |
|
5851 |
margin := Point x:(self leftMargin) y:(self topMargin). |
|
5852 |
||
5853 |
transformation := WindowingTransformation scale:fontScale |
|
5854 |
translation:(margin * fontScale). |
|
2351 | 5855 |
]. |
5856 |
! |
|
5857 |
||
5858 |
initialize |
|
5859 |
super initialize. |
|
5860 |
||
5861 |
pageCounter := 0. |
|
5862 |
needsEndOfPage := false. |
|
2356 | 5863 |
printPageNumbers := true. |
5864 |
||
5865 |
Language == #de ifTrue:[ pageNumberFormat := 'Seite %1' ] |
|
5866 |
ifFalse:[ pageNumberFormat := 'page %1' ]. |
|
2351 | 5867 |
! ! |
5868 |
||
5869 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'printing process'! |
|
5870 |
||
2356 | 5871 |
displayTitleDo:aNoneArgAction |
5872 |
||
5873 |
|oldClip oldTrans oldFont| |
|
5874 |
||
2357
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5875 |
oldClip := clipRect. |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5876 |
oldClip notNil ifTrue:[ self deviceClippingRectangle:nil ]. |
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5877 |
|
2356 | 5878 |
oldTrans := self translation. |
5879 |
oldFont := font. |
|
5880 |
||
5881 |
self font:(self titleFont). |
|
5882 |
self translation:0. |
|
5883 |
||
5884 |
aNoneArgAction value. |
|
5885 |
||
5886 |
self translation:oldTrans. |
|
5887 |
oldFont notNil ifTrue:[ self font:oldFont ]. |
|
2357
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5888 |
oldClip notNil ifTrue:[ self deviceClippingRectangle:oldClip ]. |
2356 | 5889 |
! |
5890 |
||
2351 | 5891 |
endPage |
2354 | 5892 |
"ends the current page |
5893 |
if the current page is already closed by endPage, the request will be ignored" |
|
5894 |
||
2356 | 5895 |
|s| |
5896 |
||
5897 |
needsEndOfPage ifFalse:[ |
|
5898 |
^ self |
|
5899 |
]. |
|
2351 | 5900 |
needsEndOfPage := false. |
2356 | 5901 |
|
5902 |
printPageNumbers == true ifTrue:[ |
|
5903 |
self displayTitleDo:[ |
|
5904 |
s := pageNumberFormat bindWith:pageCounter. |
|
5905 |
||
5906 |
self displayString:s |
|
5907 |
x:(self extent x - (font widthOf:s)) |
|
5908 |
y:(self extent y + (font ascent)). |
|
5909 |
] |
|
5910 |
]. |
|
2351 | 5911 |
super endPage. |
5912 |
! |
|
5913 |
||
5914 |
startPage |
|
2354 | 5915 |
"starts a new page |
5916 |
if the current page is not closed by endPage, a endPage is forward to the device" |
|
5917 |
||
2351 | 5918 |
needsEndOfPage ifTrue:[ |
5919 |
self endPage. |
|
5920 |
]. |
|
5921 |
super startPage. |
|
5922 |
needsEndOfPage := true. |
|
5923 |
pageCounter := pageCounter + 1. |
|
5924 |
! ! |
|
5925 |
||
5926 |
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'queries'! |
|
5927 |
||
5928 |
pixelPerInch |
|
5929 |
^ Point x:(self pixelsPerInchOfScreenWidth) |
|
5930 |
y:(self pixelsPerInchOfScreenHeight). |
|
5931 |
! |
|
5932 |
||
5933 |
resolution |
|
5934 |
^ self pixelPerInch |
|
5935 |
! ! |
|
5936 |
||
2299 | 5937 |
!WinPrinterContext class methodsFor:'documentation'! |
5938 |
||
5939 |
version |
|
2357
918859a27b27
accessing pageCounter and titleFont used for pageNumbers...
ca
parents:
2356
diff
changeset
|
5940 |
^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.30 2007-11-23 13:06:49 ca Exp $' |
2299 | 5941 |
! ! |