PrintConverter.st
changeset 212 874afdeb380a
parent 114 e577a2f332d0
child 222 c51b06f6bf9a
--- a/PrintConverter.st	Tue Apr 23 13:12:01 1996 +0200
+++ b/PrintConverter.st	Tue Apr 23 21:57:19 1996 +0200
@@ -10,11 +10,11 @@
  hereby transferred.
 "
 
-Object subclass:#PrintConverter 
-	 instanceVariableNames:'valueToStringBlock stringToValueBlock type'
-	 classVariableNames:''
-	 poolDictionaries:''
-	 category:'Interface-Support'
+Object subclass:#PrintConverter
+	instanceVariableNames:'valueToStringBlock stringToValueBlock type'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Support'
 !
 
 !PrintConverter class methodsFor:'documentation'!
@@ -33,10 +33,6 @@
 "
 !
 
-version 
-    ^ '$Header: /cvs/stx/stx/libview2/PrintConverter.st,v 1.9 1995-11-11 16:04:54 cg Exp $'
-!
-
 documentation
 "
     printConverters can be used with labels and editFields to convert 
@@ -263,6 +259,22 @@
     ^ type
 ! !
 
+!PrintConverter methodsFor:'converting'!
+
+printStringFor:aValue
+    "sent when an inputField wants a models value to be converted to a string
+     for display"
+
+    ^ valueToStringBlock value:aValue
+!
+
+readValueFrom:aString
+    "sent when an inputField wants a string to be converted to a value 
+     to be returned as its contents value"
+
+    ^ stringToValueBlock value:aString
+! !
+
 !PrintConverter methodsFor:'initialization'!
 
 initFor:aTypeSymbol
@@ -287,34 +299,20 @@
     "Modified: 6.9.1995 / 12:10:38 / claus"
 !
 
-toPrint:printBlock toRead:readBlock
-    "initialize to convert using two custom blocks.
-     printBlock is supposed to get the objects value as argument,
-     and to return a string.
-     readBlock is supposed to get a string as argument, and return
-     the corresponding object."
+initForDate
+    "initialize to convert to/from a date 
+     - if the string is empty or invalid, convert to the current date"
 
-    valueToStringBlock := printBlock.
-    stringToValueBlock := readBlock.
+    valueToStringBlock := [:date | date printString].
+    stringToValueBlock := [:string | Date readFromString:string onError:[Date today]]
 !
 
-initForInteger
-    "initialize to convert to/from an integer 
-     - if the string is empty or invalid, convert to 0"
-
-    valueToStringBlock := [:num | num truncated printString].
-    stringToValueBlock := [:string | Integer readFromString:string onError:0]
-!
-
-initForIntegerOrNil
-    "initialize to convert to/from an integer 
+initForDateOrNil
+    "initialize to convert to/from a date 
      - if the string is empty or invalid, convert to nil"
 
-    valueToStringBlock := [:num | 
-	num isNil ifTrue:[''] 
-		  ifFalse:[num printString]].
-    stringToValueBlock := [:string | 
-	Integer readFromString:string onError:nil]
+    valueToStringBlock := [:date | date printString].
+    stringToValueBlock := [:string | Date readFromString:string onError:nil]
 !
 
 initForFloat
@@ -337,6 +335,25 @@
     stringToValueBlock := [:string | Float readFromString:string onError:0]
 !
 
+initForInteger
+    "initialize to convert to/from an integer 
+     - if the string is empty or invalid, convert to 0"
+
+    valueToStringBlock := [:num | num truncated printString].
+    stringToValueBlock := [:string | Integer readFromString:string onError:0]
+!
+
+initForIntegerOrNil
+    "initialize to convert to/from an integer 
+     - if the string is empty or invalid, convert to nil"
+
+    valueToStringBlock := [:num | 
+	num isNil ifTrue:[''] 
+		  ifFalse:[num printString]].
+    stringToValueBlock := [:string | 
+	Integer readFromString:string onError:nil]
+!
+
 initForNumber
     "initialize to convert to/from a number 
      - if the string is empty or invalid, convert to 0"
@@ -363,22 +380,6 @@
     stringToValueBlock := [:string | string]
 !
 
-initForDate
-    "initialize to convert to/from a date 
-     - if the string is empty or invalid, convert to the current date"
-
-    valueToStringBlock := [:date | date printString].
-    stringToValueBlock := [:string | Date readFromString:string onError:[Date today]]
-!
-
-initForDateOrNil
-    "initialize to convert to/from a date 
-     - if the string is empty or invalid, convert to nil"
-
-    valueToStringBlock := [:date | date printString].
-    stringToValueBlock := [:string | Date readFromString:string onError:nil]
-!
-
 initForYesNo
     "initialize to convert a 'yes'/'no' string to/from a boolean 
      The string is supposed to be in the current Language
@@ -388,20 +389,21 @@
     valueToStringBlock := [:bool | bool ifTrue:[ApplicationModel classResources string:'yes']
 					ifFalse:[ApplicationModel classResources string:'no']].
     stringToValueBlock := [:string | string = (ApplicationModel classResources string:'yes')]
+!
+
+toPrint:printBlock toRead:readBlock
+    "initialize to convert using two custom blocks.
+     printBlock is supposed to get the objects value as argument,
+     and to return a string.
+     readBlock is supposed to get a string as argument, and return
+     the corresponding object."
+
+    valueToStringBlock := printBlock.
+    stringToValueBlock := readBlock.
 ! !
 
-!PrintConverter methodsFor:'converting'!
-
-printStringFor:aValue
-    "sent when an inputField wants a models value to be converted to a string
-     for display"
+!PrintConverter class methodsFor:'documentation'!
 
-    ^ valueToStringBlock value:aValue
-!
-
-readValueFrom:aString
-    "sent when an inputField wants a string to be converted to a value 
-     to be returned as its contents value"
-
-    ^ stringToValueBlock value:aString
+version 
+    ^ '$Header: /cvs/stx/stx/libview2/PrintConverter.st,v 1.10 1996-04-23 19:57:19 cg Exp $'
 ! !