author | Claus Gittinger <cg@exept.de> |
Tue, 23 Apr 1996 10:48:32 +0200 | |
changeset 590 | fc18ba574a4d |
parent 589 | 2c119dc32f8c |
child 591 | d071af7739db |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
78 | 3 |
All Rights Reserved |
0 | 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 |
||
13 |
DeviceDrawable subclass:#Form |
|
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
14 |
instanceVariableNames:'depth localColorMap offset data fileName' |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
15 |
classVariableNames:'VeryLightGreyForm LightGreyForm GreyForm DarkGreyForm |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
16 |
VeryDarkGreyForm AdditionalBitmapDirectoryNames |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
17 |
BlackAndWhiteColorMap DitherPatternArray' |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
18 |
poolDictionaries:'' |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
19 |
category:'Graphics-Display Objects' |
0 | 20 |
! |
21 |
||
46 | 22 |
!Form class methodsFor:'documentation'! |
23 |
||
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
78 | 27 |
All Rights Reserved |
0 | 28 |
|
46 | 29 |
This software is furnished under a license and may be used |
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
Instances of this class represent forms (i.e. bit- and pixmaps) |
|
590 | 41 |
which can be created on a drawing device. |
42 |
In X, these device resources are XPixmaps. |
|
46 | 43 |
Not all devices will support forms. |
134 | 44 |
|
45 |
NOTICE: |
|
589 | 46 |
the Form class is a historic leftover and now only used for real |
47 |
device forms (i.e. on devices which support downloading bitmaps). |
|
590 | 48 |
|
589 | 49 |
In your application, you should always use Image, both for compatibility |
50 |
with ST-80 and for device independence, since Form may not be supported |
|
51 |
by all devices (for example: PostscriptPrinters). |
|
52 |
||
53 |
[See also] |
|
54 |
Image DeviceDrawable |
|
46 | 55 |
" |
56 |
! ! |
|
0 | 57 |
|
58 |
!Form class methodsFor:'initialization'! |
|
59 |
||
60 |
initialize |
|
126 | 61 |
"initialize set of dictionaries to look for bitmaps" |
0 | 62 |
|
63 |
AdditionalBitmapDirectoryNames isNil ifTrue:[ |
|
78 | 64 |
AdditionalBitmapDirectoryNames := #('/usr/lib/X11/bitmaps'). |
0 | 65 |
|
78 | 66 |
"want to be informed when returning from snapshot" |
67 |
ObjectMemory addDependent:self. |
|
0 | 68 |
] |
69 |
! |
|
70 |
||
71 |
reinitializeAllOn:aDevice |
|
72 |
"recreate all forms on aDevice; called by Workstation, to |
|
73 |
have all background bitmaps at hand, when views are restored" |
|
74 |
||
127 | 75 |
Lobby do:[:aDrawable | |
76 |
(aDrawable device == aDevice) ifTrue:[ |
|
77 |
aDrawable isForm ifTrue:[ |
|
126 | 78 |
"now, try to recreate it" |
127 | 79 |
aDrawable recreate. |
126 | 80 |
] |
78 | 81 |
] |
0 | 82 |
] |
83 |
! |
|
84 |
||
85 |
update:something |
|
86 |
"sent just before snapOut and just after a snapIn" |
|
87 |
||
88 |
(something == #save) ifTrue:[ |
|
78 | 89 |
"get all bits from the device into saveable arrays" |
127 | 90 |
Lobby do:[:aDrawable | |
91 |
aDrawable isForm ifTrue:[ |
|
92 |
aDrawable getBits |
|
126 | 93 |
] |
78 | 94 |
] |
0 | 95 |
]. |
96 |
(something == #restarted) ifTrue:[ |
|
78 | 97 |
"remove all left-over device info" |
127 | 98 |
Lobby do:[:aDrawable | |
99 |
aDrawable isForm ifTrue:[ |
|
100 |
aDrawable restored. |
|
162 | 101 |
Lobby registerChange:aDrawable |
126 | 102 |
] |
78 | 103 |
] |
0 | 104 |
] |
105 |
! ! |
|
106 |
||
278 | 107 |
!Form class methodsFor:'instance creation'! |
108 |
||
109 |
black |
|
110 |
"ST80 compatibility; |
|
111 |
in st80, return a black form - here we return black color" |
|
112 |
||
113 |
^ Color black |
|
114 |
! |
|
115 |
||
116 |
darkGray |
|
117 |
"ST80 compatibility; |
|
118 |
in st80, return a darkGrey form - here we return darkGrey color" |
|
119 |
||
120 |
^ Color darkGrey |
|
121 |
! |
|
122 |
||
123 |
darkGrey |
|
124 |
"ST80 compatibility; |
|
125 |
in st80, return a darkGrey form - here we return darkGrey color" |
|
126 |
||
127 |
^ Color darkGrey |
|
128 |
! |
|
129 |
||
130 |
extent:ext |
|
131 |
"create a new, cleared form, take dimensions from ext. |
|
132 |
Smalltalk-80 compatibility" |
|
133 |
||
134 |
|newForm| |
|
135 |
||
136 |
newForm := self width:(ext x) height:(ext y). |
|
137 |
newForm fill:(Color colorId:0). |
|
138 |
newForm paint:(Color colorId:1). |
|
139 |
^ newForm |
|
140 |
! |
|
141 |
||
142 |
extent:ext fromArray:data |
|
143 |
"create a new form, take dimensions from ext, bits from data. |
|
144 |
Smalltalk-80 compatibility." |
|
145 |
||
146 |
^ self width:(ext x) height:(ext y) offset:0@0 fromArray:data |
|
147 |
! |
|
148 |
||
149 |
extent:ext fromArray:data offset:offs |
|
150 |
"create a new form, take dimensions from ext, bits from data. |
|
151 |
Smalltalk-80 compatibility." |
|
152 |
||
153 |
^ self width:(ext x) height:(ext y) offset:offs fromArray:data |
|
154 |
! |
|
155 |
||
156 |
extent:ext offset:anOffset |
|
157 |
"create a new, cleared form, take dimensions from ext. |
|
158 |
Smalltalk-80 compatibility" |
|
159 |
||
160 |
^ (self extent:ext) offset:anOffset. |
|
161 |
! |
|
162 |
||
163 |
gray |
|
164 |
"ST80 compatibility; |
|
165 |
in st80, return a grey form - here we return grey color" |
|
166 |
||
167 |
^ self grey |
|
168 |
! |
|
169 |
||
170 |
grey |
|
171 |
"ST80 compatibility; |
|
172 |
in st80, return a grey form - here we return grey color" |
|
173 |
||
174 |
^ Color grey |
|
175 |
! |
|
176 |
||
177 |
lightGrey |
|
178 |
"ST80 compatibility; |
|
179 |
in st80, return a lightGrey form - here we return lightGrey color" |
|
180 |
||
181 |
^ Color lightGrey |
|
182 |
! |
|
109 | 183 |
|
278 | 184 |
white |
185 |
"ST80 compatibility; |
|
186 |
in st80, return a white form - here we return white color" |
|
187 |
||
188 |
^ Color white |
|
189 |
! |
|
190 |
||
191 |
width:w height:h |
|
192 |
"create a new form on the default device" |
|
193 |
||
194 |
^ (self on:Screen current) width:w height:h |
|
195 |
! |
|
196 |
||
197 |
width:w height:h depth:d |
|
198 |
"create a new form on the default device" |
|
199 |
||
200 |
^ (self on:Screen current) width:w height:h depth:d |
|
201 |
! |
|
202 |
||
203 |
width:w height:h depth:d on:aDevice |
|
204 |
"create a new form with depth d on device, aDevice" |
|
205 |
||
206 |
^ (self on:aDevice) width:w height:h depth:d |
|
207 |
! |
|
208 |
||
209 |
width:w height:h fromArray:anArray |
|
210 |
"create a new form on the default device" |
|
211 |
||
212 |
^ (self on:Screen current) width:w height:h fromArray:anArray |
|
213 |
! |
|
214 |
||
215 |
width:w height:h fromArray:anArray on:aDevice |
|
216 |
"create a new form on device, aDevice and |
|
217 |
initialize the pixels from anArray" |
|
218 |
||
219 |
^ (self on:aDevice) width:w height:h fromArray:anArray |
|
220 |
! |
|
109 | 221 |
|
278 | 222 |
width:w height:h offset:offs fromArray:anArray |
223 |
"create a new form on the default device" |
|
224 |
||
225 |
^ (self on:Screen current) width:w height:h offset:offs fromArray:anArray |
|
226 |
! |
|
227 |
||
228 |
width:w height:h on:aDevice |
|
229 |
"create a new form on device, aDevice; depth is what device likes most" |
|
230 |
||
231 |
^ (self on:aDevice) width:w height:h |
|
232 |
! ! |
|
233 |
||
234 |
!Form class methodsFor:'ST-80 compatibility'! |
|
235 |
||
236 |
and |
|
237 |
"return a constant usable as bitblt-combinationrule" |
|
238 |
||
239 |
^ #and |
|
240 |
! |
|
241 |
||
242 |
over |
|
243 |
"return a constant usable as bitblt-combinationrule" |
|
244 |
||
245 |
^ #copy |
|
246 |
! |
|
247 |
||
248 |
paint |
|
249 |
"return a constant usable as bitblt-combinationrule" |
|
250 |
||
251 |
^ #copy |
|
252 |
! |
|
253 |
||
254 |
reverse |
|
255 |
"return a constant usable as bitblt-combinationrule" |
|
256 |
||
257 |
^ #xor |
|
258 |
! |
|
259 |
||
260 |
under |
|
261 |
"return a constant usable as bitblt-combinationrule" |
|
262 |
||
263 |
^ #or |
|
109 | 264 |
! ! |
265 |
||
12 | 266 |
!Form class methodsFor:'cleanup'! |
267 |
||
268 |
lowSpaceCleanup |
|
269 |
"cleanup in low-memory situations" |
|
270 |
||
54 | 271 |
DitherPatternArray := nil |
12 | 272 |
! ! |
273 |
||
0 | 274 |
!Form class methodsFor:'file search'! |
275 |
||
276 |
findBitmapFile:fileName |
|
277 |
"find the bitmap file in one of the standard places; |
|
278 |
return the pathName or nil" |
|
279 |
||
280 |
|aStream path| |
|
281 |
||
282 |
((fileName at:1) == $/) ifTrue:[^ fileName]. |
|
283 |
(fileName startsWith:'../') ifTrue:[^ fileName]. |
|
284 |
(fileName startsWith:'./') ifTrue:[^ fileName]. |
|
127 | 285 |
fileName asFilename exists ifTrue:[^ fileName]. |
0 | 286 |
|
134 | 287 |
aStream := Smalltalk bitmapFileStreamFor:fileName. |
0 | 288 |
aStream notNil ifTrue:[ |
78 | 289 |
path := aStream pathName. |
290 |
aStream close. |
|
291 |
^ path |
|
0 | 292 |
]. |
293 |
AdditionalBitmapDirectoryNames notNil ifTrue:[ |
|
78 | 294 |
AdditionalBitmapDirectoryNames do:[:aPath | |
295 |
path := aPath , '/' , fileName. |
|
296 |
(OperatingSystem isReadable:path) ifTrue:[ |
|
297 |
^ path |
|
298 |
] |
|
299 |
] |
|
0 | 300 |
]. |
301 |
^ nil |
|
302 |
! ! |
|
303 |
||
278 | 304 |
!Form class methodsFor:'fileIn/Out'! |
54 | 305 |
|
278 | 306 |
fromFile:filename |
307 |
"create a new form taking the bits from a file on the default device. |
|
308 |
WARNING: |
|
309 |
Please do no longer use this, since it will not work |
|
310 |
correctly in multi-display applications (creates the form on the |
|
311 |
default Display). |
|
312 |
Use #fromFile:on: and pass the devive as argument." |
|
0 | 313 |
|
278 | 314 |
^ self fromFile:filename on:Screen current |
0 | 315 |
! |
316 |
||
278 | 317 |
fromFile:filename on:aDevice |
318 |
"create a new form on device, aDevice and |
|
319 |
initialize the pixels from the file filename" |
|
0 | 320 |
|
278 | 321 |
^ (self on:aDevice) readFromFile:filename |
89 | 322 |
! |
323 |
||
278 | 324 |
fromFile:filename resolution:dpi |
325 |
"create a new form taking the bits from a file on the default device |
|
326 |
the data in the file is assumed to be for dpi resolution; |
|
327 |
if it is different from the displays resolution, magnify or |
|
328 |
shrink the picture (but only in integer magnification steps). |
|
329 |
WARNING: |
|
330 |
Please do no longer use this, since it will not work |
|
331 |
correctly in multi-display applications (creates the form on the |
|
332 |
default Display). |
|
333 |
Use #fromFile:resolution:on: and pass the devive as argument." |
|
98 | 334 |
|
278 | 335 |
^ self fromFile:filename resolution:dpi on:Screen current |
0 | 336 |
! |
337 |
||
278 | 338 |
fromFile:filename resolution:dpi on:aDevice |
339 |
"create a new form on device, aDevice and |
|
340 |
initialize the pixels from the file filename; |
|
341 |
the data in the file is assumed to be for dpi resolution; |
|
342 |
if it is different from the displays resolution, magnify or |
|
343 |
shrink the picture (but only in integer magnification steps)" |
|
0 | 344 |
|
278 | 345 |
^ (self on:aDevice) readFromFile:filename resolution:dpi |
0 | 346 |
! |
347 |
||
278 | 348 |
readFrom:fileName |
349 |
"same as Form>>fromFile: - for ST-80 compatibility. |
|
350 |
WARNING: |
|
351 |
Please do no longer use this, since it will not work |
|
352 |
correctly in multi-display applications (creates the form on the |
|
353 |
default Display). |
|
354 |
Use #fromFile:on: and pass the devive as argument." |
|
0 | 355 |
|
278 | 356 |
^ self fromFile:fileName on:Screen current |
0 | 357 |
! ! |
358 |
||
359 |
!Form class methodsFor:'patterns'! |
|
360 |
||
278 | 361 |
darkGreyFormBits |
362 |
"return a pattern usable to simulate darkGray on monochrome device" |
|
0 | 363 |
|
278 | 364 |
^ #(2r10111011 |
365 |
2r11101110 |
|
366 |
2r10111011 |
|
367 |
2r11101110) |
|
0 | 368 |
! |
369 |
||
278 | 370 |
ditherBitsForXin64:x |
371 |
"return a dither pattern for x/64; x in 1..63" |
|
372 |
||
588 | 373 |
^ #( |
374 |
||
375 |
"/ 1in64 |
|
376 |
||
377 |
#[2r10000000 |
|
378 |
2r00000000 |
|
379 |
2r00000000 |
|
380 |
2r00000000 |
|
381 |
2r00000000 |
|
382 |
2r00000000 |
|
383 |
2r00000000 |
|
384 |
2r00000000] |
|
385 |
||
386 |
"/ 2in64 |
|
387 |
||
388 |
#[2r10000000 |
|
389 |
2r00000000 |
|
390 |
2r00000000 |
|
391 |
2r00000000 |
|
392 |
2r00001000 |
|
393 |
2r00000000 |
|
394 |
2r00000000 |
|
395 |
2r00000000] |
|
396 |
||
397 |
"/ 3in64 |
|
398 |
||
399 |
#[2r10000000 |
|
400 |
2r00000000 |
|
401 |
2r00000000 |
|
402 |
2r00000000 |
|
403 |
2r10001000 |
|
404 |
2r00000000 |
|
405 |
2r00000000 |
|
406 |
2r00000000] |
|
407 |
"/ 4in64 |
|
408 |
||
409 |
#[2r10001000 |
|
410 |
2r00000000 |
|
411 |
2r00000000 |
|
412 |
2r00000000 |
|
413 |
2r10001000 |
|
414 |
2r00000000 |
|
415 |
2r00000000 |
|
416 |
2r00000000] |
|
417 |
||
418 |
"/ 5in64 |
|
419 |
||
420 |
#[2r10001000 |
|
421 |
2r00000000 |
|
422 |
2r00000000 |
|
423 |
2r00000000 |
|
424 |
2r10001000 |
|
425 |
2r00000000 |
|
426 |
2r00000010 |
|
427 |
2r00000000] |
|
428 |
||
429 |
"/ 6in64 |
|
430 |
||
431 |
#[2r10001000 |
|
432 |
2r00000000 |
|
433 |
2r00100000 |
|
434 |
2r00000000 |
|
435 |
2r10001000 |
|
436 |
2r00000000 |
|
437 |
2r00000010 |
|
438 |
2r00000000] |
|
439 |
||
440 |
"/ 7in64 |
|
441 |
||
442 |
#[2r10001000 |
|
443 |
2r00000000 |
|
444 |
2r00100010 |
|
445 |
2r00000000 |
|
446 |
2r10001000 |
|
447 |
2r00000000 |
|
448 |
2r00000010 |
|
449 |
2r00000000] |
|
450 |
||
451 |
"/ 8in64 |
|
452 |
||
453 |
#[2r10001000 |
|
454 |
2r00000000 |
|
455 |
2r00100010 |
|
456 |
2r00000000 |
|
457 |
2r10001000 |
|
458 |
2r00000000 |
|
459 |
2r00100010 |
|
460 |
2r00000000] |
|
461 |
||
462 |
"/ 9in64 |
|
463 |
||
464 |
#[2r10001000 |
|
465 |
2r00000000 |
|
466 |
2r00100010 |
|
467 |
2r00000000 |
|
468 |
2r10001000 |
|
469 |
2r00000000 |
|
470 |
2r10100010 |
|
471 |
2r00000000] |
|
472 |
||
473 |
/* 10 */ |
|
474 |
#[2r10001000 |
|
475 |
2r00000000 |
|
476 |
2r00101010 |
|
477 |
2r00000000 |
|
478 |
2r10001000 |
|
479 |
2r00000000 |
|
480 |
2r10100010 |
|
481 |
2r00000000] |
|
482 |
||
483 |
"/ 11in64 |
|
484 |
||
485 |
#[2r10001000 |
|
486 |
2r00000000 |
|
487 |
2r00101010 |
|
488 |
2r00000000 |
|
489 |
2r10001000 |
|
490 |
2r00000000 |
|
491 |
2r10101010 |
|
492 |
2r00000000] |
|
493 |
||
494 |
"/ 12in64 |
|
495 |
||
496 |
#[2r10001000 |
|
497 |
2r00000000 |
|
498 |
2r10101010 |
|
499 |
2r00000000 |
|
500 |
2r10001000 |
|
501 |
2r00000000 |
|
502 |
2r10101010 |
|
503 |
2r00000000] |
|
504 |
||
505 |
"/ 13in64 |
|
506 |
||
507 |
#[2r10001000 |
|
508 |
2r00000000 |
|
509 |
2r10101010 |
|
510 |
2r00000000 |
|
511 |
2r10101000 |
|
512 |
2r00000000 |
|
513 |
2r10101010 |
|
514 |
2r00000000] |
|
515 |
||
516 |
"/ 14in64 |
|
517 |
||
518 |
#[2r10001010 |
|
519 |
2r00000000 |
|
520 |
2r10101010 |
|
521 |
2r00000000 |
|
522 |
2r10101000 |
|
523 |
2r00000000 |
|
524 |
2r10101010 |
|
525 |
2r00000000] |
|
526 |
||
527 |
"/ 15in64 |
|
528 |
||
529 |
#[2r10001010 |
|
530 |
2r00000000 |
|
531 |
2r10101010 |
|
532 |
2r00000000 |
|
533 |
2r10101010 |
|
534 |
2r00000000 |
|
535 |
2r10101010 |
|
536 |
2r00000000] |
|
537 |
||
538 |
"/ 16in64 |
|
539 |
||
540 |
#[2r10101010 |
|
541 |
2r00000000 |
|
542 |
2r10101010 |
|
543 |
2r00000000 |
|
544 |
2r10101010 |
|
545 |
2r00000000 |
|
546 |
2r10101010 |
|
547 |
2r00000000] |
|
548 |
||
549 |
"/ 17in64 |
|
550 |
||
551 |
#[2r10101010 |
|
552 |
2r01000000 |
|
553 |
2r10101010 |
|
554 |
2r00000000 |
|
555 |
2r10101010 |
|
556 |
2r00000000 |
|
557 |
2r10101010 |
|
558 |
2r00000000] |
|
559 |
||
560 |
"/ 18in64 |
|
561 |
||
562 |
#[2r10101010 |
|
563 |
2r01000000 |
|
564 |
2r10101010 |
|
565 |
2r00000000 |
|
566 |
2r10101010 |
|
567 |
2r00000100 |
|
568 |
2r10101010 |
|
569 |
2r00000000] |
|
570 |
||
571 |
"/ 19in64 |
|
572 |
||
573 |
#[2r10101010 |
|
574 |
2r01000000 |
|
575 |
2r10101010 |
|
576 |
2r00000000 |
|
577 |
2r10101010 |
|
578 |
2r01000100 |
|
579 |
2r10101010 |
|
580 |
2r00000000] |
|
581 |
||
582 |
"/ 20in64 |
|
583 |
||
584 |
#[2r10101010 |
|
585 |
2r01000100 |
|
586 |
2r10101010 |
|
587 |
2r00000000 |
|
588 |
2r10101010 |
|
589 |
2r01000100 |
|
590 |
2r10101010 |
|
591 |
2r00000000] |
|
592 |
||
593 |
"/ 21in64 |
|
594 |
||
595 |
#[2r10101010 |
|
596 |
2r01000100 |
|
597 |
2r10101010 |
|
598 |
2r00000000 |
|
599 |
2r10101010 |
|
600 |
2r01000100 |
|
601 |
2r10101010 |
|
602 |
2r00000001] |
|
603 |
||
604 |
"/ 22in64 |
|
605 |
||
606 |
#[2r10101010 |
|
607 |
2r01000100 |
|
608 |
2r10101010 |
|
609 |
2r00010000 |
|
610 |
2r10101010 |
|
611 |
2r01000100 |
|
612 |
2r10101010 |
|
613 |
2r00000001] |
|
614 |
||
615 |
"/ 23in64 |
|
616 |
||
617 |
#[2r10101010 |
|
618 |
2r01000100 |
|
619 |
2r10101010 |
|
620 |
2r00010001 |
|
621 |
2r10101010 |
|
622 |
2r01000100 |
|
623 |
2r10101010 |
|
624 |
2r00000001] |
|
625 |
||
626 |
"/ 24in64 |
|
627 |
||
628 |
#[2r10101010 |
|
629 |
2r01000100 |
|
630 |
2r10101010 |
|
631 |
2r00010001 |
|
632 |
2r10101010 |
|
633 |
2r01000100 |
|
634 |
2r10101010 |
|
635 |
2r00010001] |
|
636 |
||
637 |
"/ 25in64 |
|
638 |
||
639 |
#[2r10101010 |
|
640 |
2r01000100 |
|
641 |
2r10101010 |
|
642 |
2r00010001 |
|
643 |
2r10101010 |
|
644 |
2r01000100 |
|
645 |
2r10101010 |
|
646 |
2r01010001] |
|
647 |
||
648 |
"/ 26in64 |
|
649 |
||
650 |
#[2r10101010 |
|
651 |
2r01000100 |
|
652 |
2r10101010 |
|
653 |
2r00010101 |
|
654 |
2r10101010 |
|
655 |
2r01000100 |
|
656 |
2r10101010 |
|
657 |
2r01010001] |
|
658 |
||
659 |
"/ 27in64 |
|
660 |
||
661 |
#[2r10101010 |
|
662 |
2r01000100 |
|
663 |
2r10101010 |
|
664 |
2r00010101 |
|
665 |
2r10101010 |
|
666 |
2r01000100 |
|
667 |
2r10101010 |
|
668 |
2r01010101] |
|
669 |
||
670 |
"/ 28in64 |
|
671 |
||
672 |
#[2r10101010 |
|
673 |
2r01000100 |
|
674 |
2r10101010 |
|
675 |
2r01010101 |
|
676 |
2r10101010 |
|
677 |
2r01000100 |
|
678 |
2r10101010 |
|
679 |
2r01010101] |
|
680 |
||
681 |
"/ 29in64 |
|
682 |
||
683 |
#[2r10101010 |
|
684 |
2r01000100 |
|
685 |
2r10101010 |
|
686 |
2r01010101 |
|
687 |
2r10101010 |
|
688 |
2r01010100 |
|
689 |
2r10101010 |
|
690 |
2r01010101] |
|
691 |
||
692 |
"/ 30in64 |
|
693 |
||
694 |
#[2r10101010 |
|
695 |
2r01000101 |
|
696 |
2r10101010 |
|
697 |
2r01010101 |
|
698 |
2r10101010 |
|
699 |
2r01010100 |
|
700 |
2r10101010 |
|
701 |
2r01010101] |
|
702 |
||
703 |
"/ 31in64 |
|
704 |
||
705 |
#[2r10101010 |
|
706 |
2r01000101 |
|
707 |
2r10101010 |
|
708 |
2r01010101 |
|
709 |
2r10101010 |
|
710 |
2r01010101 |
|
711 |
2r10101010 |
|
712 |
2r01010101] |
|
713 |
||
714 |
"/ 32in64 |
|
278 | 715 |
|
588 | 716 |
#[2r10101010 |
717 |
2r01010101 |
|
718 |
2r10101010 |
|
719 |
2r01010101 |
|
720 |
2r10101010 |
|
721 |
2r01010101 |
|
722 |
2r10101010 |
|
723 |
2r01010101] |
|
724 |
||
725 |
"/ 33in64 |
|
726 |
||
727 |
#[2r11101010 |
|
728 |
2r01010101 |
|
729 |
2r10101010 |
|
730 |
2r01010101 |
|
731 |
2r10101010 |
|
732 |
2r01010101 |
|
733 |
2r10101010 |
|
734 |
2r01010101] |
|
735 |
||
736 |
"/ 34in64 |
|
737 |
||
738 |
#[2r11101010 |
|
739 |
2r01010101 |
|
740 |
2r10101010 |
|
741 |
2r01010101 |
|
742 |
2r10101110 |
|
743 |
2r01010101 |
|
744 |
2r10101010 |
|
745 |
2r01010101] |
|
746 |
||
747 |
"/ 35in64 |
|
748 |
||
749 |
#[2r11101010 |
|
750 |
2r01010101 |
|
751 |
2r10101010 |
|
752 |
2r01010101 |
|
753 |
2r11101110 |
|
754 |
2r01010101 |
|
755 |
2r10101010 |
|
756 |
2r01010101] |
|
757 |
||
758 |
"/ 36in64 |
|
759 |
||
760 |
#[2r11101110 |
|
761 |
2r01010101 |
|
762 |
2r10101010 |
|
763 |
2r01010101 |
|
764 |
2r11101110 |
|
765 |
2r01010101 |
|
766 |
2r10101010 |
|
767 |
2r01010101] |
|
768 |
||
769 |
"/ 37in64 |
|
770 |
||
771 |
#[2r11101110 |
|
772 |
2r01010101 |
|
773 |
2r10101010 |
|
774 |
2r01010101 |
|
775 |
2r11101110 |
|
776 |
2r01010101 |
|
777 |
2r10101011 |
|
778 |
2r01010101] |
|
779 |
||
780 |
"/ 38in64 |
|
781 |
||
782 |
#[2r11101110 |
|
783 |
2r01010101 |
|
784 |
2r10111010 |
|
785 |
2r01010101 |
|
786 |
2r11101110 |
|
787 |
2r01010101 |
|
788 |
2r10101011 |
|
789 |
2r01010101] |
|
790 |
||
791 |
"/ 39in64 |
|
792 |
||
793 |
#[2r11101110 |
|
794 |
2r01010101 |
|
795 |
2r10111011 |
|
796 |
2r01010101 |
|
797 |
2r11101110 |
|
798 |
2r01010101 |
|
799 |
2r10101011 |
|
800 |
2r01010101] |
|
801 |
||
802 |
"/ 40in64 |
|
803 |
||
804 |
#[2r11101110 |
|
805 |
2r01010101 |
|
806 |
2r10111011 |
|
807 |
2r01010101 |
|
808 |
2r11101110 |
|
809 |
2r01010101 |
|
810 |
2r10111011 |
|
811 |
2r01010101] |
|
812 |
||
813 |
"/ 41in64 |
|
814 |
||
815 |
#[2r11101110 |
|
816 |
2r01010101 |
|
817 |
2r10111011 |
|
818 |
2r01010101 |
|
819 |
2r11101110 |
|
820 |
2r01010101 |
|
821 |
2r11111011 |
|
822 |
2r01010101] |
|
823 |
||
824 |
"/ 42in64 |
|
825 |
||
826 |
#[2r11101110 |
|
827 |
2r01010101 |
|
828 |
2r10111111 |
|
829 |
2r01010101 |
|
830 |
2r11101110 |
|
831 |
2r01010101 |
|
832 |
2r11111011 |
|
833 |
2r01010101] |
|
834 |
||
835 |
"/ 43in64 |
|
836 |
||
837 |
#[2r11101110 |
|
838 |
2r01010101 |
|
839 |
2r10111111 |
|
840 |
2r01010101 |
|
841 |
2r11101110 |
|
842 |
2r01010101 |
|
843 |
2r11111111 |
|
844 |
2r01010101] |
|
845 |
||
846 |
"/ 44in64 |
|
847 |
||
848 |
#[2r11101110 |
|
849 |
2r01010101 |
|
850 |
2r11111111 |
|
851 |
2r01010101 |
|
852 |
2r11101110 |
|
853 |
2r01010101 |
|
854 |
2r11111111 |
|
855 |
2r01010101] |
|
856 |
||
857 |
"/ 45in64 |
|
858 |
||
859 |
#[2r11101110 |
|
860 |
2r01010101 |
|
861 |
2r11111111 |
|
862 |
2r01010101 |
|
863 |
2r11111110 |
|
864 |
2r01010101 |
|
865 |
2r11111111 |
|
866 |
2r01010101] |
|
867 |
||
868 |
"/ 46in64 |
|
869 |
||
870 |
#[2r11101111 |
|
871 |
2r01010101 |
|
872 |
2r11111111 |
|
873 |
2r01010101 |
|
874 |
2r11111110 |
|
875 |
2r01010101 |
|
876 |
2r11111111 |
|
877 |
2r01010101] |
|
878 |
||
879 |
"/ 47in64 |
|
880 |
||
881 |
#[2r11101111 |
|
882 |
2r01010101 |
|
883 |
2r11111111 |
|
884 |
2r01010101 |
|
885 |
2r11111111 |
|
886 |
2r01010101 |
|
887 |
2r11111111 |
|
888 |
2r01010101] |
|
889 |
||
890 |
"/ 48in64 |
|
891 |
||
892 |
#[2r11111111 |
|
893 |
2r01010101 |
|
894 |
2r11111111 |
|
895 |
2r01010101 |
|
896 |
2r11111111 |
|
897 |
2r01010101 |
|
898 |
2r11111111 |
|
899 |
2r01010101] |
|
900 |
||
901 |
"/ 49in64 |
|
902 |
||
903 |
#[2r11111111 |
|
904 |
2r01110101 |
|
905 |
2r11111111 |
|
906 |
2r01010101 |
|
907 |
2r11111111 |
|
908 |
2r01010101 |
|
909 |
2r11111111 |
|
910 |
2r01010101] |
|
911 |
||
912 |
"/ 50in64 |
|
913 |
||
914 |
#[2r11111111 |
|
915 |
2r01110101 |
|
916 |
2r11111111 |
|
917 |
2r01010101 |
|
918 |
2r11111111 |
|
919 |
2r01010111 |
|
920 |
2r11111111 |
|
921 |
2r01010101] |
|
922 |
||
923 |
"/ 51in64 |
|
924 |
||
925 |
#[2r11111111 |
|
926 |
2r01110101 |
|
927 |
2r11111111 |
|
928 |
2r01010101 |
|
929 |
2r11111111 |
|
930 |
2r01110111 |
|
931 |
2r11111111 |
|
932 |
2r01010101] |
|
933 |
||
934 |
"/ 52in64 |
|
935 |
||
936 |
#[2r11111111 |
|
937 |
2r01110111 |
|
938 |
2r11111111 |
|
939 |
2r01010101 |
|
940 |
2r11111111 |
|
941 |
2r01110111 |
|
942 |
2r11111111 |
|
943 |
2r01010101] |
|
944 |
||
945 |
"/ 53in64 |
|
946 |
||
947 |
#[2r11111111 |
|
948 |
2r01110111 |
|
949 |
2r11111111 |
|
950 |
2r01010101 |
|
951 |
2r11111111 |
|
952 |
2r01110111 |
|
953 |
2r11111111 |
|
954 |
2r11010101] |
|
955 |
||
956 |
"/ 54in64 |
|
957 |
||
958 |
#[2r11111111 |
|
959 |
2r01110111 |
|
960 |
2r11111111 |
|
961 |
2r01011101 |
|
962 |
2r11111111 |
|
963 |
2r01110111 |
|
964 |
2r11111111 |
|
965 |
2r11010101] |
|
966 |
||
967 |
"/ 55in64 |
|
968 |
||
969 |
#[2r11111111 |
|
970 |
2r01110111 |
|
971 |
2r11111111 |
|
972 |
2r11011101 |
|
973 |
2r11111111 |
|
974 |
2r01110111 |
|
975 |
2r11111111 |
|
976 |
2r11010101] |
|
977 |
||
978 |
"/ 56in64 |
|
979 |
||
980 |
#[2r11111111 |
|
981 |
2r01110111 |
|
982 |
2r11111111 |
|
983 |
2r11011101 |
|
984 |
2r11111111 |
|
985 |
2r01110111 |
|
986 |
2r11111111 |
|
987 |
2r11011101] |
|
988 |
||
989 |
"/ 57in64 |
|
990 |
||
991 |
#[2r11111111 |
|
992 |
2r01110111 |
|
993 |
2r11111111 |
|
994 |
2r11011101 |
|
995 |
2r11111111 |
|
996 |
2r01110111 |
|
997 |
2r11111111 |
|
998 |
2r11111101] |
|
999 |
||
1000 |
"/ 58in64 |
|
1001 |
||
1002 |
#[2r11111111 |
|
1003 |
2r01110111 |
|
1004 |
2r11111111 |
|
1005 |
2r11011111 |
|
1006 |
2r11111111 |
|
1007 |
2r01110111 |
|
1008 |
2r11111111 |
|
1009 |
2r11111101] |
|
1010 |
||
1011 |
"/ 59in64 |
|
1012 |
||
1013 |
#[2r11111111 |
|
1014 |
2r01110111 |
|
1015 |
2r11111111 |
|
1016 |
2r11011111 |
|
1017 |
2r11111111 |
|
1018 |
2r01110111 |
|
1019 |
2r11111111 |
|
1020 |
2r11111111] |
|
1021 |
||
1022 |
"/ 60in64 |
|
1023 |
||
1024 |
#[2r11111111 |
|
1025 |
2r01110111 |
|
1026 |
2r11111111 |
|
1027 |
2r11111111 |
|
1028 |
2r11111111 |
|
1029 |
2r01110111 |
|
1030 |
2r11111111 |
|
1031 |
2r11111111] |
|
1032 |
||
1033 |
"/ 61in64 |
|
1034 |
||
1035 |
#[2r11111111 |
|
1036 |
2r01110111 |
|
1037 |
2r11111111 |
|
1038 |
2r11111111 |
|
1039 |
2r11111111 |
|
1040 |
2r01111111 |
|
1041 |
2r11111111 |
|
1042 |
2r11111111] |
|
1043 |
||
1044 |
"/ 62in64 |
|
1045 |
||
1046 |
#[2r11111111 |
|
1047 |
2r11110111 |
|
1048 |
2r11111111 |
|
1049 |
2r11111111 |
|
1050 |
2r11111111 |
|
1051 |
2r01111111 |
|
1052 |
2r11111111 |
|
1053 |
2r11111111] |
|
1054 |
||
1055 |
"/ 63in64 |
|
1056 |
||
1057 |
#[2r11111111 |
|
1058 |
2r11110111 |
|
1059 |
2r11111111 |
|
1060 |
2r11111111 |
|
1061 |
2r11111111 |
|
1062 |
2r11111111 |
|
1063 |
2r11111111 |
|
1064 |
2r11111111] |
|
1065 |
) at:x |
|
1066 |
||
1067 |
"Created: 23.4.1996 / 09:59:22 / cg" |
|
1068 |
"Modified: 23.4.1996 / 10:00:41 / cg" |
|
0 | 1069 |
! |
1070 |
||
1071 |
grey12Bits |
|
1072 |
"return a pattern with 12% grey, usable for dithering" |
|
1073 |
||
1074 |
^ #(2r00010001 |
|
78 | 1075 |
2r00000000 |
1076 |
2r01000100 |
|
1077 |
2r00000000) |
|
0 | 1078 |
! |
1079 |
||
1080 |
grey25Bits |
|
1081 |
"return a pattern with 25% grey, usable for dithering" |
|
1082 |
||
1083 |
^ #(2r00010001 |
|
78 | 1084 |
2r01000100 |
1085 |
2r00010001 |
|
1086 |
2r01000100) |
|
0 | 1087 |
! |
1088 |
||
1089 |
grey37Bits |
|
1090 |
"return a pattern with 37% grey, usable for dithering" |
|
1091 |
||
1092 |
^ #(2r00010001 |
|
78 | 1093 |
2r10101010 |
1094 |
2r01000100 |
|
1095 |
2r10101010) |
|
0 | 1096 |
! |
1097 |
||
1098 |
grey50Bits |
|
1099 |
"return a pattern with 50% grey, usable for dithering" |
|
1100 |
||
1101 |
^ #(2r01010101 |
|
78 | 1102 |
2r10101010 |
1103 |
2r01010101 |
|
1104 |
2r10101010) |
|
0 | 1105 |
! |
1106 |
||
278 | 1107 |
grey6Bits |
1108 |
"return a pattern with 6% grey, usable for dithering" |
|
0 | 1109 |
|
278 | 1110 |
^ #(2r00000001 |
78 | 1111 |
2r00000000 |
278 | 1112 |
2r00010000 |
78 | 1113 |
2r00000000) |
0 | 1114 |
! |
1115 |
||
278 | 1116 |
greyFormBits |
1117 |
"return a pattern usable to simulate gray on monochrome device" |
|
1118 |
||
1119 |
^ #(2r01010101 |
|
1120 |
2r10101010 |
|
1121 |
2r01010101 |
|
1122 |
2r10101010) |
|
1123 |
! |
|
1124 |
||
0 | 1125 |
lightGreyFormBits |
1126 |
"return a pattern usable to simulate lightGray on monochrome device" |
|
1127 |
||
1128 |
^ #(2r01000100 |
|
78 | 1129 |
2r00010001 |
1130 |
2r01000100 |
|
1131 |
2r00010001 |
|
1132 |
2r01000100) |
|
0 | 1133 |
! |
1134 |
||
1135 |
veryDarkGreyFormBits |
|
1136 |
"return a pattern usable to simulate veryDarkGray on monochrome device" |
|
1137 |
||
1138 |
^ #(2r01110111 |
|
78 | 1139 |
2r11111111 |
1140 |
2r11011101 |
|
1141 |
2r11111111) |
|
278 | 1142 |
! |
1143 |
||
1144 |
veryLightGreyFormBits |
|
1145 |
"return a pattern usable to simulate veryDarkGray on monochrome device" |
|
1146 |
||
1147 |
^ #(2r10001000 |
|
1148 |
2r00000000 |
|
1149 |
2r00100010 |
|
1150 |
2r00000000) |
|
1151 |
! ! |
|
1152 |
||
1153 |
!Form class methodsFor:'private instance creation'! |
|
1154 |
||
1155 |
darkGreyFormOn:aDevice |
|
1156 |
"return a darkGrey form" |
|
1157 |
||
1158 |
|f| |
|
1159 |
||
1160 |
((aDevice == Display) and:[DarkGreyForm notNil]) ifTrue:[ |
|
1161 |
^ DarkGreyForm |
|
1162 |
]. |
|
1163 |
||
1164 |
f := self width:8 height:4 fromArray:(self darkGreyFormBits) on:aDevice. |
|
1165 |
(aDevice == Display) ifTrue:[ |
|
1166 |
DarkGreyForm := f |
|
1167 |
]. |
|
1168 |
^ f |
|
1169 |
! |
|
1170 |
||
1171 |
grey:percent on:aDevice |
|
1172 |
"return a form for dithering" |
|
1173 |
||
1174 |
(percent < 20) ifTrue:[^ Color black on:aDevice]. |
|
1175 |
(percent < 40) ifTrue:[^ self darkGreyFormOn:aDevice]. |
|
1176 |
(percent < 60) ifTrue:[^ self mediumGreyFormOn:aDevice]. |
|
1177 |
(percent < 80) ifTrue:[^ self lightGreyFormOn:aDevice]. |
|
1178 |
^ Color white on:aDevice |
|
1179 |
! |
|
1180 |
||
1181 |
lightGreyFormOn:aDevice |
|
1182 |
"return a lightGrey form" |
|
1183 |
||
1184 |
|f| |
|
1185 |
||
1186 |
((aDevice == Display) and:[LightGreyForm notNil]) ifTrue:[ |
|
1187 |
^ LightGreyForm |
|
1188 |
]. |
|
1189 |
||
1190 |
f := self width:8 height:4 fromArray:(self lightGreyFormBits) on:aDevice. |
|
1191 |
(aDevice == Display) ifTrue:[ |
|
1192 |
LightGreyForm := f |
|
1193 |
]. |
|
1194 |
^ f |
|
1195 |
! |
|
1196 |
||
1197 |
mediumGreyFormOn:aDevice |
|
1198 |
"return a grey form" |
|
1199 |
||
1200 |
|f| |
|
1201 |
||
1202 |
((aDevice == Display) and:[GreyForm notNil]) ifTrue:[ |
|
1203 |
^ GreyForm |
|
1204 |
]. |
|
1205 |
||
1206 |
f := self width:8 height:4 fromArray:(self greyFormBits) on:aDevice. |
|
1207 |
(aDevice == Display) ifTrue:[ |
|
1208 |
GreyForm := f |
|
1209 |
]. |
|
1210 |
^ f |
|
1211 |
! |
|
1212 |
||
1213 |
veryDarkGreyFormOn:aDevice |
|
1214 |
"return a veryDarkGrey form" |
|
1215 |
||
1216 |
|f| |
|
1217 |
||
1218 |
((aDevice == Display) and:[VeryDarkGreyForm notNil]) ifTrue:[ |
|
1219 |
^ VeryDarkGreyForm |
|
1220 |
]. |
|
1221 |
||
1222 |
f := self width:8 height:4 fromArray:(self veryDarkGreyFormBits) on:aDevice. |
|
1223 |
(aDevice == Display) ifTrue:[ |
|
1224 |
VeryDarkGreyForm := f |
|
1225 |
]. |
|
1226 |
^ f |
|
1227 |
! |
|
1228 |
||
1229 |
veryLightGreyFormOn:aDevice |
|
1230 |
"return a veryLightGrey form" |
|
1231 |
||
1232 |
|f| |
|
1233 |
||
1234 |
((aDevice == Display) and:[VeryLightGreyForm notNil]) ifTrue:[ |
|
1235 |
^ VeryLightGreyForm |
|
1236 |
]. |
|
1237 |
||
1238 |
f := self width:8 height:4 fromArray:(self veryLightGreyFormBits) on:aDevice. |
|
1239 |
(aDevice == Display) ifTrue:[ |
|
1240 |
VeryLightGreyForm := f |
|
1241 |
]. |
|
1242 |
^ f |
|
1243 |
! ! |
|
1244 |
||
1245 |
!Form methodsFor:'ST-80 compatibility'! |
|
1246 |
||
1247 |
displayOn:aGC at:aPoint |
|
1248 |
"draw in aGC. |
|
1249 |
Smalltalk-80 (2.x) compatibility" |
|
1250 |
||
1251 |
^ self displayOn:aGC at:aPoint rule:#copy |
|
1252 |
! |
|
1253 |
||
1254 |
displayOn:aGC at:aPoint rule:rule |
|
1255 |
"draw in aGC. |
|
1256 |
Smalltalk-80 (2.x) compatibility" |
|
1257 |
||
1258 |
|f| |
|
1259 |
||
1260 |
f := aGC function. |
|
1261 |
aGC function:rule. |
|
1262 |
aGC displayOpaqueForm:self x:aPoint x y:aPoint y. |
|
1263 |
aGC function:f. |
|
1264 |
! |
|
1265 |
||
1266 |
displayOn:aGC rule:rule |
|
1267 |
"draw in aGC. |
|
1268 |
Smalltalk-80 (2.x) compatibility" |
|
1269 |
||
1270 |
^ self displayOn:aGC at:0@0 rule:rule |
|
1271 |
! |
|
1272 |
||
1273 |
offset |
|
1274 |
"set the offset. |
|
1275 |
Smalltalk-80 compatibility" |
|
1276 |
||
1277 |
^ offset |
|
1278 |
! |
|
1279 |
||
1280 |
offset:org |
|
1281 |
"set the offset. |
|
1282 |
Smalltalk-80 compatibility" |
|
1283 |
||
1284 |
offset := org |
|
1285 |
! ! |
|
1286 |
||
1287 |
!Form methodsFor:'accessing'! |
|
1288 |
||
1289 |
bits |
|
1290 |
"return a ByteArray filled with my bits - |
|
1291 |
for depth 8 forms, 1 pixel/byte is filled; |
|
1292 |
for depth 1 forms, 8 pixels/byte are filled |
|
1293 |
for depth 4 forms, 2 pixels/byte are filled. |
|
1294 |
Padding is done to the next byte-boundary |
|
1295 |
(i.e. for width==13 and depth==1 it will return 2 bytes per scanline)" |
|
1296 |
||
1297 |
|bytesPerLine "{ Class: SmallInteger }" |
|
1298 |
bytesPerLineIn "{ Class: SmallInteger }" |
|
1299 |
inData tmpData info |
|
1300 |
srcIndex "{ Class: SmallInteger }" |
|
1301 |
dstIndex "{ Class: SmallInteger }" |
|
1302 |
buffer| |
|
1303 |
||
1304 |
data notNil ifTrue:[ |
|
1305 |
^ data |
|
1306 |
]. |
|
1307 |
drawableId isNil ifTrue:[ |
|
1308 |
fileName notNil ifTrue:[ |
|
1309 |
^ (self on:Screen current) bits |
|
1310 |
]. |
|
1311 |
^ nil |
|
1312 |
]. |
|
1313 |
||
1314 |
bytesPerLine := (width * depth + 31) // 32 * 4. |
|
1315 |
inData := ByteArray uninitializedNew:(bytesPerLine * height). |
|
1316 |
info := device getBitsFrom:drawableId x:0 y:0 width:width height:height into:inData. |
|
398
2b35bb58a82b
changes for new returned info from getBits
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
1317 |
bytesPerLineIn := (info at:#bytesPerLine). "what I got" |
278 | 1318 |
bytesPerLine := (width * depth + 7) // 8. "what I want" |
1319 |
(bytesPerLine ~~ bytesPerLineIn) ifTrue:[ |
|
1320 |
" |
|
1321 |
different padding - have to copy over row-wise |
|
1322 |
" |
|
1323 |
tmpData := inData. |
|
1324 |
inData := ByteArray uninitializedNew:(bytesPerLine * height). |
|
1325 |
srcIndex := 1. |
|
1326 |
dstIndex := 1. |
|
1327 |
1 to:height do:[:hi | |
|
1328 |
inData replaceFrom:dstIndex to:(dstIndex + bytesPerLine - 1) |
|
1329 |
with:tmpData startingAt:srcIndex. |
|
1330 |
dstIndex := dstIndex + bytesPerLine. |
|
1331 |
srcIndex := srcIndex + bytesPerLineIn |
|
1332 |
] |
|
1333 |
] ifFalse:[ |
|
1334 |
" |
|
1335 |
same padding - copy over all in one chunk |
|
1336 |
" |
|
1337 |
(bytesPerLine * height) ~~ inData size ifTrue:[ |
|
1338 |
tmpData := inData. |
|
1339 |
inData := ByteArray uninitializedNew:(bytesPerLine * height). |
|
1340 |
inData replaceFrom:1 to:bytesPerLine * height with:tmpData startingAt:1 |
|
1341 |
] |
|
1342 |
]. |
|
1343 |
" |
|
1344 |
have to reverse bytes, if not msbFirst ? |
|
1345 |
" |
|
398
2b35bb58a82b
changes for new returned info from getBits
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
1346 |
(info at:#bitOrder) ~~ #msbFirst ifTrue:[ |
278 | 1347 |
buffer := ByteArray new:bytesPerLine. |
1348 |
dstIndex := 1. |
|
1349 |
1 to:height do:[:hi | |
|
1350 |
buffer replaceFrom:1 to:bytesPerLine with:inData startingAt:dstIndex. |
|
1351 |
buffer reverse. |
|
1352 |
inData replaceFrom:dstIndex to:dstIndex+bytesPerLine-1 with:buffer startingAt:1. |
|
1353 |
dstIndex := dstIndex + bytesPerLine |
|
1354 |
] |
|
1355 |
]. |
|
1356 |
||
1357 |
^ inData. |
|
1358 |
! |
|
1359 |
||
588 | 1360 |
bits:aByteArray |
1361 |
"set the forms bits; |
|
1362 |
for depth-8 forms, 1 pixel/byte is expected; |
|
1363 |
for depth-1 forms, 8 pixels/byte are expected |
|
1364 |
for depth-4 forms, 2 pixels/byte are expected. |
|
1365 |
Padding is expected to the next byte-boundary |
|
1366 |
(i.e. for width==13 and depth==1 2 bytes per scanline are expected)" |
|
1367 |
||
1368 |
data := aByteArray |
|
1369 |
||
1370 |
"Modified: 23.4.1996 / 10:06:01 / cg" |
|
278 | 1371 |
! |
1372 |
||
1373 |
bitsPerSample |
|
1374 |
"for compatibility with Image class ..." |
|
1375 |
||
1376 |
^ Array with:depth |
|
1377 |
! |
|
1378 |
||
1379 |
colorMap |
|
1380 |
"return the receivers colormap" |
|
1381 |
||
1382 |
^ localColorMap |
|
1383 |
! |
|
1384 |
||
1385 |
colorMap:anArray |
|
1386 |
"set the receivers colormap" |
|
1387 |
||
1388 |
localColorMap := anArray |
|
1389 |
! |
|
1390 |
||
1391 |
depth |
|
1392 |
"return the receivers depth" |
|
1393 |
||
1394 |
^ depth |
|
1395 |
! |
|
1396 |
||
1397 |
filename |
|
1398 |
"return the filename, from which the receiver was created, |
|
1399 |
or nil, if it was not read from a file" |
|
1400 |
||
1401 |
^ fileName |
|
1402 |
! |
|
1403 |
||
1404 |
forgetBits |
|
1405 |
"for image, which also keeps the bits - so there is |
|
1406 |
no need to hold them again here" |
|
1407 |
||
1408 |
data := nil |
|
1409 |
! |
|
1410 |
||
1411 |
photometric |
|
1412 |
"for compatibility with Image class ..." |
|
1413 |
||
1414 |
depth == 1 ifTrue:[ |
|
1415 |
((localColorMap at:1) = Color white) ifTrue:[ |
|
1416 |
((localColorMap at:1) = Color black) ifTrue:[ |
|
1417 |
^ #whiteIs0 |
|
1418 |
]. |
|
1419 |
]. |
|
1420 |
((localColorMap at:1) = Color black) ifTrue:[ |
|
1421 |
((localColorMap at:1) = Color white) ifTrue:[ |
|
1422 |
^ #blackIs0 |
|
1423 |
]. |
|
1424 |
]. |
|
1425 |
]. |
|
1426 |
^ #palette |
|
1427 |
! |
|
1428 |
||
1429 |
samplesperPixel |
|
1430 |
"for compatibility with Image class ..." |
|
1431 |
||
1432 |
^ 1 |
|
1433 |
! |
|
1434 |
||
1435 |
valueAt:aPoint |
|
588 | 1436 |
"return the pixel at aPoint; the coordinates start with 0@0 |
1437 |
in the upper left, increasing to the lower right" |
|
1438 |
||
278 | 1439 |
^ self at:aPoint |
588 | 1440 |
|
1441 |
"Modified: 23.4.1996 / 10:06:55 / cg" |
|
278 | 1442 |
! |
1443 |
||
1444 |
valueAt:aPoint put:value |
|
588 | 1445 |
"set the pixel at aPoint; the coordinates start with 0@0 |
1446 |
in the upper left, increasing to the lower right." |
|
1447 |
||
278 | 1448 |
^ self at:aPoint put:value |
588 | 1449 |
|
1450 |
" |
|
1451 |
|f| |
|
1452 |
||
1453 |
f := Form width:10 height:10 depth:1. |
|
1454 |
f clear. |
|
1455 |
1 to:10 do:[:i | |
|
1456 |
f valueAt:(i @ i) put:1 |
|
1457 |
]. |
|
1458 |
f inspect |
|
1459 |
" |
|
1460 |
||
1461 |
"Modified: 23.4.1996 / 10:12:48 / cg" |
|
278 | 1462 |
! ! |
1463 |
||
1464 |
!Form methodsFor:'binary storage'! |
|
1465 |
||
1466 |
readBinaryContentsFrom: stream manager: manager |
|
1467 |
"tell the newly restored Form about restoration" |
|
1468 |
||
1469 |
super readBinaryContentsFrom: stream manager: manager. |
|
1470 |
device := Screen current. |
|
1471 |
fileName := nil. |
|
1472 |
self restored. |
|
1473 |
self recreate. |
|
1474 |
Lobby register:self. |
|
1475 |
||
1476 |
" |
|
1477 |
|f| |
|
1478 |
||
1479 |
f := Form fromFile:'bitmaps/SBrowser.xbm'. |
|
1480 |
f storeBinaryOn:'foo.bos'. |
|
1481 |
||
1482 |
(Form readBinaryFrom:'foo.bos') inspect |
|
1483 |
" |
|
1484 |
! |
|
1485 |
||
1486 |
storeBinaryDefinitionOn: stream manager: manager |
|
1487 |
"store a binary representation of the receiver on stream. |
|
588 | 1488 |
This is an internal interface for binary storage mechanism. |
278 | 1489 |
Redefined to store the actual bits, even if I have been loaded |
1490 |
from a file." |
|
1491 |
||
1492 |
data isNil ifTrue:[ |
|
588 | 1493 |
data := self bits. |
1494 |
super storeBinaryDefinitionOn: stream manager: manager. |
|
1495 |
data := nil. |
|
1496 |
^ self |
|
278 | 1497 |
]. |
1498 |
super storeBinaryDefinitionOn: stream manager: manager |
|
588 | 1499 |
|
1500 |
"Modified: 23.4.1996 / 09:30:47 / cg" |
|
278 | 1501 |
! ! |
1502 |
||
1503 |
!Form methodsFor:'converting'! |
|
1504 |
||
1505 |
asForm |
|
588 | 1506 |
"convert & return the receiver into a Form instance - nothing to be done here" |
1507 |
||
278 | 1508 |
^ self |
588 | 1509 |
|
1510 |
"Modified: 23.4.1996 / 10:14:11 / cg" |
|
278 | 1511 |
! |
1512 |
||
1513 |
asImage |
|
588 | 1514 |
"convert & return the receiver into an Image instance" |
1515 |
||
278 | 1516 |
^ Image fromForm:self |
588 | 1517 |
|
1518 |
"Modified: 23.4.1996 / 10:13:56 / cg" |
|
278 | 1519 |
! ! |
1520 |
||
1521 |
!Form methodsFor:'copying'! |
|
1522 |
||
1523 |
postCopy |
|
588 | 1524 |
"redefined to copy the colorMap as well" |
1525 |
||
278 | 1526 |
super postCopy. |
1527 |
localColorMap := localColorMap copy. |
|
1528 |
data := data copy |
|
588 | 1529 |
|
1530 |
"Modified: 23.4.1996 / 10:14:46 / cg" |
|
278 | 1531 |
! |
1532 |
||
1533 |
shallowCopyForFinalization |
|
1534 |
"redefined for faster creation of finalization copies |
|
1535 |
(only device, gcId and drawableId are needed)" |
|
1536 |
||
1537 |
|aCopy| |
|
1538 |
||
1539 |
aCopy := DeviceFormHandle basicNew. |
|
1540 |
aCopy setDevice:device id:drawableId gcId:gcId. |
|
1541 |
^ aCopy |
|
1542 |
! ! |
|
1543 |
||
1544 |
!Form methodsFor:'editing'! |
|
1545 |
||
1546 |
edit |
|
588 | 1547 |
"open an imageEditor on the receiver" |
1548 |
||
278 | 1549 |
ImageEditView openOnImage:self |
1550 |
||
1551 |
" |
|
1552 |
(Form fromFile:'bitmaps/SBrowser.xbm') edit |
|
1553 |
" |
|
588 | 1554 |
|
1555 |
"Modified: 23.4.1996 / 10:16:02 / cg" |
|
278 | 1556 |
! |
1557 |
||
1558 |
show |
|
588 | 1559 |
"open an imageView on the receiver" |
1560 |
||
278 | 1561 |
ImageView openOnImage:self |
1562 |
||
1563 |
" |
|
1564 |
(Form fromFile:'bitmaps/SBrowser.xbm') show |
|
1565 |
" |
|
588 | 1566 |
|
1567 |
"Modified: 23.4.1996 / 10:16:12 / cg" |
|
278 | 1568 |
! ! |
1569 |
||
1570 |
!Form methodsFor:'getting a device form'! |
|
1571 |
||
1572 |
asFormOn:aDevice |
|
588 | 1573 |
"convert & return the receiver into a Form instance |
1574 |
and associate it to a device (i.e. download its bits). |
|
1575 |
Added for protocol compatibility with Image." |
|
1576 |
||
278 | 1577 |
aDevice == device ifTrue:[ |
588 | 1578 |
^ self |
278 | 1579 |
]. |
1580 |
^ self on:aDevice |
|
588 | 1581 |
|
1582 |
"Modified: 23.4.1996 / 10:17:26 / cg" |
|
278 | 1583 |
! |
1584 |
||
1585 |
asMonochromeFormOn:aDevice |
|
588 | 1586 |
"added for protocol compatiblity with Image" |
1587 |
||
278 | 1588 |
aDevice == device ifTrue:[ |
588 | 1589 |
depth == 1 ifTrue:[ |
1590 |
^ self |
|
1591 |
]. |
|
278 | 1592 |
]. |
1593 |
(depth == 1) ifTrue:[ |
|
588 | 1594 |
^ self on:aDevice |
278 | 1595 |
]. |
1596 |
^ nil |
|
588 | 1597 |
|
1598 |
"Modified: 23.4.1996 / 10:18:42 / cg" |
|
278 | 1599 |
! |
1600 |
||
1601 |
on:aDevice |
|
588 | 1602 |
"associate the receiver to a device (i.e. download its bits); |
1603 |
return a deviceForm (possibly different from the receiver)." |
|
1604 |
||
278 | 1605 |
aDevice == device ifTrue:[ |
588 | 1606 |
^ self |
278 | 1607 |
]. |
1608 |
"create a new form ..." |
|
1609 |
||
1610 |
data notNil ifTrue:[ |
|
588 | 1611 |
^ self class width:width height:height fromArray:data on:aDevice |
278 | 1612 |
]. |
1613 |
fileName notNil ifTrue:[ |
|
588 | 1614 |
^ self class fromFile:fileName on:aDevice |
278 | 1615 |
]. |
1616 |
^ self width:width height:height on:aDevice |
|
588 | 1617 |
|
1618 |
"Modified: 23.4.1996 / 10:18:05 / cg" |
|
278 | 1619 |
! ! |
1620 |
||
1621 |
!Form methodsFor:'image manipulations'! |
|
1622 |
||
1623 |
darkened |
|
588 | 1624 |
"return a darkened version of the receiver. |
1625 |
Added for protocol compatibility with Color and Image. |
|
1626 |
Here, the receiver is returned as a kludge |
|
1627 |
- actually should return a darkened image (or Color black ?) .." |
|
278 | 1628 |
|
1629 |
^ self |
|
588 | 1630 |
|
1631 |
"Modified: 23.4.1996 / 10:19:52 / cg" |
|
278 | 1632 |
! |
1633 |
||
1634 |
flipHorizontal |
|
1635 |
"return a new form flipped horizontally" |
|
1636 |
||
1637 |
|dstY newForm nRows "{ Class: SmallInteger }" | |
|
1638 |
||
1639 |
newForm := ((self class) on:device) |
|
1640 |
width:width |
|
1641 |
height:height |
|
1642 |
depth:depth. |
|
1643 |
"expand rows" |
|
1644 |
dstY := height - 1. |
|
1645 |
nRows := dstY // 2. |
|
1646 |
0 to:nRows do:[:srcY | |
|
1647 |
newForm copyFrom:self |
|
1648 |
x:0 y:srcY |
|
1649 |
toX:0 y:dstY |
|
1650 |
width:width height:1. |
|
1651 |
dstY := dstY - 1 |
|
1652 |
]. |
|
1653 |
newForm colorMap:localColorMap. |
|
1654 |
^ newForm |
|
1655 |
! |
|
1656 |
||
1657 |
flipVertical |
|
1658 |
"return a new form flipped vertically" |
|
1659 |
||
1660 |
|dstX newForm nCols "{ Class: SmallInteger }" | |
|
1661 |
||
1662 |
newForm := ((self class) on:device) |
|
1663 |
width:width |
|
1664 |
height:height |
|
1665 |
depth:depth. |
|
1666 |
"expand cols" |
|
1667 |
dstX := width - 1. |
|
1668 |
nCols := dstX // 2. |
|
1669 |
0 to:nCols do:[:srcX | |
|
1670 |
newForm copyFrom:self |
|
1671 |
x:srcX y:0 |
|
1672 |
toX:dstX y:0 |
|
1673 |
width:1 height:height. |
|
1674 |
dstX := dstX - 1 |
|
1675 |
]. |
|
1676 |
newForm colorMap:localColorMap. |
|
1677 |
^ newForm |
|
1678 |
! |
|
1679 |
||
1680 |
hardMagnifiedBy:extent |
|
1681 |
"return a new form magnified by extent, aPoint. |
|
1682 |
This method handles non-integral factors." |
|
1683 |
||
1684 |
" |
|
1685 |
since Form will be replaced by Image in the long run, |
|
1686 |
and this operation is slow anyway, use the implementation |
|
1687 |
in Image for this." |
|
1688 |
||
1689 |
^ ((Image fromForm:self) magnifiedBy:extent) asFormOn:device. |
|
1690 |
||
1691 |
" |
|
1692 |
(Form fromFile:'OutputOn.64') magnifiedBy:0.5@0.5 |
|
1693 |
(Form fromFile:'OutputOn.64') magnifiedBy:1.5@1.5 |
|
1694 |
" |
|
1695 |
! |
|
1696 |
||
1697 |
lightened |
|
588 | 1698 |
"return a lightened version of the receiver. |
1699 |
Added for protocol compatibility with Color and Image. |
|
1700 |
Here, the receiver is returned as a kludge |
|
1701 |
- actually should return a lightened image (or Color white ?) .." |
|
278 | 1702 |
|
1703 |
^ self |
|
588 | 1704 |
|
1705 |
"Modified: 23.4.1996 / 10:20:14 / cg" |
|
278 | 1706 |
! |
1707 |
||
1708 |
magnifiedBy:extent |
|
1709 |
"return a new form magnified by extent, aPoint. |
|
1710 |
If non-integral magnify is asked for, pass the work on to 'hardMagnifiedBy:'" |
|
1711 |
||
1712 |
|mX mY dstX dstY newForm ext |
|
1713 |
factor "{ Class: SmallInteger }" |
|
1714 |
n "{ Class: SmallInteger }" | |
|
1715 |
||
1716 |
ext := extent asPoint. |
|
1717 |
mX := ext x. |
|
1718 |
mY := ext y. |
|
1719 |
((mX = 1) and:[mY = 1]) ifTrue:[^ self]. |
|
1720 |
||
1721 |
((mX isMemberOf:SmallInteger) and:[mY isMemberOf:SmallInteger]) ifFalse:[ |
|
1722 |
^ self hardMagnifiedBy:ext |
|
1723 |
]. |
|
1724 |
||
1725 |
newForm := ((self class) on:device) |
|
1726 |
width:(width * mX) |
|
1727 |
height:(height * mY) |
|
1728 |
depth:depth. |
|
1729 |
||
1730 |
"expand rows" |
|
1731 |
(mY > 1) ifTrue:[ |
|
1732 |
dstY := 0. |
|
1733 |
n := height. |
|
1734 |
factor := mY. |
|
1735 |
0 to:(n - 1) do:[:srcY | |
|
1736 |
1 to:factor do:[:i | |
|
1737 |
newForm copyFrom:self |
|
1738 |
x:0 y:srcY |
|
1739 |
toX:0 y:dstY |
|
1740 |
width:width height:1. |
|
1741 |
dstY := dstY + 1 |
|
1742 |
] |
|
1743 |
] |
|
1744 |
]. |
|
1745 |
||
1746 |
"expand cols" |
|
1747 |
(mX > 1) ifTrue:[ |
|
1748 |
n := width. |
|
1749 |
factor := mX. |
|
1750 |
dstX := (n * factor) - 1. |
|
1751 |
(n - 1) to:0 by:-1 do:[:srcX | |
|
1752 |
1 to:factor do:[:i | |
|
1753 |
newForm copyFrom:newForm |
|
1754 |
x:srcX y:0 |
|
1755 |
toX:dstX y:0 |
|
1756 |
width:1 height:(height * mY). |
|
1757 |
dstX := dstX - 1 |
|
1758 |
] |
|
1759 |
] |
|
1760 |
]. |
|
1761 |
newForm colorMap:localColorMap. |
|
1762 |
^ newForm |
|
1763 |
||
1764 |
" |
|
1765 |
(ArrowButton upArrowButtonForm:#iris on:Display) magnifiedBy:(2 @ 2) |
|
1766 |
(Form fromFile:'bitmaps/SBrowser.xbm') magnifiedBy:(2 @ 2) |
|
1767 |
(Form fromFile:'bitmaps/SBrowser.xbm') magnifiedBy:(0.4 @ 0.4) |
|
1768 |
" |
|
1769 |
! |
|
1770 |
||
569
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1771 |
magnifiedTo:anExtent |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1772 |
"return a new form magnified to have the size specified by extent. |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1773 |
This may distort the image if the arguments ratio is not the images ratio. |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1774 |
See also #magnifiedPreservingRatioTo: and #magnifiedBy:" |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1775 |
|
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1776 |
^ self magnifiedBy:(anExtent / self extent) |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1777 |
|
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1778 |
"Created: 18.4.1996 / 16:17:52 / cg" |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1779 |
! |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1780 |
|
278 | 1781 |
magnifyBy:scale |
1782 |
"obsolete: has been renamed to magnifiedBy: for ST-80 compatibility |
|
1783 |
and name consistency ..." |
|
1784 |
||
1785 |
self obsoleteMethodWarning. |
|
1786 |
^ self magnifiedBy:scale |
|
0 | 1787 |
! ! |
1788 |
||
1789 |
!Form methodsFor:'initialization'! |
|
1790 |
||
1791 |
initGC |
|
1792 |
"stop server from sending exposure events for Forms - |
|
1793 |
(will fill up stream-queue on some stupid (i.e. sco) systems" |
|
1794 |
||
126 | 1795 |
super initGC. |
1796 |
"/ self createGC. |
|
162 | 1797 |
"/ Lobby registerChange:self. |
0 | 1798 |
self setGraphicsExposures:false |
1799 |
! |
|
1800 |
||
278 | 1801 |
initialize |
1802 |
super initialize. |
|
1803 |
depth := 1. |
|
1804 |
foreground := paint := Color colorId:1. |
|
1805 |
background := bgPaint := Color colorId:0 |
|
1806 |
! |
|
1807 |
||
0 | 1808 |
recreate |
1809 |
"reconstruct the form after a snapin" |
|
1810 |
||
1811 |
data notNil ifTrue:[ |
|
118 | 1812 |
" |
1813 |
create one from data |
|
1814 |
" |
|
78 | 1815 |
(depth == 1 or:[depth == device depth]) ifTrue:[ |
1816 |
drawableId := device createBitmapFromArray:data width:width height:height. |
|
162 | 1817 |
Lobby registerChange:self. |
78 | 1818 |
^ self |
1819 |
]. |
|
1820 |
data := nil. |
|
0 | 1821 |
]. |
1822 |
fileName notNil ifTrue:[ |
|
118 | 1823 |
" |
1824 |
create one from a file (mhmh - this seems X-specific and will vanish) |
|
1825 |
" |
|
78 | 1826 |
drawableId := device createBitmapFromFile:fileName for:self. |
162 | 1827 |
Lobby registerChange:self. |
78 | 1828 |
^ self |
0 | 1829 |
]. |
118 | 1830 |
'FORM: cannot recreate form' errorPrintNL. |
1831 |
" |
|
1832 |
create an empty one |
|
1833 |
" |
|
0 | 1834 |
depth == 1 ifTrue:[ |
78 | 1835 |
drawableId := device createBitmapWidth:width height:height |
0 | 1836 |
] ifFalse:[ |
78 | 1837 |
drawableId := device createPixmapWidth:width height:height depth:device depth |
118 | 1838 |
]. |
162 | 1839 |
Lobby registerChange:self |
2 | 1840 |
! ! |
1841 |
||
278 | 1842 |
!Form methodsFor:'inspecting'! |
127 | 1843 |
|
278 | 1844 |
inspectorClass |
1845 |
"redefined to launch an ImageInspector |
|
1846 |
(instead of the default InspectorView)." |
|
2 | 1847 |
|
278 | 1848 |
^ ImageInspectorView |
2 | 1849 |
! ! |
1850 |
||
278 | 1851 |
!Form methodsFor:'printing & storing'! |
107 | 1852 |
|
278 | 1853 |
storeOn:aStream |
588 | 1854 |
"append an ascii representation of the receiver to aStream, |
1855 |
from which a copy of the receiver can be reconstructed" |
|
1856 |
||
278 | 1857 |
aStream nextPutAll:'(Form width:'. |
1858 |
width storeOn:aStream. |
|
1859 |
aStream nextPutAll:' height:'. |
|
1860 |
height storeOn:aStream. |
|
1861 |
aStream nextPutAll:' fromArray:('. |
|
1862 |
self bits storeOn:aStream. |
|
1863 |
aStream nextPutAll:'))' |
|
588 | 1864 |
|
1865 |
"Modified: 23.4.1996 / 10:21:10 / cg" |
|
107 | 1866 |
! ! |
1867 |
||
0 | 1868 |
!Form methodsFor:'private'! |
1869 |
||
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1870 |
beImmediateForm |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1871 |
"read the pixels from the device into a local data array. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1872 |
This makes certain that a fileName form is independent of |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1873 |
its fileName. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1874 |
To make the image smaller (i.e. not keep all those bitmaps), |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1875 |
this is NOT done by default." |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1876 |
|
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1877 |
data isNil ifTrue:[ |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1878 |
data := self bits. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1879 |
data notNil ifTrue:[ |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1880 |
fileName := nil |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1881 |
] |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1882 |
] |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1883 |
|
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1884 |
" |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1885 |
Form allInstances:[:f | |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1886 |
f beImmediateForm |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1887 |
] |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1888 |
" |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1889 |
|
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1890 |
"Created: 7.2.1996 / 16:04:18 / cg" |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1891 |
! |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1892 |
|
54 | 1893 |
getBits |
1894 |
"if the receiver was not created from a file, or |
|
1895 |
an array (i.e. it was drawn), read the pixels from the |
|
1896 |
device into a local data array. This has to be done before |
|
1897 |
an image is saved, or the receiver is storedBinary, since |
|
1898 |
the information present in the device is lost after restart/reload" |
|
1899 |
||
1900 |
(data isNil and:[fileName isNil]) ifTrue:[ |
|
78 | 1901 |
data := self bits |
54 | 1902 |
] |
1903 |
! |
|
1904 |
||
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1905 |
readFromFile:fn |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1906 |
"read a monochrome form from a file (in xbm-format). |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1907 |
The fileName argument, fn should be a relative pathname |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1908 |
such as bitmaps/foo.xbm and the corresponding file |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1909 |
will be searched in the standard places (i.e. along the SEARCHPATH). |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1910 |
Notice, when saving an image, only that fileName is kept with the |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1911 |
form, and the file is reloaded at image startup time. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1912 |
You should therefore make certain, that the file is present at image |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1913 |
reload time. (this is done to make the image smaller ...) |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1914 |
If you dont like that behavior (or your application should be able to |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1915 |
restart fully standAlone), send #beImmediateForm to all instances of |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1916 |
Form - this will set the data instance variable to a ByteArray containing |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1917 |
the actual bits and will therefore no longer depend on the file being present. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1918 |
" |
278 | 1919 |
|
1920 |
|pathName| |
|
1921 |
||
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1922 |
pathName := self class findBitmapFile:fn. |
278 | 1923 |
pathName notNil ifTrue:[ |
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1924 |
drawableId := device createBitmapFromFile:pathName for:self. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1925 |
drawableId isNil ifTrue:[^ nil]. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1926 |
|
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1927 |
"/ fileName := pathName. "/ keep the actual name (wrong) |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1928 |
fileName := fn. "/ keep the relative name (better - SEARCHPATH may be different at restart) |
278 | 1929 |
|
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1930 |
offset := 0@0. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1931 |
realized := true. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1932 |
BlackAndWhiteColorMap isNil ifTrue:[ |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1933 |
BlackAndWhiteColorMap := Array with:(Color white) with:(Color black) |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1934 |
]. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1935 |
localColorMap := BlackAndWhiteColorMap. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1936 |
Lobby registerChange:self. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1937 |
^ self |
278 | 1938 |
]. |
1939 |
^ nil |
|
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1940 |
|
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1941 |
"Modified: 7.2.1996 / 16:04:25 / cg" |
278 | 1942 |
! |
1943 |
||
1944 |
readFromFile:filename resolution:dpi |
|
1945 |
"read a monochrome form from a file, which is assumed to have data for a dpi-resolution; |
|
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1946 |
if the actual resolution of the device differs, magnify the form. |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1947 |
Read the comment in #readFromFile: on what happenes if the file is no longer present |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1948 |
after an image reload." |
278 | 1949 |
|
1950 |
|dpiH mag dev| |
|
1951 |
||
1952 |
(self readFromFile:filename) isNil ifTrue:[^ nil]. |
|
1953 |
||
1954 |
"if the device is within +- 50% of dpi, no magnify is needed" |
|
1955 |
dev := device. |
|
1956 |
dev isNil ifTrue:[ |
|
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1957 |
"should not happen ..." |
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1958 |
dev := Screen current |
278 | 1959 |
]. |
1960 |
dpiH := dev horizontalPixelPerInch. |
|
1961 |
((dpi >= (dpiH * 0.75)) and:[dpi <= (dpiH * 1.5)]) ifTrue:[^ self]. |
|
1962 |
mag := (dpiH / dpi) rounded. |
|
1963 |
mag == 0 ifTrue:[ |
|
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1964 |
^ self |
278 | 1965 |
]. |
1966 |
^ self magnifiedBy:(mag @ mag) |
|
1967 |
||
1968 |
"Form fromFile:'SBrowser.icn' resolution:50" |
|
412
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1969 |
|
766ba454c23d
keep the relative fileName; added #beImmediateForm to avoid problems if bitmap files are not present at startup
Claus Gittinger <cg@exept.de>
parents:
398
diff
changeset
|
1970 |
"Modified: 7.2.1996 / 16:03:45 / cg" |
278 | 1971 |
! |
1972 |
||
1973 |
restored |
|
1974 |
"flush device data, when restored |
|
1975 |
(sent after snapin or binaryLoad)" |
|
1976 |
||
425
7e1df86e2517
flush device ref when restored
Claus Gittinger <cg@exept.de>
parents:
412
diff
changeset
|
1977 |
device := nil. |
278 | 1978 |
drawableId := nil. |
1979 |
gcId := nil. |
|
1980 |
! |
|
1981 |
||
0 | 1982 |
width:w height:h |
54 | 1983 |
"actual create of a monochrome form" |
0 | 1984 |
|
1985 |
((w == 0) or:[h == 0]) ifTrue:[ |
|
78 | 1986 |
self error:'invalid form extent'. |
1987 |
^ nil |
|
0 | 1988 |
]. |
1989 |
width := w. |
|
1990 |
height := h. |
|
54 | 1991 |
depth := 1. |
0 | 1992 |
offset := 0@0. |
1993 |
drawableId := device createBitmapWidth:w height:h. |
|
1994 |
drawableId isNil ifTrue:[^ nil]. |
|
1995 |
BlackAndWhiteColorMap isNil ifTrue:[ |
|
78 | 1996 |
BlackAndWhiteColorMap := Array with:(Color white) with:(Color black) |
0 | 1997 |
]. |
1998 |
localColorMap := BlackAndWhiteColorMap. |
|
1999 |
realized := true. |
|
162 | 2000 |
Lobby registerChange:self. |
0 | 2001 |
! |
2002 |
||
2003 |
width:w height:h depth:d |
|
54 | 2004 |
"actual create of an arbitrary deep form (but, must be supported by device)" |
0 | 2005 |
|
2006 |
width := w. |
|
2007 |
height := h. |
|
2008 |
offset := 0@0. |
|
2009 |
drawableId := device createPixmapWidth:w height:h depth:d. |
|
2010 |
drawableId isNil ifTrue:[^ nil]. |
|
2011 |
realized := true. |
|
2012 |
depth := d. |
|
162 | 2013 |
Lobby registerChange:self. |
0 | 2014 |
! |
2015 |
||
2016 |
width:w height:h fromArray:anArray |
|
54 | 2017 |
"actual create of a monochrome form from array. |
0 | 2018 |
This method is somewhat more complicated as it should be due to |
2019 |
supporting both byte-wise (ST/X-type) and short-word-wise (ST-80-type) |
|
2020 |
Arrays; in the later case, the shorts are first converted to bytes in |
|
2021 |
a ByteArray, then passed to the device." |
|
2022 |
||
134 | 2023 |
|bytes bits |
2024 |
srcPerRow "{ Class: SmallInteger }" |
|
2025 |
dstPerRow "{ Class: SmallInteger }" |
|
2026 |
srcStart "{ Class: SmallInteger }" |
|
2027 |
srcIndex "{ Class: SmallInteger }" |
|
2028 |
dstIndex "{ Class: SmallInteger }" |
|
2029 |
hi "{ Class: SmallInteger }" | |
|
0 | 2030 |
|
2031 |
bytes := anArray. |
|
2032 |
||
2033 |
anArray size ~~ (((w + 7) // 8) * h) ifTrue:[ |
|
78 | 2034 |
anArray size == (((w + 15) // 16) * h) ifTrue:[ |
2035 |
"I want the bytes but got shorts (ST-80)" |
|
2036 |
bytes := ByteArray uninitializedNew:(((w + 7) // 8) * h). |
|
2037 |
srcPerRow := (w + 15) // 16. |
|
2038 |
dstPerRow := (w + 7) // 8. |
|
2039 |
srcStart := 1. |
|
2040 |
dstIndex := 1. |
|
134 | 2041 |
hi := h. |
2042 |
1 to:hi do:[:hi | |
|
78 | 2043 |
srcIndex := srcStart. |
2044 |
bits := anArray at:srcIndex. |
|
2045 |
1 to:dstPerRow do:[:di | |
|
2046 |
di odd ifTrue:[ |
|
2047 |
bits := anArray at:srcIndex. |
|
2048 |
bytes at:dstIndex put:(bits bitShift:-8) |
|
2049 |
] ifFalse:[ |
|
2050 |
bytes at:dstIndex put:(bits bitAnd:16rFF). |
|
2051 |
srcIndex := srcIndex + 1 |
|
2052 |
]. |
|
2053 |
dstIndex := dstIndex + 1 |
|
2054 |
]. |
|
2055 |
srcStart := srcStart + srcPerRow |
|
2056 |
] |
|
2057 |
] |
|
0 | 2058 |
]. |
2059 |
width := w. |
|
2060 |
height := h. |
|
54 | 2061 |
depth := 1. |
0 | 2062 |
offset := 0@0. |
2063 |
drawableId := device createBitmapFromArray:bytes width:w height:h. |
|
2064 |
drawableId isNil ifTrue:[^ nil]. |
|
2065 |
||
2066 |
data := bytes. |
|
2067 |
BlackAndWhiteColorMap isNil ifTrue:[ |
|
78 | 2068 |
BlackAndWhiteColorMap := Array with:(Color white) with:(Color black) |
0 | 2069 |
]. |
2070 |
localColorMap := BlackAndWhiteColorMap. |
|
2071 |
realized := true. |
|
162 | 2072 |
Lobby registerChange:self. |
0 | 2073 |
! |
2074 |
||
2075 |
width:w height:h offset:offs fromArray:anArray |
|
54 | 2076 |
"actual create of a monochrome form from array" |
0 | 2077 |
|
2078 |
self width:w height:h fromArray:anArray. |
|
2079 |
offset := offs |
|
2080 |
! ! |
|
2081 |
||
99 | 2082 |
!Form methodsFor:'queries '! |
2083 |
||
2084 |
isForm |
|
2085 |
"return true, if the receiver is some kind of form; |
|
2086 |
true is returned here - the method is redefined from Object." |
|
2087 |
||
2088 |
^ true |
|
2089 |
! |
|
2090 |
||
2091 |
isImageOrForm |
|
2092 |
"return true, if the receiver is some kind of image or form; |
|
2093 |
true is returned here - the method is redefined from Object." |
|
2094 |
||
2095 |
^ true |
|
2096 |
! ! |
|
2097 |
||
278 | 2098 |
!Form class methodsFor:'documentation'! |
134 | 2099 |
|
278 | 2100 |
version |
590 | 2101 |
^ '$Header: /cvs/stx/stx/libview/Form.st,v 1.39 1996-04-23 08:48:32 cg Exp $' |
0 | 2102 |
! ! |
278 | 2103 |
Form initialize! |