author | Claus Gittinger <cg@exept.de> |
Tue, 24 Feb 2004 11:35:43 +0100 | |
changeset 2650 | f41da3ee2446 |
parent 2544 | bcae3dbd3ccd |
child 2659 | 3af857eb52fb |
permissions | -rw-r--r-- |
1 | 1 |
" |
2 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
24 | 3 |
All Rights Reserved |
1 | 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 |
||
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1694
diff
changeset
|
13 |
"{ Package: 'stx:libwidg2' }" |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1694
diff
changeset
|
14 |
|
296 | 15 |
View subclass:#ImageView |
2158 | 16 |
instanceVariableNames:'image magnifiedImage adjust imageChannel tileMode tileOffset' |
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
17 |
classVariableNames:'DoNotMagnifyQuery' |
161 | 18 |
poolDictionaries:'' |
19 |
category:'Views-Misc' |
|
1 | 20 |
! |
21 |
||
257 | 22 |
!ImageView class methodsFor:'documentation'! |
26 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
This View knows how to display an image (or form). |
|
41 |
||
42 |
You can display an image with: |
|
43 |
||
2650 | 44 |
ImageView openOn:anImageFileName |
26 | 45 |
or: |
2650 | 46 |
ImageView openOnImage:anImage |
47 | 47 |
or: |
2650 | 48 |
ImageView new image:anImage |
26 | 49 |
|
50 |
i.e. |
|
51 |
||
2650 | 52 |
ImageView openOn:'bitmaps/gifImages/garfield.gif' |
53 |
ImageView openOn:'bitmaps/SBrowser.xbm' |
|
296 | 54 |
|
2650 | 55 |
ImageView openOnImage:(Image fromFile:'bitmaps/gifImages/garfield.gif') |
56 |
ImageView openOnImage:(Image fromFile:'bitmaps/SBrowser.xbm') |
|
26 | 57 |
|
2158 | 58 |
adjust: |
2650 | 59 |
controls how images are displayed; |
60 |
can be one of: |
|
61 |
#topLeft - image is displayed as usual |
|
62 |
#center - image is shown centered |
|
63 |
#fitBig - big images are shrunk to make it fit the view |
|
64 |
#fitSmall - small images are magnified to make it fit the view, |
|
65 |
#fit - all images are magnified to fit the view |
|
2158 | 66 |
|
296 | 67 |
[author:] |
2650 | 68 |
Claus Gittinger |
296 | 69 |
|
70 |
[see also:] |
|
2650 | 71 |
Image Form |
26 | 72 |
" |
73 |
! ! |
|
74 |
||
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
75 |
!ImageView class methodsFor:'initialization'! |
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
76 |
|
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
77 |
initialize |
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
78 |
DoNotMagnifyQuery := QuerySignal new defaultAnswer:false. |
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
79 |
! ! |
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
80 |
|
2511 | 81 |
!ImageView class methodsFor:'queries-plugin'! |
1694 | 82 |
|
83 |
aspectSelectors |
|
84 |
^ #( imageChannel ) |
|
85 |
||
86 |
"Created: / 11.2.2000 / 00:37:33 / cg" |
|
87 |
! ! |
|
88 |
||
257 | 89 |
!ImageView class methodsFor:'startup'! |
1 | 90 |
|
11 | 91 |
openOn:aFileName |
47 | 92 |
"startup an image viewer on an image read from a file" |
93 |
||
1970 | 94 |
|fn imageView img e| |
95 |
||
96 |
fn := aFileName asFilename. |
|
47 | 97 |
|
1970 | 98 |
img := Image fromFile:fn. |
47 | 99 |
img isNil ifTrue:[ |
2650 | 100 |
fn exists ifTrue:[ |
101 |
e := 'unknown/unsupported image format' |
|
102 |
] ifFalse:[ |
|
103 |
e := 'no such image'. |
|
104 |
]. |
|
105 |
self warn:e. |
|
106 |
^ nil |
|
47 | 107 |
]. |
353 | 108 |
imageView := self openOnImage:img. |
47 | 109 |
|
1970 | 110 |
imageView topView label:fn pathName iconLabel:(fn baseName). |
47 | 111 |
|
353 | 112 |
^ imageView |
1 | 113 |
|
47 | 114 |
" |
353 | 115 |
ImageView openOn:'bitmaps/gifImages/garfield.gif' |
2650 | 116 |
ImageView openOn:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm' |
47 | 117 |
" |
348 | 118 |
|
599 | 119 |
"Modified: / 31.10.1997 / 16:17:52 / cg" |
47 | 120 |
! |
121 |
||
122 |
openOnImage:anImage |
|
123 |
"startup an image viewer on an image" |
|
1 | 124 |
|
635 | 125 |
|top v imageView icnW icnH iconView magX magY mag lbl imgWidth imgHeight| |
47 | 126 |
|
127 |
anImage isImage ifTrue:[ |
|
2650 | 128 |
lbl := 'an Image' |
47 | 129 |
] ifFalse:[ |
2650 | 130 |
lbl := 'a Form' |
47 | 131 |
]. |
132 |
top := StandardSystemView label:lbl. |
|
1 | 133 |
|
134 |
v := HVScrollableView for:self in:top. |
|
135 |
v origin:0@0 extent:1.0@1.0. |
|
136 |
imageView := v scrolledView. |
|
137 |
||
47 | 138 |
anImage notNil ifTrue:[ |
2650 | 139 |
imageView image:anImage. |
7 | 140 |
|
2650 | 141 |
"define an icon view showing a little version of image. |
142 |
Since some window managers cannot handle this correctly (twm), |
|
143 |
this is only done when running on an IRIS" |
|
7 | 144 |
|
2650 | 145 |
(true "(OperatingSystem getSystemType = 'iris')" |
146 |
and:[StyleSheet name == #iris]) ifTrue:[ |
|
147 |
iconView := ImageView new. |
|
7 | 148 |
|
2650 | 149 |
"for now; should somehow get access to preferred iconview extent ..." |
150 |
icnW := 86. |
|
151 |
icnH := 68. |
|
7 | 152 |
|
2650 | 153 |
imgWidth := anImage width. |
154 |
imgHeight := anImage height. |
|
635 | 155 |
|
2650 | 156 |
((imgWidth <= icnW) and:[imgHeight <= icnH]) ifTrue:[ |
157 |
iconView extent:(imgWidth @ imgHeight). |
|
158 |
mag := 1 @ 1 |
|
159 |
] ifFalse:[ |
|
160 |
magX := icnW / imgWidth. |
|
161 |
magY := icnH / imgHeight. |
|
7 | 162 |
|
2650 | 163 |
"scale image" |
7 | 164 |
" |
2650 | 165 |
mag := magX @ magY. |
7 | 166 |
" |
2650 | 167 |
"preserve ratio" |
7 | 168 |
" |
2650 | 169 |
mag := (magX min:magY) asPoint. |
7 | 170 |
" |
171 |
" " |
|
2650 | 172 |
mag := (magX max:magY) asPoint. |
7 | 173 |
" " |
174 |
||
2650 | 175 |
iconView extent:((anImage width @ anImage height) * mag) rounded. |
176 |
]. |
|
7 | 177 |
|
2650 | 178 |
top iconView:iconView. |
179 |
]. |
|
7 | 180 |
]. |
181 |
||
182 |
top open. |
|
183 |
||
26 | 184 |
iconView notNil ifTrue:[ |
2650 | 185 |
top windowGroup addView:iconView. |
186 |
[ |
|
187 |
iconView image:(anImage magnifiedBy:mag). |
|
188 |
] forkAt:4 |
|
7 | 189 |
]. |
353 | 190 |
^ imageView |
1 | 191 |
|
26 | 192 |
" |
353 | 193 |
ImageView openOnImage:(Image fromFile:'bitmaps/gifImages/garfield.gif') |
47 | 194 |
ImageView openOnImage:(Image fromFile:'bitmaps/SBrowser.xbm') |
26 | 195 |
" |
353 | 196 |
|
635 | 197 |
"Modified: / 18.12.1997 / 11:46:19 / cg" |
1 | 198 |
! ! |
199 |
||
161 | 200 |
!ImageView methodsFor:'accessing'! |
201 |
||
202 |
adjust:layoutSymbol |
|
203 |
"set the adjust (how the image is displayed); |
|
2375 | 204 |
currently, only support #topLeft, #center, #fitBig, #fitSmall and #fit: |
2650 | 205 |
#topLeft - image is displayed as usual |
206 |
#center - image is shown centered |
|
207 |
#fitBig - big images are shrunk to make it fit the view |
|
208 |
#fitSmall - small images are magnified to make it fit the view, |
|
209 |
#fit - all images are magnified to fit the view |
|
2375 | 210 |
" |
2158 | 211 |
|
2164 | 212 |
adjust ~= layoutSymbol ifTrue:[ |
2650 | 213 |
adjust := layoutSymbol. |
161 | 214 |
|
2650 | 215 |
magnifiedImage := nil. |
216 |
self shown ifTrue:[ |
|
217 |
image notNil ifTrue:[ |
|
218 |
self generateMagnifiedImage. |
|
219 |
self clear. |
|
220 |
self scrollToTopLeft. |
|
221 |
self invalidate. |
|
222 |
self contentsChanged. |
|
223 |
] |
|
224 |
]. |
|
2158 | 225 |
]. |
161 | 226 |
! |
227 |
||
228 |
image |
|
229 |
"return the image" |
|
230 |
||
231 |
^ image |
|
232 |
! |
|
233 |
||
234 |
image:anImage |
|
235 |
"set the image - show a wait cursor, since image dithering may take a while" |
|
1 | 236 |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
237 |
self image:anImage scroll:true |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
238 |
! |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
239 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
240 |
image:anImage scroll:doScroll |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
241 |
"set the image - show a wait cursor, since image dithering may take a while" |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
242 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
243 |
self setImage:anImage scroll:doScroll |
1993 | 244 |
! |
245 |
||
246 |
setImage:anImage |
|
247 |
"set the image - show a wait cursor, since image dithering may take a while" |
|
248 |
||
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
249 |
|oldSize newSize| |
1993 | 250 |
|
251 |
oldSize := image ifNil:[0@0] ifNotNil:[image extent]. |
|
252 |
||
253 |
image := anImage. |
|
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
254 |
magnifiedImage := nil. |
2158 | 255 |
self generateMagnifiedImage. |
1993 | 256 |
|
2158 | 257 |
newSize := image ifNil:[0@0] ifNotNil:[(magnifiedImage ? image) extent]. |
2164 | 258 |
self scrollToTopLeft. |
259 |
||
1993 | 260 |
oldSize ~= newSize ifTrue:[ |
2650 | 261 |
"/ avoid endless loop in case of a resize happening due |
262 |
"/ to scrollBar visibility changes. |
|
263 |
"/ that QuerySignal suppresses another magnification in sizeChanged: |
|
264 |
DoNotMagnifyQuery answer:true |
|
265 |
do:[ |
|
266 |
self contentsChanged. |
|
267 |
] |
|
1993 | 268 |
]. |
269 |
||
270 |
shown ifTrue:[ |
|
2650 | 271 |
self clear. |
272 |
self invalidate |
|
1993 | 273 |
]. |
274 |
self changed:#image. |
|
1694 | 275 |
|
276 |
"Modified: / 10.2.2000 / 23:25:51 / cg" |
|
2089 | 277 |
! |
278 |
||
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
279 |
setImage:anImage scroll:doScroll |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
280 |
"set the image - show a wait cursor, since image dithering may take a while" |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
281 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
282 |
|oldSize newSize| |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
283 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
284 |
oldSize := image ifNil:[0@0] ifNotNil:[image extent]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
285 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
286 |
image := anImage. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
287 |
magnifiedImage := nil. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
288 |
self generateMagnifiedImage. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
289 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
290 |
newSize := image ifNil:[0@0] ifNotNil:[(magnifiedImage ? image) extent]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
291 |
doScroll ifTrue:[ |
2650 | 292 |
self scrollToTopLeft. |
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
293 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
294 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
295 |
oldSize ~= newSize ifTrue:[ |
2650 | 296 |
"/ avoid endless loop in case of a resize happening due |
297 |
"/ to scrollBar visibility changes. |
|
298 |
"/ that QuerySignal suppresses another magnification in sizeChanged: |
|
299 |
DoNotMagnifyQuery answer:true |
|
300 |
do:[ |
|
301 |
self contentsChanged. |
|
302 |
] |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
303 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
304 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
305 |
shown ifTrue:[ |
2650 | 306 |
self clear. |
307 |
self invalidate |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
308 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
309 |
self changed:#image. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
310 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
311 |
"Modified: / 10.2.2000 / 23:25:51 / cg" |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
312 |
! |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
313 |
|
2089 | 314 |
tileMode:aBoolean tileOffset:aPoint |
315 |
||
316 |
tileMode := aBoolean. |
|
317 |
tileOffset := aPoint |
|
1694 | 318 |
! ! |
319 |
||
2404 | 320 |
!ImageView methodsFor:'accessing-channels'! |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
321 |
|
1694 | 322 |
imageChannel |
323 |
imageChannel isNil ifTrue:[ |
|
2650 | 324 |
imageChannel := ValueHolder new. |
325 |
imageChannel addDependent:self. |
|
1694 | 326 |
]. |
327 |
^ imageChannel |
|
328 |
||
329 |
"Created: / 11.2.2000 / 00:34:44 / cg" |
|
330 |
! |
|
331 |
||
332 |
imageChannel:aValueHolder |
|
333 |
imageChannel notNil ifTrue:[ |
|
2650 | 334 |
imageChannel removeDependent:self. |
161 | 335 |
]. |
1694 | 336 |
imageChannel := aValueHolder. |
337 |
imageChannel notNil ifTrue:[ |
|
2650 | 338 |
imageChannel addDependent:self. |
1694 | 339 |
]. |
340 |
||
341 |
"Created: / 11.2.2000 / 00:34:33 / cg" |
|
342 |
! ! |
|
1135
75101bf02c5b
send contentsChanged notifications before, to avoid
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
343 |
|
1694 | 344 |
!ImageView methodsFor:'change & update'! |
345 |
||
346 |
update:something with:aParameter from:changedObject |
|
347 |
something == imageChannel ifTrue:[ |
|
2650 | 348 |
self image:(imageChannel value). |
349 |
^ self |
|
1694 | 350 |
]. |
351 |
super update:something with:aParameter from:changedObject |
|
352 |
||
353 |
"Created: / 11.2.2000 / 00:37:02 / cg" |
|
1 | 354 |
! ! |
355 |
||
356 |
!ImageView methodsFor:'drawing'! |
|
357 |
||
2158 | 358 |
generateMagnifiedImage |
359 |
|doFit innerWidth innerHeight imgWidth imgHeight| |
|
360 |
||
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
361 |
magnifiedImage notNil ifTrue:[ |
2650 | 362 |
^ self |
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
363 |
]. |
2358 | 364 |
image isNil ifTrue:[ |
2650 | 365 |
^ self |
2358 | 366 |
]. |
367 |
||
2158 | 368 |
doFit := false. |
369 |
||
370 |
innerWidth := self innerWidth. |
|
371 |
innerHeight := self innerHeight. |
|
372 |
||
373 |
imgWidth := image width. |
|
374 |
imgHeight := image height. |
|
375 |
||
376 |
tileMode ~~ true ifTrue:[ |
|
2650 | 377 |
((imgWidth > innerWidth) |
378 |
or:[imgHeight > innerHeight]) ifTrue:[ |
|
379 |
((adjust == #fit) or:[adjust == #fitBig]) ifTrue:[ |
|
380 |
doFit := true |
|
381 |
]. |
|
382 |
] ifFalse:[ |
|
383 |
((imgWidth < innerWidth) |
|
384 |
or:[imgHeight < innerHeight]) ifTrue:[ |
|
385 |
((adjust == #fit) or:[adjust == #fitSmall]) ifTrue:[ |
|
386 |
doFit := true |
|
387 |
]. |
|
388 |
] |
|
389 |
]. |
|
2158 | 390 |
]. |
391 |
doFit ifTrue:[ |
|
2650 | 392 |
magnifiedImage := image magnifiedPreservingRatioTo:(innerWidth @ innerHeight). |
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
393 |
"/ self contentsChanged. |
2164 | 394 |
] ifFalse:[ |
2650 | 395 |
magnifiedImage := image |
2158 | 396 |
]. |
397 |
! |
|
398 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
399 |
redrawX:x y:y width:w height:h |
2158 | 400 |
|xI yI depth shownImage imgWidth imgHeight right bott| |
11 | 401 |
|
1 | 402 |
image notNil ifTrue:[ |
2650 | 403 |
self generateMagnifiedImage. |
2158 | 404 |
|
2650 | 405 |
shownImage := magnifiedImage ? image. |
406 |
imgWidth := shownImage width. |
|
407 |
imgHeight := shownImage height. |
|
635 | 408 |
|
2650 | 409 |
adjust == #center ifTrue:[ |
410 |
xI := (width - (margin * 2) - imgWidth) // 2. |
|
411 |
yI := (height - (margin * 2) - imgHeight) // 2. |
|
412 |
] ifFalse:[ |
|
413 |
xI := yI := margin |
|
414 |
]. |
|
414 | 415 |
|
2650 | 416 |
((depth := shownImage depth) == 1) ifTrue:[ |
417 |
self paint:(shownImage colorFromValue:1) |
|
418 |
on:(shownImage colorFromValue:0). |
|
419 |
]. |
|
1071
981c97fe54de
generate device image before clearing in redraw
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
420 |
|
2650 | 421 |
tileMode == true ifTrue:[ |
422 |
(depth == 1 |
|
423 |
and:[image mask isNil]) ifFalse:[ |
|
424 |
self clearRectangleX:x y:y width:w height:h. |
|
425 |
0 to:y+h by:tileOffset y do:[:oY | |
|
426 |
0 to:x+w by:tileOffset x do:[:oX | |
|
427 |
self displayForm:image x:oX y:oY |
|
428 |
] |
|
429 |
]. |
|
430 |
] ifTrue:[ |
|
431 |
0 to:y+h by:tileOffset y do:[:oY | |
|
432 |
0 to:x+w by:tileOffset x do:[:oX | |
|
433 |
self displayOpaqueForm:image x:oX y:oY |
|
434 |
] |
|
435 |
]. |
|
436 |
]. |
|
437 |
] ifFalse:[ |
|
438 |
(depth == 1 |
|
439 |
and:[shownImage mask isNil]) ifFalse:[ |
|
440 |
self clearRectangleX:x y:y width:w height:h. |
|
441 |
self displayForm:shownImage x:xI y:yI |
|
442 |
] ifTrue:[ |
|
443 |
self displayOpaqueForm:shownImage x:xI y:yI |
|
444 |
]. |
|
430 | 445 |
|
2650 | 446 |
"/ right of image ? |
447 |
right := x + w - 1. |
|
448 |
right > (xI + imgWidth) ifTrue:[ |
|
449 |
self clearRectangleX:(xI + imgWidth) |
|
450 |
y:y |
|
451 |
width:(right - imgWidth - xI) |
|
452 |
height:h |
|
453 |
]. |
|
454 |
"/ below of image ? |
|
455 |
bott := y + h - 1. |
|
456 |
bott > (yI + imgHeight) ifTrue:[ |
|
457 |
self clearRectangleX:margin |
|
458 |
y:(yI + imgHeight) |
|
459 |
width:w |
|
460 |
height:(bott - imgHeight - yI) |
|
461 |
]. |
|
462 |
]. |
|
1 | 463 |
] |
89 | 464 |
|
635 | 465 |
"Created: / 11.7.1996 / 21:02:12 / cg" |
1071
981c97fe54de
generate device image before clearing in redraw
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
466 |
"Modified: / 12.8.1998 / 14:02:28 / cg" |
1 | 467 |
! ! |
468 |
||
2158 | 469 |
!ImageView methodsFor:'event handling'! |
470 |
||
471 |
sizeChanged:how |
|
472 |
magnifiedImage notNil ifTrue:[ |
|
2650 | 473 |
DoNotMagnifyQuery query ifFalse:[ |
474 |
magnifiedImage := nil. |
|
475 |
self generateMagnifiedImage. |
|
476 |
self clear. |
|
477 |
self invalidate. |
|
478 |
] |
|
2158 | 479 |
]. |
480 |
super sizeChanged:how |
|
481 |
! ! |
|
482 |
||
2501 | 483 |
!ImageView methodsFor:'initialization & release'! |
1327 | 484 |
|
485 |
destroy |
|
486 |
image := nil. |
|
487 |
super destroy. |
|
488 |
! ! |
|
489 |
||
161 | 490 |
!ImageView methodsFor:'queries'! |
24 | 491 |
|
161 | 492 |
heightOfContents |
493 |
"return the images height - scrollbar needs this info" |
|
1 | 494 |
|
161 | 495 |
image isNil ifTrue:[^ 0]. |
2158 | 496 |
^ (magnifiedImage ? image) height |
89 | 497 |
! |
498 |
||
1 | 499 |
widthOfContents |
500 |
"return the images width - scrollbar needs this info" |
|
501 |
||
502 |
image isNil ifTrue:[^ 0]. |
|
2158 | 503 |
^ (magnifiedImage ? image) width |
161 | 504 |
! ! |
505 |
||
257 | 506 |
!ImageView class methodsFor:'documentation'! |
161 | 507 |
|
508 |
version |
|
2650 | 509 |
^ '$Header: /cvs/stx/stx/libwidg2/ImageView.st,v 1.58 2004-02-24 10:35:43 cg Exp $' |
1 | 510 |
! ! |
2358 | 511 |
|
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
512 |
ImageView initialize! |