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