add label to vertical panel
authorca
Thu, 07 Nov 1996 15:04:42 +0100
changeset 871 541b8f9e8237
parent 870 c606f29db5d7
child 872 3cdb211615e2
add label to vertical panel
VarPanel.st
VariablePanel.st
--- a/VarPanel.st	Wed Nov 06 18:46:41 1996 +0100
+++ b/VarPanel.st	Thu Nov 07 15:04:42 1996 +0100
@@ -13,7 +13,7 @@
 SimpleView subclass:#VariablePanel
 	instanceVariableNames:'barHeight barWidth separatingLine shadowForm lightForm showHandle
 		handlePosition handleColor handleStyle handleLevel noColor
-		trackLine redrawLocked orientation'
+		trackLine redrawLocked orientation handleLabels knobHeight'
 	classVariableNames:'DefaultShowHandle DefaultHandleStyle DefaultHandlePosition
 		DefaultTrackingLine DefaultSeparatingLine DefaultHandleColor
 		DefaultHandleLevel DefaultVCursor DefaultHCursor'
@@ -21,7 +21,7 @@
 	category:'Views-Layout'
 !
 
-!VariablePanel  class methodsFor:'documentation'!
+!VariablePanel class methodsFor:'documentation'!
 
 copyright
 "
@@ -170,6 +170,8 @@
                  corner:1.0 @ 1.0
                  in:top.
         p orientation:#vertical.
+p handleLabels:#('foo' 'bar' 'baz').
+Transcript showCR:p barHeight.
 
         v1 := View origin:0.0@0.0 corner:1.0@(1/2) in:p.
         v2 := View origin:0.0@(1/2) corner:1.0@(2/3) in:p.
@@ -427,7 +429,7 @@
 "
 ! !
 
-!VariablePanel  class methodsFor:'defaults'!
+!VariablePanel class methodsFor:'defaults'!
 
 lightFormOn:aDisplay
     "use same handle as Scroller"
@@ -537,6 +539,17 @@
     ]
 !
 
+handleLabels:aCollectionOfLabels
+    orientation == #horizontal ifTrue:[
+        self error:'not allowed for horizontal panels'
+    ].
+
+    handleLabels := aCollectionOfLabels.
+    self computeBarHeight.
+    self resizeSubviews.
+
+!
+
 handleLevel:aNumber
     "define the 3D level of the handle (only with some styles).
      Normally, this is defined via styleSheet files, but this entry allows
@@ -604,157 +617,167 @@
 
 !VariablePanel methodsFor:'drawing'!
 
-drawHandleAtX:hx y:hy
+drawHandle:hIndex atX:hx y:hy
     "draw a single handle at hx/hy"
 
-    |h w x y m|
+    |h w x y m lbl|
 
     handleStyle isNil ifTrue:[^ self].
 
+
     shadowForm notNil ifTrue:[
-	h := shadowForm height.
-	w := shadowForm width .
+        h := shadowForm height.
+        w := shadowForm width .
     ] ifFalse:[
-	h := w := barHeight - 4.
+        h := w := knobHeight - 4.
     ].
 
     self paint:viewBackground.
     orientation == #vertical ifTrue:[
-	self fillRectangleX:margin y:hy 
-		      width:(width - margin - margin) 
-		     height:barHeight.
+        self fillRectangleX:margin y:hy 
+                      width:(width - margin - margin) 
+                     height:barHeight.
+
+        (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
+            m := (knobHeight - h) // 2.
+
+            shadowForm isNil ifTrue:[
+                y := hy + (barHeight // 2).
 
-	(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-	    m := (barHeight - h) // 2.
-
-	    shadowForm isNil ifTrue:[
-		y := hy + (barHeight // 2).
+                separatingLine ifTrue:[
+                    self paint:shadowColor.
+                    self displayLineFromX:margin y:y toX:(width - margin) y:y.
+                    y := y + 1.
+                    self paint:lightColor.
+                    self displayLineFromX:margin y:y toX:(width - margin) y:y.
+                ].
+                self paint:viewBackground.
+                self fillRectangleX:(hx - barWidth) y:hy 
+                             width:(barWidth + barWidth) 
+                             height:h.
 
-		separatingLine ifTrue:[
-		    self paint:shadowColor.
-		    self displayLineFromX:margin y:y toX:(width - margin) y:y.
-		    y := y + 1.
-		    self paint:lightColor.
-		    self displayLineFromX:margin y:y toX:(width - margin) y:y.
-		].
-		self paint:viewBackground.
-		self fillRectangleX:(hx - barWidth) y:hy 
-			     width:(barWidth + barWidth) 
-			     height:h.
+                handleStyle == #line ifTrue:[
+                    self paint:handleColor.
+                    self displayLineFromX:hx - barWidth y:y toX:hx + barWidth y:y
+                ] ifFalse:[
+                    y := hy.   
+                    handleStyle == #st80 ifTrue:[
+                        y := y - 1
+                    ].
+                    self drawEdgesForX:(hx - barWidth)
+                                     y:(y + m)
+                                 width:(barWidth + barWidth)
+                                height:h 
+                                 level:handleLevel.
 
-		handleStyle == #line ifTrue:[
-		    self paint:handleColor.
-		    self displayLineFromX:hx - barWidth y:y toX:hx + barWidth y:y
-		] ifFalse:[
-		    y := hy.   
-		    handleStyle == #st80 ifTrue:[
-			y := y - 1
-		    ].
-		    self drawEdgesForX:(hx - barWidth)
-				     y:(y + m)
-				 width:(barWidth + barWidth)
-				height:h 
-				 level:handleLevel.
+                    handleStyle == #iris ifTrue:[
+                        self paint:handleColor.
+                        self fillDeviceRectangleX:(hx - barWidth + 2)
+                                                y:(y + m + 2)
+                                            width:(barWidth + barWidth - 4)
+                                           height:h - 4
+                    ]
+                ].
+            ] ifFalse:[
+                y := hy.
+                self drawHandleFormAtX:hx y:(y + m)
+            ].
+            handleStyle == #st80 ifTrue:[
+                y := hy - 1.
+                self paint:lightColor.
+                self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y.
+                self displayLineFromX:0 y:hy toX:0 y:(hy + knobHeight - 1).
+                y := hy + knobHeight - 2.
+                self paint:shadowColor.
+                self displayLineFromX:margin y:y toX:(width - margin) y:y.
+                    "uncomment the -1 if you dont like the notch at the right end"
+                    "                            VVV"
+                self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + knobHeight - 1).
+            ].
+        ] ifFalse:[
+            y := hy + barHeight - 1.
+            self paint:handleColor.
+            separatingLine ifTrue:[
+                self displayLineFromX:0 y:hy+1 toX:width y:hy+1.
+                self displayLineFromX:0 y:y toX:width y:y.
+            ].
+            self fillRectangleX:hx y:hy width:barWidth height:barHeight
+        ].
 
