--- a/ScrollBar.st Mon Jul 06 17:51:29 1998 +0200
+++ b/ScrollBar.st Wed Jul 15 13:50:54 1998 +0200
@@ -370,27 +370,27 @@
downHeight "{ Class: SmallInteger }"
thumbHeight "{ Class: SmallInteger }"
upAndDownHeight "{ Class: SmallInteger }"
- bw "{ Class: SmallInteger }"
- bwn "{ Class: SmallInteger }"
+ bw "{ Class: SmallInteger }"
+ bwn "{ Class: SmallInteger }"
sep2 "{ Class: SmallInteger }"
sep3 "{ Class: SmallInteger }"
+ m2 "{ Class: SmallInteger }"
thumbWidth w h style b1Hidden b2Hidden thumbHidden
b1WasHidden b2WasHidden thumbWasHidden bX bY
leftWidth rightWidth leftAndRightWidth isHorizontal
- tX tY tW tH|
+ tX tY tW tH tExt bOrg|
- button1 isNil ifTrue:[^ self].
- thumb isNil ifTrue:[^ self].
- button2 isNil ifTrue:[^ self].
+ (button1 isNil or:[thumb isNil or:[button2 isNil]]) ifTrue:[^ self].
bw := borderWidth.
bwn := bw negated + margin.
+ m2 := margin * 2.
b1WasHidden := button1 realized not.
b2WasHidden := button2 realized not.
thumbWasHidden := thumb realized not.
- (isHorizontal := self orientation == #horizontal) ifTrue:[
+ (isHorizontal := (self orientation == #horizontal)) ifTrue:[
leftWidth := button1 width + bw.
rightWidth := button2 width + bw.
leftAndRightWidth := leftWidth + rightWidth.
@@ -407,7 +407,7 @@
"if I become too small, hide buttons"
- width < (leftAndRightWidth + margin*2) ifTrue:[
+ width < (leftAndRightWidth + m2) ifTrue:[
b1Hidden := b2Hidden := thumbHidden := true.
] ifFalse:[
b1Hidden := b2Hidden := thumbHidden := false.
@@ -435,7 +435,7 @@
"if I become too small, hide buttons and thumb"
- height < (upAndDownHeight + (margin*2)) ifTrue:[
+ height < (upAndDownHeight + (m2)) ifTrue:[
b1Hidden := b2Hidden := thumbHidden := true.
] ifFalse:[
b1Hidden := b2Hidden := thumbHidden := false.
@@ -482,7 +482,7 @@
isHorizontal ifTrue:[
"height of buttons is always my width"
- h := height - (margin * 2).
+ h := height - m2.
(h ~~ button1 height) ifTrue:[
button1 height:h.
@@ -522,14 +522,16 @@
] ifFalse:[
bX := thumbWidth + sep2.
].
+ tExt := (thumbWidth @ thumbHeight).
(how == #smaller) ifTrue:[
- thumb extent:(thumbWidth @ thumbHeight).
- button1 origin:(bX @ bwn).
- button2 origin:((bX + leftWidth) @ bwn)
- ] ifFalse:[
- button1 origin:(bX @ bwn).
- button2 origin:((bX + leftWidth) @ bwn).
- thumb extent:(thumbWidth @ thumbHeight)
+ "/ resize thumb first
+ thumb extent:tExt.
+ ].
+ button1 origin:(bX @ bwn).
+ button2 origin:((bX + leftWidth) @ bwn).
+ (how == #smaller) ifFalse:[
+ "/ resize thumb last
+ thumb extent:tExt
].
^ self
].
@@ -542,32 +544,35 @@
].
button1 origin:(bwn @ bwn).
+ bX := leftWidth + thumbWidth + sep2.
+ tX := leftWidth - bw + elementSpacing.
style == #os2 ifTrue:[
- bX := leftWidth + thumbWidth + sep2 - margin.
- tW := thumbWidth - margin - margin.
- tX := leftWidth - bw + elementSpacing + margin.
+ bX := bX - margin.
+ tW := thumbWidth - m2.
+ tX := tX + margin.
] ifFalse:[
- bX := leftWidth + thumbWidth + sep2 - (margin // 2).
+ bX := bX - (margin // 2).
tW := thumbWidth + margin - sep3 - (margin // 2).
- tX := leftWidth - bw + sep3 + elementSpacing.
+ tX := tX + sep3.
].
"/ if made smaller, shrink thumb first, then move lower button.
"/ otherwise, move lower button first, then make thumb larger.
"/ this avoids a need to redraw the button2.
+ bOrg := (bX @ bwn).
how ~~ #smaller ifTrue:[
- button2 origin:(bX @ bwn).
+ button2 origin:bOrg.
].
thumb extent:(tW @ thumbHeight).
thumb origin:(tX @ bwn).
how == #smaller ifTrue:[
- button2 origin:(bX @ bwn).
+ button2 origin:bOrg.
].
] ifFalse:[
"width of buttons is always my width"
- w := width - (margin * 2).
+ w := width - m2.
(w ~~ button1 width) ifTrue:[
button1 width:w.
button2 width:w
@@ -602,22 +607,25 @@
thumbHeight := thumbHeight + bw.
- bY := thumbHeight + sep2.
- (bY + upAndDownHeight) >= height ifTrue:[
- bY := height - margin - upAndDownHeight
- ].
+ bY := thumbHeight + sep2.
+ (bY + upAndDownHeight) >= height ifTrue:[
+ bY := height - margin - upAndDownHeight
+ ].
- button1 viewGravity:#North.
- button2 viewGravity:#North.
+ button1 viewGravity:#North.
+ button2 viewGravity:#North.
+
+ tExt := (thumbWidth @ thumbHeight).
+
(how == #smaller) ifTrue:[
- thumb extent:(thumbWidth @ thumbHeight).
-
- button1 origin:(bwn @ bY).
- button2 origin:(bwn @ (bY + upHeight))
- ] ifFalse:[
- button1 origin:(bwn @ bY).
- button2 origin:(bwn @ (bY + upHeight)).
- thumb extent:(thumbWidth @ thumbHeight)
+ "/ resize thumb first
+ thumb extent:tExt.
+ ].
+ button1 origin:(bwn @ bY).
+ button2 origin:(bwn @ (bY + upHeight)).
+ (how == #smaller) ifFalse:[
+ "/ resize thumb last
+ thumb extent:tExt
].
^ self
].
@@ -630,32 +638,35 @@
].
button1 origin:(bwn @ bwn).
+ bY := upHeight + thumbHeight + sep2.
+ tY := upHeight - bw + elementSpacing.
style == #os2 ifTrue:[
- bY := upHeight + thumbHeight + sep2 - margin "+ bw".
- tH := thumbHeight - margin - margin "+ margin - (margin // 2)".
- tY := upHeight - bw + elementSpacing + margin.
+ bY := bY - margin "+ bw".
+ tH := thumbHeight - m2 "+ margin - (margin // 2)".
+ tY := tY + margin.
] ifFalse:[
- bY := upHeight + thumbHeight + sep2 - (margin // 2) "+ bw".
+ bY := bY - (margin // 2) "+ bw".
tH := thumbHeight + margin - sep3 - (margin // 2).
- tY := upHeight - bw + sep3 + elementSpacing.
+ tY := tY + sep3.
].
"/ if made smaller, shrink thumb first, then move lower button.
"/ otherwise, move lower button first, then make thumb larger.
"/ this avoids a need to redraw the button2.
+ bOrg := (bwn @ bY).
how ~~ #smaller ifTrue:[
- button2 origin:(bwn @ bY).
+ button2 origin:bOrg.
].
thumb extent:(thumbWidth @ tH).
thumb origin:(bwn @ tY).
how == #smaller ifTrue:[
- button2 origin:(bwn @ bY).
+ button2 origin:bOrg.
].
].
"Modified: / 3.5.1996 / 23:49:02 / stefan"
- "Modified: / 21.5.1998 / 01:28:03 / cg"
+ "Modified: / 15.7.1998 / 13:49:36 / cg"
! !
!ScrollBar methodsFor:'forced scroll'!
@@ -1021,5 +1032,5 @@
!ScrollBar class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.54 1998-05-20 23:29:03 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.55 1998-07-15 11:50:54 cg Exp $'
! !