*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Wed, 03 Feb 2010 11:02:07 +0100
changeset 27445bee95e91ffd
parent 2743 a3413ff28529
child 2745 0c6f4a677a08
*** empty log message ***
Tools__ViewTreeApplication.st
     1.1 --- a/Tools__ViewTreeApplication.st	Mon Feb 01 13:19:43 2010 +0100
     1.2 +++ b/Tools__ViewTreeApplication.st	Wed Feb 03 11:02:07 2010 +0100
     1.3 @@ -2,22 +2,46 @@
     1.4  
     1.5  "{ NameSpace: Tools }"
     1.6  
     1.7 -ApplicationModel subclass:#ViewTreeApplication
     1.8 +ToolApplicationModel subclass:#ViewTreeInspectorApplication
     1.9  	instanceVariableNames:'model treeView hasSingleSelectionHolder clickedItem clickedPoint
    1.10  		motionAction process followFocusChannel showNamesHolder'
    1.11  	classVariableNames:''
    1.12  	poolDictionaries:''
    1.13 -	category:'A-Views-Support'
    1.14 +	category:'Interface-Smalltalk'
    1.15  !
    1.16  
    1.17  Object subclass:#MenuDesc
    1.18  	instanceVariableNames:'title value action'
    1.19  	classVariableNames:''
    1.20  	poolDictionaries:''
    1.21 -	privateIn:ViewTreeApplication
    1.22 +	privateIn:ViewTreeInspectorApplication
    1.23  !
    1.24  
    1.25 -!ViewTreeApplication class methodsFor:'documentation'!
    1.26 +HierarchicalItem subclass:#ViewTreeItem
    1.27 +	instanceVariableNames:'widget isDrawnShown exists xOffsetAdditionalName'
    1.28 +	classVariableNames:'HandleExtent'
    1.29 +	poolDictionaries:''
    1.30 +	privateIn:ViewTreeInspectorApplication
    1.31 +!
    1.32 +
    1.33 +ValueModel subclass:#ViewTreeModel
    1.34 +	instanceVariableNames:'lockSema selectedSuperItems selection hiddenLevel listOfItems
    1.35 +		inputEventAction mappedViewAction beforeSelectionChangedAction
    1.36 +		icons timedUpdateTask selectOnClickHolder testModeChannel
    1.37 +		hasTargetWidgetChannel'
    1.38 +	classVariableNames:''
    1.39 +	poolDictionaries:''
    1.40 +	privateIn:ViewTreeInspectorApplication
    1.41 +!
    1.42 +
    1.43 +HierarchicalList subclass:#ItemList
    1.44 +	instanceVariableNames:'treeModel eventHook eventHookInitialized showWidgetNames'
    1.45 +	classVariableNames:''
    1.46 +	poolDictionaries:''
    1.47 +	privateIn:ViewTreeInspectorApplication::ViewTreeModel
    1.48 +!
    1.49 +
    1.50 +!ViewTreeInspectorApplication class methodsFor:'documentation'!
    1.51  
    1.52  documentation
    1.53  "
    1.54 @@ -45,7 +69,7 @@
    1.55  "
    1.56  ! !
    1.57  
    1.58 -!ViewTreeApplication class methodsFor:'initialization'!
    1.59 +!ViewTreeInspectorApplication class methodsFor:'initialization'!
    1.60  
    1.61  initialize
    1.62      "add myself to the launcher menu
    1.63 @@ -54,17 +78,19 @@
    1.64  !
    1.65  
    1.66  installInLauncher
    1.67 -    "add myself to the launcher menu
    1.68 -    "
    1.69 +    "add myself to the launcher menu"
    1.70 +
    1.71      |menuItem icon|
    1.72  
    1.73      NewLauncher isNil ifTrue:[^ self].
    1.74 +    "/ cg - disabled. the icon is too ugly.
    1.75 +    ^ self.
    1.76  
    1.77      icon := ToolbarIconLibrary inspectLocals20x20Icon magnifiedTo:28@28.
    1.78  
    1.79      menuItem := MenuItem new 
    1.80 -                    label: 'View Inspector';
    1.81 -                    value: [ ViewTreeApplication open];
    1.82 +                    label: 'View Tree Inspector';
    1.83 +                    value: [ ViewTreeInspectorApplication open];
    1.84                      isButton: true;
    1.85                      icon: icon;
    1.86                      nameKey: #viewInspect.
    1.87 @@ -109,7 +135,35 @@
    1.88      super unload.
    1.89  ! !
    1.90  
    1.91 -!ViewTreeApplication class methodsFor:'interface specs'!
    1.92 +!ViewTreeInspectorApplication class methodsFor:'image specs'!
    1.93 +
    1.94 +pickWindowIcon
    1.95 +    "This resource specification was automatically generated
    1.96 +     by the ImageEditor of ST/X."
    1.97 +
    1.98 +    "Do not manually edit this!! If it is corrupted,
    1.99 +     the ImageEditor may not be able to read the specification."
   1.100 +
   1.101 +    "
   1.102 +     self pickWindowIcon inspect
   1.103 +     ImageEditor openOnClass:self andSelector:#pickWindowIcon
   1.104 +     Icon flushCachedIcons
   1.105 +    "
   1.106 +
   1.107 +    <resource: #image>
   1.108 +
   1.109 +    ^Icon
   1.110 +        constantNamed:'Tools::ViewTreeInspectorApplication class pickWindowIcon'
   1.111 +        ifAbsentPut:[(Depth8Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
   1.112 +,;N3,;N3,;N3,;N3,;N3,;N3,;N3,3H<P38;M3P,H2@^GA(VEQHQCP0KA D<[&-%XU=WST%BN#D!!GQ$TD@(IBP\BQF)+Z6E_U4-FPCX+G1,WEA@JBP$HAT23
   1.113 +,;N3,;N3,;N3,;N$():Z&IRR&1!!^,;N3,;N3,;N3,;N$)JJ^&)"T$),0W[N3,;N3,;N3,;N3,:R"'')*X%IJWK523,;N3,;N3,0@@@KN3)JJ^&)"T$"5Z,;N3
   1.114 +,;N3@@B3-KL@@JJ^&)"T$)D*V[N3,;N3@KN3-KR4)JH@&)"T$)*MJE"3,;N3,0B3)JJ4&*R"@I*X%IJZ#RYV,;N3,0B3@JR"-JR"-I(@%IJV%H %U[N3,;L@
   1.115 +-@B4-KR4-KR4@IRR%IJEIER3,;N3@KL@)JJ4():4&@BO#9RR!!RIS,;N3,;L@,:R"-JJ^& BT#8>O#8H"T+N3,;N3@KN$@@@@'')(@%H>O#(>AH%F3,;N3,;L@
   1.116 +@JR4'' @@%IJO#8>O RIO,;N3,;N3):P@@@BX%IJO#8>O#7<"S*63,;N$():Z&IRR&IRR#8>O#8=>H"&-,;N$():Z&IRR&)"T$(>O#8>O @<)R$!!GQTD?OS$8
   1.117 +MSL.I2H"H"H"H"HO,;N3,;N3,;N3,;N3,;N3,;N3,;N3,0@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; colorMapFromArray:#[0 0 0 0 50 164 0 50 171 0 137 0 0 206 0 1 50 177 2 56 178 3 64 241 3 67 246 3 73 255 4 74 255 5 63 191 7 66 194 10 71 196 10 79 255 12 59 167 12 82 255 14 77 199 18 83 201 19 88 255 21 91 255 23 89 204 27 95 206 28 97 255 29 72 179 30 100 255 32 101 209 36 106 255 36 107 211 39 109 255 41 113 214 45 115 255 45 119 216 48 118 255 50 87 176 50 125 219 51 88 176 51 88 177 52 89 178 52 90 178 53 90 178 53 127 212 54 91 179 54 123 255 54 131 221 55 92 180 55 95 181 56 93 180 56 94 181 57 127 255 57 149 229 58 99 184 58 137 224 61 104 187 63 132 255 63 143 226 64 108 190 66 113 193 66 135 255 67 149 229 68 157 232 69 117 196 71 155 231 72 122 199 72 141 255 75 126 202 75 144 255 75 160 234 77 163 236 78 131 206 80 149 255 81 136 209 84 140 212 84 153 255 87 145 215 88 157 255 91 168 235 93 161 255 94 154 222 96 157 223 96 165 255 97 159 225 98 160 225 98 162 226 99 163 227 100 165 228 101 166 229 101 170 255 102 167 230 103 169 231 104 170 232 104 173 255 105 172 233 105 174 234 106 175 235 109 178 255 112 180 255 117 186 255 119 187 255 122 154 245 125 160 253 125 193 255 126 161 253 126 194 255 127 162 254 130 165 254 132 200 255 132 201 255 133 60 36 135 170 255 139 207 255 140 175 255 144 179 255 149 184 255 153 188 255 157 192 255 162 196 255 166 200 255 170 204 255 174 208 255 174 218 230 177 212 255 181 215 255 185 219 255 188 222 255 191 225 255 212 211 224 218 217 230 219 219 230 220 220 231 222 221 232 223 223 233 225 224 234 225 225 234 226 226 237 227 226 235 227 227 236 227 227 238 228 228 237 229 229 239 231 230 238 231 231 238 231 231 240 232 232 241 233 232 239 233 233 240 234 234 242 235 234 241 236 236 243 237 236 242 237 237 244 238 237 243 238 238 244 239 238 243 239 239 245 240 239 244 241 240 245 241 241 246 241 241 247 242 242 246 242 242 247 243 243 247 243 243 248 244 244 248 244 244 249 245 244 247 246 246 249 246 246 250 247 246 249 247 247 250 248 248 251 249 249 250 249 249 251 250 250 251 250 250 252 251 251 252 251 251 253 253 253 254 254 254 255 255 255 255 0 0 0]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@C????????????????????????????????????????????????????????????????????????????????@@@C') ; yourself); yourself]
   1.118 +! !
   1.119 +
   1.120 +!ViewTreeInspectorApplication class methodsFor:'interface specs'!
   1.121  
   1.122  windowSpec
   1.123      "This resource specification was automatically generated
   1.124 @@ -131,7 +185,7 @@
   1.125          name: windowSpec
   1.126          window: 
   1.127         (WindowSpec
   1.128 -          label: 'ViewTreeInspector'
   1.129 +          label: 'View Tree Inspector'
   1.130            name: 'ViewTreeInspector'
   1.131            min: (Point 10 10)
   1.132            max: (Point 1024 9999)
   1.133 @@ -172,7 +226,7 @@
   1.134        )
   1.135  ! !
   1.136  
   1.137 -!ViewTreeApplication class methodsFor:'menu specs'!
   1.138 +!ViewTreeInspectorApplication class methodsFor:'menu specs'!
   1.139  
   1.140  menu
   1.141      "This resource specification was automatically generated
   1.142 @@ -212,6 +266,51 @@
   1.143                    label: '-'
   1.144                  )
   1.145                 (MenuItem
   1.146 +                  label: 'Settings'
   1.147 +                  translateLabel: true
   1.148 +                  submenu: 
   1.149 +                 (Menu
   1.150 +                    (
   1.151 +                     (MenuItem
   1.152 +                        label: 'Test Mode'
   1.153 +                        translateLabel: true
   1.154 +                        hideMenuOnActivated: false
   1.155 +                        indication: testModeChannel
   1.156 +                      )
   1.157 +                     (MenuItem
   1.158 +                        enabled: testModeChannel
   1.159 +                        label: 'Follow Focus'
   1.160 +                        translateLabel: true
   1.161 +                        hideMenuOnActivated: false
   1.162 +                        indication: followFocusChannel
   1.163 +                      )
   1.164 +                     (MenuItem
   1.165 +                        label: '-'
   1.166 +                      )
   1.167 +                     (MenuItem
   1.168 +                        label: 'Select on Click'
   1.169 +                        translateLabel: true
   1.170 +                        hideMenuOnActivated: false
   1.171 +                        indication: selectOnClickHolder
   1.172 +                      )
   1.173 +                     (MenuItem
   1.174 +                        label: '-'
   1.175 +                      )
   1.176 +                     (MenuItem
   1.177 +                        label: 'Show Name of Widgets'
   1.178 +                        translateLabel: true
   1.179 +                        hideMenuOnActivated: false
   1.180 +                        indication: showNamesHolder
   1.181 +                      )
   1.182 +                     )
   1.183 +                    nil
   1.184 +                    nil
   1.185 +                  )
   1.186 +                )
   1.187 +               (MenuItem
   1.188 +                  label: '-'
   1.189 +                )
   1.190 +               (MenuItem
   1.191                    label: 'Exit'
   1.192                    itemValue: closeRequest
   1.193                    translateLabel: true
   1.194 @@ -222,41 +321,74 @@
   1.195              )
   1.196            )
   1.197           (MenuItem
   1.198 -            label: 'Settings'
   1.199 +            enabled: hasSingleSelectionHolder
   1.200 +            label: 'Selection'
   1.201 +            translateLabel: true
   1.202 +            submenuChannel: middleButtonMenu
   1.203 +          )
   1.204 +         (MenuItem
   1.205 +            label: 'Application'
   1.206              translateLabel: true
   1.207              submenu: 
   1.208             (Menu
   1.209                (
   1.210                 (MenuItem
   1.211 -                  label: 'Test Mode'
   1.212 +                  enabled: hasSingleSelectionHolder
   1.213 +                  label: 'Browse'
   1.214 +                  itemValue: doBrowse:
   1.215                    translateLabel: true
   1.216 -                  hideMenuOnActivated: false
   1.217 -                  indication: testModeChannel
   1.218 +                  argument: application
   1.219                  )
   1.220                 (MenuItem
   1.221 -                  enabled: testModeChannel
   1.222 -                  label: 'Follow Focus'
   1.223 +                  enabled: hasSingleSelectionHolder
   1.224 +                  label: 'Inspect'
   1.225 +                  itemValue: doInspect:
   1.226                    translateLabel: true
   1.227 -                  hideMenuOnActivated: false
   1.228 -                  indication: followFocusChannel
   1.229 +                  argument: application
   1.230                  )
   1.231                 (MenuItem
   1.232                    label: '-'
   1.233                  )
   1.234                 (MenuItem
   1.235 -                  label: 'Select on Click'
   1.236 +                  enabled: hasTargetWidgetChannel
   1.237 +                  label: 'All Applications'
   1.238                    translateLabel: true
   1.239 -                  hideMenuOnActivated: false
   1.240 -                  indication: selectOnClickHolder
   1.241 +                  submenuChannel: submenuApplications:
   1.242 +                )
   1.243 +               )
   1.244 +              nil
   1.245 +              nil
   1.246 +            )
   1.247 +          )
   1.248 +         (MenuItem
   1.249 +            label: 'Widget'
   1.250 +            translateLabel: true
   1.251 +            submenu: 
   1.252 +           (Menu
   1.253 +              (
   1.254 +               (MenuItem
   1.255 +                  enabled: hasSingleSelectionHolder
   1.256 +                  label: 'Browse'
   1.257 +                  itemValue: doBrowse:
   1.258 +                  translateLabel: true
   1.259 +                  argument: view
   1.260 +                )
   1.261 +               (MenuItem
   1.262 +                  enabled: hasSingleSelectionHolder
   1.263 +                  label: 'Inspect'
   1.264 +                  itemValue: doInspect:
   1.265 +                  translateLabel: true
   1.266 +                  argument: view
   1.267                  )
   1.268                 (MenuItem
   1.269                    label: '-'
   1.270                  )
   1.271                 (MenuItem
   1.272 -                  label: 'Show Name of Widgets'
   1.273 +                  enabled: hasTargetWidgetChannel
   1.274 +                  label: 'All Components'
   1.275                    translateLabel: true
   1.276 -                  hideMenuOnActivated: false
   1.277 -                  indication: showNamesHolder
   1.278 +                  startGroup: right
   1.279 +                  submenuChannel: submenuComponents:
   1.280                  )
   1.281                 )
   1.282                nil
   1.283 @@ -264,26 +396,29 @@
   1.284              )
   1.285            )
   1.286           (MenuItem
   1.287 -            label: ''
   1.288 -          )
   1.289 -         (MenuItem
   1.290 -            enabled: hasSingleSelectionHolder
   1.291 -            label: 'Menu'
   1.292 +            label: 'Help'
   1.293              translateLabel: true
   1.294 -            submenuChannel: middleButtonMenu
   1.295 -          )
   1.296 -         (MenuItem
   1.297 -            enabled: hasTargetWidgetChannel
   1.298 -            label: 'Components'
   1.299 -            translateLabel: true
   1.300 -            startGroup: right
   1.301 -            submenuChannel: submenuComponents:
   1.302 -          )
   1.303 -         (MenuItem
   1.304 -            enabled: hasTargetWidgetChannel
   1.305 -            label: 'Applications'
   1.306 -            translateLabel: true
   1.307 -            submenuChannel: submenuApplications:
   1.308 +            startGroup: conditionalRight
   1.309 +            submenu: 
   1.310 +           (Menu
   1.311 +              (
   1.312 +               (MenuItem
   1.313 +                  label: 'Documentation'
   1.314 +                  itemValue: openDocumentation
   1.315 +                  translateLabel: true
   1.316 +                )
   1.317 +               (MenuItem
   1.318 +                  label: '-'
   1.319 +                )
   1.320 +               (MenuItem
   1.321 +                  label: 'About this Application...'
   1.322 +                  itemValue: openAboutThisApplication
   1.323 +                  translateLabel: true
   1.324 +                )
   1.325 +               )
   1.326 +              nil
   1.327 +              nil
   1.328 +            )
   1.329            )
   1.330           )
   1.331          nil
   1.332 @@ -463,47 +598,40 @@
   1.333       #(Menu
   1.334          (
   1.335           (MenuItem
   1.336 +            label: 'Pick a View'
   1.337 +            itemValue: doPickViews
   1.338 +            translateLabel: false
   1.339 +            isButton: true
   1.340 +            hideMenuOnActivated: false
   1.341 +            labelImage: (ResourceRetriever #'Tools::ViewTreeInspectorApplication' pickWindowIcon)
   1.342 +          )
   1.343 +         (MenuItem
   1.344              enabled: hasSingleSelectionHolder
   1.345 -            label: 'Application'
   1.346 +            label: 'Browse Application'
   1.347              itemValue: doBrowse:
   1.348              translateLabel: false
   1.349 +            isButton: true
   1.350 +            hideMenuOnActivated: false
   1.351              labelImage: (ResourceRetriever ToolbarIconLibrary systemBrowser24x24Icon2)
   1.352              argument: application
   1.353            )
   1.354           (MenuItem
   1.355              enabled: hasSingleSelectionHolder
   1.356 -            label: 'Application'
   1.357 +            label: 'Inspect Application'
   1.358              itemValue: doInspect:
   1.359              translateLabel: false
   1.360 -            labelImage: (ResourceRetriever ToolbarIconLibrary inspect22x24Icon 'Application')
   1.361 +            isButton: true
   1.362 +            hideMenuOnActivated: false
   1.363 +            labelImage: (ResourceRetriever ToolbarIconLibrary inspect22x24Icon)
   1.364              argument: application
   1.365            )
   1.366 -         (MenuItem
   1.367 -            label: ''
   1.368 -          )
   1.369 -         (MenuItem
   1.370 -            enabled: hasSingleSelectionHolder
   1.371 -            label: 'Widget'
   1.372 -            itemValue: doBrowse:
   1.373 -            translateLabel: false
   1.374 -            labelImage: (ResourceRetriever ToolbarIconLibrary systemBrowser24x24Icon2)
   1.375 -            argument: view
   1.376 -          )
   1.377 -         (MenuItem
   1.378 -            enabled: hasSingleSelectionHolder
   1.379 -            label: 'Widget'
   1.380 -            itemValue: doInspect:
   1.381 -            translateLabel: true
   1.382 -            labelImage: (ResourceRetriever ToolbarIconLibrary inspect22x24Icon 'Widget')
   1.383 -            argument: view
   1.384 -          )
   1.385           )
   1.386          nil
   1.387          nil
   1.388        )
   1.389  ! !
   1.390  
   1.391 -!ViewTreeApplication methodsFor:'actions'!
   1.392 +!ViewTreeInspectorApplication methodsFor:'actions'!
   1.393  
   1.394  indicatorClicked:anIndex
   1.395      |item sensor|
   1.396 @@ -521,7 +649,7 @@
   1.397      ].
   1.398  ! !
   1.399  
   1.400 -!ViewTreeApplication methodsFor:'aspects'!
   1.401 +!ViewTreeInspectorApplication methodsFor:'aspects'!
   1.402  
   1.403  followFocusChannel
   1.404      "boolean holder, which indicates whether selection changed dependend on the focus view"
   1.405 @@ -576,7 +704,7 @@
   1.406      ^ model testModeChannel
   1.407  ! !
   1.408  
   1.409 -!ViewTreeApplication methodsFor:'change & update'!
   1.410 +!ViewTreeInspectorApplication methodsFor:'change & update'!
   1.411  
   1.412  selectionChanged
   1.413      "called if the selection changed"
   1.414 @@ -625,7 +753,7 @@
   1.415      super update:something with:someArgument from:aModel.
   1.416  ! !
   1.417  
   1.418 -!ViewTreeApplication methodsFor:'event processing'!
   1.419 +!ViewTreeInspectorApplication methodsFor:'event processing'!
   1.420  
   1.421  processButtonMotionEvent:ev
   1.422      "handle a button motion event"
   1.423 @@ -845,7 +973,7 @@
   1.424      ].
   1.425  ! !
   1.426  
   1.427 -!ViewTreeApplication methodsFor:'initialization & release'!
   1.428 +!ViewTreeInspectorApplication methodsFor:'initialization & release'!
   1.429  
   1.430  closeDownViews
   1.431      "release the grapped application"
   1.432 @@ -879,7 +1007,7 @@
   1.433      treeView hasConstantHeight:true.
   1.434  ! !
   1.435  
   1.436 -!ViewTreeApplication methodsFor:'menu queries'!
   1.437 +!ViewTreeInspectorApplication methodsFor:'menu queries'!
   1.438  
   1.439  hasApplication
   1.440      "returns true if the current selected view has an application"
   1.441 @@ -914,7 +1042,7 @@
   1.442    ^ (view notNil and:[view model notNil])
   1.443  ! !
   1.444  
   1.445 -!ViewTreeApplication methodsFor:'menu specs'!
   1.446 +!ViewTreeInspectorApplication methodsFor:'menu specs'!
   1.447  
   1.448  middleButtonMenu
   1.449      "returns the middleButton menu for the single selected item or nil"
   1.450 @@ -1226,7 +1354,7 @@
   1.451    ^ MenuDesc buildFromList:list onGC:aMenu
   1.452  ! !
   1.453  
   1.454 -!ViewTreeApplication methodsFor:'private'!
   1.455 +!ViewTreeInspectorApplication methodsFor:'private'!
   1.456  
   1.457  selectFocusView
   1.458      |rootView focusItem focusView|
   1.459 @@ -1285,7 +1413,7 @@
   1.460                                  ].
   1.461  
   1.462                               ] priority:8.
   1.463 -            theProcess name:'ViewTreeApplication::Follow Focus'.
   1.464 +            theProcess name:'ViewTreeInspector - Follow Focus'.
   1.465              theProcess resume.
   1.466          ].
   1.467      ].
   1.468 @@ -1329,7 +1457,7 @@
   1.469      ].
   1.470  ! !
   1.471  
   1.472 -!ViewTreeApplication methodsFor:'selection'!
   1.473 +!ViewTreeInspectorApplication methodsFor:'selection'!
   1.474  
   1.475  selectedView
   1.476      "answer the selected view or nil"
   1.477 @@ -1341,7 +1469,7 @@
   1.478    ^ nil
   1.479  ! !
   1.480  
   1.481 -!ViewTreeApplication methodsFor:'testing'!
   1.482 +!ViewTreeInspectorApplication methodsFor:'testing'!
   1.483  
   1.484  resolveApplicationClassFor:aTreeItem
   1.485      aTreeItem isApplicationClass ifTrue:[
   1.486 @@ -1357,7 +1485,7 @@
   1.487      ^ (item notNil and:[item hasChildren])
   1.488  ! !
   1.489  
   1.490 -!ViewTreeApplication methodsFor:'user operations'!
   1.491 +!ViewTreeInspectorApplication methodsFor:'user operations'!
   1.492  
   1.493  doBrowse:what
   1.494      "open browser on:
   1.495 @@ -1532,9 +1660,13 @@
   1.496      "release current picked window and contained subwindows"
   1.497  
   1.498      self setRootItem:nil.
   1.499 +!
   1.500 +
   1.501 +openDocumentation
   1.502 +    HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#VIEWTREEINSPECTOR'
   1.503  ! !
   1.504  
   1.505 -!ViewTreeApplication::MenuDesc class methodsFor:'building'!
   1.506 +!ViewTreeInspectorApplication::MenuDesc class methodsFor:'building'!
   1.507  
   1.508  buildFromList:aList onGC:aMenu
   1.509      |tabSpec menu w menuPanel|
   1.510 @@ -1559,7 +1691,7 @@
   1.511      ^ menuPanel
   1.512  ! !
   1.513  
   1.514 -!ViewTreeApplication::MenuDesc class methodsFor:'instance creation'!
   1.515 +!ViewTreeInspectorApplication::MenuDesc class methodsFor:'instance creation'!
   1.516  
   1.517  separator
   1.518      ^ self new
   1.519 @@ -1573,13 +1705,13 @@
   1.520      ^ self new title:aTitle value:aValue action:anAction
   1.521  ! !
   1.522  
   1.523 -!ViewTreeApplication::MenuDesc methodsFor:'accessing'!
   1.524 +!ViewTreeInspectorApplication::MenuDesc methodsFor:'accessing'!
   1.525  
   1.526  title
   1.527      ^ title
   1.528  ! !
   1.529  
   1.530 -!ViewTreeApplication::MenuDesc methodsFor:'building'!
   1.531 +!ViewTreeInspectorApplication::MenuDesc methodsFor:'building'!
   1.532  
   1.533  asMenuItemWithTabulatorSpecification:aTabSpec
   1.534      |array|
   1.535 @@ -1596,7 +1728,7 @@
   1.536               value:action
   1.537  ! !
   1.538  
   1.539 -!ViewTreeApplication::MenuDesc methodsFor:'instance creation'!
   1.540 +!ViewTreeInspectorApplication::MenuDesc methodsFor:'instance creation'!
   1.541  
   1.542  title:aTitle value:aValue action:anAction
   1.543      "test for separator
   1.544 @@ -1614,7 +1746,7 @@
   1.545      ].
   1.546  ! !
   1.547  
   1.548 -!ViewTreeApplication::MenuDesc methodsFor:'queries'!
   1.549 +!ViewTreeInspectorApplication::MenuDesc methodsFor:'queries'!
   1.550  
   1.551  isSeparator
   1.552      ^ title isNil
   1.553 @@ -1625,10 +1757,2136 @@
   1.554    ^ title widthOn:aGC
   1.555  ! !
   1.556  
   1.557 -!ViewTreeApplication class methodsFor:'documentation'!
   1.558 +!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'building'!
   1.559 +
   1.560 +buildViewsFrom:aView
   1.561 +    "build the items starting from a source view;
   1.562 +     returns the anhor.
   1.563 +    "
   1.564 +    |item subViews subItems|
   1.565 +
   1.566 +    aView isNil ifTrue:[^ nil].
   1.567 +
   1.568 +    item     := self forView:aView.
   1.569 +    subViews := aView subViews.
   1.570 +
   1.571 +    subViews notEmptyOrNil ifTrue:[
   1.572 +        subItems := OrderedCollection new.
   1.573 +        subViews do:[:aSubView|
   1.574 +            subItems add:(self buildViewsFrom:aSubView).
   1.575 +        ].
   1.576 +        item children:subItems.
   1.577 +    ].
   1.578 +    ^ item
   1.579 +! !
   1.580 +
   1.581 +!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'documentation'!
   1.582 +
   1.583 +documentation
   1.584 +"
   1.585 +    ViewTreeItems represants a pickable object within a ViewTreeModel.
   1.586 +    The class is used to build up the hierarchical tree.
   1.587 +
   1.588 +    [Instance variables:]
   1.589 +        widget        <View>            the widget represented by the item
   1.590 +        spec          <UISpecification> the UISpecification or nil
   1.591 +
   1.592 +    [Class variables:]
   1.593 +        HandleExtent  <Point>           keeps the extent of a handle
   1.594 +
   1.595 +
   1.596 +    [author:]
   1.597 +        Claus Atzkern
   1.598 +
   1.599 +    [see also:]
   1.600 +        HierarchicalItem
   1.601 +        ViewTreeModel
   1.602 +"
   1.603 +!
   1.604  
   1.605  version
   1.606      ^ '$Header$'
   1.607  ! !
   1.608  
   1.609 -ViewTreeApplication initialize!
   1.610 +!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'initialization'!
   1.611 +
   1.612 +initialize
   1.613 +    "set the extent of the Handle
   1.614 +    "
   1.615 +    HandleExtent := 6@6.
   1.616 +! !
   1.617 +
   1.618 +!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'instance creation'!
   1.619 +
   1.620 +forView:aView
   1.621 +    |item|
   1.622 +
   1.623 +    item := self basicNew initialize.
   1.624 +    item forView:aView.
   1.625 +  ^ item
   1.626 +!
   1.627 +
   1.628 +new
   1.629 +    self error:'not allowed'.
   1.630 +  ^ nil
   1.631 +!
   1.632 +
   1.633 +on:aView withSpec:aSpec
   1.634 +    |item|
   1.635 +
   1.636 +    item := self basicNew initialize.
   1.637 +    item on:aView withSpec:aSpec.
   1.638 +  ^ item
   1.639 +! !
   1.640 +
   1.641 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'accessing'!
   1.642 +
   1.643 +applicationClass
   1.644 +    |appl|
   1.645 +
   1.646 +    widget notNil ifTrue:[
   1.647 +        appl := widget application.
   1.648 +        appl notNil ifTrue:[^ appl class ].
   1.649 +    ].
   1.650 +    ^ nil
   1.651 +!
   1.652 +
   1.653 +isDrawnShown
   1.654 +    "returns true if the last display operations was done during the widget was shown
   1.655 +    "
   1.656 +    ^ isDrawnShown
   1.657 +!
   1.658 +
   1.659 +isDrawnShown:aBoolean
   1.660 +    isDrawnShown := aBoolean.
   1.661 +!
   1.662 +
   1.663 +rootView
   1.664 +    "returns the widget assigned to the root or nil
   1.665 +    "
   1.666 +    ^ parent rootView
   1.667 +!
   1.668 +
   1.669 +specClass
   1.670 +    "returns the spec-class assigned to the item
   1.671 +    "
   1.672 +    ^ widget specClass
   1.673 +!
   1.674 +
   1.675 +treeModel
   1.676 +    "returns the assigned treeModel, an instance of ViewTreeModel
   1.677 +    "
   1.678 +    ^ parent treeModel
   1.679 +!
   1.680 +
   1.681 +widget
   1.682 +    "returns the widget assigned to the item
   1.683 +    "
   1.684 +    ^ widget
   1.685 +! !
   1.686 +
   1.687 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'accessing layout'!
   1.688 +
   1.689 +boundsRelativeToRoot
   1.690 +    "returns the bounds relative to the root widget
   1.691 +    "
   1.692 +    ^ self originRelativeToRoot extent:(widget extent)
   1.693 +!
   1.694 +
   1.695 +cornerRelativeToRoot
   1.696 +    "returns the corner relative to the root widget
   1.697 +    "
   1.698 +    ^ self originRelativeToRoot + (widget extent)
   1.699 +!
   1.700 +
   1.701 +extent
   1.702 +    "returns the extent of the widget
   1.703 +    "
   1.704 +    ^ widget extent
   1.705 +!
   1.706 +
   1.707 +layoutType
   1.708 +    "returns the type of layout assigned to the wiget; nil if the
   1.709 +     superView cannot resize its sub widgets
   1.710 +    "
   1.711 +    |layout specClass superView|
   1.712 +
   1.713 +    (superView := widget superView) isNil ifTrue:[
   1.714 +        ^ #Extent
   1.715 +    ].
   1.716 +        
   1.717 +    specClass := superView specClass.
   1.718 +
   1.719 +    (specClass notNil and:[specClass isLayoutContainer]) ifTrue:[
   1.720 +        ^ specClass canResizeSubComponents ifTrue:[#Extent] ifFalse:[nil]
   1.721 +    ].
   1.722 +
   1.723 +    (layout := widget geometryLayout) isNil ifTrue:[
   1.724 +        ^ #Extent
   1.725 +    ].
   1.726 +
   1.727 +    layout isLayout ifTrue:[
   1.728 +        layout isLayoutFrame        ifTrue:[ ^ #LayoutFrame ].
   1.729 +        layout isAlignmentOrigin    ifTrue:[ ^ #AlignmentOrigin ].
   1.730 +        layout isLayoutOrigin       ifTrue:[ ^ #LayoutOrigin ].
   1.731 +    ] ifFalse:[
   1.732 +        layout isRectangle          ifTrue:[ ^ #Rectangle ].
   1.733 +        layout isPoint              ifTrue:[ ^ #Point ].
   1.734 +
   1.735 +    ].
   1.736 +    Transcript showCR:'UNSUPPORTRD LAYOUT: ', layout printString.
   1.737 +  ^ nil
   1.738 +!
   1.739 +
   1.740 +originRelativeToRoot
   1.741 +    "returns the origin relative to the root widget
   1.742 +    "
   1.743 +    ^ widget originRelativeTo:(self rootView)
   1.744 +! !
   1.745 +
   1.746 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'accessing optimize'!
   1.747 +
   1.748 +children
   1.749 +    "redefined: optimize
   1.750 +    "
   1.751 +    ^ children
   1.752 +!
   1.753 +
   1.754 +hasChildren
   1.755 +    |subViews list item|
   1.756 +
   1.757 +    children size ~~ 0 ifTrue:[
   1.758 +        ^ true
   1.759 +    ].
   1.760 +    isExpanded := false.
   1.761 +    subViews   := widget subViews.
   1.762 +
   1.763 +    subViews size == 0 ifTrue:[^ false].
   1.764 +
   1.765 +    list := OrderedCollection new.
   1.766 +
   1.767 +    subViews do:[:aSubView|
   1.768 +        item := self class buildViewsFrom:aSubView.
   1.769 +        item parent:self.
   1.770 +        list add:item.
   1.771 +    ].
   1.772 +    children := list.
   1.773 +    ^ true
   1.774 +!
   1.775 +
   1.776 +size
   1.777 +    "redefined: returns list of children
   1.778 +    "
   1.779 +    ^ children size
   1.780 +! !
   1.781 +
   1.782 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'displaying'!
   1.783 +
   1.784 +additionalLabelForItem:anItem
   1.785 +    "answer an additional item for an Item or nil"
   1.786 +
   1.787 +    parent notNil ifTrue:[
   1.788 +        ^ parent additionalLabelForItem:anItem
   1.789 +    ].
   1.790 +    ^ nil
   1.791 +!
   1.792 +
   1.793 +displayIcon:anIcon atX:x y:y on:aGC
   1.794 +    |x0 y0 y1 w|
   1.795 +
   1.796 +    super displayIcon:anIcon atX:x y:y on:aGC.
   1.797 +
   1.798 +    self exists ifFalse:[
   1.799 +        aGC paint:(Color red).
   1.800 +
   1.801 +        y0 := y + 1.
   1.802 +        y1 := y + anIcon height - 2.
   1.803 +
   1.804 +        x0 := x - 1.
   1.805 +        w  := anIcon width.
   1.806 +
   1.807 +        2 timesRepeat:[
   1.808 +            aGC displayLineFromX:x0 y:y0 toX:(x0 + w) y:y1.
   1.809 +            aGC displayLineFromX:x0 y:y1 toX:(x0 + w) y:y0.
   1.810 +            x0 := x0 + 1.
   1.811 +        ].
   1.812 +    ].
   1.813 +!
   1.814 +
   1.815 +displayOn:aGC x:x y:y h:h
   1.816 +    |labelHeight additionalName label isValidAndShown|
   1.817 +
   1.818 +    label := self label.
   1.819 +    label isEmptyOrNil ifTrue:[^ self].
   1.820 +
   1.821 +    widget id isNil ifTrue:[
   1.822 +        isDrawnShown := false.
   1.823 +
   1.824 +        self exists ifFalse:[
   1.825 +            xOffsetAdditionalName := nil.
   1.826 +        ].
   1.827 +        isValidAndShown := false.
   1.828 +    ] ifFalse:[
   1.829 +        isValidAndShown := widget shown.
   1.830 +    ].
   1.831 +    isValidAndShown ifFalse:[
   1.832 +        label := Text string:label emphasis:#italic
   1.833 +    ].
   1.834 +
   1.835 +    labelHeight := self heightOn:aGC.
   1.836 +    self displayLabel:label h:labelHeight on:aGC x:x y:y h:h.
   1.837 +
   1.838 +    xOffsetAdditionalName notNil ifTrue:[
   1.839 +        additionalName := self additionalLabelForItem:self.
   1.840 +
   1.841 +        additionalName notNil ifTrue:[
   1.842 +            self displayLabel:additionalName
   1.843 +                            h:labelHeight on:aGC
   1.844 +                            x:(x + xOffsetAdditionalName)
   1.845 +                            y:y
   1.846 +                            h:h.
   1.847 +        ] ifFalse:[
   1.848 +            xOffsetAdditionalName := nil.
   1.849 +        ].
   1.850 +    ].
   1.851 +!
   1.852 +
   1.853 +recursiveAdditionalNameBehaviourChanged
   1.854 +    width := xOffsetAdditionalName := nil.
   1.855 +
   1.856 +    children notNil ifTrue:[
   1.857 +        children do:[:each| each recursiveAdditionalNameBehaviourChanged ]
   1.858 +    ].
   1.859 +!
   1.860 +
   1.861 +widthOn:aGC
   1.862 +    "return the width of the receiver, if it is to be displayed on aGC
   1.863 +    "
   1.864 +    |additionalName|
   1.865 +
   1.866 +    width isNil ifTrue:[
   1.867 +        width := self widthOf:(self label) on:aGC.
   1.868 +        width := width + 2.
   1.869 +
   1.870 +        additionalName := self additionalLabelForItem:self.
   1.871 +
   1.872 +        additionalName notNil ifTrue:[
   1.873 +            xOffsetAdditionalName := width + 10.
   1.874 +            width := xOffsetAdditionalName + (self widthOf:additionalName on:aGC).
   1.875 +            width := width + 2.
   1.876 +        ] ifFalse:[
   1.877 +            xOffsetAdditionalName := nil.
   1.878 +        ].
   1.879 +    ].
   1.880 +    ^ width
   1.881 +! !
   1.882 +
   1.883 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'enumerating'!
   1.884 +
   1.885 +handlesDo:aTwoArgAction
   1.886 +    "evaluate the two arg block on each handle; the arguments to the block is
   1.887 +     the rectangle relative to the rootView and the handle type which is
   1.888 +     set to nil if not resizeable.
   1.889 +
   1.890 +     TYPES:     type    position( X - Y )
   1.891 +                -------------------------        
   1.892 +                #LT     Left   - Top
   1.893 +                #LC     Left   - Center
   1.894 +                #LB     Left   - Bottom
   1.895 +                #CT     Center - Top
   1.896 +                #CB     Center - Bottom
   1.897 +                #RT     Right  - Top
   1.898 +                #RC     Right  - Center
   1.899 +                #RB     Right  - Bottom
   1.900 +
   1.901 +                nil     ** handle not pickable **
   1.902 +    "
   1.903 +    |type relOrg relCrn maxExt rootView w h
   1.904 +     xL    "{ Class:SmallInteger }"
   1.905 +     xC    "{ Class:SmallInteger }"
   1.906 +     xR    "{ Class:SmallInteger }"
   1.907 +     yT    "{ Class:SmallInteger }"
   1.908 +     yC    "{ Class:SmallInteger }"
   1.909 +     yB    "{ Class:SmallInteger }"
   1.910 +    |
   1.911 +    rootView := self rootView.
   1.912 +    relOrg   := widget originRelativeTo:rootView.
   1.913 +    relOrg isNil ifTrue:[ ^ self ].    "/ widget destroyed
   1.914 +
   1.915 +    relOrg   := relOrg - (HandleExtent // 2).
   1.916 +    relCrn   := relOrg + widget extent.
   1.917 +    maxExt   := rootView extent - HandleExtent.
   1.918 +
   1.919 +    xL := relOrg x max:0.
   1.920 +    xR := relCrn x min:(maxExt x).
   1.921 +    xC := xR + xL // 2.
   1.922 +
   1.923 +    yT := relOrg y max:0.
   1.924 +    yB := relCrn y min:(maxExt y).
   1.925 +    yC := yB + yT // 2.
   1.926 +
   1.927 +    type := self layoutType.
   1.928 +    w   := HandleExtent x.
   1.929 +    h   := HandleExtent y.
   1.930 +
   1.931 +    (type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[
   1.932 +        aTwoArgAction value:(Rectangle left:xL top:yT width:w height:h) value:#LT.
   1.933 +        aTwoArgAction value:(Rectangle left:xL top:yC width:w height:h) value:#LC.
   1.934 +        aTwoArgAction value:(Rectangle left:xL top:yB width:w height:h) value:#LB.
   1.935 +        aTwoArgAction value:(Rectangle left:xC top:yT width:w height:h) value:#CT.
   1.936 +        aTwoArgAction value:(Rectangle left:xC top:yB width:w height:h) value:#CB.
   1.937 +        aTwoArgAction value:(Rectangle left:xR top:yT width:w height:h) value:#RT.
   1.938 +        aTwoArgAction value:(Rectangle left:xR top:yC width:w height:h) value:#RC.
   1.939 +        aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:#RB.
   1.940 +      ^ self
   1.941 +    ].
   1.942 +
   1.943 +    aTwoArgAction value:(Rectangle left:xL top:yT width:w height:h) value:nil.
   1.944 +    aTwoArgAction value:(Rectangle left:xL top:yB width:w height:h) value:nil.
   1.945 +    aTwoArgAction value:(Rectangle left:xR top:yT width:w height:h) value:nil.
   1.946 +
   1.947 +    type == #Extent ifTrue:[
   1.948 +        aTwoArgAction value:(Rectangle left:xC top:yB width:w height:h) value:#CB.
   1.949 +        aTwoArgAction value:(Rectangle left:xR top:yC width:w height:h) value:#RC.
   1.950 +        aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:#RB.
   1.951 +      ^ self
   1.952 +    ].
   1.953 +    aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:nil.
   1.954 +!
   1.955 +
   1.956 +recursiveEachVisibleItemDo:anOneArgBlock
   1.957 +    "recursive evaluate the block on each child which is visible
   1.958 +    "
   1.959 +    (isExpanded and:[children size > 0]) ifTrue:[
   1.960 +        children do:[:aChild|
   1.961 +            anOneArgBlock value:aChild.
   1.962 +            aChild recursiveEachVisibleItemDo:anOneArgBlock.
   1.963 +        ]
   1.964 +    ].
   1.965 +!
   1.966 +
   1.967 +subViewsDo:aOneArgBlock
   1.968 +    "evaluate aBlock for all subviews other than InputView's   
   1.969 +    "
   1.970 +    |subViews|
   1.971 +
   1.972 +    subViews := widget subViews.
   1.973 +
   1.974 +    subViews notNil ifTrue:[
   1.975 +        subViews do:aOneArgBlock
   1.976 +    ].
   1.977 +! !
   1.978 +
   1.979 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'initialization'!
   1.980 +
   1.981 +forView:aView
   1.982 +    widget := aView.
   1.983 +!
   1.984 +
   1.985 +initialize
   1.986 +    "setup default attributes
   1.987 +    "
   1.988 +    super initialize.
   1.989 +    isDrawnShown := false.
   1.990 +    isExpanded   := false.
   1.991 +    children     := OrderedCollection new.
   1.992 +! !
   1.993 +
   1.994 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'operations delete'!
   1.995 +
   1.996 +delete
   1.997 +    "delete self and all contained items; the assigned views are destroyed
   1.998 +     in case of rootView, only the children are deleted
   1.999 +    "
  1.1000 +    parent isHierarchicalItem ifTrue:[
  1.1001 +        self criticalDo:[
  1.1002 +            parent remove:self.
  1.1003 +            widget destroy.
  1.1004 +        ]
  1.1005 +    ] ifFalse:[
  1.1006 +        self deleteAll
  1.1007 +    ].
  1.1008 +!
  1.1009 +
  1.1010 +deleteAll
  1.1011 +    "delete all contained items; the assigned views are destroyed
  1.1012 +    "
  1.1013 +    children size == 0 ifTrue:[^ self].
  1.1014 +
  1.1015 +    self criticalDo:[
  1.1016 +        self nonCriticalDo:[:el| el widget destroy ].
  1.1017 +        self removeAll
  1.1018 +    ].
  1.1019 +! !
  1.1020 +
  1.1021 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'operations layout'!
  1.1022 +
  1.1023 +asLayoutFrame
  1.1024 +    "convert the layout of the widget to a LayoutFrame;
  1.1025 +    "
  1.1026 +    |extent layout newLyt lftFrc lftOff topFrc topOff|
  1.1027 +
  1.1028 +    layout := widget geometryLayout.
  1.1029 +
  1.1030 +    layout isNil ifTrue:[
  1.1031 +        ^ widget bounds asLayout
  1.1032 +    ].
  1.1033 +
  1.1034 +    layout isLayout ifFalse:[
  1.1035 +        layout isRectangle ifTrue:[
  1.1036 +            ^ LayoutFrame leftOffset:(layout left) rightOffset:(layout right)
  1.1037 +                           topOffset:(layout top) bottomOffset:(layout bottom)
  1.1038 +        ].
  1.1039 +        layout isPoint ifTrue:[
  1.1040 +            extent := widget extent.
  1.1041 +          ^ LayoutFrame leftOffset:(layout x)  rightOffset:(layout x + extent x)
  1.1042 +                         topOffset:(layout y) bottomOffset:(layout y + extent y)
  1.1043 +        ].
  1.1044 +
  1.1045 +        Transcript showCR:'UNSUPPORTRD LAYOUT: ', layout printString.
  1.1046 +      ^ nil
  1.1047 +    ].
  1.1048 +
  1.1049 +    layout isLayoutFrame ifTrue:[ ^ layout copy ].    
  1.1050 +
  1.1051 +    lftFrc := layout leftFraction.
  1.1052 +    lftOff := layout leftOffset.
  1.1053 +    topFrc := layout topFraction.
  1.1054 +    topOff := layout topOffset.
  1.1055 +    extent := widget extent.
  1.1056 +
  1.1057 +    newLyt := LayoutFrame leftFraction:lftFrc offset:lftOff
  1.1058 +                         rightFraction:lftFrc offset:(lftOff + extent x)
  1.1059 +                           topFraction:topFrc offset:topOff
  1.1060 +                        bottomFraction:topFrc offset:(topOff + extent y).
  1.1061 +
  1.1062 +    (      layout isAlignmentOrigin
  1.1063 +     and:[(layout leftAlignmentFraction ~= 0 or:[layout topAlignmentFraction ~= 0])]
  1.1064 +    ) ifTrue:[
  1.1065 +        |svRc prBd dlta|
  1.1066 +
  1.1067 +        svRc := widget superView viewRectangle.
  1.1068 +        prBd := widget preferredBounds.
  1.1069 +
  1.1070 +        dlta := (  ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
  1.1071 +                 - ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
  1.1072 +                ) rounded.
  1.1073 +
  1.1074 +        newLyt   leftOffset:(lftOff + dlta x).
  1.1075 +        newLyt  rightOffset:(lftOff + extent x + dlta x).
  1.1076 +        newLyt    topOffset:(topOff + dlta y).
  1.1077 +        newLyt bottomOffset:(topOff + extent y + dlta y).
  1.1078 +    ].
  1.1079 +    ^ newLyt
  1.1080 +!
  1.1081 +
  1.1082 +moveLeft:l top:t
  1.1083 +    "move the widget n pixele left and right
  1.1084 +    "
  1.1085 +    |layout|
  1.1086 +
  1.1087 +    self isMoveable ifFalse:[ ^ self ].
  1.1088 +
  1.1089 +    (layout := widget geometryLayout) isNil ifTrue:[
  1.1090 +        "Extent"
  1.1091 +        widget origin:(widget origin + (l@t)).
  1.1092 +      ^ self
  1.1093 +    ].
  1.1094 +
  1.1095 +    layout := layout copy.
  1.1096 +
  1.1097 +    layout isLayout ifTrue:[
  1.1098 +        layout leftOffset:(layout leftOffset + l)
  1.1099 +                topOffset:(layout topOffset  + t).
  1.1100 +
  1.1101 +        layout isLayoutFrame ifTrue:[
  1.1102 +            layout  rightOffset:(layout rightOffset  + l).
  1.1103 +            layout bottomOffset:(layout bottomOffset + t).
  1.1104 +        ]
  1.1105 +
  1.1106 +    ] ifFalse:[
  1.1107 +        layout isRectangle ifTrue:[
  1.1108 +            layout setLeft:(layout left + l).
  1.1109 +            layout  setTop:(layout top  + t).
  1.1110 +        ] ifFalse:[
  1.1111 +            layout isPoint ifFalse:[^ self].
  1.1112 +            layout x:(layout x + l) y:(layout y + t).
  1.1113 +        ]
  1.1114 +    ].
  1.1115 +    widget geometryLayout:layout.
  1.1116 +!
  1.1117 +
  1.1118 +resizeLeft:l top:t right:r bottom:b
  1.1119 +    "resize the widget measured in pixels
  1.1120 +    "
  1.1121 +    |layout|
  1.1122 +
  1.1123 +    self isResizeable ifFalse:[
  1.1124 +        ^ self
  1.1125 +    ].
  1.1126 +
  1.1127 +    (layout := widget geometryLayout) isNil ifTrue:[
  1.1128 +        "Extent"
  1.1129 +        (r == l and:[b == t]) ifFalse:[
  1.1130 +            widget extent:(widget computeExtent + ((r-l) @ (b-t))).
  1.1131 +        ].
  1.1132 +        ^ self
  1.1133 +    ].
  1.1134 +
  1.1135 +    layout isLayout ifTrue:[
  1.1136 +        layout := layout copy.
  1.1137 +
  1.1138 +        layout leftOffset:(layout leftOffset + l)
  1.1139 +                topOffset:(layout topOffset  + t).
  1.1140 +
  1.1141 +        layout isLayoutFrame ifTrue:[
  1.1142 +            layout bottomOffset:(layout bottomOffset + b).
  1.1143 +            layout  rightOffset:(layout rightOffset  + r).
  1.1144 +        ]
  1.1145 +    ] ifFalse:[
  1.1146 +        layout isRectangle ifFalse:[^ self].
  1.1147 +        layout := layout copy.
  1.1148 +
  1.1149 +        layout left:(layout left   + l)
  1.1150 +              right:(layout right  + r)
  1.1151 +                top:(layout top    + t)
  1.1152 +             bottom:(layout bottom + b).
  1.1153 +    ].
  1.1154 +    widget geometryLayout:layout.
  1.1155 +! !
  1.1156 +
  1.1157 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'operations update'!
  1.1158 +
  1.1159 +updateChildren
  1.1160 +    |list|
  1.1161 +
  1.1162 +    self do:[:el|
  1.1163 +        el exists ifTrue:[
  1.1164 +            el updateChildren.
  1.1165 +        ] ifFalse:[
  1.1166 +            list isNil ifTrue:[list := OrderedCollection new].
  1.1167 +            list add:el.
  1.1168 +        ]
  1.1169 +    ].
  1.1170 +    list notNil ifTrue:[
  1.1171 +        list do:[:el| self remove:el ].
  1.1172 +    ].
  1.1173 +!
  1.1174 +
  1.1175 +updateFromChildren:mergedList
  1.1176 +    "update my children against the list of items derived from
  1.1177 +     the merged list.
  1.1178 +    "
  1.1179 +
  1.1180 +    mergedList size == 0 ifTrue:[ ^ self removeAll ].
  1.1181 +    children   size == 0 ifTrue:[ ^ self addAll:mergedList ].
  1.1182 +
  1.1183 +    self criticalDo:[
  1.1184 +        self nonCriticalDo:[:el| |wdg|
  1.1185 +            wdg := el widget.
  1.1186 +            mergedList detect:[:e2| e2 widget == wdg ] ifNone:[ self remove:el ].
  1.1187 +        ].
  1.1188 +
  1.1189 +        mergedList keysAndValuesDo:[:i :el| |wdg e2|
  1.1190 +            wdg := el widget.
  1.1191 +
  1.1192 +            e2  := self at:i ifAbsent:nil.
  1.1193 +
  1.1194 +            (e2 isNil or:[e2 widget ~~ wdg]) ifTrue:[
  1.1195 +                self add:el beforeIndex:i
  1.1196 +            ]
  1.1197 +        ]
  1.1198 +    ].
  1.1199 +! !
  1.1200 +
  1.1201 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'printing & storing'!
  1.1202 +
  1.1203 +icon
  1.1204 +    "get the icon used for presentation
  1.1205 +    "
  1.1206 +    |specClass model|
  1.1207 +
  1.1208 +    specClass := self specClass.
  1.1209 +    specClass isNil ifTrue:[^ nil].
  1.1210 +
  1.1211 +    model := self treeModel.
  1.1212 +
  1.1213 +    model notNil ifTrue:[
  1.1214 +        ^ model iconAt:specClass ifNonePut:[specClass icon]
  1.1215 +    ].
  1.1216 +    ^ specClass icon
  1.1217 +!
  1.1218 +
  1.1219 +label
  1.1220 +    "get the label used for presentation
  1.1221 +    "
  1.1222 +    ^ self string
  1.1223 +!
  1.1224 +
  1.1225 +printOn:aStream
  1.1226 +    "append a a printed representation of the item to aStream
  1.1227 +    "
  1.1228 +    aStream nextPutAll:(self string)
  1.1229 +!
  1.1230 +
  1.1231 +string
  1.1232 +    "get the string
  1.1233 +    "
  1.1234 +    ^ widget class name.
  1.1235 +! !
  1.1236 +
  1.1237 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'queries'!
  1.1238 +
  1.1239 +canChangeLayout
  1.1240 +    "returns true if the layout of the widget can be changed and the
  1.1241 +     layout is not organized by its superView
  1.1242 +    "
  1.1243 +    ^ self isResizeable
  1.1244 +!
  1.1245 +
  1.1246 +canResizeSubComponents
  1.1247 +    "returns true if the widget can resize its sub components
  1.1248 +    "
  1.1249 +    |specClass|
  1.1250 +
  1.1251 +    specClass := self specClass.
  1.1252 +
  1.1253 +    specClass notNil ifTrue:[
  1.1254 +        ^ specClass canResizeSubComponents
  1.1255 +    ].
  1.1256 +    ^ false
  1.1257 +!
  1.1258 +
  1.1259 +exists
  1.1260 +    widget id notNil ifTrue:[^ true ].
  1.1261 +
  1.1262 +    exists ~~ false ifTrue:[
  1.1263 +        exists := false.
  1.1264 +
  1.1265 +        widget superView notNil ifTrue:[
  1.1266 +            (parent isHierarchicalItem and:[parent exists]) ifTrue:[
  1.1267 +                exists := (parent widget subViews includesIdentical:widget).
  1.1268 +            ].
  1.1269 +        ].
  1.1270 +    ].
  1.1271 +    ^ exists
  1.1272 +!
  1.1273 +
  1.1274 +isApplicationClass
  1.1275 +    |cls|
  1.1276 +
  1.1277 +    cls := widget class.
  1.1278 +
  1.1279 +    ^ (    cls == ApplicationSubView
  1.1280 +        or:[cls == ApplicationWindow
  1.1281 +        or:[cls == SubCanvas]]
  1.1282 +      ) 
  1.1283 +!
  1.1284 +
  1.1285 +isSelected
  1.1286 +    |model|
  1.1287 +
  1.1288 +    model := self treeModel.
  1.1289 +    model notNil ifTrue:[^ model isSelected:self].
  1.1290 +    ^ false
  1.1291 +!
  1.1292 +
  1.1293 +supportsSubComponents
  1.1294 +    "returns true if the widget supports sub components
  1.1295 +    "
  1.1296 +    |specClass|
  1.1297 +
  1.1298 +    widget isScrollWrapper ifTrue:[
  1.1299 +        ^ false
  1.1300 +    ].
  1.1301 +    specClass := self specClass.
  1.1302 +
  1.1303 +    specClass notNil ifTrue:[
  1.1304 +        ^ specClass supportsSubComponents
  1.1305 +    ].
  1.1306 +    ^ false
  1.1307 +! !
  1.1308 +
  1.1309 +!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'testing'!
  1.1310 +
  1.1311 +isInLayoutContainer
  1.1312 +    "returns true if the widget is in a layout container
  1.1313 +    "
  1.1314 +    |sv specClass|
  1.1315 +
  1.1316 +    sv := widget superView.
  1.1317 +
  1.1318 +    sv notNil ifTrue:[
  1.1319 +        specClass := sv specClass.
  1.1320 +
  1.1321 +        specClass notNil ifTrue:[
  1.1322 +            ^ specClass isLayoutContainer
  1.1323 +        ].
  1.1324 +    ].
  1.1325 +    ^ false
  1.1326 +!
  1.1327 +
  1.1328 +isLayoutContainer
  1.1329 +    "answer whether corresponding view instances of the spec class can contain
  1.1330 +     (and arrange) other view
  1.1331 +    "
  1.1332 +    |specClass|
  1.1333 +
  1.1334 +    specClass := self specClass.
  1.1335 +
  1.1336 +    specClass notNil ifTrue:[
  1.1337 +        ^ specClass isLayoutContainer
  1.1338 +    ].
  1.1339 +    ^ false
  1.1340 +!
  1.1341 +
  1.1342 +isMoveable
  1.1343 +    "returns true if the widget is not in a layout container
  1.1344 +    "
  1.1345 +    self isInLayoutContainer ifFalse:[
  1.1346 +        ^ widget superView notNil
  1.1347 +    ].
  1.1348 +    ^ false
  1.1349 +!
  1.1350 +
  1.1351 +isResizeable
  1.1352 +    "returns true if the widget is resizeable
  1.1353 +    "
  1.1354 +    |sv specClass|
  1.1355 +
  1.1356 +    sv := widget superView.
  1.1357 +
  1.1358 +    sv notNil ifTrue:[
  1.1359 +        specClass := sv specClass.
  1.1360 +
  1.1361 +        specClass notNil ifTrue:[
  1.1362 +            ^ specClass canResizeSubComponents
  1.1363 +        ].
  1.1364 +    ].
  1.1365 +    ^ false
  1.1366 +! !
  1.1367 +
  1.1368 +!ViewTreeInspectorApplication::ViewTreeModel class methodsFor:'documentation'!
  1.1369 +
  1.1370 +documentation
  1.1371 +"
  1.1372 +    Instances of ViewTreeModel can be used as model on a View and all
  1.1373 +    it contained subviews for a HierarchicalListView.
  1.1374 +    The model keeps two values, the hierarchical representation of the views
  1.1375 +    and subviews (ViewTreeItems) and the selection, a list of selected ViewTreeItems's.
  1.1376 +    It shows the selected items highlighted.
  1.1377 +
  1.1378 +
  1.1379 +    [Instance variables:]
  1.1380 +        lockSema            <Semaphore>         lock selection notifications and redraws
  1.1381 +
  1.1382 +        testModeChannel     <ValueHolder>       true, than running in test mode.
  1.1383 +
  1.1384 +        hasTargetWidgetChannel <ValueHolder>    true, than any target view is grapped
  1.1385 +
  1.1386 +        selection           <Sequence or nil>   selected items or nil
  1.1387 +
  1.1388 +        hiddenLevel         <Integer>           internal use; redrawing the selection
  1.1389 +                                                only is done if the counter is 0.
  1.1390 +
  1.1391 +        listOfItems         <HierarchicalList>  hiearchical list build from existing items.
  1.1392 +
  1.1393 +        selectedSuperItems  <Sequence>          list of selected super items; items selected
  1.1394 +                                                but not contained in another selected item.
  1.1395 +
  1.1396 +        inputEventAction    <Action>            called for each InputEvent
  1.1397 +
  1.1398 +        mappedViewAction    <Action>            called for a new mapped view which
  1.1399 +                                                can not be found in the current item list.
  1.1400 +
  1.1401 +        beforeSelectionChangedAction <Action>   called before the selection changed
  1.1402 +
  1.1403 +    [author:]
  1.1404 +        Claus Atzkern
  1.1405 +
  1.1406 +    [see also:]
  1.1407 +        ViewTreeItem
  1.1408 +"
  1.1409 +!
  1.1410 +
  1.1411 +examples
  1.1412 +"
  1.1413 +    example 1: pick any window and show views and contained views
  1.1414 +                                                                                [exBegin]
  1.1415 +    |top sel model panel|
  1.1416 +
  1.1417 +    model := ViewTreeModel new.
  1.1418 +    top   := StandardSystemView new; extent:440@400.
  1.1419 +    sel   := ScrollableView for:HierarchicalListView miniScroller:true origin:0.0@0.0 corner:1.0@1.0 in:top.
  1.1420 +    sel bottomInset:24.
  1.1421 +
  1.1422 +    panel := HorizontalPanelView origin:0.0@1.0 corner:1.0@1.0 in:top.
  1.1423 +    panel topInset:-24.
  1.1424 +    panel horizontalLayout:#fitSpace.
  1.1425 +
  1.1426 +    Button label:'Exit'       action:[model rootItem:nil. top destroy] in:panel.
  1.1427 +    Button label:'Pick Views' action:[  |win|
  1.1428 +                                        (     (win := Screen current viewFromUser) notNil
  1.1429 +                                         and:[(win := win topView) ~~ Screen current rootView
  1.1430 +                                         and:[win ~~ top]]
  1.1431 +                                        ) ifTrue:[
  1.1432 +                                            model rootItem:(ViewTreeItem buildViewsFrom:win)
  1.1433 +                                        ] ifFalse:[
  1.1434 +                                            model rootItem:nil
  1.1435 +                                        ]
  1.1436 +                                     ] in:panel.
  1.1437 +
  1.1438 +    sel  multipleSelectOk:true.
  1.1439 +    sel              list:model listOfItems.
  1.1440 +    sel             model:model.
  1.1441 +    sel          useIndex:false.
  1.1442 +
  1.1443 +    sel doubleClickAction:[:i| |el|
  1.1444 +        el := model listOfItems at:i.
  1.1445 +        el spec notNil ifTrue:[ el spec   inspect ] ifFalse:[ el widget inspect ]
  1.1446 +    ].
  1.1447 +    sel indicatorAction:[:i| (model listOfItems at:i) toggleExpand ].
  1.1448 +
  1.1449 +    model inputEventAction:[:anEvent| |item|
  1.1450 +        anEvent isButtonEvent ifTrue:[
  1.1451 +            anEvent isButtonPressEvent ifTrue:[
  1.1452 +                model selectedItem:(model listOfItems detectItemRespondsToView:(anEvent view)).
  1.1453 +            ] ifFalse:[
  1.1454 +                anEvent type == #'buttonMultiPress:x:y:' ifTrue:[
  1.1455 +                    (item := model selectedItem) notNil ifTrue:[item widget inspect]
  1.1456 +                ]
  1.1457 +            ]
  1.1458 +        ]
  1.1459 +    ].
  1.1460 +
  1.1461 +    top openAndWait.
  1.1462 +    [[top shown] whileTrue:[Delay waitForSeconds:0.5]. model rootItem:nil] forkAt:8
  1.1463 +
  1.1464 +                                                                                [exEnd]
  1.1465 +"
  1.1466 +! !
  1.1467 +
  1.1468 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'accessing'!
  1.1469 +
  1.1470 +application:anApplication
  1.1471 +    listOfItems application:anApplication.
  1.1472 +!
  1.1473 +
  1.1474 +rootItem
  1.1475 +    "get the rootItem the event viewer is established on
  1.1476 +    "
  1.1477 +    ^ listOfItems root
  1.1478 +!
  1.1479 +
  1.1480 +rootItem:anItem
  1.1481 +    "set the rootItem the event viewer is established on
  1.1482 +    "
  1.1483 +    |expanded|
  1.1484 +
  1.1485 +    timedUpdateTask := nil.
  1.1486 +    self deselect.
  1.1487 +
  1.1488 +    lockSema critical:[
  1.1489 +        anItem notNil ifTrue:[ expanded := anItem isExpanded ]
  1.1490 +                     ifFalse:[ expanded := false ].
  1.1491 +
  1.1492 +        self value:nil.
  1.1493 +        listOfItems root:anItem.
  1.1494 +
  1.1495 +        anItem notNil ifTrue:[
  1.1496 +            timedUpdateTask := Process for:[ self timedUpdateTaskCycle ] priority:8.
  1.1497 +            timedUpdateTask name:'Update'.
  1.1498 +            timedUpdateTask resume.
  1.1499 +        ].
  1.1500 +    ].
  1.1501 +
  1.1502 +    (expanded and:[anItem notNil]) ifTrue:[
  1.1503 +        anItem expand
  1.1504 +    ].
  1.1505 +    ^ anItem
  1.1506 +!
  1.1507 +
  1.1508 +rootView
  1.1509 +    "get the top widget the event viewer is established on, a View
  1.1510 +    "
  1.1511 +    ^ listOfItems rootView
  1.1512 +! !
  1.1513 +
  1.1514 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'accessing actions'!
  1.1515 +
  1.1516 +beforeSelectionChangedAction
  1.1517 +    "none argument action which is called before
  1.1518 +     the selection changed
  1.1519 +    "
  1.1520 +    ^ beforeSelectionChangedAction
  1.1521 +!
  1.1522 +
  1.1523 +beforeSelectionChangedAction:aNoneArgBlock
  1.1524 +    "none argument action which is called before
  1.1525 +     the selection changed
  1.1526 +    "
  1.1527 +    beforeSelectionChangedAction := aNoneArgBlock.
  1.1528 +!
  1.1529 +
  1.1530 +inputEventAction
  1.1531 +    "called for each input event; the argument to the action is the WindowEvent
  1.1532 +    "
  1.1533 +    ^ inputEventAction
  1.1534 +!
  1.1535 +
  1.1536 +inputEventAction:aOneArgActionTheEvent
  1.1537 +    "called for each input event; the argument to the action is the WindowEvent
  1.1538 +    "
  1.1539 +    inputEventAction := aOneArgActionTheEvent.
  1.1540 +!
  1.1541 +
  1.1542 +mappedViewAction
  1.1543 +    "called for a new mapped view which can not be found
  1.1544 +     in the current item list
  1.1545 +    "
  1.1546 +    ^ mappedViewAction
  1.1547 +!
  1.1548 +
  1.1549 +mappedViewAction:aOneArgBlockTheMappedView
  1.1550 +    "called for a new mapped view which can not be found
  1.1551 +     in the current item list
  1.1552 +    "
  1.1553 +    mappedViewAction := aOneArgBlockTheMappedView
  1.1554 +! !
  1.1555 +
  1.1556 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'accessing look'!
  1.1557 +
  1.1558 +iconAt:aKey ifNonePut:aNoneArgBlock
  1.1559 +    |icon view|
  1.1560 +
  1.1561 +    icon := icons at:aKey ifAbsent:nil.
  1.1562 +    icon notNil ifTrue:[^ icon].
  1.1563 +
  1.1564 +    icon := aNoneArgBlock value.
  1.1565 +    icon isNil ifTrue:[^ nil].
  1.1566 +
  1.1567 +    view := self rootView.
  1.1568 +    view isNil ifTrue:[^ icon].
  1.1569 +
  1.1570 +    icon := icon copy onDevice:(view device).
  1.1571 +    icon isImage ifTrue:[
  1.1572 +        icon clearMaskedPixels.
  1.1573 +    ].
  1.1574 +    icons at:aKey put:icon.
  1.1575 +    ^ icon
  1.1576 +! !
  1.1577 +
  1.1578 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'accessing visibility'!
  1.1579 +
  1.1580 +signalHiddenLevel
  1.1581 +    "show the selection if signaled; increments hiddenLevel
  1.1582 +     see: #waitHiddenLevel
  1.1583 +    "
  1.1584 +    (hiddenLevel := hiddenLevel - 1) < 1 ifTrue:[
  1.1585 +        hiddenLevel := 0.
  1.1586 +        self invalidateSelection.
  1.1587 +    ].
  1.1588 +!
  1.1589 +
  1.1590 +waitHiddenLevel
  1.1591 +    "hide the selection until signaled; increments hiddenLevel
  1.1592 +     see: #signalHiddenLevel
  1.1593 +    "
  1.1594 +    self redrawUnselected:selection andLock:true
  1.1595 +!
  1.1596 +
  1.1597 +withSelectionHiddenDo:aNoneArgumentBlock
  1.1598 +    "apply block with selection hidden
  1.1599 +    "
  1.1600 +
  1.1601 +    [   self waitHiddenLevel.
  1.1602 +
  1.1603 +        aNoneArgumentBlock value
  1.1604 +
  1.1605 +    ] valueNowOrOnUnwindDo:[
  1.1606 +        self signalHiddenLevel.
  1.1607 +    ].
  1.1608 +! !
  1.1609 +
  1.1610 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'aspects'!
  1.1611 +
  1.1612 +hasTargetWidgetChannel
  1.1613 +    "answer the channel which is set to true if a target widget exists"
  1.1614 +
  1.1615 +    ^ hasTargetWidgetChannel
  1.1616 +!
  1.1617 +
  1.1618 +listOfItems
  1.1619 +    "hiearchical list build from existing items"
  1.1620 +
  1.1621 +    ^ listOfItems
  1.1622 +!
  1.1623 +
  1.1624 +selectOnClickHolder
  1.1625 +    "boolean holder, which indicates whether the selection will change on click
  1.1626 +    "
  1.1627 +    ^ selectOnClickHolder
  1.1628 +!
  1.1629 +
  1.1630 +testModeChannel
  1.1631 +    "answer a boolean channel which describes the behaviour how to process
  1.1632 +     events on the target view.
  1.1633 +
  1.1634 +     false: all input events are eaten and the selection is shown on the target view.
  1.1635 +     true:  no  input events are eaten and no  selection is shown on the target view."
  1.1636 +
  1.1637 +    ^ testModeChannel
  1.1638 +! !
  1.1639 +
  1.1640 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'change & update'!
  1.1641 +
  1.1642 +targetWidgetChanged
  1.1643 +    hasTargetWidgetChannel value:(self rootItem notNil).
  1.1644 +!
  1.1645 +
  1.1646 +timedUpdateTaskCycle
  1.1647 +    |view myTaskId|
  1.1648 +
  1.1649 +    myTaskId := timedUpdateTask.
  1.1650 +
  1.1651 +    listOfItems root notNil ifTrue:[
  1.1652 +        view := listOfItems root widget.
  1.1653 +    ].
  1.1654 +
  1.1655 +    [ view notNil ] whileTrue:[
  1.1656 +        Delay waitForSeconds:0.5.
  1.1657 +        
  1.1658 +        (myTaskId == timedUpdateTask and:[view id notNil]) ifFalse:[
  1.1659 +            view := nil.
  1.1660 +        ] ifTrue:[
  1.1661 +            (view sensor hasUserEvent:#updateChildren for:self) ifFalse:[
  1.1662 +                view sensor pushUserEvent:#updateChildren for:self.
  1.1663 +            ].
  1.1664 +        ].
  1.1665 +    ].
  1.1666 +    timedUpdateTask == myTaskId ifTrue:[
  1.1667 +        timedUpdateTask := nil.
  1.1668 +        listOfItems root:nil.
  1.1669 +    ].
  1.1670 +!
  1.1671 +
  1.1672 +update:something with:someArgument from:aModel
  1.1673 +
  1.1674 +    aModel == testModeChannel ifTrue:[
  1.1675 +        (hiddenLevel == 0 and:[selection size > 0]) ifTrue:[
  1.1676 +            testModeChannel value ifTrue:[
  1.1677 +                self redrawUnselected:selection andLock:false checkTestMode:false.
  1.1678 +            ] ifFalse:[
  1.1679 +                self invalidateSelection.
  1.1680 +            ].
  1.1681 +        ].
  1.1682 +        ^ self
  1.1683 +    ].
  1.1684 +    super update:something with:someArgument from:aModel.
  1.1685 +!
  1.1686 +
  1.1687 +updateChildren
  1.1688 +    |rootItem|
  1.1689 +
  1.1690 +    rootItem := listOfItems root.
  1.1691 +    rootItem isNil ifTrue:[^ self].
  1.1692 +
  1.1693 +    rootItem exists ifFalse:[
  1.1694 +        listOfItems root:nil.
  1.1695 +    ] ifTrue:[
  1.1696 +        rootItem updateChildren.
  1.1697 +    ].
  1.1698 +! !
  1.1699 +
  1.1700 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'event processing'!
  1.1701 +
  1.1702 +processEvent:anEvent
  1.1703 +    "catch and process all WindowEvents for the rootComponent and its contained
  1.1704 +     widgets; redraw selection in case of damage ....
  1.1705 +    "
  1.1706 +    |evView item rootView testMode|
  1.1707 +
  1.1708 +    evView := anEvent view.
  1.1709 +    evView isNil ifTrue:[
  1.1710 +        (anEvent isMessageSendEvent and:[anEvent receiver == self]) ifFalse:[
  1.1711 +            ^ false
  1.1712 +        ].
  1.1713 +        anEvent value.
  1.1714 +        ^ true.
  1.1715 +    ].
  1.1716 +    rootView := listOfItems rootView.
  1.1717 +    rootView isNil ifTrue:[ ^ false ].
  1.1718 +
  1.1719 +    anEvent isConfigureEvent ifTrue:[
  1.1720 +        hiddenLevel == 0 ifTrue:[
  1.1721 +            self redrawUnselected:selection andLock:false.
  1.1722 +        ].
  1.1723 +        ^ false
  1.1724 +    ].
  1.1725 +
  1.1726 +    "/ check whether view is contained within the rootView
  1.1727 +    (evView == rootView or:[evView isComponentOf:rootView]) ifFalse:[
  1.1728 +        ^ false
  1.1729 +    ].
  1.1730 +
  1.1731 +    anEvent isInputEvent ifFalse:[
  1.1732 +        anEvent isDamage ifTrue:[
  1.1733 +            hiddenLevel == 0 ifTrue:[self invalidateSelection].
  1.1734 +            ^ false
  1.1735 +        ].
  1.1736 +
  1.1737 +        anEvent isMapEvent ifTrue:[
  1.1738 +            mappedViewAction notNil ifTrue:[
  1.1739 +                item := listOfItems recursiveDetect:[:el| el widget == evView].
  1.1740 +                item isNil ifTrue:[ mappedViewAction value:evView ]
  1.1741 +            ].
  1.1742 +            ^ false
  1.1743 +        ].
  1.1744 +
  1.1745 +        anEvent type == #terminate ifTrue:[
  1.1746 +            item := listOfItems recursiveDetect:[:el| el widget == evView].
  1.1747 +            item notNil ifTrue:[ self processTerminateForItem:item ].
  1.1748 +            ^ false
  1.1749 +        ].
  1.1750 +        ^ false
  1.1751 +    ].
  1.1752 +    testMode := testModeChannel value.
  1.1753 +
  1.1754 +    anEvent isFocusEvent ifTrue:[
  1.1755 +        evView == rootView ifTrue:[
  1.1756 +            self invalidateSelection
  1.1757 +        ].
  1.1758 +        ^ testMode not.
  1.1759 +    ].
  1.1760 +    anEvent isPointerEnterLeaveEvent ifTrue:[ ^ testMode not ].
  1.1761 +
  1.1762 +    testMode ifFalse:[
  1.1763 +        inputEventAction notNil ifTrue:[ inputEventAction value:anEvent ].
  1.1764 +    ] ifTrue:[
  1.1765 +        anEvent isButtonPressEvent ifTrue:[
  1.1766 +            selectOnClickHolder value ifTrue:[
  1.1767 +                self selectItem:(listOfItems detectItemRespondsToView:evView).
  1.1768 +            ].
  1.1769 +        ]
  1.1770 +    ].
  1.1771 +
  1.1772 +    (hiddenLevel ~~ 0 and:[anEvent isButtonReleaseEvent]) ifTrue:[
  1.1773 +        hiddenLevel := 1.
  1.1774 +        self signalHiddenLevel.
  1.1775 +    ].
  1.1776 +
  1.1777 +    ^ testMode not
  1.1778 +!
  1.1779 +
  1.1780 +processTerminateForItem:anItem
  1.1781 +    "received terminate for an item
  1.1782 +    "
  1.1783 +    anItem remove.
  1.1784 +! !
  1.1785 +
  1.1786 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'initialization'!
  1.1787 +
  1.1788 +initialize
  1.1789 +    "setup the default attributes
  1.1790 +    "
  1.1791 +    super initialize.
  1.1792 +
  1.1793 +    hiddenLevel           := 0.
  1.1794 +    lockSema              := RecursionLock new.
  1.1795 +    listOfItems           := ItemList new on:self.
  1.1796 +    selectedSuperItems    := #().
  1.1797 +    icons                 := IdentityDictionary new.
  1.1798 +
  1.1799 +    hasTargetWidgetChannel := false asValue.
  1.1800 +    selectOnClickHolder    := true asValue.
  1.1801 +
  1.1802 +    testModeChannel := false asValue.
  1.1803 +    testModeChannel addDependent:self.
  1.1804 +! !
  1.1805 +
  1.1806 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'private selection'!
  1.1807 +
  1.1808 +invalidateSelection
  1.1809 +    "invalidate the current selection
  1.1810 +    "
  1.1811 +    |topView|
  1.1812 +
  1.1813 +    testModeChannel value ifTrue:[ ^ self ]. "/ test whether running testMode
  1.1814 +
  1.1815 +    (     hiddenLevel == 0
  1.1816 +     and:[selection notNil
  1.1817 +     and:[(topView := listOfItems rootView) notNil
  1.1818 +     and:[topView shown]]]
  1.1819 +    ) ifTrue:[
  1.1820 +        topView sensor pushUserEvent:#redrawSelection for:self withArguments:#()
  1.1821 +    ]
  1.1822 +!
  1.1823 +
  1.1824 +recursiveRepair:theDamages startIn:aView relativeTo:aRootView
  1.1825 +    "repair all views and contained views, which intersects the damage.
  1.1826 +     !!!! all damages repaired are removed from the list of damages !!!!
  1.1827 +    "
  1.1828 +    |color relOrg damage subViews repaired
  1.1829 +     bwWidth    "{ Class:SmallInteger }"
  1.1830 +     x          "{ Class:SmallInteger }"
  1.1831 +     y          "{ Class:SmallInteger }"
  1.1832 +     w          "{ Class:SmallInteger }"
  1.1833 +     h          "{ Class:SmallInteger }"
  1.1834 +     relOrgX    "{ Class:SmallInteger }"
  1.1835 +     relOrgY    "{ Class:SmallInteger }"
  1.1836 +     width      "{ Class:SmallInteger }"
  1.1837 +     height     "{ Class:SmallInteger }"
  1.1838 +     size       "{ Class:SmallInteger }"
  1.1839 +    |
  1.1840 +    (aView shown and:[theDamages notEmpty]) ifFalse:[ ^ self ].
  1.1841 +
  1.1842 +    subViews := aView subViews.
  1.1843 +
  1.1844 +    subViews size ~~ 0 ifTrue:[
  1.1845 +        subViews reverseDo:[:v| self recursiveRepair:theDamages startIn:v relativeTo:aRootView ].
  1.1846 +        theDamages isEmpty ifTrue:[ ^ self ].
  1.1847 +    ].
  1.1848 +
  1.1849 +    relOrg  := aView originRelativeTo:aRootView.
  1.1850 +    bwWidth := aView borderWidth.
  1.1851 +    size    := theDamages size.
  1.1852 +
  1.1853 +    "/ compute relative origin starting from border left@top
  1.1854 +    relOrgX := relOrg x - bwWidth.
  1.1855 +    relOrgY := relOrg y - bwWidth.
  1.1856 +    width   := aView width  + bwWidth + bwWidth.
  1.1857 +    height  := aView height + bwWidth + bwWidth.
  1.1858 +
  1.1859 +    size to:1 by:-1 do:[:anIndex|
  1.1860 +        repaired := damage := theDamages at:anIndex.
  1.1861 +
  1.1862 +        "/ compute the rectangle into the view
  1.1863 +        y := damage top  - relOrgY.
  1.1864 +        x := damage left - relOrgX.
  1.1865 +        w := damage width.
  1.1866 +        h := damage height.
  1.1867 +
  1.1868 +        x     < 0      ifTrue:[ w := w + x. x := 0. repaired := nil ].
  1.1869 +        y     < 0      ifTrue:[ h := h + y. y := 0. repaired := nil ].
  1.1870 +        x + w > width  ifTrue:[ w := width  - x.    repaired := nil ].
  1.1871 +        y + h > height ifTrue:[ h := height - y.    repaired := nil ].
  1.1872 +
  1.1873 +        (w > 0 and:[h > 0]) ifTrue:[
  1.1874 +            bwWidth ~~ 0 ifTrue:[
  1.1875 +                color isNil ifTrue:[
  1.1876 +                    "/ must force redraw of border
  1.1877 +                    color := aView borderColor.
  1.1878 +                    aView borderColor:(Color colorId:1).
  1.1879 +                    aView borderColor:color.
  1.1880 +                ].
  1.1881 +                w := w - bwWidth.
  1.1882 +                h := h - bwWidth.
  1.1883 +
  1.1884 +                (x := x - bwWidth) < 0 ifTrue:[w := w + x. x := 0].
  1.1885 +                (y := y - bwWidth) < 0 ifTrue:[h := h + y. y := 0].
  1.1886 +
  1.1887 +                h > 0 ifFalse:[w := 0].         "/ later testing on width only
  1.1888 +            ].
  1.1889 +
  1.1890 +            w > 0 ifTrue:[
  1.1891 +                aView clearRectangleX:x y:y width:w height:h.
  1.1892 +                aView exposeX:x y:y width:w height:h
  1.1893 +            ].
  1.1894 +            repaired notNil ifTrue:[ theDamages removeFromIndex:anIndex toIndex:anIndex ].
  1.1895 +        ]
  1.1896 +    ].
  1.1897 +!
  1.1898 +
  1.1899 +redrawSelection
  1.1900 +    "redraw all items selected
  1.1901 +    "
  1.1902 +    |topView size|
  1.1903 +
  1.1904 +    testModeChannel value ifTrue:[ ^ self ]. "/ test whether running testMode
  1.1905 +
  1.1906 +    (     hiddenLevel == 0
  1.1907 +     and:[(size := selection size) > 0
  1.1908 +     and:[(topView := listOfItems rootView) notNil
  1.1909 +     and:[topView shown
  1.1910 +     and:[(topView sensor hasEvent:#redrawSelection for:self) not]]]]
  1.1911 +    ) ifFalse:[
  1.1912 +        ^ self
  1.1913 +    ].
  1.1914 +
  1.1915 +    lockSema critical:[
  1.1916 +        |list|
  1.1917 +
  1.1918 +        list := selection.
  1.1919 +
  1.1920 +        list size > 0 ifTrue:[
  1.1921 +            topView paint:(Color black).
  1.1922 +            topView clippedByChildren:false.
  1.1923 +
  1.1924 +            list keysAndValuesReverseDo:[:anIndex :anItem|
  1.1925 +                (anIndex == 1 and:[size > 1]) ifTrue:[ topView paint:(Color red) ].
  1.1926 +
  1.1927 +                anItem handlesDo:[:aRect :what|
  1.1928 +                    what isNil ifTrue:[topView displayRectangle:aRect]
  1.1929 +                              ifFalse:[topView    fillRectangle:aRect]
  1.1930 +                ]
  1.1931 +            ].
  1.1932 +            topView clippedByChildren:true.
  1.1933 +        ].
  1.1934 +    ].
  1.1935 +!
  1.1936 +
  1.1937 +redrawUnselected:aList andLock:doLock
  1.1938 +    "redraw all items unselected; if doLock is true, the hiddenLevel
  1.1939 +     is incremented and thus the select mechanism is locked.
  1.1940 +    "
  1.1941 +    self redrawUnselected:aList andLock:doLock checkTestMode:true.
  1.1942 +!
  1.1943 +
  1.1944 +redrawUnselected:aList andLock:doLock checkTestMode:checkTestMode
  1.1945 +    "redraw all items unselected; if doLock is true, the hiddenLevel
  1.1946 +     is incremented and thus the select mechanism is locked.
  1.1947 +    "
  1.1948 +    |rootView damages subViews x y w h|
  1.1949 +
  1.1950 +    doLock ifTrue:[
  1.1951 +        hiddenLevel := hiddenLevel + 1.
  1.1952 +        hiddenLevel ~~ 1 ifTrue:[^ self].
  1.1953 +    ] ifFalse:[
  1.1954 +        hiddenLevel ~~ 0 ifTrue:[^ self].
  1.1955 +    ].
  1.1956 +    checkTestMode ifTrue:[
  1.1957 +        testModeChannel value ifTrue:[ ^ self ]. "/ test whether running testMode
  1.1958 +    ].
  1.1959 +
  1.1960 +    (     aList size ~~ 0
  1.1961 +     and:[(rootView := listOfItems rootView) notNil
  1.1962 +     and:[rootView shown]]
  1.1963 +    ) ifFalse:[
  1.1964 +        ^ self
  1.1965 +    ].
  1.1966 +
  1.1967 +    lockSema critical:[
  1.1968 +        damages := OrderedCollection new:(8 * aList size).
  1.1969 +
  1.1970 +        aList do:[:item|
  1.1971 +            item handlesDo:[:handle :what|
  1.1972 +                damages reverseDo:[:el|
  1.1973 +                    (el intersects:handle) ifTrue:[
  1.1974 +                        damages removeIdentical:el.
  1.1975 +
  1.1976 +                        handle left:(handle left   min:el left)
  1.1977 +                              right:(handle right  max:el right)
  1.1978 +                                top:(handle top    min:el top)
  1.1979 +                             bottom:(handle bottom max:el bottom)
  1.1980 +                    ]
  1.1981 +                ].                        
  1.1982 +                damages add:handle
  1.1983 +            ]
  1.1984 +        ].
  1.1985 +
  1.1986 +        damages do:[:el|
  1.1987 +            x := el left.
  1.1988 +            y := el top.
  1.1989 +            w := el width.
  1.1990 +            h := el height.
  1.1991 +
  1.1992 +            rootView clearRectangleX:x y:y width:w height:h.
  1.1993 +            rootView         exposeX:x y:y width:w height:h.
  1.1994 +        ].
  1.1995 +
  1.1996 +        (subViews := rootView subViews) notNil ifTrue:[
  1.1997 +            subViews reverseDo:[:v| self recursiveRepair:damages startIn:v relativeTo:rootView ].
  1.1998 +        ].
  1.1999 +    ].
  1.2000 +! !
  1.2001 +
  1.2002 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'queries'!
  1.2003 +
  1.2004 +isInTestMode
  1.2005 +    "answer false, all input events are eaten and the selection is shown on the target view.
  1.2006 +     answer true,  no  input events are eaten and no  selection is shown on the target view."
  1.2007 +
  1.2008 +    ^ testModeChannel value
  1.2009 +! !
  1.2010 +
  1.2011 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection accessing'!
  1.2012 +
  1.2013 +at:anIndex
  1.2014 +    "returns the selected item at an index or nil
  1.2015 +    "
  1.2016 +    selection notNil ifTrue:[
  1.2017 +        ^ selection at:anIndex ifAbsent:nil
  1.2018 +    ].
  1.2019 +    ^ nil
  1.2020 +!
  1.2021 +
  1.2022 +at:anIndex ifAbsent:aBlock
  1.2023 +    "returns the selected item at an index or the result of the block
  1.2024 +    "
  1.2025 +    selection notNil ifTrue:[
  1.2026 +        ^ selection at:anIndex ifAbsent:aBlock
  1.2027 +    ].
  1.2028 +    ^ aBlock value
  1.2029 +!
  1.2030 +
  1.2031 +first
  1.2032 +    "returns the first selected item or nil
  1.2033 +    "
  1.2034 +    ^ self at:1
  1.2035 +!
  1.2036 +
  1.2037 +last
  1.2038 +    "returns the last selected item or nil
  1.2039 +    "
  1.2040 +    ^ selection notNil ifTrue:[selection last] ifFalse:[nil]
  1.2041 +!
  1.2042 +
  1.2043 +selectedItem
  1.2044 +    "returns the single selected item or nil (size ~~ 1 nil is returned)
  1.2045 +    "
  1.2046 +    ^ selection size == 1 ifTrue:[selection at:1] ifFalse:[nil]
  1.2047 +!
  1.2048 +
  1.2049 +selectedSuperItems
  1.2050 +    "returs the list of selected superItems; items selected
  1.2051 +     but not contained in another selected item.
  1.2052 +    "
  1.2053 +    ^ selectedSuperItems
  1.2054 +!
  1.2055 +
  1.2056 +size
  1.2057 +    "returns the number of items selected
  1.2058 +    "
  1.2059 +    ^ selection size
  1.2060 +! !
  1.2061 +
  1.2062 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection adding & removing'!
  1.2063 +
  1.2064 +add:item
  1.2065 +    "add an item to the current selection
  1.2066 +    "
  1.2067 +    |newSelect|
  1.2068 +
  1.2069 +    item isNil ifTrue:[^ item].
  1.2070 +
  1.2071 +    lockSema critical:[
  1.2072 +        selection isNil ifTrue:[
  1.2073 +            newSelect := Array with:item.
  1.2074 +        ] ifFalse:[
  1.2075 +            (self includes:item) ifFalse:[
  1.2076 +                newSelect := selection copyWith:item
  1.2077 +            ]
  1.2078 +        ].
  1.2079 +
  1.2080 +        newSelect size ~~ selection size ifTrue:[
  1.2081 +            item makeVisible.
  1.2082 +            self value:newSelect
  1.2083 +        ]
  1.2084 +    ].
  1.2085 +    ^ item
  1.2086 +!
  1.2087 +
  1.2088 +addAll:aCollectionOfItems
  1.2089 +    "add a collection of items to the current selection
  1.2090 +    "
  1.2091 +    |newSelect|
  1.2092 +
  1.2093 +    aCollectionOfItems size == 0 ifTrue:[ ^ aCollectionOfItems ].
  1.2094 +
  1.2095 +    lockSema critical:[
  1.2096 +        selection isNil ifTrue:[
  1.2097 +            newSelect := Array withAll:aCollectionOfItems.
  1.2098 +        ] ifFalse:[
  1.2099 +            newSelect := OrderedCollection withAll:selection.
  1.2100 +
  1.2101 +            aCollectionOfItems do:[:el|
  1.2102 +                (selection includesIdentical:el) ifFalse:[newSelect add:el]
  1.2103 +            ].
  1.2104 +        ].
  1.2105 +        self value:newSelect.
  1.2106 +    ].
  1.2107 +    ^ aCollectionOfItems
  1.2108 +!
  1.2109 +
  1.2110 +deselect
  1.2111 +    "clear the selection
  1.2112 +    "
  1.2113 +    self value:nil.
  1.2114 +!
  1.2115 +
  1.2116 +remove:item
  1.2117 +    "remove the item from the current selection
  1.2118 +    "
  1.2119 +    |newSelect|
  1.2120 +
  1.2121 +    item isNil ifTrue:[^ nil].
  1.2122 +
  1.2123 +    lockSema critical:[
  1.2124 +        (selection notNil and:[selection includesIdentical:item]) ifTrue:[
  1.2125 +            selection size == 1 ifTrue:[ newSelect := nil ]
  1.2126 +                               ifFalse:[ newSelect := selection copyWithout:item ].
  1.2127 +
  1.2128 +            self value:newSelect
  1.2129 +        ].
  1.2130 +    ].
  1.2131 +    ^ item
  1.2132 +!
  1.2133 +
  1.2134 +removeAll
  1.2135 +    "clear the selection
  1.2136 +    "
  1.2137 +    self deselect.
  1.2138 +!
  1.2139 +
  1.2140 +removeAll:loItems
  1.2141 +    "remove all items of the collection from the current selection
  1.2142 +    "
  1.2143 +    |newSelect|
  1.2144 +
  1.2145 +    selection   isNil ifTrue:[ ^ loItems ].
  1.2146 +    loItems size == 0 ifTrue:[ ^ loItems ].
  1.2147 +
  1.2148 +    lockSema critical:[
  1.2149 +        selection notNil ifTrue:[
  1.2150 +            newSelect := selection select:[:el| (loItems includesIdentical:el) not ].
  1.2151 +            self value:newSelect.
  1.2152 +        ]
  1.2153 +    ].
  1.2154 +    ^ loItems
  1.2155 +!
  1.2156 +
  1.2157 +selectAll
  1.2158 +    "select all items
  1.2159 +    "
  1.2160 +    |root newSelection|
  1.2161 +
  1.2162 +    root := listOfItems root.
  1.2163 +
  1.2164 +    root isNil ifTrue:[
  1.2165 +        newSelection := nil
  1.2166 +    ] ifFalse:[
  1.2167 +        newSelection := OrderedCollection new.
  1.2168 +        root recursiveDo:[:el| newSelection add:el ].
  1.2169 +    ].
  1.2170 +    self value:newSelection.
  1.2171 +!
  1.2172 +
  1.2173 +selectItem:anItem
  1.2174 +    "set the current selection to the item
  1.2175 +    "
  1.2176 +    self value:anItem
  1.2177 +!
  1.2178 +
  1.2179 +selectRootItem
  1.2180 +    "set the current selection to the root item
  1.2181 +    "
  1.2182 +    self value:(self rootItem).
  1.2183 +!
  1.2184 +
  1.2185 +selectedItem:anItem
  1.2186 +    "set the current selection to the item
  1.2187 +    "
  1.2188 +    self selectItem:anItem.
  1.2189 +!
  1.2190 +
  1.2191 +toggleSelectItem:anItem
  1.2192 +    "toggle selection-state of the item; add or remove the item from the
  1.2193 +     current selection.
  1.2194 +    "
  1.2195 +    anItem notNil ifTrue:[
  1.2196 +        (self includes:anItem) ifTrue:[self remove:anItem]
  1.2197 +                              ifFalse:[self add:anItem]
  1.2198 +    ].
  1.2199 +    ^ anItem
  1.2200 +! !
  1.2201 +
  1.2202 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection enumerating'!
  1.2203 +
  1.2204 +collect:aBlock
  1.2205 +    "for each element in the selection, evaluate the argument, aBlock
  1.2206 +     and return a new collection with the results
  1.2207 +    "
  1.2208 +    |res|
  1.2209 +
  1.2210 +    res := OrderedCollection new.
  1.2211 +    self do:[:el| res add:(aBlock value:el)].
  1.2212 +  ^ res
  1.2213 +!
  1.2214 +
  1.2215 +do:aOneArgBlock
  1.2216 +    "evaluate the argument, aBlock for each item in the selection
  1.2217 +    "
  1.2218 +    |cashedSelection|
  1.2219 +
  1.2220 +    cashedSelection := selection.
  1.2221 +    cashedSelection isNil ifTrue:[^ nil].
  1.2222 +  ^ cashedSelection do:aOneArgBlock
  1.2223 +!
  1.2224 +
  1.2225 +from:start do:aOneArgBlock
  1.2226 +    "evaluate the argument, aBlock for the items starting at index start
  1.2227 +    "
  1.2228 +    |cashedSelection|
  1.2229 +
  1.2230 +    cashedSelection := selection.
  1.2231 +    cashedSelection isNil ifTrue:[^ nil].
  1.2232 +  ^ cashedSelection from:start do:aOneArgBlock
  1.2233 +!
  1.2234 +
  1.2235 +from:start to:stop do:aOneArgBlock
  1.2236 +    "evaluate the argument, aBlock for the items with index start to
  1.2237 +     stop in the selection.
  1.2238 +    "
  1.2239 +    |cashedSelection|
  1.2240 +
  1.2241 +    cashedSelection := selection.
  1.2242 +    cashedSelection isNil ifTrue:[^ nil].
  1.2243 +  ^ cashedSelection from:start to:stop do:aOneArgBlock
  1.2244 +!
  1.2245 +
  1.2246 +reverseDo:aOneArgBlock
  1.2247 +    "evaluate the argument, aBlock for each item in the selection
  1.2248 +    "
  1.2249 +    |cashedSelection|
  1.2250 +
  1.2251 +    cashedSelection := selection.
  1.2252 +    cashedSelection isNil ifTrue:[^ nil].
  1.2253 +  ^ cashedSelection reverseDo:aOneArgBlock
  1.2254 +!
  1.2255 +
  1.2256 +select:aBlock
  1.2257 +    "return a new collection with all elements from the selection, for which
  1.2258 +     the argument aBlock evaluates to true.
  1.2259 +    "
  1.2260 +    |res|
  1.2261 +
  1.2262 +    res := OrderedCollection new.
  1.2263 +    self do:[:el| (aBlock value:el) ifTrue:[res add:el] ].
  1.2264 +  ^ res
  1.2265 +! !
  1.2266 +
  1.2267 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection protocol'!
  1.2268 +
  1.2269 +changed:aParameter with:oldSelection
  1.2270 +    "update the visibility staus of the current selection
  1.2271 +    "
  1.2272 +    |unselected rootView rootItem selSize|
  1.2273 +
  1.2274 +    selSize := selection size.
  1.2275 +
  1.2276 +    selSize == 0 ifTrue:[
  1.2277 +        selectedSuperItems := #().
  1.2278 +    ] ifFalse:[
  1.2279 +        selSize == 1 ifTrue:[
  1.2280 +            selectedSuperItems := Array with:(selection at:1).
  1.2281 +        ] ifFalse:[
  1.2282 +            rootItem := listOfItems root.
  1.2283 +
  1.2284 +            (selection includesIdentical:rootItem) ifTrue:[
  1.2285 +                selectedSuperItems := Array with:rootItem.
  1.2286 +            ] ifFalse:[
  1.2287 +                selectedSuperItems := OrderedCollection new:selSize.
  1.2288 +
  1.2289 +                selection do:[:anItem|
  1.2290 +                    anItem parentsDetect:[:el| selection includesIdentical:el ]
  1.2291 +                                  ifNone:[ selectedSuperItems add:anItem ].
  1.2292 +                ].
  1.2293 +            ]
  1.2294 +        ]
  1.2295 +    ].
  1.2296 +
  1.2297 +    (     hiddenLevel == 0
  1.2298 +     and:[(rootView := listOfItems rootView) notNil
  1.2299 +     and:[rootView shown]]
  1.2300 +    ) ifTrue:[
  1.2301 +        selSize == 0 ifTrue:[
  1.2302 +            "/ must redraw the old selection unselected
  1.2303 +            self redrawUnselected:oldSelection andLock:false
  1.2304 +        ] ifFalse:[
  1.2305 +            self invalidateSelection.
  1.2306 +
  1.2307 +            oldSelection size ~~ 0 ifTrue:[
  1.2308 +                "/ must redraw all elements no longer in the selection
  1.2309 +                unselected := oldSelection select:[:el| (selection includesIdentical:el) not ].
  1.2310 +                self redrawUnselected:unselected andLock:false.
  1.2311 +            ]
  1.2312 +        ]
  1.2313 +    ].
  1.2314 +    super changed:aParameter with:oldSelection.
  1.2315 +!
  1.2316 +
  1.2317 +setValue:aNewSelection 
  1.2318 +    "set the selection without notifying
  1.2319 +    "
  1.2320 +    |newSelect idx|
  1.2321 +
  1.2322 +    newSelect := nil.
  1.2323 +
  1.2324 +    aNewSelection notNil ifTrue:[
  1.2325 +        lockSema critical:[
  1.2326 +            aNewSelection isCollection ifFalse:[
  1.2327 +                (selection size == 1 and:[selection first == aNewSelection]) ifTrue:[
  1.2328 +                    newSelect := selection
  1.2329 +                ] ifFalse:[
  1.2330 +                    newSelect := Array with:aNewSelection.
  1.2331 +                ]
  1.2332 +            ] ifTrue:[
  1.2333 +                aNewSelection notEmpty ifTrue:[
  1.2334 +                    aNewSelection size ~~ selection size ifTrue:[
  1.2335 +                        newSelect := aNewSelection copy.
  1.2336 +                    ] ifFalse:[
  1.2337 +                        idx := selection findFirst:[:el| (aNewSelection includesIdentical:el) not ].
  1.2338 +
  1.2339 +                        idx ~~ 0 ifTrue:[newSelect := aNewSelection copy]
  1.2340 +                                ifFalse:[newSelect := selection ].
  1.2341 +                    ]
  1.2342 +                ]
  1.2343 +            ]
  1.2344 +        ].
  1.2345 +    ].
  1.2346 +    newSelect ~~ selection ifTrue:[
  1.2347 +        beforeSelectionChangedAction value.
  1.2348 +        selection := newSelect.
  1.2349 +        selection notNil ifTrue:[selection do:[:el| el makeVisible]]
  1.2350 +    ].
  1.2351 +!
  1.2352 +
  1.2353 +triggerValue:aValue
  1.2354 +    "set my value & send change notifications to my dependents.
  1.2355 +     Send the change message even if the value didn't change.
  1.2356 +    "
  1.2357 +    |oldSelection|
  1.2358 +
  1.2359 +    lockSema critical:[
  1.2360 +        oldSelection := selection.
  1.2361 +        self setValue:aValue.
  1.2362 +        self changed:#value with:oldSelection
  1.2363 +    ]
  1.2364 +!
  1.2365 +
  1.2366 +value
  1.2367 +    "returns the current selection
  1.2368 +    "
  1.2369 +    ^ selection ? #()
  1.2370 +!
  1.2371 +
  1.2372 +value:aValue
  1.2373 +    "change the current selection and send change notifications to my
  1.2374 +     dependents if it changed.
  1.2375 +    "
  1.2376 +    |oldSelection|
  1.2377 +
  1.2378 +    lockSema critical:[
  1.2379 +        oldSelection := selection.
  1.2380 +        self setValue:aValue.
  1.2381 +
  1.2382 +        oldSelection == selection ifFalse:[
  1.2383 +            self changed:#value with:oldSelection
  1.2384 +        ]
  1.2385 +    ].
  1.2386 +! !
  1.2387 +
  1.2388 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection searching'!
  1.2389 +
  1.2390 +detect:aBlock
  1.2391 +    "evaluate the argument, aBlock for each item in the selection until
  1.2392 +     the block returns true; in this case return the element which caused
  1.2393 +     the true evaluation.
  1.2394 +     If none of the evaluations returns true, an error is raised
  1.2395 +    "
  1.2396 +    ^ self detect:aBlock ifNone:[self errorNotFound]
  1.2397 +!
  1.2398 +
  1.2399 +detect:aBlock ifNone:exceptionBlock
  1.2400 +    "evaluate the argument, aBlock for each item in the selection until the
  1.2401 +     block returns true; in this case return the element which caused the
  1.2402 +     true evaluation.
  1.2403 +     If none of the evaluations returns true, the result of the evaluation
  1.2404 +     of the exceptionBlock is returned
  1.2405 +    "
  1.2406 +    |cashedSelection|
  1.2407 +
  1.2408 +    cashedSelection := selection.
  1.2409 +    cashedSelection isNil ifTrue:[ ^ exceptionBlock value ].
  1.2410 +  ^ cashedSelection detect:aBlock ifNone:exceptionBlock
  1.2411 +!
  1.2412 +
  1.2413 +detectLast:aBlock
  1.2414 +    "evaluate the argument, aBlock for each item in the selection until
  1.2415 +     the block returns true; in this case return the element which caused
  1.2416 +     the true evaluation. The items are processed in reverse order.
  1.2417 +     If none of the evaluations returns true, an error is raised
  1.2418 +    "
  1.2419 +    ^ self detectLast:aBlock ifNone:[self errorNotFound]
  1.2420 +!
  1.2421 +
  1.2422 +detectLast:aBlock ifNone:exceptionBlock
  1.2423 +    "evaluate the argument, aBlock for each item in the selection until
  1.2424 +     the block returns true; in this case return the element which caused
  1.2425 +     the true evaluation. The items are processed in reverse order.
  1.2426 +     If none of the evaluations returns true, the result of the evaluation
  1.2427 +     of the exceptionBlock is returned
  1.2428 +    "
  1.2429 +    |cashedSelection|
  1.2430 +
  1.2431 +    cashedSelection := selection.
  1.2432 +    cashedSelection isNil ifTrue:[ ^ exceptionBlock value ].
  1.2433 +  ^ cashedSelection detectLast:aBlock ifNone:exceptionBlock
  1.2434 +! !
  1.2435 +
  1.2436 +!ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection testing'!
  1.2437 +
  1.2438 +includes:anItem
  1.2439 +    "returns true if the item is in the current selection
  1.2440 +    "
  1.2441 +    |cashedSelection|
  1.2442 +
  1.2443 +    cashedSelection := selection.
  1.2444 +    cashedSelection isNil ifTrue:[^ false].
  1.2445 + ^  cashedSelection includesIdentical:anItem
  1.2446 +!
  1.2447 +
  1.2448 +includesAll:aCollection
  1.2449 +    "return true, if all items of the collection are included in the current selection
  1.2450 +    "
  1.2451 +    |cashedSelection|
  1.2452 +
  1.2453 +    aCollection size ~~ 0 ifTrue:[
  1.2454 +        cashedSelection := selection.
  1.2455 +        cashedSelection isNil ifTrue:[ ^ false ].
  1.2456 +
  1.2457 +        aCollection do:[:el|
  1.2458 +            (cashedSelection includesIdentical:el) ifFalse:[^ false]
  1.2459 +        ]
  1.2460 +    ].
  1.2461 +    ^ true
  1.2462 +!
  1.2463 +
  1.2464 +includesAny:aCollection
  1.2465 +    "return true, if the any item of the collection is in the current selection
  1.2466 +    "
  1.2467 +    |cashedSelection|
  1.2468 +
  1.2469 +    aCollection notNil ifTrue:[
  1.2470 +        cashedSelection := selection.
  1.2471 +
  1.2472 +        cashedSelection notNil ifTrue:[
  1.2473 +            aCollection do:[:el|
  1.2474 +                (cashedSelection includesIdentical:el) ifTrue:[^ true]
  1.2475 +            ]
  1.2476 +        ]
  1.2477 +    ].
  1.2478 +    ^ false
  1.2479 +!
  1.2480 +
  1.2481 +includesIdentical:anItem
  1.2482 +    "returns true if the item is in the current selection
  1.2483 +    "
  1.2484 +    ^ self includes:anItem
  1.2485 +!
  1.2486 +
  1.2487 +isEmpty
  1.2488 +    "returns true if the current selection is empty
  1.2489 +    "
  1.2490 +    ^ selection size == 0
  1.2491 +!
  1.2492 +
  1.2493 +isSelected:anItem
  1.2494 +    "returns true if the item is in the current selection
  1.2495 +    "
  1.2496 +    ^ self includes:anItem
  1.2497 +!
  1.2498 +
  1.2499 +notEmpty
  1.2500 +    "returns true if the current selection is not empty
  1.2501 +    "
  1.2502 +    ^ selection size ~~ 0
  1.2503 +! !
  1.2504 +
  1.2505 +!ViewTreeInspectorApplication::ViewTreeModel::ItemList class methodsFor:'documentation'!
  1.2506 +
  1.2507 +documentation
  1.2508 +"
  1.2509 +    Kind of HierarchicalList class which contains all the visible
  1.2510 +    ViewTreeItem's and the root, the anchor of the hierarchical list.
  1.2511 +
  1.2512 +    [Instance variables:]
  1.2513 +        treeModel       <ViewTreeModel>         all events are delegated to
  1.2514 +        eventHook       <BlockValue>            save and resore the pre/post -EventHook
  1.2515 +
  1.2516 +
  1.2517 +    [author:]
  1.2518 +        Claus Atzkern
  1.2519 +
  1.2520 +    [see also:]
  1.2521 +        HierarchicalList
  1.2522 +        ViewTreeModel
  1.2523 +        ViewTreeItem
  1.2524 +"
  1.2525 +! !
  1.2526 +
  1.2527 +!ViewTreeInspectorApplication::ViewTreeModel::ItemList methodsFor:'accessing'!
  1.2528 +
  1.2529 +root:theRoot
  1.2530 +    "set the root item; delegate events to my treeModel
  1.2531 +    "
  1.2532 +    |rootView|
  1.2533 +
  1.2534 +    theRoot == root ifTrue:[^ self].
  1.2535 +
  1.2536 +    rootView := self rootView.
  1.2537 +    super root:theRoot.
  1.2538 +
  1.2539 +    rootView notNil ifTrue:[ |wgrp|
  1.2540 +        wgrp := rootView windowGroup.
  1.2541 +
  1.2542 +        wgrp notNil ifTrue:[
  1.2543 +           wgrp removePreEventHook:treeModel.
  1.2544 +           wgrp removePostEventHook:self.
  1.2545 +        ].
  1.2546 +    ].
  1.2547 +
  1.2548 +    super root:theRoot.
  1.2549 +    rootView := self rootView.
  1.2550 +
  1.2551 +    rootView notNil ifTrue:[
  1.2552 +        "must setup a task because there might not exist a windowGroup at the moment
  1.2553 +        "
  1.2554 +        [   |wgrp|
  1.2555 +
  1.2556 +            [rootView == self rootView] whileTrue:[
  1.2557 +                wgrp := rootView windowGroup.
  1.2558 +                wgrp notNil ifTrue:[
  1.2559 +                    rootView := nil.
  1.2560 +                    wgrp addPreEventHook:treeModel.
  1.2561 +                    wgrp addPostEventHook:self.
  1.2562 +                ] ifFalse:[
  1.2563 +                    Delay waitForMilliseconds:100.
  1.2564 +                ].
  1.2565 +            ].
  1.2566 +
  1.2567 +        ] forkAt:(Processor userSchedulingPriority + 2).
  1.2568 +    ].
  1.2569 +    treeModel notNil ifTrue:[
  1.2570 +        treeModel targetWidgetChanged.
  1.2571 +    ].
  1.2572 +    
  1.2573 +    ^ root.
  1.2574 +!
  1.2575 +
  1.2576 +rootView
  1.2577 +    "returns the widget assigned to the root or nil
  1.2578 +    "
  1.2579 +    ^ root notNil ifTrue:[root widget] ifFalse:[nil]
  1.2580 +!
  1.2581 +
  1.2582 +treeModel
  1.2583 +    "returne the treeModel, a ViewTreeModel
  1.2584 +    "
  1.2585 +    ^ treeModel
  1.2586 +! !
  1.2587 +
  1.2588 +!ViewTreeInspectorApplication::ViewTreeModel::ItemList methodsFor:'accessing look'!
  1.2589 +
  1.2590 +additionalLabelForItem:anItem
  1.2591 +    "answer the additional lable for an item or nil"
  1.2592 +
  1.2593 +    |applClass|
  1.2594 +
  1.2595 +    showWidgetNames == true ifTrue:[
  1.2596 +        ^ '[', anItem widget name, ']'
  1.2597 +    ].
  1.2598 +
  1.2599 +    anItem isApplicationClass ifTrue:[
  1.2600 +        applClass := anItem applicationClass.
  1.2601 +
  1.2602 +        applClass notNil ifTrue:[
  1.2603 +            ^ ('[', applClass name, ']')
  1.2604 +        ].
  1.2605 +    ].
  1.2606 +    ^ nil
  1.2607 +!
  1.2608 +
  1.2609 +showWidgetNames
  1.2610 +    "answer true if the additional text is the widget name
  1.2611 +     otherwise the name of the application"
  1.2612 +
  1.2613 +    ^ showWidgetNames ? false
  1.2614 +!
  1.2615 +
  1.2616 +showWidgetNames:aBoolean
  1.2617 +    "set true if the additional text is the widget name
  1.2618 +     otherwise the name of the application"
  1.2619 +
  1.2620 +    self showWidgetNames == aBoolean ifFalse:[
  1.2621 +        showWidgetNames := aBoolean.
  1.2622 +
  1.2623 +        root notNil ifTrue:[
  1.2624 +            root recursiveAdditionalNameBehaviourChanged.
  1.2625 +            self changed.
  1.2626 +        ].
  1.2627 +    ].
  1.2628 +! !
  1.2629 +
  1.2630 +!ViewTreeInspectorApplication::ViewTreeModel::ItemList methodsFor:'event processing'!
  1.2631 +
  1.2632 +processEvent:anEvent
  1.2633 +    "post process event
  1.2634 +    "
  1.2635 +    ^ treeModel isInTestMode not
  1.2636 +! !
  1.2637 +
  1.2638 +!ViewTreeInspectorApplication::ViewTreeModel::ItemList methodsFor:'instance creation'!
  1.2639 +
  1.2640 +on:aModel
  1.2641 +    "set the model, a ViewTreeModel
  1.2642 +    "
  1.2643 +    treeModel := aModel.
  1.2644 +    showRoot  := true.
  1.2645 +    showWidgetNames := false.
  1.2646 +! !
  1.2647 +
  1.2648 +!ViewTreeInspectorApplication::ViewTreeModel::ItemList methodsFor:'searching'!
  1.2649 +
  1.2650 +detectItemRespondsToView:aView
  1.2651 +    "returns the bottom-most item which contains the view
  1.2652 +    "
  1.2653 +    |view item topView|
  1.2654 +
  1.2655 +    root notNil ifTrue:[
  1.2656 +        view    := aView.
  1.2657 +        topView := root widget.
  1.2658 +
  1.2659 +        [ view notNil ] whileTrue:[
  1.2660 +            topView == view ifTrue:[^ root].
  1.2661 +            item := root recursiveDetect:[:el| el widget == view ].
  1.2662 +            item notNil ifTrue:[^ item].
  1.2663 +            view := view superView
  1.2664 +        ]
  1.2665 +    ].
  1.2666 +    ^ nil
  1.2667 +!
  1.2668 +
  1.2669 +recursiveDetect:aOneOrgBlock
  1.2670 +    "recursive find the first child, for which evaluation 
  1.2671 +     of the block returns true; if none nil is returned
  1.2672 +    "
  1.2673 +    root notNil ifTrue:[
  1.2674 +        (aOneOrgBlock value:root) ifTrue:[ ^ root ].
  1.2675 +      ^ root recursiveDetect:aOneOrgBlock
  1.2676 +    ].
  1.2677 +    ^ nil
  1.2678 +! !
  1.2679 +
  1.2680 +!ViewTreeInspectorApplication class methodsFor:'documentation'!
  1.2681 +
  1.2682 +version
  1.2683 +    ^ '$Header$'
  1.2684 +!
  1.2685 +
  1.2686 +version_CVS
  1.2687 +    ^ '$Header$'
  1.2688 +! !
  1.2689 +
  1.2690 +ViewTreeInspectorApplication initialize!
  1.2691 +ViewTreeInspectorApplication::ViewTreeItem initialize!