scaling
authorclaus
Fri, 28 Oct 1994 04:14:43 +0100
changeset 76 db983d8d7e53
parent 75 a3002e14b6bd
child 77 da4678fae5c8
scaling
GC.st
GraphicsContext.st
--- a/GC.st	Fri Oct 28 04:14:34 1994 +0100
+++ b/GC.st	Fri Oct 28 04:14:43 1994 +0100
@@ -11,7 +11,7 @@
 "
 
 Object subclass:#GraphicsContext
-       instanceVariableNames:'foreground background paint bgPaint
+       instanceVariableNames:'paint bgPaint
 			      function font
 			      lineStyle lineWidth
 			      joinStyle capStyle
@@ -25,7 +25,7 @@
 COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/Attic/GC.st,v 1.11 1994-10-10 02:30:38 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/GC.st,v 1.12 1994-10-28 03:14:43 claus Exp $
 '!
 
 !GraphicsContext class methodsFor:'documentation'!
@@ -46,7 +46,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview/Attic/GC.st,v 1.11 1994-10-10 02:30:38 claus Exp $
+$Header: /cvs/stx/stx/libview/Attic/GC.st,v 1.12 1994-10-28 03:14:43 claus Exp $
 "
 !
 
@@ -56,17 +56,11 @@
     both windows and printed pages (i.e. printers) are inheriting from
     this class (even drawables not at all associated with any device would do so).
 