-		    handleStyle == #iris ifTrue:[
-			self paint:handleColor.
-			self fillDeviceRectangleX:(hx - barWidth + 2)
-						y:(y + m + 2)
-					    width:(barWidth + barWidth - 4)
-					   height:h - 4
-		    ]
-		].
-	    ] ifFalse:[
-		y := hy.
-		self drawHandleFormAtX:hx y:(y + m)
-	    ].
-	    handleStyle == #st80 ifTrue:[
-		y := hy - 1.
-		self paint:lightColor.
-		self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y.
-		self displayLineFromX:0 y:hy toX:0 y:(hy + barHeight - 1).
-		y := hy + barHeight - 2.
-		self paint:shadowColor.
-		self displayLineFromX:margin y:y toX:(width - margin) y:y.
-		    "uncomment the -1 if you dont like the notch at the right end"
-		    "                            VVV"
-		self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + barHeight - 1).
-	    ].
-	] ifFalse:[
-	    y := hy + barHeight - 1.
-	    self paint:handleColor.
-	    separatingLine ifTrue:[
-		self displayLineFromX:0 y:hy+1 toX:width y:hy+1.
-		self displayLineFromX:0 y:y toX:width y:y.
-	    ].
-	    self fillRectangleX:hx y:hy width:barWidth height:barHeight
-	]
+        lbl := self handleLabelAt:hIndex.
+        lbl notNil ifTrue:[
+            hIndex ~~ 1 ifTrue:[
+                self paint:Color black.
+                lbl displayOn:self x:margin y:hy + font ascent + 1
+            ]
+        ].
+
     ] ifFalse:[
-	self fillRectangleX:hx y:margin 
-		      width:barHeight
-		     height:(height - margin - margin).
-	(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-	     m := (barHeight - w) // 2.
-	     shadowForm isNil ifTrue:[
-		x := hx + (barHeight // 2).
-		separatingLine ifTrue:[
-		    self paint:shadowColor.
-		    self displayLineFromX:x y:margin toX:x y:(height - margin).
-		    x := x + 1.
-		    self paint:lightColor.
-		    self displayLineFromX:x y:margin toX:x y:(height - margin).
-		].
-		self paint:viewBackground.
-		self fillRectangleX:hx y:(hy - barWidth) 
-			      width:w 
-			     height:(barWidth + barWidth).
+        self fillRectangleX:hx y:margin 
+                      width:barHeight
+                     height:(height - margin - margin).
+        (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
+             m := (barHeight - w) // 2.
+             shadowForm isNil ifTrue:[
+                x := hx + (barHeight // 2).
+                separatingLine ifTrue:[
+                    self paint:shadowColor.
+                    self displayLineFromX:x y:margin toX:x y:(height - margin).
+                    x := x + 1.
+                    self paint:lightColor.
+                    self displayLineFromX:x y:margin toX:x y:(height - margin).
+                ].
+                self paint:viewBackground.
+                self fillRectangleX:hx y:(hy - barWidth) 
+                              width:w 
+                             height:(barWidth + barWidth).
 
-		handleStyle == #line ifTrue:[
-		    self paint:handleColor.
-		    self displayLineFromX:x y:hy - barWidth toX:x y:hy + barWidth.
-		] ifFalse:[
-		    x := hx.
-		    handleStyle == #st80 ifTrue:[
-			x := x - 1.
-		    ].
-		    self drawEdgesForX:(x + m)
-				     y:(hy - barWidth)
-				 width:w 
-				height:(barWidth + barWidth)
-				 level:handleLevel.
-		    handleStyle == #iris ifTrue:[
-			self paint:handleColor.
-			self fillDeviceRectangleX:(x + m + 2)
-						y:(hy - barWidth + 2)
-					    width:w - 4
-					   height:(barWidth + barWidth - 4)
-		    ].
-		]
-	    ] ifFalse:[
-		x := hx.
-		self drawHandleFormAtX:(x + m) y:hy
-	    ].
-	    handleStyle == #st80 ifTrue:[
-		x := hx - 1.
-		self paint:lightColor.
-		self displayLineFromX:x y:margin toX:x y:(height - margin).
-		self displayLineFromX:hx y:0 toX:(hx + barHeight - 1) y:0.
-		x := hx + barHeight - 2.
-		self paint:shadowColor.
-		self displayLineFromX:x y:margin toX:x y:(height - margin).
-		    "uncomment the -1 if you dont like the notch at the bottom end"
-		    "                   VVV"
-		self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeight - 1) y:height-1.
-	    ].
-	] ifFalse:[
-	    x := hx + barHeight - 1.
-	    self paint:handleColor.
-	    separatingLine ifTrue:[
-		self displayLineFromX:hx+1 y:0 toX:hx+1 y:height.
-		self displayLineFromX:x y:0 toX:x y:height.
-	    ].
-	    self fillRectangleX:hx y:hy width:barHeight height:barWidth
-	]
+                handleStyle == #line ifTrue:[
+                    self paint:handleColor.
+                    self displayLineFromX:x y:hy - barWidth toX:x y:hy + barWidth.
+                ] ifFalse:[
+                    x := hx.
+                    handleStyle == #st80 ifTrue:[
+                        x := x - 1.
+                    ].
+                    self drawEdgesForX:(x + m)
+                                     y:(hy - barWidth)
+                                 width:w 
+                                height:(barWidth + barWidth)
+                                 level:handleLevel.
+                    handleStyle == #iris ifTrue:[
+                        self paint:handleColor.
+                        self fillDeviceRectangleX:(x + m + 2)
+                                                y:(hy - barWidth + 2)
+                                            width:w - 4
+                                           height:(barWidth + barWidth - 4)
+                    ].
+                ]
+            ] ifFalse:[
+                x := hx.
+                self drawHandleFormAtX:(x + m) y:hy
+            ].
+            handleStyle == #st80 ifTrue:[
+                x := hx - 1.
+                self paint:lightColor.
+                self displayLineFromX:x y:margin toX:x y:(height - margin).
+                self displayLineFromX:hx y:0 toX:(hx + barHeight - 1) y:0.
+                x := hx + barHeight - 2.
+                self paint:shadowColor.
+                self displayLineFromX:x y:margin toX:x y:(height - margin).
+                    "uncomment the -1 if you dont like the notch at the bottom end"
+                    "                   VVV"
+                self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeight - 1) y:height-1.
+            ].
+        ] ifFalse:[
+            x := hx + barHeight - 1.
+            self paint:handleColor.
+            separatingLine ifTrue:[
+                self displayLineFromX:hx+1 y:0 toX:hx+1 y:height.
+                self displayLineFromX:x y:0 toX:x y:height.
+            ].
+            self fillRectangleX:hx y:hy width:barHeight height:barWidth
+        ]
     ].
 
     "Modified: 24.2.1996 / 19:05:52 / cg"
