ImageView.st
author Claus Gittinger <cg@exept.de>
Mon, 28 May 2018 14:23:20 +0200
changeset 5779 b5698ce18620
parent 5778 50aff5f8d07f
child 5780 fe449b76bc3c
permissions -rw-r--r--
#UI_ENHANCEMENT by cg class: ImageView class changed: #middleButtonMenu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5741
75e825820538 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5721
diff changeset
     1
"{ Encoding: utf8 }"
75e825820538 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5721
diff changeset
     2
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     3
"
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     4
 COPYRIGHT (c) 1993 by Claus Gittinger
24
6704fad5eb7d *** empty log message ***
claus
parents: 11
diff changeset
     5
	      All Rights Reserved
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     6
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     7
 This software is furnished under a license and may be used
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     8
 only in accordance with the terms of that license and with the
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
     9
 inclusion of the above copyright notice.   This software may not
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    10
 be provided or otherwise made available to, or used by, any
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    11
 other person.  No title to or ownership of the software is
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    12
 hereby transferred.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    13
"
1763
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1694
diff changeset
    14
"{ Package: 'stx:libwidg2' }"
7d6d64622ee4 change & updates fixed (monochrome bitmaps)
Claus Gittinger <cg@exept.de>
parents: 1694
diff changeset
    15
4732
b5db158865ca class: ImageView
Stefan Vogel <sv@exept.de>
parents: 4561
diff changeset
    16
"{ NameSpace: Smalltalk }"
b5db158865ca class: ImageView
Stefan Vogel <sv@exept.de>
parents: 4561
diff changeset
    17
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    18
View subclass:#ImageView
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
    19
	instanceVariableNames:'image magnifiedImage smoothMagnifiedImage adjust
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
    20
		explicitMagnificationFactor magnificationFactor tileMode
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
    21
		tileOffset lastMousePoint adjustHolder imageEditAction
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
    22
		forceSmoothingHolder smoothingProcess'
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    23
	classVariableNames:'DoNotMagnifyQuery'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
    24
	poolDictionaries:''
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
    25
	category:'Views-Misc'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    26
!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
    27
257
0acd4525d53e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
    28
!ImageView class methodsFor:'documentation'!
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    29
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    30
copyright
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    31
"
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    32
 COPYRIGHT (c) 1993 by Claus Gittinger
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    33
	      All Rights Reserved
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    34
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    35
 This software is furnished under a license and may be used
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    36
 only in accordance with the terms of that license and with the
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    37
 inclusion of the above copyright notice.   This software may not
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    38
 be provided or otherwise made available to, or used by, any
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    39
 other person.  No title to or ownership of the software is
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    40
 hereby transferred.
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    41
"
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    42
!
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    43
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    44
documentation
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    45
"
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    46
    This View knows how to display a (bitmap-)image (or form).
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    47
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    48
    You can display an image with:
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    49
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    50
        ImageView openOn:anImageFileName
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    51
    or:
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    52
        ImageView openOnImage:anImage
47
claus
parents: 46
diff changeset
    53
    or:
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    54
        ImageView new image:anImage
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    55
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    56
    i.e.
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    57
2748
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    58
        ImageView openOn:'../../goodies/bitmaps/gifImages/garfield.gif'
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    59
        ImageView openOn:'../../goodies/bitmaps/SBrowser.xbm'
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    60
2748
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    61
        ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif')
25e0b6b5b411 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2747
diff changeset
    62
        ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/SBrowser.xbm')
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    63
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
    64
    adjust:
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    65
        controls how images are displayed;
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    66
        can be one of:
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    67
            #topLeft    - image is displayed as usual
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    68
            #center     - image is shown centered
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    69
            #fitBig     - big images are shrunk to make it fit the view
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    70
            #fitSmall   - small images are magnified to make it fit the view,
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    71
            #fit        - all images are magnified to fit the view
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
    72
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    73
    [author:]
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    74
        Claus Gittinger
296
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    75
f1007170201e see also
Claus Gittinger <cg@exept.de>
parents: 269
diff changeset
    76
    [see also:]
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
    77
        Image Form
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    78
"
3683
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    79
!
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    80
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    81
examples
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    82
"
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    83
    |top imgView scrView|
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    84
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    85
    top := StandardSystemView new.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    86
    top extent:300@300.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    87
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    88
    imgView := ImageView new.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    89
    imgView image:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif').
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    90
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    91
    scrView := HVScrollableView forView:imgView.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    92
    scrView origin:0@0 corner:1.0@1.0.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    93
    top add:scrView.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    94
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    95
    top open.
80466def0fc4 comment
Claus Gittinger <cg@exept.de>
parents: 3659
diff changeset
    96
"
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    97
! !
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
    98
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
    99
!ImageView class methodsFor:'initialization'!
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   100
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   101
initialize
4912
6630a4464c2f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4732
diff changeset
   102
    DoNotMagnifyQuery isNil ifTrue:[
6630a4464c2f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4732
diff changeset
   103
        DoNotMagnifyQuery := QuerySignal new defaultAnswer:false.
6630a4464c2f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4732
diff changeset
   104
    ].
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   105
! !
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
   106
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   107
!ImageView class methodsFor:'menu specs'!
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   108
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   109
middleButtonMenu
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   110
    "This resource specification was automatically generated
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   111
     by the MenuEditor of ST/X."
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   112
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   113
    "Do not manually edit this!! If it is corrupted,
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   114
     the MenuEditor may not be able to read the specification."
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   115
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   116
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   117
    "
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   118
     MenuEditor new openOnClass:ImageView andSelector:#middleButtonMenu
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   119
     (Menu new fromLiteralArrayEncoding:(ImageView middleButtonMenu)) startUp
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   120
    "
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   121
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   122
    <resource: #menu>
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   123
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   124
    ^ 
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   125
     #(Menu
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   126
        (
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   127
         (MenuItem
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   128
            label: 'Size to Fit'
5779
b5698ce18620 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5778
diff changeset
   129
            isVisible: fitBigMenuItemVisible
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   130
            choice: adjustHolder
5599
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   131
            choiceValue: fitBig
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   132
          )
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   133
         (MenuItem
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   134
            label: 'Size to Fit (smooth)'
5779
b5698ce18620 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5778
diff changeset
   135
            isVisible: smoothFitBigMenuItemVisible
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   136
            choice: adjustHolder
5599
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   137
            choiceValue: smoothFitBig
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   138
          )
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   139
         (MenuItem
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   140
            label: 'Original Size'
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   141
            choice: adjustHolder
5599
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   142
            choiceValue: topLeft
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   143
          )
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   144
         (MenuItem
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   145
            label: 'Magnify'
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   146
            submenu: 
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   147
           (Menu
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   148
              (
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   149
               (MenuItem
5760
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   150
                  label: '* 0.5'
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   151
                  itemValue: magnifyBy:
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   152
                  argument: 0.5
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   153
                )
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   154
               (MenuItem
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   155
                  label: '* 0.75'
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   156
                  itemValue: magnifyBy:
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   157
                  argument: 0.75
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   158
                )
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   159
               (MenuItem
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   160
                  label: '* 1'
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   161
                  itemValue: magnifyBy:
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   162
                  argument: 1
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   163
                )
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   164
               (MenuItem
5599
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   165
                  label: '* 2'
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   166
                  itemValue: magnifyBy:
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   167
                  argument: 2
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   168
                )
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   169
               (MenuItem
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   170
                  label: '* 4'
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   171
                  itemValue: magnifyBy:
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   172
                  argument: 4
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   173
                )
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   174
               (MenuItem
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   175
                  label: '-'
5760
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
   176
                  isVisible: smoothingMenuItemVisible
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   177
                )
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   178
               (MenuItem
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   179
                  label: 'Smoothing'
5779
b5698ce18620 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5778
diff changeset
   180
                  isVisible: smoothingMenuItemVisible
b5698ce18620 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5778
diff changeset
   181
                  hideMenuOnActivated: false
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   182
                  indication: forceSmoothingHolder
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   183
                )
5599
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   184
               )
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   185
              nil
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   186
              nil
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
   187
            )
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   188
          )
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   189
         (MenuItem
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   190
            label: '-'
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   191
            isVisible: selfIsNotImageEditor
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   192
          )
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   193
         (MenuItem
5751
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   194
            label: 'Save As...'
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   195
            itemValue: saveImageAs
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   196
            isVisible: selfIsNotImageEditor
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   197
          )
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   198
         (MenuItem
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   199
            label: 'Edit'
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   200
            itemValue: editImage
5532
bdc0ef74e9f4 #BUGFIX by expecco
Claus Gittinger <cg@exept.de>
parents: 5530
diff changeset
   201
            isVisible: selfIsNotImageEditor
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   202
          )
5751
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   203
         (MenuItem
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   204
            label: 'Extra Slice'
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   205
            submenuChannel: middleButtonMenuExtraSlice
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   206
            isMenuSlice: true
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   207
          )
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   208
         )
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   209
        nil
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   210
        nil
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   211
      )
