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