Tools__ViewTreeApplication.st
author Claus Gittinger <cg@exept.de>
Sun, 15 Feb 2015 10:54:55 +0100
changeset 3185 3592ea3afb9e
parent 3184 7ff3f8fb0b79
child 3186 80a20e5881a5
permissions -rw-r--r--
class: Tools::ViewTreeInspectorApplication
removed:
#pickWindowIcon
#pickWindowIcon2
changed:
#crossHairIcon
#toolbarMenu
cg@2748
     1
"
cg@2748
     2
 COPYRIGHT (c) 2007 by eXept Software AG
cg@2748
     3
              All Rights Reserved
cg@2748
     4
cg@2748
     5
 This software is furnished under a license and may be used
cg@2748
     6
 only in accordance with the terms of that license and with the
cg@2748
     7
 inclusion of the above copyright notice.   This software may not
cg@2748
     8
 be provided or otherwise made available to, or used by, any
cg@2748
     9
 other person.  No title to or ownership of the software is
cg@2748
    10
 hereby transferred.
cg@2748
    11
"
ca@2177
    12
"{ Package: 'stx:libtool2' }"
ca@2177
    13
ca@2177
    14
"{ NameSpace: Tools }"
ca@2177
    15
cg@2744
    16
ToolApplicationModel subclass:#ViewTreeInspectorApplication
ca@2177
    17
	instanceVariableNames:'model treeView hasSingleSelectionHolder clickedItem clickedPoint
cg@2770
    18
		motionAction process followFocusChannel showNamesHolder
cg@3124
    19
		inspectorView inspectorModeIndexHolder path
cg@3124
    20
		isCatchingEventsChannel'
ca@2177
    21
	classVariableNames:''
ca@2177
    22
	poolDictionaries:''
cg@2744
    23
	category:'Interface-Smalltalk'
ca@2177
    24
!
ca@2177
    25
ca@2177
    26
Object subclass:#MenuDesc
ca@2177
    27
	instanceVariableNames:'title value action'
ca@2177
    28
	classVariableNames:''
ca@2177
    29
	poolDictionaries:''
cg@2744
    30
	privateIn:ViewTreeInspectorApplication
ca@2177
    31
!
ca@2177
    32
cg@2744
    33
HierarchicalItem subclass:#ViewTreeItem
cg@2744
    34
	instanceVariableNames:'widget isDrawnShown exists xOffsetAdditionalName'
cg@2744
    35
	classVariableNames:'HandleExtent'
cg@2744
    36
	poolDictionaries:''
cg@2744
    37
	privateIn:ViewTreeInspectorApplication
cg@2744
    38
!
cg@2744
    39
cg@2744
    40
ValueModel subclass:#ViewTreeModel
cg@2744
    41
	instanceVariableNames:'lockSema selectedSuperItems selection hiddenLevel listOfItems
cg@2744
    42
		inputEventAction mappedViewAction beforeSelectionChangedAction
cg@2744
    43
		icons timedUpdateTask selectOnClickHolder testModeChannel
cg@2978
    44
		hasTargetWidgetChannel catchEvents'
cg@2744
    45
	classVariableNames:''
cg@2744
    46
	poolDictionaries:''
cg@2744
    47
	privateIn:ViewTreeInspectorApplication
cg@2744
    48
!
cg@2744
    49
cg@2744
    50
HierarchicalList subclass:#ItemList
cg@2744
    51
	instanceVariableNames:'treeModel eventHook eventHookInitialized showWidgetNames'
cg@2744
    52
	classVariableNames:''
cg@2744
    53
	poolDictionaries:''
cg@2744
    54
	privateIn:ViewTreeInspectorApplication::ViewTreeModel
cg@2744
    55
!
cg@2744
    56
cg@2744
    57
!ViewTreeInspectorApplication class methodsFor:'documentation'!
ca@2177
    58
cg@2748
    59
copyright
cg@2748
    60
"
cg@2748
    61
 COPYRIGHT (c) 2007 by eXept Software AG
cg@2748
    62
              All Rights Reserved
cg@2748
    63
cg@2748
    64
 This software is furnished under a license and may be used
cg@2748
    65
 only in accordance with the terms of that license and with the
cg@2748
    66
 inclusion of the above copyright notice.   This software may not
cg@2748
    67
 be provided or otherwise made available to, or used by, any
cg@2748
    68
 other person.  No title to or ownership of the software is
cg@2748
    69
 hereby transferred.
cg@2748
    70
"
cg@2748
    71
!
cg@2748
    72
ca@2177
    73
documentation
ca@2177
    74
"
ca@2177
    75
     Small application showing a ViewTreeModel use.
ca@2177
    76
ca@2177
    77
     It displays a hierarchical list of a selected TopView and
ca@2177
    78
     all its contained subViews.
ca@2177
    79
     Useful to have a look at subcomponents - to see how views
ca@2177
    80
     are structured.
ca@2177
    81
ca@2177
    82
ca@2177
    83
    [Instance variables:]
ca@2177
    84
        model           <ViewTreeModel>      the used ViewTreeModel
ca@2177
    85
        clickedItem     <ViewTreeItem>       item under the clickedPoint (motion action)
ca@2177
    86
        clickedPoint    <Point>              point where the motion action started from.
ca@2177
    87
        motionAction    <Action>             (oneArg-) action called durring buttonMotion.
ca@2177
    88
ca@2177
    89
ca@2177
    90
    [author:]
ca@2177
    91
        Claus Atzkern
ca@2177
    92
ca@2177
    93
    [see also:]
ca@2177
    94
        ViewTreeModel
ca@2177
    95
        ViewTreeItem
ca@2177
    96
"
ca@2177
    97
! !
ca@2177
    98
cg@2744
    99
!ViewTreeInspectorApplication class methodsFor:'initialization'!
ca@2177
   100
ca@2177
   101
initialize
ca@2177
   102
    "add myself to the launcher menu
ca@2177
   103
    "
ca@2177
   104
    self installInLauncher.
ca@2177
   105
!
ca@2177
   106
ca@2177
   107
installInLauncher
cg@2744
   108
    "add myself to the launcher menu"
cg@2744
   109
ca@2177
   110
    |menuItem icon|
ca@2177
   111
ca@2177
   112
    NewLauncher isNil ifTrue:[^ self].
cg@2744
   113
    "/ cg - disabled. the icon is too ugly.
cg@2744
   114
    ^ self.
ca@2177
   115
ca@2177
   116
    icon := ToolbarIconLibrary inspectLocals20x20Icon magnifiedTo:28@28.
ca@2177
   117
ca@2177
   118
    menuItem := MenuItem new 
cg@2744
   119
                    label: 'View Tree Inspector';
cg@2744
   120
                    value: [ ViewTreeInspectorApplication open];
ca@2177
   121
                    isButton: true;
ca@2177
   122
                    icon: icon;
ca@2177
   123
                    nameKey: #viewInspect.
ca@2177
   124
ca@2177
   125
    menuItem startGroup:#right.
ca@2177
   126
    NewLauncher addMenuItem:menuItem in:'toolbar'
ca@2177
   127
                   position:#( #before #help)
ca@2177
   128
                      space:false.
ca@2177
   129
ca@2177
   130
"
ca@2177
   131
self installInLauncher
ca@2177
   132
self removeFromLauncher
ca@2177
   133
"
ca@2177
   134
!
ca@2177
   135
ca@2177
   136
postAutoload
ca@2177
   137
    "add myself to the launcher menu
ca@2177
   138
    "
ca@2177
   139
    self installInLauncher.
ca@2177
   140
"
ca@2177
   141
self installInLauncher
ca@2177
   142
self removeFromLauncher
ca@2177
   143
"
ca@2177
   144
!
ca@2177
   145
ca@2177
   146
removeFromLauncher
ca@2177
   147
    "remove myself from the launcher menu
ca@2177
   148
    "
ca@2177
   149
    NewLauncher isNil ifTrue:[^ self].
ca@2177
   150
    NewLauncher removeUserTool:#viewInspect
ca@2177
   151
ca@2177
   152
"
ca@2177
   153
self installInLauncher
ca@2177
   154
self removeFromLauncher
ca@2177
   155
"
ca@2177
   156
!
ca@2177
   157
ca@2177
   158
unload
ca@2177
   159
    "class is about to be unloaded - remove myself from the launcher menu
ca@2177
   160
    "
ca@2177
   161
    self removeFromLauncher.
ca@2177
   162
    super unload.
ca@2177
   163
! !
ca@2177
   164
cg@3070
   165
!ViewTreeInspectorApplication class methodsFor:'help specs'!
cg@3070
   166
cg@3070
   167
flyByHelpSpec
cg@3070
   168
    <resource: #help>
cg@3070
   169
cg@3070
   170
    ^super flyByHelpSpec addPairsFrom:#(
cg@3070
   171
cg@3070
   172
#doUncatchEvents
cg@3124
   173
'Release picked view and uncatch events\(currently locked for widget selection)'  
cg@3070
   174
cg@3070
   175
#doCatchEvents
cg@3124
   176
'Lock view and catch events for widget selection\(currently unlocked)'  
cg@3070
   177
cg@3070
   178
)
cg@3070
   179
! !
cg@3070
   180
cg@2744
   181
!ViewTreeInspectorApplication class methodsFor:'image specs'!
cg@2744
   182
cg@2759
   183
crossHairIcon
cg@3185
   184
    ^ ToolbarIconLibrary bigCrossHairIcon
cg@2759
   185
!
cg@2759
   186
cg@3070
   187
lockViewIcon
cg@3070
   188
    "This resource specification was automatically generated
cg@3070
   189
     by the ImageEditor of ST/X."
cg@3070
   190
cg@3070
   191
    "Do not manually edit this!! If it is corrupted,
cg@3070
   192
     the ImageEditor may not be able to read the specification."
cg@3070
   193
cg@3070
   194
    "
cg@3070
   195
     self lockViewIcon inspect
cg@3070
   196
     ImageEditor openOnClass:self andSelector:#lockViewIcon
cg@3070
   197
     Icon flushCachedIcons
cg@3070
   198
    "
cg@3070
   199
cg@3070
   200
    <resource: #image>
cg@3070
   201
cg@3070
   202
    ^Icon
cg@3070
   203
        constantNamed:'Tools::ViewTreeInspectorApplication lockViewIcon'
cg@3070
   204
        ifAbsentPut:[(Depth8Image new) width: 24; height: 24; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
cg@3070
   205
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
cg@3070
   206
@@@@@@@@@@@@@@A8^G!!7O3ACP5*P@@A8^G @@@@@@@@@@@A8^@@@OE0/!!P0S#0@@^G @@@@@@@@@@@B (@D''D#48"1.CX5H@(J@@@@@@@@@@@@B (B(>SAT"
cg@3070
   207
''%!!/P7,@(J@@@@@@@@@@@@@%IB0#M"H%IRTQV5P@IRT@@@@@@@@@@@ANSX:U]PANS$8:T80@S$8@@@@@@@@@@@AN&UYWK(EYQ@\FUPQHXT8@@@@@@@@@@@AN
cg@3070
   208
HC2!!TVY:Y#-%I*IKMD8@@@@@@@@@@@A$\@83XBEG%).GGX _!!&P@@@@@@@@@@@AO[P5+ &(WPYN@["!!E\$<@@@@@@@@@@@B_F''FQPAXX_!!&TGH4HB9<@@@@@
cg@3070
   209
@@@@@@B_%3HCJ7=BKPU,Q)01B9<@@@@@@@@@@@@PBP8T_F!!''JPI)_Y"D&!!@@@@@@@@@@@@@$B)I9TGXO''WQIWQ93W0@@@@@@@@@@@@@$"U=JR$)JR$)JR$)_
cg@3070
   210
"P@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
cg@3070
   211
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[132 141 152 147 150 154 250 223 1 246 214 0 205 172 133 238 195 0 213 180 146 217 186 150 188 136 0 206 151 0 183 125 9 208 208 202 196 204 214 255 255 210 255 255 219 210 178 65 242 242 235 106 112 117 96 107 126 250 255 255 255 241 0 154 154 151 255 227 0 67 35 0 52 17 0 253 211 0 208 159 0 167 178 193 222 168 0 248 231 45 208 174 26 199 152 26 225 184 36 255 249 75 220 220 215 77 88 108 241 241 235 245 245 239 255 250 109 242 249 255 255 255 142 255 237 1 142 148 162 242 212 1 143 154 176 174 133 0 222 189 144 169 179 192 177 184 193 184 129 0 255 255 194 253 241 60 210 210 205 214 214 209 77 83 92 230 230 225 98 106 114 243 243 238 117 117 114 255 252 115 255 255 255 115 123 147 130 140 156 152 156 159 241 210 0 53 18 0 151 116 0 162 170 184 218 187 150 193 143 4 220 165 0 206 188 46 181 130 21 204 173 44 206 206 201 208 167 44 72 84 108 240 240 234 244 244 238 243 243 237 212 182 79 255 255 126 131 135 141 119 133 159 132 141 163 195 162 126 219 188 133 218 185 135 180 180 176 221 190 150 175 181 191 176 183 196 181 189 201 202 170 38 209 209 204 207 207 202 251 241 74 229 229 224 238 238 233 226 234 245 244 244 237 255 251 113 255 255 124 255 241 2 255 234 3 249 219 0 255 249 29 252 243 30 227 181 0 212 165 5 222 170 0 173 179 194 216 171 19 255 255 198 208 208 203 156 90 7 206 175 50 91 91 95 211 180 71 242 242 237 246 246 241 212 182 80 255 255 123 129 137 152 255 239 8 251 223 0 59 25 0 251 215 0 228 183 0 222 191 149 249 238 43 177 186 197 187 129 0 186 194 206 209 209 203 249 238 67 255 255 211 226 226 221 235 235 229 100 103 111 76 93 127 255 255 112 88 104 139 130 135 148 149 155 158 247 218 0 224 194 126 255 217 0 228 184 0 13 30 68 161 138 32 204 152 0 255 255 53 206 155 18 207 207 201 255 250 72 255 255 82 209 176 59 232 232 227 243 243 236 245 245 240 255 255 115 255 255 251]; mask:((Depth1Image new) width: 24; height: 24; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@G8@@O<@@_>@@^^@@\N@@\N@@?? @?? @?? @?? @?? @?? @?? @?? @_?@@@@@@@@@@@@@@@@@@@@@') ; yourself); yourself]
cg@3070
   212
!
cg@3070
   213
cg@3000
   214
releaseViewIcon
cg@3000
   215
    "This resource specification was automatically generated
cg@3000
   216
     by the ImageEditor of ST/X."
cg@3000
   217
cg@3000
   218
    "Do not manually edit this!! If it is corrupted,
cg@3000
   219
     the ImageEditor may not be able to read the specification."
cg@3000
   220
cg@3000
   221
    "
cg@3000
   222
     self releaseViewIcon inspect
cg@3000
   223
     ImageEditor openOnClass:self andSelector:#releaseViewIcon
cg@3000
   224
     Icon flushCachedIcons
cg@3000
   225
    "
cg@3000
   226
    <resource: #image>
cg@3000
   227
cg@3000
   228
    ^Icon
cg@3000
   229
        constantNamed:'Tools::ViewTreeInspectorApplication releaseViewIcon'
cg@3000
   230
        ifAbsentPut:[(Depth8Image new) width: 24; height: 24; photometric:(#palette); bitsPerSample:(#[8]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'
cg@3000
   231
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
cg@3000
   232
@@@@@@@@@@@@@@A8^G!!7O3ACP5*P@@A8^G @@@@@@@@@@@A8^@@@OE0/!!P0S#0@@^G @@@@@@@@@@@B (@@''D#48"1.CX5H@(J@@@@@@@@@@@@B (@@@@@@"
cg@3000
   233
''%!!/P7,@(J@@@@@@@@@@@@@%I@@@@BH%IRTQV5P@IRT@@@@@@@@@@@ANSP@@@@ANS$8:T80@S$8@@@@@@@@@@@AN&UYWK(EYQ@\FUPQHXT8@@@@@@@@@@@AN
cg@3000
   234
HC2!!TVY:Y#-%I*IKMD8@@@@@@@@@@@A$\@83XBEG%).GGX _!!&P@@@@@@@@@@@AO[P5+ &(WPYN@["!!E\$<@@@@@@@@@@@B_F''FQPAXX_!!&TGH4HB9<@@@@@
cg@3000
   235
@@@@@@B_%3HCJ7=BKPU,Q)01B9<@@@@@@@@@@@@PBP8T_F!!''JPI)_Y"D&!!@@@@@@@@@@@@@$B)I9TGXO''WQIWQ93W0@@@@@@@@@@@@@$"U=JR$)JR$)JR$)_
cg@3000
   236