-    Drawing is done somewhat silly (due to being both backward compatible
-    and supporting ST-80 messages). The paint/bgPaint instance variables are
-    the colors to draw with (drawing is donw as 'paint on bgPaint'.
-    both can be dithered colors.
-
-    The actual drawing colors used are foreground and background; these are the
-    real (i.e. non dithered) colors supported by the device. Direct access to 
-    fg/bg is discouraged, since in the future, these will be totally replaced by
-    paint/bgPaint (there are some operation, for which dithered drawing is not (yet)
-    supported - for example bitmap drawing cannot currently handle a dithered
-    background color.
+    Drawing is done in paint/bgPaint colors, which can be true colors (i.e.
+    directly supported by the underlying hardware) or simulated colors
+    (i.e. dithered colors or images).
+    The paint/bgPaint instance variables are set to the logical colors,
+    device specific drawable may like to keep actual colors in addition.
 
     The transformation instance variable is typically nil, for a 1-to-1
     coordinate mapping (i.e. x/y coordinates are pixels in the drawable).
@@ -84,12 +78,10 @@
 
 	paint           <Color>         the paint used for drawing
 	bgPaint         <Color>         the background used for drawing texts and bitmaps
-	foreground      <Color>         the device foreground color used for drawing
-	background      <Color>         the device background color used for drawing
 	function        <Symbol>        the drawing function (i.e. #copy, #or, #xor ...)
 					- not all Drawables support every function
 					(i.e. paper only allows #copy)
-	font            <Font>          the font currently used for drawing
+	font            <Font>          the current font to be used for drawing
 	lineStyle       <Symbol>        the lineStyle (i.e. #solid, #dashed, #doubleDashed)
 	lineWidth       <SmallInteger>  the lineWidth (device dependent, usually pixels)
 	joinStyle       <Symbol>        the style in which lines (in polygons)
@@ -198,8 +190,8 @@
 initialize
     "set up some useful default values"
 
-    paint := foreground := Black.
-    bgPaint := background := White.
+    paint := Black.
+    bgPaint := White.
     function := #copy.
     lineWidth := 1.
     lineStyle := #solid.
@@ -252,36 +244,6 @@
     ^ self subclassResponsibility
 !
 
-foreground
-    "return the current foreground drawing color.
-     OBSOLETE: use paint:/paint:on:"
-
-    ^ foreground
-!
-
-foreground:aColor
-    "set the drawing foreground color.
-     aColor must be a real (i.e. device-) color.
-     OBSOLETE: use paint:/paint:on:"
-
-    foreground := aColor
-!
-
-background
-    "return the current background drawing color.
-     OBSOLETE: use paint:/paint:on:"
-
-    ^ background
-!
-
-background:aColor
-    "set the drawing background color.
-     aColor  must be a real (i.e. device-) color.
-     OBSOLETE: use paint:/paint:on:"
-
-    background := aColor
-!
-
 function
     "return the current drawing function"
 
@@ -294,23 +256,6 @@
     ^ self subclassResponsibility
 !
 
-foreground:fgColor background:bgColor 
-    "set both foreground and background colors.
-     OBSOLETE: use paint:/paint:on:"
-
-    self foreground:fgColor.
-    self background:bgColor
-!
-
-foreground:fgColor background:bgColor function:f
-    "set foreground, background colors and function.
-     OBSOLETE: use paint:/paint:on:"
-
-    self foreground:fgColor.
-    self background:bgColor.
-    self function:f
-!
-
 lineWidth
     "return the current drawing linewidth"
 
@@ -386,12 +331,24 @@
     ^ self subclassResponsibility
 !
 
+clipRect
+    "return the drawing clip-rectangle"
+
+    ^ self subclassResponsibility
+!
+
 clipRect:aRectangle
     "set the drawing clip-rectangle"
 
     ^ self subclassResponsibility
 !
 
+clippingBounds
+    "for ST-80 compatibility"
+
+    ^ self clipRect
+!
+
 graphicsContext
     "for ST-80 compatibility"
 
@@ -416,6 +373,18 @@
     'pattern drawing not implemented' errorPrintNL.
 
     aBlock value
+!
+
+transformation 
+    "return the transformation"
+
+    ^ transformation
+!
+
+transformation:aTransformation 
+    "set the transformation"
+
+    transformation := aTransformation
 ! !
 
 !GraphicsContext methodsFor:'ST-80 displaying'!
@@ -436,10 +405,10 @@
 displayPolyline:aPolygon
     "draw a polygon - ST-80 compatibility"
 
-    |poly|
+"/    |poly|
 
-    poly := aPolygon collect:[:pount | pount rounded].
-    self displayPolygon:poly 
+"/    poly := aPolygon collect:[:pount | pount rounded].
+    ^ self displayPolygon:aPolygon 
 !
 
 displayArc:origin radius:radius from:startAngle angle:angle
@@ -494,6 +463,39 @@
     self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:aGC width height:aGC height
 ! !
 
+!GraphicsContext methodsFor:'drawing in device coordinates'!
+
+fillDeviceRectangleX:x y:y width:w height:h with:aPattern
+    "fill the rectangular area in the receiver with aPattern,
+     which may be a Form or Color. Use device coordinates."
+
+    self withPattern:aPattern do:[
+	self fillDeviceRectangleX:x y:y width:w height:h
+    ]
+!
+
+fillDeviceRectangleX:x y:y width:w height:h
+    "fill a rectangle with current paint color (device coordinates)"
+
+    |sav|
+
+    sav := transformation.
+    transformation := nil.
+    self fillRectangleX:x y:y width:w height:h.
+    transformation := sav
+!
+
+displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2
+    "draw a line in device coordinates"
+
+    |sav|
+
+    sav := transformation.
+    transformation := nil.
+    self displayLineFromX:x1 y:y1 toX:x2 y:y2.
+    transformation := sav
+! !
+
 !GraphicsContext methodsFor:'filling'!
 
 fillRectangle:aRectangle
@@ -505,15 +507,6 @@
 		 height:(aRectangle height)
 !
 
-fillDeviceRectangleX:x y:y width:w height:h with:aPattern
-    "fill the rectangular area in the receiver with aPattern,
-     which may be a Form or Color. Use device coordinates."
-
-    self withPattern:aPattern do:[
-	self fillDeviceRectangleX:x y:y width:w height:h
-    ]
-!
-
 fillArc:origin radius:r from:startAngle angle:angle
     "draw a filled arc around a point"
 
@@ -555,12 +548,6 @@
     ^ self subclassResponsibility
 !
 
-fillDeviceRectangleX:x y:y width:w height:h
-    "fill a rectangle with current paint color (device coordinates)"
-
-    ^ self subclassResponsibility
-!
-
 fillArcX:x y:y w:w h:h from:start angle:angle
     "fill an arc with current paint color"
 
--- a/GraphicsContext.st	Fri Oct 28 04:14:34 1994 +0100
+++ b/GraphicsContext.st	Fri Oct 28 04:14:43 1994 +0100
@@ -11,7 +11,7 @@
 "
 
 Object subclass:#GraphicsContext
-       instanceVariableNames:'foreground background paint bgPaint
+       instanceVariableNames:'paint bgPaint
 			      function font
 			      lineStyle lineWidth
 			      joinStyle capStyle
@@ -25,7 +25,7 @@
 COPYRIGHT (c) 1992 by Claus Gittinger
 	      All Rights Reserved
 
-$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.11 1994-10-10 02:30:38 claus Exp $
+$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.12 1994-10-28 03:14:43 claus Exp $
 '!
 
 !GraphicsContext class methodsFor:'documentation'!
@@ -46,7 +46,7 @@
 
 version
 "
-$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.11 1994-10-10 02:30:38 claus Exp $
+$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.12 1994-10-28 03:14:43 claus Exp $
 "
 !
 
@@ -56,17 +56,11 @@
     both windows and printed pages (i.e. printers) are inheriting from
     this class (even drawables not at all associated with any device would do so).
 
-    Drawing is done somewhat silly (due to being both backward compatible
-    and supporting ST-80 messages). The paint/bgPaint instance variables are
-    the colors to draw with (drawing is donw as 'paint on bgPaint'.
-    both can be dithered colors.
-
-    The actual drawing colors used are foreground and background; these are the
-    real (i.e. non dithered) colors supported by the device. Direct access to 
-    fg/bg is discouraged, since in the future, these will be totally replaced by
-    paint/bgPaint (there are some operation, for which dithered drawing is not (yet)
-    supported - for example bitmap drawing cannot currently handle a dithered
-    background color.
+    Drawing is done in paint/bgPaint colors, which can be true colors (i.e.
+    directly supported by the underlying hardware) or simulated colors
+    (i.e. dithered colors or images).
+    The paint/bgPaint instance variables are set to the logical colors,
+    device specific drawable may like to keep actual colors in addition.
 
     The transformation instance variable is typically nil, for a 1-to-1
     coordinate mapping (i.e. x/y coordinates are pixels in the drawable).
@@ -84,12 +78,10 @@
 
 	paint           <Color>         the paint used for drawing
 	bgPaint         <Color>         the background used for drawing texts and bitmaps
-	foreground      <Color>         the device foreground color used for drawing
-	background      <Color>         the device background color used for drawing
 	function        <Symbol>        the drawing function (i.e. #copy, #or, #xor ...)
 					- not all Drawables support every function
 					(i.e. paper only allows #copy)
-	font            <Font>          the font currently used for drawing
+	font            <Font>          the current font to be used for drawing
 	lineStyle       <Symbol>        the lineStyle (i.e. #solid, #dashed, #doubleDashed)
 	lineWidth       <SmallInteger>  the lineWidth (device dependent, usually pixels)
 	joinStyle       <Symbol>        the style in which lines (in polygons)
@@ -198,8 +190,8 @@
 initialize
     "set up some useful default values"
 
-    paint := foreground := Black.
-    bgPaint := background := White.
+    paint := Black.
+    bgPaint := White.
     function := #copy.
     lineWidth := 1.
     lineStyle := #solid.
@@ -252,36 +244,6 @@
     ^ self subclassResponsibility
 !
 
-foreground
-    "return the current foreground drawing color.
-     OBSOLETE: use paint:/paint:on:"
-
-    ^ foreground
-!
-
-foreground:aColor
-    "set the drawing foreground color.
-     aColor must be a real (i.e. device-) color.
-     OBSOLETE: use paint:/paint:on:"
-
-    foreground := aColor
-!
-
-background
-    "return the current background drawing color.
-     OBSOLETE: use paint:/paint:on:"
-
-    ^ background
-!
-
-background:aColor
-    "set the drawing background color.
-     aColor  must be a real (i.e. device-) color.
-     OBSOLETE: use paint:/paint:on:"
-
-    background := aColor
-!
-
 function
     "return the current drawing function"
 
@@ -294,23 +256,6 @@
     ^ self subclassResponsibility
 !
 
-foreground:fgColor background:bgColor 
-    "set both foreground and background colors.
-     OBSOLETE: use paint:/paint:on:"
-
-    self foreground:fgColor.
-    self background:bgColor
-!
-
-foreground:fgColor background:bgColor function:f
-    "set foreground, background colors and function.
-     OBSOLETE: use paint:/paint:on:"
-
-    self foreground:fgColor.
-    self background:bgColor.
-    self function:f
-!
-
 lineWidth
     "return the current drawing linewidth"
 
@@ -386,12 +331,24 @@
     ^ self subclassResponsibility
 !
 
+clipRect
+    "return the drawing clip-rectangle"
+
+    ^ self subclassResponsibility
+!
+
 clipRect:aRectangle
     "set the drawing clip-rectangle"
 
     ^ self subclassResponsibility
 !
 
+clippingBounds
+    "for ST-80 compatibility"
+
+    ^ self clipRect
+!
+
 graphicsContext
     "for ST-80 compatibility"
 
@@ -416,6 +373,18 @@
     'pattern drawing not implemented' errorPrintNL.
 
     aBlock value
+!
+
+transformation 
+    "return the transformation"
+
+    ^ transformation
+!
+
+transformation:aTransformation 
+    "set the transformation"
+
+    transformation := aTransformation
 ! !
 
 !GraphicsContext methodsFor:'ST-80 displaying'!
@@ -436,10 +405,10 @@
 displayPolyline:aPolygon
     "draw a polygon - ST-80 compatibility"
 
-    |poly|
+"/    |poly|
 
-    poly := aPolygon collect:[:pount | pount rounded].
-    self displayPolygon:poly 
+"/    poly := aPolygon collect:[:pount | pount rounded].
+    ^ self displayPolygon:aPolygon 
 !
 
 displayArc:origin radius:radius from:startAngle angle:angle
@@ -494,6 +463,39 @@
     self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:aGC width height:aGC height
 ! !
 
+!GraphicsContext methodsFor:'drawing in device coordinates'!
+
+fillDeviceRectangleX:x y:y width:w height:h with:aPattern
+    "fill the rectangular area in the receiver with aPattern,
+     which may be a Form or Color. Use device coordinates."
+
+    self withPattern:aPattern do:[
+	self fillDeviceRectangleX:x y:y width:w height:h
+    ]
+!
+
+fillDeviceRectangleX:x y:y width:w height:h
+    "fill a rectangle with current paint color (device coordinates)"
+
+    |sav|
+
+    sav := transformation.
+    transformation := nil.
+    self fillRectangleX:x y:y width:w height:h.
+    transformation := sav
+!
+
+displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2
+    "draw a line in device coordinates"
+
+    |sav|
+
+    sav := transformation.
+    transformation := nil.
+    self displayLineFromX:x1 y:y1 toX:x2 y:y2.
+    transformation := sav
+! !
+
 !GraphicsContext methodsFor:'filling'!
 
 fillRectangle:aRectangle
@@ -505,15 +507,6 @@
 		 height:(aRectangle height)
 !
 
-fillDeviceRectangleX:x y:y width:w height:h with:aPattern
-    "fill the rectangular area in the receiver with aPattern,
-     which may be a Form or Color. Use device coordinates."
-
-    self withPattern:aPattern do:[
-	self fillDeviceRectangleX:x y:y width:w height:h
-    ]
-!
-
 fillArc:origin radius:r from:startAngle angle:angle
     "draw a filled arc around a point"
 
@@ -555,12 +548,6 @@
     ^ self subclassResponsibility
 !
 
-fillDeviceRectangleX:x y:y width:w height:h
-    "fill a rectangle with current paint color (device coordinates)"
-
-    ^ self subclassResponsibility
-!
-
 fillArcX:x y:y w:w h:h from:start angle:angle
     "fill an arc with current paint color"