--- a/TypeConv.st Thu May 21 16:43:07 1998 +0200
+++ b/TypeConv.st Fri May 22 11:21:28 1998 +0200
@@ -112,6 +112,19 @@
"Modified: 4.3.1997 / 11:51:41 / cg"
!
+onNumberValue:aValueHolder minValue:min maxValue:max
+ "create and return a typeConverter, which retrieves
+ a values string representation via #value, and converts
+ a number-string to a value via #value:.
+ Useful as an editFields model, which operates on some
+ numeric value (or aspectAdaptor, which adapts to a numeric slot)"
+
+ ^ (self on:aValueHolder) numberToTextMinValue:min maxValue:max
+
+ "Created: 4.3.1997 / 11:51:25 / cg"
+ "Modified: 4.3.1997 / 11:51:41 / cg"
+!
+
onNumberValue:aValueHolder postDecimalDigits:numPostDecimalDigits
"create and return a typeConverter, which retrieves
a values string representation via #value, and converts
@@ -467,6 +480,70 @@
"Modified: 21.2.1997 / 18:59:44 / cg"
!
+numberToTextMin:minVal max:maxVal
+ "setup the converter to convert from a string to a number
+ and vice versa, but clamping the number into the range."
+
+ self
+ getBlock:[:model |
+ |numericValue|
+
+ (numericValue := model value) isNil ifTrue:[
+ String new
+ ] ifFalse:[
+ numericValue printString
+ ]]
+
+ putBlock:
+ [:model :string |
+
+ |value|
+
+ string isEmpty ifTrue:[
+ value := 0
+ ] ifFalse:[
+ value := string asNumber
+ ].
+ value := (value max:minVal) min:maxVal.
+ model value:value]
+
+ updateBlock: [:m :a :p | true]
+
+ "Modified: 21.2.1997 / 18:59:44 / cg"
+!
+
+numberToTextMinValue:minVal maxValue:maxVal
+ "setup the converter to convert from a string to a number
+ and vice versa, but clamping the number into the range."
+
+ self
+ getBlock:[:model |
+ |numericValue|
+
+ (numericValue := model value) isNil ifTrue:[
+ String new
+ ] ifFalse:[
+ numericValue printString
+ ]]
+
+ putBlock:
+ [:model :string |
+
+ |value|
+
+ string isEmpty ifTrue:[
+ value := 0
+ ] ifFalse:[
+ value := string asNumber
+ ].
+ value := (value max:minVal) min:maxVal.
+ model value:value]
+
+ updateBlock: [:m :a :p | true]
+
+ "Modified: 21.2.1997 / 18:59:44 / cg"
+!
+
smalltalkObject
"setup the converter to convert from a string to any smalltalk object
and vice versa. The string used is the objects storeString.
@@ -601,5 +678,5 @@
!TypeConverter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/Attic/TypeConv.st,v 1.9 1997-12-08 17:37:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/Attic/TypeConv.st,v 1.10 1998-05-22 09:21:28 cg Exp $'
! !
--- a/TypeConverter.st Thu May 21 16:43:07 1998 +0200
+++ b/TypeConverter.st Fri May 22 11:21:28 1998 +0200
@@ -112,6 +112,19 @@
"Modified: 4.3.1997 / 11:51:41 / cg"
!
+onNumberValue:aValueHolder minValue:min maxValue:max
+ "create and return a typeConverter, which retrieves
+ a values string representation via #value, and converts
+ a number-string to a value via #value:.
+ Useful as an editFields model, which operates on some
+ numeric value (or aspectAdaptor, which adapts to a numeric slot)"
+
+ ^ (self on:aValueHolder) numberToTextMinValue:min maxValue:max
+
+ "Created: 4.3.1997 / 11:51:25 / cg"
+ "Modified: 4.3.1997 / 11:51:41 / cg"
+!
+
onNumberValue:aValueHolder postDecimalDigits:numPostDecimalDigits
"create and return a typeConverter, which retrieves
a values string representation via #value, and converts
@@ -467,6 +480,70 @@
"Modified: 21.2.1997 / 18:59:44 / cg"
!
+numberToTextMin:minVal max:maxVal
+ "setup the converter to convert from a string to a number
+ and vice versa, but clamping the number into the range."
+
+ self
+ getBlock:[:model |
+ |numericValue|
+
+ (numericValue := model value) isNil ifTrue:[
+ String new
+ ] ifFalse:[
+ numericValue printString
+ ]]
+
+ putBlock:
+ [:model :string |
+
+ |value|
+
+ string isEmpty ifTrue:[
+ value := 0
+ ] ifFalse:[
+ value := string asNumber
+ ].
+ value := (value max:minVal) min:maxVal.
+ model value:value]
+
+ updateBlock: [:m :a :p | true]
+
+ "Modified: 21.2.1997 / 18:59:44 / cg"
+!
+
+numberToTextMinValue:minVal maxValue:maxVal
+ "setup the converter to convert from a string to a number
+ and vice versa, but clamping the number into the range."
+
+ self
+ getBlock:[:model |
+ |numericValue|
+
+ (numericValue := model value) isNil ifTrue:[
+ String new
+ ] ifFalse:[
+ numericValue printString
+ ]]
+
+ putBlock:
+ [:model :string |
+
+ |value|
+
+ string isEmpty ifTrue:[
+ value := 0
+ ] ifFalse:[
+ value := string asNumber
+ ].
+ value := (value max:minVal) min:maxVal.
+ model value:value]
+
+ updateBlock: [:m :a :p | true]
+
+ "Modified: 21.2.1997 / 18:59:44 / cg"
+!
+
smalltalkObject
"setup the converter to convert from a string to any smalltalk object
and vice versa. The string used is the objects storeString.
@@ -601,5 +678,5 @@
!TypeConverter class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.9 1997-12-08 17:37:47 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/TypeConverter.st,v 1.10 1998-05-22 09:21:28 cg Exp $'
! !