use UnitConverter for page sizes
authorClaus Gittinger <cg@exept.de>
Fri, 31 May 1996 19:44:38 +0200
changeset 736 53d23f1eb6af
parent 735 2552463a8f34
child 737 911a168ef967
use UnitConverter for page sizes
ObjView.st
ObjectView.st
--- a/ObjView.st	Fri May 31 13:24:09 1996 +0200
+++ b/ObjView.st	Fri May 31 19:44:38 1996 +0200
@@ -1880,7 +1880,8 @@
 documentFormat:aFormatString
     "set the document format (mostly used by scrollbars).
      The argument should be a string such as 'a4', 'a5'
-     or 'letter'. See widthOfContentsInMM for supported formats."
+     or 'letter'. 
+     See the UnitConverter class for supported formats."
 
     aFormatString ~= documentFormat ifTrue:[
         documentFormat := aFormatString.
@@ -1891,7 +1892,7 @@
         ]
     ]
 
-    "Modified: 29.5.1996 / 16:19:44 / cg"
+    "Modified: 31.5.1996 / 19:44:08 / cg"
 !
 
 forEach:aCollection do:aBlock
@@ -2173,54 +2174,22 @@
 heightOfContentsInMM
     "answer the height of the document in millimeters"
 
+    |unit value|
+
     "landscape"
-    (documentFormat = 'a1l') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a2l') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a3l') ifTrue:[
-	^ 296
-    ].
-    (documentFormat = 'a4l') ifTrue:[
-	^ 210
-    ].
-    (documentFormat = 'a5l') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'a6l') ifTrue:[
-	^ 105
-    ].
-    (documentFormat = 'letterl') ifTrue:[
-	^ 8.5 * 25.4
+    unit := (documentFormat , 'H') asSymbolIfInterned.
+    unit isNil ifTrue:[
+        "/ certainly unknown
+    ] ifFalse:[
+        value := UnitConverter convert:1 from:unit to:#millimeter
     ].
-
-    (documentFormat = 'a1') ifTrue:[
-	^ 840
-    ].
-    (documentFormat = 'a2') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a3') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a4') ifTrue:[
-	^ 296
+    value isNil ifTrue:[
+        "/ assuming window size is document size
+        value := (height / self verticalPixelPerMillimeter:1) asInteger
     ].
-    (documentFormat = 'a5') ifTrue:[
-	^ 210
-    ].
-    (documentFormat = 'a6') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'letter') ifTrue:[
-	^ 11 * 25.4
-    ].
-    "*** more formats needed here ...***"
-
-    "assuming window size is document size"
-    ^ (height / self verticalPixelPerMillimeter:1) asInteger
+    ^ value
+
+    "Modified: 31.5.1996 / 19:38:51 / cg"
 !
 
 widthOfContents
@@ -2235,54 +2204,22 @@
 widthOfContentsInMM
     "answer the width of the document in millimeters"
 
+    |unit value|
+
     "landscape"
-    (documentFormat = 'a1l') ifTrue:[
-	^ 840
-    ].
-    (documentFormat = 'a2l') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a3l') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a4l') ifTrue:[
-	^ 296
-    ].
-    (documentFormat = 'a5l') ifTrue:[
-	^ 210
-    ].
-    (documentFormat = 'a6l') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'letterl') ifTrue:[
-	^ 11 * 25.4
+    unit := (documentFormat , 'W') asSymbolIfInterned.
+    unit isNil ifTrue:[
+        "/ certainly unknown
+    ] ifFalse:[
+        value := UnitConverter convert:1 from:unit to:#millimeter
     ].
-
-    (documentFormat = 'a1') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a2') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a3') ifTrue:[
-	^ 296
-    ].
-    (documentFormat = 'a4') ifTrue:[
-	^ 210
+    value isNil ifTrue:[
+        "/ assuming window size is document size
+        value := (width / self horizontalPixelPerMillimeter:1) asInteger
     ].
-    (documentFormat = 'a5') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'a6') ifTrue:[
-	^ 105
-    ].
-    (documentFormat = 'letter') ifTrue:[
-	^ 8.5 * 25.4
-    ].
-    "*** more formats needed here ...***"
-
-    "assuming window size is document size"
-    ^ (width / self horizontalPixelPerMillimeter:1) asInteger
+    ^ value
+
+    "Modified: 31.5.1996 / 19:38:22 / cg"
 ! !
 
 !ObjectView methodsFor:'saving / restoring'!
@@ -2869,5 +2806,5 @@
 !ObjectView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ObjView.st,v 1.43 1996-05-30 16:47:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ObjView.st,v 1.44 1996-05-31 17:44:38 cg Exp $'
 ! !
