class: GradientBackground
authorClaus Gittinger <cg@exept.de>
Fri, 22 Feb 2013 13:35:02 +0100
changeset 6014 0da48fc12d6a
parent 6013 aee5be18d9a1
child 6015 4f8a9806acb9
class: GradientBackground comment/format in: #horizontal:to: changed: #asFormOn: #fillRectangleX:y:width:height:in:
GradientBackground.st
--- a/GradientBackground.st	Fri Feb 22 12:45:43 2013 +0100
+++ b/GradientBackground.st	Fri Feb 22 13:35:02 2013 +0100
@@ -60,6 +60,14 @@
      v viewBackground:bg.
      v open.
     "
+    "
+     |bg v|
+
+     bg := GradientBackground horizontal:Color red to:Color yellow.
+     v := View new extent:300@300.
+     v viewBackground:bg.
+     v open.
+    "
 !
 
 vertical:color1 to:color2
@@ -155,15 +163,20 @@
 !GradientBackground methodsFor:'converting'!
 
 asFormOn:aDevice
-    |h w|
+    |h w len|
+
+    usedLength == #full ifTrue:[self halt. ^ nil].
 
     cachedForm isNil ifTrue:[
+        (len := usedLength) == #full ifTrue:[
+            len := nil
+        ].
         (direction == #northSouth or:[direction == nil]) ifTrue:[
-            h := usedLength ? (Display height). "/ aView height.
+            h := len ? (Display height). "/ aView height.
             w := 8.
         ] ifFalse:[
             h := 8.
-            w := usedLength ? (Display width).  "/ aView width.
+            w := len ? (Display width).  "/ aView width.
         ].
         cachedForm := Form width:w height:h depth:aDevice depth onDevice:aDevice.
         "/ cachedForm clear.
@@ -194,10 +207,17 @@
     "/ always take the full-screen as reference
     "/ (so we do not have to care for changed gradient, when view changes size)
     usedLength notNil ifTrue:[
-        hAll := usedLength.
-        wAll := usedLength.
-        scaleStartX := 0.
-        scaleStartY := 0.
+        usedLength == #full ifTrue:[
+            hAll := aView height.
+            wAll := aView width.
+            scaleStartX := 0.
+            scaleStartY := 0.
+        ] ifFalse:[
+            hAll := usedLength.
+            wAll := usedLength.
+            scaleStartX := 0.
+            scaleStartY := 0.
+        ]
     ] ifFalse:[
         hAll := Display height. "/ aView height.
         wAll := Display width.  "/ aView width.
@@ -306,7 +326,11 @@
 
 !GradientBackground class methodsFor:'documentation'!
 
+version
+    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.15 2013-02-22 12:35:02 cg Exp $'
+!
+
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.14 2013-02-22 11:45:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/GradientBackground.st,v 1.15 2013-02-22 12:35:02 cg Exp $'
 ! !