author | Claus Gittinger <cg@exept.de> |
Wed, 17 Jul 1996 14:19:00 +0200 | |
changeset 951 | ebedf8da0e89 |
parent 935 | e71b1be3eb6c |
child 1058 | 103860173cb2 |
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 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
680
diff
changeset
|
13 |
GraphicsMedium 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 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
22 |
!Form class methodsFor:'documentation'! |
46 | 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 |
|
789 | 51 |
by all devices. |
589 | 52 |
|
935 | 53 |
WARNING: |
54 |
Forms created on some device may not be recreatable, when an |
|
55 |
image is restarted on a display with different display capabilities. |
|
56 |
For example, a 24bit truecolor form will be lost when the image is |
|
57 |
saved and restarted in an 8bit or monochrome display. |
|
58 |
Worse: the information is completely lost. |
|
59 |
||
60 |
With images, the original information is always preserved, although |
|
61 |
the display may be with less resolution, dithered or otherwise |
|
62 |
approximated. |
|
63 |
||
591 | 64 |
[See also:] |
589 | 65 |
Image DeviceDrawable |
610 | 66 |
|
67 |
[author:] |
|
68 |
Claus Gittinger |
|
46 | 69 |
" |
70 |
! ! |
|
0 | 71 |
|
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
72 |
!Form class methodsFor:'initialization'! |
0 | 73 |
|
889 | 74 |
flushDeviceForms |
75 |
"recreate all forms on aDevice; called by Workstation, to |
|
76 |
have all background bitmaps at hand, when views are restored" |
|
77 |
||
78 |
Lobby do:[:aDrawable | |
|
79 |
aDrawable isForm ifTrue:[ |
|
927
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
80 |
(aDrawable graphicsDevice notNil) ifTrue:[ |
889 | 81 |
"now, try to recreate it" |
82 |
aDrawable recreate. |
|
83 |
] |
|
84 |
] |
|
85 |
] |
|
86 |
||
87 |
"Created: 18.6.1996 / 13:04:59 / cg" |
|
927
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
88 |
"Modified: 5.7.1996 / 17:56:02 / cg" |
889 | 89 |
! |
90 |
||
0 | 91 |
initialize |
126 | 92 |
"initialize set of dictionaries to look for bitmaps" |
0 | 93 |
|
94 |
AdditionalBitmapDirectoryNames isNil ifTrue:[ |
|
78 | 95 |
AdditionalBitmapDirectoryNames := #('/usr/lib/X11/bitmaps'). |
0 | 96 |
|
78 | 97 |
"want to be informed when returning from snapshot" |
98 |
ObjectMemory addDependent:self. |
|
0 | 99 |
] |
100 |
! |
|
101 |
||
102 |
reinitializeAllOn:aDevice |
|
103 |
"recreate all forms on aDevice; called by Workstation, to |
|
104 |
have all background bitmaps at hand, when views are restored" |
|
105 |
||
127 | 106 |
Lobby do:[:aDrawable | |
927
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
107 |
(aDrawable graphicsDevice == aDevice) ifTrue:[ |
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
108 |
aDrawable isForm ifTrue:[ |
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
109 |
"now, try to recreate it" |
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
110 |
aDrawable recreate. |
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
111 |
] |
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
112 |
] |
0 | 113 |
] |
927
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
114 |
|
c4bc2a7ff733
use #graphicsDevice instead of #device.
Claus Gittinger <cg@exept.de>
parents:
925
diff
changeset
|
115 |
"Modified: 5.7.1996 / 17:55:58 / cg" |
0 | 116 |
! |
117 |
||
870
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
118 |
update:something with:aParameter from:changedObject |
0 | 119 |
"sent just before snapOut and just after a snapIn" |
120 |
||
121 |
(something == #save) ifTrue:[ |
|
870
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
122 |
"get all bits from the device into saveable arrays" |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
123 |
Lobby do:[:aDrawable | |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
124 |
aDrawable isForm ifTrue:[ |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
125 |
aDrawable getBits |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
126 |
] |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
127 |
] |
0 | 128 |
]. |
129 |
(something == #restarted) ifTrue:[ |
|
870
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
130 |
"remove all left-over device info" |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
131 |
Lobby do:[:aDrawable | |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
132 |
aDrawable isForm ifTrue:[ |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
133 |
aDrawable flushDeviceHandles. |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
134 |
Lobby registerChange:aDrawable |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
135 |
] |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
136 |
] |
0 | 137 |
] |
870
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
138 |
|
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
139 |
"Modified: 15.6.1996 / 15:44:09 / cg" |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
140 |
"Created: 15.6.1996 / 15:47:50 / cg" |
0 | 141 |
! ! |
142 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
143 |
!Form class methodsFor:'instance creation'! |
278 | 144 |
|
145 |
extent:ext |
|
146 |
"create a new, cleared form, take dimensions from ext. |
|
147 |
Smalltalk-80 compatibility" |
|
148 |
||
149 |
|newForm| |
|
150 |
||
151 |
newForm := self width:(ext x) height:(ext y). |
|
152 |
newForm fill:(Color colorId:0). |
|
153 |
newForm paint:(Color colorId:1). |
|
154 |
^ newForm |
|
155 |
! |
|
156 |
||
157 |
extent:ext fromArray:data |
|
158 |
"create a new form, take dimensions from ext, bits from data. |
|
159 |
Smalltalk-80 compatibility." |
|
160 |
||
161 |
^ self width:(ext x) height:(ext y) offset:0@0 fromArray:data |
|
162 |
! |
|
163 |
||
164 |
extent:ext fromArray:data offset:offs |
|
165 |
"create a new form, take dimensions from ext, bits from data. |
|
166 |
Smalltalk-80 compatibility." |
|
167 |
||
168 |
^ self width:(ext x) height:(ext y) offset:offs fromArray:data |
|
169 |
! |
|
170 |
||
171 |
extent:ext offset:anOffset |
|
172 |
"create a new, cleared form, take dimensions from ext. |
|
173 |
Smalltalk-80 compatibility" |
|
174 |
||
175 |
^ (self extent:ext) offset:anOffset. |
|
176 |
! |
|
177 |
||
178 |
width:w height:h |
|
179 |
"create a new form on the default device" |
|
180 |
||
789 | 181 |
^ self width:w height:h on:Screen current |
182 |
||
183 |
"Modified: 4.6.1996 / 22:16:33 / cg" |
|
278 | 184 |
! |
185 |
||
186 |
width:w height:h depth:d |
|
187 |
"create a new form on the default device" |
|
188 |
||
789 | 189 |
^ self width:w height:h depth:d on:Screen current |
190 |
||
191 |
"Modified: 4.6.1996 / 22:16:51 / cg" |
|
278 | 192 |
! |
193 |
||
194 |
width:w height:h depth:d on:aDevice |
|
195 |
"create a new form with depth d on device, aDevice" |
|
196 |
||
197 |
^ (self on:aDevice) width:w height:h depth:d |
|
198 |
! |
|
199 |
||
200 |
width:w height:h fromArray:anArray |
|
201 |
"create a new form on the default device" |
|
202 |
||
789 | 203 |
^ self width:w height:h fromArray:anArray on:Screen current |
204 |
||
205 |
"Modified: 4.6.1996 / 22:17:05 / cg" |
|
278 | 206 |
! |
207 |
||
208 |
width:w height:h fromArray:anArray on:aDevice |
|
209 |
"create a new form on device, aDevice and |
|
210 |
initialize the pixels from anArray" |
|
211 |
||
212 |
^ (self on:aDevice) width:w height:h fromArray:anArray |
|
213 |
! |
|
109 | 214 |
|
278 | 215 |
width:w height:h offset:offs fromArray:anArray |
216 |
"create a new form on the default device" |
|
217 |
||
218 |
^ (self on:Screen current) width:w height:h offset:offs fromArray:anArray |
|
219 |
! |
|
220 |
||
221 |
width:w height:h on:aDevice |
|
222 |
"create a new form on device, aDevice; depth is what device likes most" |
|
223 |
||
224 |
^ (self on:aDevice) width:w height:h |
|
225 |
! ! |
|
226 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
227 |
!Form class methodsFor:'ST-80 compatibility'! |
278 | 228 |
|
229 |
and |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
230 |
"return a constant usable as bitblt-combinationrule. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
231 |
In ST-80rel2.x, these used to be numeric constants; in ST/X, |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
232 |
these are symbolic." |
278 | 233 |
|
234 |
^ #and |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
235 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
236 |
"Modified: 2.5.1996 / 11:41:23 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
237 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
238 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
239 |
black |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
240 |
"ST80 compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
241 |
In old st80, you could use `Form black' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
242 |
- here we return the black color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
243 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
244 |
^ Color black |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
245 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
246 |
"Modified: 2.5.1996 / 11:44:17 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
247 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
248 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
249 |
darkGray |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
250 |
"ST80 compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
251 |
In old st80, you could use `Form darkGray' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
252 |
- here we return the darkGray color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
253 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
254 |
^ Color darkGray |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
255 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
256 |
"Modified: 2.5.1996 / 11:44:06 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
257 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
258 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
259 |
darkGrey |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
260 |
"ST80 compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
261 |
In old st80, you could use `Form darkGrey' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
262 |
- here we return the darkGrey color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
263 |
|
746 | 264 |
^ Color darkGray |
265 |
||
266 |
"Modified: 28.5.1996 / 20:47:54 / cg" |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
267 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
268 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
269 |
gray |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
270 |
"ST80 compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
271 |
In old st80, you could use `Form gray' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
272 |
- here we return the grey color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
273 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
274 |
^ Color gray |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
275 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
276 |
"Modified: 2.5.1996 / 11:43:44 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
277 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
278 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
279 |
grey |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
280 |
"ST80 compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
281 |
In old st80, you could use `Form grey' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
282 |
- here we return the grey color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
283 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
284 |
^ Color grey |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
285 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
286 |
"Modified: 2.5.1996 / 11:43:17 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
287 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
288 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
289 |
lightGray |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
290 |
"ST80 compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
291 |
In old st80, you could use `Form lightGray' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
292 |
- here we return the lightGray color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
293 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
294 |
^ Color lightGray |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
295 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
296 |
"Created: 2.5.1996 / 11:40:07 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
297 |
"Modified: 2.5.1996 / 11:43:21 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
298 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
299 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
300 |
lightGrey |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
301 |
"ST80 compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
302 |
In old st80, you could use `Form lightGray' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
303 |
- here we return the lightGray color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
304 |
|
746 | 305 |
^ Color lightGray |
306 |
||
307 |
"Modified: 28.5.1996 / 20:53:28 / cg" |
|
278 | 308 |
! |
309 |
||
310 |
over |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
311 |
"return a constant usable as bitblt-combinationrule. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
312 |
In ST-80rel2.x, these used to be numeric constants; in ST/X, |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
313 |
these are symbolic." |
278 | 314 |
|
315 |
^ #copy |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
316 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
317 |
"Modified: 2.5.1996 / 11:41:31 / cg" |
278 | 318 |
! |
319 |
||
320 |
paint |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
321 |
"return a constant usable as bitblt-combinationrule. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
322 |
In ST-80rel2.x, these used to be numeric constants; in ST/X, |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
323 |
these are symbolic." |
278 | 324 |
|
325 |
^ #copy |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
326 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
327 |
"Modified: 2.5.1996 / 11:41:40 / cg" |
278 | 328 |
! |
329 |
||
330 |
reverse |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
331 |
"return a constant usable as bitblt-combinationrule. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
332 |
In ST-80rel2.x, these used to be numeric constants; in ST/X, |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
333 |
these are symbolic." |
278 | 334 |
|
335 |
^ #xor |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
336 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
337 |
"Modified: 2.5.1996 / 11:41:45 / cg" |
278 | 338 |
! |
339 |
||
340 |
under |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
341 |
"return a constant usable as bitblt-combinationrule. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
342 |
In ST-80rel2.x, these used to be numeric constants; in ST/X, |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
343 |
these are symbolic." |
278 | 344 |
|
345 |
^ #or |
|
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
346 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
347 |
"Modified: 2.5.1996 / 11:41:49 / cg" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
348 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
349 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
350 |
white |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
351 |
"ST80rel2.x compatibility; |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
352 |
In old st80, you could use `Form white' for drawing |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
353 |
- here we return the white color." |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
354 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
355 |
^ Color white |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
356 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
357 |
"Modified: 2.5.1996 / 11:42:50 / cg" |
109 | 358 |
! ! |
359 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
360 |
!Form class methodsFor:'cleanup'! |
12 | 361 |
|
362 |
lowSpaceCleanup |
|
363 |
"cleanup in low-memory situations" |
|
364 |
||
54 | 365 |
DitherPatternArray := nil |
12 | 366 |
! ! |
367 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
368 |
!Form class methodsFor:'file search'! |
0 | 369 |
|
370 |
findBitmapFile:fileName |
|
371 |
"find the bitmap file in one of the standard places; |
|
372 |
return the pathName or nil" |
|
373 |
||
374 |
|aStream path| |
|
375 |
||
376 |
((fileName at:1) == $/) ifTrue:[^ fileName]. |
|
377 |
(fileName startsWith:'../') ifTrue:[^ fileName]. |
|
378 |
(fileName startsWith:'./') ifTrue:[^ fileName]. |
|
127 | 379 |
fileName asFilename exists ifTrue:[^ fileName]. |
0 | 380 |
|
134 | 381 |
aStream := Smalltalk bitmapFileStreamFor:fileName. |
0 | 382 |
aStream notNil ifTrue:[ |
78 | 383 |
path := aStream pathName. |
384 |
aStream close. |
|
385 |
^ path |
|
0 | 386 |
]. |
387 |
AdditionalBitmapDirectoryNames notNil ifTrue:[ |
|
78 | 388 |
AdditionalBitmapDirectoryNames do:[:aPath | |
389 |
path := aPath , '/' , fileName. |
|
390 |
(OperatingSystem isReadable:path) ifTrue:[ |
|
391 |
^ path |
|
392 |
] |
|
393 |
] |
|
0 | 394 |
]. |
395 |
^ nil |
|
396 |
! ! |
|
397 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
398 |
!Form class methodsFor:'fileIn/Out'! |
54 | 399 |
|
278 | 400 |
fromFile:filename |
401 |
"create a new form taking the bits from a file on the default device. |
|
402 |
WARNING: |
|
403 |
Please do no longer use this, since it will not work |
|
404 |
correctly in multi-display applications (creates the form on the |
|
405 |
default Display). |
|
406 |
Use #fromFile:on: and pass the devive as argument." |
|
0 | 407 |
|
278 | 408 |
^ self fromFile:filename on:Screen current |
0 | 409 |
! |
410 |
||
278 | 411 |
fromFile:filename on:aDevice |
412 |
"create a new form on device, aDevice and |
|
413 |
initialize the pixels from the file filename" |
|
0 | 414 |
|
278 | 415 |
^ (self on:aDevice) readFromFile:filename |
89 | 416 |
! |
417 |
||
278 | 418 |
fromFile:filename resolution:dpi |
419 |
"create a new form taking the bits from a file on the default device |
|
420 |
the data in the file is assumed to be for dpi resolution; |
|
421 |
if it is different from the displays resolution, magnify or |
|
422 |
shrink the picture (but only in integer magnification steps). |
|
423 |
WARNING: |
|
424 |
Please do no longer use this, since it will not work |
|
425 |
correctly in multi-display applications (creates the form on the |
|
426 |
default Display). |
|
427 |
Use #fromFile:resolution:on: and pass the devive as argument." |
|
98 | 428 |
|
278 | 429 |
^ self fromFile:filename resolution:dpi on:Screen current |
0 | 430 |
! |
431 |
||
278 | 432 |
fromFile:filename resolution:dpi on:aDevice |
433 |
"create a new form on device, aDevice and |
|
434 |
initialize the pixels from the file filename; |
|
435 |
the data in the file is assumed to be for dpi resolution; |
|
436 |
if it is different from the displays resolution, magnify or |
|
437 |
shrink the picture (but only in integer magnification steps)" |
|
0 | 438 |
|
278 | 439 |
^ (self on:aDevice) readFromFile:filename resolution:dpi |
0 | 440 |
! |
441 |
||
278 | 442 |
readFrom:fileName |
443 |
"same as Form>>fromFile: - for ST-80 compatibility. |
|
444 |
WARNING: |
|
445 |
Please do no longer use this, since it will not work |
|
446 |
correctly in multi-display applications (creates the form on the |
|
447 |
default Display). |
|
448 |
Use #fromFile:on: and pass the devive as argument." |
|
0 | 449 |
|
278 | 450 |
^ self fromFile:fileName on:Screen current |
0 | 451 |
! ! |
452 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
453 |
!Form class methodsFor:'obsolete instance creation'! |
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
454 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
455 |
darkGreyFormOn:aDevice |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
456 |
"return a darkGrey form" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
457 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
458 |
|f| |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
459 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
460 |
((aDevice == Display) and:[DarkGreyForm notNil]) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
461 |
^ DarkGreyForm |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
462 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
463 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
464 |
f := self width:8 height:4 fromArray:(self darkGreyFormBits) on:aDevice. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
465 |
(aDevice == Display) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
466 |
DarkGreyForm := f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
467 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
468 |
^ f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
469 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
470 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
471 |
grey:percent on:aDevice |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
472 |
"return a form for dithering" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
473 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
474 |
(percent < 20) ifTrue:[^ Color black on:aDevice]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
475 |
(percent < 40) ifTrue:[^ self darkGreyFormOn:aDevice]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
476 |
(percent < 60) ifTrue:[^ self mediumGreyFormOn:aDevice]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
477 |
(percent < 80) ifTrue:[^ self lightGreyFormOn:aDevice]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
478 |
^ Color white on:aDevice |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
479 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
480 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
481 |
lightGreyFormOn:aDevice |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
482 |
"return a lightGrey form" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
483 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
484 |
|f| |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
485 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
486 |
((aDevice == Display) and:[LightGreyForm notNil]) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
487 |
^ LightGreyForm |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
488 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
489 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
490 |
f := self width:8 height:4 fromArray:(self lightGreyFormBits) on:aDevice. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
491 |
(aDevice == Display) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
492 |
LightGreyForm := f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
493 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
494 |
^ f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
495 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
496 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
497 |
mediumGreyFormOn:aDevice |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
498 |
"return a grey form" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
499 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
500 |
|f| |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
501 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
502 |
((aDevice == Display) and:[GreyForm notNil]) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
503 |
^ GreyForm |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
504 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
505 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
506 |
f := self width:8 height:4 fromArray:(self greyFormBits) on:aDevice. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
507 |
(aDevice == Display) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
508 |
GreyForm := f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
509 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
510 |
^ f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
511 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
512 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
513 |
veryDarkGreyFormOn:aDevice |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
514 |
"return a veryDarkGrey form" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
515 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
516 |
|f| |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
517 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
518 |
((aDevice == Display) and:[VeryDarkGreyForm notNil]) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
519 |
^ VeryDarkGreyForm |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
520 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
521 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
522 |
f := self width:8 height:4 fromArray:(self veryDarkGreyFormBits) on:aDevice. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
523 |
(aDevice == Display) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
524 |
VeryDarkGreyForm := f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
525 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
526 |
^ f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
527 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
528 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
529 |
veryLightGreyFormOn:aDevice |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
530 |
"return a veryLightGrey form" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
531 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
532 |
|f| |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
533 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
534 |
((aDevice == Display) and:[VeryLightGreyForm notNil]) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
535 |
^ VeryLightGreyForm |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
536 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
537 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
538 |
f := self width:8 height:4 fromArray:(self veryLightGreyFormBits) on:aDevice. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
539 |
(aDevice == Display) ifTrue:[ |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
540 |
VeryLightGreyForm := f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
541 |
]. |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
542 |
^ f |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
543 |
! ! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
544 |
|
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
545 |
!Form class methodsFor:'obsolete patterns'! |
0 | 546 |
|
278 | 547 |
darkGreyFormBits |
548 |
"return a pattern usable to simulate darkGray on monochrome device" |
|
0 | 549 |
|
278 | 550 |
^ #(2r10111011 |
551 |
2r11101110 |
|
552 |
2r10111011 |
|
553 |
2r11101110) |
|
0 | 554 |
! |
555 |
||
632
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
556 |
grey12Bits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
557 |
"return a pattern with 12% grey, usable for dithering" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
558 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
559 |
^ #(2r00010001 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
560 |
2r00000000 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
561 |
2r01000100 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
562 |
2r00000000) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
563 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
564 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
565 |
grey25Bits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
566 |
"return a pattern with 25% grey, usable for dithering" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
567 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
568 |
^ #(2r00010001 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
569 |
2r01000100 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
570 |
2r00010001 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
571 |
2r01000100) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
572 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
573 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
574 |
grey37Bits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
575 |
"return a pattern with 37% grey, usable for dithering" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
576 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
577 |
^ #(2r00010001 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
578 |
2r10101010 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
579 |
2r01000100 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
580 |
2r10101010) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
581 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
582 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
583 |
grey50Bits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
584 |
"return a pattern with 50% grey, usable for dithering" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
585 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
586 |
^ #(2r01010101 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
587 |
2r10101010 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
588 |
2r01010101 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
589 |
2r10101010) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
590 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
591 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
592 |
grey6Bits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
593 |
"return a pattern with 6% grey, usable for dithering" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
594 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
595 |
^ #(2r00000001 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
596 |
2r00000000 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
597 |
2r00010000 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
598 |
2r00000000) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
599 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
600 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
601 |
greyFormBits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
602 |
"return a pattern usable to simulate gray on monochrome device" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
603 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
604 |
^ #(2r01010101 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
605 |
2r10101010 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
606 |
2r01010101 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
607 |
2r10101010) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
608 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
609 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
610 |
lightGreyFormBits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
611 |
"return a pattern usable to simulate lightGray on monochrome device" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
612 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
613 |
^ #(2r01000100 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
614 |
2r00010001 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
615 |
2r01000100 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
616 |
2r00010001 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
617 |
2r01000100) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
618 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
619 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
620 |
veryDarkGreyFormBits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
621 |
"return a pattern usable to simulate veryDarkGray on monochrome device" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
622 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
623 |
^ #(2r01110111 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
624 |
2r11111111 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
625 |
2r11011101 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
626 |
2r11111111) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
627 |
! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
628 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
629 |
veryLightGreyFormBits |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
630 |
"return a pattern usable to simulate veryDarkGray on monochrome device" |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
631 |
|
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
632 |
^ #(2r10001000 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
633 |
2r00000000 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
634 |
2r00100010 |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
635 |
2r00000000) |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
636 |
! ! |
28cbc6517090
marked some obsolete; grey/gray (sigh)
Claus Gittinger <cg@exept.de>
parents:
610
diff
changeset
|
637 |
|
278 | 638 |
!Form methodsFor:'ST-80 compatibility'! |
639 |
||
640 |
displayOn:aGC at:aPoint |
|
641 |
"draw in aGC. |
|
642 |
Smalltalk-80 (2.x) compatibility" |
|
643 |
||
672 | 644 |
^ self displayOn:aGC x:aPoint x y:aPoint y rule:#copy |
645 |
||
646 |
"Modified: 12.5.1996 / 20:16:15 / cg" |
|
278 | 647 |
! |
648 |
||
649 |
displayOn:aGC at:aPoint rule:rule |
|
650 |
"draw in aGC. |
|
651 |
Smalltalk-80 (2.x) compatibility" |
|
652 |
||
672 | 653 |
self displayOn:aGC x:aPoint x y:aPoint y rule:rule |
654 |
||
655 |
"Modified: 12.5.1996 / 20:16:02 / cg" |
|
656 |
! |
|
657 |
||
658 |
displayOn:aGC rule:rule |
|
659 |
"draw in aGC. |
|
660 |
Smalltalk-80 (2.x) compatibility" |
|
661 |
||
662 |
^ self displayOn:aGC x:0 y:0 rule:rule |
|
663 |
||
664 |
"Modified: 12.5.1996 / 20:15:41 / cg" |
|
665 |
! |
|
666 |
||
667 |
displayOn:aGC x:x y:y |
|
668 |
"draw in aGC. |
|
669 |
Smalltalk-80 (2.x) compatibility" |
|
670 |
||
671 |
^ self displayOn:aGC x:x y:y rule:#copy |
|
672 |
||
673 |
"Created: 12.5.1996 / 20:15:05 / cg" |
|
674 |
! |
|
675 |
||
676 |
displayOn:aGC x:x y:y rule:rule |
|
677 |
"draw in aGC. |
|
678 |
Smalltalk-80 (2.x) compatibility" |
|
679 |
||
278 | 680 |
|f| |
681 |
||
682 |
f := aGC function. |
|
683 |
aGC function:rule. |
|
672 | 684 |
aGC displayOpaqueForm:self x:x y:y. |
278 | 685 |
aGC function:f. |
686 |
||
672 | 687 |
"Created: 12.5.1996 / 20:15:26 / cg" |
278 | 688 |
! |
689 |
||
690 |
offset |
|
691 |
"set the offset. |
|
692 |
Smalltalk-80 compatibility" |
|
693 |
||
694 |
^ offset |
|
695 |
! |
|
696 |
||
697 |
offset:org |
|
698 |
"set the offset. |
|
699 |
Smalltalk-80 compatibility" |
|
700 |
||
701 |
offset := org |
|
702 |
! ! |
|
703 |
||
704 |
!Form methodsFor:'accessing'! |
|
705 |
||
706 |
bits |
|
707 |
"return a ByteArray filled with my bits - |
|
708 |
for depth 8 forms, 1 pixel/byte is filled; |
|
709 |
for depth 1 forms, 8 pixels/byte are filled |
|
710 |
for depth 4 forms, 2 pixels/byte are filled. |
|
711 |
Padding is done to the next byte-boundary |
|
712 |
(i.e. for width==13 and depth==1 it will return 2 bytes per scanline)" |
|
713 |
||
714 |
|bytesPerLine "{ Class: SmallInteger }" |
|
715 |
bytesPerLineIn "{ Class: SmallInteger }" |
|
716 |
inData tmpData info |
|
717 |
srcIndex "{ Class: SmallInteger }" |
|
718 |
dstIndex "{ Class: SmallInteger }" |
|
719 |
buffer| |
|
720 |
||
721 |
data notNil ifTrue:[ |
|
915 | 722 |
^ data |
278 | 723 |
]. |
724 |
drawableId isNil ifTrue:[ |
|
915 | 725 |
fileName notNil ifTrue:[ |
726 |
^ (self on:Screen current) bits |
|
727 |
]. |
|
728 |
^ nil |
|
278 | 729 |
]. |
730 |
||
731 |
bytesPerLine := (width * depth + 31) // 32 * 4. |
|
732 |
inData := ByteArray uninitializedNew:(bytesPerLine * height). |
|
733 |
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
|
734 |
bytesPerLineIn := (info at:#bytesPerLine). "what I got" |
278 | 735 |
bytesPerLine := (width * depth + 7) // 8. "what I want" |
736 |
(bytesPerLine ~~ bytesPerLineIn) ifTrue:[ |
|
915 | 737 |
" |
738 |
different padding - have to copy over row-wise |
|
739 |
" |
|
740 |
tmpData := inData. |
|
741 |
inData := ByteArray uninitializedNew:(bytesPerLine * height). |
|
742 |
srcIndex := 1. |
|
743 |
dstIndex := 1. |
|
744 |
1 to:height do:[:hi | |
|
745 |
inData replaceFrom:dstIndex to:(dstIndex + bytesPerLine - 1) |
|
746 |
with:tmpData startingAt:srcIndex. |
|
747 |
dstIndex := dstIndex + bytesPerLine. |
|
748 |
srcIndex := srcIndex + bytesPerLineIn |
|
749 |
] |
|
278 | 750 |
] ifFalse:[ |
915 | 751 |
" |
752 |
same padding - copy over all in one chunk |
|
753 |
" |
|
754 |
(bytesPerLine * height) ~~ inData size ifTrue:[ |
|
755 |
tmpData := inData. |
|
756 |
inData := ByteArray uninitializedNew:(bytesPerLine * height). |
|
757 |
inData replaceFrom:1 to:bytesPerLine * height with:tmpData startingAt:1 |
|
758 |
] |
|
278 | 759 |
]. |
760 |
" |
|
761 |
have to reverse bytes, if not msbFirst ? |
|
762 |
" |
|
915 | 763 |
|
764 |
"/ (info at:#byteOrder) ~~ #msbFirst ifTrue:[ |
|
765 |
"/ buffer := ByteArray new:bytesPerLine. |
|
766 |
"/ dstIndex := 1. |
|
767 |
"/ 1 to:height do:[:hi | |
|
768 |
"/ buffer replaceFrom:1 to:bytesPerLine with:inData startingAt:dstIndex. |
|
769 |
"/ buffer reverse. |
|
770 |
"/ inData replaceFrom:dstIndex to:dstIndex+bytesPerLine-1 with:buffer startingAt:1. |
|
771 |
"/ dstIndex := dstIndex + bytesPerLine |
|
772 |
"/ ] |
|
773 |
"/ ]. |
|
398
2b35bb58a82b
changes for new returned info from getBits
Claus Gittinger <cg@exept.de>
parents:
278
diff
changeset
|
774 |
(info at:#bitOrder) ~~ #msbFirst ifTrue:[ |
915 | 775 |
buffer := ByteArray new:bytesPerLine. |
776 |
dstIndex := 1. |
|
777 |
1 to:height do:[:hi | |
|
778 |
buffer replaceFrom:1 to:bytesPerLine with:inData startingAt:dstIndex. |
|
779 |
buffer expandPixels:8 width:bytesPerLine height:1 into:buffer |
|
780 |
mapping:(ImageReader reverseBits). "/ translate only |
|
781 |
inData replaceFrom:dstIndex to:dstIndex+bytesPerLine-1 with:buffer startingAt:1. |
|
782 |
dstIndex := dstIndex + bytesPerLine |
|
783 |
] |
|
278 | 784 |
]. |
785 |
||
786 |
^ inData. |
|
787 |
! |
|
788 |
||
588 | 789 |
bits:aByteArray |
790 |
"set the forms bits; |
|
791 |
for depth-8 forms, 1 pixel/byte is expected; |
|
792 |
for depth-1 forms, 8 pixels/byte are expected |
|
793 |
for depth-4 forms, 2 pixels/byte are expected. |
|
794 |
Padding is expected to the next byte-boundary |
|
795 |
(i.e. for width==13 and depth==1 2 bytes per scanline are expected)" |
|
796 |
||
797 |
data := aByteArray |
|
798 |
||
799 |
"Modified: 23.4.1996 / 10:06:01 / cg" |
|
278 | 800 |
! |
801 |
||
802 |
bitsPerSample |
|
803 |
"for compatibility with Image class ..." |
|
804 |
||
805 |
^ Array with:depth |
|
806 |
! |
|
807 |
||
808 |
colorMap |
|
809 |
"return the receivers colormap" |
|
810 |
||
811 |
^ localColorMap |
|
812 |
! |
|
813 |
||
814 |
colorMap:anArray |
|
815 |
"set the receivers colormap" |
|
816 |
||
817 |
localColorMap := anArray |
|
818 |
! |
|
819 |
||
820 |
depth |
|
821 |
"return the receivers depth" |
|
822 |
||
823 |
^ depth |
|
824 |
! |
|
825 |
||
826 |
filename |
|
827 |
"return the filename, from which the receiver was created, |
|
828 |
or nil, if it was not read from a file" |
|
829 |
||
830 |
^ fileName |
|
831 |
! |
|
832 |
||
833 |
forgetBits |
|
834 |
"for image, which also keeps the bits - so there is |
|
835 |
no need to hold them again here" |
|
836 |
||
837 |
data := nil |
|
838 |
! |
|
839 |
||
897 | 840 |
mask |
841 |
"for compatibility with images; forms have no mask/alpha channel" |
|
842 |
||
843 |
^ nil |
|
844 |
||
845 |
"Created: 21.6.1996 / 12:52:42 / cg" |
|
846 |
! |
|
847 |
||
278 | 848 |
photometric |
849 |
"for compatibility with Image class ..." |
|
850 |
||
851 |
depth == 1 ifTrue:[ |
|
872 | 852 |
localColorMap isNil ifTrue:[ |
853 |
^ #whiteIs0 |
|
854 |
]. |
|
855 |
((localColorMap at:1) = Color white) ifTrue:[ |
|
856 |
((localColorMap at:2) = Color black) ifTrue:[ |
|
857 |
^ #whiteIs0 |
|
858 |
]. |
|
859 |
]. |
|
860 |
((localColorMap at:1) = Color black) ifTrue:[ |
|
861 |
((localColorMap at:2) = Color white) ifTrue:[ |
|
862 |
^ #blackIs0 |
|
863 |
]. |
|
864 |
]. |
|
278 | 865 |
]. |
866 |
^ #palette |
|
872 | 867 |
|
868 |
"Modified: 17.6.1996 / 11:45:16 / cg" |
|
278 | 869 |
! |
870 |
||
871 |
samplesperPixel |
|
872 |
"for compatibility with Image class ..." |
|
873 |
||
874 |
^ 1 |
|
875 |
! |
|
876 |
||
877 |
valueAt:aPoint |
|
588 | 878 |
"return the pixel at aPoint; the coordinates start with 0@0 |
879 |
in the upper left, increasing to the lower right" |
|
880 |
||
278 | 881 |
^ self at:aPoint |
588 | 882 |
|
883 |
"Modified: 23.4.1996 / 10:06:55 / cg" |
|
278 | 884 |
! |
885 |
||
886 |
valueAt:aPoint put:value |
|
588 | 887 |
"set the pixel at aPoint; the coordinates start with 0@0 |
888 |
in the upper left, increasing to the lower right." |
|
889 |
||
278 | 890 |
^ self at:aPoint put:value |
588 | 891 |
|
892 |
" |
|
893 |
|f| |
|
894 |
||
895 |
f := Form width:10 height:10 depth:1. |
|
896 |
f clear. |
|
897 |
1 to:10 do:[:i | |
|
898 |
f valueAt:(i @ i) put:1 |
|
899 |
]. |
|
900 |
f inspect |
|
901 |
" |
|
902 |
||
903 |
"Modified: 23.4.1996 / 10:12:48 / cg" |
|
278 | 904 |
! ! |
905 |
||
906 |
!Form methodsFor:'binary storage'! |
|
907 |
||
908 |
readBinaryContentsFrom: stream manager: manager |
|
909 |
"tell the newly restored Form about restoration" |
|
910 |
||
911 |
super readBinaryContentsFrom: stream manager: manager. |
|
912 |
device := Screen current. |
|
913 |
fileName := nil. |
|
914 |
self restored. |
|
915 |
self recreate. |
|
916 |
Lobby register:self. |
|
917 |
||
918 |
" |
|
919 |
|f| |
|
920 |
||
921 |
f := Form fromFile:'bitmaps/SBrowser.xbm'. |
|
922 |
f storeBinaryOn:'foo.bos'. |
|
923 |
||
924 |
(Form readBinaryFrom:'foo.bos') inspect |
|
925 |
" |
|
926 |
! |
|
927 |
||
928 |
storeBinaryDefinitionOn: stream manager: manager |
|
929 |
"store a binary representation of the receiver on stream. |
|
588 | 930 |
This is an internal interface for binary storage mechanism. |
278 | 931 |
Redefined to store the actual bits, even if I have been loaded |
932 |
from a file." |
|
933 |
||
934 |
data isNil ifTrue:[ |
|
588 | 935 |
data := self bits. |
936 |
super storeBinaryDefinitionOn: stream manager: manager. |
|
937 |
data := nil. |
|
938 |
^ self |
|
278 | 939 |
]. |
940 |
super storeBinaryDefinitionOn: stream manager: manager |
|
588 | 941 |
|
942 |
"Modified: 23.4.1996 / 09:30:47 / cg" |
|
278 | 943 |
! ! |
944 |
||
945 |
!Form methodsFor:'converting'! |
|
946 |
||
947 |
asForm |
|
588 | 948 |
"convert & return the receiver into a Form instance - nothing to be done here" |
949 |
||
278 | 950 |
^ self |
588 | 951 |
|
952 |
"Modified: 23.4.1996 / 10:14:11 / cg" |
|
278 | 953 |
! |
954 |
||
955 |
asImage |
|
588 | 956 |
"convert & return the receiver into an Image instance" |
957 |
||
278 | 958 |
^ Image fromForm:self |
588 | 959 |
|
960 |
"Modified: 23.4.1996 / 10:13:56 / cg" |
|
278 | 961 |
! ! |
962 |
||
963 |
!Form methodsFor:'copying'! |
|
964 |
||
965 |
postCopy |
|
588 | 966 |
"redefined to copy the colorMap as well" |
967 |
||
278 | 968 |
super postCopy. |
969 |
localColorMap := localColorMap copy. |
|
970 |
data := data copy |
|
588 | 971 |
|
972 |
"Modified: 23.4.1996 / 10:14:46 / cg" |
|
278 | 973 |
! |
974 |
||
975 |
shallowCopyForFinalization |
|
976 |
"redefined for faster creation of finalization copies |
|
977 |
(only device, gcId and drawableId are needed)" |
|
978 |
||
979 |
|aCopy| |
|
980 |
||
981 |
aCopy := DeviceFormHandle basicNew. |
|
982 |
aCopy setDevice:device id:drawableId gcId:gcId. |
|
983 |
^ aCopy |
|
984 |
! ! |
|
985 |
||
986 |
!Form methodsFor:'editing'! |
|
987 |
||
988 |
edit |
|
588 | 989 |
"open an imageEditor on the receiver" |
990 |
||
278 | 991 |
ImageEditView openOnImage:self |
992 |
||
993 |
" |
|
994 |
(Form fromFile:'bitmaps/SBrowser.xbm') edit |
|
995 |
" |
|
588 | 996 |
|
997 |
"Modified: 23.4.1996 / 10:16:02 / cg" |
|
278 | 998 |
! |
999 |
||
1000 |
show |
|
588 | 1001 |
"open an imageView on the receiver" |
1002 |
||
278 | 1003 |
ImageView openOnImage:self |
1004 |
||
1005 |
" |
|
1006 |
(Form fromFile:'bitmaps/SBrowser.xbm') show |
|
1007 |
" |
|
588 | 1008 |
|
1009 |
"Modified: 23.4.1996 / 10:16:12 / cg" |
|
278 | 1010 |
! ! |
1011 |
||
1012 |
!Form methodsFor:'getting a device form'! |
|
1013 |
||
1014 |
asFormOn:aDevice |
|
588 | 1015 |
"convert & return the receiver into a Form instance |
1016 |
and associate it to a device (i.e. download its bits). |
|
1017 |
Added for protocol compatibility with Image." |
|
1018 |
||
278 | 1019 |
aDevice == device ifTrue:[ |
588 | 1020 |
^ self |
278 | 1021 |
]. |
1022 |
^ self on:aDevice |
|
588 | 1023 |
|
1024 |
"Modified: 23.4.1996 / 10:17:26 / cg" |
|
278 | 1025 |
! |
1026 |
||
1027 |
asMonochromeFormOn:aDevice |
|
588 | 1028 |
"added for protocol compatiblity with Image" |
1029 |
||
278 | 1030 |
aDevice == device ifTrue:[ |
588 | 1031 |
depth == 1 ifTrue:[ |
1032 |
^ self |
|
1033 |
]. |
|
278 | 1034 |
]. |
1035 |
(depth == 1) ifTrue:[ |
|
588 | 1036 |
^ self on:aDevice |
278 | 1037 |
]. |
1038 |
^ nil |
|
588 | 1039 |
|
1040 |
"Modified: 23.4.1996 / 10:18:42 / cg" |
|
278 | 1041 |
! |
1042 |
||
1043 |
on:aDevice |
|
588 | 1044 |
"associate the receiver to a device (i.e. download its bits); |
1045 |
return a deviceForm (possibly different from the receiver)." |
|
1046 |
||
278 | 1047 |
aDevice == device ifTrue:[ |
588 | 1048 |
^ self |
278 | 1049 |
]. |
1050 |
"create a new form ..." |
|
1051 |
||
1052 |
data notNil ifTrue:[ |
|
588 | 1053 |
^ self class width:width height:height fromArray:data on:aDevice |
278 | 1054 |
]. |
1055 |
fileName notNil ifTrue:[ |
|
588 | 1056 |
^ self class fromFile:fileName on:aDevice |
278 | 1057 |
]. |
1058 |
^ self width:width height:height on:aDevice |
|
588 | 1059 |
|
1060 |
"Modified: 23.4.1996 / 10:18:05 / cg" |
|
278 | 1061 |
! ! |
1062 |
||
1063 |
!Form methodsFor:'image manipulations'! |
|
1064 |
||
1065 |
darkened |
|
588 | 1066 |
"return a darkened version of the receiver. |
1067 |
Added for protocol compatibility with Color and Image. |
|
1068 |
Here, the receiver is returned as a kludge |
|
1069 |
- actually should return a darkened image (or Color black ?) .." |
|
278 | 1070 |
|
1071 |
^ self |
|
588 | 1072 |
|
1073 |
"Modified: 23.4.1996 / 10:19:52 / cg" |
|
278 | 1074 |
! |
1075 |
||
1076 |
flipHorizontal |
|
1077 |
"return a new form flipped horizontally" |
|
1078 |
||
1079 |
|dstY newForm nRows "{ Class: SmallInteger }" | |
|
1080 |
||
1081 |
newForm := ((self class) on:device) |
|
1082 |
width:width |
|
1083 |
height:height |
|
1084 |
depth:depth. |
|
1085 |
"expand rows" |
|
1086 |
dstY := height - 1. |
|
1087 |
nRows := dstY // 2. |
|
1088 |
0 to:nRows do:[:srcY | |
|
1089 |
newForm copyFrom:self |
|
1090 |
x:0 y:srcY |
|
1091 |
toX:0 y:dstY |
|
1092 |
width:width height:1. |
|
1093 |
dstY := dstY - 1 |
|
1094 |
]. |
|
1095 |
newForm colorMap:localColorMap. |
|
1096 |
^ newForm |
|
1097 |
! |
|
1098 |
||
1099 |
flipVertical |
|
1100 |
"return a new form flipped vertically" |
|
1101 |
||
1102 |
|dstX newForm nCols "{ Class: SmallInteger }" | |
|
1103 |
||
1104 |
newForm := ((self class) on:device) |
|
1105 |
width:width |
|
1106 |
height:height |
|
1107 |
depth:depth. |
|
1108 |
"expand cols" |
|
1109 |
dstX := width - 1. |
|
1110 |
nCols := dstX // 2. |
|
1111 |
0 to:nCols do:[:srcX | |
|
1112 |
newForm copyFrom:self |
|
1113 |
x:srcX y:0 |
|
1114 |
toX:dstX y:0 |
|
1115 |
width:1 height:height. |
|
1116 |
dstX := dstX - 1 |
|
1117 |
]. |
|
1118 |
newForm colorMap:localColorMap. |
|
1119 |
^ newForm |
|
1120 |
! |
|
1121 |
||
1122 |
hardMagnifiedBy:extent |
|
1123 |
"return a new form magnified by extent, aPoint. |
|
1124 |
This method handles non-integral factors." |
|
1125 |
||
1126 |
" |
|
1127 |
since Form will be replaced by Image in the long run, |
|
1128 |
and this operation is slow anyway, use the implementation |
|
1129 |
in Image for this." |
|
1130 |
||
1131 |
^ ((Image fromForm:self) magnifiedBy:extent) asFormOn:device. |
|
1132 |
||
1133 |
" |
|
1134 |
(Form fromFile:'OutputOn.64') magnifiedBy:0.5@0.5 |
|
1135 |
(Form fromFile:'OutputOn.64') magnifiedBy:1.5@1.5 |
|
1136 |
" |
|
1137 |
! |
|
1138 |
||
1139 |
lightened |
|
588 | 1140 |
"return a lightened version of the receiver. |
1141 |
Added for protocol compatibility with Color and Image. |
|
1142 |
Here, the receiver is returned as a kludge |
|
1143 |
- actually should return a lightened image (or Color white ?) .." |
|
278 | 1144 |
|
1145 |
^ self |
|
588 | 1146 |
|
1147 |
"Modified: 23.4.1996 / 10:20:14 / cg" |
|
278 | 1148 |
! |
1149 |
||
1150 |
magnifiedBy:extent |
|
1151 |
"return a new form magnified by extent, aPoint. |
|
1152 |
If non-integral magnify is asked for, pass the work on to 'hardMagnifiedBy:'" |
|
1153 |
||
1154 |
|mX mY dstX dstY newForm ext |
|
1155 |
factor "{ Class: SmallInteger }" |
|
1156 |
n "{ Class: SmallInteger }" | |
|
1157 |
||
1158 |
ext := extent asPoint. |
|
1159 |
mX := ext x. |
|
1160 |
mY := ext y. |
|
1161 |
((mX = 1) and:[mY = 1]) ifTrue:[^ self]. |
|
1162 |
||
1163 |
((mX isMemberOf:SmallInteger) and:[mY isMemberOf:SmallInteger]) ifFalse:[ |
|
1164 |
^ self hardMagnifiedBy:ext |
|
1165 |
]. |
|
1166 |
||
1167 |
newForm := ((self class) on:device) |
|
1168 |
width:(width * mX) |
|
1169 |
height:(height * mY) |
|
1170 |
depth:depth. |
|
1171 |
||
1172 |
"expand rows" |
|
1173 |
(mY > 1) ifTrue:[ |
|
1174 |
dstY := 0. |
|
1175 |
n := height. |
|
1176 |
factor := mY. |
|
1177 |
0 to:(n - 1) do:[:srcY | |
|
1178 |
1 to:factor do:[:i | |
|
1179 |
newForm copyFrom:self |
|
1180 |
x:0 y:srcY |
|
1181 |
toX:0 y:dstY |
|
1182 |
width:width height:1. |
|
1183 |
dstY := dstY + 1 |
|
1184 |
] |
|
1185 |
] |
|
1186 |
]. |
|
1187 |
||
1188 |
"expand cols" |
|
1189 |
(mX > 1) ifTrue:[ |
|
1190 |
n := width. |
|
1191 |
factor := mX. |
|
1192 |
dstX := (n * factor) - 1. |
|
1193 |
(n - 1) to:0 by:-1 do:[:srcX | |
|
1194 |
1 to:factor do:[:i | |
|
1195 |
newForm copyFrom:newForm |
|
1196 |
x:srcX y:0 |
|
1197 |
toX:dstX y:0 |
|
1198 |
width:1 height:(height * mY). |
|
1199 |
dstX := dstX - 1 |
|
1200 |
] |
|
1201 |
] |
|
1202 |
]. |
|
1203 |
newForm colorMap:localColorMap. |
|
1204 |
^ newForm |
|
1205 |
||
1206 |
" |
|
1207 |
(ArrowButton upArrowButtonForm:#iris on:Display) magnifiedBy:(2 @ 2) |
|
1208 |
(Form fromFile:'bitmaps/SBrowser.xbm') magnifiedBy:(2 @ 2) |
|
1209 |
(Form fromFile:'bitmaps/SBrowser.xbm') magnifiedBy:(0.4 @ 0.4) |
|
1210 |
" |
|
1211 |
! |
|
1212 |
||
569
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1213 |
magnifiedTo:anExtent |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1214 |
"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
|
1215 |
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
|
1216 |
See also #magnifiedPreservingRatioTo: and #magnifiedBy:" |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1217 |
|
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1218 |
^ self magnifiedBy:(anExtent / self extent) |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1219 |
|
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1220 |
"Created: 18.4.1996 / 16:17:52 / cg" |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1221 |
! |
7dee80bce37b
added #magnifiedTo: (protocol compatibility with Image)
Claus Gittinger <cg@exept.de>
parents:
425
diff
changeset
|
1222 |
|
278 | 1223 |
magnifyBy:scale |
1224 |
"obsolete: has been renamed to magnifiedBy: for ST-80 compatibility |
|
1225 |
and name consistency ..." |
|
1226 |
||
1227 |
self obsoleteMethodWarning. |
|
1228 |
^ self magnifiedBy:scale |
|
0 | 1229 |
! ! |
1230 |
||
1231 |
!Form methodsFor:'initialization'! |
|
1232 |
||
1233 |
initGC |
|
1234 |
"stop server from sending exposure events for Forms - |
|
1235 |
(will fill up stream-queue on some stupid (i.e. sco) systems" |
|
1236 |
||
951 | 1237 |
"/ depth-1 forms draw differently ... |
1238 |
||
1239 |
depth == 1 ifTrue:[ |
|
1240 |
foreground isNil ifTrue:[ |
|
1241 |
foreground := paint := Color colorId:1. |
|
1242 |
]. |
|
1243 |
background isNil ifTrue:[ |
|
1244 |
background := bgPaint := Color colorId:0 |
|
1245 |
] |
|
1246 |
]. |
|
126 | 1247 |
super initGC. |
0 | 1248 |
self setGraphicsExposures:false |
836
d6eb406b1c04
dither bitmaps moved to Color
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
1249 |
|
951 | 1250 |
"Modified: 17.7.1996 / 13:21:24 / cg" |
0 | 1251 |
! |
1252 |
||
278 | 1253 |
initialize |
951 | 1254 |
foreground := paint := Color colorId:1. |
1255 |
background := bgPaint := Color colorId:0. |
|
1256 |
||
278 | 1257 |
super initialize. |
1258 |
depth := 1. |
|
836
d6eb406b1c04
dither bitmaps moved to Color
Claus Gittinger <cg@exept.de>
parents:
789
diff
changeset
|
1259 |
|
951 | 1260 |
"/ foreground isNil ifTrue:[ |
1261 |
"/ foreground := Color colorId:1. |
|
1262 |
"/ ]. |
|
1263 |
"/ paint isNil ifTrue:[ |
|
1264 |
"/ paint := foreground. |
|
1265 |
"/ ]. |
|
1266 |
"/ background isNil ifTrue:[ |
|
1267 |
"/ background := Color colorId:0 |
|
1268 |
"/ ]. |
|
1269 |
"/ bgPaint isNil ifTrue:[ |
|
1270 |
"/ bgPaint := background |
|
1271 |
"/ ] |
|
1272 |
||
1273 |
"Modified: 17.7.1996 / 13:02:01 / cg" |
|
278 | 1274 |
! |
1275 |
||
0 | 1276 |
recreate |
1277 |
"reconstruct the form after a snapin" |
|
1278 |
||
1279 |
data notNil ifTrue:[ |
|
871
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1280 |
" |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1281 |
create one from data |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1282 |
" |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1283 |
(depth == 1 or:[depth == device depth]) ifTrue:[ |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1284 |
drawableId := device createBitmapFromArray:data width:width height:height. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1285 |
Lobby registerChange:self. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1286 |
drawableId notNil ifTrue:[ |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1287 |
^ self |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1288 |
] |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1289 |
]. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1290 |
'FORM: cannot recreate form' errorPrintCR. |
0 | 1291 |
]. |
1292 |
fileName notNil ifTrue:[ |
|
871
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1293 |
" |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1294 |
create one from a file (mhmh - this seems X-specific and will vanish) |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1295 |
" |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1296 |
self readFromFile:fileName. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1297 |
|
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1298 |
"/ drawableId := device createBitmapFromFile:fileName for:self. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1299 |
"/ Lobby registerChange:self. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1300 |
drawableId notNil ifTrue:[ |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1301 |
^ self |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1302 |
]. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1303 |
'FORM: cannot recreate file form: ' errorPrint. fileName errorPrintCR. |
0 | 1304 |
]. |
871
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1305 |
|
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1306 |
^ self. |
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1307 |
|
118 | 1308 |
" |
1309 |
create an empty one |
|
1310 |
" |
|
0 | 1311 |
depth == 1 ifTrue:[ |
871
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1312 |
drawableId := device createBitmapWidth:width height:height |
0 | 1313 |
] ifFalse:[ |
871
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1314 |
drawableId := device createPixmapWidth:width height:height depth:device depth |
118 | 1315 |
]. |
162 | 1316 |
Lobby registerChange:self |
871
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1317 |
|
c078c33c51ac
recreate was somehow corrupted ?!
Claus Gittinger <cg@exept.de>
parents:
870
diff
changeset
|
1318 |
"Modified: 15.6.1996 / 16:18:12 / cg" |
2 | 1319 |
! ! |
1320 |
||
278 | 1321 |
!Form methodsFor:'inspecting'! |
127 | 1322 |
|
278 | 1323 |
inspectorClass |
1324 |
"redefined to launch an ImageInspector |
|
1325 |
(instead of the default InspectorView)." |
|
2 | 1326 |
|
278 | 1327 |
^ ImageInspectorView |
2 | 1328 |
! ! |
1329 |
||
278 | 1330 |
!Form methodsFor:'printing & storing'! |
107 | 1331 |
|
278 | 1332 |
storeOn:aStream |
588 | 1333 |
"append an ascii representation of the receiver to aStream, |
1334 |
from which a copy of the receiver can be reconstructed" |
|
1335 |
||
278 | 1336 |
aStream nextPutAll:'(Form width:'. |
1337 |
width storeOn:aStream. |
|
1338 |
aStream nextPutAll:' height:'. |
|
1339 |
height storeOn:aStream. |
|
1340 |
aStream nextPutAll:' fromArray:('. |
|
1341 |
self bits storeOn:aStream. |
|
1342 |
aStream nextPutAll:'))' |
|
588 | 1343 |
|
1344 |
"Modified: 23.4.1996 / 10:21:10 / cg" |
|
107 | 1345 |
! ! |
1346 |
||
0 | 1347 |
!Form methodsFor:'private'! |
1348 |
||
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
|
1349 |
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
|
1350 |
"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
|
1351 |
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
|
1352 |
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
|
1353 |
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
|
1354 |
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
|
1355 |
|
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
|
1356 |
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
|
1357 |
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
|
1358 |
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
|
1359 |
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
|
1360 |
] |
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
|
1361 |
] |
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
|
1362 |
|
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
|
1363 |
" |
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
|
1364 |
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
|
1365 |
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
|
1366 |
] |
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
|
1367 |
" |
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
|
1368 |
|
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
|
1369 |
"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
|
1370 |
! |
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
|
1371 |
|
870
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1372 |
flushDeviceHandles |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1373 |
"flush device handles (sent after a restart)" |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1374 |
|
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1375 |
drawableId := nil. |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1376 |
gcId := nil. |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1377 |
|
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1378 |
"Created: 15.6.1996 / 15:44:28 / cg" |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1379 |
! |
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1380 |
|
54 | 1381 |
getBits |
1382 |
"if the receiver was not created from a file, or |
|
1383 |
an array (i.e. it was drawn), read the pixels from the |
|
1384 |
device into a local data array. This has to be done before |
|
1385 |
an image is saved, or the receiver is storedBinary, since |
|
1386 |
the information present in the device is lost after restart/reload" |
|
1387 |
||
1388 |
(data isNil and:[fileName isNil]) ifTrue:[ |
|
78 | 1389 |
data := self bits |
54 | 1390 |
] |
1391 |
! |
|
1392 |
||
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
|
1393 |
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
|
1394 |
"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
|
1395 |
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
|
1396 |
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
|
1397 |
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
|
1398 |
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
|
1399 |
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
|
1400 |
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
|
1401 |
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
|
1402 |
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
|
1403 |
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
|
1404 |
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
|
1405 |
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
|
1406 |
" |
278 | 1407 |
|
1408 |
|pathName| |
|
1409 |
||
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
|
1410 |
pathName := self class findBitmapFile:fn. |
278 | 1411 |
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
|
1412 |
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
|
1413 |
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
|
1414 |
|
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
|
1415 |
"/ 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
|
1416 |
fileName := fn. "/ keep the relative name (better - SEARCHPATH may be different at restart) |
278 | 1417 |
|
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
|
1418 |
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
|
1419 |
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
|
1420 |
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
|
1421 |
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
|
1422 |
]. |
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
|
1423 |
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
|
1424 |
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
|
1425 |
^ self |
278 | 1426 |
]. |
1427 |
^ 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
|
1428 |
|
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
|
1429 |
"Modified: 7.2.1996 / 16:04:25 / cg" |
278 | 1430 |
! |
1431 |
||
1432 |
readFromFile:filename resolution:dpi |
|
1433 |
"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
|
1434 |
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
|
1435 |
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
|
1436 |
after an image reload." |
278 | 1437 |
|
1438 |
|dpiH mag dev| |
|
1439 |
||
1440 |
(self readFromFile:filename) isNil ifTrue:[^ nil]. |
|
1441 |
||
1442 |
"if the device is within +- 50% of dpi, no magnify is needed" |
|
1443 |
dev := device. |
|
1444 |
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
|
1445 |
"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
|
1446 |
dev := Screen current |
278 | 1447 |
]. |
1448 |
dpiH := dev horizontalPixelPerInch. |
|
1449 |
((dpi >= (dpiH * 0.75)) and:[dpi <= (dpiH * 1.5)]) ifTrue:[^ self]. |
|
1450 |
mag := (dpiH / dpi) rounded. |
|
1451 |
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
|
1452 |
^ self |
278 | 1453 |
]. |
1454 |
^ self magnifiedBy:(mag @ mag) |
|
1455 |
||
1456 |
"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
|
1457 |
|
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
|
1458 |
"Modified: 7.2.1996 / 16:03:45 / cg" |
278 | 1459 |
! |
1460 |
||
1461 |
restored |
|
870
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1462 |
"flush device data, when restored (sent after a binaryLoad)" |
278 | 1463 |
|
425
7e1df86e2517
flush device ref when restored
Claus Gittinger <cg@exept.de>
parents:
412
diff
changeset
|
1464 |
device := nil. |
278 | 1465 |
drawableId := nil. |
1466 |
gcId := nil. |
|
870
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1467 |
|
2b7db80e7ad1
oops - restart mechanism got corrupted
Claus Gittinger <cg@exept.de>
parents:
836
diff
changeset
|
1468 |
"Modified: 15.6.1996 / 15:43:39 / cg" |
278 | 1469 |
! |
1470 |
||
0 | 1471 |
width:w height:h |
54 | 1472 |
"actual create of a monochrome form" |
0 | 1473 |
|
1474 |
((w == 0) or:[h == 0]) ifTrue:[ |
|
78 | 1475 |
self error:'invalid form extent'. |
1476 |
^ nil |
|
0 | 1477 |
]. |
1478 |
width := w. |
|
1479 |
height := h. |
|
54 | 1480 |
depth := 1. |
0 | 1481 |
offset := 0@0. |
1482 |
drawableId := device createBitmapWidth:w height:h. |
|
1483 |
drawableId isNil ifTrue:[^ nil]. |
|
1484 |
BlackAndWhiteColorMap isNil ifTrue:[ |
|
78 | 1485 |
BlackAndWhiteColorMap := Array with:(Color white) with:(Color black) |
0 | 1486 |
]. |
1487 |
localColorMap := BlackAndWhiteColorMap. |
|
1488 |
realized := true. |
|
162 | 1489 |
Lobby registerChange:self. |
0 | 1490 |
! |
1491 |
||
1492 |
width:w height:h depth:d |
|
54 | 1493 |
"actual create of an arbitrary deep form (but, must be supported by device)" |
0 | 1494 |
|
1495 |
width := w. |
|
1496 |
height := h. |
|
1497 |
offset := 0@0. |
|
1498 |
drawableId := device createPixmapWidth:w height:h depth:d. |
|
1499 |
drawableId isNil ifTrue:[^ nil]. |
|
1500 |
realized := true. |
|
1501 |
depth := d. |
|
162 | 1502 |
Lobby registerChange:self. |
0 | 1503 |
! |
1504 |
||
1505 |
width:w height:h fromArray:anArray |
|
54 | 1506 |
"actual create of a monochrome form from array. |
0 | 1507 |
This method is somewhat more complicated as it should be due to |
1508 |
supporting both byte-wise (ST/X-type) and short-word-wise (ST-80-type) |
|
1509 |
Arrays; in the later case, the shorts are first converted to bytes in |
|
1510 |
a ByteArray, then passed to the device." |
|
1511 |
||
134 | 1512 |
|bytes bits |
1513 |
srcPerRow "{ Class: SmallInteger }" |
|
1514 |
dstPerRow "{ Class: SmallInteger }" |
|
1515 |
srcStart "{ Class: SmallInteger }" |
|
1516 |
srcIndex "{ Class: SmallInteger }" |
|
1517 |
dstIndex "{ Class: SmallInteger }" |
|
1518 |
hi "{ Class: SmallInteger }" | |
|
0 | 1519 |
|
1520 |
bytes := anArray. |
|
1521 |
||
1522 |
anArray size ~~ (((w + 7) // 8) * h) ifTrue:[ |
|
78 | 1523 |
anArray size == (((w + 15) // 16) * h) ifTrue:[ |
1524 |
"I want the bytes but got shorts (ST-80)" |
|
1525 |
bytes := ByteArray uninitializedNew:(((w + 7) // 8) * h). |
|
1526 |
srcPerRow := (w + 15) // 16. |
|
1527 |
dstPerRow := (w + 7) // 8. |
|
1528 |
srcStart := 1. |
|
1529 |
dstIndex := 1. |
|
134 | 1530 |
hi := h. |
1531 |
1 to:hi do:[:hi | |
|
78 | 1532 |
srcIndex := srcStart. |
1533 |
bits := anArray at:srcIndex. |
|
1534 |
1 to:dstPerRow do:[:di | |
|
1535 |
di odd ifTrue:[ |
|
1536 |
bits := anArray at:srcIndex. |
|
1537 |
bytes at:dstIndex put:(bits bitShift:-8) |
|
1538 |
] ifFalse:[ |
|
1539 |
bytes at:dstIndex put:(bits bitAnd:16rFF). |
|
1540 |
srcIndex := srcIndex + 1 |
|
1541 |
]. |
|
1542 |
dstIndex := dstIndex + 1 |
|
1543 |
]. |
|
1544 |
srcStart := srcStart + srcPerRow |
|
1545 |
] |
|
1546 |
] |
|
0 | 1547 |
]. |
1548 |
width := w. |
|
1549 |
height := h. |
|
54 | 1550 |
depth := 1. |
0 | 1551 |
offset := 0@0. |
1552 |
drawableId := device createBitmapFromArray:bytes width:w height:h. |
|
1553 |
drawableId isNil ifTrue:[^ nil]. |
|
1554 |
||
1555 |
data := bytes. |
|
1556 |
BlackAndWhiteColorMap isNil ifTrue:[ |
|
78 | 1557 |
BlackAndWhiteColorMap := Array with:(Color white) with:(Color black) |
0 | 1558 |
]. |
1559 |
localColorMap := BlackAndWhiteColorMap. |
|
1560 |
realized := true. |
|
162 | 1561 |
Lobby registerChange:self. |
0 | 1562 |
! |
1563 |
||
1564 |
width:w height:h offset:offs fromArray:anArray |
|
54 | 1565 |
"actual create of a monochrome form from array" |
0 | 1566 |
|
1567 |
self width:w height:h fromArray:anArray. |
|
1568 |
offset := offs |
|
1569 |
! ! |
|
1570 |
||
99 | 1571 |
!Form methodsFor:'queries '! |
1572 |
||
680
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1573 |
bounds |
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1574 |
"return my bounds (added to make forms usable as VisualComponents)" |
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1575 |
|
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1576 |
^ Rectangle left:0 top:0 width:width height:height |
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1577 |
|
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1578 |
"Modified: 13.5.1996 / 10:26:13 / cg" |
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1579 |
! |
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1580 |
|
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1581 |
colorFromValue:pixel |
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1582 |
localColorMap notNil ifTrue:[ |
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1583 |
^ localColorMap at:(pixel + 1) |
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1584 |
]. |
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1585 |
depth == 1 ifTrue:[ |
951 | 1586 |
pixel == 0 ifTrue:[^ White]. |
1587 |
^ Black |
|
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1588 |
]. |
951 | 1589 |
^ Black |
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1590 |
|
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1591 |
"Created: 28.6.1996 / 16:10:13 / cg" |
951 | 1592 |
"Modified: 17.7.1996 / 13:05:59 / cg" |
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1593 |
! |
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1594 |
|
925 | 1595 |
hasBits |
1596 |
"return true, if the receiver has its pixel data available. |
|
1597 |
For forms, which were created from data, this is always true. |
|
1598 |
For forms, which were created as off-screen device forms on some |
|
1599 |
device, this is always false." |
|
1600 |
||
1601 |
^ data notNil |
|
1602 |
||
1603 |
"Created: 5.7.1996 / 16:21:20 / cg" |
|
1604 |
! |
|
1605 |
||
673 | 1606 |
heightOn:aGC |
674 | 1607 |
"return my height, if displayed on aGC; |
1608 |
since my height is independent of the device (the number of pixels), |
|
1609 |
return the pixel-height" |
|
1610 |
||
680
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1611 |
^ height |
673 | 1612 |
|
1613 |
"Created: 12.5.1996 / 21:35:33 / cg" |
|
680
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1614 |
"Modified: 13.5.1996 / 10:26:09 / cg" |
673 | 1615 |
! |
1616 |
||
99 | 1617 |
isForm |
1618 |
"return true, if the receiver is some kind of form; |
|
1619 |
true is returned here - the method is redefined from Object." |
|
1620 |
||
1621 |
^ true |
|
1622 |
! |
|
1623 |
||
1624 |
isImageOrForm |
|
1625 |
"return true, if the receiver is some kind of image or form; |
|
1626 |
true is returned here - the method is redefined from Object." |
|
1627 |
||
1628 |
^ true |
|
673 | 1629 |
! |
1630 |
||
1631 |
widthOn:aGC |
|
674 | 1632 |
"return my width, if displayed on aGC; |
1633 |
since my width is independent of the device (the number of pixels), |
|
1634 |
return the pixel-width" |
|
1635 |
||
680
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1636 |
^ width |
673 | 1637 |
|
1638 |
"Created: 12.5.1996 / 21:35:29 / cg" |
|
680
a905d02dcb82
added #bounds (for VisualComponent protocol compatibility)
Claus Gittinger <cg@exept.de>
parents:
674
diff
changeset
|
1639 |
"Modified: 13.5.1996 / 10:26:05 / cg" |
99 | 1640 |
! ! |
1641 |
||
910
6a19a80f66b4
added colorFromValue: for Image compatibility
Claus Gittinger <cg@exept.de>
parents:
897
diff
changeset
|
1642 |
!Form class methodsFor:'documentation'! |
134 | 1643 |
|
278 | 1644 |
version |
951 | 1645 |
^ '$Header: /cvs/stx/stx/libview/Form.st,v 1.62 1996-07-17 12:19:00 cg Exp $' |
0 | 1646 |
! ! |
278 | 1647 |
Form initialize! |