Tools__ViewTreeItem.st
changeset 2405 ec54aeed9a42
parent 2178 d970c06282d7
child 2452 7892f26996b7
equal deleted inserted replaced
2404:06d51e254934 2405:ec54aeed9a42
     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'
     6 	instanceVariableNames:'widget isDrawnShown exists xOffsetApplClass'
     7 	classVariableNames:'HandleExtent'
     7 	classVariableNames:'HandleExtent'
     8 	poolDictionaries:''
     8 	poolDictionaries:''
     9 	category:'A-Views-Support'
     9 	category:'A-Views-Support'
    10 !
    10 !
    11 
    11 
   229 ! !
   229 ! !
   230 
   230 
   231 !ViewTreeItem methodsFor:'displaying'!
   231 !ViewTreeItem methodsFor:'displaying'!
   232 
   232 
   233 displayOn:aGC x:x y:y h:h
   233 displayOn:aGC x:x y:y h:h
   234     |labelHeight applClass paint|
   234     |labelHeight paint applName|
   235 
   235 
   236     widget id isNil ifTrue:[
   236     widget id isNil ifTrue:[
   237         isDrawnShown := false.
   237         isDrawnShown := false.
   238         self exists ifFalse:[^ self].
   238         self exists ifFalse:[^ self].
   239         paint := Color white.
   239         paint := Color white.
   244     aGC paint:paint.
   244     aGC paint:paint.
   245 
   245 
   246     labelHeight := self heightOn:aGC.
   246     labelHeight := self heightOn:aGC.
   247     self displayLabel:(self label) h:labelHeight on:aGC x:x y:y h:h.
   247     self displayLabel:(self label) h:labelHeight on:aGC x:x y:y h:h.
   248 
   248 
   249     self isApplicationClass ifTrue:[
   249     xOffsetApplClass notNil ifTrue:[
   250         aGC paint:(Color black).
   250         applName := self labelOfApplicationClass.
   251         applClass := self applicationClass.
   251         applName notNil ifTrue:[
   252 
   252             self displayLabel:applName
   253         applClass notNil ifTrue:[
       
   254             self displayLabel:('[ ', applClass name, ' ]')
       
   255                             h:labelHeight on:aGC
   253                             h:labelHeight on:aGC
   256                             x:(x + 10 + (self widthOn:aGC))
   254                             x:(x + xOffsetApplClass)
   257                             y:y
   255                             y:y
   258                             h:h.
   256                             h:h.
   259         ].
   257         ].
   260     ].
   258     ].
   261 !
   259 !
   262 
   260 
       
   261 labelOfApplicationClass
       
   262     "answer the name of the underlaying application or nil"
       
   263     |applClass|
       
   264 
       
   265     self isApplicationClass ifTrue:[
       
   266         applClass := self applicationClass.
       
   267 
       
   268         applClass notNil ifTrue:[
       
   269             ^ ('[ ', applClass name, ' ]')
       
   270         ].
       
   271     ].
       
   272     xOffsetApplClass := nil.
       
   273     ^ nil
       
   274 !
       
   275 
   263 widthOn:aGC
   276 widthOn:aGC
   264     "return the width of the receiver, if it is to be displayed on aGC
   277     "return the width of the receiver, if it is to be displayed on aGC
   265     "
   278     "
       
   279     |applName|
       
   280 
   266     width isNil ifTrue:[
   281     width isNil ifTrue:[
   267         width := self widthOf:(self label) on:aGC.
   282         width := self widthOf:(self label) on:aGC.
   268         width := width + 2.
   283         width := width + 2.
       
   284 
       
   285         applName := self labelOfApplicationClass.
       
   286 
       
   287         applName notNil ifTrue:[
       
   288             xOffsetApplClass := width + 10.
       
   289             width := xOffsetApplClass + (self widthOf:applName on:aGC).
       
   290             width := width + 2.
       
   291         ].
   269     ].
   292     ].
   270     ^ width
   293     ^ width
   271 ! !
   294 ! !
   272 
   295 
   273 !ViewTreeItem methodsFor:'enumerating'!
   296 !ViewTreeItem methodsFor:'enumerating'!