@@ -810,11 +833,11 @@
     "redraw some handles"
 
     subViews notNil ifTrue:[
-	showHandle ifTrue:[
-	    self handleOriginsFrom:start to:stop do:[:hPoint |
-		self drawHandleAtX:(hPoint x) y:(hPoint y)
-	    ].
-	]
+        showHandle ifTrue:[
+            self handleOriginsWithIndexFrom:start to:stop do:[:hPoint :hIndex |
+                self drawHandle:hIndex atX:(hPoint x) y:(hPoint y)
+            ].
+        ]
     ]
 !
 
@@ -842,6 +865,32 @@
 
 !VariablePanel methodsFor:'initializing'!
 
+computeBarHeight
+    |bH h|
+
+    handleStyle == #next ifTrue:[
+        bH := shadowForm height + 2.
+    ] ifFalse:[
+        self is3D ifTrue:[
+            h := 3
+        ] ifFalse:[
+            h := 2
+        ].
+        bH := (h * device verticalPixelPerMillimeter) rounded.
+    ].
+    knobHeight := bH.
+
+    handleLabels notNil ifTrue:[
+        font := font on:device.
+        bH := handleLabels inject:bH into:[:maxSoFar :thisLabel |
+                                                maxSoFar max:(thisLabel heightOn:self)].
+        bH := bH + font descent - 1
+    ].
+
+    self barHeight:bH.
+
+!
+
 defaultControllerClass
     ^ VariablePanelController
 !
@@ -898,7 +947,7 @@
 !
 
 initStyle
-    |mm h bH|
+    |mm|
 
     super initStyle.
 
@@ -920,21 +969,14 @@
         shadowForm := self class shadowFormOn:device.
         lightForm := self class lightFormOn:device.
 
-        bH := shadowForm height + 2.
         barWidth := shadowForm width.
     ] ifFalse:[
         shadowForm := lightForm := nil.
 
         mm := device verticalPixelPerMillimeter.
-        self is3D ifTrue:[
-            h := 3
-        ] ifFalse:[
-            h := 2
-        ].
-        bH := (h * mm) rounded.
         barWidth := (2 * mm) rounded. "motif style width"
     ].
-    self barHeight:bH.
+    self computeBarHeight.
 
     handleStyle == #mswindows ifTrue:[
         barWidth := (ArrowButton new direction:#up) width + 1 
@@ -965,13 +1007,20 @@
     ^ false
 !
 
-handleOriginsDo:aBlock
+handleLabelAt:hIndex
+    handleLabels notNil ifTrue:[
+        ^ handleLabels at:hIndex ifAbsent:nil
+    ].
+    ^ nil
+!
+
+handleOriginsWithIndexDo:aBlock
     "evaluate the argument block for every handle-origin"
 
-    self handleOriginsFrom:1 to:(subViews size) do:aBlock
+    self handleOriginsWithIndexFrom:1 to:(subViews size) do:aBlock
 !
 
-handleOriginsFrom:start to:stop do:aBlock
+handleOriginsWithIndexFrom:start to:stop do:aBlock
     "evaluate the argument block for some handle-origins"
 
     |x y hw hh hDelta vDelta
@@ -979,45 +1028,45 @@
      last  "{ Class: SmallInteger }"|
 
     subViews notNil ifTrue:[
-	shadowForm notNil ifTrue:[
-	    hw := shadowForm width.
-	    hh := shadowForm height.
-	] ifFalse:[
-	    hw := hh := barWidth
-	].
+        shadowForm notNil ifTrue:[
+            hw := shadowForm width.
+            hh := shadowForm height.
+        ] ifFalse:[
+            hw := hh := barWidth
+        ].
 
-	(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-	    hDelta := barWidth // 2.
-	    vDelta := barWidth // 2.
-	] ifFalse:[
-	    hDelta := vDelta := 0
-	].
+        (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
+            hDelta := barWidth // 2.
+            vDelta := barWidth // 2.
+        ] ifFalse:[
+            hDelta := vDelta := 0
+        ].
 
-	(handlePosition == #left) ifTrue:[
-	    x := hDelta. 
-	    y := vDelta
-	] ifFalse:[
-	    (handlePosition == #right) ifTrue:[
-		x := width - hw - margin - hDelta.
-		y := height - hh - margin - vDelta.
-	    ] ifFalse:[
-		x := width - barWidth // 2.
-		y := height - barWidth // 2
-	    ]
-	].
-	first := start + 1.
-	last := stop.
-	first to:last do:[:index |
-	    |view|
+        (handlePosition == #left) ifTrue:[
+            x := hDelta. 
+            y := vDelta
+        ] ifFalse:[
+            (handlePosition == #right) ifTrue:[
+                x := width - hw - margin - hDelta.
+                y := height - hh - margin - vDelta.
+            ] ifFalse:[
+                x := width - barWidth // 2.
+                y := height - barWidth // 2
+            ]
+        ].
+        first := start + 1.
+        last := stop.
+        first to:last do:[:index |
+            |view|
 
-	    view := subViews at:index.
-	    orientation == #vertical ifTrue:[
-		y := view top "origin y" - barHeight + 1.
-	    ] ifFalse:[
-		x := view left "origin x" - barHeight + 1.
-	    ].
-	    aBlock value:(x @ y)
-	]
+            view := subViews at:index.
+            orientation == #vertical ifTrue:[
+                y := view top "origin y" - barHeight + 1.
+            ] ifFalse:[
+                x := view left "origin x" - barHeight + 1.
+            ].
+            aBlock value:(x @ y) value:index
+        ]
     ]
 !
 
