ImageInspectorView.st
branchjv
changeset 15566 184cea584be5
parent 13330 02d6c2d848a0
parent 14795 91e2bdc0c8cf
equal deleted inserted replaced
13752:25c2a13f00c5 15566:184cea584be5
    42 ! !
    42 ! !
    43 
    43 
    44 !ImageInspectorView class methodsFor:'defaults'!
    44 !ImageInspectorView class methodsFor:'defaults'!
    45 
    45 
    46 defaultTopViewExtent
    46 defaultTopViewExtent
    47     ^ LastExtent ? super defaultExtent
    47     |def|
       
    48 
       
    49     def := LastExtent ? self defaultExtent.
       
    50     ^ def min:(Screen current usableExtent)
    48 
    51 
    49     "Created: / 23-10-2007 / 18:58:18 / cg"
    52     "Created: / 23-10-2007 / 18:58:18 / cg"
    50 !
    53 !
    51 
    54 
    52 rememberLastExtent:anExtent
    55 rememberLastExtent:anExtent
    62      by the MenuEditor of ST/X."
    65      by the MenuEditor of ST/X."
    63 
    66 
    64     "Do not manually edit this!! If it is corrupted,
    67     "Do not manually edit this!! If it is corrupted,
    65      the MenuEditor may not be able to read the specification."
    68      the MenuEditor may not be able to read the specification."
    66 
    69 
       
    70 
    67     "
    71     "
    68      MenuEditor new openOnClass:ImageInspectorView andSelector:#imageMenu
    72      MenuEditor new openOnClass:ImageInspectorView andSelector:#imageMenu
    69      (Menu new fromLiteralArrayEncoding:(ImageInspectorView imageMenu)) startUp
    73      (Menu new fromLiteralArrayEncoding:(ImageInspectorView imageMenu)) startUp
    70     "
    74     "
    71 
    75 
    73 
    77 
    74     ^ 
    78     ^ 
    75      #(Menu
    79      #(Menu
    76         (
    80         (
    77          (MenuItem
    81          (MenuItem
       
    82             enabled: hasImage
    78             label: 'Edit'
    83             label: 'Edit'
    79             itemValue: menuEdit
    84             itemValue: menuEdit
    80             translateLabel: true
    85           )
    81           )
    86          (MenuItem
    82          (MenuItem
    87             enabled: filenameOfImageKnown
    83             label: 'File Browser'
    88             label: 'File Browser'
    84             itemValue: menuFileBrowser
    89             itemValue: menuFileBrowser
    85             translateLabel: true
       
    86             enabled: filenameOfImageKnown
       
    87           )
    90           )
    88          (MenuItem
    91          (MenuItem
    89             label: '-'
    92             label: '-'
    90           )
    93           )
    91          (MenuItem
    94          (MenuItem
    92             label: 'Magnification...'
    95             label: 'Magnification...'
    93             itemValue: menuMagnification
    96             itemValue: menuMagnification
    94             translateLabel: true
       
    95           )
    97           )
    96          (MenuItem
    98          (MenuItem
    97             label: 'Background'
    99             label: 'Background'
    98             translateLabel: true
       
    99             submenu: 
   100             submenu: 
   100            (Menu
   101            (Menu
   101               (
   102               (
   102                (MenuItem
   103                (MenuItem
   103                   label: 'White'
   104                   label: 'White'
   104                   itemValue: menuSetBackgroundColor:
   105                   itemValue: menuSetBackgroundColor:
   105                   translateLabel: true
       
   106                   argument: white
   106                   argument: white
   107                 )
   107                 )
   108                (MenuItem
   108                (MenuItem
   109                   label: 'Grey'
   109                   label: 'Grey'
   110                   itemValue: menuSetBackgroundColor:
   110                   itemValue: menuSetBackgroundColor:
   111                   translateLabel: true
       
   112                   argument: grey
   111                   argument: grey
   113                 )
   112                 )
   114                (MenuItem
   113                (MenuItem
   115                   label: 'Black'
   114                   label: 'Black'
   116                   itemValue: menuSetBackgroundColor:
   115                   itemValue: menuSetBackgroundColor:
   117                   translateLabel: true
       
   118                   argument: black
   116                   argument: black
   119                 )
   117                 )
   120                (MenuItem
   118                (MenuItem
   121                   label: '-'
   119                   label: '-'
   122                 )
   120                 )
   123                (MenuItem
   121                (MenuItem
   124                   label: 'Red'
   122                   label: 'Red'
   125                   itemValue: menuSetBackgroundColor:
   123                   itemValue: menuSetBackgroundColor:
   126                   translateLabel: true
       
   127                   argument: red
   124                   argument: red
   128                 )
   125                 )
   129                (MenuItem
   126                (MenuItem
   130                   label: 'Green'
   127                   label: 'Green'
   131                   itemValue: menuSetBackgroundColor:
   128                   itemValue: menuSetBackgroundColor:
   132                   translateLabel: true
       
   133                   argument: green
   129                   argument: green
   134                 )
   130                 )
   135                (MenuItem
   131                (MenuItem
   136                   label: 'Blue'
   132                   label: 'Blue'
   137                   itemValue: menuSetBackgroundColor:
   133                   itemValue: menuSetBackgroundColor:
   138                   translateLabel: true
       
   139                   argument: blue
   134                   argument: blue
   140                 )
   135                 )
   141                )
   136                )
   142               nil
   137               nil
   143               nil
   138               nil
   152 !ImageInspectorView methodsFor:'accessing'!
   147 !ImageInspectorView methodsFor:'accessing'!
   153 
   148 
   154 inspect:anObject
   149 inspect:anObject
   155     "set the object to be inspected"
   150     "set the object to be inspected"
   156 
   151 
       
   152     |scrollToBottom prevViewOrigin prevImageSize|
       
   153 
       
   154     prevViewOrigin := imageView viewOrigin.
       
   155     imageView image notNil ifTrue:[
       
   156         prevImageSize := imageView image extent.
       
   157     ].
   157     super inspect:anObject.
   158     super inspect:anObject.
   158     imageView image:anObject.
   159 "/    imageView image:anObject.
       
   160 
       
   161     scrollToBottom := false.
       
   162 
       
   163 "/    scrollToBottom :=
       
   164 "/        anObject notNil
       
   165 "/        and:[imageView image notNil 
       
   166 "/        and:[ imageView viewOrigin y + imageView image height >= imageView height ]].
       
   167 
       
   168     imageView image:anObject scroll:scrollToBottom not invalidate:false.
       
   169     scrollToBottom ifTrue:[
       
   170         imageView 
       
   171             scrollTo:(0 @ ((anObject height - imageView height) max:0))
       
   172             redraw:false.
       
   173     ].
       
   174     imageView invalidate.
   159 
   175 
   160     "
   176     "
   161      ImageInspectorView inspect:(Image fromScreen:(0@0 corner:800@800))
   177      ImageInspectorView inspect:(Image fromScreen:(0@0 corner:800@800))
   162     "
   178     "
   163 ! !
   179 ! !
   228 menuEdit
   244 menuEdit
   229     inspectedObject edit
   245     inspectedObject edit
   230 !
   246 !
   231 
   247 
   232 menuFileBrowser
   248 menuFileBrowser
   233     UserPreferences current fileBrowserClass
   249     UserPreferences fileBrowserClass
   234         openOn:inspectedObject fileName
   250         openOn:inspectedObject fileName
   235 !
   251 !
   236 
   252 
   237 menuMagnification
   253 menuMagnification
   238     |mag|
   254     |mag|
   255 ! !
   271 ! !
   256 
   272 
   257 !ImageInspectorView methodsFor:'queries'!
   273 !ImageInspectorView methodsFor:'queries'!
   258 
   274 
   259 filenameOfImageKnown
   275 filenameOfImageKnown
   260     ^ [ inspectedObject fileName notNil ]
   276     ^ [ inspectedObject isImage and:[inspectedObject fileName notNil] ]
       
   277 !
       
   278 
       
   279 hasImage
       
   280     "do we inspect an image and not a Form?"
       
   281 
       
   282     ^ inspectedObject isImage
   261 !
   283 !
   262 
   284 
   263 labelFor:anObject
   285 labelFor:anObject
   264     |l fn|
   286     |l fn|
   265 
   287 
   266     l := super labelFor:anObject.
   288     l := super labelFor:anObject.
   267     (anObject notNil and:[(fn := anObject fileName) notNil]) ifTrue:[
   289     (anObject isImage and:[(fn := anObject fileName) notNil]) ifTrue:[
   268         l := l , ' (''' , fn asFilename baseName, ''')'
   290         l := l , ' (''' , fn asFilename baseName, ''')'
   269     ].
   291     ].
   270     ^ l
   292     ^ l
   271 
   293 
   272     "Modified: / 25-07-2012 / 12:53:13 / cg"
   294     "Modified: / 25-07-2012 / 12:53:13 / cg"
   273 ! !
   295 ! !
   274 
   296 
   275 !ImageInspectorView class methodsFor:'documentation'!
   297 !ImageInspectorView class methodsFor:'documentation'!
   276 
   298 
   277 version
   299 version
   278     ^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.28 2013-08-06 08:38:10 cg Exp $'
   300     ^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.36 2014-10-23 11:15:46 cg Exp $'
   279 !
   301 !
   280 
   302 
   281 version_CVS
   303 version_CVS
   282     ^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.28 2013-08-06 08:38:10 cg Exp $'
   304     ^ '$Header: /cvs/stx/stx/libtool/ImageInspectorView.st,v 1.36 2014-10-23 11:15:46 cg Exp $'
   283 !
   305 ! !
   284 
   306 
   285 version_HG
       
   286 
       
   287     ^ '$Changeset: <not expanded> $'
       
   288 !
       
   289 
       
   290 version_SVN
       
   291     ^ '$Id: ImageInspectorView.st 8026 2012-07-26 16:09:41Z vranyj1 $'
       
   292 ! !
       
   293