VariablePanel.st
changeset 1981 15a646f9e4fb
parent 1948 e92d1005d6a3
child 1987 599825bed176
--- a/VariablePanel.st	Wed Aug 04 16:10:07 1999 +0200
+++ b/VariablePanel.st	Wed Aug 04 16:15:06 1999 +0200
@@ -771,6 +771,10 @@
 !
 
 handleLabels:aCollectionOfLabels
+    "define special handle labels - typically a collection of
+     bitmap images. Notice, that the first handle is not
+     drawn, that is, the first element if the argument is useless."
+
     orientation == #horizontal ifTrue:[
         self error:'not allowed for horizontal panels'
     ].
@@ -779,6 +783,17 @@
     self computeBarHeight.
     self resizeSubviews.
 
+    "
+     |top panel v1 v2|
+
+     top := StandardSystemView new.
+     panel := VariableVerticalPanel origin:0.0@0.0 corner:1.0@1.0 in:top.
+     panel add:(EditTextView origin:0.0@0.0 corner:1.0@0.5).
+     panel add:(EditTextView origin:0.0@0.5 corner:1.0@1.0).
+     panel handleStyle:nil.
+     panel handleLabels:#('foo' 'bar').
+     top open
+    "
 !
 
 handleLevel:aNumber
@@ -874,8 +889,8 @@
      barWidthInt   "{ Class: SmallInteger }"
      barHeightInt  "{ Class: SmallInteger }" |
 