@@ -1033,71 +1082,72 @@
     |step nSubviews|
 
     subViews notNil ifTrue:[
-	(start <= stop) ifTrue:[
-	    step := 1
-	] ifFalse:[
-	    step := -1
-	].
-	nSubviews := subViews size.
-	start to:stop by:step do:[:index |
-	    |bw view o1 o2 relOrg relCorner newOrg newCorner newExt|
+        (start <= stop) ifTrue:[
+            step := 1
+        ] ifFalse:[
+            step := -1
+        ].
+        nSubviews := subViews size.
+        start to:stop by:step do:[:index |
+            |bw view o1 o2 relOrg relCorner newOrg newCorner newExt|
 
-	    view := subViews at:index.
-	    bw := view borderWidth.
+            view := subViews at:index.
+            bw := view borderWidth.
 
-	    index == 1 ifTrue:[
-		o1 := 0.
-	    ] ifFalse:[
-		o1 := barHeight // 2 - bw
-	    ].
-	    index ==  nSubviews ifTrue:[
-		o2 := 0.
-	    ] ifFalse:[
-		o2 := barHeight // 2 - bw
-	    ].
+            index == 1 ifTrue:[
+                o1 := 0.
+            ] ifFalse:[
+                o1 := barHeight // 2 - bw
+            ].
+            index ==  nSubviews ifTrue:[
+                o2 := 0.
+            ] ifFalse:[
+                o2 := barHeight // 2 - bw
+            ].
 
 "
-	    relCorner := view relativeCorner.
-	    relCorner isNil ifTrue:[
-		self error:'subview must have relative corner'
-	    ].
-	    newCorner := view cornerFromRelativeCorner.
-	    newCorner notNil ifTrue:[
-		newCorner y:(newCorner y - o2)
-	    ].
+            relCorner := view relativeCorner.
+            relCorner isNil ifTrue:[
+                self error:'subview must have relative corner'
+            ].
+            newCorner := view cornerFromRelativeCorner.
+            newCorner notNil ifTrue:[
+                newCorner y:(newCorner y - o2)
+            ].
 
-	    relOrg := view relativeOrigin.
-	    relOrg isNil ifTrue:[
-		self error:'subview must have relative origin'
-	    ].
-	    newOrg := view originFromRelativeOrigin.
-	    newOrg notNil ifTrue:[
-		(index ~~ 1) ifTrue:[  
-		    newOrg y:(newOrg y + o1)
-		].
-	    ].
-	    view pixelOrigin:newOrg corner:newCorner
+            relOrg := view relativeOrigin.
+            relOrg isNil ifTrue:[
+                self error:'subview must have relative origin'
+            ].
+            newOrg := view originFromRelativeOrigin.
+            newOrg notNil ifTrue:[
+                (index ~~ 1) ifTrue:[  
+                    newOrg y:(newOrg y + o1)
+                ].
+            ].
+            view pixelOrigin:newOrg corner:newCorner
 "
-	    newOrg := view computeOrigin.
-	    newOrg notNil ifTrue:[
-		(index ~~ 1) ifTrue:[
-		    orientation == #vertical ifTrue:[
-			newOrg y:(newOrg y + o1)
-		    ] ifFalse:[
-			newOrg x:(newOrg x + o1)
-		    ]
-		].
-	    ].
-	    newExt := view computeExtent.
-	    newExt notNil ifTrue:[
-		orientation == #vertical ifTrue:[
-		    newExt y:(newExt y - o2 - o1)
-		] ifFalse:[
-		    newExt x:(newExt x - o2 - o1)
-		]
-	    ].
-	    view pixelOrigin:newOrg extent:newExt.
-	]
+            newOrg := view computeOrigin.
+            newOrg notNil ifTrue:[
+                (index ~~ 1) ifTrue:[
+                    orientation == #vertical ifTrue:[
+                        newOrg y:(newOrg y + o1)
+                    ] ifFalse:[
+                        newOrg x:(newOrg x + o1)
+                    ]
+                ].
+            ].
+            newExt := view computeExtent.
+            newExt notNil ifTrue:[
+                orientation == #vertical ifTrue:[
+                    newExt y:(newExt y - o2 - o1)
+                ] ifFalse:[
+                    newExt x:(newExt x - o2 - o1)
+                ]
+            ].
+Transcript show:newOrg; space; showCR:newExt.
+            view pixelOrigin:newOrg extent:newExt.
+        ]
     ]
 !
 
@@ -1180,8 +1230,8 @@
     "Modified: 21.8.1996 / 10:01:29 / stefan"
 ! !
 
-!VariablePanel  class methodsFor:'documentation'!
+!VariablePanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/VarPanel.st,v 1.13 1996-08-21 10:27:50 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/VarPanel.st,v 1.14 1996-11-07 14:04:42 ca Exp $'
 ! !
