DeviceGraphicsContext.st
branchdelegated_gc_jv
changeset 6819 f91377f97414
parent 6800 f4acb46ba42e
parent 6765 dd2a04d4f86e
child 6836 7c4adc740f7b
--- a/DeviceGraphicsContext.st	Thu Feb 19 06:21:17 2015 +0000
+++ b/DeviceGraphicsContext.st	Tue Mar 03 03:55:48 2015 +0000
@@ -92,11 +92,11 @@
 !
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.137.2.4 2014-09-26 10:25:04 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.150 2015-02-10 18:09:32 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.137.2.4 2014-09-26 10:25:04 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.150 2015-02-10 18:09:32 stefan Exp $'
 ! !
 
 !DeviceGraphicsContext class methodsFor:'initialization'!
@@ -469,6 +469,8 @@
     "Modified: / 16.5.1999 / 19:40:37 / cg"
 !
 
+
+
 colorAt:aPoint
     "return the color of the pixel at the coordinate given by x@y"
 
@@ -569,8 +571,39 @@
 !
 
 deviceClippingRectangle:aRectangleOrNil
-    <resource: #obsolete>
-    self deviceClippingBounds:aRectangleOrNil
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
+<conflict>
 !
 
 drawableId
@@ -687,20 +720,16 @@
     |n|
 
     (aNumber ~~ lineWidth) ifTrue:[
-	lineWidth := aNumber.
-	transformation isNil ifTrue:[
-	    n := aNumber.
-	] ifFalse:[
-	    n := transformation applyScaleX:aNumber.
-	    n := n rounded
-	].
-	gcId notNil ifTrue:[
-	    device setLineWidth:n
-			  style:lineStyle
-			    cap:capStyle
-			   join:joinStyle
-			     in:gcId
-	]
+        lineWidth := aNumber.
+        transformation isNil ifTrue:[
+            n := aNumber.
+        ] ifFalse:[
+            n := transformation applyScaleX:aNumber.
+            n := n rounded
+        ].
+        gcId notNil ifTrue:[
+            device setLineWidth:n style:lineStyle cap:capStyle join:joinStyle in:gcId
+        ]
     ]
 !
 
@@ -730,7 +759,7 @@
 maskOrigin:aPoint
     "set the origin of the mask-pattern"
 
-    |x y|
+    |x y pO|
 
     x := aPoint x.
     y := aPoint y.
@@ -738,18 +767,19 @@
     (maskOrigin isNil or:[
      ((x ~= maskOrigin x) or:[y ~= maskOrigin y]) ]) ifTrue:[
 
-	maskOrigin := aPoint.
-
-	transformation notNil ifTrue:[
-	    x := transformation applyToX:x.
-	    y := transformation applyToY:y.
-	].
-	x := x rounded.
-	y := y rounded.
-
-	gcId notNil ifTrue:[
-	    device setMaskOriginX:x y:y in:gcId
-	]
+        maskOrigin := aPoint.
+
+        transformation notNil ifTrue:[
+            pO := transformation transformPoint:aPoint.
+            x:= pO x.
+            y := pO y.
+        ].
+        x := x rounded.
+        y := y rounded.
+
+        gcId notNil ifTrue:[
+            device setMaskOriginX:x y:y in:gcId
+        ]
     ]
 
     "Created: / 26.1.1998 / 19:03:02 / cg"
@@ -758,28 +788,7 @@
 maskOriginX:orgX y:orgY
     "set the origin of the pattern"
 
-    |x y|
-
-    transformation notNil ifTrue:[
-	x := transformation applyToX:orgX.
-	y := transformation applyToY:orgY.
-    ] ifFalse:[
-	x := orgX.
-	y := orgY
-    ].
-    x := x rounded.
-    y := y rounded.
-
-    (maskOrigin isNil or:[
-     ((x ~~ maskOrigin x) or:[y ~~ maskOrigin y]) ]) ifTrue:[
-
-	maskOrigin := x @ y.
-	gcId notNil ifTrue:[
-	    device setMaskOriginX:x y:y in:gcId
-	]
-    ]
-
-    "Created: / 26.1.1998 / 18:51:18 / cg"
+    self maskOrigin:(orgX @ orgY)
 !
 
 noClipByChildren
