ImageView.st
author Claus Gittinger <cg@exept.de>
Tue, 02 Jun 2009 15:44:43 +0200
changeset 3710 162a45c5ce34
parent 3705 a75510393dc8
child 3711 ce2e9d1bcfcc
permissions -rw-r--r--
invalidate when image changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     1
"
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1993 by Claus Gittinger
24
6704fad5eb7d *** empty log message ***
claus
parents: 11
diff changeset
     3
	      All Rights Reserved
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     4
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    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
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    14
View subclass:#ImageView
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
    15
	instanceVariableNames:'image magnifiedImage adjust imageChannel tileMode tileOffset
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
    16
		lastMousePoint'
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    17
	classVariableNames:'DoNotMagnifyQuery'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
    18
	poolDictionaries:''
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
    19
	category:'Views-Misc'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    20
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    21
257
0acd4525d53e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
    22
!ImageView class methodsFor:'documentation'!
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    23
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    24
copyright
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    25
"
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    26
 COPYRIGHT (c) 1993 by Claus Gittinger
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    27
	      All Rights Reserved
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    28
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    29
 This software is furnished under a license and may be used
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    30
 only in accordance with the terms of that license and with the
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    31
 inclusion of the above copyright notice.   This software may not
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    32
 be provided or otherwise made available to, or used by, any
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    33
 other person.  No title to or ownership of the software is
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    34
 hereby transferred.
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    35
"
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    36
!
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    37
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    38
documentation
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    39
"
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    40
    This View knows how to display a (bitmap-)image (or form).
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    41
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    42
    You can display an image with:
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    43
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    44
        ImageView openOn:anImageFileName
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    45
    or:
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    46
        ImageView openOnImage:anImage
47
claus
parents: 46
diff changeset
    47
    or:
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    48
        ImageView new image:anImage
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    49
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    50
    i.e.
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    51
2748
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    52
        ImageView openOn:'../../goodies/bitmaps/gifImages/garfield.gif'
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    53
        ImageView openOn:'../../goodies/bitmaps/SBrowser.xbm'
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    54
2748
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    55
        ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif')
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    56
        ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/SBrowser.xbm')
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    57
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
    58
    adjust:     
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    59
        controls how images are displayed;
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    60
        can be one of:
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    61
            #topLeft    - image is displayed as usual
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    62
            #center     - image is shown centered
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    63
            #fitBig     - big images are shrunk to make it fit the view
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    64
            #fitSmall   - small images are magnified to make it fit the view,
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    65
            #fit        - all images are magnified to fit the view
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
    66
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    67
    [author:]
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    68
        Claus Gittinger
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    69
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    70
    [see also:]
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    71
        Image Form
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    72
"
3683
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    73
!
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    74
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    75
examples
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    76
"
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    77
    |top imgView scrView|
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    78
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    79
    top := StandardSystemView new.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    80
    top extent:300@300.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    81
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    82
    imgView := ImageView new.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    83
    imgView image:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif').
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    84
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    85
    scrView := HVScrollableView forView:imgView.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    86
    scrView origin:0@0 corner:1.0@1.0.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    87
    top add:scrView.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    88
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    89
    top open.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    90
"
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    91
! !
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    92
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    93
!ImageView class methodsFor:'initialization'!
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    94
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    95
initialize
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    96
    DoNotMagnifyQuery := QuerySignal new defaultAnswer:false.
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    97
! !
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    98
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
    99
!ImageView class methodsFor:'queries-plugin'!
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   100
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   101
aspectSelectors
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   102
    ^ #( imageChannel )
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   103
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   104
    "Created: / 11.2.2000 / 00:37:33 / cg"
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   105
! !
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   106
257
0acd4525d53e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   107
!ImageView class methodsFor:'startup'!
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   108
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   109
openOn:aFileName
47
claus
parents: 46
diff changeset
   110
    "startup an image viewer on an image read from a file"
claus
parents: 46
diff changeset
   111
1970
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   112
    |fn imageView img e|
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   113
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   114
    fn := aFileName asFilename.
47
claus
parents: 46
diff changeset
   115
1970
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   116
    img := Image fromFile:fn.
47
claus
parents: 46
diff changeset
   117
    img isNil ifTrue:[
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   118
        fn exists ifTrue:[
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   119
            e := 'Unknown or unsupported image format.'
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   120
        ] ifFalse:[
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   121
            e := 'No such image file.'.
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   122
        ].
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   123
        self warn:(self resources string:e).
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   124
        ^ nil
47
claus
parents: 46
diff changeset
   125
    ].
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   126
    imageView := self openOnImage:img.
