SelectionInTreeView.st
changeset 448 7f9f3531660c
parent 446 b6ac0f279b2f
child 456 d46a10de4380
equal deleted inserted replaced
447:705b618eb324 448:7f9f3531660c
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 
    13 
    14 SelectionInListView subclass:#SelectionInTreeView
    14 SelectionInListView subclass:#SelectionInTreeView
    15 	instanceVariableNames:'listOfNodes figuresWidth figuresInset dblClickEvt'
    15 	instanceVariableNames:'listOfNodes figuresWidth figuresInset dblClickEvt imageOpened
       
    16 		imageClosed imageItem'
    16 	classVariableNames:'ImageOpened ImageClosed ImageItem'
    17 	classVariableNames:'ImageOpened ImageClosed ImageItem'
    17 	poolDictionaries:''
    18 	poolDictionaries:''
    18 	category:'Views-Text'
    19 	category:'Views-Text'
    19 !
    20 !
    20 
    21 
    76 
    77 
    77       top add:(ScrollableView forView:hierarchyV)
    78       top add:(ScrollableView forView:hierarchyV)
    78           in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
    79           in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
    79       top open.
    80       top open.
    80                                                                         [exEnd]
    81                                                                         [exEnd]
       
    82     same, including nil-subclasses (i.e. really all classes):
       
    83                                                                         [exBegin]
       
    84       |top hierarchy hierarchyV scroller|
       
    85 
       
    86       hierarchy := SelectionInHierarchy new.
       
    87       hierarchy root:(HierarchyNode newAsTreeFromSmalltalkClass:nil level:1).
       
    88       hierarchy setHideToChildren:true startingAt:hierarchy root.
       
    89 
       
    90       top := StandardSystemView new.
       
    91       top extent:300@300.
       
    92 
       
    93       hierarchyV := SelectionInTreeView new.
       
    94       hierarchyV model: hierarchy.
       
    95       hierarchyV action:[:nr | Transcript show:'selected:'; showCR:nr].
       
    96 
       
    97       top add:(ScrollableView forView:hierarchyV)
       
    98           in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
       
    99       top open.
       
   100                                                                         [exEnd]
    81 "
   101 "
    82 
   102 
    83 ! !
   103 ! !
    84 
   104 
    85 !SelectionInTreeView class methodsFor:'constants'!
   105 !SelectionInTreeView class methodsFor:'constants'!
   117 ImageOpened := nil
   137 ImageOpened := nil
   118 "
   138 "
   119 ! !
   139 ! !
   120 
   140 
   121 !SelectionInTreeView methodsFor:'accessing'!
   141 !SelectionInTreeView methodsFor:'accessing'!
       
   142 
       
   143 imageClosed
       
   144     "return the value of the instance variable 'imageClosed' (automatically generated)"
       
   145 
       
   146     ^ imageClosed
       
   147 
       
   148     "Created: 3.7.1997 / 12:34:31 / cg"
       
   149 !
       
   150 
       
   151 imageClosed:something
       
   152     "set the value of the instance variable 'imageClosed' (automatically generated)"
       
   153 
       
   154     imageClosed := something.
       
   155 
       
   156     "Created: 3.7.1997 / 12:34:31 / cg"
       
   157 !
       
   158 
       
   159 imageItem
       
   160     "return the value of the instance variable 'imageItem' (automatically generated)"
       
   161 
       
   162     ^ imageItem
       
   163 
       
   164     "Created: 3.7.1997 / 12:34:34 / cg"
       
   165 !
       
   166 
       
   167 imageItem:something
       
   168     "set the value of the instance variable 'imageItem' (automatically generated)"
       
   169 
       
   170     imageItem := something.
       
   171 
       
   172     "Created: 3.7.1997 / 12:34:34 / cg"
       
   173 !
       
   174 
       
   175 imageOpened
       
   176     "return the value of the instance variable 'imageOpened' (automatically generated)"
       
   177 
       
   178     ^ imageOpened
       
   179 
       
   180     "Created: 3.7.1997 / 12:34:28 / cg"
       
   181 !
       
   182 
       
   183 imageOpened:something
       
   184     "set the value of the instance variable 'imageOpened' (automatically generated)"
       
   185 
       
   186     imageOpened := something.
       
   187 
       
   188     "Created: 3.7.1997 / 12:34:28 / cg"
       
   189 !
   122 
   190 
   123 list:aList keepSelection:keepSelection
   191 list:aList keepSelection:keepSelection
   124     |list|
   192     |list|
   125 
   193 
   126     list := aList.
   194     list := aList.
   259     ]
   327     ]
   260 ! !
   328 ! !
   261 
   329 
   262 !SelectionInTreeView methodsFor:'initialization'!
   330 !SelectionInTreeView methodsFor:'initialization'!
   263 
   331 
       
   332 fetchDeviceResources
       
   333     "initialize heavily used device resources - to avoid rendering
       
   334      images again and again later"
       
   335 
       
   336     super fetchDeviceResources.
       
   337 
       
   338     imageOpened := (self class imageOpened) onDevice:device.
       
   339     imageClosed := (self class imageClosed) onDevice:device.
       
   340     imageItem := (self class imageItem) onDevice:device.
       
   341 
       
   342     "Created: 3.7.1997 / 12:31:12 / cg"
       
   343 !
       
   344 
   264 getFontParameters
   345 getFontParameters
   265     |image1 image2 height|
   346     |image1 image2 height|
   266 
   347 
   267     super getFontParameters.
   348     super getFontParameters.
       
   349     imageClosed isNil ifTrue:[
       
   350         self fetchDeviceResources
       
   351     ].
   268 
   352 
   269     figuresInset := 4.
   353     figuresInset := 4.
   270 
   354 
   271     image1 := self class imageClosed.
   355     image1 := imageClosed.
   272     image2 := self class imageOpened.
   356     image2 := imageOpened.
   273     height := image1 heightOn:self.
   357     height := image1 heightOn:self.
   274     figuresWidth := image1 widthOn:self.
   358     figuresWidth := image1 widthOn:self.
   275 
   359 
   276     height < (image2 heightOn:self) ifTrue:[
   360     height < (image2 heightOn:self) ifTrue:[
   277         height := image2 heightOn:self
   361         height := image2 heightOn:self
   282 
   366 
   283     figuresWidth < (image2 widthOn:self) ifTrue:[
   367     figuresWidth < (image2 widthOn:self) ifTrue:[
   284         figuresWidth := image2 widthOn:self
   368         figuresWidth := image2 widthOn:self
   285     ].
   369     ].
   286 
   370 
       
   371     "Modified: 3.7.1997 / 12:33:10 / cg"
   287 !
   372 !
   288 
   373 
   289 initialize
   374 initialize
   290     super initialize.
   375     super initialize.
   291     dblClickEvt := false
   376     dblClickEvt := false
   295 
   380 
   296 figureFor:aNode
   381 figureFor:aNode
   297     "access figure for a node
   382     "access figure for a node
   298     "
   383     "
   299     aNode hasChildren ifTrue:[
   384     aNode hasChildren ifTrue:[
   300         aNode isExpandable ifTrue:[ ^ self class imageClosed ]
   385         aNode isExpandable ifTrue:[ ^ imageClosed ]
   301                           ifFalse:[ ^ self class imageOpened ]
   386                           ifFalse:[ ^ imageOpened ]
   302     ].
   387     ].
   303   ^ self class imageItem
   388   ^ imageItem
       
   389 
       
   390     "Modified: 3.7.1997 / 12:31:48 / cg"
   304 !
   391 !
   305 
   392 
   306 getListFromModel
   393 getListFromModel
   307     "if I have a model, get my list from it using the listMessage.
   394     "if I have a model, get my list from it using the listMessage.
   308      If listMessage is nil, try aspectMessage for backward compatibilty.
   395      If listMessage is nil, try aspectMessage for backward compatibilty.
   387 ! !
   474 ! !
   388 
   475 
   389 !SelectionInTreeView class methodsFor:'documentation'!
   476 !SelectionInTreeView class methodsFor:'documentation'!
   390 
   477 
   391 version
   478 version
   392     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.2 1997-07-03 10:17:04 cg Exp $'
   479     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.3 1997-07-03 10:59:54 cg Exp $'
   393 ! !
   480 ! !