add icons which are stored under a specific key
authorca
Thu, 18 Apr 2002 11:54:31 +0200
changeset 2094 71c676b5f061
parent 2093 0dff6d4c173a
child 2095 46120b1fd644
add icons which are stored under a specific key and registered on the device. useable by hierarchical items ....
HierarchicalListView.st
--- a/HierarchicalListView.st	Wed Apr 17 07:02:56 2002 +0200
+++ b/HierarchicalListView.st	Thu Apr 18 11:54:31 2002 +0200
@@ -306,6 +306,26 @@
     ].
 !
 
+iconAt:aKey ifAbsentPut:aBlock
+    "return the icon stored under a key; if not present,the
+     result of the block if not nil is stored under the key
+     and returned.
+    "
+    |icon|
+
+    icon := icons at:aKey ifAbsent:nil.
+    icon ifNotNil:[^ icon].
+
+    icon := aBlock value.
+    icon ifNil:[^ nil].
+
+    realized ifTrue:[
+        icon := self imageOnDevice:icon
+    ].
+    icons at:aKey put:icon.
+  ^ icon
+!
+
 registerKeysAndIcons:aDictionary
     "register icons by key and value derived from a directory
     "
@@ -1173,5 +1193,5 @@
 !HierarchicalListView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.39 2001-12-14 10:53:19 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalListView.st,v 1.40 2002-04-18 09:54:31 ca Exp $'
 ! !