@@ -1133,7 +1142,20 @@
         y:dstY
 !
 
-
+copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h
+    "copy from aDrawable into the receiver;
+     the source may be the receiver as well - in this case its a scroll.
+     All coordinates are in device coordinates."
+
+    ^ self
+        copyFrom:aDrawable
+        x:srcX y:srcY
+        toX:dstX y:dstY
+        width:w height:h
+        async:false
+
+    "Modified: 29.1.1997 / 13:12:36 / cg"
+!
 
 copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:async
     "copy from aDrawable into the receiver;
@@ -1144,10 +1166,10 @@
      (not all devices care for this).
      If the receiver is a pixmap, the call always returns immediately."
 
-    |deviceDrawable id srcGCId|
+    |deviceDrawable id srcGCId asy|
 
     ((aDrawable graphicsDevice ~~ device)
-     or:[aDrawable isImage]) ifTrue:[
+    or:[aDrawable isImage]) ifTrue:[
         deviceDrawable := aDrawable asFormOn:device.
     ] ifFalse:[
         deviceDrawable := aDrawable
@@ -1162,7 +1184,9 @@
      This will be fixed soon (no longer use device>>bitmapFromFile:).
     "
     id isNil ifTrue:[
-        'DeviceGraphicsContext [warning]: invalid bitmap copy - ignored' errorPrintCR.
+        Smalltalk isStandAloneApp ifFalse:[
+            'DeviceGraphicsContext [warning]: invalid bitmap copy - ignored' infoPrintCR.
+        ].
         ^ self
     ].
 
@@ -1213,6 +1237,10 @@
                 width:w
                 height:h
         ] ifFalse:[
+            asy := async or:[self isView not].
+            asy ifFalse:[
+                self catchExpose
+            ].
             device
                 copyFromId:id
                 x:srcX
@@ -1224,6 +1252,10 @@
                 gc:gcId
                 width:w
                 height:h.
+            asy ifFalse:[
+                device flush.
+                self waitForExpose
+            ]
         ]
     ]
 
@@ -1315,29 +1347,32 @@
 displayArcX:x y:y width:w height:h from:startAngle angle:angle
     "draw an arc; apply transformation if nonNil"
 
-    |pX pY nW nH sA a|
+    |pX pY nW nH sA a pO pC|
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
-	nW := transformation applyScaleX:w.
-	nH := transformation applyScaleY:h.
-	nW < 0 ifTrue:[
-	      nW := nW abs.
-	      pX := pX - nW.
-	].
-	nH < 0 ifTrue:[
-	      nH := nH abs.
-	      pY := pY - nH.
-	].
+        pO := transformation transformPoint:x@y.
+        pC := transformation transformPoint:(x+w-1)@(y+h-1).
+        pX := pO x.
+        pY := pO y.
+        nW := pC x - pX + 1.
+        nH := pC y - pY + 1.
+
+        nW < 0 ifTrue:[
+              nW := nW abs.
+              pX := pX - nW.
+        ].
+        nH < 0 ifTrue:[
+              nH := nH abs.
+              pY := pY - nH.
+        ].
     ] ifFalse:[
-	pX := x.
-	pY := y.
-	nW := w.
-	nH := h.
+        pX := x.
+        pY := y.
+        nW := w.
+        nH := h.
     ].
 
     pX := pX rounded.
@@ -1351,14 +1386,14 @@
     a isInteger ifFalse:[a := a asFloat].
 
     device