5751
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   212
!
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   213
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   214
middleButtonMenuExtraSlice
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   215
    "can be refdefined in subclasses to add more menu items"
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   216
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
   217
    ^ nil
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   218
! !
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   219
2511
10537dc4e961 category change
Claus Gittinger <cg@exept.de>
parents: 2501
diff changeset
   220
!ImageView class methodsFor:'queries-plugin'!
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   221
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   222
aspectSelectors
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   223
    ^ #( imageChannel )
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   224
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   225
    "Created: / 11.2.2000 / 00:37:33 / cg"
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   226
! !
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   227
257
0acd4525d53e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
   228
!ImageView class methodsFor:'startup'!
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   229
4192
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   230
openOn:anImageOrFileName
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   231
    "startup an image viewer on an image or
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   232
     an image read from a file.
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   233
     Return the imageView (not the topView)"
4192
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   234
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   235
    anImageOrFileName isImage ifTrue:[
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   236
        ^ self openOnImage:anImageOrFileName
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   237
    ].
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   238
    ^ self openOnFile:anImageOrFileName
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   239
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   240
    "
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   241
     ImageView openOn:'bitmaps/gifImages/garfield.gif'
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   242
     ImageView openOn:'bitmaps/xpmBitmaps/misc_icons/BOOK.xpm'
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   243
    "
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   244
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   245
    "Modified: / 31-10-1997 / 16:17:52 / cg"
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   246
    "Modified (comment): / 13-02-2017 / 10:13:13 / cg"
4192
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   247
!
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   248
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
   249
openOnFile:aFileName
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   250
    "startup an image viewer on an image read from a file.
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   251
     Return the imageView (not the topView)"
47
claus
parents: 46
diff changeset
   252
1970
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   253
    |fn imageView img e|
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   254
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   255
    fn := aFileName asFilename.
47
claus
parents: 46
diff changeset
   256
1970
b7cf91b688d1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1764
diff changeset
   257
    img := Image fromFile:fn.
47
claus
parents: 46
diff changeset
   258
    img isNil ifTrue:[
2747
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   259
        fn exists ifTrue:[
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   260
            e := 'Unknown or unsupported image format.'
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   261
        ] ifFalse:[
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   262
            e := 'No such image file.'.
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   263
        ].
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   264
        self warn:(self resources string:e).
818a513a64c3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2659
diff changeset
   265
        ^ nil
47
claus
parents: 46
diff changeset
   266
    ].
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   267
    imageView := self openOnImage:img.
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   268
    imageView topView label:(fn pathName) iconLabel:(fn baseName).
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   269
    ^ imageView
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   270
47
claus
parents: 46
diff changeset
   271
    "
4558
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   272
     ImageView openOnFile:'../../goodies/bitmaps/gifImages/garfield.gif'
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   273
     ImageView openOnFile:'../../goodies/bitmaps/xpmBitmaps/misc_icons/BOOK.xpm'
47
claus
parents: 46
diff changeset
   274
    "
348
58d52a823cca checkin from browser
Claus Gittinger <cg@exept.de>
parents: 324
diff changeset
   275
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   276
    "Modified: / 31-10-1997 / 16:17:52 / cg"
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   277
    "Modified (comment): / 13-02-2017 / 10:12:53 / cg"
47
claus
parents: 46
diff changeset
   278
!
claus
parents: 46
diff changeset
   279
claus
parents: 46
diff changeset
   280
openOnImage:anImage
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   281
    "startup an image viewer on an image.
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   282
     Return the imageView (not the topView)"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   283
4558
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   284
    |lbl|
47
claus
parents: 46
diff changeset
   285
claus
parents: 46
diff changeset
   286
    anImage isImage ifTrue:[
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   287
        lbl := anImage fileName ? 'an Image'
47
claus
parents: 46
diff changeset
   288
    ] ifFalse:[
3904
6e93f6b54377 changed: #openOnImage:
Claus Gittinger <cg@exept.de>
parents: 3884
diff changeset
   289
        anImage isNil ifTrue:[
6e93f6b54377 changed: #openOnImage:
Claus Gittinger <cg@exept.de>
parents: 3884
diff changeset
   290
            lbl := 'an Image'
6e93f6b54377 changed: #openOnImage:
Claus Gittinger <cg@exept.de>
parents: 3884
diff changeset
   291
        ] ifFalse:[
6e93f6b54377 changed: #openOnImage:
Claus Gittinger <cg@exept.de>
parents: 3884
diff changeset
   292
            lbl := 'a Form'
6e93f6b54377 changed: #openOnImage:
Claus Gittinger <cg@exept.de>
parents: 3884
diff changeset
   293
        ]
47
claus
parents: 46
diff changeset
   294
    ].
4558
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   295
    ^ self openOnImage:anImage title:lbl
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   296
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   297
    "
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   298
     ImageView openOnImage:(Image fromFile:'bitmaps/gifImages/garfield.gif') title:'garfield'
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   299
     ImageView openOnImage:(Image fromFile:'../../libtool/bitmaps/SBrowser.xbm') title:'old browser icon'
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   300
    "
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   301
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   302
    "Modified (comment): / 13-02-2017 / 10:12:43 / cg"
4558
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   303
!
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   304
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   305
openOnImage:anImage title:aString
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   306
    "startup an image viewer on an image.
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   307
     Return the imageView (not the topView)"
