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