minSize computation
authorClaus Gittinger <cg@exept.de>
Mon, 03 Nov 1997 16:17:59 +0100
changeset 1383 b6541bec0b4f
parent 1382 ab46d50d06df
child 1384 e4acb2c5b10b
minSize computation
ScrollBar.st
--- a/ScrollBar.st	Sun Nov 02 20:15:09 1997 +0100
+++ b/ScrollBar.st	Mon Nov 03 16:17:59 1997 +0100
@@ -10,8 +10,6 @@
  hereby transferred.
 "
 
-'From Smalltalk/X, Version:3.2.1 on 14-oct-1997 at 11:23:40 pm'                 !
-
 SimpleView subclass:#ScrollBar
 	instanceVariableNames:'thumb button1 button2 buttonLayout elementSpacing'
 	classVariableNames:'DefaultButtonPositions DefaultLevel DefaultElementSpacing
@@ -364,7 +362,13 @@
     "when my size changes, I have to resize/reposition the subviews.
      Also, if I became too small, hide thumb/buttons."
 
-    |upHeight downHeight thumbHeight upAndDownHeight bwn sep2
+    |upHeight "{ Class: SmallInteger }"
+     downHeight "{ Class: SmallInteger }"
+     thumbHeight "{ Class: SmallInteger }"
+     upAndDownHeight "{ Class: SmallInteger }"
+     bw  "{ Class: SmallInteger }" 
+     bwn "{ Class: SmallInteger }"
+     sep2 "{ Class: SmallInteger }"
      thumbWidth w h style b1Hidden b2Hidden thumbHidden 
      b1WasHidden b2WasHidden thumbWasHidden bX bY
      leftWidth rightWidth leftAndRightWidth isHorizontal|
@@ -374,30 +378,31 @@
     button2 isNil ifTrue:[^ self].
 
     style := styleSheet name.
-    bwn := borderWidth negated + margin.
+    bw := borderWidth.
+    bwn := bw negated + margin.
 
     b1WasHidden := button1 realized not.
     b2WasHidden := button2 realized not.
     thumbWasHidden := thumb realized not.
 
     (isHorizontal := self orientation == #horizontal) ifTrue:[
-        leftWidth := button1 width + borderWidth.
-        rightWidth := button2 width + borderWidth.
+        leftWidth := button1 width + bw.
+        rightWidth := button2 width + bw.
         leftAndRightWidth := leftWidth + rightWidth.
 
-        thumbWidth := width - leftAndRightWidth - borderWidth - (elementSpacing * 3).
+        thumbWidth := width - leftAndRightWidth - bw - (elementSpacing * 3).
     "
         ((buttonLayout ~~ #top) and:[buttonLayout ~~ #bottom]) ifTrue:[
-            thumbWidth := thumbWidth - borderWidth
+            thumbWidth := thumbWidth - bw
         ].
     "
         buttonLayout == #around ifTrue:[
-            thumbWidth := thumbWidth + borderWidth
+            thumbWidth := thumbWidth + bw
         ].
 
         "if I become too small, hide buttons"
 
-        width < leftAndRightWidth ifTrue:[
+        width < (leftAndRightWidth + margin*2) ifTrue:[
             b1Hidden := b2Hidden := thumbHidden := true.
         ] ifFalse:[
             b1Hidden := b2Hidden := thumbHidden := false.
@@ -409,23 +414,23 @@
             thumbHidden := false.
         ].
     ] ifFalse:[
-        upHeight := button1 height + borderWidth.
-        downHeight := button2 height + borderWidth.
+        upHeight := button1 height + bw.
+        downHeight := button2 height + bw.
         upAndDownHeight := upHeight + downHeight.
 
-        thumbHeight := height - upAndDownHeight - borderWidth - (elementSpacing * 3).
+        thumbHeight := height - upAndDownHeight - bw - (elementSpacing * 3).
 "
         ((buttonLayout ~~ #top) and:[buttonLayout ~~ #bottom]) ifTrue:[
-            thumbHeight := thumbHeight - borderWidth
+            thumbHeight := thumbHeight - bw
         ].
 "
         buttonLayout == #around ifTrue:[
-            thumbHeight := thumbHeight + borderWidth
+            thumbHeight := thumbHeight + bw
         ].
 
         "if I become too small, hide buttons and thumb"
 
-        height < upAndDownHeight ifTrue:[
+        height < (upAndDownHeight + (margin*2)) ifTrue:[
             b1Hidden := b2Hidden := thumbHidden := true.
         ] ifFalse:[
             b1Hidden := b2Hidden := thumbHidden := false.
@@ -502,7 +507,7 @@
         sep2 := elementSpacing * 2.
         (buttonLayout == #top) ifTrue:[
             "buttons at right"
-            thumbWidth := thumbWidth + borderWidth.
+            thumbWidth := thumbWidth + bw.
             thumbHidden ifTrue:[
                 bX := elementSpacing
             ] ifFalse:[
@@ -529,11 +534,11 @@
         style == #os2 ifTrue:[
             button2 origin:((leftWidth + thumbWidth + sep2 - margin) @ bwn).
             thumb extent:((thumbWidth - margin - margin) @ thumbHeight).
-            thumb origin:((leftWidth - borderWidth + elementSpacing + margin) @ bwn)
+            thumb origin:((leftWidth - bw + elementSpacing + margin) @ bwn)
         ] ifFalse:[
             button2 origin:((leftWidth + thumbWidth + sep2 - (margin // 2)) @ bwn).
             thumb extent:((thumbWidth + margin - (margin // 2)) @ thumbHeight).
-            thumb origin:((leftWidth - borderWidth + elementSpacing) @ bwn)
+            thumb origin:((leftWidth - bw + elementSpacing) @ bwn)
         ].
     ] ifFalse:[
         "width of buttons is always my width"
@@ -571,7 +576,7 @@
         (buttonLayout == #bottom) ifTrue:[
             "buttons at bottom"
 
-            thumbHeight := thumbHeight + borderWidth.
+            thumbHeight := thumbHeight + bw.
             
                 bY := thumbHeight + sep2.
                 (bY + upAndDownHeight) >= height ifTrue:[
@@ -600,18 +605,18 @@
         button1 origin:(bwn @ bwn).
 
         style == #os2 ifTrue:[
-            button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - margin "+ borderWidth")).
+            button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - margin "+ bw")).
             thumb extent:(thumbWidth @ (thumbHeight - margin - margin "+ margin - (margin // 2)")).
-            thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing + margin))
+            thumb origin:(bwn @ (upHeight - bw + elementSpacing + margin))
         ] ifFalse:[
-            button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - (margin // 2) "+ borderWidth")).
+            button2 origin:(bwn @ (upHeight + thumbHeight + sep2 - (margin // 2) "+ bw")).
             thumb extent:(thumbWidth @ (thumbHeight + margin - (margin // 2))).
-            thumb origin:(bwn @ (upHeight - borderWidth + elementSpacing))
+            thumb origin:(bwn @ (upHeight - bw + elementSpacing))
         ].
     ].
 
-    "Modified: 3.5.1996 / 23:49:02 / stefan"
-    "Modified: 24.7.1997 / 14:42:58 / cg"
+    "Modified: / 3.5.1996 / 23:49:02 / stefan"
+    "Modified: / 3.11.1997 / 15:23:08 / cg"
 ! !
 
 !ScrollBar methodsFor:'forced scroll'!
@@ -971,5 +976,5 @@
 !ScrollBar class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.51 1997-10-15 11:27:12 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.52 1997-11-03 15:17:59 cg Exp $'
 ! !