-	  displayArcX:pX
-		    y:pY
-		width:nW
-	       height:nH
-		 from:sA
-		angle:a
-		   in:drawableId
-		 with:gcId
+          displayArcX:pX
+                    y:pY
+                width:nW
+               height:nH
+                 from:sA
+                angle:a
+                   in:drawableId
+                 with:gcId
 
     "Created: 8.5.1996 / 08:31:30 / cg"
     "Modified: 4.6.1996 / 17:59:28 / cg"
@@ -1377,49 +1412,52 @@
      certain, that the colors are real colors (actually, only for
      noColor or allColor)."
 
-    |realForm pX pY w h nW nH|
+    |realForm pX pY w h nW nH pO pC|
 
     realForm := formToDraw.
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
-
-	transformation noScale ifFalse:[
-	    w := formToDraw width.
-	    h := formToDraw height.
-
-	    nW := (transformation applyScaleX:w) rounded.
-	    nH := (transformation applyScaleY:h) rounded.
-
-	    ((nW ~= w) or:[nH ~= h]) ifTrue:[
-		"/
-		"/ hard case - someone is drawing forms with scaling in effect
-		"/ look if we have a scaled version in our pocket ...
-		"/
-		realForm := nil.
-		CachedScaledForms notNil ifTrue:[
-		    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
-			realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
-		    ]
-		].
-		realForm isNil ifTrue:[
-		    "/
-		    "/ nope - must do the work ...
-		    "/
-		    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
-		    CachedScaledForms isNil ifTrue:[
-			CachedScaledForms := WeakIdentityDictionary new.
-			CachedScales := WeakIdentityDictionary new.
-		    ].
-		    CachedScaledForms at:formToDraw put:realForm.
-		    CachedScales at:formToDraw put:transformation scale.
-		]
-	    ]
-	]
+        pO := transformation transformPoint:x@y.
+        pX := pO x.
+        pY := pO y.
+
+        transformation isNoScale ifFalse:[
+            w := formToDraw width.
+            h := formToDraw height.
+            pC := transformation applyTo:(x+w-1)@(y+h-1).
+            nW := pC x - pX + 1.
+            nH := pC y - pY + 1.
+            "/ nW := (transformation applyScaleX:w) rounded.
+            "/ nH := (transformation applyScaleY:h) rounded.
+
+            ((nW ~= w) or:[nH ~= h]) ifTrue:[
+                "/
+                "/ hard case - someone is drawing forms with scaling in effect
+                "/ look if we have a scaled version in our pocket ...
+                "/
+                realForm := nil.
+                CachedScaledForms notNil ifTrue:[
+                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
+                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
+                    ]
+                ].
+                realForm isNil ifTrue:[
+                    "/
+                    "/ nope - must do the work ...
+                    "/
+                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
+                    CachedScaledForms isNil ifTrue:[
+                        CachedScaledForms := WeakIdentityDictionary new.
+                        CachedScales := WeakIdentityDictionary new.
+                    ].
+                    CachedScaledForms at:formToDraw put:realForm.
+                    CachedScales at:formToDraw put:transformation scale.
+                ]
+            ]
+        ]
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
 
     self displayDeviceForm:realForm x:pX y:pY
@@ -1427,58 +1465,124 @@
     "Modified: 12.4.1997 / 12:47:29 / cg"
 !
 
-displayLineFromX:x0 y:y0 toX:x1 y:y1
+displayLineFrom:p0 to:p1
     "draw a line (with current paint-color); apply transformation if nonNil"
 
-    |pX0 pY0 pX1 pY1 easy fgId bgId|
+    |pX0 pY0 pX1 pY1 easy fgId bgId tp0 tp1|
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
 
     lineStyle == #doubleDashed ifTrue:[