4558
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   308
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   309
    |top v imageView icnW icnH iconView magX magY mag imgWidth imgHeight|
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   310
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   311
    top := StandardSystemView label:aString.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   312
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   313
    v := HVScrollableView for:self in:top.
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   314
    v origin:0@0 extent:1.0@1.0.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   315
    imageView := v scrolledView.
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   316
47
claus
parents: 46
diff changeset
   317
    anImage notNil ifTrue:[
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   318
        imageView image:anImage.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   319
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   320
        "define an icon view showing a little version of image.
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   321
         Since some window managers cannot handle this correctly (twm),
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   322
         this is only done when running on an IRIS"
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   323
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   324
        (true "(OperatingSystem getSystemType = 'iris')"
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   325
        and:[StyleSheet name == #iris]) ifTrue:[
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   326
            iconView := ImageView new.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   327
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   328
            "for now; should somehow get access to preferred iconview extent ..."
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   329
            icnW := 86.
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   330
            icnH := 68.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   331
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   332
            imgWidth := anImage width.
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   333
            imgHeight := anImage height.
635
915077fd17ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   334
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   335
            ((imgWidth <= icnW) and:[imgHeight <= icnH]) ifTrue:[
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   336
                iconView extent:(imgWidth @ imgHeight).
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   337
                mag := 1 @ 1
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   338
            ] ifFalse:[
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   339
                magX := icnW / imgWidth.
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   340
                magY := icnH / imgHeight.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   341
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   342
                "scale image"
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   343
"
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   344
                mag := magX @ magY.
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   345
"
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   346
                "preserve ratio"
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   347
"
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   348
                mag := (magX min:magY) asPoint.
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   349
"
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   350
                mag := (magX max:magY) asPoint.
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   351
                iconView extent:((anImage width @ anImage height) * mag) rounded.
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   352
            ].
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   353
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   354
            top iconView:iconView.
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   355
        ].
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   356
    ].
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   357
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   358
    top open.
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   359
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
   360
    iconView notNil ifTrue:[
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   361
        top windowGroup addView:iconView.
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   362
        [
3733
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   363
            iconView image:(anImage magnifiedBy:mag).
f7c401c2b55c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3726
diff changeset
   364
        ] forkAt:4
7
19b36b78ee01 *** empty log message ***
claus
parents: 1
diff changeset
   365
    ].
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   366
    ^ imageView
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   367
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
   368
    "
4558
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   369
     ImageView openOnImage:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif') title:'garfield'
699f6a043e51 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4263
diff changeset
   370
     ImageView openOnImage:(Image fromFile:'../../libtool/bitmaps/SBrowser.xbm')
26
ff148983c183 *** empty log message ***
claus
parents: 24
diff changeset
   371
    "
353
0442fc169b82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 348
diff changeset
   372
3904
6e93f6b54377 changed: #openOnImage:
Claus Gittinger <cg@exept.de>
parents: 3884
diff changeset
   373
    "Modified: / 01-06-2010 / 18:31:14 / cg"
5467
fef61bfd9fad #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5430
diff changeset
   374
    "Modified (comment): / 13-02-2017 / 10:12:35 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   375
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   376
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   377
!ImageView methodsFor:'accessing'!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   378
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   379
adjust
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   380
    "get the adjust (how the image is displayed);
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   381
     currently, support #topLeft, #center, #fitBig, #fitSmall and #fit:
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   382
            #topLeft    - image is displayed as usual
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   383
            #center     - image is shown centered
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   384
            #fitBig     - big images are shrunk to make it fit the view
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   385
            #fitSmall   - small images are magnified to make it fit the view,
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   386
            #fit        - all images are magnified to fit the view
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   387
            #smoothFitBig     - fitBig with smoothing
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   388
            #smoothFitSmall   - fitSmall with smoothing
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   389
            #smoothFit        - fit with smoothing
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   390
    "
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   391
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   392
    ^ adjust ? #topLeft
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   393
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   394
    "Modified (comment): / 10-09-2017 / 17:06:16 / cg"
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   395
!
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   396
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   397
adjust:layoutSymbol
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   398
    "set the adjust (how the image is displayed);
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   399
     currently, support #topLeft, #center, #fitBig, #fitSmall and #fit:
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   400
            #topLeft    - image is displayed as usual
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   401
            #center     - image is shown centered
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   402
            #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
   403
            #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
   404
            #fit        - all images are magnified to fit the view
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   405
            #topLeftNoZoom    - image is displayed as usual, and magnification is reset
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   406
            #smoothFitBig     - fitBig with smoothing
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   407
            #smoothFitSmall   - fitSmall with smoothing
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   408
            #smoothFit        - fit with smoothing
2375
e0c7852263e4 comment
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
   409
    "
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   410
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   411
    |layoutUsed|
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   412
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   413
    layoutUsed := layoutSymbol.
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   414
    layoutUsed == #topLeftNoZoom ifTrue:[
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   415
        layoutUsed := #topLeft
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   416
    ].
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   417
    self magnificationFactor ~= 1 ifTrue:[
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   418
        explicitMagnificationFactor := magnificationFactor := 1.
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   419
        self magnificationFactor:1
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   420
    ].
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   421
    
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   422
    adjust ~= layoutUsed ifTrue:[
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   423
        adjust := layoutUsed.
5402
ac1a78db1d84 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
   424
        adjustHolder notNil ifTrue:[
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   425
            adjustHolder value:layoutUsed withoutNotifying:self
5402
ac1a78db1d84 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5400
diff changeset
   426
        ].    
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   427
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   428
        magnifiedImage := smoothMagnifiedImage := nil.
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   429
        shown ifTrue:[
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   430
            image notNil ifTrue:[
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   431
                "/ self magnificationFactor ~= 1 ifTrue:[
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   432
                    self generateMagnifiedImage.
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   433
                "/ ].    
2659
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   434
                self clear.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   435
                self scrollToTopLeft.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   436
                self invalidate.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   437
                self contentsChanged.
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   438
            ]
3af857eb52fb invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents: 2650
diff changeset
   439
        ].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   440
    ].
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   441
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   442
    "Modified: / 28-09-2017 / 18:20:55 / cg"
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   443
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   444
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   445
adjustHolder
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   446
    "get a valeHolder for the adjust (how the image is displayed);
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   447
     currently, support #topLeft, #center, #fitBig, #fitSmall and #fit:
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   448
            #topLeft    - image is displayed as usual
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   449
            #center     - image is shown centered
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   450
            #fitBig     - big images are shrunk to make it fit the view
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   451
            #fitSmall   - small images are magnified to make it fit the view,
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   452
            #fit        - all images are magnified to fit the view
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   453
            #smoothFitBig     - fitBig with smoothing
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   454
            #smoothFitSmall   - fitSmall with smoothing
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   455
            #smoothFit        - fit with smoothing
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   456
    "
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   457
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   458
    adjustHolder isNil ifTrue:[
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   459
        adjustHolder := self adjust asValue.
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   460
        adjustHolder 
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   461
            onChangeEvaluate:[
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   462
                self adjust:(adjustHolder value).
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   463
            ]
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   464
    ].        
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   465
    ^ adjustHolder
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   466
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   467
    "Modified (comment): / 10-09-2017 / 17:06:23 / cg"
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   468
!
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   469
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   470
forceSmoothing
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   471
    ^ self forceSmoothingHolder value
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   472
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   473
    "Created: / 28-09-2017 / 17:52:38 / cg"
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   474
!
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   475
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   476
forceSmoothing:aBoolean
5611
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   477
    self forceSmoothingHolder value:aBoolean.
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   478
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   479
    "Created: / 28-09-2017 / 17:52:30 / cg"