"P@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
cg@3000
   237
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[132 141 152 147 150 154 250 223 1 246 214 0 205 172 133 238 195 0 213 180 146 217 186 150 188 136 0 206 151 0 183 125 9 208 208 202 196 204 214 255 255 210 255 255 219 210 178 65 242 242 235 106 112 117 96 107 126 250 255 255 255 241 0 154 154 151 255 227 0 67 35 0 52 17 0 253 211 0 208 159 0 167 178 193 222 168 0 248 231 45 208 174 26 199 152 26 225 184 36 255 249 75 220 220 215 77 88 108 241 241 235 245 245 239 255 250 109 242 249 255 255 255 142 255 237 1 142 148 162 242 212 1 143 154 176 174 133 0 222 189 144 169 179 192 177 184 193 184 129 0 255 255 194 253 241 60 210 210 205 214 214 209 77 83 92 230 230 225 98 106 114 243 243 238 117 117 114 255 252 115 255 255 255 115 123 147 130 140 156 152 156 159 241 210 0 53 18 0 151 116 0 162 170 184 218 187 150 193 143 4 220 165 0 206 188 46 181 130 21 204 173 44 206 206 201 208 167 44 72 84 108 240 240 234 244 244 238 243 243 237 212 182 79 255 255 126 131 135 141 119 133 159 132 141 163 195 162 126 219 188 133 218 185 135 180 180 176 221 190 150 175 181 191 176 183 196 181 189 201 202 170 38 209 209 204 207 207 202 251 241 74 229 229 224 238 238 233 226 234 245 244 244 237 255 251 113 255 255 124 255 241 2 255 234 3 249 219 0 255 249 29 252 243 30 227 181 0 212 165 5 222 170 0 173 179 194 216 171 19 255 255 198 208 208 203 156 90 7 206 175 50 91 91 95 211 180 71 242 242 237 246 246 241 212 182 80 255 255 123 129 137 152 255 239 8 251 223 0 59 25 0 251 215 0 228 183 0 222 191 149 249 238 43 177 186 197 187 129 0 186 194 206 209 209 203 249 238 67 255 255 211 226 226 221 235 235 229 100 103 111 76 93 127 255 255 112 88 104 139 130 135 148 149 155 158 247 218 0 224 194 126 255 217 0 228 184 0 13 30 68 161 138 32 204 152 0 255 255 53 206 155 18 207 207 201 255 250 72 255 255 82 209 176 59 232 232 227 243 243 236 245 245 240 255 255 115 255 255 251]; mask:((Depth1Image new) width: 24; height: 24; photometric:(#blackIs0); bitsPerSample:(#[1]); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@G8@@O<@@O>@@@^@@@N@@@N@@?? @?? @?? @?? @?? @?? @?? @?? @_?@@@@@@@@@@@@@@@@@@@@@') ; yourself); yourself]
cg@2744
   238
! !
cg@2744
   239
cg@2744
   240
!ViewTreeInspectorApplication class methodsFor:'interface specs'!
ca@2177
   241
ca@2177
   242
windowSpec
ca@2177
   243
    "This resource specification was automatically generated
ca@2177
   244
     by the UIPainter of ST/X."
ca@2177
   245
ca@2177
   246
    "Do not manually edit this!! If it is corrupted,
ca@2177
   247
     the UIPainter may not be able to read the specification."
ca@2177
   248
ca@2177
   249
    "
cg@2757
   250
     UIPainter new openOnClass:Tools::ViewTreeInspectorApplication andSelector:#windowSpec
cg@2757
   251
     Tools::ViewTreeInspectorApplication new openInterface:#windowSpec
cg@2757
   252
     Tools::ViewTreeInspectorApplication open
ca@2177
   253
    "
ca@2177
   254
ca@2177
   255
    <resource: #canvas>
ca@2177
   256
ca@2177
   257
    ^ 
cg@3037
   258
    #(FullSpec
cg@3037
   259
       name: windowSpec
cg@3037
   260
       window: 
cg@3037
   261
      (WindowSpec
cg@3037
   262
         label: 'View Tree Inspector'
cg@3037
   263
         name: 'View Tree Inspector'
cg@3037
   264
         min: (Point 10 10)
cg@3037
   265
         max: (Point 1024 9999)
jan@3112
   266
         bounds: (Rectangle 0 0 693 643)
cg@3037
   267
         menu: menu
cg@3037
   268
       )
cg@3037
   269
       component: 
cg@3037
   270
      (SpecCollection
cg@3037
   271
         collection: (
cg@3037
   272
          (MenuPanelSpec
cg@3037
   273
             name: 'toolbarMenu'
cg@3037
   274
             layout: (LayoutFrame 0 0.0 0 0 0 1.0 40 0)
cg@3037
   275
             menu: toolbarMenu
cg@3037
   276
             textDefault: true
cg@3037
   277
           )
cg@3037
   278
          (VariableVerticalPanelSpec
cg@3037
   279
             name: 'VariableVerticalPanel1'
cg@3037
   280
             layout: (LayoutFrame 0 0.0 40 0.0 0 1.0 0 1.0)
cg@3037
   281
             component: 
cg@3037
   282
            (SpecCollection
cg@3037
   283
               collection: (
jan@3112
   284
                (ViewSpec
jan@3112
   285
                   name: 'PathAndListPane'
jan@3112
   286
                   component: 
jan@3112
   287
                  (SpecCollection
jan@3112
   288
                     collection: (
jan@3112
   289
                      (ViewSpec
jan@3112
   290
                         name: 'PathPane'
jan@3112
   291
                         layout: (LayoutFrame 0 0 0 0 0 1 25 0)
jan@3112
   292
                         component: 
jan@3112
   293
                        (SpecCollection
jan@3112
   294
                           collection: (
jan@3112
   295
                            (InputFieldSpec
jan@3112
   296
                               name: 'Path'
jan@3112
   297
                               layout: (LayoutFrame 0 0 0 0 0 1 0 1)
jan@3112
   298
                               model: path
jan@3112
   299
                               acceptOnReturn: true
jan@3112
   300
                               acceptOnTab: true
jan@3112
   301
                               acceptOnPointerLeave: true
jan@3112
   302
                               emptyFieldReplacementText: 'No View Selected'
jan@3112
   303
                             )
jan@3112
   304
                            )
jan@3112
   305
                          
jan@3112
   306
                         )
jan@3112
   307
                       )
jan@3112
   308
                      (HierarchicalListViewSpec
jan@3112
   309
                         name: 'List'
jan@3112
   310
                         layout: (LayoutFrame 0 0 25 0 0 1 0 1)
jan@3112
   311
                         level: 1
jan@3112
   312
                         model: model
jan@3112
   313
                         menu: middleButtonMenu
jan@3112
   314
                         hasHorizontalScrollBar: true
jan@3112
   315
                         hasVerticalScrollBar: true
jan@3112
   316
                         miniScrollerHorizontal: true
jan@3112
   317
                         miniScrollerVertical: false
jan@3112
   318
                         listModel: listOfItems
jan@3112
   319
                         multipleSelectOk: true
jan@3112
   320
                         useIndex: false
jan@3112
   321
                         highlightMode: label
jan@3112
   322
                         showLeftIndicators: false
jan@3112
   323
                         indicatorSelector: indicatorClicked:
jan@3112
   324
                         useDefaultIcons: false
jan@3112
   325
                         postBuildCallback: postBuildTree:
jan@3112
   326
                       )
jan@3112
   327
                      )
jan@3112
   328
                    
jan@3112
   329
                   )
cg@2770
   330
                 )
cg@3037
   331
                (ViewSpec
cg@3037
   332
                   name: 'Box2'
cg@3037
   333
                   component: 
cg@3037
   334
                  (SpecCollection
cg@3037
   335
                     collection: (
cg@3037
   336
                      (TabViewSpec
cg@3037
   337
                         name: 'TabHeader1'
cg@3037
   338
                         layout: (LayoutFrame 0 0.0 0 0 0 1.0 25 0)
cg@3037
   339
                         model: inspectorModeIndexHolder
cg@3037
   340
                         menu: inspectorModes
cg@3037
   341
                         useIndex: true
cg@3037
   342
                         translateLabel: true
cg@3037
   343
                       )
cg@3049
   344
                      (ViewSpec
cg@3049
   345
                         name: 'Inspector'
cg@3049
   346
                         layout: (LayoutFrame 0 0 26 0 0 1 0 1)
jan@3112
   347
                         postBuildCallback: postBuildInspectorView:
cg@3049
   348
                         viewClassName: 'InspectorView'
cg@3049
   349
                       )
cg@3037
   350
                      )
cg@3037
   351
                    
cg@3037
   352
                   )
cg@3037
   353
                 )
cg@3037
   354
                )
cg@3037
   355
              
cg@3037
   356
             )
cg@3037
   357
             handles: (Any 0.5 1.0)
ca@2177
   358
           )
cg@3037
   359
          )
cg@3037
   360
        
cg@3037
   361
       )
cg@3037
   362
     )
ca@2177
   363
! !
ca@2177
   364
cg@2744
   365
!ViewTreeInspectorApplication class methodsFor:'menu specs'!
ca@2177
   366
ca@2177
   367
menu
ca@2177
   368
    "This resource specification was automatically generated
ca@2177
   369
     by the MenuEditor of ST/X."
ca@2177
   370
ca@2177
   371
    "Do not manually edit this!! If it is corrupted,
cg@3174
   372
     the MenuEditor may not be able to read the specification."      
ca@2177
   373
cg@2978
   374
ca@2177
   375
    "
cg@2978
   376
     MenuEditor new openOnClass:Tools::ViewTreeInspectorApplication andSelector:#menu
cg@2978
   377
     (Menu new fromLiteralArrayEncoding:(Tools::ViewTreeInspectorApplication menu)) startUp
ca@2177
   378
    "
ca@2177
   379
ca@2177
   380
    <resource: #menu>
ca@2177
   381
ca@2177
   382
    ^ 
ca@2177
   383
     #(Menu
ca@2177
   384
        (
ca@2177
   385
         (MenuItem
ca@2177
   386
            label: 'File'
ca@2177
   387
            submenu: 
ca@2177
   388
           (Menu
ca@2177
   389
              (
ca@2177
   390
               (MenuItem
ca@2177
   391
                  label: 'Pick a View'
cg@2762
   392
                  itemValue: doPickView
ca@2177
   393
                )
ca@2177
   394
               (MenuItem
ca@2455
   395
                  enabled: hasTargetWidgetChannel
ca@2177
   396
                  label: 'Release Picked View'
ca@2177
   397
                  itemValue: doUnpick
ca@2177
   398
                )
ca@2177
   399
               (MenuItem
ca@2177
   400
                  label: '-'
ca@2177
   401
                )
ca@2177
   402
               (MenuItem
cg@2744
   403
                  label: 'Settings'
cg@2744
   404
                  submenu: 
cg@2744
   405
                 (Menu
cg@2744
   406
                    (
cg@2744
   407
                     (MenuItem
cg@2744
   408
                        label: 'Test Mode'
cg@2744
   409
                        hideMenuOnActivated: false
cg@2744
   410
                        indication: testModeChannel
cg@2744
   411
                      )
cg@2744
   412
                     (MenuItem
cg@2744
   413
                        enabled: testModeChannel
cg@2744
   414
                        label: 'Follow Focus'
cg@2744
   415
                        hideMenuOnActivated: false
cg@2744
   416
                        indication: followFocusChannel
cg@2744
   417
                      )
cg@2744
   418
                     (MenuItem
cg@2744
   419
                        label: '-'
cg@2744
   420
                      )
cg@2744
   421
                     (MenuItem
cg@2744
   422
                        label: 'Select on Click'
cg@2744
   423
                        hideMenuOnActivated: false
cg@2744
   424
                        indication: selectOnClickHolder
cg@2744
   425
                      )
cg@2744
   426
                     (MenuItem
cg@2744
   427
                        label: '-'
cg@2744
   428
                      )
cg@2744
   429
                     (MenuItem
cg@2744
   430
                        label: 'Show Name of Widgets'
cg@2744
   431
                        hideMenuOnActivated: false
cg@2744
   432
                        indication: showNamesHolder
cg@2744
   433
                      )
cg@2744
   434
                     )
cg@2744
   435
                    nil
cg@2744
   436
                    nil
cg@2744
   437
                  )
cg@2744
   438
                )
cg@2744
   439
               (MenuItem
cg@2744
   440
                  label: '-'
cg@2744
   441
                )
cg@2744
   442
               (MenuItem
ca@2177
   443
                  label: 'Exit'
ca@2177
   444
                  itemValue: closeRequest
ca@2177
   445
                )
ca@2177
   446
               )
ca@2177
   447
              nil
ca@2177
   448
              nil
ca@2177
   449
            )
ca@2177
   450
          )
ca@2177
   451
         (MenuItem
cg@2744
   452
            enabled: hasSingleSelectionHolder
cg@2744
   453
            label: 'Selection'
cg@2744
   454
            submenuChannel: middleButtonMenu
cg@2744
   455
          )
cg@2744
   456
         (MenuItem
cg@3034
   457
            label: 'Widget'
cg@3034
   458
            submenu: 
cg@3034
   459
           (Menu
cg@3034
   460
              (
cg@3034
   461
               (MenuItem
cg@3034
   462
                  enabled: hasSingleSelectionHolder
cg@3034
   463
                  label: 'Browse'
cg@3034
   464
                  itemValue: doBrowse:
cg@3034
   465
                  argument: view
cg@3034
   466
                )
cg@3034
   467
               (MenuItem
cg@3034
   468
                  enabled: hasSingleSelectionHolder
cg@3034
   469
                  label: 'Inspect'
cg@3034
   470
                  itemValue: doInspect:
cg@3034
   471
                  argument: view
cg@3034
   472
                )
cg@3034
   473
               (MenuItem
cg@3034
   474
                  label: '-'
cg@3034
   475
                )
cg@3034
   476
               (MenuItem
cg@3034
   477
                  enabled: hasTargetWidgetChannel
cg@3034
   478
                  label: 'All Components'
cg@3034
   479
                  startGroup: right
cg@3034
   480
                  submenuChannel: submenuComponents:
cg@3034
   481
                )
cg@3034
   482
               )
cg@3034
   483
              nil
cg@3034
   484
              nil
cg@3034
   485
            )
cg@3034
   486
          )
cg@3034
   487
         (MenuItem
cg@2744
   488
            label: 'Application'
ca@2454
   489
            submenu: 
ca@2454
   490
           (Menu
ca@2454
   491
              (
ca@2454
   492
               (MenuItem
cg@2978
   493
                  label: 'Redraw'
cg@2978
   494
                  itemValue: doRedraw
cg@2978
   495
                )
cg@2978
   496
               (MenuItem
cg@2978
   497
                  label: '-'
cg@2978
   498
                )
cg@2978
   499
               (MenuItem
cg@2744
   500
                  enabled: hasSingleSelectionHolder
cg@2744
   501
                  label: 'Browse'
cg@2744
   502
                  itemValue: doBrowse:
cg@2744
   503
                  argument: application
ca@2454
   504
                )
ca@2454
   505
               (MenuItem
cg@2744
   506
                  enabled: hasSingleSelectionHolder
cg@2744
   507
                  label: 'Inspect'
cg@2744
   508
                  itemValue: doInspect:
cg@2744
   509
                  argument: application
ca@2454
   510
                )
ca@2454
   511
               (MenuItem
ca@2454
   512
                  label: '-'
ca@2454
   513
                )
ca@2454
   514
               (MenuItem
cg@3174
   515
                  enabled: canBrowseWindowSpecMethod
cg@3174
   516
                  label: 'Browse Window Spec Method'
cg@3174
   517
                  itemValue: doBrowseWindowSpecMethod
cg@3174
   518
                )
cg@3174
   519
               (MenuItem
cg@3174
   520
                  enabled: canEditWindowSpec
cg@3174
   521
                  label: 'Edit Window Spec'
cg@3174
   522
                  itemValue: doEditWindowSpec
cg@3174
   523
                )
cg@3174
   524
               (MenuItem
cg@3174
   525
                  label: '-'
cg@3174
   526
                )
cg@3174
   527
               (MenuItem
cg@2744
   528
                  enabled: hasTargetWidgetChannel
cg@2744
   529
                  label: 'All Applications'
cg@2744
   530
                  submenuChannel: submenuApplications:
cg@2744
   531
                )
cg@2744
   532
               )
cg@2744
   533
              nil
cg@2744
   534
              nil
cg@2744
   535
            )
cg@2744
   536
          )
cg@2744
   537
         (MenuItem
cg@3034
   538
            label: 'Process'
cg@2744
   539
            submenu: 
cg@2744
   540
           (Menu
cg@2744
   541
              (
cg@2744
   542
               (MenuItem
cg@2744
   543
                  enabled: hasSingleSelectionHolder
cg@3171
   544
                  label: 'Debug'
cg@3171
   545
                  itemValue: doDebugProcess
cg@3171
   546
                )
cg@3171
   547
               (MenuItem
cg@3171
   548
                  enabled: hasSingleSelectionHolder
cg@2744
   549
                  label: 'Inspect'
cg@2744
   550
                  itemValue: doInspect:
cg@3034
   551
                  argument: process
ca@2454
   552
                )
ca@2454
   553
               (MenuItem
ca@2454
   554
                  label: '-'
ca@2454
   555
                )
ca@2454
   556
               (MenuItem
cg@3034
   557
                  label: 'Open Process Monitor'
cg@3034
   558
                  itemValue: doOpenProcessMonitor
ca@2454
   559
                )
ca@2454
   560
               )
ca@2454
   561
              nil
ca@2454
   562
              nil
ca@2454
   563
            )
ca@2454
   564
          )
ca@2454
   565
         (MenuItem
cg@2744
   566
            label: 'Help'
cg@2744
   567
            startGroup: conditionalRight
cg@2744
   568
            submenu: 
cg@2744
   569
           (Menu
cg@2744
   570
              (
cg@2744
   571
               (MenuItem
cg@2744
   572
                  label: 'Documentation'
cg@2744
   573
                  itemValue: openDocumentation
cg@2744
   574
                )
cg@2744
   575
               (MenuItem
cg@2744
   576
                  label: '-'
cg@2744
   577
                )
cg@2744
   578
               (MenuItem
cg@2744
   579
                  label: 'About this Application...'
cg@2744
   580
                  itemValue: openAboutThisApplication
cg@2744
   581
                )
cg@2744
   582
               )
cg@2744
   583
              nil
cg@2744
   584
              nil
cg@2744
   585
            )
ca@2177
   586
          )
ca@2177
   587
         )
ca@2177
   588
        nil
ca@2177
   589
        nil
ca@2177
   590
      )
ca@2177
   591
!
ca@2177
   592
ca@2177
   593
middleButtonMenu
ca@2177
   594
    "This resource specification was automatically generated
ca@2177
   595
     by the MenuEditor of ST/X."
ca@2177
   596
ca@2177
   597
    "Do not manually edit this!! If it is corrupted,
ca@2177
   598
     the MenuEditor may not be able to read the specification."
ca@2177
   599
ca@2177
   600
    "
ca@2177
   601
     MenuEditor new openOnClass:ViewTreeApplication andSelector:#middleButtonMenu
