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