UILayoutTool.st
changeset 3235 62205b199fc6
parent 3234 de4008994329
child 3239 d6d4d8ed0421
--- a/UILayoutTool.st	Thu Oct 29 09:31:25 2015 +0100
+++ b/UILayoutTool.st	Thu Oct 29 09:44:01 2015 +0100
@@ -1137,6 +1137,14 @@
         ]
 ! !
 
+!UILayoutTool::AnyLayout methodsFor:'accessing'!
+
+aspectValueOr0For:aspectName
+    "common helper - fetches the aspect value; if it is nil, return 0."
+
+    ^ self aspectValueOr:0 for:aspectName
+! !
+
 !UILayoutTool::AlignmentOrigin class methodsFor:'help specs'!
 
 helpSpec
@@ -1420,14 +1428,14 @@
     layout  := (Smalltalk at:#AlignmentOrigin) new.
 
     layout 
-        leftFraction:(((self aspectFor:#leftFraction) value) ? 0)
-              offset:(((self aspectFor:#leftOffset)   value) ? 0)
-        topFraction:(((self aspectFor:#topFraction)  value) ? 0)
-             offset:(((self aspectFor:#topOffset)    value) ? 0).
+        leftFraction:(self aspectValueOr0For:#leftFraction)
+        offset:(self aspectValueOr0For:#leftOffset)
+        topFraction:(self aspectValueOr0For:#topFraction)
+        offset:(self aspectValueOr0For:#topOffset).
 
     layout 
-        leftAlignmentFraction:(((self aspectFor:#leftAlignmentFraction) value) ? 0)
-        topAlignmentFraction:(((self aspectFor:#topAlignmentFraction)  value) ? 0).
+        leftAlignmentFraction:(self aspectValueOr0For:#leftAlignmentFraction)
+        topAlignmentFraction:(self aspectValueOr0For:#topAlignmentFraction).
 
   ^ layout
 ! !
@@ -1722,7 +1730,7 @@
 layout
     "returns the current extent"
 
-    ^ (((self aspectFor:#leftOffset) value) ? 0) @ (((self aspectFor:#topOffset)  value) ? 0)
+    ^ (self aspectValueOr0For:#leftOffset) @ (self aspectValueOr0For:#topOffset)
 ! !
 
 !UILayoutTool::Extent methodsFor:'aspects'!
@@ -3053,14 +3061,14 @@
     layout  := (Smalltalk at:LayoutFrame) new.
 
     layout 
-        leftFraction:(((self aspectFor:#leftFraction)   value) ? 0)
-              offset:(((self aspectFor:#leftOffset)     value) ? 0)
-        rightFraction:(((self aspectFor:#rightFraction)  value) ? 0)
-              offset:(((self aspectFor:#rightOffset)    value) ? 0)
-        topFraction:(((self aspectFor:#topFraction)    value) ? 0)
-              offset:(((self aspectFor:#topOffset)      value) ? 0)
-        bottomFraction:(((self aspectFor:#bottomFraction) value) ? 0)
-              offset:(((self aspectFor:#bottomOffset)   value) ? 0).
+        leftFraction:(self aspectValueOr0For:#leftFraction)
+            offset:(self aspectValueOr0For:#leftOffset)
+        rightFraction:(self aspectValueOr0For:#rightFraction)
+            offset:(self aspectValueOr0For:#rightOffset)
+        topFraction:(self aspectValueOr0For:#topFraction)
+            offset:(self aspectValueOr0For:#topOffset)
+        bottomFraction:(self aspectValueOr0For:#bottomFraction)
+            offset:(self aspectValueOr0For:#bottomOffset).
 
   ^ layout
 ! !
@@ -3290,10 +3298,10 @@
     layout  := (Smalltalk at:#LayoutOrigin) new.
 
     layout 
-        leftFraction:(((self aspectFor:#leftFraction) value) ? 0)
-              offset:(((self aspectFor:#leftOffset)   value) ? 0)
-        topFraction:(((self aspectFor:#topFraction)  value) ? 0)
-             offset:(((self aspectFor:#topOffset)    value) ? 0).
+        leftFraction:(self aspectValueOr0For:#leftFraction)
+            offset:(self aspectValueOr0For:#leftOffset)
+        topFraction:(self aspectValueOr0For:#topFraction)
+            offset:(self aspectValueOr0For:#topOffset).
 
   ^ layout
 ! !
@@ -3358,9 +3366,7 @@
 layout
     "returns current layout as point
     "
-  ^ (((self aspectFor:#leftOffset) value) ? 0) 
-    @ 
-    (((self aspectFor:#topOffset)  value) ? 0)
+  ^ (self aspectValueOr0For:#leftOffset) @ (self aspectValueOr0For:#topOffset)
 ! !
 
 !UILayoutTool::Rectangle class methodsFor:'interface specs'!
@@ -3480,10 +3486,10 @@
     "returns current layout as rectangle"
 
     ^ (Smalltalk at:#Rectangle) 
-        left:(((self aspectFor:#leftOffset)   value) ? 0)
-        top:(((self aspectFor:#topOffset)    value) ? 0)
-        right:(((self aspectFor:#rightOffset)  value) ? 0)
-        bottom:(((self aspectFor:#bottomOffset) value) ? 0)
+        left:(self aspectValueOr0For:#leftOffset)
+        top:(self aspectValueOr0For:#topOffset)
+        right:(self aspectValueOr0For:#rightOffset)
+        bottom:(self aspectValueOr0For:#bottomOffset)
 ! !
 
 !UILayoutTool class methodsFor:'documentation'!