Tools__ViewTreeApplication.st
changeset 3456 4d4297bad4fa
parent 3453 01e6b207c1b4
child 3457 3f3ea99e8af5
equal deleted inserted replaced
3455:4ba13182f80f 3456:4d4297bad4fa
    29 	poolDictionaries:''
    29 	poolDictionaries:''
    30 	privateIn:ViewTreeInspectorApplication
    30 	privateIn:ViewTreeInspectorApplication
    31 !
    31 !
    32 
    32 
    33 HierarchicalItem subclass:#ViewTreeItem
    33 HierarchicalItem subclass:#ViewTreeItem
    34 	instanceVariableNames:'widget isDrawnShown exists xOffsetAdditionalName'
    34 	instanceVariableNames:'widget menuItem isDrawnShown exists xOffsetAdditionalName'
    35 	classVariableNames:'HandleExtent'
    35 	classVariableNames:'HandleExtent'
    36 	poolDictionaries:''
    36 	poolDictionaries:''
    37 	privateIn:ViewTreeInspectorApplication
    37 	privateIn:ViewTreeInspectorApplication
    38 !
    38 !
    39 
    39 
   749         nil
   749         nil
   750         nil
   750         nil
   751       )
   751       )
   752 !
   752 !
   753 
   753 
       
   754 middleButtonMenuForMenuItems
       
   755     "This resource specification was automatically generated
       
   756      by the MenuEditor of ST/X."
       
   757 
       
   758     "Do not manually edit this!! If it is corrupted,
       
   759      the MenuEditor may not be able to read the specification."
       
   760 
       
   761 
       
   762     "
       
   763      MenuEditor new openOnClass:Tools::ViewTreeInspectorApplication andSelector:#middleButtonMenu
       
   764      (Menu new fromLiteralArrayEncoding:(Tools::ViewTreeInspectorApplication middleButtonMenu)) startUp
       
   765     "
       
   766 
       
   767     <resource: #menu>
       
   768 
       
   769     ^ 
       
   770      #(Menu
       
   771         (
       
   772          (MenuItem
       
   773             label: 'Browse Menu Item''s Class'
       
   774             itemValue: doBrowseMenuItem:
       
   775             argument: view
       
   776           )
       
   777          (MenuItem
       
   778             label: '-'
       
   779           )
       
   780          (MenuItem
       
   781             label: 'Inspect Menu Item'
       
   782             itemValue: doInspectMenuItem:
       
   783             argument: view
       
   784           )
       
   785          (MenuItem
       
   786             label: '-'
       
   787           )
       
   788          (MenuItem
       
   789             label: 'Interface'
       
   790             submenuChannel: submenuMenuItemInterface:
       
   791             keepLinkedMenu: true
       
   792           )
       
   793          )
       
   794         nil
       
   795         nil
       
   796       )
       
   797 
       
   798     "Created: / 16-08-2017 / 13:48:49 / cg"
       
   799 !
       
   800 
   754 toolbarMenu
   801 toolbarMenu
   755     "This resource specification was automatically generated
   802     "This resource specification was automatically generated
   756      by the MenuEditor of ST/X."
   803      by the MenuEditor of ST/X."
   757 
   804 
   758     "Do not manually edit this!! If it is corrupted,
   805     "Do not manually edit this!! If it is corrupted,
  1108     item := model selectedItem.
  1155     item := model selectedItem.
  1109     item notNil ifTrue:[ 
  1156     item notNil ifTrue:[ 
  1110         |state|
  1157         |state|
  1111 
  1158 
  1112         view := item widget.
  1159         view := item widget.
  1113 
  1160         view isNil ifTrue:[
  1114         view id isNil ifTrue:[
  1161             info := '%1 [%2]' bindWith:(item menuItem label asString)
  1115             state := 'no ID'.
  1162                                   with:(item menuItem value asString).
  1116         ] ifFalse:[
  1163         ] ifFalse:[    
  1117             view shown ifTrue:[
  1164             view id isNil ifTrue:[
  1118                 state := 'visible'.
  1165                 state := 'no ID'.
  1119             ] ifFalse:[
  1166             ] ifFalse:[
  1120                 state := 'invisible'
  1167                 view shown ifTrue:[
       
  1168                     state := 'visible'.
       
  1169                 ] ifFalse:[
       
  1170                     state := 'invisible'
       
  1171                 ].
  1121             ].
  1172             ].
  1122         ].
  1173             info := '%1 [%2] - %3' bindWith:(view class name)
  1123         info := '%1 [%2] - %3' bindWith:(view class name)
  1174                                        with:(view name ? '') with:state allBold.
  1124                                    with:(view name ? '') with:state allBold.
  1175         ]
  1125     ] ifFalse:[
  1176     ] ifFalse:[
  1126         info := ''
  1177         info := ''
  1127     ].
  1178     ].
  1128     hasSingleSelectionHolder value:(view notNil).
  1179     hasSingleSelectionHolder value:(view notNil).
  1129     self updateInspector
  1180     self updateInspector
  1130 
  1181 
  1131     "Modified: / 30-07-2013 / 09:21:27 / cg"
  1182     "Modified: / 16-08-2017 / 13:44:59 / cg"
  1132 !
  1183 !
  1133 
  1184 
  1134 update:something with:someArgument from:aModel
  1185 update:something with:someArgument from:aModel
  1135     |oldSelection|
  1186     |oldSelection|
  1136 
  1187 
  1500 
  1551 
  1501 middleButtonMenu
  1552 middleButtonMenu
  1502     "returns the middleButton menu for the single selected item or nil"
  1553     "returns the middleButton menu for the single selected item or nil"
  1503 
  1554 
  1504     ^ [ 
  1555     ^ [ 
  1505         model selectedItem notNil 
  1556         model selectedItem notNil ifTrue:[
  1506             ifTrue:[self class middleButtonMenu]
  1557             model selectedItem isView ifTrue:[
  1507             ifFalse:[nil]
  1558                 self class middleButtonMenu
       
  1559             ] ifFalse:[
       
  1560                 self class middleButtonMenuForMenuItems
       
  1561             ].    
       
  1562         ] ifFalse:[
       
  1563             nil
       
  1564         ]
  1508       ]
  1565       ]
       
  1566 
       
  1567     "Modified: / 16-08-2017 / 13:48:31 / cg"
  1509 !
  1568 !
  1510 
  1569 
  1511 submenuApplications:aMenu
  1570 submenuApplications:aMenu
  1512     |applications menu item list addBlock|
  1571     |applications menu item list addBlock|
  1513 
  1572 
  1813 
  1872 
  1814     list last isSeparator ifTrue:[ list removeLast ].
  1873     list last isSeparator ifTrue:[ list removeLast ].
  1815     ^ MenuDesc buildFromList:list onGC:aMenu
  1874     ^ MenuDesc buildFromList:list onGC:aMenu
  1816 
  1875 
  1817     "Modified: / 31-07-2013 / 13:09:55 / cg"
  1876     "Modified: / 31-07-2013 / 13:09:55 / cg"
       
  1877 !
       
  1878 
       
  1879 submenuMenuItemInterface:aMenu
       
  1880     "builds and returns the menuItem interface submenu"
       
  1881 
       
  1882     |item list|
       
  1883 
       
  1884     item := self selectedMenuItem.
       
  1885     item isNil ifTrue:[^ nil].
       
  1886 
       
  1887     list := OrderedCollection new.
       
  1888 
       
  1889     list add:(MenuDesc title:'itemValue'  value:(item itemValue)).
       
  1890 
       
  1891     ^ MenuDesc buildFromList:list onGC:aMenu
       
  1892 
       
  1893     "Created: / 16-08-2017 / 13:51:05 / cg"
  1818 !
  1894 !
  1819 
  1895 
  1820 submenuVisibility:aMenu
  1896 submenuVisibility:aMenu
  1821     "builds and returns the geometry submenu"
  1897     "builds and returns the geometry submenu"
  1822 
  1898 
  1953 
  2029 
  1954     max := 0.
  2030     max := 0.
  1955     min := 9999999.
  2031     min := 9999999.
  1956 
  2032 
  1957     rootItem recursiveEachVisibleItemDo:[:anItem|
  2033     rootItem recursiveEachVisibleItemDo:[:anItem|
  1958         visState := (anItem widget shown).
  2034         anItem widget notNil ifTrue:[
  1959 
  2035             visState := (anItem widget shown).
  1960         visState ~~ anItem isDrawnShown ifTrue:[
  2036 
  1961             anItem isDrawnShown:visState.
  2037             visState ~~ anItem isDrawnShown ifTrue:[
  1962             listIdx := treeView identityIndexOf:anItem.
  2038                 anItem isDrawnShown:visState.
  1963 
  2039                 listIdx := treeView identityIndexOf:anItem.
  1964             listIdx > 0 ifTrue:[    
  2040 
  1965                 max := max max:listIdx.
  2041                 listIdx > 0 ifTrue:[    
  1966                 min := min min:listIdx.
  2042                     max := max max:listIdx.
       
  2043                     min := min min:listIdx.
       
  2044                 ].
  1967             ].
  2045             ].
  1968         ].
  2046         ].
  1969     ].
  2047     ].
  1970     max < min ifTrue:[^ self].
  2048     max < min ifTrue:[^ self].
  1971     max := max + 1.
  2049     max := max + 1.
  1978         treeView shown ifTrue:[
  2056         treeView shown ifTrue:[
  1979             damage := Rectangle left:0 top:visY0 width:(treeView width) height:height.
  2057             damage := Rectangle left:0 top:visY0 width:(treeView width) height:height.
  1980             treeView invalidateDeviceRectangle:damage repairNow:false.
  2058             treeView invalidateDeviceRectangle:damage repairNow:false.
  1981         ].
  2059         ].
  1982     ].
  2060     ].
       
  2061 
       
  2062     "Modified: / 16-08-2017 / 12:29:15 / cg"
  1983 ! !
  2063 ! !
  1984 
  2064 
  1985 !ViewTreeInspectorApplication methodsFor:'selection'!
  2065 !ViewTreeInspectorApplication methodsFor:'selection'!
       
  2066 
       
  2067 selectedMenuItem
       
  2068     "answer the selected menuItem or nil"
       
  2069 
       
  2070     |item|
       
  2071 
       
  2072     item := model selectedItem.
       
  2073     item notNil ifTrue:[ ^ item menuItem ].
       
  2074     ^ nil
       
  2075 
       
  2076     "Created: / 16-08-2017 / 13:50:35 / cg"
       
  2077 !
  1986 
  2078 
  1987 selectedView
  2079 selectedView
  1988     "answer the selected view or nil"
  2080     "answer the selected view or nil"
  1989 
  2081 
  1990     |item|
  2082     |item|
  2161 !
  2253 !
  2162 
  2254 
  2163 doRedraw
  2255 doRedraw
  2164     "redraw the app"
  2256     "redraw the app"
  2165 
  2257 
  2166     model rootView notNil ifTrue:[
  2258     |rootView|
  2167         model rootView withAllSubViewsDo:[:v | v "redraw; "invalidate].
  2259     
       
  2260     (rootView := model rootView) notNil ifTrue:[
       
  2261         rootView withAllSubViewsDo:[:v | v "redraw; "invalidate].
  2168     ]
  2262     ]
       
  2263 
       
  2264     "Modified: / 16-08-2017 / 12:02:11 / cg"
  2169 !
  2265 !
  2170 
  2266 
  2171 doSelectNextElementStartingIn:anItem forWhich:aBlock
  2267 doSelectNextElementStartingIn:anItem forWhich:aBlock
  2172     |startItem firstFound searchNext|
  2268     |startItem firstFound searchNext|
  2173 
  2269 
  2357     ^ title widthOn:aGC
  2453     ^ title widthOn:aGC
  2358 ! !
  2454 ! !
  2359 
  2455 
  2360 !ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'building'!
  2456 !ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'building'!
  2361 
  2457 
       
  2458 buildMenuItemsFrom:aMenuItem
       
  2459     "build the items starting from a source menu item;
       
  2460      returns the anchor.
       
  2461     "
       
  2462     |item subMenu subItems|
       
  2463 
       
  2464     aMenuItem isNil ifTrue:[^ nil].
       
  2465 
       
  2466     item     := self forMenuItem:aMenuItem.
       
  2467     subItems := OrderedCollection new.
       
  2468     (subMenu := aMenuItem submenuOrNil) notNil ifTrue:[
       
  2469         subMenu items do:[:eachMenuItem |
       
  2470             subItems add:(self buildMenuItemsFrom:eachMenuItem)
       
  2471         ].    
       
  2472     ].
       
  2473     item children:subItems.
       
  2474     ^ item
       
  2475 
       
  2476     "Created: / 16-08-2017 / 12:23:02 / cg"
       
  2477 !
       
  2478 
  2362 buildViewsFrom:aView
  2479 buildViewsFrom:aView
  2363     "build the items starting from a source view;
  2480     "build the items starting from a source view;
  2364      returns the anhor.
  2481      returns the anchor.
  2365     "
  2482     "
  2366     |item subViews subItems|
  2483     |item subViews subItems|
  2367 
  2484 
  2368     aView isNil ifTrue:[^ nil].
  2485     aView isNil ifTrue:[^ nil].
  2369 
  2486 
  2370     item     := self forView:aView.
  2487     item     := self forView:aView.
  2371     subViews := aView subViews.
  2488     subViews := aView subViews.
       
  2489     subItems := OrderedCollection new.
  2372 
  2490 
  2373     subViews notEmptyOrNil ifTrue:[
  2491     subViews notEmptyOrNil ifTrue:[
  2374         subItems := OrderedCollection new.
       
  2375         subViews do:[:aSubView|
  2492         subViews do:[:aSubView|
  2376             subItems add:(self buildViewsFrom:aSubView).
  2493             subItems add:(self buildViewsFrom:aSubView).
  2377         ].
  2494         ].
  2378         item children:subItems.
  2495     ].
  2379     ].
  2496 
       
  2497     (aView isKindOf:MenuPanel) ifTrue:[
       
  2498         (aView items ? #()) do:[:eachMenuItem |
       
  2499             subItems add:(self buildMenuItemsFrom:eachMenuItem)
       
  2500         ].    
       
  2501     ].    
       
  2502     item children:subItems.
       
  2503     
  2380     ^ item
  2504     ^ item
       
  2505 
       
  2506     "Modified: / 16-08-2017 / 12:43:35 / cg"
  2381 ! !
  2507 ! !
  2382 
  2508 
  2383 !ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'documentation'!
  2509 !ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'documentation'!
  2384 
  2510 
  2385 documentation
  2511 documentation
  2416     HandleExtent := 6@6.
  2542     HandleExtent := 6@6.
  2417 ! !
  2543 ! !
  2418 
  2544 
  2419 !ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'instance creation'!
  2545 !ViewTreeInspectorApplication::ViewTreeItem class methodsFor:'instance creation'!
  2420 
  2546 
       
  2547 forMenuItem:aMenuItem
       
  2548     |item|
       
  2549 
       
  2550     item := self basicNew initialize.
       
  2551     item forMenuItem:aMenuItem.
       
  2552     ^ item
       
  2553 
       
  2554     "Created: / 16-08-2017 / 12:07:55 / cg"
       
  2555 !
       
  2556 
  2421 forView:aView
  2557 forView:aView
  2422     |item|
  2558     |item|
  2423 
  2559 
  2424     item := self basicNew initialize.
  2560     item := self basicNew initialize.
  2425     item forView:aView.
  2561     item forView:aView.
  2426   ^ item
  2562     ^ item
       
  2563 
       
  2564     "Modified (format): / 16-08-2017 / 12:07:40 / cg"
  2427 !
  2565 !
  2428 
  2566 
  2429 new
  2567 new
  2430     self error:'not allowed'.
  2568     self error:'not allowed'.
  2431   ^ nil
  2569   ^ nil
  2459 
  2597 
  2460 isDrawnShown:aBoolean
  2598 isDrawnShown:aBoolean
  2461     isDrawnShown := aBoolean.
  2599     isDrawnShown := aBoolean.
  2462 !
  2600 !
  2463 
  2601 
       
  2602 menuItem
       
  2603     ^ menuItem
       
  2604 !
       
  2605 
       
  2606 parent:aParent
       
  2607     super parent:aParent.
       
  2608 
       
  2609     "Created: / 16-08-2017 / 12:40:26 / cg"
       
  2610 !
       
  2611 
  2464 rootView
  2612 rootView
  2465     "returns the widget assigned to the root or nil
  2613     "returns the widget assigned to the root or nil
  2466     "
  2614     "
  2467     parent isNil ifTrue:[^ nil].
  2615     parent isNil ifTrue:[^ nil].
  2468 
  2616 
  2470 !
  2618 !
  2471 
  2619 
  2472 specClass
  2620 specClass
  2473     "returns the spec-class assigned to the item
  2621     "returns the spec-class assigned to the item
  2474     "
  2622     "
       
  2623     widget isNil ifTrue:[
       
  2624         ^ MenuPanelSpec 
       
  2625     ].
  2475     ^ widget specClass
  2626     ^ widget specClass
       
  2627 
       
  2628     "Modified (format): / 16-08-2017 / 12:31:36 / cg"
  2476 !
  2629 !
  2477 
  2630 
  2478 treeModel
  2631 treeModel
  2479     "returns the assigned treeModel, an instance of ViewTreeModel
  2632     "returns the assigned treeModel, an instance of ViewTreeModel
  2480     "
  2633     "
  2553     "
  2706     "
  2554     ^ children
  2707     ^ children
  2555 !
  2708 !
  2556 
  2709 
  2557 hasChildren
  2710 hasChildren
  2558     |subViews list item|
  2711     "not only a query; also builds"
  2559 
  2712 
  2560     children size ~~ 0 ifTrue:[
  2713     |subViews list item subMenu|
  2561         ^ true
  2714 
  2562     ].
  2715     children isNil ifTrue:[
  2563     isExpanded := false.
  2716         isExpanded := false.
  2564     subViews   := widget subViews.
  2717 
  2565 
  2718         list := OrderedCollection new.
  2566     subViews size == 0 ifTrue:[^ false].
  2719 
  2567 
  2720         "/ it's either a widget or a menuItem
  2568     list := OrderedCollection new.
  2721         widget notNil ifTrue:[
  2569 
  2722             subViews := widget subViews.
  2570     subViews do:[:aSubView|
  2723             subViews notEmptyOrNil ifTrue:[
  2571         item := self class buildViewsFrom:aSubView.
  2724                 subViews do:[:aSubView|
  2572         item parent:self.
  2725                     item := self class buildViewsFrom:aSubView.
  2573         list add:item.
  2726                     item parent:self.
  2574     ].
  2727                     list add:item.
  2575     children := list.
  2728                 ].
  2576     ^ true
  2729             ].
       
  2730         ].
       
  2731 
       
  2732         menuItem notNil ifTrue:[ 
       
  2733             (subMenu := menuItem submenuOrNil) notNil ifTrue:[
       
  2734                 subMenu items do:[:aSubItem|
       
  2735                     item := self class buildMenuItemsFrom:aSubItem.
       
  2736                     item parent:self.
       
  2737                     list add:item.
       
  2738                 ].
       
  2739             ].
       
  2740         ].
       
  2741         children := list.
       
  2742     ].
       
  2743     ^ children notEmpty
       
  2744 
       
  2745     "Modified: / 16-08-2017 / 12:27:23 / cg"
  2577 !
  2746 !
  2578 
  2747 
  2579 size
  2748 size
  2580     "redefined: returns list of children
  2749     "redefined: returns list of children
  2581     "
  2750     "
  2619     |labelHeight additionalName label isValidAndShown|
  2788     |labelHeight additionalName label isValidAndShown|
  2620 
  2789 
  2621     label := self label.
  2790     label := self label.
  2622     label isEmptyOrNil ifTrue:[^ self].
  2791     label isEmptyOrNil ifTrue:[^ self].
  2623 
  2792 
  2624     widget id isNil ifTrue:[
  2793     widget isNil ifTrue:[
  2625         isDrawnShown := false.
  2794         isValidAndShown := true.
  2626 
       
  2627         self exists ifFalse:[
       
  2628             xOffsetAdditionalName := nil.
       
  2629         ].
       
  2630         isValidAndShown := false.
       
  2631     ] ifFalse:[
  2795     ] ifFalse:[
  2632         isValidAndShown := widget shown.
  2796         widget id isNil ifTrue:[
  2633     ].
  2797             isDrawnShown := false.
       
  2798 
       
  2799             self exists ifFalse:[
       
  2800                 xOffsetAdditionalName := nil.
       
  2801             ].
       
  2802             isValidAndShown := false.
       
  2803         ] ifFalse:[
       
  2804             isValidAndShown := widget shown.
       
  2805         ].
       
  2806     ].
       
  2807     
  2634     isValidAndShown ifFalse:[
  2808     isValidAndShown ifFalse:[
  2635         label := Text string:label emphasis:#italic.
  2809         label := Text string:label emphasis:#italic.
  2636         label colorizeAllWith:Color gray.
  2810         label colorizeAllWith:Color gray.
  2637     ].
  2811     ].
  2638 
  2812 
  2643         additionalName := self additionalLabelForItem:self.
  2817         additionalName := self additionalLabelForItem:self.
  2644 
  2818 
  2645         additionalName notNil ifTrue:[
  2819         additionalName notNil ifTrue:[
  2646             self displayLabel:additionalName
  2820             self displayLabel:additionalName
  2647                             h:labelHeight on:aGC
  2821                             h:labelHeight on:aGC
  2648                             x:(x + xOffsetAdditionalName)
  2822                             x:(x + xOffsetAdditionalName) y:y
  2649                             y:y
       
  2650                             h:h.
  2823                             h:h.
  2651         ] ifFalse:[
  2824         ] ifFalse:[
  2652             xOffsetAdditionalName := nil.
  2825             xOffsetAdditionalName := nil.
  2653         ].
  2826         ].
  2654     ].
  2827     ].
       
  2828 
       
  2829     "Modified (format): / 16-08-2017 / 12:57:39 / cg"
  2655 !
  2830 !
  2656 
  2831 
  2657 recursiveAdditionalNameBehaviourChanged
  2832 recursiveAdditionalNameBehaviourChanged
  2658     width := xOffsetAdditionalName := nil.
  2833     width := xOffsetAdditionalName := nil.
  2659 
  2834 
  2713      yB    "{ Class:SmallInteger }"
  2888      yB    "{ Class:SmallInteger }"
  2714     |
  2889     |
  2715     rootView := self rootView.
  2890     rootView := self rootView.
  2716     rootView isNil ifTrue:[^ self ].
  2891     rootView isNil ifTrue:[^ self ].
  2717 
  2892 
       
  2893     widget isNil ifTrue:[^ self].
       
  2894 
  2718     relOrg   := widget originRelativeTo:rootView.
  2895     relOrg   := widget originRelativeTo:rootView.
  2719     relOrg isNil ifTrue:[ ^ self ].    "/ widget destroyed
  2896     relOrg isNil ifTrue:[ ^ self ].    "/ widget destroyed
  2720 
  2897 
  2721     relOrg   := relOrg - (HandleExtent // 2).
  2898     relOrg   := relOrg - (HandleExtent // 2).
  2722     relCrn   := relOrg + widget extent.
  2899     relCrn   := relOrg + widget extent.
  2755         aTwoArgAction value:(Rectangle left:xR top:yC width:w height:h) value:#RC.
  2932         aTwoArgAction value:(Rectangle left:xR top:yC width:w height:h) value:#RC.
  2756         aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:#RB.
  2933         aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:#RB.
  2757       ^ self
  2934       ^ self
  2758     ].
  2935     ].
  2759     aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:nil.
  2936     aTwoArgAction value:(Rectangle left:xR top:yB width:w height:h) value:nil.
       
  2937 
       
  2938     "Modified: / 16-08-2017 / 13:04:27 / cg"
  2760 !
  2939 !
  2761 
  2940 
  2762 recursiveEachVisibleItemDo:anOneArgBlock
  2941 recursiveEachVisibleItemDo:anOneArgBlock
  2763     "recursive evaluate the block on each child which is visible
  2942     "recursive evaluate the block on each child which is visible
  2764     "
  2943     "
  2781         subViews do:aOneArgBlock
  2960         subViews do:aOneArgBlock
  2782     ].
  2961     ].
  2783 ! !
  2962 ! !
  2784 
  2963 
  2785 !ViewTreeInspectorApplication::ViewTreeItem methodsFor:'initialization'!
  2964 !ViewTreeInspectorApplication::ViewTreeItem methodsFor:'initialization'!
       
  2965 
       
  2966 forMenuItem:aMenuItem
       
  2967     menuItem := aMenuItem.
       
  2968 
       
  2969     "Created: / 16-08-2017 / 12:08:50 / cg"
       
  2970 !
  2786 
  2971 
  2787 forView:aView
  2972 forView:aView
  2788     widget := aView.
  2973     widget := aView.
  2789 !
  2974 !
  2790 
  2975 
  3016 ! !
  3201 ! !
  3017 
  3202 
  3018 !ViewTreeInspectorApplication::ViewTreeItem methodsFor:'printing & storing'!
  3203 !ViewTreeInspectorApplication::ViewTreeItem methodsFor:'printing & storing'!
  3019 
  3204 
  3020 icon
  3205 icon
  3021     "get the icon used for presentation
  3206     "get the icon used for presentation"
  3022     "
  3207 
  3023     |specClass model|
  3208     |specClass model|
  3024 
  3209 
       
  3210     menuItem notNil ifTrue:[
       
  3211         menuItem label isImage ifTrue:[
       
  3212             ^ menuItem label magnifiedTo:20@20.
       
  3213         ].    
       
  3214     ].
       
  3215     
  3025     specClass := self specClass.
  3216     specClass := self specClass.
  3026     specClass isNil ifTrue:[^ nil].
  3217     specClass isNil ifTrue:[^ nil].
  3027 
  3218 
  3028     model := self treeModel.
  3219     model := self treeModel.
  3029 
       
  3030     model notNil ifTrue:[
  3220     model notNil ifTrue:[
  3031         ^ model iconAt:specClass ifNonePut:[specClass icon]
  3221         ^ model iconAt:specClass ifNonePut:[specClass icon]
  3032     ].
  3222     ].
  3033     ^ specClass icon
  3223     ^ specClass icon
       
  3224 
       
  3225     "Modified: / 16-08-2017 / 13:00:35 / cg"
  3034 !
  3226 !
  3035 
  3227 
  3036 label
  3228 label
  3037     "get the label used for presentation
  3229     "get the label used for presentation
  3038     "
  3230     "
  3046 !
  3238 !
  3047 
  3239 
  3048 string
  3240 string
  3049     "get the string
  3241     "get the string
  3050     "
  3242     "
       
  3243     widget isNil ifTrue:[
       
  3244         ^ menuItem class name    
       
  3245     ].    
  3051     ^ widget class name.
  3246     ^ widget class name.
       
  3247 
       
  3248     "Modified: / 16-08-2017 / 13:45:39 / cg"
  3052 ! !
  3249 ! !
  3053 
  3250 
  3054 !ViewTreeInspectorApplication::ViewTreeItem methodsFor:'queries'!
  3251 !ViewTreeInspectorApplication::ViewTreeItem methodsFor:'queries'!
  3055 
  3252 
  3056 canChangeLayout
  3253 canChangeLayout
  3072     ].
  3269     ].
  3073     ^ false
  3270     ^ false
  3074 !
  3271 !
  3075 
  3272 
  3076 exists
  3273 exists
       
  3274     widget isNil ifTrue:[^ menuItem notNil].
  3077     widget id notNil ifTrue:[^ true ].
  3275     widget id notNil ifTrue:[^ true ].
  3078 
  3276 
  3079     exists ~~ false ifTrue:[
  3277     exists ~~ false ifTrue:[
  3080         exists := false.
  3278         exists := false.
  3081 
  3279 
  3084                 exists := (parent widget subViews includesIdentical:widget).
  3282                 exists := (parent widget subViews includesIdentical:widget).
  3085             ].
  3283             ].
  3086         ].
  3284         ].
  3087     ].
  3285     ].
  3088     ^ exists
  3286     ^ exists
       
  3287 
       
  3288     "Modified: / 16-08-2017 / 12:47:50 / cg"
  3089 !
  3289 !
  3090 
  3290 
  3091 isApplicationClass
  3291 isApplicationClass
  3092     |cls|
  3292     |cls|
  3093 
  3293 
  3305         selection size ~~ 1 ifTrue:[ ^ nil ].
  3505         selection size ~~ 1 ifTrue:[ ^ nil ].
  3306         view := selection anElement widget.
  3506         view := selection anElement widget.
  3307     ] ifFalse:[ 
  3507     ] ifFalse:[ 
  3308         view := selection widget.
  3508         view := selection widget.
  3309     ].
  3509     ].
       
  3510     view isNil ifTrue:[^ nil].
       
  3511     
  3310     views := OrderedCollection new.
  3512     views := OrderedCollection new.
  3311     [ view notNil ] whileTrue:[ 
  3513     [ view notNil ] whileTrue:[ 
  3312         views add: view.
  3514         views add: view.
  3313         view := view superView.
  3515         view := view superView.
  3314     ].
  3516     ].
  3319             s nextPutAll: each name asString "storeString".
  3521             s nextPutAll: each name asString "storeString".
  3320         ].
  3522         ].
  3321     ]
  3523     ]
  3322 
  3524 
  3323     "Created: / 19-05-2014 / 18:15:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
  3525     "Created: / 19-05-2014 / 18:15:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
       
  3526     "Modified: / 16-08-2017 / 13:03:47 / cg"
  3324 !
  3527 !
  3325 
  3528 
  3326 rootItem
  3529 rootItem
  3327     "get the rootItem the event viewer is established on
  3530     "get the rootItem the event viewer is established on
  3328     "
  3531     "
  4462 additionalLabelForItem:anItem
  4665 additionalLabelForItem:anItem
  4463     "answer the additional lable for an item or nil"
  4666     "answer the additional lable for an item or nil"
  4464 
  4667 
  4465     |widget l applClass applClassName key|
  4668     |widget l applClass applClassName key|
  4466 
  4669 
  4467     widget := anItem widget.
       
  4468 
       
  4469     l := nil.
  4670     l := nil.
  4470     showWidgetNames == true ifTrue:[
  4671     showWidgetNames == true ifTrue:[
  4471         l := '"', widget name, '"'
  4672         (widget := anItem widget) notNil ifTrue:[
       
  4673             l := '"', widget name, '"'
       
  4674         ] ifFalse:[
       
  4675             l := '"', anItem menuItem label asString, '"'
       
  4676         ].    
  4472     ].
  4677     ].
  4473 
  4678 
  4474     anItem isApplicationClass ifTrue:[
  4679     anItem isApplicationClass ifTrue:[
  4475         applClass := anItem applicationClass.
  4680         applClass := anItem applicationClass.
  4476         applClass notNil ifTrue:[   
  4681         applClass notNil ifTrue:[   
  4485             l := l , ' #',key
  4690             l := l , ' #',key
  4486         ].
  4691         ].
  4487     ].
  4692     ].
  4488 
  4693 
  4489     ^ l
  4694     ^ l
       
  4695 
       
  4696     "Modified: / 16-08-2017 / 12:47:12 / cg"
  4490 !
  4697 !
  4491 
  4698 
  4492 showWidgetNames
  4699 showWidgetNames
  4493     "answer true if the additional text is the widget name
  4700     "answer true if the additional text is the widget name
  4494      otherwise the name of the application"
  4701      otherwise the name of the application"