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