--- a/ObjectView.st	Fri May 31 13:24:09 1996 +0200
+++ b/ObjectView.st	Fri May 31 19:44:38 1996 +0200
@@ -1880,7 +1880,8 @@
 documentFormat:aFormatString
     "set the document format (mostly used by scrollbars).
      The argument should be a string such as 'a4', 'a5'
-     or 'letter'. See widthOfContentsInMM for supported formats."
+     or 'letter'. 
+     See the UnitConverter class for supported formats."
 
     aFormatString ~= documentFormat ifTrue:[
         documentFormat := aFormatString.
@@ -1891,7 +1892,7 @@
         ]
     ]
 
-    "Modified: 29.5.1996 / 16:19:44 / cg"
+    "Modified: 31.5.1996 / 19:44:08 / cg"
 !
 
 forEach:aCollection do:aBlock
@@ -2173,54 +2174,22 @@
 heightOfContentsInMM
     "answer the height of the document in millimeters"
 
+    |unit value|
+
     "landscape"
-    (documentFormat = 'a1l') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a2l') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a3l') ifTrue:[
-	^ 296
-    ].
-    (documentFormat = 'a4l') ifTrue:[
-	^ 210
-    ].
-    (documentFormat = 'a5l') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'a6l') ifTrue:[
-	^ 105
-    ].
-    (documentFormat = 'letterl') ifTrue:[
-	^ 8.5 * 25.4
+    unit := (documentFormat , 'H') asSymbolIfInterned.
+    unit isNil ifTrue:[
+        "/ certainly unknown
+    ] ifFalse:[
+        value := UnitConverter convert:1 from:unit to:#millimeter
     ].
-
-    (documentFormat = 'a1') ifTrue:[
-	^ 840
-    ].
-    (documentFormat = 'a2') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a3') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a4') ifTrue:[
-	^ 296
+    value isNil ifTrue:[
+        "/ assuming window size is document size
+        value := (height / self verticalPixelPerMillimeter:1) asInteger
     ].
-    (documentFormat = 'a5') ifTrue:[
-	^ 210
-    ].
-    (documentFormat = 'a6') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'letter') ifTrue:[
-	^ 11 * 25.4
-    ].
-    "*** more formats needed here ...***"
-
-    "assuming window size is document size"
-    ^ (height / self verticalPixelPerMillimeter:1) asInteger
+    ^ value
+
+    "Modified: 31.5.1996 / 19:38:51 / cg"
 !
 
 widthOfContents
@@ -2235,54 +2204,22 @@
 widthOfContentsInMM
     "answer the width of the document in millimeters"
 
+    |unit value|
+
     "landscape"
-    (documentFormat = 'a1l') ifTrue:[
-	^ 840
-    ].
-    (documentFormat = 'a2l') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a3l') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a4l') ifTrue:[
-	^ 296
-    ].
-    (documentFormat = 'a5l') ifTrue:[
-	^ 210
-    ].
-    (documentFormat = 'a6l') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'letterl') ifTrue:[
-	^ 11 * 25.4
+    unit := (documentFormat , 'W') asSymbolIfInterned.
+    unit isNil ifTrue:[
+        "/ certainly unknown
+    ] ifFalse:[
+        value := UnitConverter convert:1 from:unit to:#millimeter
     ].
-
-    (documentFormat = 'a1') ifTrue:[
-	^ 592
-    ].
-    (documentFormat = 'a2') ifTrue:[
-	^ 420
-    ].
-    (documentFormat = 'a3') ifTrue:[
-	^ 296
-    ].
-    (documentFormat = 'a4') ifTrue:[
-	^ 210
+    value isNil ifTrue:[
+        "/ assuming window size is document size
+        value := (width / self horizontalPixelPerMillimeter:1) asInteger
     ].
-    (documentFormat = 'a5') ifTrue:[
-	^ 148
-    ].
-    (documentFormat = 'a6') ifTrue:[
-	^ 105
-    ].
-    (documentFormat = 'letter') ifTrue:[
-	^ 8.5 * 25.4
-    ].
-    "*** more formats needed here ...***"
-
-    "assuming window size is document size"
-    ^ (width / self horizontalPixelPerMillimeter:1) asInteger
+    ^ value
+
+    "Modified: 31.5.1996 / 19:38:22 / cg"
 ! !
 
 !ObjectView methodsFor:'saving / restoring'!
@@ -2869,5 +2806,5 @@
 !ObjectView class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.43 1996-05-30 16:47:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.44 1996-05-31 17:44:38 cg Exp $'
 ! !