ScrollBar.st
changeset 3010 f920bb8248bd
parent 2914 68ef3b429d77
child 3014 bf5e25dd200b
--- a/ScrollBar.st	Wed Sep 08 12:18:21 2004 +0200
+++ b/ScrollBar.st	Mon Sep 13 10:44:06 2004 +0200
@@ -296,6 +296,11 @@
     "/ ^ super allViewBackground:something
 !
 
+beNativeWidget
+    super beNativeWidget.
+    self destroyElements.
+!
+
 orientation
     "for ST-80 compatibility, answer this query"
 
@@ -405,8 +410,8 @@
      sep2 "{ Class: SmallInteger }"
      sep3 "{ Class: SmallInteger }"
      m2   "{ Class: SmallInteger }"
-     thumbWidth w h style b1Hidden b2Hidden thumbHidden 
-     b1WasHidden b2WasHidden thumbWasHidden bX bY
+     thumbWidth w h style b1Visible b2Visible thumbVisible 
+     b1WasVisible b2WasVisible thumbWasVisible bX bY
      leftWidth rightWidth leftAndRightWidth isHorizontal
      tX tY tW tH tExt bOrg|
 
@@ -416,9 +421,9 @@
     bwn := bw negated + margin.
     m2 := margin * 2.
 
-    b1WasHidden := button1 realized not.
-    b2WasHidden := button2 realized not.
-    thumbWasHidden := thumb realized not.
+    b1WasVisible := button1 realized.
+    b2WasVisible := button2 realized.
+    thumbWasVisible := thumb realized.
 
     (isHorizontal := (orientation == #horizontal)) ifTrue:[
         leftWidth := button1 width + bw.
@@ -438,15 +443,15 @@
         "if I become too small, hide buttons"
 
         width <= (leftAndRightWidth + m2) ifTrue:[
-            b1Hidden := b2Hidden := thumbHidden := true.
+            b1Visible := b2Visible := thumbVisible := false.  
         ] ifFalse:[
-            b1Hidden := b2Hidden := thumbHidden := false.
+            b1Visible := b2Visible := thumbVisible := true.  
         ].
 
         (thumbWidth < 10) ifTrue:[
-            thumbHidden := true.
+            thumbVisible := false.
         ] ifFalse:[
-            thumbHidden := false.
+            thumbVisible := true.
         ].
     ] ifFalse:[
         upHeight := button1 height + bw.
@@ -466,43 +471,28 @@
         "if I become too small, hide buttons and thumb"
 
         height <= (upAndDownHeight + (m2)) ifTrue:[
-            b1Hidden := b2Hidden := thumbHidden := true.
+            b1Visible := b2Visible := thumbVisible := false.  
         ] ifFalse:[
-            b1Hidden := b2Hidden := thumbHidden := false.
+            b1Visible := b2Visible := thumbVisible := true.  
         ].
 
         (thumbHeight < 10) ifTrue:[
-            thumbHidden := true.
+            thumbVisible := false.
         ] ifFalse:[
-            thumbHidden := false.
+            thumbVisible := true.
         ].
     ].
 
-    b1Hidden ~~ b1WasHidden ifTrue:[
-        button1 hiddenOnRealize:b1Hidden.
-        b1Hidden ifTrue:[
-            button1 unmap
-        ] ifFalse:[
-            shown ifTrue:[button1 realize]
-        ].
+    b1Visible ~~ b1WasVisible ifTrue:[
+        self changeVisibilityOf:button1 to:b1Visible.
     ].
 
-    b2Hidden ~~ b2WasHidden ifTrue:[
-        button2 hiddenOnRealize:b1Hidden.
-        b2Hidden ifTrue:[
-            button2 unmap
-        ] ifFalse:[
-            shown ifTrue:[button2 realize]
-        ].
+    b2Visible ~~ b2WasVisible ifTrue:[
+        self changeVisibilityOf:button2 to:b2Visible.
     ].
 
-    thumbHidden ~~ thumbWasHidden ifTrue:[
-        thumb hiddenOnRealize:thumbHidden.
-        thumbHidden ifTrue:[
-            thumb unmap
-        ] ifFalse:[
-            shown ifTrue:[thumb realize]
-        ].
+    thumbVisible ~~ thumbWasVisible ifTrue:[
+        self changeVisibilityOf:thumb to:thumbVisible.
     ].
 
     sep2 := elementSpacing * 2.
@@ -547,9 +537,9 @@
         (buttonLayout == #top) ifTrue:[
             "buttons at right"
             thumbWidth := thumbWidth + bw.
-            thumbHidden ifTrue:[
+            thumbVisible ifFalse:[
                 bX := elementSpacing
-            ] ifFalse:[
+            ] ifTrue:[
                 bX := thumbWidth + sep2.
             ].
             tExt := (thumbWidth @ thumbHeight).
@@ -771,6 +761,24 @@
     "Created: 1.3.1996 / 19:22:11 / cg"
 !
 
+destroyElements
+    button1 notNil ifTrue:[
+        button1 beInvisible.
+        "/ button1 destroy.
+        "/ button1 := nil.
+    ].
+    button2 notNil ifTrue:[
+        button2 beInvisible.
+        "/ button2 destroy.
+        "/ button2 := nil.
+    ].
+    thumb notNil ifTrue:[
+        thumb beInvisible.
+        "/ thumb destroy.
+        "/ thumb := nil.
+    ].
+!
+
 initStyle
     "setup viewStyle specifics"
 
@@ -928,6 +936,17 @@
 
 !ScrollBar methodsFor:'private'!
 
+changeVisibilityOf:aComponent to:aBoolean
+    self isNativeWidget ifTrue:[^ self].
+
+    aComponent hiddenOnRealize:aBoolean not.
+    aBoolean ifFalse:[
+        aComponent unmap
+    ] ifTrue:[
+        shown ifTrue:[aComponent realize]
+    ].
+!
+
 enableDisableButtons
     "only used with styles which disable their buttons if the
      thumb is at either end. Check where the thumb is and enable/disable
@@ -1086,5 +1105,5 @@
 !ScrollBar class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.69 2004-02-27 10:56:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ScrollBar.st,v 1.70 2004-09-13 08:44:06 cg Exp $'
 ! !