5611
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   480
    "Modified: / 29-09-2017 / 10:30:32 / cg"
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   481
!
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   482
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   483
forceSmoothingHolder
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   484
    forceSmoothingHolder isNil ifTrue:[
5611
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   485
        forceSmoothingHolder := false asValue.
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   486
        forceSmoothingHolder 
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   487
            onChangeEvaluate:[
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   488
                smoothMagnifiedImage := nil.
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   489
                self invalidate.
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   490
            ].
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   491
    ].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   492
    ^ forceSmoothingHolder
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   493
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   494
    "Created: / 28-09-2017 / 17:55:51 / cg"
5611
8c53817d5e0a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5610
diff changeset
   495
    "Modified: / 29-09-2017 / 10:30:57 / cg"
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   496
!
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   497
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   498
image
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   499
    "return the image"
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   500
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   501
    ^ image
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   502
!
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   503
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
   504
image:anImage
5398
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   505
    "set the image scrolls as set by adjust
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   506
     - may show a wait cursor, if image dithering may take a while"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   507
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   508
    self image:anImage scroll:true
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   509
!
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   510
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   511
image:anImage scroll:doScroll
5398
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   512
    "set the image possibly scroll as set by adjust
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   513
     - 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
   514
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   515
    self setImage:anImage scroll:doScroll
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   516
!
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   517
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   518
image:anImage scroll:doScroll invalidate:doInvalidate
5398
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   519
    "set the image possibly scroll as set by adjust
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   520
     - may show a wait cursor, if image dithering may take a while"
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   521
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   522
    self setImage:anImage scroll:doScroll invalidate:doInvalidate
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   523
!
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   524
5488
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   525
imageEditAction:aOneArgBlockOrNil
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   526
    "if nonNil, aOneArgBlockOrNil will be called to open
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   527
     the image editor (as by the 'Edit Image' menu action).
5487
7faa7a284651 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5482
diff changeset
   528
     If never set, the default ImageEditor is opened."
7faa7a284651 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5482
diff changeset
   529
5488
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   530
    imageEditAction := aOneArgBlockOrNil.
5487
7faa7a284651 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5482
diff changeset
   531
5488
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   532
    "Created: / 19-02-2017 / 22:58:14 / cg"
5487
7faa7a284651 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5482
diff changeset
   533
!
7faa7a284651 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5482
diff changeset
   534
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   535
magnification
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   536
    magnifiedImage isNil ifTrue:[^ 1@1].
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   537
    ^ magnifiedImage extent / image extent
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   538
!
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
   539
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   540
magnificationFactor
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   541
    ^ magnificationFactor ? 1
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   542
!
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   543
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   544
magnificationFactor:aNumber
5614
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   545
    true "explicitMagnificationFactor ~= aNumber" ifTrue:[
5596
0ec4341756f5 #BUGFIX by Maren
matilk
parents: 5595
diff changeset
   546
        magnificationFactor := explicitMagnificationFactor := aNumber.
5403
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   547
        "/    magnificationFactor fractionPart < 0.1 ifTrue:[
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   548
        "/        "magnifying by integer factor is faster"
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   549
        "/        magnificationFactor := magnificationFactor truncated.
c261a6c25100 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5402
diff changeset
   550
        "/    ].
5614
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   551
        self synchronized:[
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   552
            smoothingProcess notNil ifTrue:[
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   553
                smoothingProcess terminate.
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   554
                smoothMagnifiedImage := nil.
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   555
            ].
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   556
        ].    
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   557
        magnifiedImage := smoothMagnifiedImage := nil.
5398
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   558
        magnificationFactor = 1 ifTrue:[
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   559
            self contentsChanged.
5777
14cf639d3fce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5760
diff changeset
   560
        ].
14cf639d3fce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5760
diff changeset
   561
        (adjust includesString:'fit' caseSensitive:false) ifTrue:[
14cf639d3fce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5760
diff changeset
   562
            adjust := #topLeft.
14cf639d3fce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5760
diff changeset
   563
        ].
5398
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   564
        self invalidate.
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   565
    ].
5596
0ec4341756f5 #BUGFIX by Maren
matilk
parents: 5595
diff changeset
   566
0ec4341756f5 #BUGFIX by Maren
matilk
parents: 5595
diff changeset
   567
    "Modified: / 06-09-2017 / 12:51:28 / Maren"
5614
eb3741274c29 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5611
diff changeset
   568
    "Modified: / 04-10-2017 / 16:40:00 / cg"
5777
14cf639d3fce #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5760
diff changeset
   569
    "Modified: / 28-05-2018 / 14:11:50 / Claus Gittinger"
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   570
!
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   571
4066
a2fe2f6cf0c7 added: #model:
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
   572
model:aValueHolder
a2fe2f6cf0c7 added: #model:
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
   573
    super model:aValueHolder.
a2fe2f6cf0c7 added: #model:
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
   574
    self updateFromModel.
a2fe2f6cf0c7 added: #model:
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
   575
a2fe2f6cf0c7 added: #model:
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
   576
    "Created: / 25-07-2011 / 15:32:10 / cg"
a2fe2f6cf0c7 added: #model:
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
   577
!
a2fe2f6cf0c7 added: #model:
Claus Gittinger <cg@exept.de>
parents: 4031
diff changeset
   578
1993
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   579
setImage:anImage
e7c12938af98 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1970
diff changeset
   580
    "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
   581
4966
fd25317b66de #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   582
    self setImage:anImage scroll:true invalidate:true
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   583
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   584
    "Modified: / 10.2.2000 / 23:25:51 / cg"
2089
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   585
!
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   586
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   587
setImage:anImage scroll:doScroll
5398
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   588
    "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
   589
3710
162a45c5ce34 invalidate when image changes
Claus Gittinger <cg@exept.de>
parents: 3705
diff changeset
   590
    self setImage:anImage scroll:doScroll invalidate:true
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   591
!
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   592
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   593
setImage:anImage scroll:doScroll invalidate:doInvalidate
5398
3c4304d0d819 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5387
diff changeset
   594
    "set the image - may show a wait cursor, if image dithering may take a while"
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   595
4966
fd25317b66de #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   596
    |oldSize newSize newImageIsSmaller|
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   597
5688
00641931349b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5616
diff changeset
   598
    self assert:(anImage isImageOrForm or:[anImage isNil]).
5430
b073297e25ae #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 5404
diff changeset
   599
    
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   600
    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
   601
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   602
    image := anImage.
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   603
    magnifiedImage := smoothMagnifiedImage := nil.
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   604
    self generateMagnifiedImage.
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   605
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   606
    newSize := image isNil ifTrue:[0@0] ifFalse:[(magnifiedImage ? image) extent].