47
claus
parents: 46
diff changeset
   127
1970
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   128
    imageView topView label:fn pathName iconLabel:(fn baseName).
47
claus
parents: 46
diff changeset
   129
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   130
    ^ imageView
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   131
47
claus
parents: 46
diff changeset
   132
    "
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   133
     ImageView openOn:'bitmaps/gifImages/garfield.gif'
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   134
     ImageView openOn:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm'
47
claus
parents: 46
diff changeset
   135
    "
348
58d52a823cca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   136
599
66c4da764a9e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 430
diff changeset
   137
    "Modified: / 31.10.1997 / 16:17:52 / cg"
47
claus
parents: 46
diff changeset
   138
!
claus
parents: 46
diff changeset
   139
claus
parents: 46
diff changeset
   140
openOnImage:anImage
claus
parents: 46
diff changeset
   141
    "startup an image viewer on an image"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   142
635
915077fd17ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   143
    |top v imageView icnW icnH iconView magX magY mag lbl imgWidth imgHeight|
47
claus
parents: 46
diff changeset
   144
claus
parents: 46
diff changeset
   145
    anImage isImage ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   146
	lbl := 'an Image'
47
claus
parents: 46
diff changeset
   147
    ] ifFalse:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   148
	lbl := 'a Form'
47
claus
parents: 46
diff changeset
   149
    ].
claus
parents: 46
diff changeset
   150
    top := StandardSystemView label:lbl.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   151
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   152
    v := HVScrollableView for:self in:top.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   153
    v origin:0@0 extent:1.0@1.0. 
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   154
    imageView := v scrolledView.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   155
47
claus
parents: 46
diff changeset
   156
    anImage notNil ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   157
	imageView image:anImage.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   158
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   159
	"define an icon view showing a little version of image.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   160
	 Since some window managers cannot handle this correctly (twm),
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   161
	 this is only done when running on an IRIS"
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   162
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   163
	(true "(OperatingSystem getSystemType = 'iris')" 
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   164
	and:[StyleSheet name == #iris]) ifTrue:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   165
	    iconView := ImageView new.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   166
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   167
	    "for now; should somehow get access to preferred iconview extent ..."
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   168
	    icnW := 86.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   169
	    icnH := 68.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   170
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   171
	    imgWidth := anImage width.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   172
	    imgHeight := anImage height.
635
915077fd17ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   173
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   174
	    ((imgWidth <= icnW) and:[imgHeight <= icnH]) ifTrue:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   175
		iconView extent:(imgWidth @ imgHeight).
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   176
		mag := 1 @ 1
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   177
	    ] ifFalse:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   178
		magX := icnW / imgWidth.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   179
		magY := icnH / imgHeight.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   180
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   181
		"scale image"
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   182
"
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   183
		mag := magX @ magY.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   184
"
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   185
		"preserve ratio"
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   186
" 
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   187
		mag := (magX min:magY) asPoint.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   188
" 
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   189
" "
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   190
		mag := (magX max:magY) asPoint.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   191
" "
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   192
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   193
		iconView extent:((anImage width @ anImage height) * mag) rounded.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   194
	    ].
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   195
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   196
	    top iconView:iconView.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   197
	].
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   198
    ].
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   199
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   200
    top open.
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   201
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
   202
    iconView notNil ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   203
	top windowGroup addView:iconView.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   204
	[ 
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   205
	    iconView image:(anImage magnifiedBy:mag).
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   206
	] forkAt:4
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   207
    ].
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   208
    ^ imageView
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   209
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
   210
    "
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   211
     ImageView openOnImage:(Image fromFile:'bitmaps/gifImages/garfield.gif')
47
claus
parents: 46
diff changeset
   212
     ImageView openOnImage:(Image fromFile:'bitmaps/SBrowser.xbm')
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
   213
    "
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   214
635
915077fd17ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   215
    "Modified: / 18.12.1997 / 11:46:19 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   216
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   217
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   218
!ImageView methodsFor:'accessing'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   219
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   220
adjust:layoutSymbol
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   221
    "set the adjust (how the image is displayed);
2375
e0c7852263e4 comment
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   222
     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
   223
            #topLeft    - image is displayed as usual
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   224
            #center     - image is shown centered
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   225
            #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
   226
            #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
   227
            #fit        - all images are magnified to fit the view