-    (handleStyle isNil 
-    or:[handleStyle == #none]) ifTrue:[^ self].
+    ((handleStyle isNil or:[handleStyle == #none])
+    and:[handleLabels isNil]) ifTrue:[^ self].
 
     mar := margin.
     barHeightInt := barHeight.
@@ -903,99 +918,101 @@
                       width:(width - mar - mar) 
                      height:barHeightInt.
 
-        (handleStyle ~~ #normal 
-        and:[handleStyle ~~ #mswindows]) ifTrue:[
-            m := (maxKnob - h) // 2.
+        (handleStyle isNil
+        or:[handleStyle == #none]) ifFalse:[
+            (handleStyle ~~ #normal 
+            and:[handleStyle ~~ #mswindows]) ifTrue:[
+                m := (maxKnob - h) // 2.
+
+                shadowForm isNil ifTrue:[
+
+                    y := hy + (barHeightInt // 2).   "/ center of the bar
 
-            shadowForm isNil ifTrue:[
+                    separatingLine ifTrue:[
+                        self paint:shadowColor.
+                        self displayLineFromX:mar y:y toX:(width - mar) y:y.
+                        y := y + 1.
+                        self paint:lightColor.
+                        self displayLineFromX:mar y:y toX:(width - mar) y:y.
+                        self paint:viewBackground.
+                    ].
 
-                y := hy + (barHeightInt // 2).   "/ center of the bar
+                    self fillRectangleX:(hx - barWidthInt) 
+                                      y:hy 
+                                  width:(barWidthInt + barWidthInt) 
+                                 height:h.
+
+                    handleStyle == #line ifTrue:[
+                        self paint:handleColor.
+                        self displayLineFromX:hx - barWidthInt y:y toX:hx + barWidthInt y:y
+                    ] ifFalse:[
+                        y := hy.   
+                        handleStyle == #st80 ifTrue:[
+                            y := y - 1
+                        ].
+                        ym := y + m.
 
-                separatingLine ifTrue:[
-                    self paint:shadowColor.
-                    self displayLineFromX:mar y:y toX:(width - mar) y:y.
-                    y := y + 1.
-                    self paint:lightColor.
-                    self displayLineFromX:mar y:y toX:(width - mar) y:y.
-                    self paint:viewBackground.
+                        handleStyle == #full ifTrue:[
+                            handleLevel ~~ 0 ifTrue:[
+                                self 
+                                    drawEdgesForX:0 "/ -(handleLevel abs)
+                                    y:ym "/-1
+                                    width:width "/+(handleLevel+handleLevel)abs
+                                    height:h-2 
+                                    level:handleLevel
+                                    shadow:shadowColor 
+                                    light:lightColor
+                                    halfShadow:nil 
+                                    halfLight:nil 
+                                    style:nil 
+                            ]
+                        ] ifFalse:[
+                            handleLevel ~~ 0 ifTrue:[
+                                self drawEdgesForX:(hx - barWidthInt)
+                                                 y:ym
+                                             width:(barWidthInt + barWidthInt)
+                                            height:h 
+                                             level:handleLevel.
+                            ].
+
+                            handleStyle == #iris ifTrue:[
+                                self paint:handleColor.
+                                self fillDeviceRectangleX:(hx - barWidthInt + 2)
+                                                        y:(ym + 2)
+                                                    width:(barWidthInt + barWidthInt - 4)
+                                                   height:h - 4
+                            ]
+                        ]
+                    ].
+                ] ifFalse:[
+                    y := hy.
+                    (shadowForm notNil or:[lightForm notNil]) ifTrue:[
+                        self drawHandleFormAtX:hx y:(y + m)
+                    ]
                 ].
 
-                self fillRectangleX:(hx - barWidthInt) 
-                                  y:hy 
-                              width:(barWidthInt + barWidthInt) 
-                             height:h.
-
-                handleStyle == #line ifTrue:[
-                    self paint:handleColor.
-                    self displayLineFromX:hx - barWidthInt y:y toX:hx + barWidthInt y:y
-                ] ifFalse:[
-                    y := hy.   
-                    handleStyle == #st80 ifTrue:[
-                        y := y - 1
-                    ].
-                    ym := y + m.
-
-                    handleStyle == #full ifTrue:[
-                        handleLevel ~~ 0 ifTrue:[
-                            self 
-                                drawEdgesForX:0 "/ -(handleLevel abs)
-                                y:ym "/-1
-                                width:width "/+(handleLevel+handleLevel)abs
-                                height:h-2 
-                                level:handleLevel
-                                shadow:shadowColor 
-                                light:lightColor
-                                halfShadow:nil 
-                                halfLight:nil 
-                                style:nil 
-                        ]
-                    ] ifFalse:[
-                        handleLevel ~~ 0 ifTrue:[
-                            self drawEdgesForX:(hx - barWidthInt)
-                                             y:ym
-                                         width:(barWidthInt + barWidthInt)
-                                        height:h 
-                                         level:handleLevel.
-                        ].
-
-                        handleStyle == #iris ifTrue:[
-                            self paint:handleColor.
-                            self fillDeviceRectangleX:(hx - barWidthInt + 2)
-                                                    y:(ym + 2)
-                                                width:(barWidthInt + barWidthInt - 4)
-                                               height:h - 4
-                        ]
-                    ]
+                handleStyle == #st80 ifTrue:[
+                    y := hy - 1.
+                    self paint:lightColor.
+                    self displayLineFromX:mar y:y toX:(width - mar - mar - 1) y:y.
+                    self displayLineFromX:0 y:hy toX:0 y:(hy + knobHeight - 1).
+                    y := hy + knobHeight - 2.
+                    self paint:shadowColor.
+                    self displayLineFromX:mar y:y toX:(width - mar) 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 - 1).
                 ].
             ] ifFalse:[
-                y := hy.
-                (shadowForm notNil or:[lightForm notNil]) ifTrue:[
-                    self drawHandleFormAtX:hx y:(y + m)
-                ]
+                y := hy + barHeightInt - 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:barWidthInt height:barHeightInt
             ].
-
-            handleStyle == #st80 ifTrue:[
-                y := hy - 1.
-                self paint:lightColor.
-                self displayLineFromX:mar y:y toX:(width - mar - mar - 1) y:y.
-                self displayLineFromX:0 y:hy toX:0 y:(hy + knobHeight - 1).
-                y := hy + knobHeight - 2.
-                self paint:shadowColor.
-                self displayLineFromX:mar y:y toX:(width - mar) 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 - 1).
-            ].
-        ] ifFalse:[
-            y := hy + barHeightInt - 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:barWidthInt height:barHeightInt
         ].
-
         lbl := self handleLabelAt:hIndex.
         lbl notNil ifTrue:[
             hIndex ~~ 1 ifTrue:[
@@ -1013,90 +1030,93 @@
                       width:barHeightInt
                      height:(height - mar - mar).
 
-        (handleStyle ~~ #normal
-        and:[handleStyle ~~ #mswindows]) ifTrue:[
-             m := (barHeightInt - w) // 2.
-            m := (maxKnob - w) // 2.
-             shadowForm isNil ifTrue:[
-                x := hx + (barHeightInt // 2).
-                separatingLine ifTrue:[
-                    self paint:shadowColor.
-                    self displayLineFromX:x y:mar toX:x y:(height - mar).
-                    x := x + 1.
-                    self paint:lightColor.
-                    self displayLineFromX:x y:mar toX:x y:(height - mar).
-                    self paint:viewBackground.
-                ].
-                self fillRectangleX:hx y:(hy - barWidthInt) 
-                              width:w 
-                             height:(barWidthInt + barWidthInt).
+        (handleStyle isNil
+        or:[handleStyle == #none]) ifFalse:[
+            (handleStyle ~~ #normal
+            and:[handleStyle ~~ #mswindows]) ifTrue:[
+                 m := (barHeightInt - w) // 2.
+                m := (maxKnob - w) // 2.
+                 shadowForm isNil ifTrue:[
+                    x := hx + (barHeightInt // 2).
+                    separatingLine ifTrue:[
+                        self paint:shadowColor.
+                        self displayLineFromX:x y:mar toX:x y:(height - mar).
+                        x := x + 1.
+                        self paint:lightColor.
+                        self displayLineFromX:x y:mar toX:x y:(height - mar).
+                        self paint:viewBackground.
+                    ].
+                    self fillRectangleX:hx y:(hy - barWidthInt) 
+                                  width:w 
+                                 height:(barWidthInt + barWidthInt).
 
-                handleStyle == #line ifTrue:[
-                    self paint:handleColor.
-                    self displayLineFromX:x y:hy - barWidthInt toX:x y:hy + barWidthInt.
+                    handleStyle == #line ifTrue:[
+                        self paint:handleColor.
+                        self displayLineFromX:x y:hy - barWidthInt toX:x y:hy + barWidthInt.
+                    ] ifFalse:[
+                        x := hx.
+                        handleStyle == #st80 ifTrue:[
+                            x := x - 1.
+                        ].
+                        xm := x + m.
+                        handleStyle == #full ifTrue:[
+                            handleLevel ~~ 0 ifTrue:[
+                                self 
+                                    drawEdgesForX:xm "/-1
+                                    y:0 "/ -handleLevel
+                                    width:w-2
+                                    height:height "/ +handleLevel+handleLevel 
+                                    level:handleLevel
+                                    shadow:shadowColor 
+                                    light:lightColor
+                                    halfShadow:nil 
+                                    halfLight:nil 
+                                    style:nil
+                            ]
+                        ] ifFalse:[
+                            handleLevel ~~ 0 ifTrue:[
+                                self drawEdgesForX:xm
+                                                 y:(hy - barWidthInt)
+                                             width:w 
+                                            height:(barWidthInt + barWidthInt)
+                                             level:handleLevel.
+                            ].
+                            handleStyle == #iris ifTrue:[
+                                self paint:handleColor.
+                                self fillDeviceRectangleX:(xm + 2)
+                                                        y:(hy - barWidthInt + 2)
+                                                    width:w - 4
+                                                   height:(barWidthInt + barWidthInt - 4)
+                            ].
+                        ].
+                    ]
                 ] ifFalse:[
                     x := hx.
-                    handleStyle == #st80 ifTrue:[
-                        x := x - 1.
-                    ].
-                    xm := x + m.
-                    handleStyle == #full ifTrue:[
-                        handleLevel ~~ 0 ifTrue:[
-                            self 
-                                drawEdgesForX:xm "/-1
-                                y:0 "/ -handleLevel
-                                width:w-2
-                                height:height "/ +handleLevel+handleLevel 
-                                level:handleLevel
-                                shadow:shadowColor 
-                                light:lightColor
-                                halfShadow:nil 
-                                halfLight:nil 
-                                style:nil
-                        ]
-                    ] ifFalse:[
-                        handleLevel ~~ 0 ifTrue:[
-                            self drawEdgesForX:xm
-                                             y:(hy - barWidthInt)
-                                         width:w 
-                                        height:(barWidthInt + barWidthInt)
-                                         level:handleLevel.
-                        ].
-                        handleStyle == #iris ifTrue:[
-                            self paint:handleColor.
-                            self fillDeviceRectangleX:(xm + 2)
-                                                    y:(hy - barWidthInt + 2)
-                                                width:w - 4
-                                               height:(barWidthInt + barWidthInt - 4)
-                        ].
-                    ].
-                ]
+                    (shadowForm notNil or:[lightForm notNil]) ifTrue:[
+                        self drawHandleFormAtX:(x + m) y:hy
+                    ]
+                ].
+                handleStyle == #st80 ifTrue:[
+                    x := hx - 1.
+                    self paint:lightColor.
+                    self displayLineFromX:x y:mar toX:x y:(height - mar).
+                    self displayLineFromX:hx y:0 toX:(hx + barHeightInt - 1) y:0.
+                    x := hx + barHeightInt - 2.
+                    self paint:shadowColor.
+                    self displayLineFromX:x y:mar toX:x y:(height - mar).
+                        "uncomment the -1 if you dont like the notch at the bottom end"
+                        "                   VVV"
+                    self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeightInt - 1) y:height-1.
+                ].
             ] ifFalse:[
-                x := hx.
-                (shadowForm notNil or:[lightForm notNil]) ifTrue:[
-                    self drawHandleFormAtX:(x + m) y:hy
-                ]
-            ].
-            handleStyle == #st80 ifTrue:[
-                x := hx - 1.
-                self paint:lightColor.
-                self displayLineFromX:x y:mar toX:x y:(height - mar).
-                self displayLineFromX:hx y:0 toX:(hx + barHeightInt - 1) y:0.
-                x := hx + barHeightInt - 2.
-                self paint:shadowColor.
-                self displayLineFromX:x y:mar toX:x y:(height - mar).
-                    "uncomment the -1 if you dont like the notch at the bottom end"
-                    "                   VVV"
-                self displayLineFromX:hx" "-1" " y:height-1 toX:(hx + barHeightInt - 1) y:height-1.
-            ].
-        ] ifFalse:[
-            x := hx + barHeightInt - 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:barHeightInt height:barWidthInt
+                x := hx + barHeightInt - 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:barHeightInt height:barWidthInt
+            ]
         ]
     ].
 
@@ -1682,5 +1702,5 @@
 !VariablePanel class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.48 1999-07-06 10:09:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/VariablePanel.st,v 1.49 1999-08-04 14:15:06 cg Exp $'
 ! !