--- a/VariablePanel.st	Wed Nov 06 18:46:41 1996 +0100
+++ b/VariablePanel.st	Thu Nov 07 15:04:42 1996 +0100
@@ -13,7 +13,7 @@
 SimpleView subclass:#VariablePanel
 	instanceVariableNames:'barHeight barWidth separatingLine shadowForm lightForm showHandle
 		handlePosition handleColor handleStyle handleLevel noColor
-		trackLine redrawLocked orientation'
+		trackLine redrawLocked orientation handleLabels knobHeight'
 	classVariableNames:'DefaultShowHandle DefaultHandleStyle DefaultHandlePosition
 		DefaultTrackingLine DefaultSeparatingLine DefaultHandleColor
 		DefaultHandleLevel DefaultVCursor DefaultHCursor'
@@ -21,7 +21,7 @@
 	category:'Views-Layout'
 !
 
-!VariablePanel  class methodsFor:'documentation'!
+!VariablePanel class methodsFor:'documentation'!
 
 copyright
 "
@@ -170,6 +170,8 @@
                  corner:1.0 @ 1.0
                  in:top.
         p orientation:#vertical.
+p handleLabels:#('foo' 'bar' 'baz').
+Transcript showCR:p barHeight.
 
         v1 := View origin:0.0@0.0 corner:1.0@(1/2) in:p.
         v2 := View origin:0.0@(1/2) corner:1.0@(2/3) in:p.
@@ -427,7 +429,7 @@
 "
 ! !
 
-!VariablePanel  class methodsFor:'defaults'!
+!VariablePanel class methodsFor:'defaults'!
 
 lightFormOn:aDisplay
     "use same handle as Scroller"
@@ -537,6 +539,17 @@
     ]
 !
 
+handleLabels:aCollectionOfLabels
+    orientation == #horizontal ifTrue:[
+        self error:'not allowed for horizontal panels'
+    ].
+
+    handleLabels := aCollectionOfLabels.
+    self computeBarHeight.
+    self resizeSubviews.
+
+!
+
 handleLevel:aNumber
     "define the 3D level of the handle (only with some styles).
      Normally, this is defined via styleSheet files, but this entry allows
@@ -604,157 +617,167 @@
 
 !VariablePanel methodsFor:'drawing'!
 
-drawHandleAtX:hx y:hy
+drawHandle:hIndex atX:hx y:hy
     "draw a single handle at hx/hy"
 
-    |h w x y m|
+    |h w x y m lbl|
 
     handleStyle isNil ifTrue:[^ self].
 
+
     shadowForm notNil ifTrue:[
-	h := shadowForm height.
-	w := shadowForm width .
+        h := shadowForm height.
+        w := shadowForm width .
     ] ifFalse:[
-	h := w := barHeight - 4.
+        h := w := knobHeight - 4.
     ].
 
     self paint:viewBackground.
     orientation == #vertical ifTrue:[
-	self fillRectangleX:margin y:hy 
-		      width:(width - margin - margin) 
-		     height:barHeight.
+        self fillRectangleX:margin y:hy 
+                      width:(width - margin - margin) 
+                     height:barHeight.
+
+        (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
+            m := (knobHeight - h) // 2.
+
+            shadowForm isNil ifTrue:[
+                y := hy + (barHeight // 2).
 
-	(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-	    m := (barHeight - h) // 2.
-
-	    shadowForm isNil ifTrue:[
-		y := hy + (barHeight // 2).
+                separatingLine ifTrue:[
+                    self paint:shadowColor.
+                    self displayLineFromX:margin y:y toX:(width - margin) y:y.
+                    y := y + 1.
+                    self paint:lightColor.
+                    self displayLineFromX:margin y:y toX:(width - margin) y:y.
+                ].
+                self paint:viewBackground.
+                self fillRectangleX:(hx - barWidth) y:hy 
+                             width:(barWidth + barWidth) 
+                             height:h.
 
-		separatingLine ifTrue:[
-		    self paint:shadowColor.
-		    self displayLineFromX:margin y:y toX:(width - margin) y:y.
-		    y := y + 1.
-		    self paint:lightColor.
-		    self displayLineFromX:margin y:y toX:(width - margin) y:y.
-		].
-		self paint:viewBackground.
-		self fillRectangleX:(hx - barWidth) y:hy 
-			     width:(barWidth + barWidth) 
-			     height:h.
+                handleStyle == #line ifTrue:[
+                    self paint:handleColor.
+                    self displayLineFromX:hx - barWidth y:y toX:hx + barWidth y:y
+                ] ifFalse:[
+                    y := hy.   
+                    handleStyle == #st80 ifTrue:[
+                        y := y - 1
+                    ].
+                    self drawEdgesForX:(hx - barWidth)
+                                     y:(y + m)
+                                 width:(barWidth + barWidth)
+                                height:h 
+                                 level:handleLevel.
 
-		handleStyle == #line ifTrue:[
-		    self paint:handleColor.
-		    self displayLineFromX:hx - barWidth y:y toX:hx + barWidth y:y
-		] ifFalse:[
-		    y := hy.   
-		    handleStyle == #st80 ifTrue:[
-			y := y - 1
-		    ].
-		    self drawEdgesForX:(hx - barWidth)
-				     y:(y + m)
-				 width:(barWidth + barWidth)
-				height:h 
-				 level:handleLevel.
+                    handleStyle == #iris ifTrue:[
+                        self paint:handleColor.
+                        self fillDeviceRectangleX:(hx - barWidth + 2)
+                                                y:(y + m + 2)
+                                            width:(barWidth + barWidth - 4)
+                                           height:h - 4
+                    ]
+                ].
+            ] ifFalse:[
+                y := hy.
+                self drawHandleFormAtX:hx y:(y + m)
+            ].
+            handleStyle == #st80 ifTrue:[
+                y := hy - 1.
+                self paint:lightColor.
+                self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y.
+                self displayLineFromX:0 y:hy toX:0 y:(hy + knobHeight - 1).
+                y := hy + knobHeight - 2.
+                self paint:shadowColor.
+                self displayLineFromX:margin y:y toX:(width - margin) y:y.
+                    "uncomment the -1 if you dont like the notch at the right end"
+                    "                            VVV"
+                self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + knobHeight - 1).
+            ].
+        ] ifFalse:[
+            y := hy + barHeight - 1.
+            self paint:handleColor.
+            separatingLine ifTrue:[
+                self displayLineFromX:0 y:hy+1 toX:width y:hy+1.
+                self displayLineFromX:0 y:y toX:width y:y.
+            ].
+            self fillRectangleX:hx y:hy width:barWidth height:barHeight
+        ].
 