ca@2177
   602
     (Menu new fromLiteralArrayEncoding:(ViewTreeApplication middleButtonMenu)) startUp
ca@2177
   603
    "
ca@2177
   604
ca@2177
   605
    <resource: #menu>
ca@2177
   606
ca@2177
   607
    ^ 
ca@2177
   608
     #(Menu
ca@2177
   609
        (
ca@2177
   610
         (MenuItem
ca@2177
   611
            label: 'Geometry'
ca@2177
   612
            translateLabel: true
ca@2177
   613
            submenuChannel: submenuGeometry:
ca@2177
   614
            keepLinkedMenu: true
ca@2177
   615
          )
ca@2177
   616
         (MenuItem
ca@2177
   617
            label: 'Interface'
ca@2177
   618
            translateLabel: true
ca@2177
   619
            submenuChannel: submenuInterface:
ca@2177
   620
            keepLinkedMenu: true
ca@2177
   621
          )
ca@2177
   622
         (MenuItem
ca@2177
   623
            label: 'Visibility'
ca@2177
   624
            translateLabel: true
ca@2177
   625
            submenuChannel: submenuVisibility:
ca@2177
   626
            keepLinkedMenu: true
ca@2177
   627
          )
ca@2177
   628
         (MenuItem
ca@2177
   629
            label: '-'
ca@2177
   630
          )
ca@2177
   631
         (MenuItem
ca@2177
   632
            label: 'Browse View Class'
ca@2177
   633
            itemValue: doBrowse:
ca@2177
   634
            translateLabel: true
cg@3169
   635
            argument: #view
ca@2177
   636
          )
ca@2177
   637
         (MenuItem
ca@2177
   638
            label: 'Browse Model Class'
ca@2177
   639
            itemValue: doBrowse:
ca@2177
   640
            translateLabel: true
ca@2177
   641
            isVisible: hasModel
cg@3169
   642
            argument: #model
ca@2177
   643
          )
ca@2177
   644
         (MenuItem
ca@2177
   645
            label: 'Browse Application Class'
ca@2177
   646
            itemValue: doBrowse:
ca@2177
   647
            translateLabel: true
ca@2177
   648
            isVisible: hasApplication
cg@3169
   649
            argument: #application
ca@2177
   650
          )
ca@2177
   651
         (MenuItem
ca@2177
   652
            label: 'Browse Controller Class'
ca@2177
   653
            itemValue: doBrowse:
ca@2177
   654
            translateLabel: true
ca@2177
   655
            isVisible: hasController
cg@3169
   656
            argument: #controller
ca@2177
   657
          )
ca@2177
   658
         (MenuItem
ca@2177
   659
            label: '-'
ca@2177
   660
          )
ca@2177
   661
         (MenuItem
ca@2177
   662
            label: 'Inspect View'
ca@2177
   663
            itemValue: doInspect:
ca@2177
   664
            translateLabel: true
cg@3169
   665
            argument: #view
ca@2177
   666
          )
ca@2177
   667
         (MenuItem
ca@2177
   668
            label: 'Inspect Window Group'
ca@2177
   669
            itemValue: doInspect:
ca@2177
   670
            translateLabel: true
cg@3169
   671
            argument: #group
ca@2177
   672
          )
ca@2177
   673
         (MenuItem
ca@2177
   674
            label: 'Inspect Model'
ca@2177
   675
            itemValue: doInspect:
ca@2177
   676
            translateLabel: true
ca@2177
   677
            isVisible: hasModel
cg@3169
   678
            argument: #model
ca@2177
   679
          )
ca@2177
   680
         (MenuItem
ca@2177
   681
            label: 'Inspect Application'
ca@2177
   682
            itemValue: doInspect:
ca@2177
   683
            translateLabel: true
ca@2177
   684
            isVisible: hasApplication
cg@3169
   685
            argument: #application
ca@2177
   686
          )
ca@2177
   687
         (MenuItem
ca@2177
   688
            label: 'Inspect Controller'
ca@2177
   689
            itemValue: doInspect:
ca@2177
   690
            translateLabel: true
ca@2177
   691
            isVisible: hasController
cg@3169
   692
            argument: #controller
ca@2177
   693
          )
ca@2177
   694
         (MenuItem
ca@2177
   695
            label: '-'
ca@2177
   696
          )
ca@2177
   697
         (MenuItem
ca@2177
   698
            label: 'Flash'
ca@2177
   699
            itemValue: doFlash
ca@2177
   700
            translateLabel: true
ca@2177
   701
          )
ca@2177
   702
         (MenuItem
ca@2177
   703
            label: '-'
ca@2177
   704
          )
ca@2177
   705
         (MenuItem
ca@2177
   706
            label: 'Destroy'
ca@2177
   707
            itemValue: doDestroy
ca@2177
   708
            translateLabel: true
ca@2177
   709
          )
ca@2177
   710
         (MenuItem
ca@2177
   711
            label: '-'
ca@2177
   712
          )
ca@2177
   713
         (MenuItem
ca@2177
   714
            label: 'Instance Variables'
ca@2177
   715
            translateLabel: true
ca@2177
   716
            submenuChannel: submenuInspector:
ca@2177
   717
            keepLinkedMenu: true
ca@2177
   718
          )
ca@2177
   719
         (MenuItem
ca@2177
   720
            label: '='
ca@2177
   721
          )
ca@2177
   722
         (MenuItem
ca@2177
   723
            label: ''
ca@2177
   724
          )
ca@2177
   725
         (MenuItem
ca@2177
   726
            enabled: selectedComponentHasChildren
ca@2177
   727
            label: 'Applications'
ca@2177
   728
            nameKey: single
ca@2177
   729
            translateLabel: true
ca@2177
   730
            submenuChannel: submenuApplications:
ca@2177
   731
            keepLinkedMenu: true
ca@2177
   732
          )
ca@2177
   733
         (MenuItem
ca@2177
   734
            enabled: selectedComponentHasChildren
ca@2177
   735
            label: 'Components'
ca@2177
   736
            nameKey: single
ca@2177
   737
            translateLabel: true
ca@2177
   738
            submenuChannel: submenuComponents:
ca@2177
   739
            keepLinkedMenu: true
ca@2177
   740
          )
ca@2177
   741
         )
ca@2177
   742
        nil
ca@2177
   743
        nil
ca@2177
   744
      )
ca@2177
   745
!
ca@2177
   746
ca@2177
   747
toolbarMenu
ca@2177
   748
    "This resource specification was automatically generated
ca@2177
   749
     by the MenuEditor of ST/X."
ca@2177
   750
ca@2177
   751
    "Do not manually edit this!! If it is corrupted,
ca@2177
   752
     the MenuEditor may not be able to read the specification."
ca@2177
   753
cg@2978
   754
ca@2177
   755
    "
cg@2757
   756
     MenuEditor new openOnClass:Tools::ViewTreeInspectorApplication andSelector:#toolbarMenu
cg@2757
   757
     (Menu new fromLiteralArrayEncoding:(Tools::ViewTreeInspectorApplication toolbarMenu)) startUp
ca@2177
   758
    "
ca@2177
   759
ca@2177
   760
    <resource: #menu>
ca@2177
   761
ca@2177
   762
    ^ 
ca@2177
   763
     #(Menu
ca@2177
   764
        (
ca@2177
   765
         (MenuItem
cg@2978
   766
            enabled: hasTargetWidgetChannel
cg@2978
   767
            label: 'Redraw'
cg@2978
   768
            itemValue: doRedraw
cg@2978
   769
            isButton: true
cg@2978
   770
            labelImage: (ResourceRetriever ToolbarIconLibrary reloadIcon)
cg@2978
   771
          )
cg@2978
   772
         (MenuItem
cg@2978
   773
            label: '-'
cg@2978
   774
          )
cg@2978
   775
         (MenuItem
cg@2978
   776
            label: 'Pick a View and Catch Events'
cg@2762
   777
            itemValue: doPickView
cg@2744
   778
            translateLabel: false
cg@2744
   779
            isButton: true
cg@2744
   780
            hideMenuOnActivated: false
cg@3185
   781
            labelImage: (ResourceRetriever ToolbarIconLibrary pickWindowIcon)
cg@2744
   782
          )
cg@2744
   783
         (MenuItem
cg@2757
   784
            enabled: hasTargetWidgetChannel
cg@3124
   785
            isVisible: isNotCatchingEventsChannel
cg@3124
   786
            label: 'Catch Events of Picked View'
cg@3124
   787
            activeHelpKey: doCatchEvents
cg@3124
   788
            itemValue: doCatchEvents
cg@3124
   789
            nameKey: doCatchEvents
cg@3124
   790
            isButton: true
cg@3124
   791
            labelImage: (ResourceRetriever nil releaseViewIcon)
cg@3124
   792
          )
cg@3124
   793
         (MenuItem
cg@3124
   794
            enabled: hasTargetWidgetChannel
cg@3124
   795
            isVisible: isCatchingEventsChannel
cg@2978
   796
            label: 'Release Picked View and Uncatch Events'
cg@3070
   797
            activeHelpKey: doUncatchEvents
cg@2978
   798
            itemValue: doUncatchEvents
cg@3070
   799
            nameKey: doUncatchEvents
cg@2757
   800
            isButton: true
cg@3124
   801
            labelImage: (ResourceRetriever nil lockViewIcon)
cg@2757
   802
          )
cg@2757
   803
         (MenuItem
cg@2757
   804
            label: '-'
cg@2757
   805
          )
cg@2757
   806
         (MenuItem
ca@2454
   807
            enabled: hasSingleSelectionHolder
cg@2744
   808
            label: 'Browse Application'
ca@2454
   809
            itemValue: doBrowse:
ca@2454
   810
            translateLabel: false
cg@2744
   811
            isButton: true
cg@2744
   812
            hideMenuOnActivated: false
ca@2454
   813
            labelImage: (ResourceRetriever ToolbarIconLibrary systemBrowser24x24Icon2)
ca@2454
   814
            argument: application
ca@2177
   815
          )
ca@2177
   816
         (MenuItem
ca@2454
   817
            enabled: hasSingleSelectionHolder
cg@2744
   818
            label: 'Inspect Application'
ca@2454
   819
            itemValue: doInspect:
ca@2454
   820
            translateLabel: false
cg@2744
   821
            isButton: true
cg@2744
   822
            hideMenuOnActivated: false
cg@2744
   823
            labelImage: (ResourceRetriever ToolbarIconLibrary inspect22x24Icon)
ca@2454
   824
            argument: application
ca@2177
   825
          )
ca@2177
   826
         )
ca@2177
   827
        nil
ca@2177
   828
        nil
ca@2177
   829
      )
ca@2177
   830
! !
ca@2177
   831
cg@2747
   832
!ViewTreeInspectorApplication class methodsFor:'startup'!
cg@2747
   833
cg@2747
   834
openInPickMode
cg@2747
   835
    |app|
cg@2747
   836
cg@2747
   837
    app := self new.
cg@2747
   838
    app open.
cg@2762
   839
    app doPickView.
cg@3124
   840
    ^ app
cg@3124
   841
!
cg@3124
   842
cg@3124
   843
openInPickModeAndRelease
cg@3124
   844
    "release the pick-lock after picking"
cg@3124
   845
cg@3124
   846
    |app|
cg@3124
   847
cg@3124
   848
    app := self openInPickMode.
cg@3124
   849
    app doUncatchEvents.
cg@3124
   850
    ^ app
cg@3014
   851
!
cg@3014
   852
cg@3014
   853
openOn:aView
cg@3014
   854
    "show a particular window's topView hierarchy,
cg@3014
   855
     select the given view"
cg@3014
   856
cg@3014
   857
    |app|
cg@3014
   858
cg@3014
   859
    app := self new.
cg@3014
   860
    app open.
cg@3014
   861
    app showWindow:aView.
cg@3124
   862
    ^ app
cg@2747
   863
! !
cg@2747
   864
cg@2744
   865
!ViewTreeInspectorApplication methodsFor:'actions'!
ca@2177
   866
ca@2177
   867
indicatorClicked:anIndex
ca@2177
   868
    |item sensor|
ca@2177
   869
ca@2177
   870
    item := model listOfItems at:anIndex ifAbsent:nil.
ca@2177
   871
ca@2177
   872
    item notNil ifTrue:[
ca@2177
   873
        (     (sensor := self window sensor) notNil
ca@2177
   874
         and:[(sensor ctrlDown or:[sensor shiftDown])]
ca@2177
   875
        ) ifTrue:[
ca@2177
   876
            item recursiveToggleExpand
ca@2177
   877
        ] ifFalse:[
ca@2177
   878
            item toggleExpand
ca@2177
   879
        ]
ca@2177
   880
    ].
ca@2177
   881
! !
ca@2177
   882
cg@2744
   883
!ViewTreeInspectorApplication methodsFor:'aspects'!
ca@2177
   884
cg@3174
   885
canBrowseWindowSpecMethod
cg@3174
   886
    ^ self hasSingleSelectionHolder value and:[ self windowSpecMethodOfSelection notNil ]
cg@3174
   887
!
cg@3174
   888
cg@3174
   889
canEditWindowSpec
cg@3174
   890
    ^ self hasSingleSelectionHolder value and:[ self windowSpecMethodOfSelection notNil ]
cg@3174
   891
!
cg@3174
   892
ca@2177
   893
followFocusChannel
ca@2455
   894
    "boolean holder, which indicates whether selection changed dependend on the focus view"
ca@2455
   895
ca@2177
   896
    ^ followFocusChannel
ca@2177
   897
!
ca@2177
   898
ca@2177
   899
hasSingleSelectionHolder
ca@2455
   900
    "boolean holder, true if one item is selected"
ca@2455
   901
ca@2177
   902
    ^ hasSingleSelectionHolder
ca@2177
   903
!
ca@2177
   904
ca@2455
   905
hasTargetWidgetChannel
ca@2455
   906
    "answer the channel which is set to true if a target widget exists"
ca@2455
   907
ca@2455
   908
    ^ model hasTargetWidgetChannel
ca@2455
   909
!
ca@2455
   910
cg@3037
   911
inspectorMode
cg@3049
   912
    "what is shown in the inspector:
cg@3037
   913
     1->widget
cg@3049
   914
     2->application
cg@3049
   915
     3->WindowGroup
cg@3049
   916
     4->Sensor
cg@3049
   917
     5->Model 
cg@3049
   918
    "
cg@3049
   919
