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