checkin from browser
authorClaus Gittinger <cg@exept.de>
Fri, 28 May 1999 20:05:44 +0200
changeset 1398 590a0d3a5ff4
parent 1397 44bdb2311a90
child 1399 da1eed642569
checkin from browser
HierarchicalItem.st
--- a/HierarchicalItem.st	Tue May 25 18:44:20 1999 +0200
+++ b/HierarchicalItem.st	Fri May 28 20:05:44 1999 +0200
@@ -749,47 +749,83 @@
 
 !HierarchicalItem methodsFor:'protocol displaying'!
 
-displayOn:aGC x:x y:y
+displayOn:aGC x:xL y:yT toX:xR y:yB
     "draw the receiver in the graphicsContext, aGC.
     "
     |label
+     yF "{ Class:SmallInteger }"
+     x0 "{ Class:SmallInteger }"
      y0 "{ Class:SmallInteger }"
+     ascent "{ Class:SmallInteger }"
+     h  "{ Class:SmallInteger }"
     |
-    label := self label.
+    (label := self label) isNil ifTrue:[
+        ^ self
+    ].
+    h := yB - yT.
+
+    (label isSequenceable and:[label isString not]) ifFalse:[
+        y0 := yT - ((label heightOn:aGC) + 1 - h // 2).
 
-    label notNil ifTrue:[
-        (      label isImageOrForm not
-         and:[(label isString or:[label isKindOf:LabelAndIcon])]
-        ) ifTrue:[
-            y0 := y + aGC font ascent
+        label isImageOrForm ifTrue:[
+            label displayOn:aGC x:xL y:y0
         ] ifFalse:[
-            y0 := y
+            label displayOn:aGC x:xL y:(y0 + aGC font ascent)
         ].
-        label displayOn:aGC x:x y:y0.
+        ^ self
+    ].
+
+    x0 := xL.
+    ascent := aGC font ascent.
+
+    label do:[:el|
+        el notNil ifTrue:[
+            y0 := yT - ((el heightOn:aGC) + 1 - h // 2).
+            el isImageOrForm ifFalse:[
+                y0 := y0 + ascent
+            ].
+            el displayOn:aGC x:x0 y:y0.
+            x0 := x0 + 5 + (el widthOn:aGC).
+
+            x0 < xR ifFalse:[
+                ^ self
+            ]
+        ]
     ]
-
 !
 
 heightOn:aGC
     "return the width of the receiver, if it is to be displayed on aGC
     "
-    |label|
+    |label h "{ Class:SmallInteger }"|
 
-    label := self label.
-  ^ label notNil ifTrue:[label heightOn:aGC] ifFalse:[0]
-
+    (label := self label) isNil ifTrue:[
+        ^ 0
+    ].
+    (label isString or:[label isSequenceable not]) ifTrue:[
+        ^ label heightOn:aGC
+    ].
+    h := 0.
+    label do:[:el| el notNil ifTrue:[h := (el heightOn:aGC) max:h]].
+  ^ h
 
 !
 
 widthOn:aGC
     "return the width of the receiver, if it is to be displayed on aGC
     "
-    |label|
+    |label w "{ Class:SmallInteger }"|
 
-    label := self label.
-  ^ label  notNil ifTrue:[label widthOn:aGC] ifFalse:[0]
+    (label := self label) isNil ifTrue:[
+        ^ 0
+    ].
+    (label isString or:[label isSequenceable not]) ifTrue:[
+        ^ label widthOn:aGC
+    ].
 
-
+    w := -5.
+    label do:[:el|el notNil ifTrue:[w := w + 5 + (el widthOn:aGC)]].
+  ^ w
 ! !
 
 !HierarchicalItem methodsFor:'protocol monitoring'!
@@ -817,7 +853,25 @@
      searching for an entry starting with a character.
      *** to optimize:redefine by subClass
     "
-    ^ self label perform:#string ifNotUnderstood:nil
+    |label|
+
+    (label := self label) notNil ifTrue:[
+        label isString      ifTrue:[ ^ label string ].
+        label isImageOrForm ifTrue:[ ^ nil ].
+
+        label isSequenceable ifFalse:[
+            ^ label perform:#string ifNotUnderstood:nil
+        ].
+
+        label do:[:el||s|
+            (el notNil and:[el isImageOrForm not]) ifTrue:[
+                s := el perform:#string ifNotUnderstood:nil.
+                s notNil ifTrue:[^ s].
+            ]
+        ]
+    ].
+    ^ nil
+        
 
 ! !
 
@@ -969,6 +1023,7 @@
 
         1 to:5 do:[:i|
             lbl := i odd ifTrue:[txt] ifFalse:[img].
+            lbl := Array with:lbl with:'test' with:img.
             children add:(self class labeled:lbl icon:icon).
         ]
     ].
@@ -1033,5 +1088,5 @@
 !HierarchicalItem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.1 1999-05-23 12:56:18 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalItem.st,v 1.2 1999-05-28 18:05:44 cg Exp $'
 ! !