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