Tools__ViewTreeItem.st
changeset 2452 7892f26996b7
parent 2405 ec54aeed9a42
child 2456 3d8a5dd293ba
equal deleted inserted replaced
2451:cbda60900ced 2452:7892f26996b7
     1 "{ Package: 'stx:libtool2' }"
     1 "{ Package: 'stx:libtool2' }"
     2 
     2 
     3 "{ NameSpace: Tools }"
     3 "{ NameSpace: Tools }"
     4 
     4 
     5 HierarchicalItem subclass:#ViewTreeItem
     5 HierarchicalItem subclass:#ViewTreeItem
     6 	instanceVariableNames:'widget isDrawnShown exists xOffsetApplClass'
     6 	instanceVariableNames:'widget isDrawnShown exists xOffsetAdditionalName'
     7 	classVariableNames:'HandleExtent'
     7 	classVariableNames:'HandleExtent'
     8 	poolDictionaries:''
     8 	poolDictionaries:''
     9 	category:'A-Views-Support'
     9 	category:'A-Views-Support'
    10 !
    10 !
    11 
    11 
   228     ^ children size
   228     ^ children size
   229 ! !
   229 ! !
   230 
   230 
   231 !ViewTreeItem methodsFor:'displaying'!
   231 !ViewTreeItem methodsFor:'displaying'!
   232 
   232 
       
   233 additionalLabelForItem:anItem
       
   234     "answer an additional item for an Item or nil"
       
   235 
       
   236     parent notNil ifTrue:[
       
   237         ^ parent additionalLabelForItem:anItem
       
   238     ].
       
   239     ^ nil
       
   240 !
       
   241 
   233 displayOn:aGC x:x y:y h:h
   242 displayOn:aGC x:x y:y h:h
   234     |labelHeight paint applName|
   243     |labelHeight paint additionalName|
   235 
   244 
   236     widget id isNil ifTrue:[
   245     widget id isNil ifTrue:[
   237         isDrawnShown := false.
   246         isDrawnShown := false.
   238         self exists ifFalse:[^ self].
   247         self exists ifFalse:[^ self].
   239         paint := Color white.
   248         paint := Color white.
   244     aGC paint:paint.
   253     aGC paint:paint.
   245 
   254 
   246     labelHeight := self heightOn:aGC.
   255     labelHeight := self heightOn:aGC.
   247     self displayLabel:(self label) h:labelHeight on:aGC x:x y:y h:h.
   256     self displayLabel:(self label) h:labelHeight on:aGC x:x y:y h:h.
   248 
   257 
   249     xOffsetApplClass notNil ifTrue:[
   258     xOffsetAdditionalName notNil ifTrue:[
   250         applName := self labelOfApplicationClass.
   259         additionalName := self additionalLabelForItem:self.
   251         applName notNil ifTrue:[
   260 
   252             self displayLabel:applName
   261         additionalName notNil ifTrue:[
       
   262             self displayLabel:additionalName
   253                             h:labelHeight on:aGC
   263                             h:labelHeight on:aGC
   254                             x:(x + xOffsetApplClass)
   264                             x:(x + xOffsetAdditionalName)
   255                             y:y
   265                             y:y
   256                             h:h.
   266                             h:h.
   257         ].
   267         ] ifFalse:[
   258     ].
   268             xOffsetAdditionalName := nil.
   259 !
   269         ].
   260 
   270     ].
   261 labelOfApplicationClass
   271 !
   262     "answer the name of the underlaying application or nil"
   272 
   263     |applClass|
   273 recursiveAdditionalNameBehaviourChanged
   264 
   274     width := xOffsetAdditionalName := nil.
   265     self isApplicationClass ifTrue:[
   275 
   266         applClass := self applicationClass.
   276     children notNil ifTrue:[
   267 
   277         children do:[:each| each recursiveAdditionalNameBehaviourChanged ]
   268         applClass notNil ifTrue:[
   278     ].
   269             ^ ('[ ', applClass name, ' ]')
       
   270         ].
       
   271     ].
       
   272     xOffsetApplClass := nil.
       
   273     ^ nil
       
   274 !
   279 !
   275 
   280 
   276 widthOn:aGC
   281 widthOn:aGC
   277     "return the width of the receiver, if it is to be displayed on aGC
   282     "return the width of the receiver, if it is to be displayed on aGC
   278     "
   283     "
   279     |applName|
   284     |additionalName|
   280 
   285 
   281     width isNil ifTrue:[
   286     width isNil ifTrue:[
   282         width := self widthOf:(self label) on:aGC.
   287         width := self widthOf:(self label) on:aGC.
   283         width := width + 2.
   288         width := width + 2.
   284 
   289 
   285         applName := self labelOfApplicationClass.
   290         additionalName := self additionalLabelForItem:self.
   286 
   291 
   287         applName notNil ifTrue:[
   292         additionalName notNil ifTrue:[
   288             xOffsetApplClass := width + 10.
   293             xOffsetAdditionalName := width + 10.
   289             width := xOffsetApplClass + (self widthOf:applName on:aGC).
   294             width := xOffsetAdditionalName + (self widthOf:additionalName on:aGC).
   290             width := width + 2.
   295             width := width + 2.
       
   296         ] ifFalse:[
       
   297             xOffsetAdditionalName := nil.
   291         ].
   298         ].
   292     ].
   299     ].
   293     ^ width
   300     ^ width
   294 ! !
   301 ! !
   295 
   302