author | Claus Gittinger <cg@exept.de> |
Mon, 13 Feb 2017 10:14:03 +0100 | |
changeset 5467 | fef61bfd9fad |
parent 5430 | b073297e25ae |
child 5479 | 489a12a34dbe |
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 |
" |
|
1763
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1694
diff
changeset
|
12 |
"{ Package: 'stx:libwidg2' }" |
7d6d64622ee4
change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents:
1694
diff
changeset
|
13 |
|
4732 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
296 | 16 |
View subclass:#ImageView |
4124 | 17 |
instanceVariableNames:'image magnifiedImage adjust magnificationFactor tileMode |
5402 | 18 |
tileOffset lastMousePoint adjustHolder' |
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
19 |
classVariableNames:'DoNotMagnifyQuery' |
161 | 20 |
poolDictionaries:'' |
21 |
category:'Views-Misc' |
|
1 | 22 |
! |
23 |
||
257 | 24 |
!ImageView class methodsFor:'documentation'! |
26 | 25 |
|
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 1993 by Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
2747 | 42 |
This View knows how to display a (bitmap-)image (or form). |
26 | 43 |
|
44 |
You can display an image with: |
|
45 |
||
2747 | 46 |
ImageView openOn:anImageFileName |
26 | 47 |
or: |
2747 | 48 |
ImageView openOnImage:anImage |
47 | 49 |
or: |
2747 | 50 |
ImageView new image:anImage |
26 | 51 |
|
52 |
i.e. |
|
53 |
||
2748 | 54 |
ImageView openOn:'../../goodies/bitmaps/gifImages/garfield.gif' |
55 |
ImageView openOn:'../../goodies/bitmaps/SBrowser.xbm' |
|
296 | 56 |
|
2748 | 57 |
ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') |
58 |
ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/SBrowser.xbm') |
|
26 | 59 |
|
5226 | 60 |
adjust: |
2747 | 61 |
controls how images are displayed; |
62 |
can be one of: |
|
63 |
#topLeft - image is displayed as usual |
|
64 |
#center - image is shown centered |
|
65 |
#fitBig - big images are shrunk to make it fit the view |
|
66 |
#fitSmall - small images are magnified to make it fit the view, |
|
67 |
#fit - all images are magnified to fit the view |
|
2158 | 68 |
|
296 | 69 |
[author:] |
2747 | 70 |
Claus Gittinger |
296 | 71 |
|
72 |
[see also:] |
|
2747 | 73 |
Image Form |
26 | 74 |
" |
3683 | 75 |
! |
76 |
||
77 |
examples |
|
78 |
" |
|
79 |
|top imgView scrView| |
|
80 |
||
81 |
top := StandardSystemView new. |
|
82 |
top extent:300@300. |
|
83 |
||
84 |
imgView := ImageView new. |
|
85 |
imgView image:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif'). |
|
86 |
||
87 |
scrView := HVScrollableView forView:imgView. |
|
88 |
scrView origin:0@0 corner:1.0@1.0. |
|
89 |
top add:scrView. |
|
90 |
||
91 |
top open. |
|
92 |
" |
|
26 | 93 |
! ! |
94 |
||
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
95 |
!ImageView class methodsFor:'initialization'! |
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
96 |
|
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
97 |
initialize |
4912 | 98 |
DoNotMagnifyQuery isNil ifTrue:[ |
99 |
DoNotMagnifyQuery := QuerySignal new defaultAnswer:false. |
|
100 |
]. |
|
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
101 |
! ! |
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
102 |
|
4245 | 103 |
!ImageView class methodsFor:'menu specs'! |
104 |
||
105 |
middleButtonMenu |
|
106 |
"This resource specification was automatically generated |
|
107 |
by the MenuEditor of ST/X." |
|
108 |
||
109 |
"Do not manually edit this!! If it is corrupted, |
|
110 |
the MenuEditor may not be able to read the specification." |
|
111 |
||
112 |
||
113 |
" |
|
114 |
MenuEditor new openOnClass:ImageView andSelector:#middleButtonMenu |
|
115 |
(Menu new fromLiteralArrayEncoding:(ImageView middleButtonMenu)) startUp |
|
116 |
" |
|
117 |
||
118 |
<resource: #menu> |
|
119 |
||
120 |
^ |
|
121 |
#(Menu |
|
122 |
( |
|
123 |
(MenuItem |
|
124 |
label: 'Size to Fit' |
|
5403 | 125 |
choice: adjustHolder |
5402 | 126 |
choiceValue: fitBig |
4245 | 127 |
) |
128 |
(MenuItem |
|
129 |
label: 'Original Size' |
|
5403 | 130 |
choice: adjustHolder |
131 |
choiceValue: #topLeft |
|
4245 | 132 |
) |
133 |
) |
|
134 |
nil |
|
135 |
nil |
|
136 |
) |
|
137 |
! ! |
|
138 |
||
2511 | 139 |
!ImageView class methodsFor:'queries-plugin'! |
1694 | 140 |
|
141 |
aspectSelectors |
|
142 |
^ #( imageChannel ) |
|
143 |
||
144 |
"Created: / 11.2.2000 / 00:37:33 / cg" |
|
145 |
! ! |
|
146 |
||
257 | 147 |
!ImageView class methodsFor:'startup'! |
1 | 148 |
|
4192 | 149 |
openOn:anImageOrFileName |
5467 | 150 |
"startup an image viewer on an image or |
151 |
an image read from a file. |
|
152 |
Return the imageView (not the topView)" |
|
4192 | 153 |
|
154 |
anImageOrFileName isImage ifTrue:[ |
|
155 |
^ self openOnImage:anImageOrFileName |
|
156 |
]. |
|
157 |
^ self openOnFile:anImageOrFileName |
|
158 |
||
159 |
" |
|
160 |
ImageView openOn:'bitmaps/gifImages/garfield.gif' |
|
161 |
ImageView openOn:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm' |
|
162 |
" |
|
163 |
||
5467 | 164 |
"Modified: / 31-10-1997 / 16:17:52 / cg" |
165 |
"Modified (comment): / 13-02-2017 / 10:13:13 / cg" |
|
4192 | 166 |
! |
167 |
||
168 |
openOnFile:aFileName |
|
5467 | 169 |
"startup an image viewer on an image read from a file. |
170 |
Return the imageView (not the topView)" |
|
47 | 171 |
|
1970 | 172 |
|fn imageView img e| |
173 |
||
174 |
fn := aFileName asFilename. |
|
47 | 175 |
|
1970 | 176 |
img := Image fromFile:fn. |
47 | 177 |
img isNil ifTrue:[ |
2747 | 178 |
fn exists ifTrue:[ |
179 |
e := 'Unknown or unsupported image format.' |
|
180 |
] ifFalse:[ |
|
181 |
e := 'No such image file.'. |
|
182 |
]. |
|
183 |
self warn:(self resources string:e). |
|
184 |
^ nil |
|
47 | 185 |
]. |
353 | 186 |
imageView := self openOnImage:img. |
3733 | 187 |
imageView topView label:(fn pathName) iconLabel:(fn baseName). |
353 | 188 |
^ imageView |
1 | 189 |
|
47 | 190 |
" |
4558 | 191 |
ImageView openOnFile:'../../goodies/bitmaps/gifImages/garfield.gif' |
192 |
ImageView openOnFile:'../../goodies/bitmaps/xpmBitmaps/misc_icons/BOOK.xpm' |
|
47 | 193 |
" |
348 | 194 |
|
5467 | 195 |
"Modified: / 31-10-1997 / 16:17:52 / cg" |
196 |
"Modified (comment): / 13-02-2017 / 10:12:53 / cg" |
|
47 | 197 |
! |
198 |
||
199 |
openOnImage:anImage |
|
5467 | 200 |
"startup an image viewer on an image. |
201 |
Return the imageView (not the topView)" |
|
1 | 202 |
|
4558 | 203 |
|lbl| |
47 | 204 |
|
205 |
anImage isImage ifTrue:[ |
|
3733 | 206 |
lbl := anImage fileName ? 'an Image' |
47 | 207 |
] ifFalse:[ |
3904 | 208 |
anImage isNil ifTrue:[ |
209 |
lbl := 'an Image' |
|
210 |
] ifFalse:[ |
|
211 |
lbl := 'a Form' |
|
212 |
] |
|
47 | 213 |
]. |
4558 | 214 |
^ self openOnImage:anImage title:lbl |
215 |
||
216 |
" |
|
217 |
ImageView openOnImage:(Image fromFile:'bitmaps/gifImages/garfield.gif') title:'garfield' |
|
218 |
ImageView openOnImage:(Image fromFile:'../../libtool/bitmaps/SBrowser.xbm') title:'old browser icon' |
|
219 |
" |
|
5467 | 220 |
|
221 |
"Modified (comment): / 13-02-2017 / 10:12:43 / cg" |
|
4558 | 222 |
! |
223 |
||
224 |
openOnImage:anImage title:aString |
|
5467 | 225 |
"startup an image viewer on an image. |
226 |
Return the imageView (not the topView)" |
|
4558 | 227 |
|
228 |
|top v imageView icnW icnH iconView magX magY mag imgWidth imgHeight| |
|
229 |
||
230 |
top := StandardSystemView label:aString. |
|
1 | 231 |
|
232 |
v := HVScrollableView for:self in:top. |
|
5226 | 233 |
v origin:0@0 extent:1.0@1.0. |
1 | 234 |
imageView := v scrolledView. |
235 |
||
47 | 236 |
anImage notNil ifTrue:[ |
3733 | 237 |
imageView image:anImage. |
7 | 238 |
|
3733 | 239 |
"define an icon view showing a little version of image. |
240 |
Since some window managers cannot handle this correctly (twm), |
|
241 |
this is only done when running on an IRIS" |
|
7 | 242 |
|
5226 | 243 |
(true "(OperatingSystem getSystemType = 'iris')" |
3733 | 244 |
and:[StyleSheet name == #iris]) ifTrue:[ |
245 |
iconView := ImageView new. |
|
7 | 246 |
|
3733 | 247 |
"for now; should somehow get access to preferred iconview extent ..." |
248 |
icnW := 86. |
|
249 |
icnH := 68. |
|
7 | 250 |
|
3733 | 251 |
imgWidth := anImage width. |
252 |
imgHeight := anImage height. |
|
635 | 253 |
|
3733 | 254 |
((imgWidth <= icnW) and:[imgHeight <= icnH]) ifTrue:[ |
255 |
iconView extent:(imgWidth @ imgHeight). |
|
256 |
mag := 1 @ 1 |
|
257 |
] ifFalse:[ |
|
258 |
magX := icnW / imgWidth. |
|
259 |
magY := icnH / imgHeight. |
|
7 | 260 |
|
3733 | 261 |
"scale image" |
7 | 262 |
" |
3733 | 263 |
mag := magX @ magY. |
7 | 264 |
" |
3733 | 265 |
"preserve ratio" |
5226 | 266 |
" |
3733 | 267 |
mag := (magX min:magY) asPoint. |
5226 | 268 |
" |
3733 | 269 |
mag := (magX max:magY) asPoint. |
270 |
iconView extent:((anImage width @ anImage height) * mag) rounded. |
|
271 |
]. |
|
7 | 272 |
|
3733 | 273 |
top iconView:iconView. |
274 |
]. |
|
7 | 275 |
]. |
276 |
||
277 |
top open. |
|
278 |
||
26 | 279 |
iconView notNil ifTrue:[ |
3733 | 280 |
top windowGroup addView:iconView. |
5226 | 281 |
[ |
3733 | 282 |
iconView image:(anImage magnifiedBy:mag). |
283 |
] forkAt:4 |
|
7 | 284 |
]. |
353 | 285 |
^ imageView |
1 | 286 |
|
26 | 287 |
" |
4558 | 288 |
ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') title:'garfield' |
289 |
ImageView openOnImage:(Image fromFile:'../../libtool/bitmaps/SBrowser.xbm') |
|
26 | 290 |
" |
353 | 291 |
|
3904 | 292 |
"Modified: / 01-06-2010 / 18:31:14 / cg" |
5467 | 293 |
"Modified (comment): / 13-02-2017 / 10:12:35 / cg" |
1 | 294 |
! ! |
295 |
||
161 | 296 |
!ImageView methodsFor:'accessing'! |
297 |
||
5387 | 298 |
adjust |
299 |
"get the adjust (how the image is displayed); |
|
300 |
currently, only support #topLeft, #center, #fitBig, #fitSmall and #fit: |
|
301 |
#topLeft - image is displayed as usual |
|
302 |
#center - image is shown centered |
|
303 |
#fitBig - big images are shrunk to make it fit the view |
|
304 |
#fitSmall - small images are magnified to make it fit the view, |
|
305 |
#fit - all images are magnified to fit the view |
|
306 |
" |
|
307 |
||
308 |
^ adjust ? #topLeft |
|
309 |
! |
|
310 |
||
161 | 311 |
adjust:layoutSymbol |
312 |
"set the adjust (how the image is displayed); |
|
2375 | 313 |
currently, only support #topLeft, #center, #fitBig, #fitSmall and #fit: |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
314 |
#topLeft - image is displayed as usual |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
315 |
#center - image is shown centered |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
316 |
#fitBig - big images are shrunk to make it fit the view |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
317 |
#fitSmall - small images are magnified to make it fit the view, |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
318 |
#fit - all images are magnified to fit the view |
5403 | 319 |
#topLeftNoZoom - image is displayed as usual, and magnification is reset |
2375 | 320 |
" |
2158 | 321 |
|
5403 | 322 |
|layoutUsed| |
323 |
||
324 |
layoutUsed := layoutSymbol. |
|
325 |
layoutUsed == #topLeftNoZoom ifTrue:[ |
|
326 |
layoutUsed := #topLeft |
|
327 |
]. |
|
328 |
self magnificationFactor ~= 1 ifTrue:[ |
|
329 |
self magnificationFactor:1 |
|
330 |
]. |
|
331 |
||
332 |
adjust ~= layoutUsed ifTrue:[ |
|
333 |
adjust := layoutUsed. |
|
5402 | 334 |
adjustHolder notNil ifTrue:[ |
5403 | 335 |
adjustHolder value:layoutUsed withoutNotifying:self |
5402 | 336 |
]. |
161 | 337 |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
338 |
magnifiedImage := nil. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
339 |
shown ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
340 |
image notNil ifTrue:[ |
5403 | 341 |
self magnificationFactor ~= 1 ifTrue:[ |
342 |
self generateMagnifiedImage. |
|
343 |
]. |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
344 |
self clear. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
345 |
self scrollToTopLeft. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
346 |
self invalidate. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
347 |
self contentsChanged. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
348 |
] |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
349 |
]. |
2158 | 350 |
]. |
161 | 351 |
! |
352 |
||
5403 | 353 |
adjustHolder |
354 |
"get a valeHolder for the adjust (how the image is displayed); |
|
355 |
currently, only support #topLeft, #center, #fitBig, #fitSmall and #fit: |
|
356 |
#topLeft - image is displayed as usual |
|
357 |
#center - image is shown centered |
|
358 |
#fitBig - big images are shrunk to make it fit the view |
|
359 |
#fitSmall - small images are magnified to make it fit the view, |
|
360 |
#fit - all images are magnified to fit the view |
|
361 |
" |
|
362 |
||
363 |
adjustHolder isNil ifTrue:[ |
|
364 |
adjustHolder := self adjust asValue. |
|
365 |
adjustHolder |
|
366 |
onChangeEvaluate:[ |
|
367 |
self adjust:(adjustHolder value). |
|
368 |
] |
|
369 |
]. |
|
370 |
^ adjustHolder |
|
371 |
! |
|
372 |
||
161 | 373 |
image |
374 |
"return the image" |
|
375 |
||
376 |
^ image |
|
377 |
! |
|
378 |
||
379 |
image:anImage |
|
5398 | 380 |
"set the image scrolls as set by adjust |
381 |
- may show a wait cursor, if image dithering may take a while" |
|
1 | 382 |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
383 |
self image:anImage scroll:true |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
384 |
! |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
385 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
386 |
image:anImage scroll:doScroll |
5398 | 387 |
"set the image possibly scroll as set by adjust |
388 |
- may show a wait cursor, if image dithering may take a while" |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
389 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
390 |
self setImage:anImage scroll:doScroll |
1993 | 391 |
! |
392 |
||
3705 | 393 |
image:anImage scroll:doScroll invalidate:doInvalidate |
5398 | 394 |
"set the image possibly scroll as set by adjust |
395 |
- may show a wait cursor, if image dithering may take a while" |
|
3705 | 396 |
|
397 |
self setImage:anImage scroll:doScroll invalidate:doInvalidate |
|
398 |
! |
|
399 |
||
3408 | 400 |
magnification |
401 |
magnifiedImage isNil ifTrue:[^ 1@1]. |
|
402 |
^ magnifiedImage extent / image extent |
|
403 |
! |
|
404 |
||
5387 | 405 |
magnificationFactor |
406 |
^ magnificationFactor ? 1 |
|
407 |
! |
|
408 |
||
409 |
magnificationFactor:aNumber |
|
5398 | 410 |
magnificationFactor ~= aNumber ifTrue:[ |
411 |
magnificationFactor := aNumber. |
|
5403 | 412 |
"/ magnificationFactor fractionPart < 0.1 ifTrue:[ |
413 |
"/ "magnifying by integer factor is faster" |
|
414 |
"/ magnificationFactor := magnificationFactor truncated. |
|
415 |
"/ ]. |
|
5398 | 416 |
magnifiedImage := nil. |
417 |
magnificationFactor = 1 ifTrue:[ |
|
418 |
self contentsChanged. |
|
419 |
]. |
|
420 |
self invalidate. |
|
421 |
]. |
|
5387 | 422 |
! |
423 |
||
4066 | 424 |
model:aValueHolder |
425 |
super model:aValueHolder. |
|
426 |
self updateFromModel. |
|
427 |
||
428 |
"Created: / 25-07-2011 / 15:32:10 / cg" |
|
429 |
! |
|
430 |
||
1993 | 431 |
setImage:anImage |
432 |
"set the image - show a wait cursor, since image dithering may take a while" |
|
433 |
||
4966 | 434 |
self setImage:anImage scroll:true invalidate:true |
1694 | 435 |
|
436 |
"Modified: / 10.2.2000 / 23:25:51 / cg" |
|
2089 | 437 |
! |
438 |
||
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
439 |
setImage:anImage scroll:doScroll |
5398 | 440 |
"set the image - may show a wait cursor, if image dithering may take a while" |
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
441 |
|
3710
162a45c5ce34
invalidate when image changes
Claus Gittinger <cg@exept.de>
parents:
3705
diff
changeset
|
442 |
self setImage:anImage scroll:doScroll invalidate:true |
3705 | 443 |
! |
444 |
||
445 |
setImage:anImage scroll:doScroll invalidate:doInvalidate |
|
5398 | 446 |
"set the image - may show a wait cursor, if image dithering may take a while" |
3705 | 447 |
|
4966 | 448 |
|oldSize newSize newImageIsSmaller| |
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
449 |
|
5430 | 450 |
self assert:(anImage isImage or:[anImage isNil]). |
451 |
||
5226 | 452 |
oldSize := image isNil ifTrue:[0@0] ifFalse:[image extent]. |
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
453 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
454 |
image := anImage. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
455 |
magnifiedImage := nil. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
456 |
self generateMagnifiedImage. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
457 |
|
5226 | 458 |
newSize := image isNil ifTrue:[0@0] ifFalse:[(magnifiedImage ? image) extent]. |
4966 | 459 |
newImageIsSmaller := ((oldSize x > newSize x) or:[oldSize y > newSize y]). |
5226 | 460 |
|
5227 | 461 |
(newImageIsSmaller and:[ doInvalidate ]) ifTrue:[ self invalidate ]. |
462 |
doScroll ifTrue:[ self scrollToTopLeft ]. |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
463 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
464 |
oldSize ~= newSize ifTrue:[ |
3705 | 465 |
"/ avoid endless loop in case of a resize happening due |
466 |
"/ to scrollBar visibility changes. |
|
5226 | 467 |
"/ that QuerySignal suppresses another magnification in sizeChanged: |
468 |
DoNotMagnifyQuery |
|
4966 | 469 |
answer:true |
470 |
do:[ |
|
471 |
self contentsChanged. |
|
472 |
] |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
473 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
474 |
|
3705 | 475 |
(shown and:[doInvalidate]) ifTrue:[ |
5268 | 476 |
"/ (anImage isNil "or:[newImageIsSmaller]") ifTrue:[ |
477 |
"/ self clear. |
|
478 |
"/ ]. |
|
3705 | 479 |
self invalidate |
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
480 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
481 |
self changed:#image. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
482 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
483 |
"Modified: / 10.2.2000 / 23:25:51 / cg" |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
484 |
! |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
485 |
|
4245 | 486 |
sizeToFit:aBoolean |
487 |
aBoolean ifTrue:[ |
|
488 |
self adjust:#fitBig |
|
489 |
] ifFalse:[ |
|
490 |
self adjust:nil. |
|
491 |
] |
|
492 |
! |
|
493 |
||
2089 | 494 |
tileMode:aBoolean tileOffset:aPoint |
495 |
||
496 |
tileMode := aBoolean. |
|
497 |
tileOffset := aPoint |
|
1694 | 498 |
! ! |
499 |
||
2404 | 500 |
!ImageView methodsFor:'accessing-channels'! |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
501 |
|
1694 | 502 |
imageChannel |
4031 | 503 |
^ self model |
1694 | 504 |
|
4031 | 505 |
"Modified: / 31-03-2011 / 10:45:58 / cg" |
1694 | 506 |
! |
507 |
||
508 |
imageChannel:aValueHolder |
|
4031 | 509 |
self model:aValueHolder. |
1694 | 510 |
|
4031 | 511 |
"Created: / 11-02-2000 / 00:34:33 / cg" |
512 |
"Modified: / 31-03-2011 / 10:46:07 / cg" |
|
1694 | 513 |
! ! |
1135
75101bf02c5b
send contentsChanged notifications before, to avoid
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
514 |
|
1694 | 515 |
!ImageView methodsFor:'change & update'! |
516 |
||
517 |
update:something with:aParameter from:changedObject |
|
4031 | 518 |
changedObject == model ifTrue:[ |
4561 | 519 |
self updateFromModel. |
2786
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
520 |
^ self |
1694 | 521 |
]. |
522 |
super update:something with:aParameter from:changedObject |
|
523 |
||
4031 | 524 |
"Created: / 11-02-2000 / 00:37:02 / cg" |
525 |
"Modified: / 31-03-2011 / 10:46:16 / cg" |
|
2786
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
526 |
! |
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
527 |
|
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
528 |
updateFromModel |
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
529 |
"the model changes, set my image" |
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
530 |
|
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
531 |
self image:model value. |
1 | 532 |
! ! |
533 |
||
534 |
!ImageView methodsFor:'drawing'! |
|
535 |
||
2158 | 536 |
generateMagnifiedImage |
537 |
|doFit innerWidth innerHeight imgWidth imgHeight| |
|
538 |
||
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
539 |
magnifiedImage notNil ifTrue:[ |
4124 | 540 |
^ self |
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
541 |
]. |
2358 | 542 |
image isNil ifTrue:[ |
4124 | 543 |
^ self |
2358 | 544 |
]. |
2158 | 545 |
doFit := false. |
546 |
||
547 |
innerWidth := self innerWidth. |
|
548 |
innerHeight := self innerHeight. |
|
549 |
||
550 |
imgWidth := image width. |
|
551 |
imgHeight := image height. |
|
5430 | 552 |
|
2158 | 553 |
tileMode ~~ true ifTrue:[ |
4124 | 554 |
((imgWidth > innerWidth) |
555 |
or:[imgHeight > innerHeight]) ifTrue:[ |
|
556 |
((adjust == #fit) or:[adjust == #fitBig]) ifTrue:[ |
|
557 |
doFit := true |
|
558 |
]. |
|
559 |
] ifFalse:[ |
|
560 |
((imgWidth < innerWidth) |
|
561 |
or:[imgHeight < innerHeight]) ifTrue:[ |
|
562 |
((adjust == #fit) or:[adjust == #fitSmall]) ifTrue:[ |
|
563 |
doFit := true |
|
564 |
]. |
|
565 |
] |
|
566 |
]. |
|
2158 | 567 |
]. |
568 |
doFit ifTrue:[ |
|
4124 | 569 |
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
|
570 |
"/ self contentsChanged. |
2164 | 571 |
] ifFalse:[ |
4124 | 572 |
(magnificationFactor notNil and:[magnificationFactor ~= 1]) ifTrue:[ |
573 |
magnifiedImage := image magnifiedBy:magnificationFactor. |
|
574 |
] ifFalse:[ |
|
575 |
magnifiedImage := image |
|
576 |
]. |
|
2158 | 577 |
]. |
5387 | 578 |
self contentsChanged. |
4124 | 579 |
|
580 |
"Modified: / 06-05-2012 / 12:17:23 / cg" |
|
2158 | 581 |
! |
582 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
583 |
redrawX:x y:y width:w height:h |
5227 | 584 |
|xI yI depth shownImage imgWidth imgHeight right bott "rectRight rectBelow"| |
11 | 585 |
|
1 | 586 |
image notNil ifTrue:[ |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
587 |
self generateMagnifiedImage. |
2158 | 588 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
589 |
shownImage := magnifiedImage ? image. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
590 |
imgWidth := shownImage width. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
591 |
imgHeight := shownImage height. |
635 | 592 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
593 |
adjust == #center ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
594 |
xI := (width - (margin * 2) - imgWidth) // 2. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
595 |
yI := (height - (margin * 2) - imgHeight) // 2. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
596 |
] ifFalse:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
597 |
xI := yI := margin |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
598 |
]. |
414 | 599 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
600 |
((depth := shownImage depth) == 1) ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
601 |
self paint:(shownImage colorFromValue:1) |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
602 |
on:(shownImage colorFromValue:0). |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
603 |
]. |
1071
981c97fe54de
generate device image before clearing in redraw
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
604 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
605 |
tileMode == true ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
606 |
(tileOffset y > 0 and:[tileOffset x > 0]) ifTrue:[ |
5022 | 607 |
(false "depth ~~ 1" |
608 |
or:[shownImage mask notNil]) ifTrue:[ |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
609 |
self clearRectangleX:x y:y width:w height:h. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
610 |
0 to:y+h by:tileOffset y do:[:oY | |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
611 |
0 to:x+w by:tileOffset x do:[:oX | |
5226 | 612 |
self displayForm:image x:oX y:oY |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
613 |
] |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
614 |
]. |
5022 | 615 |
] ifFalse:[ |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
616 |
0 to:y+h by:tileOffset y do:[:oY | |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
617 |
0 to:x+w by:tileOffset x do:[:oX | |
5226 | 618 |
self displayOpaqueForm:image x:oX y:oY |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
619 |
] |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
620 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
621 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
622 |
] |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
623 |
] ifFalse:[ |
5227 | 624 |
"/rectRight := (shownImage width @ 0) corner:(width @ shownImage height). |
625 |
"/rectBelow := 0 @ (shownImage height) corner:(shownImage height @ height). |
|
626 |
"/(rectRight width > 0 and:[rectRight height > 0]) ifTrue:[ self clearRectangle:rectRight ]. |
|
627 |
"/(rectBelow width > 0 and:[rectBelow height > 0]) ifTrue:[ self clearRectangle:rectBelow ]. |
|
628 |
||
3726 | 629 |
xI > (x+w) ifTrue:[^ self]. "/ no need to draw |
630 |
yI > (y+h) ifTrue:[^ self]. "/ no need to draw |
|
631 |
(xI+imgWidth) < x ifTrue:[^ self]. "/ no need to draw |
|
632 |
(yI+imgHeight) < y ifTrue:[^ self]. "/ no need to draw |
|
633 |
||
5022 | 634 |
(false "depth ~~ 1" |
3726 | 635 |
or:[shownImage mask notNil]) ifTrue:[ |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
636 |
self clearRectangleX:x y:y width:w height:h. |
3726 | 637 |
shownImage displayOn:self x:xI y:yI. |
5226 | 638 |
"/ self displayForm:shownImage x:xI y:yI |
3726 | 639 |
] ifFalse:[ |
5226 | 640 |
self displayOpaqueForm:shownImage x:xI y:yI |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
641 |
]. |
430 | 642 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
643 |
"/ right of image ? |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
644 |
right := x + w - 1. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
645 |
right > (xI + imgWidth) ifTrue:[ |
5022 | 646 |
self clearRectangleX:(xI + imgWidth) y:y |
5226 | 647 |
width:(right - imgWidth - xI) height:h |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
648 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
649 |
"/ below of image ? |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
650 |
bott := y + h - 1. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
651 |
bott > (yI + imgHeight) ifTrue:[ |
5022 | 652 |
self clearRectangleX:margin y:(yI + imgHeight) |
5226 | 653 |
width:w height:(bott - imgHeight - yI) |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
654 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
655 |
]. |
5268 | 656 |
] ifFalse:[ |
657 |
self clearRectangleX:x y:y width:w height:h. |
|
658 |
]. |
|
89 | 659 |
|
635 | 660 |
"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
|
661 |
"Modified: / 12.8.1998 / 14:02:28 / cg" |
1 | 662 |
! ! |
663 |
||
2158 | 664 |
!ImageView methodsFor:'event handling'! |
665 |
||
3618 | 666 |
buttonMotion:state x:x y:y |
667 |
|delta mousePoint| |
|
668 |
||
669 |
lastMousePoint notNil ifTrue:[ |
|
670 |
mousePoint := (x@y). |
|
671 |
delta := mousePoint - lastMousePoint. |
|
672 |
delta ~= (0@0) ifTrue:[ |
|
673 |
self scrollTo:(self viewOrigin - delta). |
|
674 |
lastMousePoint := mousePoint. |
|
675 |
] |
|
676 |
] ifFalse:[ |
|
677 |
super buttonMotion:state x:x y:y |
|
678 |
] |
|
679 |
! |
|
680 |
||
681 |
buttonPress:button x:x y:y |
|
682 |
button == 1 ifTrue:[ |
|
4124 | 683 |
"self cursor:(Cursor handGrab). " |
3618 | 684 |
lastMousePoint := x@y. |
685 |
]. |
|
686 |
super buttonPress:button x:x y:y |
|
4124 | 687 |
|
688 |
"Modified: / 06-05-2012 / 12:19:39 / cg" |
|
3618 | 689 |
! |
690 |
||
691 |
buttonRelease:button x:x y:y |
|
692 |
button == 1 ifTrue:[ |
|
693 |
lastMousePoint := nil |
|
694 |
]. |
|
695 |
super buttonRelease:button x:x y:y |
|
696 |
! |
|
697 |
||
4124 | 698 |
mouseWheelZoom:amount |
699 |
"CTRL-wheel action" |
|
700 |
||
701 |
|mul| |
|
702 |
||
703 |
amount > 0 ifTrue:[ |
|
704 |
mul := 1.2. |
|
705 |
] ifFalse:[ |
|
706 |
mul := 0.8. |
|
707 |
]. |
|
5387 | 708 |
self magnificationFactor:((magnificationFactor ? 1) * mul). |
4124 | 709 |
|
710 |
"Created: / 06-05-2012 / 12:18:06 / cg" |
|
711 |
! |
|
712 |
||
2158 | 713 |
sizeChanged:how |
2911
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
714 |
(#(fit fitBig fitSmall) includes:adjust) ifTrue:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
715 |
magnifiedImage notNil ifTrue:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
716 |
DoNotMagnifyQuery query ifFalse:[ |
5387 | 717 |
self pushEvent:#updateImageAfterSizeChange. |
2911
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
718 |
] |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
719 |
]. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
720 |
] ifFalse:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
721 |
adjust == #center ifTrue:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
722 |
self clear. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
723 |
self invalidate. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
724 |
]. |
2158 | 725 |
]. |
726 |
super sizeChanged:how |
|
5387 | 727 |
! |
728 |
||
729 |
updateImageAfterSizeChange |
|
5399 | 730 |
|oldMagnifiedImage| |
731 |
||
732 |
oldMagnifiedImage := magnifiedImage. |
|
5387 | 733 |
magnifiedImage := nil. |
734 |
self generateMagnifiedImage. |
|
5400 | 735 |
(oldMagnifiedImage isNil |
736 |
or:[ magnifiedImage isNil |
|
737 |
or:[ oldMagnifiedImage extent ~= magnifiedImage extent ]] |
|
738 |
) ifTrue:[ |
|
739 |
"/ self clear. |
|
5399 | 740 |
self invalidate. |
741 |
]. |
|
2158 | 742 |
! ! |
743 |
||
2501 | 744 |
!ImageView methodsFor:'initialization & release'! |
1327 | 745 |
|
746 |
destroy |
|
5404 | 747 |
magnifiedImage := nil. |
748 |
"/ image := nil. |
|
1327 | 749 |
super destroy. |
750 |
! ! |
|
751 |
||
4245 | 752 |
!ImageView methodsFor:'menu'! |
753 |
||
754 |
middleButtonMenu |
|
4263 | 755 |
menuHolder notNil ifTrue:[^ super middleButtonMenu]. |
4245 | 756 |
^ self class middleButtonMenu |
757 |
! ! |
|
758 |
||
161 | 759 |
!ImageView methodsFor:'queries'! |
24 | 760 |
|
161 | 761 |
heightOfContents |
5387 | 762 |
"return the image's height - scrollbar needs this info" |
1 | 763 |
|
161 | 764 |
image isNil ifTrue:[^ 0]. |
2158 | 765 |
^ (magnifiedImage ? image) height |
89 | 766 |
! |
767 |
||
1 | 768 |
widthOfContents |
5387 | 769 |
"return the image's width - scrollbar needs this info" |
1 | 770 |
|
771 |
image isNil ifTrue:[^ 0]. |
|
2158 | 772 |
^ (magnifiedImage ? image) width |
161 | 773 |
! ! |
774 |
||
3408 | 775 |
!ImageView methodsFor:'scrolling'! |
776 |
||
777 |
scrollToMakeVisible:aPoint |
|
778 |
"try to arrange for aPoint to be visible (at the center, if possible)" |
|
779 |
||
780 |
|mag pos| |
|
781 |
||
782 |
mag := self magnification. |
|
783 |
pos := aPoint * mag. |
|
3705 | 784 |
self scrollTo:(pos - (self extent / 2)) rounded. |
3408 | 785 |
! ! |
786 |
||
257 | 787 |
!ImageView class methodsFor:'documentation'! |
161 | 788 |
|
789 |
version |
|
4912 | 790 |
^ '$Header$' |
3884 | 791 |
! |
792 |
||
793 |
version_CVS |
|
4912 | 794 |
^ '$Header$' |
1 | 795 |
! ! |
2358 | 796 |
|
4192 | 797 |
|
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
798 |
ImageView initialize! |