-	"
-	 if bgPaint or paint is not a real color, we have to do it the hard way ...
-	"
-	easy := true.
-	paint isColor ifFalse:[
-	    easy := false
-	] ifTrue:[
-	    fgId := paint colorId.
-	    fgId isNil ifTrue:[
-		easy := false
-	    ]
-	].
-	bgPaint isColor ifFalse:[
-	    easy := false
-	] ifTrue:[
-	    bgId := bgPaint colorId.
-	    bgId isNil ifTrue:[
-		easy := false
-	    ]
-	].
-
-	easy ifTrue:[
-	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
-		device setForeground:fgId background:bgId in:gcId.
-		foreground := paint.
-		background := bgPaint.
-	    ].
-	] ifFalse:[
-	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
-	].
+        "
+         if bgPaint or paint is not a real color, we have to do it the hard way ...
+        "
+        easy := true.
+        paint isColor ifFalse:[
+            easy := false
+        ] ifTrue:[
+            fgId := paint colorId.
+            fgId isNil ifTrue:[
+                easy := false
+            ]
+        ].
+        bgPaint isColor ifFalse:[
+            easy := false
+        ] ifTrue:[
+            bgId := bgPaint colorId.
+            bgId isNil ifTrue:[
+                easy := false
+            ]
+        ].
+
+        easy ifTrue:[
+            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
+                device setForeground:fgId background:bgId in:gcId.
+                foreground := paint.
+                background := bgPaint.
+            ].
+        ] ifFalse:[
+            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
+        ].
     ].
 
     transformation notNil ifTrue:[
-	pX0 := transformation applyToX:x0.
-	pY0 := transformation applyToY:y0.
-	pX1 := transformation applyToX:x1.
-	pY1 := transformation applyToY:y1.
+        tp0 := transformation transformPoint:p0.
+        tp1 := transformation transformPoint:p1.
+        pX0 := tp0 x.
+        pY0 := tp0 y.
+        pX1 := tp1 x.
+        pY1 := tp1 y.
     ] ifFalse:[
-	pX0 := x0.
-	pY0 := y0.
-	pX1 := x1.
-	pY1 := y1
+        pX0 := p0 x.
+        pY0 := p0 y.
+        pX1 := p1 x.
+        pY1 := p1 y
+    ].
+
+    pX0 := pX0 rounded.
+    pY0 := pY0 rounded.
+    pX1 := pX1 rounded.
+    pY1 := pY1 rounded.
+
+    device displayLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId
+!
+
+displayLineFromX:x0 y:y0 toX:x1 y:y1
+    "draw a line (with current paint-color); apply transformation if nonNil"
+
+    |pX0 pY0 pX1 pY1 easy fgId bgId p0 p1|
+
+    gcId isNil ifTrue:[
+        self initGC
+    ].
+
+    lineStyle == #doubleDashed ifTrue:[
+        "
+         if bgPaint or paint is not a real color, we have to do it the hard way ...
+        "
+        easy := true.
+        paint isColor ifFalse:[
+            easy := false
+        ] ifTrue:[
+            fgId := paint colorId.
+            fgId isNil ifTrue:[
+                easy := false
+            ]
+        ].
+        bgPaint isColor ifFalse:[
+            easy := false
+        ] ifTrue:[
+            bgId := bgPaint colorId.
+            bgId isNil ifTrue:[
+                easy := false
+            ]
+        ].
+
+        easy ifTrue:[
+            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
+                device setForeground:fgId background:bgId in:gcId.
+                foreground := paint.
+                background := bgPaint.
+            ].
+        ] ifFalse:[
+            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
+        ].
+    ].
+
+    transformation notNil ifTrue:[
+        p0 := transformation transformPoint:x0@y0.
+        p1 := transformation transformPoint:x1@y1.
+        pX0 := p0 x.
+        pY0 := p0 y.
+        pX1 := p1 x.
+        pY1 := p1 y.
+    ] ifFalse:[
+        pX0 := x0.
+        pY0 := y0.
+        pX1 := x1.
+        pY1 := y1
     ].
 
     pX0 := pX0 rounded.