-		    handleStyle == #iris ifTrue:[
-			self paint:handleColor.
-			self fillDeviceRectangleX:(hx - barWidth + 2)
-						y:(y + m + 2)
-					    width:(barWidth + barWidth - 4)
-					   height:h - 4
-		    ]
-		].
-	    ] ifFalse:[
-		y := hy.
-		self drawHandleFormAtX:hx y:(y + m)
-	    ].
-	    handleStyle == #st80 ifTrue:[
-		y := hy - 1.
-		self paint:lightColor.
-		self displayLineFromX:margin y:y toX:(width - margin - margin - 1) y:y.
-		self displayLineFromX:0 y:hy toX:0 y:(hy + barHeight - 1).
-		y := hy + barHeight - 2.
-		self paint:shadowColor.
-		self displayLineFromX:margin y:y toX:(width - margin) y:y.
-		    "uncomment the -1 if you dont like the notch at the right end"
-		    "                            VVV"
-		self displayLineFromX:width-1 y:hy" "-1" " toX:width-1 y:(hy + barHeight - 1).
-	    ].
-	] ifFalse:[
-	    y := hy + barHeight - 1.
-	    self paint:handleColor.
-	    separatingLine ifTrue:[
-		self displayLineFromX:0 y:hy+1 toX:width y:hy+1.
-		self displayLineFromX:0 y:y toX:width y:y.
-	    ].
-	    self fillRectangleX:hx y:hy width:barWidth height:barHeight
-	]
+        lbl := self handleLabelAt:hIndex.
+        lbl notNil ifTrue:[
+            hIndex ~~ 1 ifTrue:[
+                self paint:Color black.
+                lbl displayOn:self x:margin y:hy + font ascent + 1
+            ]
+        ].
+
     ] ifFalse:[
-	self fillRectangleX:hx y:margin 
-		      width:barHeight
-		     height:(height - margin - margin).
-	(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-	     m := (barHeight - w) // 2.
-	     shadowForm isNil ifTrue:[
-		x := hx + (barHeight // 2).
-		separatingLine ifTrue:[
-		    self paint:shadowColor.
-		    self displayLineFromX:x y:margin toX:x y:(height - margin).
-		    x := x + 1.
-		    self paint:lightColor.
-		    self displayLineFromX:x y:margin toX:x y:(height - margin).
-		].
-		self paint:viewBackground.
-		self fillRectangleX:hx y:(hy - barWidth) 
-			      width:w 
-			     height:(barWidth + barWidth).
+        self fillRectangleX:hx y:margin 
+                      width:barHeight
+                     height:(height - margin - margin).
+        (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
+             m := (barHeight - w) // 2.
+             shadowForm isNil ifTrue:[
+                x := hx + (barHeight // 2).
+                separatingLine ifTrue:[
+                    self paint:shadowColor.
+                    self displayLineFromX:x y:margin toX:x y:(height - margin).
+                    x := x + 1.
+                    self paint:lightColor.
+                    self displayLineFromX:x y:margin toX:x y:(height - margin).
+                ].
+                self paint:viewBackground.
+                self fillRectangleX:hx y:(hy - barWidth) 
+                              width:w 
+                             height:(barWidth + barWidth).
 
-		handleStyle == #line ifTrue:[
-		    self paint:handleColor.
-		    self displayLineFromX:x y:hy - barWidth toX:x y:hy + barWidth.
-		] ifFalse:[
-		    x := hx.
-		    handleStyle == #st80 ifTrue:[
-			x := x - 1.
-		    ].
-		    self drawEdgesForX:(x + m)
-				     y:(hy - barWidth)
-				 width:w 
-				height:(barWidth + barWidth)
-				 level:handleLevel.
-		    handleStyle == #iris ifTrue:[
-			self paint:handleColor.
-			self fillDeviceRectangleX:(x + m + 2)
-						y:(hy - barWidth + 2)
-					    width:w - 4
-					   height:(barWidth + barWidth - 4)
-		    ].
-		]
-	    ] ifFalse:[
-		x := hx.
-		self drawHandleFormAtX:(x + m) y:hy
-	    ].
-	    handleStyle == #st80 ifTrue:[
-		x := hx - 1.
-		self paint:lightColor.
-		self displayLineFromX:x y:margin toX:x y:(height - margin).
-		self displayLineFromX:hx y:0 toX:(hx + barHeight - 1) y:0.
-		x := hx + barHeight - 2.
-		self paint:shadowColor.
-		self displayLineFromX:x y:margin toX:x y:(height - margin).
-		    "uncomment the -1 if you dont like the notch at the bottom end"
-		    "                   VVV"
-		self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeight - 1) y:height-1.
-	    ].
-	] ifFalse:[
-	    x := hx + barHeight - 1.
-	    self paint:handleColor.
-	    separatingLine ifTrue:[
-		self displayLineFromX:hx+1 y:0 toX:hx+1 y:height.
-		self displayLineFromX:x y:0 toX:x y:height.
-	    ].
-	    self fillRectangleX:hx y:hy width:barHeight height:barWidth
-	]
+                handleStyle == #line ifTrue:[
+                    self paint:handleColor.
+                    self displayLineFromX:x y:hy - barWidth toX:x y:hy + barWidth.
+                ] ifFalse:[
+                    x := hx.
+                    handleStyle == #st80 ifTrue:[
+                        x := x - 1.
+                    ].
+                    self drawEdgesForX:(x + m)
+                                     y:(hy - barWidth)
+                                 width:w 
+                                height:(barWidth + barWidth)
+                                 level:handleLevel.
+                    handleStyle == #iris ifTrue:[
+                        self paint:handleColor.
+                        self fillDeviceRectangleX:(x + m + 2)
+                                                y:(hy - barWidth + 2)
+                                            width:w - 4
+                                           height:(barWidth + barWidth - 4)
+                    ].
+                ]
+            ] ifFalse:[
+                x := hx.
+                self drawHandleFormAtX:(x + m) y:hy
+            ].
+            handleStyle == #st80 ifTrue:[
+                x := hx - 1.
+                self paint:lightColor.
+                self displayLineFromX:x y:margin toX:x y:(height - margin).
+                self displayLineFromX:hx y:0 toX:(hx + barHeight - 1) y:0.
+                x := hx + barHeight - 2.
+                self paint:shadowColor.
+                self displayLineFromX:x y:margin toX:x y:(height - margin).
+                    "uncomment the -1 if you dont like the notch at the bottom end"
+                    "                   VVV"
+                self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeight - 1) y:height-1.
+            ].
+        ] ifFalse:[
+            x := hx + barHeight - 1.
+            self paint:handleColor.
+            separatingLine ifTrue:[
+                self displayLineFromX:hx+1 y:0 toX:hx+1 y:height.
+                self displayLineFromX:x y:0 toX:x y:height.
+            ].
+            self fillRectangleX:hx y:hy width:barHeight height:barWidth
+        ]
     ].
 
     "Modified: 24.2.1996 / 19:05:52 / cg"
