Scale.st
changeset 34 159147b254e1
parent 1 c6ca7bfedf31
child 49 4dd0f5c3353e
--- a/Scale.st	Wed Dec 21 20:25:09 1994 +0100
+++ b/Scale.st	Mon Feb 06 01:57:39 1995 +0100
@@ -1,6 +1,6 @@
 "
  COPYRIGHT (c) 1993 by Claus Gittinger
-              All Rights Reserved
+	      All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -17,27 +17,69 @@
 	 category:'Views-Interactors'
 !
 
+!Scale class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1993 by Claus Gittinger
+	      All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+!
+
+version
+"
+$Header: /cvs/stx/stx/libwidg2/Scale.st,v 1.2 1995-02-06 00:57:27 claus Exp $
+"
+!
+
+documentation
+"
+    like a slider, but with a range (i.e. may be different from 0..100)
+    and displaying the current value.
+"
+!
+
+examples 
+"
+    |top s1 s2|
+
+    top := StandardSystemView new.
+    top extent:200@200.
+    s1 := Scale origin:0.0 @ 0.0 extent:50 @ 1.0 in:top.
+    s2 := Scale origin:0.5 @ 0.0 extent:50 @ 1.0 in:top.
+    s2 range:(-50 to:50).
+    top open
+"
+! !
+
 !Scale methodsFor:'slider actions'!
 
 scroll:percent
     |value y label|
 
     action notNil ifTrue:[
-        value := (range last - range first) * (percent / 100).
-        value := value + range first.
-        action value:value.
+	value := (range last - range first) * (percent / 100).
+	value := value + range first.
+	action value:value.
 
-        y := slider thumbFrame top + (slider thumbFrame height // 2).
-        self clear.
-        self paint:Black.
-        value := value roundTo:(range last - range first) / 100.
-        label := value asFloat printString.
-        (label endsWith:'.0') ifTrue:[
-            label := value asInteger printString
-        ].
-        self displayString:label
-                         x:slider width + device horizontalPixelPerMillimeter
-                         y:y + (font ascent // 2)
+	y := slider thumbFrame top + (slider thumbFrame height // 2).
+	self clear.
+	self paint:Black.
+	value := value roundTo:(range last - range first) / 100.
+	label := value asFloat printString.
+	(label endsWith:'.0') ifTrue:[
+	    label := value asInteger printString
+	].
+	self displayString:label
+			 x:slider width + device horizontalPixelPerMillimeter
+			 y:y + (font ascent // 2)
     ]
 ! !
 
@@ -58,11 +100,12 @@
 
     range := (0 to:100).
     slider := Slider in:self.
+    slider fixSize.
     slider origin:0.0 @ 0.0.
     slider extent:slider width@ 1.0.
     self width:(slider width  
-                + (font widthOf:'100')
-                + (device horizontalPixelPerMillimeter * 2) rounded).
+		+ (font widthOf:'100')
+		+ (device horizontalPixelPerMillimeter * 2) rounded).
 
     slider scrollAction:[:percent | self scroll:percent].
 ! !