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