2375
e0c7852263e4 comment
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   228
    "
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   229
2164
df689a29b5d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2160
diff changeset
   230
    adjust ~= layoutSymbol ifTrue:[
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   231
        adjust := layoutSymbol.
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   232
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   233
        magnifiedImage := nil.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   234
        shown ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   235
            image notNil ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   236
                self generateMagnifiedImage.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   237
                self clear.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   238
                self scrollToTopLeft.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   239
                self invalidate.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   240
                self contentsChanged.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   241
            ]
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   242
        ].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   243
    ].
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   244
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   245
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   246
image
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   247
    "return the image"
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   248
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   249
    ^ image
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   250
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   251
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   252
image:anImage
3710
162a45c5ce34 invalidate when image changes
Claus Gittinger <cg@exept.de>
parents: 3705
diff changeset
   253
    "set the image"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   254
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   255
    self image:anImage scroll:true
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   256
!
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   257
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   258
image:anImage scroll:doScroll
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   259
    "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
   260
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   261
    self setImage:anImage scroll:doScroll
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   262
!
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   263
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   264
image:anImage scroll:doScroll invalidate:doInvalidate
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   265
    "set the image - show a wait cursor, since image dithering may take a while"
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   266
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   267
    self setImage:anImage scroll:doScroll invalidate:doInvalidate
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   268
!
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   269
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   270
magnification
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   271
    magnifiedImage isNil ifTrue:[^ 1@1].
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   272
    ^ magnifiedImage extent / image extent
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   273
!
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   274
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   275
setImage:anImage
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   276
    "set the image - show a wait cursor, since image dithering may take a while"
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   277
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   278
    |oldSize newSize|
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   279
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   280
    oldSize := image ifNil:[0@0] ifNotNil:[image extent].
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   281
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   282
    image := anImage.
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   283
    magnifiedImage := nil.
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   284
    self generateMagnifiedImage.
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   285
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   286
    newSize := image ifNil:[0@0] ifNotNil:[(magnifiedImage ? image) extent].
2164
df689a29b5d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2160
diff changeset
   287
    self scrollToTopLeft.
df689a29b5d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2160
diff changeset
   288
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   289
    oldSize ~= newSize ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   290
	"/ avoid endless loop in case of a resize happening due
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   291
	"/ to scrollBar visibility changes.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   292
	"/ that QuerySignal suppresses another magnification in sizeChanged: 
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   293
	DoNotMagnifyQuery answer:true
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   294
	do:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   295
	    self contentsChanged.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   296
	]
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   297
    ].
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   298
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   299
    shown ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   300
	self clear.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   301
	self invalidate
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   302
    ].
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   303
    self changed:#image.
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   304
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   305
    "Modified: / 10.2.2000 / 23:25:51 / cg"
2089
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   306
!
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   307
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   308
setImage:anImage scroll:doScroll
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   309
    "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
   310
3710
162a45c5ce34 invalidate when image changes
Claus Gittinger <cg@exept.de>
parents: 3705
diff changeset
   311
    self setImage:anImage scroll:doScroll invalidate:true
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   312
!
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   313
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   314
setImage:anImage scroll:doScroll invalidate:doInvalidate
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   315
    "set the image - show a wait cursor, since image dithering may take a while"
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   316
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   317
    |oldSize newSize|
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   318
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   319
    oldSize := image ifNil:[0@0] ifNotNil:[image extent].
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   320
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   321
    image := anImage.
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   322
    magnifiedImage := nil.
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   323
    self generateMagnifiedImage.
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   324
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   325
    newSize := image ifNil:[0@0] ifNotNil:[(magnifiedImage ? image) extent].
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   326
    doScroll ifTrue:[
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   327
        self scrollToTopLeft.
2544
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
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   330
    oldSize ~= newSize ifTrue:[
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   331
        "/ avoid endless loop in case of a resize happening due
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   332
        "/ to scrollBar visibility changes.
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   333
        "/ that QuerySignal suppresses another magnification in sizeChanged: 
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   334
        DoNotMagnifyQuery answer:true
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   335
        do:[
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   336
            self contentsChanged.
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   337
        ]
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   338
    ].
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   339
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   340
    (shown and:[doInvalidate]) ifTrue:[
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   341
        self clear.
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   342
        self invalidate
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   343
    ].
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   344
    self changed:#image.
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   345
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   346
    "Modified: / 10.2.2000 / 23:25:51 / cg"
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   347
!
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   348
2089
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   349
tileMode:aBoolean tileOffset:aPoint
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   350
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   351
    tileMode := aBoolean.
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   352
    tileOffset := aPoint
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   353
! !
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   354
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2402
diff changeset
   355
!ImageView methodsFor:'accessing-channels'!
1510
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
   356
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   357
imageChannel
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   358
    imageChannel isNil ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   359
	imageChannel := ValueHolder new.
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   360
	imageChannel addDependent:self.
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   361
    ].
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   362
    ^ imageChannel
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   363
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   364
    "Created: / 11.2.2000 / 00:34:44 / cg"
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   365
!
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   366
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   367
imageChannel:aValueHolder
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   368
    imageChannel notNil ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   369
	imageChannel removeDependent:self.
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   370
    ].
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   371
    imageChannel := aValueHolder.
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   372
    imageChannel notNil ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   373
	imageChannel addDependent:self.
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   374
    ].
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   375
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   376
    "Created: / 11.2.2000 / 00:34:33 / cg"
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   377
! !
1135
75101bf02c5b send contentsChanged notifications before, to avoid
Claus Gittinger <cg@exept.de>
parents: 1071
diff changeset
   378
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   379
!ImageView methodsFor:'change & update'!
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   380
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   381
update:something with:aParameter from:changedObject
2786
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   382
    changedObject == imageChannel ifTrue:[
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   383
        self image:imageChannel value.
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   384
        ^ self
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   385
    ].
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   386
    super update:something with:aParameter from:changedObject
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   387
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   388
    "Created: / 11.2.2000 / 00:37:02 / cg"