@@ -810,11 +833,11 @@
     "redraw some handles"
 
     subViews notNil ifTrue:[
-	showHandle ifTrue:[
-	    self handleOriginsFrom:start to:stop do:[:hPoint |
-		self drawHandleAtX:(hPoint x) y:(hPoint y)
-	    ].
-	]
+        showHandle ifTrue:[
+            self handleOriginsWithIndexFrom:start to:stop do:[:hPoint :hIndex |
+                self drawHandle:hIndex atX:(hPoint x) y:(hPoint y)
+            ].
+        ]
     ]
 !
 
@@ -842,6 +865,32 @@
 
 !VariablePanel methodsFor:'initializing'!
 
+computeBarHeight
+    |bH h|
+
+    handleStyle == #next ifTrue:[
+        bH := shadowForm height + 2.
+    ] ifFalse:[
+        self is3D ifTrue:[
+            h := 3
+        ] ifFalse:[
+            h := 2
+        ].
+        bH := (h * device verticalPixelPerMillimeter) rounded.
+    ].
+    knobHeight := bH.
+
+    handleLabels notNil ifTrue:[
+        font := font on:device.
+        bH := handleLabels inject:bH into:[:maxSoFar :thisLabel |
+                                                maxSoFar max:(thisLabel heightOn:self)].
+        bH := bH + font descent - 1
+    ].
+
+    self barHeight:bH.
+
+!
+
 defaultControllerClass
     ^ VariablePanelController
 !
@@ -898,7 +947,7 @@
 !
 
 initStyle
-    |mm h bH|
+    |mm|
 
     super initStyle.
 
@@ -920,21 +969,14 @@
         shadowForm := self class shadowFormOn:device.
         lightForm := self class lightFormOn:device.
 
-        bH := shadowForm height + 2.
         barWidth := shadowForm width.
     ] ifFalse:[
         shadowForm := lightForm := nil.
 
         mm := device verticalPixelPerMillimeter.
-        self is3D ifTrue:[
-            h := 3
-        ] ifFalse:[
-            h := 2
-        ].
-        bH := (h * mm) rounded.
         barWidth := (2 * mm) rounded. "motif style width"
     ].
-    self barHeight:bH.
+    self computeBarHeight.
 
     handleStyle == #mswindows ifTrue:[
         barWidth := (ArrowButton new direction:#up) width + 1 
@@ -965,13 +1007,20 @@
     ^ false
 !
 
-handleOriginsDo:aBlock
+handleLabelAt:hIndex
+    handleLabels notNil ifTrue:[
+        ^ handleLabels at:hIndex ifAbsent:nil
+    ].
+    ^ nil
+!
+
+handleOriginsWithIndexDo:aBlock
     "evaluate the argument block for every handle-origin"
 
-    self handleOriginsFrom:1 to:(subViews size) do:aBlock
+    self handleOriginsWithIndexFrom:1 to:(subViews size) do:aBlock
 !
 
-handleOriginsFrom:start to:stop do:aBlock
+handleOriginsWithIndexFrom:start to:stop do:aBlock
     "evaluate the argument block for some handle-origins"
 
     |x y hw hh hDelta vDelta
@@ -979,45 +1028,45 @@
      last  "{ Class: SmallInteger }"|
 
     subViews notNil ifTrue:[
-	shadowForm notNil ifTrue:[
-	    hw := shadowForm width.
-	    hh := shadowForm height.
-	] ifFalse:[
-	    hw := hh := barWidth
-	].
+        shadowForm notNil ifTrue:[
+            hw := shadowForm width.
+            hh := shadowForm height.
+        ] ifFalse:[
+            hw := hh := barWidth
+        ].
 
-	(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
-	    hDelta := barWidth // 2.
-	    vDelta := barWidth // 2.
-	] ifFalse:[
-	    hDelta := vDelta := 0
-	].
+        (handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
+            hDelta := barWidth // 2.
+            vDelta := barWidth // 2.
+        ] ifFalse:[
+            hDelta := vDelta := 0
+        ].
 
-	(handlePosition == #left) ifTrue:[
-	    x := hDelta. 
-	    y := vDelta
-	] ifFalse:[
-	    (handlePosition == #right) ifTrue:[
-		x := width - hw - margin - hDelta.
-		y := height - hh - margin - vDelta.
-	    ] ifFalse:[
-		x := width - barWidth // 2.
-		y := height - barWidth // 2
-	    ]
-	].
-	first := start + 1.
-	last := stop.
-	first to:last do:[:index |
-	    |view|
+        (handlePosition == #left) ifTrue:[
+            x := hDelta. 
+            y := vDelta
+        ] ifFalse:[
+            (handlePosition == #right) ifTrue:[
+                x := width - hw - margin - hDelta.
+                y := height - hh - margin - vDelta.
+            ] ifFalse:[
+                x := width - barWidth // 2.
+                y := height - barWidth // 2
+            ]
+        ].
+        first := start + 1.
+        last := stop.
+        first to:last do:[:index |
+            |view|
 
-	    view := subViews at:index.
-	    orientation == #vertical ifTrue:[
-		y := view top "origin y" - barHeight + 1.
-	    ] ifFalse:[
-		x := view left "origin x" - barHeight + 1.
-	    ].
-	    aBlock value:(x @ y)
-	]
+            view := subViews at:index.
+            orientation == #vertical ifTrue:[
+                y := view top "origin y" - barHeight + 1.
+            ] ifFalse:[
+                x := view left "origin x" - barHeight + 1.
+            ].
+            aBlock value:(x @ y) value:index
+        ]
     ]
 !
 