@@ -1502,57 +1606,62 @@
      (by sending #on: to the colors) before doing so.
      If there is a transformation, the image is scaled as appropiate."
 
-    |w h realForm pX pY nW nH|
+    |w h realForm pX pY nW nH pO pC|
 
     bgPaint isNil ifTrue:[
-	"/
-	"/ actually not an opaque draw
-	"/
-	self displayForm:formToDraw x:x y:y.
-	^ self
+        "/
+        "/ actually not an opaque draw
+        "/
+        self displayForm:formToDraw x:x y:y.
+        ^ self
     ].
 
     realForm := formToDraw.
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
-
-	transformation noScale ifFalse:[
-	    w := formToDraw width.
-	    h := formToDraw height.
-
-	    nW := (transformation applyScaleX:w) rounded.
-	    nH := (transformation applyScaleY:h) rounded.
-
-	    ((nW ~= w) or:[nH ~= h]) ifTrue:[
-		"/
-		"/ hard case - someone is drawing forms with scaling in effect
-		"/ look if we have a scaled version in our pocket ...
-		"/
-		realForm := nil.
-		CachedScaledForms notNil ifTrue:[
-		    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
-			realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
-		    ]
-		].
-		realForm isNil ifTrue:[
-		    "/
-		    "/ nope - must do the work ...
-		    "/
-		    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
-		    CachedScaledForms isNil ifTrue:[
-			CachedScaledForms := WeakIdentityDictionary new.
-			CachedScales := WeakIdentityDictionary new.
-		    ].
-		    CachedScaledForms at:formToDraw put:realForm.
-		    CachedScales at:formToDraw put:transformation scale.
-		]
-	    ]
-	]
+        pO := transformation transformPoint:x@y.
+        pX := pO x.
+        pY := pO y.
+        "/ pX := transformation applyToX:x.
+        "/ pY := transformation applyToY:y.
+
+        transformation isNoScale ifFalse:[
+            w := formToDraw width.
+            h := formToDraw height.
+            pC := transformation applyTo:(x+w-1)@(y+h-1).
+            nW := pX - x + 1.
+            nH := pY - y + 1.
+            "/ nW := (transformation applyScaleX:w) rounded.
+            "/ nH := (transformation applyScaleY:h) rounded.
+
+            ((nW ~= w) or:[nH ~= h]) ifTrue:[
+                "/
+                "/ hard case - someone is drawing forms with scaling in effect
+                "/ look if we have a scaled version in our pocket ...
+                "/
+                realForm := nil.
+                CachedScaledForms notNil ifTrue:[
+                    (CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[
+                        realForm := CachedScaledForms at:formToDraw ifAbsent:nil.
+                    ]
+                ].
+                realForm isNil ifTrue:[
+                    "/
+                    "/ nope - must do the work ...
+                    "/
+                    realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h).
+                    CachedScaledForms isNil ifTrue:[
+                        CachedScaledForms := WeakIdentityDictionary new.
+                        CachedScales := WeakIdentityDictionary new.
+                    ].
+                    CachedScaledForms at:formToDraw put:realForm.
+                    CachedScales at:formToDraw put:transformation scale.
+                ]
+            ]
+        ]
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
 
     self displayDeviceOpaqueForm:realForm x:pX y:pY
@@ -1593,17 +1702,18 @@
 displayPointX:x y:y
     "draw a point (with current paint-color); apply transformation if nonNil"
 
-    |pX pY|
+    |pX pY pO|
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
+        pO := transformation transformPoint:x@y.
+        pX := pO x.
+        pY := pO y.
     ] ifFalse:[
-	pX := x.
-	pY := y
+        pX := x.
+        pY := y
     ].
     pX := pX rounded.
     pY := pY rounded.
@@ -1621,7 +1731,7 @@
         self initGC
     ].
     transformation notNil ifTrue:[
-        newPolygon := aPolygon collect:[:point | transformation applyTo:point].
+        newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
     ] ifFalse:[
         newPolygon := aPolygon
     ].
@@ -1640,63 +1750,69 @@
     "draw a rectangle (with current paint-color).
      If transformation is nonNil, drawing is in logical coordinates."
 