4966
fd25317b66de #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4912
diff changeset
   607
    newImageIsSmaller := ((oldSize x > newSize x) or:[oldSize y > newSize y]).
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   608
5227
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   609
    (newImageIsSmaller and:[ doInvalidate ]) ifTrue:[ self invalidate ].
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   610
    doScroll ifTrue:[ self scrollToTopLeft ].
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   611
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   612
    oldSize ~= newSize ifTrue:[
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   613
        "/ avoid endless loop in case of a resize happening due
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   614
        "/ to scrollBar visibility changes.
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   615
        "/ that QuerySignal suppresses another magnification in sizeChanged:
5688
00641931349b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5616
diff changeset
   616
        DoNotMagnifyQuery answer:true do:[ self contentsChanged ]
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   617
    ].
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   618
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   619
    (shown and:[doInvalidate]) ifTrue:[
5268
b490144a4971 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5227
diff changeset
   620
        "/ (anImage isNil "or:[newImageIsSmaller]") ifTrue:[
b490144a4971 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5227
diff changeset
   621
        "/     self clear.
b490144a4971 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5227
diff changeset
   622
        "/ ].
3705
a75510393dc8 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3683
diff changeset
   623
        self invalidate
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   624
    ].
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   625
    self changed:#image.
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   626
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   627
    "Modified: / 28-09-2017 / 18:21:07 / cg"
2544
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   628
!
bcae3dbd3ccd do not scroll, when crobbing
Claus Gittinger <cg@exept.de>
parents: 2511
diff changeset
   629
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   630
sizeToFit:aBoolean
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   631
    aBoolean ifTrue:[
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   632
        self adjust:#fitBig
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   633
    ] ifFalse:[
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   634
        explicitMagnificationFactor := magnificationFactor := 1.
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   635
        self adjust:nil.
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   636
    ]
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   637
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   638
    "Modified: / 10-09-2017 / 17:54:49 / cg"
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   639
!
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   640
2089
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   641
tileMode:aBoolean tileOffset:aPoint
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   642
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   643
    tileMode := aBoolean.
8c0aed9152c4 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1993
diff changeset
   644
    tileOffset := aPoint
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   645
! !
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   646
2404
2b7591c982ac category change
Claus Gittinger <cg@exept.de>
parents: 2402
diff changeset
   647
!ImageView methodsFor:'accessing-channels'!
1510
fd0cd6065dc6 catch image conversion errors.
Claus Gittinger <cg@exept.de>
parents: 1327
diff changeset
   648
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   649
imageChannel
4031
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   650
    ^ self model
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   651
4031
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   652
    "Modified: / 31-03-2011 / 10:45:58 / cg"
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   653
!
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   654
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   655
imageChannel:aValueHolder
4031
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   656
    self model:aValueHolder.
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   657
4031
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   658
    "Created: / 11-02-2000 / 00:34:33 / cg"
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   659
    "Modified: / 31-03-2011 / 10:46:07 / cg"
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   660
!
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   661
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   662
mousePointHolder
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   663
    ^ lastMousePoint
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   664
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   665
    "Created: / 25-02-2017 / 22:36:02 / cg"
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   666
! !
1135
75101bf02c5b send contentsChanged notifications before, to avoid
Claus Gittinger <cg@exept.de>
parents: 1071
diff changeset
   667
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   668
!ImageView methodsFor:'change & update'!
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   669
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   670
update:something with:aParameter from:changedObject
4031
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   671
    changedObject == model ifTrue:[
4561
5e11aa6a92d8 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4558
diff changeset
   672
        self updateFromModel.
2786
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   673
        ^ self
1694
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   674
    ].
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   675
    super update:something with:aParameter from:changedObject
668020398028 de-uglified
Claus Gittinger <cg@exept.de>
parents: 1510
diff changeset
   676
4031
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   677
    "Created: / 11-02-2000 / 00:37:02 / cg"
4213ffa8fc14 class definition
Claus Gittinger <cg@exept.de>
parents: 3904
diff changeset
   678
    "Modified: / 31-03-2011 / 10:46:16 / cg"
2786
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   679
!
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   680
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   681
updateFromModel
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   682
    "the model changes, set my image"
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   683
d3b6171aec01 React to changes of imageChannel.
Stefan Vogel <sv@exept.de>
parents: 2748
diff changeset
   684
    self image:model value.
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   685
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   686
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   687
!ImageView methodsFor:'drawing'!
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   688
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   689
generateMagnifiedImage
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   690
    |adj smooth doFit innerWidth innerHeight imgWidth imgHeight|
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   691
5741
75e825820538 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5721
diff changeset
   692
    image isNil ifTrue:[^ self].
75e825820538 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5721
diff changeset
   693
    smoothMagnifiedImage notNil ifTrue:[^ self].
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   694
    
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   695
    adj := adjust.
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   696
    smooth := false.
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   697
    (adjust notNil and:[adjust startsWith:#smooth]) ifTrue:[
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   698
        adj := (adjust copyFrom:'smooth' size+1) asLowercaseFirst asSymbol.
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   699
        smooth := true.
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   700
    ].
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   701
    self forceSmoothing ifTrue:[smooth := true].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   702
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   703
    magnifiedImage isNil ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   704
        doFit := false.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   705
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   706
        innerWidth := self innerWidth.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   707
        innerHeight := self innerHeight.
5596
0ec4341756f5 #BUGFIX by Maren
matilk
parents: 5595
diff changeset
   708
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   709
        imgWidth := image width.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   710
        imgHeight := image height.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   711
5778
50aff5f8d07f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5777
diff changeset
   712
        (#(fit fitBig fitSmall) includes:adj) ifTrue:[
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   713
            magnificationFactor := explicitMagnificationFactor.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   714
        ].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   715
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   716
        tileMode ~~ true ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   717
            ((imgWidth > innerWidth)
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   718
            or:[imgHeight > innerHeight]) ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   719
                ((adj == #fit) or:[adj == #fitBig]) ifTrue:[
4124
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   720
                    doFit := true
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   721
                ].
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   722
            ] ifFalse:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   723
                ((imgWidth < innerWidth)
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   724
                or:[imgHeight < innerHeight]) ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   725
                    ((adj == #fit) or:[adj == #fitSmall]) ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   726
                        doFit := true
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   727
                    ].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   728
                ]
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   729
            ].
4124
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   730
        ].
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   731
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   732
        doFit ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   733
            magnifiedImage := image magnifiedPreservingRatioTo:(innerWidth @ innerHeight) smooth:false "smooth".
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   734
            magnificationFactor := magnifiedImage width / imgWidth.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   735
        ] ifFalse:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   736
            (magnificationFactor notNil and:[magnificationFactor ~= 1]) ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   737
                magnifiedImage := image magnifiedBy:magnificationFactor smooth:false "smooth".
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   738
            ] ifFalse:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   739
                magnifiedImage := image.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   740
            ].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   741
        ].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   742
    
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   743
        (magnifiedImage width == 0 or:[magnifiedImage height == 0]) ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   744
            magnifiedImage := nil.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   745
        ].    
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   746
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   747
        smooth ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   748
            smoothMagnifiedImage := nil.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   749
        ] ifFalse:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   750
            smoothMagnifiedImage := magnifiedImage.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   751
        ].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   752
        
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   753
        self contentsChanged.
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   754
    ].
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   755
    
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   756
    smooth ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   757
        magnifiedImage extent = image extent ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   758
            smoothMagnifiedImage := magnifiedImage
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   759
        ] ifFalse:[    
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   760
            smoothMagnifiedImage := nil.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   761
            
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   762
            self synchronized:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   763
                smoothingProcess notNil ifTrue:[
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   764
                    smoothingProcess terminate.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   765
                    smoothMagnifiedImage := nil.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   766
                ].
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   767
                smoothingProcess := 
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   768
                    [
5615
38692913900c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5614
diff changeset
   769
                        |i|
38692913900c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5614
diff changeset
   770
                        
38692913900c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5614
diff changeset
   771
                        (i := magnifiedImage) notNil ifTrue:[
38692913900c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5614
diff changeset
   772
                            smoothMagnifiedImage := image magnifiedTo:(i extent) smooth:true.
38692913900c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5614
diff changeset
   773
                            self invalidate.
38692913900c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5614
diff changeset
   774
                        ]
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   775
                    ] fork.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   776
            ].        
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   777
        ].    
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   778
    ].