@@ -1033,71 +1082,72 @@
     |step nSubviews|
 
     subViews notNil ifTrue:[
-	(start <= stop) ifTrue:[
-	    step := 1
-	] ifFalse:[
-	    step := -1
-	].
-	nSubviews := subViews size.
-	start to:stop by:step do:[:index |
-	    |bw view o1 o2 relOrg relCorner newOrg newCorner newExt|
+        (start <= stop) ifTrue:[
+            step := 1
+        ] ifFalse:[
+            step := -1
+        ].
+        nSubviews := subViews size.
+        start to:stop by:step do:[:index |
+            |bw view o1 o2 relOrg relCorner newOrg newCorner newExt|
 
-	    view := subViews at:index.
-	    bw := view borderWidth.
+            view := subViews at:index.
+            bw := view borderWidth.
 
-	    index == 1 ifTrue:[
-		o1 := 0.
-	    ] ifFalse:[
-		o1 := barHeight // 2 - bw
-	    ].
-	    index ==  nSubviews ifTrue:[
-		o2 := 0.
-	    ] ifFalse:[
-		o2 := barHeight // 2 - bw
-	    ].
+            index == 1 ifTrue:[
+                o1 := 0.
+            ] ifFalse:[
+                o1 := barHeight // 2 - bw
+            ].
+            index ==  nSubviews ifTrue:[
+                o2 := 0.
+            ] ifFalse:[
+                o2 := barHeight // 2 - bw
+            ].
 
 "
-	    relCorner := view relativeCorner.
-	    relCorner isNil ifTrue:[
-		self error:'subview must have relative corner'
-	    ].
-	    newCorner := view cornerFromRelativeCorner.
-	    newCorner notNil ifTrue:[
-		newCorner y:(newCorner y - o2)
-	    ].
+            relCorner := view relativeCorner.
+            relCorner isNil ifTrue:[
+                self error:'subview must have relative corner'
+            ].
+            newCorner := view cornerFromRelativeCorner.
+            newCorner notNil ifTrue:[
+                newCorner y:(newCorner y - o2)
+            ].
 
-	    relOrg := view relativeOrigin.
-	    relOrg isNil ifTrue:[
-		self error:'subview must have relative origin'
-	    ].
-	    newOrg := view originFromRelativeOrigin.
-	    newOrg notNil ifTrue:[
-		(index ~~ 1) ifTrue:[  
-		    newOrg y:(newOrg y + o1)
-		].
-	    ].
-	    view pixelOrigin:newOrg corner:newCorner
+            relOrg := view relativeOrigin.
+            relOrg isNil ifTrue:[
+                self error:'subview must have relative origin'
+            ].
+            newOrg := view originFromRelativeOrigin.
+            newOrg notNil ifTrue:[
+                (index ~~ 1) ifTrue:[  
+                    newOrg y:(newOrg y + o1)
+                ].
+            ].
+            view pixelOrigin:newOrg corner:newCorner
 "
-	    newOrg := view computeOrigin.
-	    newOrg notNil ifTrue:[
-		(index ~~ 1) ifTrue:[
-		    orientation == #vertical ifTrue:[
-			newOrg y:(newOrg y + o1)
-		    ] ifFalse:[
-			newOrg x:(newOrg x + o1)
-		    ]
-		].
-	    ].
-	    newExt := view computeExtent.
-	    newExt notNil ifTrue:[
-		orientation == #vertical ifTrue:[
-		    newExt y:(newExt y - o2 - o1)
-		] ifFalse:[
-		    newExt x:(newExt x - o2 - o1)
-		]
-	    ].
-	    view pixelOrigin:newOrg extent:newExt.
-	]
+            newOrg := view computeOrigin.
+            newOrg notNil ifTrue:[
+                (index ~~ 1) ifTrue:[
+                    orientation == #vertical ifTrue:[
+                        newOrg y:(newOrg y + o1)
+                    ] ifFalse:[
+                        newOrg x:(newOrg x + o1)
+                    ]
+                ].
+            ].
+            newExt := view computeExtent.
+            newExt notNil ifTrue:[
+                orientation == #vertical ifTrue:[
+                    newExt y:(newExt y - o2 - o1)
+                ] ifFalse:[
+                    newExt x:(newExt x - o2 - o1)
+                ]
+            ].
+Transcript show:newOrg; space; showCR:newExt.
+            view pixelOrigin:newOrg extent:newExt.
+        ]
     ]
 !
 
@@ -1180,8 +1230,8 @@
     "Modified: 21.8.1996 / 10:01:29 / stefan"
 ! !
 
-!VariablePanel  class methodsFor:'documentation'!
+!VariablePanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.13 1996-08-21 10:27:50 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.14 1996-11-07 14:04:42 ca Exp $'
 ! !