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