4124
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   779
5596
0ec4341756f5 #BUGFIX by Maren
matilk
parents: 5595
diff changeset
   780
    "Modified: / 06-09-2017 / 12:52:19 / Maren"
5615
38692913900c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5614
diff changeset
   781
    "Modified: / 04-10-2017 / 16:43:44 / cg"
5778
50aff5f8d07f #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5777
diff changeset
   782
    "Modified: / 28-05-2018 / 14:20:59 / Claus Gittinger"
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   783
!
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   784
210
1a3b06d71a03 faster redraw; care for margins
Claus Gittinger <cg@exept.de>
parents: 207
diff changeset
   785
redrawX:x y:y width:w height:h
5227
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   786
    |xI yI depth shownImage imgWidth imgHeight right bott "rectRight rectBelow"|
11
793044d4bc90 *** empty log message ***
claus
parents: 9
diff changeset
   787
5741
75e825820538 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5721
diff changeset
   788
    self generateMagnifiedImage.
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   789
5741
75e825820538 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5721
diff changeset
   790
    shownImage := smoothMagnifiedImage ? magnifiedImage ? image.
75e825820538 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5721
diff changeset
   791
    shownImage notNil ifTrue:[
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   792
        imgWidth := shownImage width.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   793
        imgHeight := shownImage height.
635
915077fd17ab checkin from browser
Claus Gittinger <cg@exept.de>
parents: 599
diff changeset
   794
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   795
        adjust == #center ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   796
            xI := (width - (margin * 2) - imgWidth) // 2.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   797
            yI := (height - (margin * 2) - imgHeight) // 2.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   798
        ] ifFalse:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   799
            xI := yI := margin
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   800
        ].
414
0347d494cd61 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   801
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   802
        ((depth := shownImage depth) == 1) ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   803
            self paint:(shownImage colorFromValue:1)
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   804
                    on:(shownImage colorFromValue:0).
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   805
        ].
1071
981c97fe54de generate device image before clearing in redraw
Claus Gittinger <cg@exept.de>
parents: 677
diff changeset
   806
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   807
        tileMode == true ifTrue:[
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   808
            (tileOffset y > 0 and:[tileOffset x > 0]) ifTrue:[
5022
c2e58c679b8e #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
   809
                (false "depth ~~ 1"
c2e58c679b8e #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
   810
                or:[shownImage mask notNil]) ifTrue:[
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   811
                    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
   812
                    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
   813
                        0 to:x+w by:tileOffset x do:[:oX |
5530
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   814
                            gc displayForm:image x:oX y:oY
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   815
                        ]
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   816
                    ].
5022
c2e58c679b8e #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
   817
                ] ifFalse:[
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   818
                    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
   819
                        0 to:x+w by:tileOffset x do:[:oX |
5530
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   820
                            gc displayOpaqueForm:image x:oX y:oY
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   821
                        ]
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   822
                    ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   823
                ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   824
            ]
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   825
        ] ifFalse:[
5227
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   826
            "/rectRight := (shownImage width @ 0) corner:(width @ shownImage height).
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   827
            "/rectBelow := 0 @ (shownImage height) corner:(shownImage height @ height).
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   828
            "/(rectRight width > 0 and:[rectRight height > 0]) ifTrue:[ self clearRectangle:rectRight ].
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   829
            "/(rectBelow width > 0 and:[rectBelow height > 0]) ifTrue:[ self clearRectangle:rectBelow ].
14206c682961 #OTHER by mawalch
mawalch
parents: 5226
diff changeset
   830
3726
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   831
            xI > (x+w) ifTrue:[^ self]. "/ no need to draw
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   832
            yI > (y+h) ifTrue:[^ self]. "/ no need to draw
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   833
            (xI+imgWidth) < x ifTrue:[^ self]. "/ no need to draw
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   834
            (yI+imgHeight) < y ifTrue:[^ self]. "/ no need to draw
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   835
5022
c2e58c679b8e #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
   836
            (false "depth ~~ 1"
3726
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   837
            or:[shownImage mask notNil]) ifTrue:[
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   838
                self clearRectangleX:x y:y width:w height:h.
3726
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   839
                shownImage displayOn:self x:xI y:yI.
5226
24916b8eff22 #TUNING by mawalch
mawalch
parents: 5022
diff changeset
   840
                "/ self displayForm:shownImage x:xI y:yI
3726
1ef0073283b1 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 3711
diff changeset
   841
            ] ifFalse:[
5699
22dc6462ae23 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5693
diff changeset
   842
                (shownImage depth == 32 and:[ shownImage hasAlphaChannel ]) ifTrue:[
22dc6462ae23 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5693
diff changeset
   843
                    "/ now, we support at least some 32rgba images...
5530
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   844
                    true "device supportsAlphaChannel" ifTrue:[
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   845
                        self clearRectangleX:x y:y width:w height:h.
5699
22dc6462ae23 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5693
diff changeset
   846
                        self displayForm:shownImage x:xI y:yI
5530
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   847
                    ] ifFalse:[
5699
22dc6462ae23 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5693
diff changeset
   848
                        "/ hack: currently 32bit+alpha is not supported by Displays.
22dc6462ae23 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5693
diff changeset
   849
                        "/ make it a masked d24 image and draw that.
22dc6462ae23 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5693
diff changeset
   850
5530
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   851
                        |d24Image|
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   852
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   853
                        d24Image := Depth24Image fromImage:shownImage.
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   854
                        d24Image mask:(ImageMask fromAlphaInImage:shownImage).
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   855
                        self clearRectangleX:x y:y width:w height:h.
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   856
                        d24Image displayOn:self x:xI y:yI.
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   857
                    ]
5529
4eee15e7acbe #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5507
diff changeset
   858
                ] ifFalse:[    
5530
6f430f6d0033 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 5529
diff changeset
   859
                    gc displayOpaqueForm:shownImage x:xI y:yI
5529
4eee15e7acbe #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5507
diff changeset
   860
                ].
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   861
            ].
430
574a94732ece checkin from browser
Claus Gittinger <cg@exept.de>
parents: 414
diff changeset
   862
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   863
            "/ right of image ?
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   864
            right := x + w - 1.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   865
            right > (xI + imgWidth) ifTrue:[
5022
c2e58c679b8e #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
   866
                self clearRectangleX:(xI + imgWidth) y:y
5595
7a58ff8c13f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
   867
                     width:(right - imgWidth - xI) height:h
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   868
            ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   869
            "/ below of image ?
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   870
            bott := y + h - 1.
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   871
            bott > (yI + imgHeight) ifTrue:[
5022
c2e58c679b8e #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 4966
diff changeset
   872
                self clearRectangleX:margin y:(yI + imgHeight)
5595
7a58ff8c13f1 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5556
diff changeset
   873
                     width:w height:(bott - imgHeight - yI)
3659
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   874
            ].
53ec00df6b6c care for zero-sized image when tiling
Claus Gittinger <cg@exept.de>
parents: 3618
diff changeset
   875
        ].
5268
b490144a4971 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5227
diff changeset
   876
    ] ifFalse:[
b490144a4971 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 5227
diff changeset
   877
        self clearRectangleX:x y:y width:w height:h.
5529
4eee15e7acbe #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5507
diff changeset
   878
    ].
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   879
5529
4eee15e7acbe #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5507
diff changeset
   880
    "Created: / 11-07-1996 / 21:02:12 / cg"
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   881
    "Modified: / 28-09-2017 / 18:19:01 / cg"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   882