2786
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   389
!
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   390
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   391
updateFromModel
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   392
    "the model changes, set my image"
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   393
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   394
    self image:model value.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   395
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   396
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   397
!ImageView methodsFor:'drawing'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   398
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   399
generateMagnifiedImage
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   400
    |doFit innerWidth innerHeight imgWidth imgHeight|
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   401
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   402
    magnifiedImage notNil ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   403
	^ self
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   404
    ].
2358
68180cd61e53 care for nil image
Claus Gittinger <cg@exept.de>
parents: 2164
diff changeset
   405
    image isNil ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   406
	^ self
2358
68180cd61e53 care for nil image
Claus Gittinger <cg@exept.de>
parents: 2164
diff changeset
   407
    ].
68180cd61e53 care for nil image
Claus Gittinger <cg@exept.de>
parents: 2164
diff changeset
   408
        
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   409
    doFit := false.
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   410
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   411
    innerWidth := self innerWidth.
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   412
    innerHeight := self innerHeight.
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   413
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   414
    imgWidth := image width.
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   415
    imgHeight := image height.
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   416
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   417
    tileMode ~~ true ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   418
	((imgWidth > innerWidth)
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   419
	or:[imgHeight > innerHeight]) ifTrue:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   420
	    ((adjust == #fit) or:[adjust == #fitBig]) ifTrue:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   421
		doFit := true
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   422
	    ].
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   423
	] ifFalse:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   424
	    ((imgWidth < innerWidth)
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   425
	    or:[imgHeight < innerHeight]) ifTrue:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   426
		((adjust == #fit) or:[adjust == #fitSmall]) ifTrue:[
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   427
		    doFit := true
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   428
		].
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   429
	    ]
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   430
	].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   431
    ].
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   432
    doFit ifTrue:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   433
	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
   434
"/        self contentsChanged.
2164
df689a29b5d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2160
diff changeset
   435
    ] ifFalse:[
2650
f41da3ee2446 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2544
diff changeset
   436
	magnifiedImage := image
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   437
    ].
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   438
!
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   439
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 207
diff changeset
   440
redrawX:x y:y width:w height:h
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   441
    |xI yI depth shownImage imgWidth imgHeight right bott|
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   442
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   443
    image notNil ifTrue:[
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   444
        self generateMagnifiedImage.
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   445
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   446
        shownImage := magnifiedImage ? image.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   447
        imgWidth := shownImage width.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   448
        imgHeight := shownImage height.
635
915077fd17ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   449
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   450
        adjust == #center ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   451
            xI := (width - (margin * 2) - imgWidth) // 2.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   452
            yI := (height - (margin * 2) - imgHeight) // 2.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   453
        ] ifFalse:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   454
            xI := yI := margin
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   455
        ].
414
0347d494cd61 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   456
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   457
        ((depth := shownImage depth) == 1) ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   458
            self paint:(shownImage colorFromValue:1)
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   459
                    on:(shownImage colorFromValue:0).
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   460
        ].
1071
981c97fe54de generate device image before clearing in redraw
Claus Gittinger <cg@exept.de>
parents: 677
diff changeset
   461
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   462
        tileMode == true ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   463
            (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
   464
                (depth == 1
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   465
                and:[image mask isNil]) ifFalse:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   466
                    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
   467
                    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
   468
                        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
   469
                            self displayForm:image x:oX y:oY 
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   470
                        ]
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   471
                    ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   472
                ] ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   473
                    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
   474
                        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
   475
                            self displayOpaqueForm:image x:oX y:oY 
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   476
                        ]
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   477
                    ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   478
                ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   479
            ]
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   480
        ] ifFalse:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   481
            (depth == 1
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   482
            and:[shownImage mask isNil]) ifFalse:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   483
                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
   484
                self displayForm:shownImage x:xI y:yI 
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   485
            ] ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   486
                self displayOpaqueForm:shownImage x:xI y:yI 
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   487
            ].
