Tools__ViewTreeApplication.st
changeset 2978 a952dfdb1b6a
parent 2888 9adfb8a84696
child 3000 7b530cc76688
equal deleted inserted replaced
2977:2f7cc2452dd7 2978:a952dfdb1b6a
    38 
    38 
    39 ValueModel subclass:#ViewTreeModel
    39 ValueModel subclass:#ViewTreeModel
    40 	instanceVariableNames:'lockSema selectedSuperItems selection hiddenLevel listOfItems
    40 	instanceVariableNames:'lockSema selectedSuperItems selection hiddenLevel listOfItems
    41 		inputEventAction mappedViewAction beforeSelectionChangedAction
    41 		inputEventAction mappedViewAction beforeSelectionChangedAction
    42 		icons timedUpdateTask selectOnClickHolder testModeChannel
    42 		icons timedUpdateTask selectOnClickHolder testModeChannel
    43 		hasTargetWidgetChannel'
    43 		hasTargetWidgetChannel catchEvents'
    44 	classVariableNames:''
    44 	classVariableNames:''
    45 	poolDictionaries:''
    45 	poolDictionaries:''
    46 	privateIn:ViewTreeInspectorApplication
    46 	privateIn:ViewTreeInspectorApplication
    47 !
    47 !
    48 
    48 
   320      by the MenuEditor of ST/X."
   320      by the MenuEditor of ST/X."
   321 
   321 
   322     "Do not manually edit this!! If it is corrupted,
   322     "Do not manually edit this!! If it is corrupted,
   323      the MenuEditor may not be able to read the specification."
   323      the MenuEditor may not be able to read the specification."
   324 
   324 
   325     "
   325 
   326      MenuEditor new openOnClass:Tools::ViewTreeApplication andSelector:#menu
   326     "
   327      (Menu new fromLiteralArrayEncoding:(Tools::ViewTreeApplication menu)) startUp
   327      MenuEditor new openOnClass:Tools::ViewTreeInspectorApplication andSelector:#menu
       
   328      (Menu new fromLiteralArrayEncoding:(Tools::ViewTreeInspectorApplication menu)) startUp
   328     "
   329     "
   329 
   330 
   330     <resource: #menu>
   331     <resource: #menu>
   331 
   332 
   332     ^ 
   333     ^ 
   333      #(Menu
   334      #(Menu
   334         (
   335         (
   335          (MenuItem
   336          (MenuItem
   336             label: 'File'
   337             label: 'File'
   337             translateLabel: true
       
   338             submenu: 
   338             submenu: 
   339            (Menu
   339            (Menu
   340               (
   340               (
   341                (MenuItem
   341                (MenuItem
   342                   label: 'Pick a View'
   342                   label: 'Pick a View'
   343                   itemValue: doPickView
   343                   itemValue: doPickView
   344                   translateLabel: true
       
   345                 )
   344                 )
   346                (MenuItem
   345                (MenuItem
   347                   enabled: hasTargetWidgetChannel
   346                   enabled: hasTargetWidgetChannel
   348                   label: 'Release Picked View'
   347                   label: 'Release Picked View'
   349                   itemValue: doUnpick
   348                   itemValue: doUnpick
   350                   translateLabel: true
       
   351                 )
   349                 )
   352                (MenuItem
   350                (MenuItem
   353                   label: '-'
   351                   label: '-'
   354                 )
   352                 )
   355                (MenuItem
   353                (MenuItem
   356                   label: 'Settings'
   354                   label: 'Settings'
   357                   translateLabel: true
       
   358                   submenu: 
   355                   submenu: 
   359                  (Menu
   356                  (Menu
   360                     (
   357                     (
   361                      (MenuItem
   358                      (MenuItem
   362                         label: 'Test Mode'
   359                         label: 'Test Mode'
   363                         translateLabel: true
       
   364                         hideMenuOnActivated: false
   360                         hideMenuOnActivated: false
   365                         indication: testModeChannel
   361                         indication: testModeChannel
   366                       )
   362                       )
   367                      (MenuItem
   363                      (MenuItem
   368                         enabled: testModeChannel
   364                         enabled: testModeChannel
   369                         label: 'Follow Focus'
   365                         label: 'Follow Focus'
   370                         translateLabel: true
       
   371                         hideMenuOnActivated: false
   366                         hideMenuOnActivated: false
   372                         indication: followFocusChannel
   367                         indication: followFocusChannel
   373                       )
   368                       )
   374                      (MenuItem
   369                      (MenuItem
   375                         label: '-'
   370                         label: '-'
   376                       )
   371                       )
   377                      (MenuItem
   372                      (MenuItem
   378                         label: 'Select on Click'
   373                         label: 'Select on Click'
   379                         translateLabel: true
       
   380                         hideMenuOnActivated: false
   374                         hideMenuOnActivated: false
   381                         indication: selectOnClickHolder
   375                         indication: selectOnClickHolder
   382                       )
   376                       )
   383                      (MenuItem
   377                      (MenuItem
   384                         label: '-'
   378                         label: '-'
   385                       )
   379                       )
   386                      (MenuItem
   380                      (MenuItem
   387                         label: 'Show Name of Widgets'
   381                         label: 'Show Name of Widgets'
   388                         translateLabel: true
       
   389                         hideMenuOnActivated: false
   382                         hideMenuOnActivated: false
   390                         indication: showNamesHolder
   383                         indication: showNamesHolder
   391                       )
   384                       )
   392                      )
   385                      )
   393                     nil
   386                     nil
   398                   label: '-'
   391                   label: '-'
   399                 )
   392                 )
   400                (MenuItem
   393                (MenuItem
   401                   label: 'Exit'
   394                   label: 'Exit'
   402                   itemValue: closeRequest
   395                   itemValue: closeRequest
   403                   translateLabel: true
       
   404                 )
   396                 )
   405                )
   397                )
   406               nil
   398               nil
   407               nil
   399               nil
   408             )
   400             )
   409           )
   401           )
   410          (MenuItem
   402          (MenuItem
   411             enabled: hasSingleSelectionHolder
   403             enabled: hasSingleSelectionHolder
   412             label: 'Selection'
   404             label: 'Selection'
   413             translateLabel: true
       
   414             submenuChannel: middleButtonMenu
   405             submenuChannel: middleButtonMenu
   415           )
   406           )
   416          (MenuItem
   407          (MenuItem
   417             label: 'Application'
   408             label: 'Application'
   418             translateLabel: true
       
   419             submenu: 
   409             submenu: 
   420            (Menu
   410            (Menu
   421               (
   411               (
   422                (MenuItem
   412                (MenuItem
       
   413                   label: 'Redraw'
       
   414                   itemValue: doRedraw
       
   415                 )
       
   416                (MenuItem
       
   417                   label: '-'
       
   418                 )
       
   419                (MenuItem
   423                   enabled: hasSingleSelectionHolder
   420                   enabled: hasSingleSelectionHolder
   424                   label: 'Browse'
   421                   label: 'Browse'
   425                   itemValue: doBrowse:
   422                   itemValue: doBrowse:
   426                   translateLabel: true
       
   427                   argument: application
   423                   argument: application
   428                 )
   424                 )
   429                (MenuItem
   425                (MenuItem
   430                   enabled: hasSingleSelectionHolder
   426                   enabled: hasSingleSelectionHolder
   431                   label: 'Inspect'
   427                   label: 'Inspect'
   432                   itemValue: doInspect:
   428                   itemValue: doInspect:
   433                   translateLabel: true
       
   434                   argument: application
   429                   argument: application
   435                 )
   430                 )
   436                (MenuItem
   431                (MenuItem
   437                   label: '-'
   432                   label: '-'
   438                 )
   433                 )
   439                (MenuItem
   434                (MenuItem
   440                   enabled: hasTargetWidgetChannel
   435                   enabled: hasTargetWidgetChannel
   441                   label: 'All Applications'
   436                   label: 'All Applications'
   442                   translateLabel: true
       
   443                   submenuChannel: submenuApplications:
   437                   submenuChannel: submenuApplications:
   444                 )
   438                 )
   445                )
   439                )
   446               nil
   440               nil
   447               nil
   441               nil
   448             )
   442             )
   449           )
   443           )
   450          (MenuItem
   444          (MenuItem
   451             label: 'Widget'
   445             label: 'Widget'
   452             translateLabel: true
       
   453             submenu: 
   446             submenu: 
   454            (Menu
   447            (Menu
   455               (
   448               (
   456                (MenuItem
   449                (MenuItem
   457                   enabled: hasSingleSelectionHolder
   450                   enabled: hasSingleSelectionHolder
   458                   label: 'Browse'
   451                   label: 'Browse'
   459                   itemValue: doBrowse:
   452                   itemValue: doBrowse:
   460                   translateLabel: true
       
   461                   argument: view
   453                   argument: view
   462                 )
   454                 )
   463                (MenuItem
   455                (MenuItem
   464                   enabled: hasSingleSelectionHolder
   456                   enabled: hasSingleSelectionHolder
   465                   label: 'Inspect'
   457                   label: 'Inspect'
   466                   itemValue: doInspect:
   458                   itemValue: doInspect:
   467                   translateLabel: true
       
   468                   argument: view
   459                   argument: view
   469                 )
   460                 )
   470                (MenuItem
   461                (MenuItem
   471                   label: '-'
   462                   label: '-'
   472                 )
   463                 )
   473                (MenuItem
   464                (MenuItem
   474                   enabled: hasTargetWidgetChannel
   465                   enabled: hasTargetWidgetChannel
   475                   label: 'All Components'
   466                   label: 'All Components'
   476                   translateLabel: true
       
   477                   startGroup: right
   467                   startGroup: right
   478                   submenuChannel: submenuComponents:
   468                   submenuChannel: submenuComponents:
   479                 )
   469                 )
   480                )
   470                )
   481               nil
   471               nil
   482               nil
   472               nil
   483             )
   473             )
   484           )
   474           )
   485          (MenuItem
   475          (MenuItem
   486             label: 'Help'
   476             label: 'Help'
   487             translateLabel: true
       
   488             startGroup: conditionalRight
   477             startGroup: conditionalRight
   489             submenu: 
   478             submenu: 
   490            (Menu
   479            (Menu
   491               (
   480               (
   492                (MenuItem
   481                (MenuItem
   493                   label: 'Documentation'
   482                   label: 'Documentation'
   494                   itemValue: openDocumentation
   483                   itemValue: openDocumentation
   495                   translateLabel: true
       
   496                 )
   484                 )
   497                (MenuItem
   485                (MenuItem
   498                   label: '-'
   486                   label: '-'
   499                 )
   487                 )
   500                (MenuItem
   488                (MenuItem
   501                   label: 'About this Application...'
   489                   label: 'About this Application...'
   502                   itemValue: openAboutThisApplication
   490                   itemValue: openAboutThisApplication
   503                   translateLabel: true
       
   504                 )
   491                 )
   505                )
   492                )
   506               nil
   493               nil
   507               nil
   494               nil
   508             )
   495             )
   509           )
   496           )
   510          )
   497          )
   511         nil
   498         nil
   512         nil
   499         nil
   513       )
   500       )
   514 
       
   515     "Modified: / 27-04-2012 / 14:13:17 / cg"
       
   516 !
   501 !
   517 
   502 
   518 middleButtonMenu
   503 middleButtonMenu
   519     "This resource specification was automatically generated
   504     "This resource specification was automatically generated
   520      by the MenuEditor of ST/X."
   505      by the MenuEditor of ST/X."
   674      by the MenuEditor of ST/X."
   659      by the MenuEditor of ST/X."
   675 
   660 
   676     "Do not manually edit this!! If it is corrupted,
   661     "Do not manually edit this!! If it is corrupted,
   677      the MenuEditor may not be able to read the specification."
   662      the MenuEditor may not be able to read the specification."
   678 
   663 
       
   664 
   679     "
   665     "
   680      MenuEditor new openOnClass:Tools::ViewTreeInspectorApplication andSelector:#toolbarMenu
   666      MenuEditor new openOnClass:Tools::ViewTreeInspectorApplication andSelector:#toolbarMenu
   681      (Menu new fromLiteralArrayEncoding:(Tools::ViewTreeInspectorApplication toolbarMenu)) startUp
   667      (Menu new fromLiteralArrayEncoding:(Tools::ViewTreeInspectorApplication toolbarMenu)) startUp
   682     "
   668     "
   683 
   669 
   685 
   671 
   686     ^ 
   672     ^ 
   687      #(Menu
   673      #(Menu
   688         (
   674         (
   689          (MenuItem
   675          (MenuItem
   690             label: 'Pick a View'
   676             enabled: hasTargetWidgetChannel
       
   677             label: 'Redraw'
       
   678             itemValue: doRedraw
       
   679             isButton: true
       
   680             labelImage: (ResourceRetriever ToolbarIconLibrary reloadIcon)
       
   681           )
       
   682          (MenuItem
       
   683             label: '-'
       
   684           )
       
   685          (MenuItem
       
   686             label: 'Pick a View and Catch Events'
   691             itemValue: doPickView
   687             itemValue: doPickView
   692             translateLabel: false
   688             translateLabel: false
   693             isButton: true
   689             isButton: true
   694             hideMenuOnActivated: false
   690             hideMenuOnActivated: false
   695             labelImage: (ResourceRetriever #'Tools::ViewTreeInspectorApplication' pickWindowIcon2)
   691             labelImage: (ResourceRetriever #'Tools::ViewTreeInspectorApplication' pickWindowIcon2)
   696           )
   692           )
   697          (MenuItem
   693          (MenuItem
   698             enabled: hasTargetWidgetChannel
   694             enabled: hasTargetWidgetChannel
   699             label: 'Release Picked View'
   695             label: 'Release Picked View and Uncatch Events'
       
   696             itemValue: doUncatchEvents
   700             isButton: true
   697             isButton: true
   701             itemValue: doUnpick
       
   702             translateLabel: true
       
   703             labelImage: (ResourceRetriever ToolbarIconLibrary undoIcon)
   698             labelImage: (ResourceRetriever ToolbarIconLibrary undoIcon)
   704           )
   699           )
   705          (MenuItem
   700          (MenuItem
   706             label: '-'
   701             label: '-'
   707           )
   702           )
  1754     (    topWindow == Screen current rootView
  1749     (    topWindow == Screen current rootView
  1755      or:[topWindow == self window topView]
  1750      or:[topWindow == self window topView]
  1756     ) ifTrue:[
  1751     ) ifTrue:[
  1757         ^ self
  1752         ^ self
  1758     ].
  1753     ].
       
  1754 
       
  1755     model catchEvents:true.
  1759     self setRootItem:(ViewTreeItem buildViewsFrom:topWindow).
  1756     self setRootItem:(ViewTreeItem buildViewsFrom:topWindow).
  1760     self selectView:clickedView.
  1757     self selectView:clickedView.
       
  1758 !
       
  1759 
       
  1760 doRedraw
       
  1761     "redraw the app"
       
  1762 
       
  1763     model rootView withAllSubViewsDo:[:v | v redraw; invalidate].
  1761 !
  1764 !
  1762 
  1765 
  1763 doSelectNextOfApplicationClass:aClass startingIn:anItem
  1766 doSelectNextOfApplicationClass:aClass startingIn:anItem
  1764     |startItem firstFound searchNext|
  1767     |startItem firstFound searchNext|
  1765 
  1768 
  1808     ].
  1811     ].
  1809     firstFound notNil ifTrue:[
  1812     firstFound notNil ifTrue:[
  1810         self window beep.
  1813         self window beep.
  1811         model selectItem:firstFound
  1814         model selectItem:firstFound
  1812     ].
  1815     ].
       
  1816 !
       
  1817 
       
  1818 doUncatchEvents
       
  1819     model catchEvents:false.
       
  1820     self doRedraw
  1813 !
  1821 !
  1814 
  1822 
  1815 doUnpick
  1823 doUnpick
  1816     "release current picked window and contained subwindows"
  1824     "release current picked window and contained subwindows"
  1817 
  1825 
  2828 
  2836 
  2829 application:anApplication
  2837 application:anApplication
  2830     listOfItems application:anApplication.
  2838     listOfItems application:anApplication.
  2831 !
  2839 !
  2832 
  2840 
       
  2841 catchEvents:aBoolean
       
  2842     catchEvents := aBoolean.
       
  2843     aBoolean ifFalse:[
       
  2844         self redrawUnselected:selection andLock:false checkTestMode:false.
       
  2845     ].
       
  2846 !
       
  2847 
  2833 rootItem
  2848 rootItem
  2834     "get the rootItem the event viewer is established on
  2849     "get the rootItem the event viewer is established on
  2835     "
  2850     "
  2836     ^ listOfItems root
  2851     ^ listOfItems root
  2837 !
  2852 !
  3063      widgets; redraw selection in case of damage...
  3078      widgets; redraw selection in case of damage...
  3064      return true, if the event was eaten"
  3079      return true, if the event was eaten"
  3065 
  3080 
  3066     |evView item rootView testMode|
  3081     |evView item rootView testMode|
  3067 
  3082 
       
  3083     catchEvents ifFalse:[^ false].
       
  3084 
  3068     evView := anEvent view.
  3085     evView := anEvent view.
  3069     evView isNil ifTrue:[
  3086     evView isNil ifTrue:[
  3070         (anEvent isMessageSendEvent not or:[anEvent receiver ~~ self]) ifTrue:[
  3087         (anEvent isMessageSendEvent not or:[anEvent receiver ~~ self]) ifTrue:[
  3071             ^ false
  3088             ^ false
  3072         ].
  3089         ].
  3153     hiddenLevel           := 0.
  3170     hiddenLevel           := 0.
  3154     lockSema              := RecursionLock new.
  3171     lockSema              := RecursionLock new.
  3155     listOfItems           := ItemList new on:self.
  3172     listOfItems           := ItemList new on:self.
  3156     selectedSuperItems    := #().
  3173     selectedSuperItems    := #().
  3157     icons                 := IdentityDictionary new.
  3174     icons                 := IdentityDictionary new.
       
  3175     catchEvents           := true.
  3158 
  3176 
  3159     hasTargetWidgetChannel := false asValue.
  3177     hasTargetWidgetChannel := false asValue.
  3160     selectOnClickHolder    := true asValue.
  3178     selectOnClickHolder    := true asValue.
  3161 
  3179 
  3162     testModeChannel := false asValue.
  3180     testModeChannel := false asValue.
  4047 
  4065 
  4048 version_CVS
  4066 version_CVS
  4049     ^ '$Header$'
  4067     ^ '$Header$'
  4050 ! !
  4068 ! !
  4051 
  4069 
       
  4070 
  4052 ViewTreeInspectorApplication initialize!
  4071 ViewTreeInspectorApplication initialize!
  4053 ViewTreeInspectorApplication::ViewTreeItem initialize!
  4072 ViewTreeInspectorApplication::ViewTreeItem initialize!