! !
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
   883
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   884
!ImageView methodsFor:'event handling'!
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   885
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   886
buttonMotion:state x:x y:y
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   887
    |delta mousePoint lastPoint|
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   888
5616
4ff2c28c261c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5615
diff changeset
   889
    (state ~~ 0 and:[(lastPoint := lastMousePoint value) notNil]) ifTrue:[
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   890
        mousePoint := (x@y).
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   891
        delta := mousePoint - lastPoint.
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   892
        delta ~= (0@0) ifTrue:[
5616
4ff2c28c261c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5615
diff changeset
   893
            "/ lastMousePoint value:mousePoint.
4ff2c28c261c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5615
diff changeset
   894
            self scrollTo:(self viewOrigin - delta) "/ waitForDrawingFinished:true.
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   895
        ]
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   896
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   897
        super buttonMotion:state x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   898
    ]
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   899
5616
4ff2c28c261c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5615
diff changeset
   900
    "Modified: / 05-10-2017 / 13:54:48 / cg"
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   901
!
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   902
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   903
buttonPress:button x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   904
    button == 1 ifTrue:[
4124
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   905
        "self cursor:(Cursor handGrab). "
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   906
        lastMousePoint value:( x@y ).
5616
4ff2c28c261c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5615
diff changeset
   907
        "/ self sensor compressMotionEvents:true.
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   908
    ].
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   909
    super buttonPress:button x:x y:y
4124
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   910
5616
4ff2c28c261c #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5615
diff changeset
   911
    "Modified: / 05-10-2017 / 13:56:06 / cg"
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   912
!
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   913
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   914
buttonRelease:button x:x y:y
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   915
    button == 1 ifTrue:[
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   916
        lastMousePoint value: nil
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   917
    ].
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   918
    super buttonRelease:button x:x y:y
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   919
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   920
    "Modified: / 25-02-2017 / 22:35:20 / cg"
3618
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   921
!
Claus Gittinger <cg@exept.de>
parents: 3408
diff changeset
   922
4124
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   923
mouseWheelZoom:amount
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   924
    "CTRL-wheel action"
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   925
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   926
    |mul|
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   927
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   928
    amount > 0 ifTrue:[
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   929
        mul := 1.2.
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   930
    ] ifFalse:[
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   931
        mul := 0.8.
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   932
    ].
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   933
    self magnificationFactor:((magnificationFactor ? 1) * mul).
4124
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   934
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   935
    "Created: / 06-05-2012 / 12:18:06 / cg"
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   936
!
bac298acc241 class definition
Claus Gittinger <cg@exept.de>
parents: 4066
diff changeset
   937
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   938
sizeChanged:how
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   939
    (#(fit fitBig fitSmall smoothFit smoothFitBig smoothFitSmall) includes:adjust) ifTrue:[
2911
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   940
        magnifiedImage notNil ifTrue:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   941
            DoNotMagnifyQuery query ifFalse:[
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   942
                self pushEvent:#updateImageAfterSizeChange.
2911
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   943
            ]
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   944
        ].
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   945
    ] ifFalse:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   946
        adjust == #center ifTrue:[
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   947
            self clear.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   948
            self invalidate.
b350e90e9a5b avoid flickern when resizing
Claus Gittinger <cg@exept.de>
parents: 2786
diff changeset
   949
        ].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   950
    ].
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   951
    super sizeChanged:how
5597
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   952
fd48983043d6 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5596
diff changeset
   953
    "Modified: / 10-09-2017 / 17:11:08 / cg"
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   954
!
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   955
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   956
updateImageAfterSizeChange
5399
0dab5e63d3d9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5398
diff changeset
   957
    |oldMagnifiedImage|
0dab5e63d3d9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5398
diff changeset
   958
    
0dab5e63d3d9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5398
diff changeset
   959
    oldMagnifiedImage := magnifiedImage.
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   960
    smoothMagnifiedImage := magnifiedImage := nil.
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   961
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
   962
    self generateMagnifiedImage.
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   963
5400
db097f6162be #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
   964
    (oldMagnifiedImage isNil
db097f6162be #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
   965
      or:[ magnifiedImage isNil
db097f6162be #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
   966
      or:[ oldMagnifiedImage extent ~= magnifiedImage extent ]]
db097f6162be #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
   967
    ) ifTrue:[
db097f6162be #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5399
diff changeset
   968
        "/ self clear.
5399
0dab5e63d3d9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5398
diff changeset
   969
        self invalidate.
0dab5e63d3d9 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5398
diff changeset
   970
    ].
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   971
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   972
    "Modified (format): / 28-09-2017 / 18:20:32 / cg"
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   973
! !
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
   974
2501
832cbac295b8 method category rename
Claus Gittinger <cg@exept.de>
parents: 2404
diff changeset
   975
!ImageView methodsFor:'initialization & release'!
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   976
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   977
destroy
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   978
    magnifiedImage := smoothMagnifiedImage := nil.
5404
c327195bfbb4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5403
diff changeset
   979
    "/ image := nil.
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   980
    super destroy.
5610
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   981
72882e1d2bee #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5599
diff changeset
   982
    "Modified: / 28-09-2017 / 18:20:44 / cg"
5503
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   983
!
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   984
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   985
initialize
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   986
    super initialize.
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   987
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   988
    lastMousePoint := nil asValue.
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   989
5cbf5c6569c4 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5488
diff changeset
   990
    "Created: / 25-02-2017 / 22:33:27 / cg"
1327
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   991
! !
ab99aad206dc category change
Claus Gittinger <cg@exept.de>
parents: 1135
diff changeset
   992
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   993
!ImageView methodsFor:'menu'!
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
   994
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
   995
editImage
5488
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   996
    |img|
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   997
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   998
    img := self image.
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
   999
    imageEditAction notNil ifTrue:[
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
  1000
        imageEditAction value:img
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
  1001
    ] ifFalse:[    
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
  1002
        ImageEditor openOnImage:img.
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
  1003
    ].
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1004
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1005
    "Created: / 16-02-2017 / 19:01:41 / cg"