430
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   488
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   489
            "/ right of image ?
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   490
            right := x + w - 1.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   491
            right > (xI + imgWidth) ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   492
                self clearRectangleX:(xI + imgWidth)
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   493
                                   y:y
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   494
                               width:(right - imgWidth - xI)
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   495
                              height:h  
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   496
            ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   497
            "/ below of image ?
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   498
            bott := y + h - 1.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   499
            bott > (yI + imgHeight) ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   500
                self clearRectangleX:margin
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   501
                                   y:(yI + imgHeight)
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   502
                               width:w
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   503
                              height:(bott - imgHeight - yI)  
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   504
            ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   505
        ].
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   506
    ]
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   507
635
915077fd17ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   508
    "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
   509
    "Modified: / 12.8.1998 / 14:02:28 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   510
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   511
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   512
!ImageView methodsFor:'event handling'!
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   513
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   514
buttonMotion:state x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   515
    |delta mousePoint|
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   516
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   517
    lastMousePoint notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   518
        mousePoint := (x@y).
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   519
        delta := mousePoint - lastMousePoint.
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   520
        delta ~= (0@0) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   521
            self scrollTo:(self viewOrigin - delta).
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   522
            lastMousePoint := mousePoint.
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   523
        ]
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   524
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   525
        super buttonMotion:state x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   526
    ]
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   527
!
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   528
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   529
buttonPress:button x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   530
    button == 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   531
        "/ self cursor:(Cursor handGrab)
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   532
        lastMousePoint := x@y.
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   533
    ].
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   534
    super buttonPress:button x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   535
!
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   536
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   537
buttonRelease:button x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   538
    button == 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   539
        lastMousePoint := nil
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   540
    ].
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   541
    super buttonRelease:button x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   542
!
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   543
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   544
sizeChanged:how
2911
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   545
    (#(fit fitBig fitSmall) includes:adjust) ifTrue:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   546
        magnifiedImage notNil ifTrue:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   547
            DoNotMagnifyQuery query ifFalse:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   548
                magnifiedImage := nil.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   549
                self generateMagnifiedImage.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   550
                self clear.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   551
                self invalidate.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   552
            ]
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   553
        ].
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   554
    ] ifFalse:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   555
        adjust == #center ifTrue:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   556
            self clear.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   557
            self invalidate.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   558
        ].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   559
    ].
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   560
    super sizeChanged:how
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   561
! !
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   562
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   563
!ImageView methodsFor:'initialization & release'!
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   564
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   565
destroy
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   566
    image := nil.
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   567
    super destroy.
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   568
! !
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   569
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   570
!ImageView methodsFor:'queries'!
24
6704fad5eb7d *** empty log message ***
claus
parents: 11
diff changeset
   571
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   572
heightOfContents
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   573
    "return the images height - scrollbar needs this info"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   574
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   575
    image isNil ifTrue:[^ 0].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   576
    ^ (magnifiedImage ? image) height
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   577
!
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   578
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   579
widthOfContents
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   580
    "return the images width - scrollbar needs this info"
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   581
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   582
    image isNil ifTrue:[^ 0].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   583
    ^ (magnifiedImage ? image) width
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   584
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   585
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   586
!ImageView methodsFor:'scrolling'!
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   587
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   588
scrollToMakeVisible:aPoint
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   589
    "try to arrange for aPoint to be visible (at the center, if possible)"
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   590
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   591
    |mag pos|
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   592
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   593
    mag := self magnification.
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   594
    pos := aPoint * mag.
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   595
    self scrollTo:(pos - (self extent / 2)) rounded.
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   596
! !
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   597
257
0acd4525d53e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   598
!ImageView class methodsFor:'documentation'!
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   599
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   600
version
3710
162a45c5ce34 invalidate when image changes
Claus Gittinger <cg@exept.de>
parents: 3705
diff changeset
   601
    ^ '$Header: /cvs/stx/stx/libwidg2/ImageView.st,v 1.69 2009-06-02 13:44:43 cg Exp $'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   602
! !
2358
68180cd61e53 care for nil image
Claus Gittinger <cg@exept.de>
parents: 2164
diff changeset
   603
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   604
ImageView initialize!