-    |pX pY nW nH easy fgId bgId|
+    |pX pY nW nH easy fgId bgId pO pC|
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
 
     lineStyle == #doubleDashed ifTrue:[
-	"
-	 if bgPaint or paint is not a real color, we have to do it the hard way ...
-	"
-	easy := true.
-	paint isColor ifFalse:[
-	    easy := false
-	] ifTrue:[
-	    fgId := paint colorId.
-	    fgId isNil ifTrue:[
-		easy := false
-	    ]
-	].
-	bgPaint isColor ifFalse:[
-	    easy := false
-	] ifTrue:[
-	    bgId := bgPaint colorId.
-	    bgId isNil ifTrue:[
-		easy := false
-	    ]
-	].
-
-	easy ifTrue:[
-	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
-		device setForeground:fgId background:bgId in:gcId.
-		foreground := paint.
-		background := bgPaint.
-	    ].
-	] ifFalse:[
-	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
-	].
+        "
+         if bgPaint or paint is not a real color, we have to do it the hard way ...
+        "
+        easy := true.
+        paint isColor ifFalse:[
+            easy := false
+        ] ifTrue:[
+            fgId := paint colorId.
+            fgId isNil ifTrue:[
+                easy := false
+            ]
+        ].
+        bgPaint isColor ifFalse:[
+            easy := false
+        ] ifTrue:[
+            bgId := bgPaint colorId.
+            bgId isNil ifTrue:[
+                easy := false
+            ]
+        ].
+
+        easy ifTrue:[
+            ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
+                device setForeground:fgId background:bgId in:gcId.
+                foreground := paint.
+                background := bgPaint.
+            ].
+        ] ifFalse:[
+            'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
+        ].
     ].
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
-	nW := transformation applyScaleX:w.
-	nH := transformation applyScaleY:h.
-	nW < 0 ifTrue:[
-	      nW := nW abs.
-	      pX := pX - nW.
-	].
-	nH < 0 ifTrue:[
-	      nH := nH abs.
-	      pY := pY - nH.
-	].
+        pO := transformation transformPoint:x@y.
+        pC := transformation transformPoint:(x+w-1)@(y+h-1).
+        pX := pO x.
+        pY := pO y.
+        nW := pC x - pX + 1.
+        nH := pC y - pY + 1.
+"/        pX := transformation applyToX:x.
+"/        pY := transformation applyToY:y.
+"/        nW := transformation applyScaleX:w.
+"/        nH := transformation applyScaleY:h.
+        nW < 0 ifTrue:[
+              nW := nW abs.
+              pX := pX - nW.
+        ].
+        nH < 0 ifTrue:[
+              nH := nH abs.
+              pY := pY - nH.
+        ].
     ] ifFalse:[
-	pX := x.
-	pY := y.
-	nW := w.
-	nH := h
+        pX := x.
+        pY := y.
+        nW := w.
+        nH := h
     ].
 
     pX := pX rounded.
@@ -1710,10 +1826,10 @@
      I'm not certain if is the right thing to do ...
     "
     device displayRectangleX:pX
-			   y:pY
-		       width:(nW - 1)
-		      height:(nH - 1)
-			  in:drawableId with:gcId
+                           y:pY
+                       width:(nW - 1)
+                      height:(nH - 1)
+                          in:drawableId with:gcId
 
     "Modified: 10.1.1997 / 17:46:41 / cg"
 !
@@ -1949,14 +2065,15 @@
      noColor or allColor).
      The origins coordinate is transformed, but the image itself is unscaled."
 
-    |pX pY|
+    |pX pY pO|
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
+        pO := transformation transformPoint:(x@y).
+        pX := pO x.
+        pY := pO y.
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
 
     self displayDeviceForm:formToDraw x:pX y:pY
@@ -1972,14 +2089,15 @@
      settings are ignored and the form is drawn as-is (opaque).
      The origins coordinate is transformed, but the image itself is unscaled."
 