cg@3049
   920
    (inspectorModeIndexHolder value == 1) ifTrue:[ ^#widget].
cg@3049
   921
    (inspectorModeIndexHolder value == 2) ifTrue:[ ^#application].
cg@3049
   922
    (inspectorModeIndexHolder value == 3) ifTrue:[ ^#group].
cg@3049
   923
    (inspectorModeIndexHolder value == 4) ifTrue:[ ^#sensor].
cg@3049
   924
    (inspectorModeIndexHolder value == 5) ifTrue:[ ^#model].
cg@3049
   925
    ^ #application
cg@3037
   926
cg@3037
   927
    "Created: / 30-07-2013 / 07:44:59 / cg"
cg@3037
   928
!
cg@3037
   929
cg@3037
   930
inspectorModeIndexHolder
cg@3049
   931
    "what is shown in the inspector:
cg@3049
   932
     1->Widget
cg@3049
   933
     2->Application
cg@3049
   934
     3->WindowGroup
cg@3049
   935
     4->Sensor
cg@3049
   936
     5->Model 
cg@3049
   937
    "
cg@3037
   938
cg@3037
   939
    ^ inspectorModeIndexHolder
cg@3037
   940
cg@3037
   941
    "Created: / 30-07-2013 / 07:44:07 / cg"
cg@3037
   942
!
cg@3037
   943
cg@3037
   944
inspectorModes
cg@3049
   945
    ^ #('Widget' 'Application' 'WindowGroup' 'Sensor' 'Model')
cg@3037
   946
cg@3037
   947
    "Created: / 30-07-2013 / 09:42:16 / cg"
cg@3037
   948
!
cg@3037
   949
cg@3124
   950
isCatchingEventsChannel
cg@3124
   951
    ^ isCatchingEventsChannel
cg@3124
   952
!
cg@3124
   953
cg@3124
   954
isNotCatchingEventsChannel
cg@3124
   955
    ^ BlockValue forLogicalNot:self isCatchingEventsChannel
cg@3124
   956
!
cg@3124
   957
ca@2177
   958
listOfItems
ca@2455
   959
    "returns the hierarchical list of items"
ca@2455
   960
ca@2177
   961
    ^ model listOfItems
ca@2177
   962
!
ca@2177
   963
ca@2177
   964
model
ca@2455
   965
    "returns my selection model, a ViewTreeModel"
ca@2455
   966
ca@2177
   967
    ^ model
ca@2177
   968
!
ca@2177
   969
jan@3112
   970
path
jan@3112
   971
    <resource: #uiAspect>
jan@3112
   972
jan@3112
   973
    path isNil ifTrue:[
cg@3123
   974
        path := PluggableAdaptor 
cg@3123
   975
                    on: self model 
cg@3123
   976
                    getter:[ :model | model path ]
cg@3123
   977
                    setter:[ :model :newValue |  ]
jan@3112
   978
    ].
jan@3112
   979
    ^ path.
jan@3112
   980
jan@3112
   981
    "Modified: / 19-05-2014 / 18:40:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
jan@3112
   982
!
jan@3112
   983
ca@2177
   984
selectOnClickHolder
ca@2455
   985
    "boolean holder, which indicates whether the selection will change on click"
ca@2455
   986
ca@2177
   987
    ^ model selectOnClickHolder
ca@2177
   988
!
ca@2177
   989
ca@2451
   990
showNamesHolder
ca@2451
   991
    "boolean holder, which indicates whether application names or widget names
ca@2455
   992
     as additional text are shown for the items"
ca@2455
   993
ca@2451
   994
    ^ showNamesHolder
ca@2451
   995
!
ca@2451
   996
ca@2177
   997
testModeChannel
ca@2455
   998
    "answer a boolean channel which describes the behaviour how to process
ca@2455
   999
     events on the target view.
ca@2455
  1000
ca@2455
  1001
     false: all input events are eaten and the selection is shown on the target view.
ca@2455
  1002
     true:  no  input events are eaten and no  selection is shown on the target view."
ca@2455
  1003
ca@2455
  1004
    ^ model testModeChannel
cg@3174
  1005
!
cg@3174
  1006
cg@3174
  1007
windowSpecMethodOfSelection
cg@3174
  1008
    |item view app spec builder specSelector implementors|
cg@3174
  1009
cg@3174
  1010
    item := model selectedItem.
cg@3174
  1011
    item isNil ifTrue:[^ nil]. 
cg@3174
  1012
cg@3174
  1013
    view := item widget.
cg@3174
  1014
    view isNil ifTrue:[^ nil]. 
cg@3174
  1015
cg@3174
  1016
    app := view application.
cg@3174
  1017
    app isNil ifTrue:[^ nil]. 
cg@3174
  1018
cg@3174
  1019
    builder := app builder.
cg@3174
  1020
    builder isNil ifTrue:[^ nil]. 
cg@3174
  1021
cg@3174
  1022
    spec := builder spec.
cg@3174
  1023
    spec isNil ifTrue:[^ nil].
cg@3174
  1024
cg@3174
  1025
    specSelector := spec name.
cg@3174
  1026
    specSelector isNil ifTrue:[^ nil].
cg@3174
  1027
cg@3174
  1028
    (app class theNonMetaclass canUnderstand:specSelector) ifTrue:[
cg@3174
  1029
        ^ app class theNonMetaclass lookupMethodFor:specSelector.
cg@3174
  1030
    ].
cg@3174
  1031
    (app class theMetaclass canUnderstand:specSelector) ifTrue:[
cg@3174
  1032
        ^ app class theMetaclass lookupMethodFor:specSelector.
cg@3174
  1033
    ].
cg@3174
  1034
cg@3174
  1035
    "/ maybe a simple dialog given a spec
cg@3174
  1036
    app masterApplication notNil ifTrue:[
cg@3174
  1037
        (app masterApplication class theNonMetaclass canUnderstand:specSelector) ifTrue:[     
cg@3174
  1038
            ^ app masterApplication class theNonMetaclass lookupMethodFor:specSelector.
cg@3174
  1039
        ].
cg@3174
  1040
        (app masterApplication class theMetaclass canUnderstand:specSelector) ifTrue:[    
cg@3174
  1041
            ^ app masterApplication class theMetaclass lookupMethodFor:specSelector.
cg@3174
  1042
        ].
cg@3174
  1043
    ].
cg@3174
  1044
cg@3174
  1045
    implementors := Smalltalk allImplementorsOf: specSelector.
cg@3174
  1046
    implementors size == 1 ifTrue:[
cg@3174
  1047
        ^ implementors first compiledMethodAt:specSelector.
cg@3174
  1048
    ].
cg@3174
  1049
cg@3174
  1050
    ^ nil
ca@2177
  1051
! !
ca@2177
  1052
cg@2744
  1053
!ViewTreeInspectorApplication methodsFor:'change & update'!
ca@2177
  1054
cg@3037
  1055
inspectorModeIndexHolderChanged
cg@3037
  1056
    self updateInspector
cg@3037
  1057
cg@3037
  1058
    "Created: / 30-07-2013 / 09:21:51 / cg"
cg@3037
  1059
!
cg@3037
  1060
ca@2177
  1061
selectionChanged
ca@2177
  1062
    |info view item|
ca@2177
  1063
ca@2177
  1064
    item := model selectedItem.
cg@3174
  1065
    item notNil ifTrue:[ 
cg@3174
  1066
        |state|
cg@3174
  1067
ca@2177
  1068
        view := item widget.
ca@2177
  1069
ca@2177
  1070
        view id isNil ifTrue:[
ca@2177
  1071
            state := 'no ID'.
ca@2177
  1072
        ] ifFalse:[
ca@2177
  1073
            view shown ifTrue:[
ca@2177
  1074
                state := 'visible'.
ca@2177
  1075
            ] ifFalse:[
ca@2177
  1076
                state := 'invisible'
ca@2177
  1077
            ].
ca@2177
  1078
        ].
ca@2177
  1079
        info := '%1 [%2] - %3' bindWith:(view class name)
ca@2177
  1080
                                   with:(view name ? '') with:state allBold.
ca@2177
  1081
    ] ifFalse:[
ca@2177
  1082
        info := ''
ca@2177
  1083
    ].
ca@2177
  1084
    hasSingleSelectionHolder value:(view notNil).
cg@3037
  1085
    self updateInspector
cg@3037
  1086
cg@3037
  1087
    "Modified: / 30-07-2013 / 09:21:27 / cg"
ca@2177
  1088
!
ca@2177
  1089
ca@2177
  1090
update:something with:someArgument from:aModel
ca@2454
  1091
    |oldSelection|
ca@2454
  1092
ca@2451
  1093
    aModel == showNamesHolder ifTrue:[
ca@2455
  1094
        oldSelection := model selectedItem.
ca@2454
  1095
        model selectedItem:nil.
ca@2451
  1096
        self listOfItems showWidgetNames:(aModel value).
ca@2454
  1097
        model selectedItem:oldSelection.
ca@2451
  1098
        ^ self
ca@2451
  1099
    ].
ca@2458
  1100
ca@2458
  1101
    aModel == model ifTrue:[
ca@2458
  1102
        self selectionChanged.
ca@2458
  1103
        ^ self
ca@2458
  1104
    ].
ca@2458
  1105
ca@2177
  1106
    super update:something with:someArgument from:aModel.
cg@3037
  1107
!
cg@3037
  1108
cg@3037
  1109
updateInspector
cg@3037
  1110
    |view obj|
cg@3037
  1111
cg@3037
  1112
    view := self selectedView.
cg@3037
  1113
    (view isNil or:[self inspectorMode == #widget]) ifTrue:[
cg@3037
  1114
        obj := view.
cg@3049
  1115
    ] ifFalse:[ (self inspectorMode == #group) ifTrue:[
cg@3049
  1116
        obj := view windowGroup
cg@3049
  1117
    ] ifFalse:[ (self inspectorMode == #sensor) ifTrue:[
cg@3049
  1118
        obj := view sensor
cg@3049
  1119
    ] ifFalse:[ (self inspectorMode == #model) ifTrue:[
cg@3049
  1120
        obj := view model
cg@3037
  1121
    ] ifFalse:[
cg@3037
  1122
        obj := view application.
cg@3049
  1123
    ]]]].
cg@3037
  1124
    inspectorView inspect:obj.
cg@3037
  1125
    inspectorView headLineLabel:(obj class nameWithoutPrefix)
cg@3037
  1126
cg@3037
  1127
    "Created: / 30-07-2013 / 09:21:16 / cg"
ca@2177
  1128
! !
ca@2177
  1129
cg@2744
  1130
!ViewTreeInspectorApplication methodsFor:'event processing'!
ca@2177
  1131
ca@2177
  1132
processButtonMotionEvent:ev
ca@2455
  1133
    |click rootView|
ca@2177
  1134
ca@2455
  1135
    motionAction isNil ifTrue:[^ self].
ca@2455
  1136
ca@2455
  1137
    (rootView := model rootView) isNil ifTrue:[
ca@2455
  1138
        clickedItem := motionAction := nil.
ca@2455
  1139
        ^ self
ca@2455
  1140
    ].
ca@2455
  1141
ca@2455
  1142
    click := rootView device
ca@2455
  1143
            translatePoint:((ev x)@ (ev y))
ca@2455
  1144
            fromView:(ev view)
ca@2455
  1145
            toView:rootView.
ca@2455
  1146
ca@2455
  1147
    click = clickedPoint ifFalse:[
ca@2455
  1148
        (clickedItem isNil or:[(click dist:clickedPoint) > 5.0]) ifTrue:[
ca@2455
  1149
            motionAction value:click
ca@2177
  1150
        ]
ca@2177
  1151
    ].
ca@2177
  1152
!
ca@2177
  1153
ca@2177
  1154
processButtonPressEvent:ev
ca@2455
  1155
    |rootView sensor lastRectangle|
ca@2455
  1156
ca@2455
  1157
    rootView    := model rootView.
ca@2177
  1158
    sensor      := model rootView sensor.
ca@2177
  1159
    clickedItem := model listOfItems detectItemRespondsToView:(ev view).
ca@2177
  1160
ca@2177
  1161
    (sensor ctrlDown or:[sensor shiftDown]) ifTrue:[
ca@2177
  1162
        clickedItem notNil ifTrue:[
ca@2177
  1163
            self selectOnClickHolder value ifTrue:[
ca@2177
  1164
                model toggleSelectItem:clickedItem
ca@2177
  1165
            ].
ca@2177
  1166
        ].
ca@2177
  1167
        clickedItem := motionAction := nil.
ca@2455
  1168
        ^ self
ca@2455
  1169
    ].
ca@2177
  1170
ca@2455
  1171
    clickedPoint := rootView device translatePoint:((ev x)@ (ev y))  fromView:(ev view) toView:rootView.
ca@2455
  1172
    lastRectangle := nil.
ca@2177
  1173
ca@2455
  1174
    motionAction :=[:p|
ca@2455
  1175
        rootView    := model rootView device rootView.
ca@2455
  1176
        rootView    := model rootView.
ca@2455
  1177
        clickedItem := nil.
ca@2177
  1178
ca@2455
  1179
        rootView xoring:[
ca@2455
  1180
            lastRectangle notNil ifTrue:[ rootView displayRectangle:lastRectangle ]
ca@2455
  1181
                                ifFalse:[ rootView clippedByChildren:false ].
ca@2455
  1182
ca@2455
  1183
            p isNil ifTrue:[
ca@2455
  1184
                rootView clippedByChildren:true.
ca@2455
  1185
                motionAction := nil.
ca@2455
  1186
            ] ifFalse:[
ca@2455
  1187
                lastRectangle := Rectangle origin:(clickedPoint min:p) corner:(clickedPoint max:p).
ca@2455
  1188
                rootView displayRectangle:lastRectangle.
ca@2177
  1189
            ].
ca@2455
  1190
            rootView flush.
ca@2455
  1191
        ].
ca@2455
  1192
        lastRectangle
ca@2455
  1193
    ].
ca@2177
  1194
!
ca@2177
  1195
ca@2177
  1196
processButtonReleaseEvent:anEvent
ca@2177
  1197
    |rootView rectangle newItems widget origin|
ca@2177
  1198
ca@2455
  1199
    (rootView := model rootView) isNil ifTrue:[
ca@2455
  1200
        clickedItem := motionAction := nil.
ca@2455
  1201
        ^ self
ca@2455
  1202
    ].
ca@2177
  1203
    motionAction isNil ifTrue:[ ^ self ].
ca@2177
  1204
    clickedItem notNil ifTrue:[ ^ model selectItem:clickedItem ].
ca@2177
  1205
ca@2455
  1206
    rectangle := motionAction value:nil.
ca@2455
  1207
    rectangle isNil ifTrue:[^ self].
ca@2177
  1208
ca@2455
  1209
    newItems := OrderedCollection new.
ca@2177
  1210
ca@2455
  1211
    model rootItem recursiveDo:[:anItem|
ca@2455
  1212
        widget := anItem widget.
ca@2455
  1213
        origin := widget originRelativeTo:rootView.
ca@2455
  1214
ca@2455
  1215
        (rectangle containsRect:(Rectangle origin:origin extent:(widget extent))) ifTrue:[
ca@2455
  1216
            newItems add:anItem.
ca@2455
  1217
        ]
ca@2177
  1218
    ].
ca@2455
  1219
    model value:newItems.
ca@2177
  1220
!
ca@2177
  1221
ca@2177
  1222
processEvent:anEvent
ca@2177
  1223
    |button menu|
ca@2177
  1224
cg@2758
  1225
    anEvent isKeyPressEvent ifTrue:[ self processKeyPressEvent:anEvent. ^ self  ].
ca@2177
  1226
    anEvent isButtonEvent  ifFalse:[ ^ self ].
ca@2177
  1227
ca@2177
  1228
    button := anEvent button.
ca@2177
  1229
ca@2177
  1230
    (button == 2 or:[button == #menu]) ifTrue:[
ca@2177
  1231
        motionAction isNil ifTrue:[
ca@2177
  1232
            anEvent isButtonPressEvent ifTrue:[
ca@2177
  1233
                self selectOnClickHolder value ifTrue:[
ca@2177
  1234
                    menu := self middleButtonMenu value.
ca@2177
  1235
                    menu notNil ifTrue:[
cg@2758
  1236
                        menu := MenuPanel 
cg@2758
  1237
                                    menu:(Menu new fromLiteralArrayEncoding:menu)
cg@2758
  1238
                                    receiver:self.
ca@2177
  1239
                        menu startUp.
ca@2177
  1240
                    ]
ca@2177
  1241
                ].
ca@2177
  1242
            ].
ca@2177
  1243
            clickedItem := nil.
ca@2177
  1244
        ].
ca@2177
  1245
        ^ self
ca@2177
  1246
    ].
ca@2177
  1247
cg@2758
  1248
    anEvent isButtonPressEvent  ifTrue:[ self processButtonPressEvent:anEvent. ^ self ].
cg@2758
  1249
    anEvent isButtonMotionEvent ifTrue:[ self processButtonMotionEvent:anEvent. ^ self ].
ca@2177
  1250
ca@2177
  1251
    anEvent isButtonReleaseEvent ifTrue:[
ca@2177
  1252
        self selectOnClickHolder value ifTrue:[
ca@2177
  1253
            self processButtonReleaseEvent:anEvent
ca@2177
  1254
        ].
ca@2177
  1255
    ].
ca@2177
  1256
    clickedItem := motionAction := nil.
ca@2177
  1257
ca@2177
  1258
    anEvent type == #'buttonMultiPress:x:y:' ifTrue:[
ca@2177
  1259
        self selectOnClickHolder value ifTrue:[
ca@2177
  1260
            self doInspect:#view.
ca@2177
  1261
        ].
ca@2177
  1262
    ].
ca@2177
  1263
!
ca@2177
  1264
ca@2177
  1265
processKeyPressEvent:anEvent
ca@2177
  1266
    |item prnt idx key max next|
ca@2177
  1267
ca@2177
  1268
    key := anEvent key.
ca@2177
  1269
    key isSymbol ifFalse:[^ self].
ca@2177
  1270
ca@2177
  1271
    key == #Delete    ifTrue:[ ^ self doDestroy ].
ca@2177
  1272
    key == #InspectIt ifTrue:[ ^ self doInspect:#view ].
ca@2177
  1273
ca@2177
  1274
    (   key == #CursorUp
ca@2177
  1275
    or:[key == #CursorDown
ca@2177
  1276
    or:[key == #CursorLeft
ca@2177
  1277
    or:[key == #CursorRight]]]
ca@2177
  1278
    ) ifFalse:[
ca@2177
  1279
        ^ self
ca@2177
  1280
    ].
ca@2177
  1281
    item := model selectedItem.
ca@2177
  1282
ca@2177
  1283
    item isNil ifTrue:[
ca@2177
  1284
        ^ model selectedItem:(model first ? model rootItem)
ca@2177
  1285
    ].
ca@2177
  1286
ca@2177
  1287
    prnt := item parent.
ca@2177
  1288
    prnt isNil ifTrue:[
ca@2177
  1289
        "/ is the root item
ca@2177
  1290
        (key == #CursorUp or:[key == #CursorLeft]) ifTrue:[item := model listOfItems last]
ca@2177
  1291
                                                  ifFalse:[item := item at:1 ifAbsent:item].
ca@2177
  1292
cg@2758
  1293
        ^ model selectedItem:item
ca@2177
  1294
    ].
ca@2177
  1295
    key == #CursorLeft ifTrue:[ ^ model selectedItem:prnt ].
ca@2177
  1296
ca@2177
  1297
    key == #CursorRight ifTrue:[
ca@2177
  1298
        next := item at:1 ifAbsent:nil.
ca@2177
  1299
        next notNil ifTrue:[ model selectedItem:next ].
cg@2758
  1300
        ^ self
ca@2177
  1301
    ].
ca@2177
  1302
ca@2177
  1303
    max := prnt size.
ca@2177
  1304
ca@2177
  1305
    key == #CursorUp ifTrue:[
ca@2177
  1306
        idx := prnt identityIndexOf:item.
ca@2177
  1307
        idx == 1 ifTrue:[idx := max + 1].
ca@2177
  1308
        model selectedItem:(prnt at:idx - 1).
cg@2758
  1309
        ^ self.
ca@2177
  1310
    ].
ca@2177
  1311
ca@2177
  1312
    key == #CursorDown ifTrue:[
ca@2177
  1313
        idx := prnt identityIndexOf:item.
ca@2177
  1314
        idx == max ifTrue:[idx := 0].
ca@2177
  1315
        model selectedItem:(prnt at:idx + 1).
cg@2758
  1316
        ^ self.
ca@2177
  1317
    ].
ca@2177
  1318
!
ca@2177
  1319
ca@2177
  1320
processMappedView:aView
ca@2177
  1321
    |parent anchor|
ca@2177
  1322
ca@2177
  1323
    parent := self listOfItems detectItemRespondsToView:aView.
ca@2177
  1324
    parent isNil ifTrue:[ ^ self ].
ca@2177
  1325
ca@2177
  1326
    NotFoundSignal handle:[:ex|
ca@2177
  1327
        "contained subvies used by spec are not yet created;
ca@2177
  1328
         thus we have to wait until last used subview is build
ca@2177
  1329
        "
ca@2177
  1330
        anchor := nil.
ca@2177
  1331
    ] do:[
ca@2177
  1332
        anchor := parent class buildViewsFrom:(parent widget).
ca@2177
  1333
    ].
ca@2177
  1334
    anchor notNil ifTrue:[
ca@2177
  1335
        parent updateFromChildren:anchor children.
ca@2177
  1336
    ].
ca@2177
  1337
! !
ca@2177
  1338
cg@2744
  1339
!ViewTreeInspectorApplication methodsFor:'initialization & release'!
ca@2177
  1340
ca@2177
  1341
closeDownViews
ca@2455
  1342
    "release the grapped application"
ca@2455
  1343
ca@2177
  1344
    process := nil.
ca@2177
  1345
    super closeDownViews.
ca@2177
  1346
    self doUnpick.
ca@2177
  1347
!
ca@2177
  1348
ca@2177
  1349
initialize
ca@2455
  1350
    "setup my model and channels"
ca@2455
  1351
ca@2177
  1352
    super initialize.
ca@2177
  1353
ca@2177
  1354
    hasSingleSelectionHolder := false asValue.
ca@2177
  1355
    followFocusChannel       := false asValue.
cg@3124
  1356
    isCatchingEventsChannel  := false asValue.
cg@3037
  1357
    inspectorModeIndexHolder := 1 asValue.
cg@3037
  1358
    inspectorModeIndexHolder onChangeSend:#inspectorModeIndexHolderChanged to:self.
ca@2177
  1359
ca@2177
  1360
    model := ViewTreeModel new.
ca@2177
  1361
    model inputEventAction:[:ev| self processEvent:ev ].
ca@2177
  1362
    model mappedViewAction:[:vw| self processMappedView:vw ].
ca@2177
  1363
    model application:self.
ca@2458
  1364
    model addDependent:self.
ca@2458
  1365
ca@2177
  1366
ca@2451
  1367
    showNamesHolder := false asValue.
ca@2451
  1368
    showNamesHolder addDependent:self.
cg@3037
  1369
cg@3037
  1370
    "Modified: / 30-07-2013 / 09:20:08 / cg"
ca@2177
  1371
!
ca@2177
  1372
cg@2770
  1373
postBuildInspectorView:anInspector
cg@2770
  1374
    inspectorView := anInspector.
cg@2770
  1375
!
cg@2770
  1376
ca@2177
  1377
postBuildTree:aTree
ca@2177
  1378
    treeView := aTree scrolledView.
cg@3105
  1379
    "/ treeView hasConstantHeight:true.
cg@3104
  1380
!
cg@3104
  1381
cg@3104
  1382
release
cg@3104
  1383
    "release the grapped application"
cg@3104
  1384
cg@3104
  1385
    super release.
cg@3104
  1386
    self doUnpick.
ca@2177
  1387
! !
ca@2177
  1388
cg@2744
  1389
!ViewTreeInspectorApplication methodsFor:'menu queries'!
ca@2177
  1390
ca@2177
  1391
hasApplication
ca@2455
  1392
    "returns true if the current selected view has an application"
ca@2455
  1393
ca@2177
  1394
    |view|
ca@2177
  1395
ca@2177
  1396
    view := self selectedView.
ca@2177
  1397
  ^ (view notNil and:[view application notNil])
ca@2177
  1398
!
ca@2177
  1399
ca@2177
  1400
hasController
ca@2177
  1401
    "returns true if the current selected item's view has a controller
ca@2455
  1402
     other than nil or the view itself"
ca@2455
  1403
ca@2177
  1404
    |view controller|
ca@2177
  1405
ca@2177
  1406
    view := self selectedView.
ca@2177
  1407
ca@2177
  1408
    view notNil ifTrue:[
ca@2177
  1409
        controller := view controller.
ca@2177
  1410
      ^ (controller notNil and:[controller ~~ view])
ca@2177
  1411
    ].
ca@2177
  1412
    ^ false
ca@2177
  1413
!
ca@2177
  1414
ca@2177
  1415
hasModel
ca@2455
  1416
    "returns true if the current selected view has a model"
ca@2455
  1417
ca@2177
  1418
    |view|
ca@2177
  1419
ca@2177
  1420
    view := self selectedView.
ca@2177
  1421
  ^ (view notNil and:[view model notNil])
ca@2177
  1422
! !
ca@2177
  1423
cg@2744
  1424
!ViewTreeInspectorApplication methodsFor:'menu specs'!
ca@2177
  1425
ca@2177
  1426
middleButtonMenu
ca@2455
  1427
    "returns the middleButton menu for the single selected item or nil"
ca@2455
  1428
cg@2758
  1429
    ^ [ 
cg@2758
  1430
        model selectedItem notNil 
cg@2758
  1431
            ifTrue:[self class middleButtonMenu]
cg@2758
  1432
            ifFalse:[nil]
ca@2177
  1433
      ]
ca@2177
  1434
!
ca@2177
  1435
ca@2177
  1436
submenuApplications:aMenu
ca@2177
  1437
    |applications menu item list addBlock|
ca@2177
  1438
ca@2177
  1439
    item := aMenu selection nameKey == #single ifTrue:[model selectedItem]
ca@2177
  1440
                                              ifFalse:[model rootItem].
ca@2177
  1441
    item isNil ifTrue:[^ nil].
ca@2177
  1442
ca@2177
  1443
    applications := IdentityDictionary new.
ca@2177
  1444
ca@2177
  1445
    addBlock := [:el| |cls ctr|
ca@2177
  1446
        cls := self resolveApplicationClassFor:el.
ca@2177
  1447
ca@2177
  1448
        cls notNil ifTrue:[
ca@2177
  1449
            ctr := applications at:cls ifAbsent:0.
ca@2177
  1450
            applications at:cls put:(ctr + 1).
ca@2177
  1451
        ].
ca@2177
  1452
    ].
ca@2177
  1453
    item recursiveDo:addBlock.
ca@2177
  1454
    addBlock value:item.
ca@2177
  1455
ca@2177
  1456
    applications isEmpty ifTrue:[^ nil ].
ca@2177
  1457
    list := SortedCollection sortBlock:[:a :b| a title < b title ].
ca@2177
  1458
ca@2177
  1459
    applications keysAndValuesDo:[:cls :ctr|
ca@2177
  1460
       list add:(MenuDesc title:(cls name)
ca@2177
  1461
                          value:(ctr printString)
ca@2177
  1462
                         action:[self doSelectNextOfApplicationClass:cls startingIn:item]
ca@2177
  1463
                 ).
ca@2177
  1464
    ].
ca@2177
  1465
ca@2177
  1466
    menu := MenuDesc buildFromList:list onGC:aMenu.
ca@2177
  1467
    menu do:[:el|
ca@2177
  1468
        el hideMenuOnActivated:false
ca@2177
  1469
    ].
ca@2177
  1470
    ^ menu
ca@2177
  1471
!
ca@2177
  1472
ca@2177
  1473
submenuComponents:aMenu
ca@2177
  1474
    |widgets list total menu item|
ca@2177
  1475
ca@2177
  1476
    item := aMenu selection nameKey == #single ifTrue:[model selectedItem]
ca@2177
  1477
                                              ifFalse:[model rootItem].
ca@2177
  1478
    item isNil ifTrue:[^ nil].
ca@2177
  1479
ca@2177
  1480
    widgets := IdentityDictionary new.
ca@2177
  1481
    total   := 0.
ca@2177
  1482
ca@2177
  1483
    item recursiveDo:[:el| |cls ctr|
ca@2177
  1484
        cls := el widget.
ca@2177
  1485
ca@2177
  1486
        cls notNil ifTrue:[
ca@2177
  1487
            cls := cls class.
ca@2177
  1488
            ctr := widgets at:cls ifAbsent:0.
ca@2177
  1489
            widgets at:cls put:(ctr + 1).
ca@2177
  1490
            total := total + 1.
ca@2177
  1491
        ].
ca@2177
  1492
    ].
ca@2177
  1493
    total == 0 ifTrue:[^ nil].
ca@2177
  1494
    list := SortedCollection sortBlock:[:a :b| a title < b title ].
ca@2177
  1495
ca@2177
  1496
    widgets keysAndValuesDo:[:cls :ctr|
ca@2177
  1497
        list add:(MenuDesc title:(cls name)
ca@2177
  1498
                           value:(ctr printString)
ca@2177
  1499
                          action:[self doSelectNextOfClass:cls startingIn:item]
ca@2177
  1500
                 ).
ca@2177
  1501
    ].
ca@2177
  1502
    list := list asOrderedCollection.
ca@2177
  1503
    list add:(MenuDesc separator).
ca@2177
  1504
    list add:(MenuDesc title:'Total' value:(total printString)).
ca@2177
  1505
    menu := MenuDesc buildFromList:list onGC:aMenu.
ca@2177
  1506
    menu do:[:el|
ca@2177
  1507
        el hideMenuOnActivated:false
ca@2177
  1508
    ].
ca@2177
  1509
    ^ menu
ca@2177
  1510
!
ca@2177
  1511
ca@2177
  1512
submenuGeometry:aMenu
ca@2455
  1513
    "builds and returns the geometry submenu"
ca@2455
  1514
ca@2177
  1515
    |view point inst list x y|
ca@2177
  1516
ca@2177
  1517
    view := self selectedView.
ca@2177
  1518
    view isNil ifTrue:[^ nil].
ca@2177
  1519
ca@2177
  1520
    list := OrderedCollection new.
ca@2177
  1521
ca@2177
  1522
    "/ origin
ca@2177
  1523
    point := view relativeOrigin.
ca@2177
  1524
    point isNil ifTrue:[ point := view origin ].
ca@2177
  1525
ca@2177
  1526
    x := view left.
ca@2177
  1527
    y := view top.
ca@2177
  1528
ca@2177
  1529
    (x == point x and:[y == point y]) ifTrue:[ inst := point ]
ca@2177
  1530
                                     ifFalse:[ inst := '%1 --> (%2@%3)' bindWith:point with:x with:y ].
ca@2177
  1531
ca@2177
  1532
    list add:(MenuDesc title:'origin' value:inst).
ca@2177
  1533
ca@2177
  1534
    "/ corner
ca@2177
  1535
    point := view relativeCorner.
ca@2177
  1536
    point isNil ifTrue:[ point := view corner ].
ca@2177
  1537
ca@2177
  1538
    x := view right.
ca@2177
  1539
    y := view bottom.
ca@2177
  1540
ca@2177
  1541
    (x == point x and:[y == point y]) ifTrue:[ inst := point ]
ca@2177
  1542
                                     ifFalse:[ inst := '%1 --> (%2@%3)' bindWith:point with:x with:y ].
ca@2177
  1543
ca@2177
  1544
    list add:(MenuDesc title:'corner' value:inst).
ca@2177
  1545
ca@2177
  1546
    "/ extent
ca@2177
  1547
    (point := view relativeExtent) isNil ifTrue:[point := view extent].
ca@2177
  1548
    list add:(MenuDesc title:'extent' value:point).
ca@2177
  1549
ca@2177
  1550
    "/ preferred extent
ca@2177
  1551
    list add:(MenuDesc title:'pref. extent' value:(view preferredExtent)).
ca@2177
  1552
    list add:(MenuDesc separator).
ca@2177
  1553
ca@2177
  1554
    "/ view insets
ca@2177
  1555
    inst := 'l:%1  r:%2  t:%3  b:%4' bindWith:(view leftInset)
ca@2177
  1556
                                         with:(view rightInset)
ca@2177
  1557
                                         with:(view topInset)
ca@2177
  1558
                                         with:(view bottomInset).
ca@2177
  1559
ca@2177
  1560
    list add:(MenuDesc title:'insets'      value:inst).
ca@2177
  1561
    list add:(MenuDesc title:'borderWidth' value:(view borderWidth)).
ca@2177
  1562
    list add:(MenuDesc title:'level'       value:(view level)).
ca@2177
  1563
    list add:(MenuDesc separator).
ca@2177
  1564
ca@2177
  1565
    (inst := view layout) notNil ifTrue:[ inst := inst displayString ].
ca@2177
  1566
    list add:(MenuDesc title:'layout' value:inst).
ca@2177
  1567
ca@2177
  1568
    (inst := view transformation) notNil ifTrue:[ inst := inst displayString ].
ca@2177
  1569
    list add:(MenuDesc title:'transformation' value:inst).
ca@2177
  1570
cg@3183
  1571
    (view isKindOf:Label) ifTrue:[
cg@3183
  1572
        list add:(MenuDesc separator).
cg@3183
  1573
        (inst := view adjust) notNil ifTrue:[ inst := inst displayString ].
cg@3183
  1574
        list add:(MenuDesc title:'adjust' value:inst).
cg@3183
  1575
    ].
cg@3183
  1576
    (view isKindOf:PanelView) ifTrue:[
cg@3183
  1577
        list add:(MenuDesc separator).
cg@3183
  1578
        (inst := view horizontalLayout ) notNil ifTrue:[ inst := inst displayString ].
cg@3183
  1579
        list add:(MenuDesc title:'horizontalLayout' value:inst).
cg@3183
  1580
        (inst := view verticalLayout ) notNil ifTrue:[ inst := inst displayString ].
cg@3183
  1581
        list add:(MenuDesc title:'verticalLayout' value:inst).
cg@3183
  1582
    ].
cg@3183
  1583
cg@3183
  1584
    ^ MenuDesc buildFromList:list onGC:aMenu
ca@2177
  1585
!
ca@2177
  1586
ca@2177
  1587
submenuInspector:aMenu
ca@2455
  1588
    "builds and returns the inspector submenu"
ca@2455
  1589
cg@3040
  1590
    |view list n names label value indices|
ca@2177
  1591
ca@2177
  1592
    view := self selectedView.
ca@2177
  1593
    view isNil ifTrue:[^ nil].
ca@2177
  1594
ca@2177
  1595
    n := view class instSize.
ca@2177
  1596
    n > 0 ifFalse:[^ nil ].
ca@2177
  1597
ca@2177
  1598
    list  := OrderedCollection new:n.
ca@2177
  1599
    names := view class allInstVarNames.
cg@3040
  1600
    indices := (1 to:names size) asArray.
cg@3040
  1601
    names sortWith:indices.
ca@2177
  1602
ca@2177
  1603
    1 to:n do:[:i| |action|
ca@2177
  1604
        label := (names at:i) printString.
cg@3040
  1605
        value := view instVarAt:(indices at:i).
ca@2177
  1606
        value isNil ifTrue:[
ca@2177
  1607
            value  := '------'.
ca@2177
  1608
            action := nil.
ca@2177
  1609
        ] ifFalse:[
ca@2177
  1610
            value  := value displayString contractAtEndTo:40.
ca@2177
  1611
            action := [(view instVarAt:i) inspect].
ca@2177
  1612
        ].
ca@2177
  1613
        list add:(MenuDesc title:label value:value action:action).
ca@2177
  1614
    ].
ca@2177
  1615
ca@2177
  1616
    ^ MenuDesc buildFromList:list onGC:aMenu
cg@3040
  1617
cg@3040
  1618
    "Modified: / 31-07-2013 / 13:12:52 / cg"
ca@2177
  1619
!
ca@2177
  1620
ca@2177
  1621
submenuInterface:aMenu
ca@2455
  1622
    "builds and returns the interface submenu"
ca@2455
  1623
ca@2177
  1624
    |view label inst value list|
ca@2177
  1625
ca@2177
  1626
    view := self selectedView.
ca@2177
  1627
    view isNil ifTrue:[^ nil].
ca@2177
  1628
ca@2177
  1629
    list := OrderedCollection new.
ca@2177
  1630
ca@2177
  1631
    inst  := view controller.
ca@2177
  1632
    value := nil.
ca@2177
  1633
ca@2177
  1634
    inst isNil ifTrue:[
ca@2177
  1635
        label := nil
ca@2177
  1636
    ] ifFalse:[
cg@2758
  1637
        inst == view ifTrue:[ 
cg@2758
  1638
            label := '== view itself' 
cg@2758
  1639
        ] ifFalse:[ 
cg@2758
  1640
            label := inst displayString.
cg@2758
  1641
            value := [view controller inspect].
cg@2758
  1642
        ].
ca@2177
  1643
    ].
ca@2177
  1644
    list add:(MenuDesc title:'controller' value:label action:value).
ca@2177
  1645
ca@2177
  1646
    inst := view delegate.
ca@2177
  1647
    inst notNil ifTrue:[
ca@2177
  1648
        list add:(MenuDesc title:'delegate' value:(inst displayString) action:[ view delegate inspect ]).
ca@2177
  1649
    ].
ca@2177
  1650
ca@2177
  1651
    inst := view application.
ca@2177
  1652
cg@2758
  1653
    inst notNil ifTrue:[ 
cg@2758
  1654
        |topAppl|
cg@2758
  1655
ca@2177
  1656
        list add:(MenuDesc title:'application' value:inst action:[ view application inspect ]).
ca@2177
  1657
ca@2177
  1658
        topAppl := inst topApplication.
ca@2177
  1659
ca@2177
  1660
        (topAppl notNil and:[topAppl ~~ inst]) ifTrue:[
ca@2177
  1661
            list add:(MenuDesc title:'topApplication' value:topAppl action:[ inst topApplication inspect ]).
ca@2177
  1662
        ].
ca@2177
  1663
    ].
ca@2177
  1664
    list add:(MenuDesc separator).
ca@2177
  1665
cg@2888
  1666
    (view respondsTo:#'model') ifTrue:[
cg@2779
  1667
        inst := view model.
ca@2177
  1668
cg@2888
  1669
        inst isNil 
cg@2888
  1670
            ifTrue:[ label := value := nil ]
cg@2888
  1671
            ifFalse:[ label := inst displayString.
cg@2888
  1672
                      label := label,(self aspectLabelFor:inst inApplicationOf:view).  
cg@2888
  1673
                      value := [ view model inspect ].
cg@2888
  1674
                    ].
ca@2177
  1675
ca@2177
  1676
        list add:(MenuDesc title:'model' value:label action:value).
ca@2177
  1677
ca@2177
  1678
        (inst notNil and:[view respondsTo:#modelInterface]) ifTrue:[
ca@2177
  1679
            view modelInterface keysAndValuesDo:[:key : val|
ca@2177
  1680
                val isNil ifTrue:[ label := nil ]
ca@2177
  1681
                         ifFalse:[ label := val displayString ].
ca@2177
  1682
ca@2177
  1683
                list add:(MenuDesc title:('      - ', key) value:label ).
ca@2177
  1684
            ]
ca@2177
  1685
        ].
ca@2177
  1686
    ].
ca@2177
  1687
ca@2177
  1688
    (view respondsTo:#enableChannel) ifTrue:[
ca@2177
  1689
        inst := view enableChannel.
ca@2177
  1690
ca@2177
  1691
        inst isNil ifTrue:[ label := value := nil ]
ca@2177
  1692
                  ifFalse:[ label := inst displayString.
cg@2888
  1693
                            label := label,(self aspectLabelFor:inst inApplicationOf:view).  
ca@2177
  1694
                            value := [ view enableChannel inspect ].
ca@2177
  1695
                          ].
ca@2177
  1696
ca@2177
  1697
        list add:(MenuDesc title:'enableChannel' value:label action:value).
ca@2177
  1698
    ].
ca@2177
  1699
cg@2888
  1700
    #( #action #pressAction #releaseAction ) do:[:actionSelector |
cg@2779
  1701
        (view respondsTo:actionSelector) ifTrue:[
cg@2779
  1702
            inst := view perform:actionSelector.
cg@2779
  1703
cg@2779
  1704
            inst isNil 
cg@2779
  1705
                ifTrue:[ label := value := nil ]
cg@2779
  1706
                ifFalse:[ label := inst displayString.
cg@2779
  1707
                            value := [ (view perform:actionSelector) inspect ].
cg@2779
  1708
                        ].
cg@2779
  1709
cg@3040
  1710
            list add:(MenuDesc title:actionSelector"'action'" value:label action:value).
cg@2779
  1711
        ].
cg@2779
  1712
    ].
cg@2779
  1713
ca@2177
  1714
    list last isSeparator ifFalse:[ list add:(MenuDesc separator) ].
ca@2177
  1715
ca@2177
  1716
    (view respondsTo:#listHolder) ifTrue:[
ca@2177
  1717
        inst := view listHolder.
ca@2177
  1718
ca@2177
  1719
        inst isNil ifTrue:[ label := value := nil ]
ca@2177
  1720
                  ifFalse:[ label := inst class printString.
cg@2888
  1721
                            label := label,(self aspectLabelFor:inst inApplicationOf:view).  
ca@2177
  1722
                            value := [ view listHolder inspect ].
ca@2177
  1723
                          ].
ca@2177
  1724
        list add:(MenuDesc title:'listHolder' value:label action:value).
ca@2177
  1725
    ].
ca@2177
  1726
ca@2177
  1727
    (view respondsTo:#list) ifTrue:[
ca@2177
  1728
        inst := view list.
ca@2177
  1729
ca@2177
  1730
        inst isNil ifTrue:[ label := value := nil ]
ca@2177
  1731
                  ifFalse:[ label := '%1 [%2]' bindWith:(inst class printString) with:(inst size).
cg@2888
  1732
                            label := label,(self aspectLabelFor:inst inApplicationOf:view).  
ca@2177
  1733
                            value := [ view list inspect ].
ca@2177
  1734
                          ].
ca@2177
  1735
ca@2177
  1736
        list add:(MenuDesc title:'list' value:label action:value).
ca@2177
  1737
    ].
ca@2177
  1738
ca@2177
  1739
    list last isSeparator ifTrue:[ list removeLast ].
cg@2888
  1740
    ^ MenuDesc buildFromList:list onGC:aMenu
cg@2888
  1741
cg@3040
  1742
    "Modified: / 31-07-2013 / 13:09:55 / cg"
ca@2177
  1743
!
ca@2177
  1744
ca@2177
  1745
submenuVisibility:aMenu
ca@2455
  1746
    "builds and returns the geometry submenu"
ca@2455
  1747
ca@2177
  1748
    |view list value|
ca@2177
  1749
ca@2177
  1750
    view := self selectedView.
ca@2177
  1751
    view isNil ifTrue:[^ nil].
ca@2177
  1752
ca@2177
  1753
    list := OrderedCollection new.
ca@2177
  1754
ca@2177
  1755
    list add:(MenuDesc title:'device'     value:(view device printString)).
ca@2177
  1756
    list add:(MenuDesc title:'drawableId' value:(view id)).
ca@2177
  1757
    list add:(MenuDesc title:'gcId'       value:(view gcId)).
ca@2177
  1758
ca@2177
  1759
    list add:(MenuDesc separator).
ca@2177
  1760
ca@2177
  1761
    list add:(MenuDesc title:'shown'    value:(view shown)).
ca@2177
  1762
    list add:(MenuDesc title:'realized' value:(view realized)).
ca@2177
  1763
ca@2177
  1764
    list add:(MenuDesc separator).
ca@2177
  1765
ca@2177
  1766
    list add:(MenuDesc title:'hiddenOnRealize' value:(view isHiddenOnRealize)).
ca@2177
  1767
ca@2177
  1768
    (value := view visibilityChannel) isNil ifTrue:[
ca@2177
  1769
        list add:(MenuDesc title:'visibilityChannel' value:'------').
ca@2177
  1770
    ] ifFalse:[
ca@2177
  1771
        list add:(MenuDesc title:'visibilityChannel'
ca@2177
  1772
                           value:(value displayString)
ca@2177
  1773
                          action:[view visibilityChannel inspect]).
ca@2177
  1774
    ].
ca@2177
  1775
cg@2758
  1776
    ^ MenuDesc buildFromList:list onGC:aMenu
ca@2177
  1777
! !
ca@2177
  1778
cg@2744
  1779
!ViewTreeInspectorApplication methodsFor:'private'!
ca@2177
  1780
cg@2888
  1781
aspectLabelFor:aModel inApplicationOf:aView
cg@2888
  1782
    |app|
cg@2888
  1783
cg@2888
  1784
    aModel isNil ifTrue:[^ ''].
cg@2888
  1785
    aView isNil ifTrue:[^ ''].
cg@2888
  1786
    (app := aView application) isNil ifTrue:[^ ''].
cg@2888
  1787
    app builder bindings keysAndValuesDo:[:aspect :value |
cg@2888
  1788
        value == aModel ifTrue:[^ ' [aspect: ',aspect,']'].
cg@2888
  1789
    ].
cg@2888
  1790
    app class allInstVarNames do:[:nm | 
cg@2888
  1791
        (app instVarNamed:nm) == aModel ifTrue:[^ ' [instvar: ',nm,']']
cg@2888
  1792
    ].
cg@2888
  1793
cg@2888
  1794
    ^ ''
cg@2888
  1795
cg@2888
  1796
    "Created: / 27-04-2012 / 14:22:09 / cg"
cg@2888
  1797
!
cg@2888
  1798
ca@2177
  1799
selectFocusView
cg@2762
  1800
    |rootView focusView|
ca@2177
  1801
ca@2177
  1802
    rootView := model rootView.
ca@2177
  1803
ca@2177
  1804
    (rootView notNil and:[rootView shown]) ifTrue:[
ca@2177
  1805
        focusView := rootView windowGroup focusView.
ca@2177
  1806
    ].
ca@2177
  1807
    focusView isNil ifTrue:[^ self ].
ca@2177
  1808
cg@2762
  1809
    self selectView:focusView
cg@2762
  1810
!
cg@2762
  1811
cg@2762
  1812
selectView:aView
cg@2762
  1813
    |currentItem viewItem|
cg@2762
  1814
cg@2762
  1815
    currentItem := model selectedItem.
cg@2762
  1816
cg@2762
  1817
    (currentItem notNil and:[currentItem widget == aView]) ifTrue:[
ca@2177
  1818
        ^ self
ca@2177
  1819
    ].
cg@2762
  1820
    viewItem := model listOfItems recursiveDetect:[:el| el widget == aView ].
cg@2762
  1821
cg@2762
  1822
    viewItem notNil ifTrue:[
cg@2762
  1823
        model selectItem:viewItem.
ca@2177
  1824
    ].        
ca@2177
  1825
!
ca@2177
  1826
ca@2177
  1827
setRootItem:aRootItemOrNil
ca@2177
  1828
    |theProcess|
ca@2177
  1829
ca@2177
  1830
    aRootItemOrNil isNil ifTrue:[
ca@2177
  1831
        process := nil.
ca@2177
  1832
    ] ifFalse:[
ca@2177
  1833
        "/ expand tree to level 3
ca@2177
  1834
        aRootItemOrNil do:[:aRootChild|
ca@2177
  1835
            aRootChild do:[:aSubChild| aSubChild expand ].
ca@2177
  1836
            aRootChild expand.
ca@2177
  1837
        ].
ca@2177
  1838
        aRootItemOrNil expand.
ca@2177
  1839
ca@2177
  1840
        process isNil ifTrue:[
ca@2177
  1841
            theProcess := process :=
cg@3034
  1842
                Process 
cg@3034
  1843
                    for:[   
cg@3034
  1844
                        |update testModeChannel|
cg@3034
  1845
cg@3034
  1846
                        update := false.
cg@3034
  1847
                        testModeChannel := model testModeChannel.
cg@3034
  1848
cg@3034
  1849
                        [process == theProcess] whileTrue:[
cg@3034
  1850
                            Delay waitForSeconds:0.5.
cg@3034
  1851
cg@3034
  1852
                            (treeView notNil and:[process == theProcess and:[treeView shown]]) ifTrue:[
cg@3034
  1853
                                (testModeChannel value == true and:[followFocusChannel value == true]) ifTrue:[
cg@3034
  1854
                                    self selectFocusView.
ca@2177
  1855
                                ].
cg@3034
  1856
                                update ifTrue:[
cg@3034
  1857
                                    self updateShownStatus.
cg@3034
  1858
                                ].
cg@3034
  1859
                                update := update not.
cg@3034
  1860
                            ].
cg@3034
  1861
                        ].
cg@3034
  1862
                    ] 
cg@3034
  1863
                    priority:(Processor userSchedulingPriority).
cg@3034
  1864
            theProcess name:'ViewTreeInspector - Focus Follower'.
ca@2177
  1865
            theProcess resume.
ca@2177
  1866
        ].
ca@2177
  1867
    ].
ca@2177
  1868
    model rootItem:aRootItemOrNil.
cg@3034
  1869
cg@3034
  1870
    "Modified: / 25-07-2013 / 12:03:44 / cg"
ca@2177
  1871
!
ca@2177
  1872
ca@2177
  1873
updateShownStatus
ca@2177
  1874
    |rootItem min max visState listIdx visY0 visY1 height damage|
ca@2177
  1875
ca@2177
  1876
    rootItem := model rootItem.
ca@2177
  1877
    (rootItem notNil and:[rootItem widget shown]) ifFalse:[^ self].
ca@2177
  1878
ca@2177
  1879
    max := 0.
ca@2177
  1880
    min := 9999999.
ca@2177
  1881
ca@2177
  1882
    rootItem recursiveEachVisibleItemDo:[:anItem|
ca@2177
  1883
        visState := (anItem widget shown).
ca@2177
  1884
ca@2177
  1885
        visState ~~ anItem isDrawnShown ifTrue:[
ca@2177
  1886
            anItem isDrawnShown:visState.
ca@2177
  1887
            listIdx := treeView identityIndexOf:anItem.
ca@2177
  1888
ca@2177
  1889
            listIdx > 0 ifTrue:[    
ca@2177
  1890
                max := max max:listIdx.
ca@2177
  1891
                min := min min:listIdx.
ca@2177
  1892
            ].
ca@2177
  1893
        ].
ca@2177
  1894
    ].
ca@2177
  1895
    max < min ifTrue:[^ self].
ca@2177
  1896
    max := max + 1.
ca@2177
  1897
ca@2177
  1898
    visY0  := (treeView yVisibleOfLine:min) max:0.
ca@2177
  1899
    visY1  := (treeView yVisibleOfLine:max) min:(treeView height).
ca@2177
  1900
    height := visY1 - visY0.
ca@2177
  1901
    
ca@2177
  1902
    height > 2 ifTrue:[
ca@2177
  1903
        treeView shown ifTrue:[
ca@2177
  1904
            damage := Rectangle left:0 top:visY0 width:(treeView width) height:height.
ca@2177
  1905
            treeView invalidateDeviceRectangle:damage repairNow:false.
ca@2177
  1906
        ].
ca@2177
  1907
    ].
ca@2177
  1908
! !
ca@2177
  1909
cg@2744
  1910
!ViewTreeInspectorApplication methodsFor:'selection'!
ca@2177
  1911
ca@2177
  1912
selectedView
ca@2455
  1913
    "answer the selected view or nil"
ca@2455
  1914
ca@2177
  1915
    |item|
ca@2177
  1916
ca@2177
  1917
    item := model selectedItem.
ca@2177
  1918
    item notNil ifTrue:[ ^ item widget ].
ca@2177
  1919
  ^ nil
ca@2177
  1920
! !
ca@2177
  1921
cg@2744
  1922
!ViewTreeInspectorApplication methodsFor:'testing'!
ca@2177
  1923
ca@2177
  1924
resolveApplicationClassFor:aTreeItem
ca@2177
  1925
    aTreeItem isApplicationClass ifTrue:[
ca@2177
  1926
       ^ aTreeItem applicationClass
ca@2177
  1927
    ].
ca@2177
  1928
    ^ nil
ca@2177
  1929
!
ca@2177
  1930
ca@2177
  1931
selectedComponentHasChildren
ca@2177
  1932
    |item|
ca@2177
  1933
ca@2177
  1934
    item := model selectedItem.
ca@2177
  1935
    ^ (item notNil and:[item hasChildren])
ca@2177
  1936
! !
ca@2177
  1937
cg@2744
  1938
!ViewTreeInspectorApplication methodsFor:'user operations'!
ca@2177
  1939
ca@2177
  1940
doBrowse:what
ca@2177
  1941
    "open browser on:
ca@2177
  1942
        #view           browse class
ca@2177
  1943
        #model          browse model class
ca@2177
  1944
        #application    browse application class
ca@2177
  1945
        #controller     browse controller class
ca@2177
  1946
    "
cg@3167
  1947
    |inst|
cg@3167
  1948
cg@3167
  1949
    (inst := self objectToInspectOrBrowse:what) isNil ifTrue:[^ self].
cg@3167
  1950
    inst class browserClass openInClass:(inst class) selector:nil
cg@3049
  1951
cg@3049
  1952
    "Modified: / 28-08-2013 / 23:57:42 / cg"
ca@2177
  1953
!
ca@2177
  1954
cg@3174
  1955
doBrowseWindowSpecMethod
cg@3174
  1956
    |mthd|
cg@3174
  1957
cg@3174
  1958
    mthd := self windowSpecMethodOfSelection.
cg@3174
  1959
    NewSystemBrowser openInClass:mthd mclass selector:mthd selector
cg@3174
  1960
!
cg@3174
  1961
cg@3124
  1962
doCatchEvents
cg@3124
  1963
    model catchEvents:true.
cg@3124
  1964
    isCatchingEventsChannel value:true.
cg@3124
  1965
"/    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
cg@3124
  1966
"/        enabled:true;
cg@3124
  1967
"/        label:(self class releaseViewIcon);
cg@3124
  1968
"/        activeHelpKey:#doUncatchEvents.
cg@3124
  1969
!
cg@3124
  1970
cg@3171
  1971
doDebugProcess
cg@3171
  1972
    "open debugger on the window process"
cg@3171
  1973
cg@3171
  1974
    |view|
cg@3171
  1975
cg@3171
  1976
    view := self selectedView.
cg@3171
  1977
    view isNil ifTrue:[^ nil].
cg@3171
  1978
cg@3171
  1979
    Debugger openOn:view windowGroup process
cg@3171
  1980
!
cg@3171
  1981
ca@2177
  1982
doDestroy
ca@2455
  1983
    "destroy the current selected view"
ca@2455
  1984
ca@2177
  1985
    |item parent|
ca@2177
  1986
ca@2177
  1987
    item := model selectedItem.
ca@2177
  1988
    item isNil ifTrue:[ ^ self].
ca@2177
  1989
ca@2177
  1990
    parent := item parent.
ca@2177
  1991
ca@2177
  1992
    parent isNil ifTrue:[
ca@2177
  1993
        "/ the root
ca@2177
  1994
        model withSelectionHiddenDo:[item deleteAll].
ca@2177
  1995
      ^ self
ca@2177
  1996
    ].
ca@2177
  1997
ca@2177
  1998
    model withSelectionHiddenDo:[
ca@2177
  1999
        |idx nsel|
ca@2177
  2000
ca@2177
  2001
        idx := parent identityIndexOf:item.
ca@2177
  2002
ca@2177
  2003
        idx == parent size ifTrue:[
ca@2177
  2004
            nsel := parent at:(idx - 1) ifAbsent:parent
ca@2177
  2005
        ] ifFalse:[
ca@2177
  2006
            nsel := parent at:(idx + 1)
ca@2177
  2007
        ].
ca@2177
  2008
        model setValue:nil.
ca@2177
  2009
        item delete.
ca@2177
  2010
ca@2177
  2011
        parent isLayoutContainer ifTrue:[
ca@2177
  2012
            parent widget sizeChanged:nil
ca@2177
  2013
        ].
ca@2177
  2014
        model value:nsel.
ca@2177
  2015
    ].
ca@2177
  2016
!
ca@2177
  2017
cg@3174
  2018
doEditWindowSpec
cg@3174
  2019
    |mthd|
cg@3174
  2020
cg@3174
  2021
    mthd := self windowSpecMethodOfSelection.
cg@3174
  2022
    UIPainter openOnClass:mthd mclass andSelector:mthd selector
cg@3174
  2023
!
cg@3174
  2024
ca@2177
  2025
doFlash
ca@2455
  2026
    "flash the selected view"
ca@2455
  2027
ca@2177
  2028
    |view|
ca@2177
  2029
ca@2177
  2030
    view := self selectedView.
ca@2177
  2031
    view isNil ifTrue:[ ^ self].
ca@2177
  2032
ca@2177
  2033
    view shown ifTrue:[
ca@2177
  2034
        model withSelectionHiddenDo:[
ca@2177
  2035
            view perform:#flash ifNotUnderstood:nil.
ca@2177
  2036
        ].
ca@2177
  2037
    ].
ca@2177
  2038
!
ca@2177
  2039
ca@2177
  2040
doInspect:what
ca@2177
  2041
    "open inspector on:
ca@2177
  2042
        #view           inspect class
ca@2177
  2043
        #group          inspect windowGroup
ca@2177
  2044
        #model          inspect model
ca@2177
  2045
        #application    inspect application
ca@2177
  2046
        #controller     inspect controller
cg@3034
  2047
        #process        inspect application's process
ca@2177
  2048
    "
cg@3167
  2049
ca@2177
  2050
    |inst|
ca@2177
  2051
cg@3167
  2052
    (inst := self objectToInspectOrBrowse:what) isNil ifTrue:[^ self].
cg@3167
  2053
    inst inspect.
cg@3049
  2054
cg@3049
  2055
    "Modified: / 28-08-2013 / 23:58:27 / cg"
ca@2177
  2056
!
ca@2177
  2057
cg@3034
  2058
doOpenProcessMonitor
cg@3034
  2059
    (ProcessMonitorV2 ? ProcessMonitor) open
cg@3034
  2060
cg@3034
  2061
    "Created: / 25-07-2013 / 12:34:23 / cg"
cg@3034
  2062
!
cg@3034
  2063
cg@2762
  2064
doPickView
ca@2455
  2065
    "pick a window's topView"
ca@2455
  2066
cg@2762
  2067
    |screen clickedView topWindow cursor|
ca@2177
  2068
ca@2177
  2069
    self doUnpick.
ca@2177
  2070
cg@2759
  2071
    cursor := Cursor fromImage:(self class crossHairIcon).
cg@2759
  2072
cg@2759
  2073
    screen := Screen current.
cg@2762
  2074
    clickedView := screen viewFromPoint:(screen pointFromUserShowing:cursor).
cg@2762
  2075
    clickedView isNil ifTrue:[^ self].
cg@2762
  2076
cg@2762
  2077
    topWindow := clickedView topView.
cg@2762
  2078
cg@2762
  2079
    (    topWindow == Screen current rootView
cg@2762
  2080
     or:[topWindow == self window topView]
ca@2177
  2081
    ) ifTrue:[
ca@2177
  2082
        ^ self
ca@2177
  2083
    ].
cg@2978
  2084
cg@3070
  2085
    self showWindow:clickedView.
ca@2177
  2086
!
ca@2177
  2087
cg@2978
  2088
doRedraw
cg@2978
  2089
    "redraw the app"
cg@2978
  2090
cg@3124
  2091
    model rootView notNil ifTrue:[
cg@3124
  2092
        model rootView withAllSubViewsDo:[:v | v "redraw; "invalidate].
cg@3124
  2093
    ]
cg@2978
  2094
!
cg@2978
  2095
cg@3168
  2096
doSelectNextElementStartingIn:anItem forWhich:aBlock
ca@2177
  2097
    |startItem firstFound searchNext|
ca@2177
  2098
ca@2177
  2099
    startItem  := model last.
ca@2177
  2100
    searchNext := startItem notNil.        
ca@2177
  2101
    firstFound := nil.
ca@2177
  2102
ca@2177
  2103
    anItem recursiveDo:[:el|
ca@2177
  2104
        el == startItem ifTrue:[
ca@2177
  2105
            searchNext := false
ca@2177
  2106
        ] ifFalse:[
cg@3168
  2107
            (aBlock value:el) ifTrue:[
ca@2177
  2108
                searchNext ifFalse:[^ model selectItem:el].
ca@2177
  2109
ca@2177
  2110
                firstFound isNil ifTrue:[
ca@2177
  2111
                    firstFound := el
ca@2177
  2112
                ]
ca@2177
  2113
            ]
ca@2177
  2114
        ]
ca@2177
  2115
    ].
ca@2177
  2116
    firstFound notNil ifTrue:[
ca@2177
  2117
        self window beep.
ca@2177
  2118
        model selectItem:firstFound
ca@2177
  2119
    ].
ca@2177
  2120
!
ca@2177
  2121
cg@3168
  2122
doSelectNextOfApplicationClass:aClass startingIn:anItem
cg@3168
  2123
    self doSelectNextElementStartingIn:anItem forWhich:[:el | (self resolveApplicationClassFor:el) == aClass].
cg@3168
  2124
!
cg@3168
  2125
ca@2177
  2126
doSelectNextOfClass:aClass startingIn:anItem
cg@3168
  2127
    self doSelectNextElementStartingIn:anItem forWhich:[:el | el widget class == aClass].
ca@2177
  2128
!
ca@2177
  2129
cg@2978
  2130
doUncatchEvents
cg@3124
  2131
    "release the inspected window (no longer catch its events)"
cg@3124
  2132
cg@2978
  2133
    model catchEvents:false.
cg@3124
  2134
    isCatchingEventsChannel value:false.
cg@3124
  2135
"/    ((builder componentAt:'toolbarMenu') itemAt:#doUncatchEvents) 
cg@3124
  2136
"/        label:(self class releaseViewIcon);
cg@3124
  2137
"/        enabled:false;
cg@3124
  2138
"/        activeHelpKey:#doCatchEvents.
cg@2978
  2139
    self doRedraw
cg@2978
  2140
!
cg@2978
  2141
ca@2177
  2142
doUnpick
ca@2455
  2143
    "release current picked window and contained subwindows"
ca@2455
  2144
ca@2177
  2145
    self setRootItem:nil.
cg@2744
  2146
!
cg@2744
  2147
cg@3167
  2148
objectToInspectOrBrowse:what
cg@3167
  2149
    "return one of:
cg@3167
  2150
        #view           inspect class
cg@3167
  2151
        #group          inspect windowGroup
cg@3167
  2152
        #model          inspect model
cg@3167
  2153
        #application    inspect application
cg@3167
  2154
        #controller     inspect controller
cg@3167
  2155
        #process        inspect application's process
cg@3167
  2156
    "
cg@3167
  2157
    |view inst|
cg@3167
  2158
cg@3167
  2159
    view := self selectedView.
cg@3167
  2160
    view isNil ifTrue:[^ nil].
cg@3167
  2161
cg@3167
  2162
             what == #group       ifTrue:[ inst := view windowGroup ]
cg@3167
  2163
    ifFalse:[what == #model       ifTrue:[ inst := view model ]
cg@3167
  2164
    ifFalse:[what == #application ifTrue:[ inst := view application ]
cg@3167
  2165
    ifFalse:[what == #controller  ifTrue:[ inst := view controller  ]
cg@3167
  2166
    ifFalse:[what == #process     ifTrue:[ inst := view windowGroup process  ]
cg@3169
  2167
    ifFalse:[what == #sensor      ifTrue:[ inst := view sensor  ]
cg@3169
  2168
    ifFalse:[inst := view  ]]]]]].
cg@3167
  2169
cg@3167
  2170
    (inst isNil and:[what == #application]) ifTrue:[
cg@3167
  2171
        inst := view topView
cg@3167
  2172
    ].
cg@3167
  2173
    ^ inst
cg@3167
  2174
cg@3167
  2175
    "Modified: / 28-08-2013 / 23:58:27 / cg"
cg@3167
  2176
!
cg@3167
  2177
cg@2744
  2178
openDocumentation
cg@2744
  2179
    HTMLDocumentView openFullOnDocumentationFile:'tools/misc/TOP.html#VIEWTREEINSPECTOR'
cg@3014
  2180
!
cg@3014
  2181
cg@3014
  2182
showWindow:aView
cg@3014
  2183
    "show a particular window's topView hierarchy,
cg@3014
  2184
     select the given view"
cg@3014
  2185
cg@3014
  2186
    | topWindow |
cg@3014
  2187
cg@3014
  2188
    topWindow := aView topView.
cg@3014
  2189
cg@3124
  2190
    self doCatchEvents.
cg@3014
  2191
    self setRootItem:(ViewTreeItem buildViewsFrom:topWindow).
cg@3014
  2192
    self selectView:aView.
ca@2177
  2193
! !
ca@2177
  2194
cg@2744
  2195
!ViewTreeInspectorApplication::MenuDesc class methodsFor:'building'!
ca@2177
  2196
ca@2177
  2197
buildFromList:aList onGC:aMenu
ca@2177
  2198
    |tabSpec menu w menuPanel|
ca@2177
  2199
ca@2177
  2200
    w := 0.
ca@2177
  2201
    aList do:[:el| w := w max:(el widthOn:aMenu) ].
ca@2177
  2202
ca@2177
  2203
    tabSpec := TabulatorSpecification new.
ca@2177
  2204
    tabSpec unit:#pixel.
ca@2177
  2205
    tabSpec positions:#(0     1.5 ).
ca@2177
  2206
    tabSpec align:#(#left #left).
ca@2177
  2207
ca@2177
  2208
    w := w + 15.
ca@2177
  2209
    tabSpec positions:(Array with:0 with:w).
ca@2177
  2210
ca@2177
  2211
    menu := Menu new.
ca@2177
  2212
ca@2177
  2213
    aList do:[:el|
ca@2177
  2214
        menu addItem:(el asMenuItemWithTabulatorSpecification:tabSpec).
ca@2177
  2215
    ].
ca@2177
  2216
    menuPanel := MenuPanel menu:menu.
ca@2177
  2217
    ^ menuPanel
ca@2177
  2218
! !
ca@2177
  2219
cg@2744
  2220
!ViewTreeInspectorApplication::MenuDesc class methodsFor:'instance creation'!
ca@2177
  2221
ca@2177
  2222
separator
ca@2177
  2223
    ^ self new
ca@2177
  2224
!
ca@2177
  2225
ca@2177
  2226
title:aTitle value:aValue
ca@2177
  2227
    ^ self title:aTitle value:aValue action:nil
ca@2177
  2228
!
ca@2177
  2229
ca@2177
  2230
title:aTitle value:aValue action:anAction
ca@2177
  2231
    ^ self new title:aTitle value:aValue action:anAction
ca@2177
  2232
! !
ca@2177
  2233
cg@2744
  2234
!ViewTreeInspectorApplication::MenuDesc methodsFor:'accessing'!
ca@2177
  2235
ca@2177
  2236
title
ca@2177
  2237
    ^ title
ca@2177
  2238
! !
ca@2177
  2239
cg@2744
  2240
!ViewTreeInspectorApplication::MenuDesc methodsFor:'building'!
ca@2177
  2241
ca@2177
  2242
asMenuItemWithTabulatorSpecification:aTabSpec
ca@2177
  2243
    |array|
ca@2177
  2244
ca@2177
  2245
    title isNil ifTrue:[ ^ MenuItem label:value ].     "/ separator
ca@2177
  2246
ca@2177
  2247
    array := Array with:(title, ':') with:'------'.
ca@2177
  2248
ca@2177
  2249
    value notNil ifTrue:[
ca@2177
  2250
        array at:2 put:(value printString, ' ')
ca@2177
  2251
    ].
ca@2177
  2252
cg@2758
  2253
   ^ MenuItem 
cg@2758
  2254
        label:(MultiColListEntry fromStrings:array tabulatorSpecification:aTabSpec)
cg@2758
  2255
        value:action
ca@2177
  2256
! !
ca@2177
  2257
cg@2744
  2258
!ViewTreeInspectorApplication::MenuDesc methodsFor:'instance creation'!
ca@2177
  2259
ca@2177
  2260
title:aTitle value:aValue action:anAction
ca@2177
  2261
    "test for separator
ca@2177
  2262
    "
ca@2177
  2263
    title  := aTitle withoutSeparators.
ca@2177
  2264
    action := anAction.
ca@2177
  2265
ca@2177
  2266
    aValue notNil ifTrue:[
ca@2177
  2267
        value := aValue printString.
ca@2177
  2268
ca@2177
  2269
        value size > 70 ifTrue:[
ca@2177
  2270
            value := value copyFrom:1 to:70.
ca@2177
  2271
            value := value, '...'
ca@2177
  2272
        ]
ca@2177
  2273
    ].
ca@2177
  2274
! !
ca@2177
  2275
cg@2744
  2276
!ViewTreeInspectorApplication::MenuDesc methodsFor:'queries'!
ca@2177
  2277
ca@2177
  2278
isSeparator
ca@2177
  2279
    ^ title isNil
ca@2177
  2280
!
ca@2177
  2281
ca@2177
  2282
widthOn:aGC
ca@2177
  2283
    title isNil ifTrue:[^ 5].  "/ separator
cg@2758
  2284
    ^ title widthOn:aGC
ca@2177
  2285
! !
ca@2177
  2286
cg@2744
  2287
!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'building'!
cg@2744
  2288
cg@2744
  2289
buildViewsFrom:aView
cg@2744
  2290
    "build the items starting from a source view;
cg@2744
  2291
     returns the anhor.
cg@2744
  2292
    "
cg@2744
  2293
    |item subViews subItems|
cg@2744
  2294
cg@2744
  2295
    aView isNil ifTrue:[^ nil].
cg@2744
  2296
cg@2744
  2297
    item     := self forView:aView.
cg@2744
  2298
    subViews := aView subViews.
cg@2744
  2299
cg@2744
  2300
    subViews notEmptyOrNil ifTrue:[
cg@2744
  2301
        subItems := OrderedCollection new.
cg@2744
  2302
        subViews do:[:aSubView|
cg@2744
  2303
            subItems add:(self buildViewsFrom:aSubView).
cg@2744
  2304
        ].
cg@2744
  2305
        item children:subItems.
cg@2744
  2306
    ].
cg@2744
  2307
    ^ item
cg@2744
  2308
! !
cg@2744
  2309
cg@2744
  2310
!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'documentation'!
cg@2744
  2311
cg@2744
  2312
documentation
cg@2744
  2313
"
cg@2744
  2314
    ViewTreeItems represants a pickable object within a ViewTreeModel.
cg@2744
  2315
    The class is used to build up the hierarchical tree.
cg@2744
  2316
cg@2744
  2317
    [Instance variables:]
cg@2744
  2318
        widget        <View>            the widget represented by the item
cg@2744
  2319
        spec          <UISpecification> the UISpecification or nil
cg@2744
  2320
cg@2744
  2321
    [Class variables:]
cg@2744
  2322
        HandleExtent  <Point>           keeps the extent of a handle
cg@2744
  2323
cg@2744
  2324
cg@2744
  2325
    [author:]
cg@2744
  2326
        Claus Atzkern
cg@2744
  2327
cg@2744
  2328
    [see also:]
cg@2744
  2329
        HierarchicalItem
cg@2744
  2330
        ViewTreeModel
cg@2744
  2331
"
cg@2744
  2332
!
ca@2177
  2333
ca@2177
  2334
version
ca@2177
  2335
    ^ '$Header$'
ca@2177
  2336
! !
ca@2177
  2337
cg@2744
  2338
!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'initialization'!
cg@2744
  2339
cg@2744
  2340
initialize
cg@2744
  2341
    "set the extent of the Handle
cg@2744
  2342
    "
cg@2744
  2343
    HandleExtent := 6@6.
cg@2744
  2344
! !
cg@2744
  2345
cg@2744
  2346
!ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'instance creation'!
cg@2744
  2347
cg@2744
  2348
forView:aView
cg@2744
  2349
    |item|
cg@2744
  2350
cg@2744
  2351
    item := self basicNew initialize.
cg@2744
  2352
    item forView:aView.
cg@2744
  2353
  ^ item
cg@2744
  2354
!
cg@2744
  2355
cg@2744
  2356
new
cg@2744
  2357
    self error:'not allowed'.
cg@2744
  2358
  ^ nil
cg@2744
  2359
!
cg@2744
  2360
cg@2744
  2361
on:aView withSpec:aSpec
cg@2744
  2362
    |item|
cg@2744
  2363
cg@2744
  2364
    item := self basicNew initialize.
cg@2744
  2365
    item on:aView withSpec:aSpec.
cg@2744
  2366
  ^ item
cg@2744
  2367
! !
cg@2744
  2368
cg@2744
  2369
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'accessing'!
cg@2744
  2370
cg@2744
  2371
applicationClass
cg@2744
  2372
    |appl|
cg@2744
  2373
cg@2744
  2374
    widget notNil ifTrue:[
cg@2744
  2375
        appl := widget application.
cg@2744
  2376
        appl notNil ifTrue:[^ appl class ].
cg@2744
  2377
    ].
cg@2744
  2378
    ^ nil
cg@2744
  2379
!
cg@2744
  2380
cg@2744
  2381
isDrawnShown
cg@2744
  2382
    "returns true if the last display operations was done during the widget was shown
cg@2744
  2383
    "
cg@2744
  2384
    ^ isDrawnShown
cg@2744
  2385
!
cg@2744
  2386
cg@2744
  2387
isDrawnShown:aBoolean
cg@2744
  2388
    isDrawnShown := aBoolean.
cg@2744
  2389
!
cg@2744
  2390
cg@2744
  2391
rootView
cg@2744
  2392
    "returns the widget assigned to the root or nil
cg@2744
  2393
    "
cg@2744
  2394
    ^ parent rootView
cg@2744
  2395
!
cg@2744
  2396
cg@2744
  2397
specClass
cg@2744
  2398
    "returns the spec-class assigned to the item
cg@2744
  2399
    "
cg@2744
  2400
    ^ widget specClass
cg@2744
  2401
!
cg@2744
  2402
cg@2744
  2403
treeModel
cg@2744
  2404
    "returns the assigned treeModel, an instance of ViewTreeModel
cg@2744
  2405
    "
cg@2744
  2406
    ^ parent treeModel
cg@2744
  2407
!
cg@2744
  2408
cg@2744
  2409
widget
cg@2744
  2410
    "returns the widget assigned to the item
cg@2744
  2411
    "
cg@2744
  2412
    ^ widget
cg@2744
  2413
! !
cg@2744
  2414
cg@2744
  2415
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'accessing layout'!
cg@2744
  2416
cg@2744
  2417
boundsRelativeToRoot
cg@2744
  2418
    "returns the bounds relative to the root widget
cg@2744
  2419
    "
cg@2744
  2420
    ^ self originRelativeToRoot extent:(widget extent)
cg@2744
  2421
!
cg@2744
  2422
cg@2744
  2423
cornerRelativeToRoot
cg@2744
  2424
    "returns the corner relative to the root widget
cg@2744
  2425
    "
cg@2744
  2426
    ^ self originRelativeToRoot + (widget extent)
cg@2744
  2427
!
cg@2744
  2428
cg@2744
  2429
extent
cg@2744
  2430
    "returns the extent of the widget
cg@2744
  2431
    "
cg@2744
  2432
    ^ widget extent
cg@2744
  2433
!
cg@2744
  2434
cg@2744
  2435
layoutType
cg@2744
  2436
    "returns the type of layout assigned to the wiget; nil if the
cg@2744
  2437
     superView cannot resize its sub widgets
cg@2744
  2438
    "
cg@2744
  2439
    |layout specClass superView|
cg@2744
  2440
cg@2744
  2441
    (superView := widget superView) isNil ifTrue:[
cg@2744
  2442
        ^ #Extent
cg@2744
  2443
    ].
cg@2744
  2444
        
cg@2744
  2445
    specClass := superView specClass.
cg@2744
  2446
cg@2744
  2447
    (specClass notNil and:[specClass isLayoutContainer]) ifTrue:[
cg@2744
  2448
        ^ specClass canResizeSubComponents ifTrue:[#Extent] ifFalse:[nil]
cg@2744
  2449
    ].
cg@2744
  2450
cg@2744
  2451
    (layout := widget geometryLayout) isNil ifTrue:[
cg@2744
  2452
        ^ #Extent
cg@2744
  2453
    ].
cg@2744
  2454
cg@2744
  2455
    layout isLayout ifTrue:[
cg@2744
  2456
        layout isLayoutFrame        ifTrue:[ ^ #LayoutFrame ].
cg@2744
  2457
        layout isAlignmentOrigin    ifTrue:[ ^ #AlignmentOrigin ].
cg@2744
  2458
        layout isLayoutOrigin       ifTrue:[ ^ #LayoutOrigin ].
cg@2744
  2459
    ] ifFalse:[
cg@2744
  2460
        layout isRectangle          ifTrue:[ ^ #Rectangle ].
cg@2744
  2461
        layout isPoint              ifTrue:[ ^ #Point ].
cg@2744
  2462
cg@2744
  2463
    ].
cg@2744
  2464
    Transcript showCR:'UNSUPPORTRD LAYOUT: ', layout printString.
cg@2744
  2465
  ^ nil
cg@2744
  2466
!
cg@2744
  2467
cg@2744
  2468
originRelativeToRoot
cg@2744
  2469
    "returns the origin relative to the root widget
cg@2744
  2470
    "
cg@2744
  2471
    ^ widget originRelativeTo:(self rootView)
cg@2744
  2472
! !
cg@2744
  2473
cg@2744
  2474
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'accessing optimize'!
cg@2744
  2475
cg@2744
  2476
children
cg@2744
  2477
    "redefined: optimize
cg@2744
  2478
    "
cg@2744
  2479
    ^ children
cg@2744
  2480
!
cg@2744
  2481
cg@2744
  2482
hasChildren
cg@2744
  2483
    |subViews list item|
cg@2744
  2484
cg@2744
  2485
    children size ~~ 0 ifTrue:[
cg@2744
  2486
        ^ true
cg@2744
  2487
    ].
cg@2744
  2488
    isExpanded := false.
cg@2744
  2489
    subViews   := widget subViews.
cg@2744
  2490
cg@2744
  2491
    subViews size == 0 ifTrue:[^ false].
cg@2744
  2492
cg@2744
  2493
    list := OrderedCollection new.
cg@2744
  2494
cg@2744
  2495
    subViews do:[:aSubView|
cg@2744
  2496
        item := self class buildViewsFrom:aSubView.
cg@2744
  2497
        item parent:self.
cg@2744
  2498
        list add:item.
cg@2744
  2499
    ].
cg@2744
  2500
    children := list.
cg@2744
  2501
    ^ true
cg@2744
  2502
!
cg@2744
  2503
cg@2744
  2504
size
cg@2744
  2505
    "redefined: returns list of children
cg@2744
  2506
    "
cg@2744
  2507
    ^ children size
cg@2744
  2508
! !
cg@2744
  2509
cg@2744
  2510
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'displaying'!
cg@2744
  2511
cg@2744
  2512
additionalLabelForItem:anItem
cg@3017
  2513
    "answer an additional label for an Item"
cg@2744
  2514
cg@2744
  2515
    parent notNil ifTrue:[
cg@2744
  2516
        ^ parent additionalLabelForItem:anItem
cg@2744
  2517
    ].
cg@2744
  2518
    ^ nil
cg@2744
  2519
!
cg@2744
  2520
cg@2744
  2521
displayIcon:anIcon atX:x y:y on:aGC
cg@2744
  2522
    |x0 y0 y1 w|
cg@2744
  2523
cg@2744
  2524
    super displayIcon:anIcon atX:x y:y on:aGC.
cg@2744
  2525
cg@2744
  2526
    self exists ifFalse:[
cg@2744
  2527
        aGC paint:(Color red).
cg@2744
  2528
cg@2744
  2529
        y0 := y + 1.
cg@2744
  2530
        y1 := y + anIcon height - 2.
cg@2744
  2531
cg@2744
  2532
        x0 := x - 1.
cg@2744
  2533
        w  := anIcon width.
cg@2744
  2534
cg@2744
  2535
        2 timesRepeat:[
cg@2744
  2536
            aGC displayLineFromX:x0 y:y0 toX:(x0 + w) y:y1.
cg@2744
  2537
            aGC displayLineFromX:x0 y:y1 toX:(x0 + w) y:y0.
cg@2744
  2538
            x0 := x0 + 1.
cg@2744
  2539
        ].
cg@2744
  2540
    ].
cg@2744
  2541
!
cg@2744
  2542
cg@3184
  2543
displayOn:aGC x:x y:y h:h isHighlightedAsSelected:isHighlightedAsSelected
cg@2744
  2544
    |labelHeight additionalName label isValidAndShown|
cg@2744
  2545
cg@2744
  2546
    label := self label.
cg@2744
  2547
    label isEmptyOrNil ifTrue:[^ self].
cg@2744
  2548
cg@2744
  2549
    widget id isNil ifTrue:[
cg@2744
  2550
        isDrawnShown := false.
cg@2744
  2551
cg@2744
  2552
        self exists ifFalse:[
cg@2744
  2553
            xOffsetAdditionalName := nil.
cg@2744
  2554
        ].
cg@2744
  2555
        isValidAndShown := false.
cg@2744
  2556
    ] ifFalse:[
cg@2744
  2557
        isValidAndShown := widget shown.
cg@2744
  2558
    ].
cg@2744
  2559
    isValidAndShown ifFalse:[
cg@2762
  2560
        label := Text string:label emphasis:#italic.
cg@3141
  2561
        label colorizeAllWith:Color gray.
cg@2744
  2562
    ].
cg@2744
  2563
cg@2744
  2564
    labelHeight := self heightOn:aGC.
cg@3184
  2565
    self displayLabel:label h:labelHeight on:aGC x:x y:y h:h isHighlightedAsSelected:isHighlightedAsSelected.
cg@2744
  2566
cg@2744
  2567
    xOffsetAdditionalName notNil ifTrue:[
cg@2744
  2568
        additionalName := self additionalLabelForItem:self.
cg@2744
  2569
cg@2744
  2570
        additionalName notNil ifTrue:[
cg@2744
  2571
            self displayLabel:additionalName
cg@2744
  2572
                            h:labelHeight on:aGC
cg@2744
  2573
                            x:(x + xOffsetAdditionalName)
cg@2744
  2574
                            y:y
cg@2744
  2575
                            h:h.
cg@2744
  2576
        ] ifFalse:[
cg@2744
  2577
            xOffsetAdditionalName := nil.
cg@2744
  2578
        ].
cg@2744
  2579
    ].
cg@2744
  2580
!
cg@2744
  2581
cg@2744
  2582
recursiveAdditionalNameBehaviourChanged
cg@2744
  2583
    width := xOffsetAdditionalName := nil.
cg@2744
  2584
cg@2744
  2585
    children notNil ifTrue:[
cg@2744
  2586
        children do:[:each| each recursiveAdditionalNameBehaviourChanged ]
cg@2744
  2587
    ].
cg@2744
  2588
!
cg@2744
  2589
cg@2744
  2590
widthOn:aGC
cg@2744
  2591
    "return the width of the receiver, if it is to be displayed on aGC
cg@2744
  2592
    "
cg@2744
  2593
    |additionalName|
cg@2744
  2594
cg@2744
  2595
    width isNil ifTrue:[
cg@2744
  2596
        width := self widthOf:(self label) on:aGC.
cg@2744
  2597
        width := width + 2.
cg@2744
  2598
cg@2744
  2599
        additionalName := self additionalLabelForItem:self.
cg@2744
  2600
cg@2744
  2601
        additionalName notNil ifTrue:[
cg@2744
  2602
            xOffsetAdditionalName := width + 10.
cg@2744
  2603
            width := xOffsetAdditionalName + (self widthOf:additionalName on:aGC).
cg@2744
  2604
            width := width + 2.
cg@2744
  2605
        ] ifFalse:[
cg@2744
  2606
            xOffsetAdditionalName := nil.
cg@2744
  2607
        ].
cg@2744
  2608
    ].
cg@2744
  2609
    ^ width
cg@2744
  2610
! !
cg@2744
  2611
cg@2744
  2612
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'enumerating'!
cg@2744
  2613
cg@2744
  2614
handlesDo:aTwoArgAction
cg@2744
  2615
    "evaluate the two arg block on each handle; the arguments to the block is
cg@2744
  2616
     the rectangle relative to the rootView and the handle type which is
cg@2744
  2617
     set to nil if not resizeable.
cg@2744
  2618
cg@2744
  2619
     TYPES:     type    position( X - Y )
cg@2744
  2620
                -------------------------        
cg@2744
  2621
                #LT     Left   - Top
cg@2744
  2622
                #LC     Left   - Center
cg@2744
  2623
                #LB     Left   - Bottom
cg@2744
  2624
                #CT     Center - Top
cg@2744
  2625
                #CB     Center - Bottom
cg@2744
  2626
                #RT     Right  - Top
cg@2744
  2627
                #RC     Right  - Center
cg@2744
  2628
                #RB     Right  - Bottom
cg@2744
  2629
cg@2744
  2630
                nil     ** handle not pickable **
cg@2744
  2631
    "
cg@2744
  2632
    |type relOrg relCrn maxExt rootView w h
cg@2744
  2633
     xL    "{ Class:SmallInteger }"
cg@2744
  2634
     xC    "{ Class:SmallInteger }"
cg@2744
  2635
     xR    "{ Class:SmallInteger }"
cg@2744
  2636
     yT    "{ Class:SmallInteger }"
cg@2744
  2637
     yC    "{ Class:SmallInteger }"
cg@2744
  2638
     yB    "{ Class:SmallInteger }"
cg@2744
  2639
    |
cg@2744
  2640
    rootView := self rootView.
cg@2744
  2641
    relOrg   := widget originRelativeTo:rootView.
cg@2744
  2642
    relOrg isNil ifTrue:[ ^ self ].    "/ widget destroyed
cg@2744
  2643
cg@2744
  2644
    relOrg   := relOrg - (HandleExtent // 2).
cg@2744
  2645
    relCrn   := relOrg + widget extent.
cg@2744
  2646
    maxExt   := rootView extent - HandleExtent.
cg@2744
  2647
cg@2744
  2648
    xL := relOrg x max:0.
cg@2744
  2649
    xR := relCrn x min:(maxExt x).
cg@2744
  2650
    xC := xR + xL // 2.
cg@2744
  2651
cg@2744
  2652
    yT := relOrg y max:0.
cg@2744
  2653
    yB := relCrn y min:(maxExt y).
cg@2744
  2654
    yC := yB + yT // 2.
cg@2744
  2655
cg@2744
  2656
    type := self layoutType.
cg@2744
  2657
    w   := HandleExtent x.
cg@2744
  2658
    h   := HandleExtent y.
cg@2744
  2659
cg@2744
  2660
    (type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[
cg@2744
  2661
        aTwoArgAction value:(Rectangle left:xL top:yT width:w height:h) value:#LT.
cg@2744
  2662
        aTwoArgAction value:(Rectangle left:xL top:yC width:w height:h) value:#LC.
cg@2744
  2663
        aTwoArgAction value:(Rectangle left:xL top:yB width:w height:h) value:#LB.
cg@2744
  2664
        aTwoArgAction value:(Rectangle left:xC top:yT width:w height:h) value:#CT.
cg@2744
  2665
        aTwoArgAction value:(Rectangle left:xC top:yB width:w height:h) value:#CB.
cg@2744
  2666
        aTwoArgAction value:(Rectangle left:xR top:yT width:w height:h) value:#RT.
cg@2744
  2667
        aTwoArgAction value:(Rectangle left:xR top:yC width:w height:h) value:#RC.
cg@2744
  2668
        aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:#RB.
cg@2744
  2669
      ^ self
cg@2744
  2670
    ].
cg@2744
  2671
cg@2744
  2672
    aTwoArgAction value:(Rectangle left:xL top:yT width:w height:h) value:nil.
cg@2744
  2673
    aTwoArgAction value:(Rectangle left:xL top:yB width:w height:h) value:nil.
cg@2744
  2674
    aTwoArgAction value:(Rectangle left:xR top:yT width:w height:h) value:nil.
cg@2744
  2675
cg@2744
  2676
    type == #Extent ifTrue:[
cg@2744
  2677
        aTwoArgAction value:(Rectangle left:xC top:yB width:w height:h) value:#CB.
cg@2744
  2678
        aTwoArgAction value:(Rectangle left:xR top:yC width:w height:h) value:#RC.
cg@2744
  2679
        aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:#RB.
cg@2744
  2680
      ^ self
cg@2744
  2681
    ].
cg@2744
  2682
    aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:nil.
cg@2744
  2683
!
cg@2744
  2684
cg@2744
  2685
recursiveEachVisibleItemDo:anOneArgBlock
cg@2744
  2686
    "recursive evaluate the block on each child which is visible
cg@2744
  2687
    "
cg@2744
  2688
    (isExpanded and:[children size > 0]) ifTrue:[
cg@2744
  2689
        children do:[:aChild|
cg@2744
  2690
            anOneArgBlock value:aChild.
cg@2744
  2691
            aChild recursiveEachVisibleItemDo:anOneArgBlock.
cg@2744
  2692
        ]
cg@2744
  2693
    ].
cg@2744
  2694
!
cg@2744
  2695
cg@2744
  2696
subViewsDo:aOneArgBlock
cg@2744
  2697
    "evaluate aBlock for all subviews other than InputView's   
cg@2744
  2698
    "
cg@2744
  2699
    |subViews|
cg@2744
  2700
cg@2744
  2701
    subViews := widget subViews.
cg@2744
  2702
cg@2744
  2703
    subViews notNil ifTrue:[
cg@2744
  2704
        subViews do:aOneArgBlock
cg@2744
  2705
    ].
cg@2744
  2706
! !
cg@2744
  2707
cg@2744
  2708
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'initialization'!
cg@2744
  2709
cg@2744
  2710
forView:aView
cg@2744
  2711
    widget := aView.
cg@2744
  2712
!
cg@2744
  2713
cg@2744
  2714
initialize
cg@2744
  2715
    "setup default attributes
cg@2744
  2716
    "
cg@2744
  2717
    super initialize.
cg@2744
  2718
    isDrawnShown := false.
cg@2744
  2719
    isExpanded   := false.
cg@2744
  2720
    children     := OrderedCollection new.
cg@2744
  2721
! !
cg@2744
  2722
cg@2744
  2723
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'operations delete'!
cg@2744
  2724
cg@2744
  2725
delete
cg@2744
  2726
    "delete self and all contained items; the assigned views are destroyed
cg@2744
  2727
     in case of rootView, only the children are deleted
cg@2744
  2728
    "
cg@2744
  2729
    parent isHierarchicalItem ifTrue:[
cg@2744
  2730
        self criticalDo:[
cg@2744
  2731
            parent remove:self.
cg@2744
  2732
            widget destroy.
cg@2744
  2733
        ]
cg@2744
  2734
    ] ifFalse:[
cg@2744
  2735
        self deleteAll
cg@2744
  2736
    ].
cg@2744
  2737
!
cg@2744
  2738
cg@2744
  2739
deleteAll
cg@2744
  2740
    "delete all contained items; the assigned views are destroyed
cg@2744
  2741
    "
cg@2744
  2742
    children size == 0 ifTrue:[^ self].
cg@2744
  2743
cg@2744
  2744
    self criticalDo:[
cg@2744
  2745
        self nonCriticalDo:[:el| el widget destroy ].
cg@2744
  2746
        self removeAll
cg@2744
  2747
    ].
cg@2744
  2748
! !
cg@2744
  2749
cg@2744
  2750
!ViewTreeInspectorApplication::ViewTreeItem methodsFor:'operations layout'!
cg@2744
  2751
cg@2744
  2752
asLayoutFrame
cg@2744
  2753
    "convert the layout of the widget to a LayoutFrame;
cg@2744
  2754
    "
cg@2744
  2755
    |extent layout newLyt lftFrc lftOff topFrc topOff|
cg@2744
  2756
cg@2744
  2757
    layout := widget geometryLayout.
cg@2744
  2758
cg@2744
  2759
    layout isNil ifTrue:[
cg@2744
  2760
        ^ widget bounds asLayout
cg@2744
  2761
    ].
cg@2744
  2762
cg@2744
  2763
    layout isLayout ifFalse:[