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