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