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