5488
f0b541c4ec2a #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5487
diff changeset
  1006
    "Modified: / 19-02-2017 / 23:01:14 / cg"
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1007
!
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1008
5760
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1009
fitBigMenuItemVisible
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1010
    ^ true
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1011
!
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1012
5599
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1013
magnifyBy:scale
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1014
    self adjustHolder value:#Mag.
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1015
    self adjust:#topLeft.
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1016
    self magnificationFactor:scale.
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1017
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1018
    "Created: / 13-09-2017 / 09:43:11 / cg"
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1019
!
44f47228bec2 #UI_ENHANCEMENT by cg
Claus Gittinger <cg@exept.de>
parents: 5597
diff changeset
  1020
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  1021
middleButtonMenu
4263
aacb0c4d8dc0 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4245
diff changeset
  1022
    menuHolder notNil ifTrue:[^ super middleButtonMenu].
5751
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1023
    ^ [ self class middleButtonMenu ]
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1024
!
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1025
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1026
middleButtonMenuExtraSlice
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1027
    ^ [ self class middleButtonMenuExtraSlice ]
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1028
!
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1029
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1030
saveImageAs
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1031
    |imageFilename|
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1032
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1033
    imageFilename := Dialog
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1034
                        requestFileName:(resources string:'Save Image As')
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1035
                        default:'image.png'
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1036
                        pattern:'*.png'
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1037
                        fromDirectory:Filename currentDirectory.
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1038
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1039
    imageFilename notNil ifTrue:[
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1040
        self saveImageAs:imageFilename
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1041
    ].
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1042
!
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1043
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1044
saveImageAs:filename
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1045
    PNGReader save:image onFile:filename
5760
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1046
!
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1047
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1048
smoothFitBigMenuItemVisible
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1049
    ^ true
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1050
!
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1051
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1052
smoothingMenuItemVisible
d689b29b69cc #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5751
diff changeset
  1053
    ^ true
4245
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  1054
! !
26b64657e15c class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4192
diff changeset
  1055
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
  1056
!ImageView methodsFor:'queries'!
24
6704fad5eb7d *** empty log message ***
claus
parents: 11
diff changeset
  1057
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
  1058
heightOfContents
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
  1059
    "return the image's height - scrollbar needs this info"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1060
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
  1061
    image isNil ifTrue:[^ 0].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
  1062
    ^ (magnifiedImage ? image) height
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1063
!
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
  1064
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1065
selfIsNotImageEditor
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1066
    "for the menu; to hide edit item"
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1067
5751
1382b5b74d06 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5741
diff changeset
  1068
    ^ true
5482
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1069
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1070
    "Created: / 16-02-2017 / 19:00:59 / cg"
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1071
!
3fe62d3049a6 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5479
diff changeset
  1072
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1073
widthOfContents
5387
278d666f9267 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5268
diff changeset
  1074
    "return the image's width - scrollbar needs this info"
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1075
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1076
    image isNil ifTrue:[^ 0].
2158
c4389029e303 magnification
Claus Gittinger <cg@exept.de>
parents: 2099
diff changeset
  1077
    ^ (magnifiedImage ? image) width
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
  1078
! !
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
  1079
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1080
!ImageView methodsFor:'scrolling'!
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1081
5555
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1082
scrollToMakeRectangleVisible:aRectangle
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1083
    "try to arrange for aRectangle to be visible (at the center, if possible)"
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1084
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1085
    self scrollToMakeVisible:(aRectangle center).
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1086
    self scrollToMakeVisible:(aRectangle corner).
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1087
    self scrollToMakeVisible:(aRectangle origin).
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1088
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1089
    "
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1090
     |v|
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1091
     v := ImageView new image:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif').
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1092
     v openAndWait.
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1093
     v inspect.
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1094
     v scrollToMakeRectangleVisible:((300@100) corner:(320@120)).
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1095
    "
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1096
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1097
    "Created: / 20-07-2017 / 13:45:29 / cg"
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1098
!
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1099
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1100
scrollToMakeVisible:aPoint
5555
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1101
    "try to arrange for aPoint (in logical image coordinates)
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1102
     to be visible (at the center, if possible)"
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1103
5693
3f150dcec4f2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5688
diff changeset
  1104
    |mag magPos imgExtent newOffset|
3f150dcec4f2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5688
diff changeset
  1105
3f150dcec4f2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5688
diff changeset
  1106
    imgExtent := 0@0.
5721
601f7686ccdb #BUGFIX by mawalch
mawalch
parents: 5699
diff changeset
  1107
    image notNil ifTrue:[
5693
3f150dcec4f2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5688
diff changeset
  1108
        imgExtent := image extent.
3f150dcec4f2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5688
diff changeset
  1109
    ].
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1110
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1111
    mag := self magnification.
5555
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1112
    magPos := aPoint * mag.
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1113
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1114
    ((self bounds + self viewOrigin) containsPoint:magPos) ifFalse:[
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1115
        newOffset := magPos - (self extent / 2).
ce5b5e4a359b #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5534
diff changeset
  1116
        newOffset := newOffset max:(0@0).
5693
3f150dcec4f2 #BUGFIX by cg
Claus Gittinger <cg@exept.de>
parents: 5688
diff changeset
  1117
        newOffset := newOffset min:((imgExtent * mag) - (self extent / 2)).
5721
601f7686ccdb #BUGFIX by mawalch
mawalch
parents: 5699
diff changeset
  1118
        newOffset := newOffset rounded.
5556
10161d3f6046 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5555
diff changeset
  1119
        self scrollTo:newOffset waitForDrawingFinished:true.
5507
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1120
    ].
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1121
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1122
    "
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1123
     |v|
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1124
     v := ImageView new image:(Image fromFile:'../../goodies/bitmaps/gifImages/garfield.gif').
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1125
     v openAndWait.
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1126
     v inspect.
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1127
     v scrollToMakeVisible:(300@100).
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1128
    "
a5c432b78ff6 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 5503
diff changeset
  1129
5556
10161d3f6046 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 5555
diff changeset
  1130
    "Modified: / 20-07-2017 / 14:37:11 / cg"
3408
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1131
! !
2ca9dff3fdaf +scrollToMakeVisible
Claus Gittinger <cg@exept.de>
parents: 2911
diff changeset
  1132
257
0acd4525d53e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 239
diff changeset
  1133
!ImageView class methodsFor:'documentation'!
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
  1134
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 90
diff changeset
  1135
version
4912
6630a4464c2f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4732
diff changeset
  1136
    ^ '$Header$'
3884
1da7ee7bcd15 changed: #destroy
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
  1137
!
1da7ee7bcd15 changed: #destroy
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
  1138
1da7ee7bcd15 changed: #destroy
Claus Gittinger <cg@exept.de>
parents: 3733
diff changeset
  1139
version_CVS
4912
6630a4464c2f #FEATURE
Claus Gittinger <cg@exept.de>
parents: 4732
diff changeset
  1140
    ^ '$Header$'
1
c6ca7bfedf31 Initial revision
claus
parents:
diff changeset
  1141
! !
2358
68180cd61e53 care for nil image
Claus Gittinger <cg@exept.de>
parents: 2164
diff changeset
  1142
4192
17828ed3f930 class: ImageView
Claus Gittinger <cg@exept.de>
parents: 4124
diff changeset
  1143
2160
4c15f05f8bc6 somewhat complicated: under win32 style, a magnify leads to scrollbars
Claus Gittinger <cg@exept.de>
parents: 2158
diff changeset
  1144
ImageView initialize!