author | Claus Gittinger <cg@exept.de> |
Fri, 15 Jan 2016 17:17:43 +0100 | |
changeset 4912 | 6630a4464c2f |
parent 4732 | b5db158865ca |
child 4966 | fd25317b66de |
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 |
18 |
tileOffset lastMousePoint' |
|
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 |
|
2158 | 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' |
|
125 |
itemValue: adjust: |
|
126 |
argument: fitBig |
|
127 |
) |
|
128 |
(MenuItem |
|
129 |
label: 'Original Size' |
|
130 |
itemValue: adjust: |
|
131 |
argument: 'nil' |
|
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. |
|
224 |
v origin:0@0 extent:1.0@1.0. |
|
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 |
|
3733 | 234 |
(true "(OperatingSystem getSystemType = 'iris')" |
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" |
7 | 257 |
" |
3733 | 258 |
mag := (magX min:magY) asPoint. |
7 | 259 |
" |
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. |
275 |
[ |
|
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 |
||
291 |
adjust:layoutSymbol |
|
292 |
"set the adjust (how the image is displayed); |
|
2375 | 293 |
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
|
294 |
#topLeft - image is displayed as usual |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
295 |
#center - image is shown centered |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
296 |
#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
|
297 |
#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
|
298 |
#fit - all images are magnified to fit the view |
2375 | 299 |
" |
2158 | 300 |
|
2164 | 301 |
adjust ~= layoutSymbol ifTrue:[ |
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
302 |
adjust := layoutSymbol. |
161 | 303 |
|
2659
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
304 |
magnifiedImage := nil. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
305 |
shown ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
306 |
image notNil ifTrue:[ |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
307 |
self generateMagnifiedImage. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
308 |
self clear. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
309 |
self scrollToTopLeft. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
310 |
self invalidate. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
311 |
self contentsChanged. |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
312 |
] |
3af857eb52fb
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
2650
diff
changeset
|
313 |
]. |
2158 | 314 |
]. |
161 | 315 |
! |
316 |
||
317 |
image |
|
318 |
"return the image" |
|
319 |
||
320 |
^ image |
|
321 |
! |
|
322 |
||
323 |
image:anImage |
|
3710
162a45c5ce34
invalidate when image changes
Claus Gittinger <cg@exept.de>
parents:
3705
diff
changeset
|
324 |
"set the image" |
1 | 325 |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
326 |
self image:anImage scroll:true |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
327 |
! |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
328 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
329 |
image:anImage scroll:doScroll |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
330 |
"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
|
331 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
332 |
self setImage:anImage scroll:doScroll |
1993 | 333 |
! |
334 |
||
3705 | 335 |
image:anImage scroll:doScroll invalidate:doInvalidate |
336 |
"set the image - show a wait cursor, since image dithering may take a while" |
|
337 |
||
338 |
self setImage:anImage scroll:doScroll invalidate:doInvalidate |
|
339 |
! |
|
340 |
||
3408 | 341 |
magnification |
342 |
magnifiedImage isNil ifTrue:[^ 1@1]. |
|
343 |
^ magnifiedImage extent / image extent |
|
344 |
! |
|
345 |
||
4066 | 346 |
model:aValueHolder |
347 |
super model:aValueHolder. |
|
348 |
self updateFromModel. |
|
349 |
||
350 |
"Created: / 25-07-2011 / 15:32:10 / cg" |
|
351 |
! |
|
352 |
||
1993 | 353 |
setImage:anImage |
354 |
"set the image - show a wait cursor, since image dithering may take a while" |
|
355 |
||
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
356 |
|oldSize newSize| |
1993 | 357 |
|
358 |
oldSize := image ifNil:[0@0] ifNotNil:[image extent]. |
|
359 |
||
360 |
image := anImage. |
|
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
361 |
magnifiedImage := nil. |
2158 | 362 |
self generateMagnifiedImage. |
1993 | 363 |
|
2158 | 364 |
newSize := image ifNil:[0@0] ifNotNil:[(magnifiedImage ? image) extent]. |
2164 | 365 |
self scrollToTopLeft. |
366 |
||
1993 | 367 |
oldSize ~= newSize ifTrue:[ |
2650 | 368 |
"/ avoid endless loop in case of a resize happening due |
369 |
"/ to scrollBar visibility changes. |
|
370 |
"/ that QuerySignal suppresses another magnification in sizeChanged: |
|
371 |
DoNotMagnifyQuery answer:true |
|
372 |
do:[ |
|
373 |
self contentsChanged. |
|
374 |
] |
|
1993 | 375 |
]. |
376 |
||
377 |
shown ifTrue:[ |
|
2650 | 378 |
self clear. |
379 |
self invalidate |
|
1993 | 380 |
]. |
381 |
self changed:#image. |
|
1694 | 382 |
|
383 |
"Modified: / 10.2.2000 / 23:25:51 / cg" |
|
2089 | 384 |
! |
385 |
||
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
386 |
setImage:anImage scroll:doScroll |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
387 |
"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
|
388 |
|
3710
162a45c5ce34
invalidate when image changes
Claus Gittinger <cg@exept.de>
parents:
3705
diff
changeset
|
389 |
self setImage:anImage scroll:doScroll invalidate:true |
3705 | 390 |
! |
391 |
||
392 |
setImage:anImage scroll:doScroll invalidate:doInvalidate |
|
393 |
"set the image - show a wait cursor, since image dithering may take a while" |
|
394 |
||
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
395 |
|oldSize newSize| |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
396 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
397 |
oldSize := image ifNil:[0@0] ifNotNil:[image extent]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
398 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
399 |
image := anImage. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
400 |
magnifiedImage := nil. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
401 |
self generateMagnifiedImage. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
402 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
403 |
newSize := image ifNil:[0@0] ifNotNil:[(magnifiedImage ? image) extent]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
404 |
doScroll ifTrue:[ |
3705 | 405 |
self scrollToTopLeft. |
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
406 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
407 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
408 |
oldSize ~= newSize ifTrue:[ |
3705 | 409 |
"/ avoid endless loop in case of a resize happening due |
410 |
"/ to scrollBar visibility changes. |
|
411 |
"/ that QuerySignal suppresses another magnification in sizeChanged: |
|
412 |
DoNotMagnifyQuery answer:true |
|
413 |
do:[ |
|
414 |
self contentsChanged. |
|
415 |
] |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
416 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
417 |
|
3705 | 418 |
(shown and:[doInvalidate]) ifTrue:[ |
419 |
self clear. |
|
420 |
self invalidate |
|
2544
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
421 |
]. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
422 |
self changed:#image. |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
423 |
|
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
424 |
"Modified: / 10.2.2000 / 23:25:51 / cg" |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
425 |
! |
bcae3dbd3ccd
do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents:
2511
diff
changeset
|
426 |
|
4245 | 427 |
sizeToFit:aBoolean |
428 |
aBoolean ifTrue:[ |
|
429 |
self adjust:#fitBig |
|
430 |
] ifFalse:[ |
|
431 |
self adjust:nil. |
|
432 |
] |
|
433 |
! |
|
434 |
||
2089 | 435 |
tileMode:aBoolean tileOffset:aPoint |
436 |
||
437 |
tileMode := aBoolean. |
|
438 |
tileOffset := aPoint |
|
1694 | 439 |
! ! |
440 |
||
2404 | 441 |
!ImageView methodsFor:'accessing-channels'! |
1510
fd0cd6065dc6
catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents:
1327
diff
changeset
|
442 |
|
1694 | 443 |
imageChannel |
4031 | 444 |
^ self model |
1694 | 445 |
|
4031 | 446 |
"Modified: / 31-03-2011 / 10:45:58 / cg" |
1694 | 447 |
! |
448 |
||
449 |
imageChannel:aValueHolder |
|
4031 | 450 |
self model:aValueHolder. |
1694 | 451 |
|
4031 | 452 |
"Created: / 11-02-2000 / 00:34:33 / cg" |
453 |
"Modified: / 31-03-2011 / 10:46:07 / cg" |
|
1694 | 454 |
! ! |
1135
75101bf02c5b
send contentsChanged notifications before, to avoid
Claus Gittinger <cg@exept.de>
parents:
1071
diff
changeset
|
455 |
|
1694 | 456 |
!ImageView methodsFor:'change & update'! |
457 |
||
458 |
update:something with:aParameter from:changedObject |
|
4031 | 459 |
changedObject == model ifTrue:[ |
4561 | 460 |
self updateFromModel. |
2786
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
461 |
^ self |
1694 | 462 |
]. |
463 |
super update:something with:aParameter from:changedObject |
|
464 |
||
4031 | 465 |
"Created: / 11-02-2000 / 00:37:02 / cg" |
466 |
"Modified: / 31-03-2011 / 10:46:16 / cg" |
|
2786
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
467 |
! |
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
468 |
|
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
469 |
updateFromModel |
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
470 |
"the model changes, set my image" |
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
471 |
|
d3b6171aec01
React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents:
2748
diff
changeset
|
472 |
self image:model value. |
1 | 473 |
! ! |
474 |
||
475 |
!ImageView methodsFor:'drawing'! |
|
476 |
||
2158 | 477 |
generateMagnifiedImage |
478 |
|doFit innerWidth innerHeight imgWidth imgHeight| |
|
479 |
||
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
480 |
magnifiedImage notNil ifTrue:[ |
4124 | 481 |
^ self |
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
482 |
]. |
2358 | 483 |
image isNil ifTrue:[ |
4124 | 484 |
^ self |
2358 | 485 |
]. |
2158 | 486 |
doFit := false. |
487 |
||
488 |
innerWidth := self innerWidth. |
|
489 |
innerHeight := self innerHeight. |
|
490 |
||
491 |
imgWidth := image width. |
|
492 |
imgHeight := image height. |
|
493 |
||
494 |
tileMode ~~ true ifTrue:[ |
|
4124 | 495 |
((imgWidth > innerWidth) |
496 |
or:[imgHeight > innerHeight]) ifTrue:[ |
|
497 |
((adjust == #fit) or:[adjust == #fitBig]) ifTrue:[ |
|
498 |
doFit := true |
|
499 |
]. |
|
500 |
] ifFalse:[ |
|
501 |
((imgWidth < innerWidth) |
|
502 |
or:[imgHeight < innerHeight]) ifTrue:[ |
|
503 |
((adjust == #fit) or:[adjust == #fitSmall]) ifTrue:[ |
|
504 |
doFit := true |
|
505 |
]. |
|
506 |
] |
|
507 |
]. |
|
2158 | 508 |
]. |
509 |
doFit ifTrue:[ |
|
4124 | 510 |
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
|
511 |
"/ self contentsChanged. |
2164 | 512 |
] ifFalse:[ |
4124 | 513 |
(magnificationFactor notNil and:[magnificationFactor ~= 1]) ifTrue:[ |
514 |
magnifiedImage := image magnifiedBy:magnificationFactor. |
|
515 |
] ifFalse:[ |
|
516 |
magnifiedImage := image |
|
517 |
]. |
|
2158 | 518 |
]. |
4124 | 519 |
|
520 |
"Modified: / 06-05-2012 / 12:17:23 / cg" |
|
2158 | 521 |
! |
522 |
||
210
1a3b06d71a03
faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents:
207
diff
changeset
|
523 |
redrawX:x y:y width:w height:h |
2158 | 524 |
|xI yI depth shownImage imgWidth imgHeight right bott| |
11 | 525 |
|
1 | 526 |
image notNil ifTrue:[ |
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
527 |
self generateMagnifiedImage. |
2158 | 528 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
529 |
shownImage := magnifiedImage ? image. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
530 |
imgWidth := shownImage width. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
531 |
imgHeight := shownImage height. |
635 | 532 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
533 |
adjust == #center ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
534 |
xI := (width - (margin * 2) - imgWidth) // 2. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
535 |
yI := (height - (margin * 2) - imgHeight) // 2. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
536 |
] ifFalse:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
537 |
xI := yI := margin |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
538 |
]. |
414 | 539 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
540 |
((depth := shownImage depth) == 1) ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
541 |
self paint:(shownImage colorFromValue:1) |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
542 |
on:(shownImage colorFromValue:0). |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
543 |
]. |
1071
981c97fe54de
generate device image before clearing in redraw
Claus Gittinger <cg@exept.de>
parents:
677
diff
changeset
|
544 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
545 |
tileMode == true ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
546 |
(tileOffset y > 0 and:[tileOffset x > 0]) ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
547 |
(depth == 1 |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
548 |
and:[image mask isNil]) ifFalse:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
549 |
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
|
550 |
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
|
551 |
0 to:x+w by:tileOffset x do:[:oX | |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
552 |
self displayForm:image x:oX y:oY |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
553 |
] |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
554 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
555 |
] ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
556 |
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
|
557 |
0 to:x+w by:tileOffset x do:[:oX | |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
558 |
self displayOpaqueForm:image x:oX y:oY |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
559 |
] |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
560 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
561 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
562 |
] |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
563 |
] ifFalse:[ |
3726 | 564 |
xI > (x+w) ifTrue:[^ self]. "/ no need to draw |
565 |
yI > (y+h) ifTrue:[^ self]. "/ no need to draw |
|
566 |
(xI+imgWidth) < x ifTrue:[^ self]. "/ no need to draw |
|
567 |
(yI+imgHeight) < y ifTrue:[^ self]. "/ no need to draw |
|
568 |
||
569 |
(depth ~~ 1 |
|
570 |
or:[shownImage mask notNil]) ifTrue:[ |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
571 |
self clearRectangleX:x y:y width:w height:h. |
3726 | 572 |
shownImage displayOn:self x:xI y:yI. |
573 |
"/ self displayForm:shownImage x:xI y:yI |
|
574 |
] ifFalse:[ |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
575 |
self displayOpaqueForm:shownImage x:xI y:yI |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
576 |
]. |
430 | 577 |
|
3659
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
578 |
"/ right of image ? |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
579 |
right := x + w - 1. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
580 |
right > (xI + imgWidth) ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
581 |
self clearRectangleX:(xI + imgWidth) |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
582 |
y:y |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
583 |
width:(right - imgWidth - xI) |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
584 |
height:h |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
585 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
586 |
"/ below of image ? |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
587 |
bott := y + h - 1. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
588 |
bott > (yI + imgHeight) ifTrue:[ |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
589 |
self clearRectangleX:margin |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
590 |
y:(yI + imgHeight) |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
591 |
width:w |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
592 |
height:(bott - imgHeight - yI) |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
593 |
]. |
53ec00df6b6c
care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents:
3618
diff
changeset
|
594 |
]. |
1 | 595 |
] |
89 | 596 |
|
635 | 597 |
"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
|
598 |
"Modified: / 12.8.1998 / 14:02:28 / cg" |
1 | 599 |
! ! |
600 |
||
2158 | 601 |
!ImageView methodsFor:'event handling'! |
602 |
||
3618 | 603 |
buttonMotion:state x:x y:y |
604 |
|delta mousePoint| |
|
605 |
||
606 |
lastMousePoint notNil ifTrue:[ |
|
607 |
mousePoint := (x@y). |
|
608 |
delta := mousePoint - lastMousePoint. |
|
609 |
delta ~= (0@0) ifTrue:[ |
|
610 |
self scrollTo:(self viewOrigin - delta). |
|
611 |
lastMousePoint := mousePoint. |
|
612 |
] |
|
613 |
] ifFalse:[ |
|
614 |
super buttonMotion:state x:x y:y |
|
615 |
] |
|
616 |
! |
|
617 |
||
618 |
buttonPress:button x:x y:y |
|
619 |
button == 1 ifTrue:[ |
|
4124 | 620 |
"self cursor:(Cursor handGrab). " |
3618 | 621 |
lastMousePoint := x@y. |
622 |
]. |
|
623 |
super buttonPress:button x:x y:y |
|
4124 | 624 |
|
625 |
"Modified: / 06-05-2012 / 12:19:39 / cg" |
|
3618 | 626 |
! |
627 |
||
628 |
buttonRelease:button x:x y:y |
|
629 |
button == 1 ifTrue:[ |
|
630 |
lastMousePoint := nil |
|
631 |
]. |
|
632 |
super buttonRelease:button x:x y:y |
|
633 |
! |
|
634 |
||
4124 | 635 |
mouseWheelZoom:amount |
636 |
"CTRL-wheel action" |
|
637 |
||
638 |
|mul| |
|
639 |
||
640 |
amount > 0 ifTrue:[ |
|
641 |
mul := 1.2. |
|
642 |
] ifFalse:[ |
|
643 |
mul := 0.8. |
|
644 |
]. |
|
645 |
||
4732 | 646 |
magnificationFactor := ((magnificationFactor ? 1) * mul). |
647 |
magnificationFactor fractionPart < 0.1 ifTrue:[ |
|
648 |
"magnifying by integer factor is faster" |
|
649 |
magnificationFactor := magnificationFactor truncated. |
|
650 |
]. |
|
4124 | 651 |
magnifiedImage := nil. |
652 |
self invalidate. |
|
653 |
||
654 |
"Created: / 06-05-2012 / 12:18:06 / cg" |
|
655 |
! |
|
656 |
||
2158 | 657 |
sizeChanged:how |
2911
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
658 |
(#(fit fitBig fitSmall) includes:adjust) ifTrue:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
659 |
magnifiedImage notNil ifTrue:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
660 |
DoNotMagnifyQuery query ifFalse:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
661 |
magnifiedImage := nil. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
662 |
self generateMagnifiedImage. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
663 |
self clear. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
664 |
self invalidate. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
665 |
] |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
666 |
]. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
667 |
] ifFalse:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
668 |
adjust == #center ifTrue:[ |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
669 |
self clear. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
670 |
self invalidate. |
b350e90e9a5b
avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents:
2786
diff
changeset
|
671 |
]. |
2158 | 672 |
]. |
673 |
super sizeChanged:how |
|
674 |
! ! |
|
675 |
||
2501 | 676 |
!ImageView methodsFor:'initialization & release'! |
1327 | 677 |
|
678 |
destroy |
|
3884 | 679 |
image := magnifiedImage := nil. |
1327 | 680 |
super destroy. |
681 |
! ! |
|
682 |
||
4245 | 683 |
!ImageView methodsFor:'menu'! |
684 |
||
685 |
middleButtonMenu |
|
4263 | 686 |
menuHolder notNil ifTrue:[^ super middleButtonMenu]. |
4245 | 687 |
^ self class middleButtonMenu |
688 |
! ! |
|
689 |
||
161 | 690 |
!ImageView methodsFor:'queries'! |
24 | 691 |
|
161 | 692 |
heightOfContents |
693 |
"return the images height - scrollbar needs this info" |
|
1 | 694 |
|
161 | 695 |
image isNil ifTrue:[^ 0]. |
2158 | 696 |
^ (magnifiedImage ? image) height |
89 | 697 |
! |
698 |
||
1 | 699 |
widthOfContents |
700 |
"return the images width - scrollbar needs this info" |
|
701 |
||
702 |
image isNil ifTrue:[^ 0]. |
|
2158 | 703 |
^ (magnifiedImage ? image) width |
161 | 704 |
! ! |
705 |
||
3408 | 706 |
!ImageView methodsFor:'scrolling'! |
707 |
||
708 |
scrollToMakeVisible:aPoint |
|
709 |
"try to arrange for aPoint to be visible (at the center, if possible)" |
|
710 |
||
711 |
|mag pos| |
|
712 |
||
713 |
mag := self magnification. |
|
714 |
pos := aPoint * mag. |
|
3705 | 715 |
self scrollTo:(pos - (self extent / 2)) rounded. |
3408 | 716 |
! ! |
717 |
||
257 | 718 |
!ImageView class methodsFor:'documentation'! |
161 | 719 |
|
720 |
version |
|
4912 | 721 |
^ '$Header$' |
3884 | 722 |
! |
723 |
||
724 |
version_CVS |
|
4912 | 725 |
^ '$Header$' |
1 | 726 |
! ! |
2358 | 727 |
|
4192 | 728 |
|
2160
4c15f05f8bc6
somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents:
2158
diff
changeset
|
729 |
ImageView initialize! |