--- a/HScale.st Sat Mar 06 13:49:08 1999 +0100
+++ b/HScale.st Sun Mar 07 14:25:33 1999 +0100
@@ -11,10 +11,10 @@
"
SimpleView subclass:#HorizontalScale
- instanceVariableNames:'slider range action'
- classVariableNames:''
- poolDictionaries:''
- category:'Views-Interactors'
+ instanceVariableNames:'slider range action'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Views-Interactors'
!
!HorizontalScale class methodsFor:'documentation'!
@@ -33,39 +33,28 @@
"
!
-version
- ^ '$Header: /cvs/stx/stx/libwidg2/Attic/HScale.st,v 1.4 1995-11-11 16:28:57 cg Exp $'
-!
-
documentation
"
like a slider, but with a range (i.e. may be different from 0..100)
and displaying the current value.
"
-! !
-
-!HorizontalScale methodsFor:'slider actions'!
+!
-scroll:percent
- |value x label|
-
- action notNil ifTrue:[
- value := (range last - range first) * (percent / 100).
- value := value + range first.
- action value:value.
+examples
+"
+ |top s1 s2|
- x := slider thumbFrame left + (slider thumbFrame width // 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:x + ((font widthOf:label) // 2)
- y:slider height + device verticalPixelPerMillimeter
- ]
+ top := StandardSystemView new.
+ top extent:200@200.
+ s1 := HorizontalScale origin:0.0 @ 0.0 in:top.
+ s1 extent:1.0 @ 50.
+
+ s2 := HorizontalScale origin:0.0 @ 0.5 in:top.
+ s2 extent:1.0 @ 50.
+ s2 range:(-50 to:50).
+ top open
+"
+
! !
!HorizontalScale methodsFor:'accessing'!
@@ -78,6 +67,32 @@
action := aBlock
! !
+!HorizontalScale methodsFor:'drawing'!
+
+redraw
+ |percent value x label|
+
+ percent := slider thumbOrigin.
+
+ value := (range last - range first) * (percent / 100).
+ value := value + range first.
+
+ x := slider thumbFrame left + (slider thumbFrame width // 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:x - ((font widthOf:label) // 2)
+ y:font ascent + device verticalPixelPerMillimeter
+
+ "Created: / 7.3.1999 / 00:16:54 / cg"
+ "Modified: / 7.3.1999 / 00:26:19 / cg"
+! !
+
!HorizontalScale methodsFor:'initialization'!
initialize
@@ -86,10 +101,43 @@
range := (0 to:100).
slider := HorizontalSlider in:self.
slider origin:0.0 @ (font height + device verticalPixelPerMillimeter rounded).
- slider extent:1.0 @ slider height.
- self height:(slider height
- + (font height)
- + (device verticalPixelPerMillimeter * 2) rounded).
+ slider width:1.0.
+
+"/ self height:(slider height
+"/ + (font height)
+"/ + (device verticalPixelPerMillimeter * 2) rounded).
slider scrollAction:[:percent | self scroll:percent].
+
+ "Modified: / 7.3.1999 / 00:21:52 / cg"
! !
+
+!HorizontalScale methodsFor:'queries'!
+
+preferredExtent
+ ^ slider preferredExtent + (0 @ (font height + device verticalPixelPerMillimeter rounded))
+
+ "Created: / 7.3.1999 / 00:18:28 / cg"
+ "Modified: / 7.3.1999 / 00:24:40 / cg"
+! !
+
+!HorizontalScale methodsFor:'slider actions'!
+
+scroll:percent
+ |value|
+
+ value := (range last - range first) * (percent / 100).
+ value := value + range first.
+ action notNil ifTrue:[
+ action value:value.
+ ].
+ self redraw
+
+ "Modified: / 7.3.1999 / 00:17:33 / cg"
+! !
+
+!HorizontalScale class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/libwidg2/Attic/HScale.st,v 1.5 1999-03-07 13:25:09 cg Exp $'
+! !