306 #topLeft - image is displayed as usual |
307 #topLeft - image is displayed as usual |
307 #center - image is shown centered |
308 #center - image is shown centered |
308 #fitBig - big images are shrunk to make it fit the view |
309 #fitBig - big images are shrunk to make it fit the view |
309 #fitSmall - small images are magnified to make it fit the view, |
310 #fitSmall - small images are magnified to make it fit the view, |
310 #fit - all images are magnified to fit the view |
311 #fit - all images are magnified to fit the view |
311 " |
312 #topLeftNoZoom - image is displayed as usual, and magnification is reset |
312 |
313 " |
313 adjust ~= layoutSymbol ifTrue:[ |
314 |
314 adjust := layoutSymbol. |
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. |
315 adjustHolder notNil ifTrue:[ |
327 adjustHolder notNil ifTrue:[ |
316 adjustHolder value:layoutSymbol withoutNotifying:self |
328 adjustHolder value:layoutUsed withoutNotifying:self |
317 ]. |
329 ]. |
318 |
330 |
319 magnifiedImage := nil. |
331 magnifiedImage := nil. |
320 shown ifTrue:[ |
332 shown ifTrue:[ |
321 image notNil ifTrue:[ |
333 image notNil ifTrue:[ |
322 self generateMagnifiedImage. |
334 self magnificationFactor ~= 1 ifTrue:[ |
|
335 self generateMagnifiedImage. |
|
336 ]. |
323 self clear. |
337 self clear. |
324 self scrollToTopLeft. |
338 self scrollToTopLeft. |
325 self invalidate. |
339 self invalidate. |
326 self contentsChanged. |
340 self contentsChanged. |
327 ] |
341 ] |
328 ]. |
342 ]. |
329 ]. |
343 ]. |
330 ! |
344 ! |
331 |
345 |
|
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 |
332 image |
366 image |
333 "return the image" |
367 "return the image" |
334 |
368 |
335 ^ image |
369 ^ image |
336 ! |
370 ! |
366 ! |
400 ! |
367 |
401 |
368 magnificationFactor:aNumber |
402 magnificationFactor:aNumber |
369 magnificationFactor ~= aNumber ifTrue:[ |
403 magnificationFactor ~= aNumber ifTrue:[ |
370 magnificationFactor := aNumber. |
404 magnificationFactor := aNumber. |
371 "/ magnificationFactor fractionPart < 0.1 ifTrue:[ |
405 "/ magnificationFactor fractionPart < 0.1 ifTrue:[ |
372 "/ "magnifying by integer factor is faster" |
406 "/ "magnifying by integer factor is faster" |
373 "/ magnificationFactor := magnificationFactor truncated. |
407 "/ magnificationFactor := magnificationFactor truncated. |
374 "/ ]. |
408 "/ ]. |
375 magnifiedImage := nil. |
409 magnifiedImage := nil. |
376 magnificationFactor = 1 ifTrue:[ |
410 magnificationFactor = 1 ifTrue:[ |
377 self contentsChanged. |
411 self contentsChanged. |
378 ]. |
412 ]. |
379 self invalidate. |
413 self invalidate. |