VariableVerticalPanel.st
changeset 63 f4eaf04d1eaf
parent 60 f3c738c24ce6
child 70 14443a9ea4ec
--- a/VariableVerticalPanel.st	Thu Nov 17 15:34:12 1994 +0100
+++ b/VariableVerticalPanel.st	Thu Nov 17 15:38:53 1994 +0100
@@ -27,7 +27,7 @@
 COPYRIGHT (c) 1991 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.9 1994-10-28 03:25:35 claus Exp $
+$Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.10 1994-11-17 14:38:49 claus Exp $
 '!
 
 !VariableVerticalPanel class methodsFor:'documentation'!
@@ -48,7 +48,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.9 1994-10-28 03:25:35 claus Exp $
+$Header: /cvs/stx/stx/libwidg/VariableVerticalPanel.st,v 1.10 1994-11-17 14:38:49 claus Exp $
 "
 !
 
@@ -75,6 +75,11 @@
 			      corner:1.0 @ 1.0
 				  in:p.
 
+"
+!
+
+examples
+"
    example:
 	|top p v1 v2 v3|
 
@@ -178,6 +183,9 @@
 	self barHeight:(2 * mm) rounded
     ].
     barWidth := (2 * mm) rounded. "motif style width"
+    handleStyle == #mswindows ifTrue:[
+	barWidth := (ArrowButton new direction:#up) width + 1 
+    ].
 !
 
 initCursor
@@ -343,7 +351,7 @@
 			height:h 
 			 level:2.
 	    handleStyle == #iris ifTrue:[
-		self paint:Black.
+		self paint:handleColor.
 		self fillDeviceRectangleX:(hx - barWidth + 2)
 					y:(y + m + 2)
 				    width:(barWidth + barWidth - 4)
@@ -372,7 +380,7 @@
 	    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:barHeight height:barHeight
+	self fillRectangleX:hx y:hy width:barWidth height:barHeight
     ]
 !
 
@@ -472,8 +480,20 @@
     self buttonMotionEventPending ifTrue:[^ self].
 
     ypos := by - start.
-    limitTop := barHeight // 2.
-    limitBot := self height - barHeight.
+
+    "
+     the two lines below will not allow resizing down to zero
+     (so that some is always visible)
+    "
+"/    limitTop := barHeight // 2.
+"/    limitBot := self height - barHeight.
+
+    "
+     these allow resizing to zero - which is better ?
+    "
+    limitTop := 0.
+    limitBot := self innerHeight.
+
     movedHandle > 1 ifTrue:[
 	limitTop := (subViews at:movedHandle) origin y + (barHeight // 2)
     ].
@@ -508,7 +528,7 @@
 buttonRelease:button x:x y:y
     "end bar-move"
 
-    |aboveView belowView aboveIndex belowIndex newY|
+    |aboveView belowView aboveIndex belowIndex newY oldY|
 
     ((button == 1) or:[button == #select]) ifTrue:[
 	movedHandle isNil ifTrue:[^ self].
@@ -533,12 +553,17 @@
 	aboveView := subViews at:aboveIndex.
 	belowView := subViews at:belowIndex.
 
+	oldY := aboveView relativeCorner y.
 	newY := (prev + start / height) asFloat.
 	aboveView relativeCorner:aboveView relativeCorner x @ newY.
 	belowView relativeOrigin:belowView relativeOrigin x @ newY.
-	self resizeSubviewsFrom:aboveIndex to:belowIndex.
+	movedHandle := nil.
 
-	movedHandle := nil.
+	oldY > newY ifTrue:[
+	    self resizeSubviewsFrom:aboveIndex to:belowIndex.
+	] ifFalse:[
+	    self resizeSubviewsFrom:belowIndex to:aboveIndex.
+	].
 
 	redrawLocked := true.
 	self redrawHandlesFrom:aboveIndex to:belowIndex.
@@ -646,21 +671,26 @@
 handleOriginsFrom:start to:stop do:aBlock
     "evaluate the argument block for some handle-origins"
 
-    |x hw|
+    |x hw hDelta|
 
     subViews notNil ifTrue:[
 	shadowForm notNil ifTrue:[
 	    hw := shadowForm width
 	] ifFalse:[
-	    hw := barHeight
+	    hw := barWidth
+	].
+	(handleStyle ~~ #normal and:[handleStyle ~~ #mswindows]) ifTrue:[
+	    hDelta := barWidth // 2.
+	] ifFalse:[
+	    hDelta := 0
 	].
 	(handlePosition == #left) ifTrue:[
-	    x := hw * 2
+	    x := hDelta
 	] ifFalse:[
 	    (handlePosition == #right) ifTrue:[
-		x := width - (1 "2" * hw) - margin
+		x := width - (1 "2" * hw) - margin - hDelta.
 	    ] ifFalse:[
-		x := width // 2
+		x := width - barWidth // 2
 	    ]
 	].
 	(start + 1) to:stop do:[:index |