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