SelectionInTreeView.st
changeset 448 7f9f3531660c
parent 446 b6ac0f279b2f
child 456 d46a10de4380
--- a/SelectionInTreeView.st	Thu Jul 03 12:59:08 1997 +0200
+++ b/SelectionInTreeView.st	Thu Jul 03 12:59:54 1997 +0200
@@ -12,7 +12,8 @@
 
 
 SelectionInListView subclass:#SelectionInTreeView
-	instanceVariableNames:'listOfNodes figuresWidth figuresInset dblClickEvt'
+	instanceVariableNames:'listOfNodes figuresWidth figuresInset dblClickEvt imageOpened
+		imageClosed imageItem'
 	classVariableNames:'ImageOpened ImageClosed ImageItem'
 	poolDictionaries:''
 	category:'Views-Text'
@@ -78,6 +79,25 @@
           in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
       top open.
                                                                         [exEnd]
+    same, including nil-subclasses (i.e. really all classes):
+                                                                        [exBegin]
+      |top hierarchy hierarchyV scroller|
+
+      hierarchy := SelectionInHierarchy new.
+      hierarchy root:(HierarchyNode newAsTreeFromSmalltalkClass:nil level:1).
+      hierarchy setHideToChildren:true startingAt:hierarchy root.
+
+      top := StandardSystemView new.
+      top extent:300@300.
+
+      hierarchyV := SelectionInTreeView new.
+      hierarchyV model: hierarchy.
+      hierarchyV action:[:nr | Transcript show:'selected:'; showCR:nr].
+
+      top add:(ScrollableView forView:hierarchyV)
+          in:((0.0 @ 0.0 ) corner:( 1.0 @ 1.0)).
+      top open.
+                                                                        [exEnd]
 "
 
 ! !
@@ -120,6 +140,54 @@
 
 !SelectionInTreeView methodsFor:'accessing'!
 
+imageClosed
+    "return the value of the instance variable 'imageClosed' (automatically generated)"
+
+    ^ imageClosed
+
+    "Created: 3.7.1997 / 12:34:31 / cg"
+!
+
+imageClosed:something
+    "set the value of the instance variable 'imageClosed' (automatically generated)"
+
+    imageClosed := something.
+
+    "Created: 3.7.1997 / 12:34:31 / cg"
+!
+
+imageItem
+    "return the value of the instance variable 'imageItem' (automatically generated)"
+
+    ^ imageItem
+
+    "Created: 3.7.1997 / 12:34:34 / cg"
+!
+
+imageItem:something
+    "set the value of the instance variable 'imageItem' (automatically generated)"
+
+    imageItem := something.
+
+    "Created: 3.7.1997 / 12:34:34 / cg"
+!
+
+imageOpened
+    "return the value of the instance variable 'imageOpened' (automatically generated)"
+
+    ^ imageOpened
+
+    "Created: 3.7.1997 / 12:34:28 / cg"
+!
+
+imageOpened:something
+    "set the value of the instance variable 'imageOpened' (automatically generated)"
+
+    imageOpened := something.
+
+    "Created: 3.7.1997 / 12:34:28 / cg"
+!
+
 list:aList keepSelection:keepSelection
     |list|
 
@@ -261,15 +329,31 @@
 
 !SelectionInTreeView methodsFor:'initialization'!
 
+fetchDeviceResources
+    "initialize heavily used device resources - to avoid rendering
+     images again and again later"
+
+    super fetchDeviceResources.
+
+    imageOpened := (self class imageOpened) onDevice:device.
+    imageClosed := (self class imageClosed) onDevice:device.
+    imageItem := (self class imageItem) onDevice:device.
+
+    "Created: 3.7.1997 / 12:31:12 / cg"
+!
+
 getFontParameters
     |image1 image2 height|
 
     super getFontParameters.
+    imageClosed isNil ifTrue:[
+        self fetchDeviceResources
+    ].
 
     figuresInset := 4.
 
-    image1 := self class imageClosed.
-    image2 := self class imageOpened.
+    image1 := imageClosed.
+    image2 := imageOpened.
     height := image1 heightOn:self.
     figuresWidth := image1 widthOn:self.
 
@@ -284,6 +368,7 @@
         figuresWidth := image2 widthOn:self
     ].
 
+    "Modified: 3.7.1997 / 12:33:10 / cg"
 !
 
 initialize
@@ -297,10 +382,12 @@
     "access figure for a node
     "
     aNode hasChildren ifTrue:[
-        aNode isExpandable ifTrue:[ ^ self class imageClosed ]
-                          ifFalse:[ ^ self class imageOpened ]
+        aNode isExpandable ifTrue:[ ^ imageClosed ]
+                          ifFalse:[ ^ imageOpened ]
     ].
-  ^ self class imageItem
+  ^ imageItem
+
+    "Modified: 3.7.1997 / 12:31:48 / cg"
 !
 
 getListFromModel
@@ -389,5 +476,5 @@
 !SelectionInTreeView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.2 1997-07-03 10:17:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.3 1997-07-03 10:59:54 cg Exp $'
 ! !