-    |pX pY|
+    |pX pY pO|
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
+        pO := transformation transformPoint:(x@y).
+        pX := pO x.
+        pY := pO y.
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
 
     self displayDeviceOpaqueForm:formToDraw x:pX y:pY
@@ -1991,14 +2109,15 @@
     "draw a substring at the transformed coordinate x/y but do not scale the font.
      Draw foreground pixels in paint-color, background pixels in bgPaint color."
 
-    |pX pY|
+    |pX pY pO|
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
+        pO := transformation transformPoint:(x@y).
+        pX := pO x.
+        pY := pO y.
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
     self displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:pX y:pY
 !
@@ -2007,14 +2126,15 @@
     "draw a string at the transformed coordinate x/y but do not scale the font.
      Draw foreground pixels in paint-color, background pixels in bgPaint color."
 
-    |pX pY|
+    |pX pY pO|
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
+        pO := transformation transformPoint:(x@y).
+        pX := pO x.
+        pY := pO y.
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
     self displayDeviceOpaqueString:aString from:1 to:(aString size) in:font x:pX y:pY
 !
@@ -2023,14 +2143,15 @@
     "draw a substring at the transformed coordinate x/y but do not scale the font.
      draw foreground-pixels only (in current paint-color), leaving background as-is."
 
-    |pX pY|
+    |pX pY pO|
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
+        pO := transformation transformPoint:(x@y).
+        pX := pO x.
+        pY := pO y.
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
     self displayDeviceString:aString from:index1 to:index2 in:font x:pX y:pY
 !
@@ -2039,14 +2160,15 @@
     "draw a string at the transformed coordinate x/y but do not scale the font.
      draw foreground-pixels only (in current paint-color), leaving background as-is."
 
-    |pX pY|
+    |pX pY pO|
 
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
+        pO := transformation transformPoint:(x@y).
+        pX := pO x.
+        pY := pO y.
     ] ifFalse:[
-	pX := x.
-	pY := y.
+        pX := x.
+        pY := y.
     ].
     self displayDeviceString:aString from:1 to:(aString size) in:font x:pX y:pY
 ! !
@@ -3385,29 +3507,31 @@
 fillArcX:x y:y width:w height:h from:startAngle angle:angle
     "draw a filled arc; apply transformation if nonNil"
 
-    |pX pY nW nH sA a|
+    |pX pY nW nH sA a pO pC|
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
-	nW := transformation applyScaleX:w.
-	nH := transformation applyScaleY:h.
-	nW < 0 ifTrue:[
-	      nW := nW abs.
-	      pX := pX - nW.
-	].
-	nH < 0 ifTrue:[
-	      nH := nH abs.
-	      pY := pY - nH.
-	].
+        pO := transformation transformPoint:x@y.
+        pC := transformation transformPoint:(x+w-1)@(y+h-1).
+        pX := pO x.
+        pY := pO y.
+        nW := pC x - pX + 1.
+        nH := pC y - pY + 1.
+        nW < 0 ifTrue:[
+              nW := nW abs.
+              pX := pX - nW.
+        ].
+        nH < 0 ifTrue:[
+              nH := nH abs.
+              pY := pY - nH.
+        ].
     ] ifFalse:[
-	pX := x.
-	pY := y.
-	nW := w.
-	nH := h.
+        pX := x.
+        pY := y.
+        nW := w.
+        nH := h.
     ].
 
     pX := pX rounded.
@@ -3421,14 +3545,14 @@
     a isInteger ifFalse:[a := a asFloat].
 
     device
-	  fillArcX:pX
-		 y:pY
-	     width:nW
-	    height:nH
-	      from:sA
-	     angle:a
-		in:drawableId
-	      with:gcId
+          fillArcX:pX
+                 y:pY
+             width:nW
+            height:nH
+              from:sA
+             angle:a
+                in:drawableId
+              with:gcId
 
     "Created: 8.5.1996 / 08:29:45 / cg"
     "Modified: 4.6.1996 / 17:58:21 / cg"
