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