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