@@ -3440,52 +3564,55 @@
     |newPolygon|
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
     transformation notNil ifTrue:[
-	newPolygon := aPolygon collect:[:point | transformation applyTo:point].
+        newPolygon := aPolygon collect:[:point | transformation transformPoint:point].
     ] ifFalse:[
-	newPolygon := aPolygon
+        newPolygon := aPolygon
     ].
     (newPolygon contains:[:p |
-	(p isPoint not
-	or:[(p x class ~~ SmallInteger)
-	or:[(p y class ~~ SmallInteger)]])
+        (p isPoint not
+        or:[(p x class ~~ SmallInteger)
+        or:[(p y class ~~ SmallInteger)]])
      ]) ifTrue:[
-	newPolygon := newPolygon collect:[:p | p asPoint rounded]
+        newPolygon := newPolygon collect:[:p | p asPoint rounded]
     ].
     device
-	fillPolygon:newPolygon
-		 in:drawableId
-	       with:gcId
+        fillPolygon:newPolygon
+                 in:drawableId
+               with:gcId
 !
 
 fillRectangleX:x y:y width:w height:h
     "draw a filled rectangle; apply transformation if nonNil"
 
-    |pX pY nW nH|
+    |pX pY nW nH pO pC|
 
     gcId isNil ifTrue:[
-	self initGC
+        self initGC
     ].
     transformation notNil ifTrue:[
-	pX := transformation applyToX:x.
-	pY := transformation applyToY:y.
-	nW := transformation applyScaleX:w.
-	nH := transformation applyScaleY:h.
-	nW < 0 ifTrue:[
-	      nW := nW abs.
-	      pX := pX - nW.
-	].
-	nH < 0 ifTrue:[
-	      nH := nH abs.
-	      pY := pY - nH.
-	].
+        pO := transformation transformPoint:x@y.
+        pC := transformation transformPoint:(x+w-1)@(y+h-1).
+        pX := pO x.
+        pY := pO y.
+        nW := pC x - pX + 1.
+        nH := pC y - pY + 1.
+
+        nW < 0 ifTrue:[
+              nW := nW abs.
+              pX := pX - nW.
+        ].
+        nH < 0 ifTrue:[
+              nH := nH abs.
+              pY := pY - nH.
+        ].
     ] ifFalse:[
-	pX := x.
-	pY := y.
-	nW := w.
-	nH := h.
+        pX := x.
+        pY := y.
+        nW := w.
+        nH := h.
     ].
     pX := pX rounded.
     pY := pY rounded.
@@ -3493,11 +3620,11 @@
     nH := nH rounded.
 
     device
-	fillRectangleX:pX
-		     y:pY
-		 width:nW
-		height:nH
-		    in:drawableId with:gcId
+        fillRectangleX:pX
+                     y:pY
+                 width:nW
+                height:nH
+                    in:drawableId with:gcId
 
     "Modified: 4.6.1996 / 17:58:49 / cg"
 ! !
@@ -3553,6 +3680,8 @@
     "Modified: 19.3.1997 / 11:07:52 / cg"
 !
 
+
+
 destroy
     |id|
 
@@ -3579,6 +3708,10 @@
     ].
 !
 
+
+
+
+
 initGC
     "since we do not need a gc-object for the drawable until something is
      really drawn, none is created.
@@ -3730,6 +3863,8 @@
     "Modified: 28.10.1996 / 13:25:02 / cg"
 !
 
+
+
 releaseGC
     "destroy the associated device GC resource - can be done to be nice to the
      display if you know that you are done with a drawable."
@@ -3918,6 +4053,8 @@
     Lobby registerChange:self.
 !
 
+
+
 createRootWindowFor:aView
     drawableId := device rootWindowFor:aView.
     drawableType := #window.