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