--- a/GraphicsContext.st Sat Jul 16 18:24:24 2016 +0200
+++ b/GraphicsContext.st Tue Jul 19 21:44:36 2016 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1992 by Claus Gittinger
All Rights Reserved
@@ -11,6 +9,8 @@
other person. No title to or ownership of the software is
hereby transferred.
"
+'From Smalltalk/X, Version:7.1.0.0 on 19-07-2016 at 15:53:05' !
+
"{ Package: 'stx:libview' }"
"{ NameSpace: Smalltalk }"
@@ -60,7 +60,7 @@
(see instance creation methods of WindowingTransformation, and examples
in 'doc/coding').
- All drawing is defined upon a few basic drawing methods, which must be
+ All drawing is defined upon a few basic drawing methods, which must be
implemented by subclasses (some subclasses also redefine the others for
more performance)
@@ -109,7 +109,7 @@
examples
"
drawing uses a paint color (which may be a dithered one) which is
- used like a `pen'.
+ used like a `pen'.
A few drawing operations (opaqueForm and opaqueString drawing)
use two colors, the paint and a backgroundPaint. For example,
normal string drawing (#displayString:...) only draws the font's
@@ -118,26 +118,26 @@
The bgPaint can be changed with #backgroundPaint: or #paint:on: (which modifies both).
lets try it in a view:
- [exBegin]
- |v|
-
- v := View new.
- v openAndWait.
-
- v paint:(Color red).
- v displayString:'hello' x:10 y:50
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new.
+ v openAndWait.
+
+ v paint:(Color red).
+ v displayString:'hello' x:10 y:50
+ [exEnd]
the same using opaque drawing:
- [exBegin]
- |v|
-
- v := View new.
- v openAndWait.
-
- v paint:(Color red) on:(Color yellow).
- v displayOpaqueString:'hello' x:10 y:50
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new.
+ v openAndWait.
+
+ v paint:(Color red) on:(Color yellow).
+ v displayOpaqueString:'hello' x:10 y:50
+ [exEnd]
@@ -145,197 +145,197 @@
(dashed lines). The look of the line is controlled by joinStyle, capStyle,
lineWidth and lineStyle.
`lineStyle' can be one of #solid, #dashed, #doubleDashed
- where: #solid - is for solid lines, drawn with the current paint color
-
- #dashed - for dashed lines, where only the on-dashes are drawn
- with the current paint color
-
- #doubleDashed - dashed lines, draws on-dashes with paint color,
- off-dashes with bgPaint
+ where: #solid - is for solid lines, drawn with the current paint color
+
+ #dashed - for dashed lines, where only the on-dashes are drawn
+ with the current paint color
+
+ #doubleDashed - dashed lines, draws on-dashes with paint color,
+ off-dashes with bgPaint
for example:
- [exBegin]
- |v|
-
- v := View new.
- v openAndWait.
-
- v paint:(Color red) on:(Color blue).
- v displayLineFrom:(10@10) to:(90@90).
-
- v lineStyle:#dashed.
- v displayLineFrom:(90@10) to:(10@90).
-
- v lineStyle:#doubleDashed.
- v displayRectangle:((5@5) corner:(95@95)).
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new.
+ v openAndWait.
+
+ v paint:(Color red) on:(Color blue).
+ v displayLineFrom:(10@10) to:(90@90).
+
+ v lineStyle:#dashed.
+ v displayLineFrom:(90@10) to:(10@90).
+
+ v lineStyle:#doubleDashed.
+ v displayRectangle:((5@5) corner:(95@95)).
+ [exEnd]
changing the line-width:
- [exBegin]
- |v|
-
- v := View new.
- v openAndWait.
-
- v paint:(Color red).
- v displayLineFrom:(20@20) to:(80@80).
-
- v lineWidth:5.
- v displayLineFrom:(80@20) to:(20@80).
-
- v lineWidth:8.
- v displayRectangle:((5@5) corner:(95@95)).
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new.
+ v openAndWait.
+
+ v paint:(Color red).
+ v displayLineFrom:(20@20) to:(80@80).
+
+ v lineWidth:5.
+ v displayLineFrom:(80@20) to:(20@80).
+
+ v lineWidth:8.
+ v displayRectangle:((5@5) corner:(95@95)).
+ [exEnd]
with wide lines, the corners (of polygons or rectangles) can be
one of the joinStyles: #miter, #bevel, #round. The default is #miter.
- [exBegin]
- |v|
-
- v := View new extent:200@200.
- v openAndWait.
-
- v lineWidth:15.
- v paint:(Color red).
-
- v displayRectangle:((65@65) corner:(135@135)).
-
- v joinStyle:#bevel.
- v displayRectangle:((45@45) corner:(155@155)).
-
- v joinStyle:#round.
- v displayRectangle:((25@25) corner:(175@175)).
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new extent:200@200.
+ v openAndWait.
+
+ v lineWidth:15.
+ v paint:(Color red).
+
+ v displayRectangle:((65@65) corner:(135@135)).
+
+ v joinStyle:#bevel.
+ v displayRectangle:((45@45) corner:(155@155)).
+
+ v joinStyle:#round.
+ v displayRectangle:((25@25) corner:(175@175)).
+ [exEnd]
the endPoints look is controlled with capStyle;
possible values are: #notLast, #butt, #round, #projecting.
- The default is #butt.
+ The default is #butt.
#notLast is mostly useful when exoring (inverting): it will not draw the
endPoint, to allow another line to join the previous line without inverting
this point twice. (See the X manual for more info).
- [exBegin]
- |v|
-
- v := View new extent:200@200.
- v openAndWait.
-
- v lineWidth:15.
- v paint:(Color red).
-
- v displayLineFrom:(25@25) to:(175@25).
-
- v capStyle:#round.
- v displayLineFrom:(25@55) to:(175@55).
-
- v capStyle:#projecting.
- v displayLineFrom:(25@85) to:(175@85).
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new extent:200@200.
+ v openAndWait.
+
+ v lineWidth:15.
+ v paint:(Color red).
+
+ v displayLineFrom:(25@25) to:(175@25).
+
+ v capStyle:#round.
+ v displayLineFrom:(25@55) to:(175@55).
+
+ v capStyle:#projecting.
+ v displayLineFrom:(25@85) to:(175@85).
+ [exEnd]
You can use a bitmap as a point color:
(this may be slow on some graphics devices, though)
- [exBegin]
- |v|
-
- v := View new extent:200@200.
- v openAndWait.
-
- v lineWidth:15.
- v paint:(Image fromFile:'granite_small.tiff').
-
- v displayLineFrom:(25@25) to:(175@25).
-
- v capStyle:#round.
- v displayLineFrom:(25@55) to:(175@55).
-
- v capStyle:#projecting.
- v displayLineFrom:(25@85) to:(175@85).
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new extent:200@200.
+ v openAndWait.
+
+ v lineWidth:15.
+ v paint:(Image fromFile:'granite_small.tiff').
+
+ v displayLineFrom:(25@25) to:(175@25).
+
+ v capStyle:#round.
+ v displayLineFrom:(25@55) to:(175@55).
+
+ v capStyle:#projecting.
+ v displayLineFrom:(25@85) to:(175@85).
+ [exEnd]
all views support a translation and scale, so you can draw in another
coordinate system:
- [exBegin]
- |v|
-
- v := View new extent:200@200.
- v openAndWait.
-
- v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
-
- v scale:(2@2); translation:50.
- v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
-
- v scale:(0.5@0.5); translation:0.
- v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new extent:200@200.
+ v openAndWait.
+
+ v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
+
+ v scale:(2@2); translation:50.
+ v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
+
+ v scale:(0.5@0.5); translation:0.
+ v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
+ [exEnd]
if scaling is on, it is often useful to be able to draw individual
things unscaled - this still translates the position, but
uses the unscaled font (for example, to draw strings in a graphic):
- [exBegin]
- |v|
-
- v := View new extent:200@200.
- v openAndWait.
-
- v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
- v displayString:'hello' x:50 y:40.
-
- v scale:(2@4).
- v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
- v displayUnscaledString:'hello' x:50 y:40.
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new extent:200@200.
+ v openAndWait.
+
+ v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
+ v displayString:'hello' x:50 y:40.
+
+ v scale:(2@4).
+ v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10.
+ v displayUnscaledString:'hello' x:50 y:40.
+ [exEnd]
Filled objects are drawin using the #fillXXX methods; for example,
displayRectangleXXX draws the outline, while fillRectangleXXX draws a
filled one:
- [exBegin]
- |v|
-
- v := View new extent:200@200.
- v openAndWait.
-
- v displayArcIn:(20@20 corner:50@50) from:0 angle:180.
- v paint:Color yellow.
- v fillArcIn:(120@120 corner:150@150) from:0 angle:180.
-
- v paint:Color red.
- v displayCircle:150@50 radius:30.
- v paint:Color blue.
- v fillCircle:50@150 radius:30.
- [exEnd]
+ [exBegin]
+ |v|
+
+ v := View new extent:200@200.
+ v openAndWait.
+
+ v displayArcIn:(20@20 corner:50@50) from:0 angle:180.
+ v paint:Color yellow.
+ v fillArcIn:(120@120 corner:150@150) from:0 angle:180.
+
+ v paint:Color red.
+ v displayCircle:150@50 radius:30.
+ v paint:Color blue.
+ v fillCircle:50@150 radius:30.
+ [exEnd]
polygons:
- [exBegin]
- |v poly1 poly2|
-
- poly1 := OrderedCollection new.
- poly1 add:(10 @ 10).
- poly1 add:(100 @ 50).
- poly1 add:(50 @ 50).
- poly1 add:(20 @ 100).
- poly1 add:(10 @ 100).
-
- poly2 := poly1 copy.
- poly2 add:(poly2 first).
-
- v := View new extent:200@200.
- v openAndWait.
-
- v scale:2.
- v paint:Color red.
- v fillPolygon:poly1.
-
- v scale:1.
- v paint:Color blue.
- v displayPolygon:poly2.
-
- v scale:0.5.
- v paint:Color yellow.
- v fillPolygon:poly1.
-
- [exEnd]
+ [exBegin]
+ |v poly1 poly2|
+
+ poly1 := OrderedCollection new.
+ poly1 add:(10 @ 10).
+ poly1 add:(100 @ 50).
+ poly1 add:(50 @ 50).
+ poly1 add:(20 @ 100).
+ poly1 add:(10 @ 100).
+
+ poly2 := poly1 copy.
+ poly2 add:(poly2 first).
+
+ v := View new extent:200@200.
+ v openAndWait.
+
+ v scale:2.
+ v paint:Color red.
+ v fillPolygon:poly1.
+
+ v scale:1.
+ v paint:Color blue.
+ v displayPolygon:poly2.
+
+ v scale:0.5.
+ v paint:Color yellow.
+ v fillPolygon:poly1.
+
+ [exEnd]
"
! !
@@ -346,27 +346,27 @@
during startup."
DrawingOnClosedDrawableSignal isNil ifTrue:[
- DrawingOnClosedDrawableSignal := Signal new mayProceed:true.
- DrawingOnClosedDrawableSignal nameClass:self message:#drawingOnClosedDrawableSignal.
- DrawingOnClosedDrawableSignal notifierString:'drawing attempt on closed drawable'.
+ DrawingOnClosedDrawableSignal := Signal new mayProceed:true.
+ DrawingOnClosedDrawableSignal nameClass:self message:#drawingOnClosedDrawableSignal.
+ DrawingOnClosedDrawableSignal notifierString:'drawing attempt on closed drawable'.
].
White isNil ifTrue:[
- Color initialize.
-
- Display notNil ifTrue:[
- White := Display whiteColor.
- Black := Display blackColor.
- ] ifFalse:[
- White := Color white.
- Black := Color black.
- ].
-
- Font initialize.
- DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12.
- Display notNil ifTrue:[
- DefaultFont := DefaultFont onDevice:Display
- ]
+ Color initialize.
+
+ Display notNil ifTrue:[
+ White := Display whiteColor.
+ Black := Display blackColor.
+ ] ifFalse:[
+ White := Color white.
+ Black := Color black.
+ ].
+
+ Font initialize.
+ DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12.
+ Display notNil ifTrue:[
+ DefaultFont := DefaultFont onDevice:Display
+ ]
]
"Modified: / 29.1.1998 / 12:56:18 / cg"
@@ -390,7 +390,7 @@
a view in the background, and is not properly synchronized
with the window thread - i.e. the window gets closed by the user,
and the background process continues to draw.
- In this case, the background thread should handle this signal
+ In this case, the background thread should handle this signal
and terminate itself in the handler."
^ DrawingOnClosedDrawableSignal
@@ -401,14 +401,14 @@
v := StandardSystemView new openAndWait.
[
- [true] whileTrue:[
- |x y|
-
- x := Random nextIntegerBetween:0 and:(v width).
- y := Random nextIntegerBetween:0 and:(v height).
- v displayString:'hello' x:x y:y.
- Delay waitForSeconds:0.5.
- ]
+ [true] whileTrue:[
+ |x y|
+
+ x := Random nextIntegerBetween:0 and:(v width).
+ y := Random nextIntegerBetween:0 and:(v height).
+ v displayString:'hello' x:x y:y.
+ Delay waitForSeconds:0.5.
+ ]
] fork.
"
"demonstration2: (no error if closed by the windowManager):
@@ -417,18 +417,18 @@
v := StandardSystemView new openAndWait.
[
- v class drawingOnClosedDrawableSignal handle:[:ex |
- ex return
- ] do:[
- [true] whileTrue:[
- |x y|
-
- x := Random nextIntegerBetween:0 and:(v width).
- y := Random nextIntegerBetween:0 and:(v height).
- v displayString:'hello' x:x y:y.
- Delay waitForSeconds:0.5.
- ]
- ]
+ v class drawingOnClosedDrawableSignal handle:[:ex |
+ ex return
+ ] do:[
+ [true] whileTrue:[
+ |x y|
+
+ x := Random nextIntegerBetween:0 and:(v width).
+ y := Random nextIntegerBetween:0 and:(v height).
+ v displayString:'hello' x:x y:y.
+ Delay waitForSeconds:0.5.
+ ]
+ ]
] fork.
"
@@ -502,19 +502,19 @@
displayArc:origin radius:radius from:startAngle angle:angle
"draw an arc around a point"
- self
+ self
displayArcX:(origin x - radius)
y:(origin y - radius)
- width:(radius * 2)
+ width:(radius * 2)
height:(radius * 2)
- from:startAngle
+ from:startAngle
angle:angle
"Modified: 8.5.1996 / 08:34:43 / cg"
!
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle
- "draw an arc/circle/ellipse - ST-80 compatibility"
+ "draw an arc/circle/ellipse - ST-80 compatibility"
^ self displayArcX:(boundingBox left)
y:(boundingBox top)
@@ -527,7 +527,7 @@
!
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin
- "draw an arc/circle/ellipse - ST-80 compatibility"
+ "draw an arc/circle/ellipse - ST-80 compatibility"
^ self displayArcX:(boundingBox left + origin x)
y:(boundingBox top + origin y)
@@ -547,7 +547,7 @@
displayPolyline:aPolygon
"draw a polygon - ST-80 compatibility"
- ^ self displayPolygon:aPolygon
+ ^ self displayPolygon:aPolygon
!
displayRectangularBorder:aRectangle
@@ -737,17 +737,17 @@
unicode (of which iso8859-1 is a subset) encoding.
The possibility to change the characterEncoding is provided as
a backward compatibility hook for programs which want to use
- another encoding internally.
+ another encoding internally.
One such view is the CharacterSetView,
which wants to show character as they are actually present in a font."
|encodingSymOrNil|
- encodingSymOrNil := encodingArg isNil
- ifTrue:[#'iso10646-1' "unicode"]
- ifFalse:[encodingArg asSymbol].
+ encodingSymOrNil := encodingArg isNil
+ ifTrue:[#'iso10646-1' "unicode"]
+ ifFalse:[encodingArg asSymbol].
characterEncoding ~~ encodingSymOrNil ifTrue:[
- characterEncoding := encodingSymOrNil.
+ characterEncoding := encodingSymOrNil.
].
"Modified (comment): / 25-01-2012 / 00:29:37 / cg"
@@ -785,11 +785,14 @@
|rect|
clipRect isNil ifTrue:[
- rect := 0@0 extent:(self medium extent).
- transformation notNil ifTrue:[
- rect := transformation applyInverseTo:rect.
- ].
- ^ rect
+ rect := 0@0 extent:(self medium extent).
+ transformation notNil ifTrue:[
+ rect := transformation applyInverseTo:rect.
+ ].
+ ^ rect
+ ].
+ transformation notNil ifTrue:[
+ ^ transformation applyInverseTo:clipRect.
].
^ clipRect
@@ -800,16 +803,25 @@
"set the clipping rectangle for drawing (in logical coordinates);
a nil argument turn off clipping (i.e. whole view is drawable)"
- clipRect := aRectangleOrNil
+ (aRectangleOrNil notNil and:[transformation notNil]) ifTrue:[
+ clipRect := transformation applyTo:aRectangleOrNil.
+ ] ifFalse:[
+ clipRect := aRectangleOrNil
+ ].
"Modified: 22.5.1996 / 13:12:07 / cg"
"Created: 28.5.1996 / 14:09:27 / cg"
!
clippingBoundsOrNil
- "return the clipping bounds (a Rectangle) for drawing, nil if there is none.
- The rectangle is in logical coordinates"
-
+ "return the clipping bounds (a Rectangle) for drawing in logical coordinates, nil if there is none."
+
+ clipRect isNil ifTrue:[
+ ^ nil
+ ].
+ transformation notNil ifTrue:[
+ ^ transformation applyInverseTo:clipRect.
+ ].
^ clipRect
"Created: 10.4.1996 / 14:32:02 / cg"
@@ -847,7 +859,7 @@
dashStyle:aDashList offset:dashOffset
"define dashes. Each element of the dashList specifies the length
of a corresponding dash. For example, setting it to [4 4]
- defines 4on-4off dashing;
+ defines 4on-4off dashing;
Setting it to [1 2 4 2] defines 1on-2off-4on-2off dashes.
The dashOffset specifies where in the dashList the dashing starts.
Ignored here - this may not be supported by all graphics devices."
@@ -928,9 +940,9 @@
#dotted, #dashDot or #dashDotDot."
aStyleSymbol isNil ifTrue:[
- lineStyle := #solid
+ lineStyle := #solid
] ifFalse:[
- lineStyle := aStyleSymbol
+ lineStyle := aStyleSymbol
]
"Modified: 12.5.1996 / 22:19:25 / cg"
@@ -979,7 +991,7 @@
"Modified: / 26.1.1998 / 18:59:18 / cg"
!
-maskOriginX:x y:y
+maskOriginX:x y:y
"set the origin within the mask (used to draw with patterns).
Should be redefined in classes which support it.
This is an alias for ST-80's #phase:"
@@ -1038,7 +1050,7 @@
OBSOLETE: use #maskOriginX:y: or #phase:"
self obsoleteMethodWarning:'use #maskOriginX:y:'.
- ^ self maskOriginX:x y:y
+ ^ self maskOriginX:x y:y
!
viewOrigin
@@ -1078,13 +1090,13 @@
"Modified: 27.4.1996 / 18:47:38 / cg"
!
-transformation
+transformation
"return the transformation"
^ transformation
!
-transformation:aTransformation
+transformation:aTransformation
"set the transformation"
transformation := aTransformation
@@ -1166,39 +1178,39 @@
(false "(device platformName ~= 'WIN32')"
or:[OperatingSystem isMSWINDOWSNTlike]) ifTrue:[
- oldStyle := lineStyle.
- self lineStyle:#dotted.
- self displayRectangleX:x y:y width:w height:h.
- self lineStyle:oldStyle.
- ^ self.
+ oldStyle := lineStyle.
+ self lineStyle:#dotted.
+ self displayRectangleX:x y:y width:w height:h.
+ self lineStyle:oldStyle.
+ ^ self.
].
1 to:w-1 by:2 do:[:o |
- lastX := x + o.
- self displayPointX:lastX y:y.
+ lastX := x + o.
+ self displayPointX:lastX y:y.
].
y0 := 1.
lastX == (x+w-1) ifTrue:[
- y0 := 0
+ y0 := 0
].
y0 to:h-1 by:2 do:[:o |
- lastY := y+o.
- self displayPointX:x+w-1 y:lastY.
+ lastY := y+o.
+ self displayPointX:x+w-1 y:lastY.
].
x0 := w-2.
lastY == (y+h-1) ifTrue:[
- x0:= w-1
+ x0:= w-1
].
x0 to:0 by:-2 do:[:o |
- lastX := x+o.
- self displayPointX:lastX y:y+h-1.
+ lastX := x+o.
+ self displayPointX:lastX y:y+h-1.
].
y0 := h-1.
lastX == 0 ifTrue:[
- y0 := h-1
+ y0 := h-1
].
y0 to:0 by:-2 do:[:o |
- self displayPointX:x y:y+o.
+ self displayPointX:x y:y+o.
].
"Modified: / 6.11.2001 / 08:48:18 / cg"
@@ -1238,23 +1250,23 @@
"/ w := 12.
"/
"/ pattern := #[
-"/ 2r00000011
-"/ 2r11001100
-"/ 2r00110000
+"/ 2r00000011
+"/ 2r11001100
+"/ 2r00110000
"/ ].
"/ h := 3.
"/ w := 8.
pattern := #[
- 2r11001100 2r11001100 2r11001100 2r11001100
- 2r00110011 2r00110011 2r00110011 2r00110011
- ].
+ 2r11001100 2r11001100 2r11001100 2r11001100
+ 2r00110011 2r00110011 2r00110011 2r00110011
+ ].
h := 2.
w := 32.
"/ pattern := #[
-"/ 2r11000000
-"/ 2r00110000
+"/ 2r11000000
+"/ 2r00110000
"/ ].
"/ h := 2.
"/ w := 4.
@@ -1266,8 +1278,8 @@
x := x0 truncateTo:w.
[x <= x1] whileTrue:[
- self displayForm:form x:x y:y0.
- x := x + w.
+ self displayForm:form x:x y:y0.
+ x := x + w.
].
self clippingRectangle:oldClip
@@ -1297,6 +1309,12 @@
^ self subclassResponsibility
!
+displayOpaqueString:aString from:index1 to:index2 x:x y:y maxWitdh:maxWidth
+ "draw part of a string with both fg and bg at x/y in current font"
+
+ ^ self subclassResponsibility
+!
+
displayPolygon:aPolygon
"draw a polygon
- this could be recoded to draw using displayLine"
@@ -1321,9 +1339,9 @@
"draw part of a string with both fg and bg at x/y in current font"
opaque ifTrue:[
- self displayOpaqueString:aString from:index1 to:index2 x:x y:y
+ self displayOpaqueString:aString from:index1 to:index2 x:x y:y
] ifFalse:[
- self displayString:aString from:index1 to:index2 x:x y:y
+ self displayString:aString from:index1 to:index2 x:x y:y
].
! !
@@ -1393,7 +1411,7 @@
displayArcIn:aRectangle from:startAngle angle:angle
"draw an arc in a box"
- self
+ self
displayArcX:(aRectangle left)
y:(aRectangle top)
width:(aRectangle width)
@@ -1413,28 +1431,17 @@
top := origin y.
right := corner x.
bot := corner y.
- self
- displayArcX:left
+ self
+ displayArcX:left
y:top
width:(right - left + 1)
height:(bot - top + 1)
- from:startAngle
+ from:startAngle
angle:angle
"Modified: 8.5.1996 / 08:35:25 / cg"
!
-displayArcX:x y:y w:w h:h from:startAngle angle:angle
- "draw an arc; apply transformation if nonNil"
-
- <resource:#obsolete>
-
- self obsoleteMethodWarning:'use #displayArcX:y:width:height:from:angle:'.
- self displayArcX:x y:y width:w height:h from:startAngle angle:angle
-
- "Modified: 8.5.1996 / 08:46:56 / cg"
-!
-
displayCircle:aPoint radius:r
"draw a circle around a center point"
@@ -1449,7 +1456,7 @@
y:(aRectangle top)
width:(aRectangle width)
height:(aRectangle height)
- from:0
+ from:0
angle:360
"Modified: 8.5.1996 / 08:35:40 / cg"
@@ -1460,12 +1467,12 @@
|d|
d := 2 * r.
- self
- displayArcX:(x - r)
+ self
+ displayArcX:(x - r)
y:(y - r)
width:d
height:d
- from:0
+ from:0
angle:360
"Modified: 8.5.1996 / 08:36:03 / cg"
@@ -1489,7 +1496,7 @@
!
displayForm:aFormOrImage x:x y:y
- "draw a form (or image) at x/y;
+ "draw a form (or image) at x/y;
if the form has depth 1, 1's in the form are
drawn in current paint color, 0's are ignored.
If the form has depth ~~ 1, the current fg color setting is ignored."
@@ -1497,8 +1504,8 @@
|fg bg f noColor|
aFormOrImage depth > 1 ifTrue:[
- self displayOpaqueForm:aFormOrImage x:x y:y.
- ^ self.
+ self displayOpaqueForm:aFormOrImage x:x y:y.
+ ^ self.
].
"/ aFormOrImage mask notNil ifTrue:[
"/self halt.
@@ -1509,8 +1516,8 @@
f := function.
f ~~ #copy ifTrue:[
- self error:'function not supported'.
- ^ self
+ self error:'function not supported'.
+ ^ self
].
noColor := Color noColor.
@@ -1532,15 +1539,15 @@
!
displayForm:aFormOrImage x:x y:y opaque:opaque
- "draw a form (or image) at x/y;
+ "draw a form (or image) at x/y;
if the form has depth 1, 1's in the form are
drawn in current paint color, 0's are ignored.
If the form has depth ~~ 1, the current fg color setting is ignored."
opaque ifTrue:[
- self displayOpaqueForm:aFormOrImage x:x y:y
+ self displayOpaqueForm:aFormOrImage x:x y:y
] ifFalse:[
- self displayForm:aFormOrImage x:x y:y
+ self displayForm:aFormOrImage x:x y:y
].
!
@@ -1581,31 +1588,31 @@
displayLineFromX:xStart y:yStart toX:xEnd y:yEnd brush:aForm
"draw a line using a brush.
- Here, a slow fallback is used, drawing into a
+ Here, a slow fallback is used, drawing into a
temporary bitmap first, which is then displayed"
|deltaX deltaY dx dy px py destX destY p tempForm
xMin xMax yMin yMax x1 x2 y1 y2|
xStart < xEnd ifTrue:[
- xMin := xStart.
- xMax := xEnd.
+ xMin := xStart.
+ xMax := xEnd.
] ifFalse:[
- xMin := xEnd.
- xMax := xStart
+ xMin := xEnd.
+ xMax := xStart
].
yStart < yEnd ifTrue:[
- yMin := yStart.
- yMax := yEnd.
+ yMin := yStart.
+ yMax := yEnd.
] ifFalse:[
- yMin := yEnd.
- yMax := yStart
+ yMin := yEnd.
+ yMax := yStart
].
tempForm := Form width:(xMax-xMin+1+aForm width)
- height:(yMax-yMin+1+aForm height)
- depth:aForm depth
- onDevice:device.
+ height:(yMax-yMin+1+aForm height)
+ depth:aForm depth
+ onDevice:device.
tempForm isNil ifTrue:[^nil].
tempForm clear.
tempForm paint:(Color colorId:1) on:(Color colorId:0).
@@ -1613,11 +1620,11 @@
((yStart = yEnd and:[xStart < xEnd])
or: [yStart < yEnd]) ifTrue:[
- x1 := xStart. y1 := yStart.
- x2 := xEnd. y2 := yEnd.
+ x1 := xStart. y1 := yStart.
+ x2 := xEnd. y2 := yEnd.
] ifFalse:[
- x1 := xEnd. y1 := yEnd.
- x2 := xStart. y2 := yStart.
+ x1 := xEnd. y1 := yEnd.
+ x2 := xStart. y2 := yStart.
].
x1 := x1 - xMin. x2 := x2 - xMin.
@@ -1639,42 +1646,36 @@
tempForm displayForm:aForm x:destX y:destY.
py > px ifTrue:[
- "horizontal"
- p := py // 2.
- py timesRepeat:[
- destX := destX + dx.
- (p := p - px) < 0 ifTrue:[
- destY := destY + dy.
- p := p + py
- ].
- tempForm displayForm:aForm x:destX y:destY.
- ]
- ] ifFalse:[
- "vertical"
- p := px // 2.
- px timesRepeat:[
- destY := destY + dy.
- (p := p - py) < 0 ifTrue:[
- destX := destX + dx.
- p := p + px
- ].
- tempForm displayForm:aForm x:destX y:destY
- ]
+ "horizontal"
+ p := py // 2.
+ py timesRepeat:[
+ destX := destX + dx.
+ (p := p - px) < 0 ifTrue:[
+ destY := destY + dy.
+ p := p + py
+ ].
+ tempForm displayForm:aForm x:destX y:destY.
+ ]
+ ] ifFalse:[
+ "vertical"
+ p := px // 2.
+ px timesRepeat:[
+ destY := destY + dy.
+ (p := p - py) < 0 ifTrue:[
+ destX := destX + dx.
+ p := p + px
+ ].
+ tempForm displayForm:aForm x:destX y:destY
+ ]
].
- self displayForm:tempForm
- x:xMin-aForm offset x
- y:yMin-aForm offset y.
+ self displayForm:tempForm
+ x:xMin-aForm offset x
+ y:yMin-aForm offset y.
tempForm close
"Modified: 1.4.1997 / 21:29:06 / cg"
!
-displayOpaqueString:aString at:aPoint
- "draw a string with both fg and bg"
-
- self displayOpaqueString:aString x:(aPoint x) y:(aPoint y)
-!
-
displayOpaqueString:aString from:start to:stop at:aPoint
"draw part of a string - drawing both fg and bg"
@@ -1692,7 +1693,7 @@
drawing both fg and bg pixels.
The angle is in degrees, clock-wise, starting with 0 for
a horizontal draw.
- Drawing is done by first drawing the string into a temporary bitmap,
+ Drawing is done by first drawing the string into a temporary bitmap,
which is rotated and finally drawn as usual.
NOTICE: due to the rotation of the temporary bitmap, this is a slow
operation - not to be used with cillions of strings ..."
@@ -1755,7 +1756,7 @@
left := origin x.
top := origin y.
- self displayRectangleX:left y:top
+ self displayRectangleX:left y:top
width:(corner x - left)
height:(corner y - top)
@@ -1766,8 +1767,8 @@
"draw a rectangle"
self displayRectangleX:(origin x) y:(origin y)
- width:(extent x)
- height:(extent y)
+ width:(extent x)
+ height:(extent y)
"Modified: 13.4.1996 / 20:58:31 / cg"
!
@@ -1788,11 +1789,11 @@
hC := hCorn.
self scale = 1 ifTrue:[
- wHalf := wC // 2.
- hHalf := hC // 2.
+ wHalf := wC // 2.
+ hHalf := hC // 2.
] ifFalse:[
- wHalf := wC / 2.
- hHalf := hC / 2.
+ wHalf := wC / 2.
+ hHalf := hC / 2.
].
"top left arc"
@@ -1803,9 +1804,9 @@
"bottom right arc"
(isWin32 and:[self scale = 1]) ifTrue:[
- self displayArcX:(right - wC+1) y:(bottom - hC+1) width:wC height:hC from:270 angle:90.
+ self displayArcX:(right - wC+1) y:(bottom - hC+1) width:wC height:hC from:270 angle:90.
] ifFalse:[
- self displayArcX:(right - wC) y:(bottom - hC) width:wC height:hC from:270 angle:90.
+ self displayArcX:(right - wC) y:(bottom - hC) width:wC height:hC from:270 angle:90.
].
"bottom left arc"
@@ -1819,7 +1820,7 @@
"bottom line"
self displayLineFromX:(left + wHalf-1) y:bottom
- toX:(right - wHalf ) y:bottom.
+ toX:(right - wHalf ) y:bottom.
"right line"
self displayLineFromX:right y:(top + hHalf) toX:right y:(bottom - hHalf).
@@ -1839,12 +1840,6 @@
self displayString:aString x:aPoint x y:aPoint y
!
-displayString:aString centeredAt:aPoint
- "draw a string - drawing fg only"
-
- self displayString:aString centeredAtX:aPoint x y:aPoint y
-!
-
displayString:aString centeredAtX:x y:y
"draw a string - drawing fg only"
@@ -1871,7 +1866,7 @@
"draw a string along a (possibly non-horizontal) line - drawing fg only.
The angle is in degrees, clock-wise, starting with 0 for
a horizontal draw.
- Drawing is done by first drawing the string into a temporary bitmap,
+ Drawing is done by first drawing the string into a temporary bitmap,
which is rotated and finally drawn as usual.
NOTICE: due to the rotation of the temporary bitmap, this is a slow
operation - not to be used with cillions of strings ..."
@@ -1936,7 +1931,7 @@
"common code to draw a string along a (possibly non-horizontal) line.
The angle is in degrees, clock-wise, starting with 0 for
a horizontal draw.
- Drawing is done by first drawing the string into a temporary bitmap,
+ Drawing is done by first drawing the string into a temporary bitmap,
which is rotated and finally drawn as usual.
NOTICE: due to the rotation of the temporary bitmap, this is a slow
operation - not to be used with cillions of strings ...
@@ -1979,11 +1974,10 @@
tempForm := Form width:w height:h depth:1 onDevice:device.
tempForm isNil ifTrue:[^ self].
+ tempForm paint:(Color colorId:1) on:(Color colorId:0).
tempForm clear.
tempForm font:font.
- tempForm paint:(Color colorId:1) on:(Color colorId:0).
tempForm displayString:aString x:0 y:ascent.
- tempImage := (Depth1Image fromForm:tempForm) rotated:angle.
] ifFalse:[
"/ something weird (labelAndIcon ..)
"/ do it in a deep form.
@@ -2002,8 +1996,9 @@
tempForm paint:paint on:bgPaint.
tempForm font:font.
aString displayOn:tempForm x:0 y:ascent opaque:true.
- tempImage := ((Image implementorForDepth:(device depth)) fromForm:tempForm) rotated:angle.
].
+ tempImage := tempForm asImage rotated:angle.
+
opaque ifTrue:[
m := ImageMask width:w height:h.
m bits:(ByteArray new:(h * m bytesPerRow) withAll:16rFF).
@@ -2013,7 +2008,7 @@
"/ compute final position of rotated form
"/ adjust position for baseline.
angle = 90 ifTrue:[
- xN := x - descent.
+ xN := x - descent.
yN := y.
] ifFalse:[
angle = 180 ifTrue:[
@@ -2032,7 +2027,7 @@
r := p r.
a := p theta.
sin := angle degreesToRadians sin.
- cos := angle degreesToRadians cos.
+ cos := angle degreesToRadians cos.
angle < 90 ifTrue:[
dX := descent * sin.
@@ -2059,7 +2054,6 @@
]
]
].
-
tempImage mask:nil.
]
].
@@ -2115,46 +2109,46 @@
drawEdgesForX:x y:y width:w height:h level:l
"draw 3D edges into a rectangle"
- self
- drawEdgesForX:x y:y width:w height:h level:l
- shadow:self blackColor light:self whiteColor
- halfShadow:nil halfLight:nil
- style:nil
+ self
+ drawEdgesForX:x y:y width:w height:h level:l
+ shadow:self blackColor light:self whiteColor
+ halfShadow:nil halfLight:nil
+ style:nil
!
-drawEdgesForX:x y:y width:w height:h level:lvl
- shadow:shadowColor light:lightColor
- halfShadow:halfShadowColor halfLight:halfLightColor
- style:edgeStyle
+drawEdgesForX:x y:y width:w height:h level:lvl
+ shadow:shadowColor light:lightColor
+ halfShadow:halfShadowColor halfLight:halfLightColor
+ style:edgeStyle
"draw 3D edges into a rectangle"
|topLeftFg botRightFg topLeftHalfFg botRightHalfFg
count "{ Class: SmallInteger }"
- r
- b
+ r
+ b
xi "{ Class: SmallInteger }"
yi "{ Class: SmallInteger }"
run paint|
count := lvl.
(count < 0) ifTrue:[
- topLeftFg := shadowColor.
- botRightFg := lightColor.
- topLeftHalfFg := halfShadowColor.
- botRightHalfFg := halfLightColor.
- count := count negated
+ topLeftFg := shadowColor.
+ botRightFg := lightColor.
+ topLeftHalfFg := halfShadowColor.
+ botRightHalfFg := halfLightColor.
+ count := count negated
] ifFalse:[
- topLeftFg := lightColor.
- botRightFg := shadowColor.
- topLeftHalfFg := halfLightColor.
- botRightHalfFg := halfShadowColor.
+ topLeftFg := lightColor.
+ botRightFg := shadowColor.
+ topLeftHalfFg := halfLightColor.
+ botRightHalfFg := halfShadowColor.
].
topLeftHalfFg isNil ifTrue:[
- topLeftHalfFg := topLeftFg
+ topLeftHalfFg := topLeftFg
].
botRightHalfFg isNil ifTrue:[
- botRightHalfFg := botRightFg
+ botRightHalfFg := botRightFg
].
r := x + w - 1. "right"
@@ -2164,39 +2158,39 @@
"top and left edges"
((edgeStyle == #soft or:[edgeStyle == #softWin95]) and:["l" count > 0]) ifTrue:[
- paint := topLeftHalfFg
+ paint := topLeftHalfFg
] ifFalse:[
- paint := topLeftFg
+ paint := topLeftFg
].
self paint:paint.
0 to:(count - 1) do:[:i |
- run := y + i.
- run < b ifTrue:[
- self displayDeviceLineFromX:x y:run toX:r y:run. "top"
- ].
- run := x + i.
- self displayDeviceLineFromX:run y:y toX:run y:b "left"
+ run := y + i.
+ run < b ifTrue:[
+ self displayDeviceLineFromX:x y:run toX:r y:run. "top"
+ ].
+ run := x + i.
+ self displayDeviceLineFromX:run y:y toX:run y:b "left"
].
(edgeStyle == #soft or:[edgeStyle == #softWin95]) ifTrue:[
"
- self paint:topLeftFg.
- self displayDeviceLineFromX:x y:y toX:r y:y.
- self displayDeviceLineFromX:x y:y toX:x y:b
+ self paint:topLeftFg.
+ self displayDeviceLineFromX:x y:y toX:r y:y.
+ self displayDeviceLineFromX:x y:y toX:x y:b
"
- (lvl > 1) ifTrue:[
- edgeStyle == #softWin95 ifTrue:[
- self paint:(Color veryLightGray).
- ] ifFalse:[
- (lvl > 2 and:[edgeStyle == #soft]) ifTrue:[
- self paint:(device blackColor).
- ] ifFalse:[
- self paint:halfLightColor.
- ]
- ].
- self displayDeviceLineFromX:x y:y toX:r y:y.
- self displayDeviceLineFromX:x y:y toX:x y:b.
- ]
+ (lvl > 1) ifTrue:[
+ edgeStyle == #softWin95 ifTrue:[
+ self paint:(Color veryLightGray).
+ ] ifFalse:[
+ (lvl > 2 and:[edgeStyle == #soft]) ifTrue:[
+ self paint:(device blackColor).
+ ] ifFalse:[
+ self paint:halfLightColor.
+ ]
+ ].
+ self displayDeviceLineFromX:x y:y toX:r y:y.
+ self displayDeviceLineFromX:x y:y toX:x y:b.
+ ]
].
xi := x + 1.
@@ -2210,27 +2204,27 @@
"bottom and right edges"
((edgeStyle == #soft or:[edgeStyle == #softWin95])
"new:" and:[count > 1]) ifTrue:[
- paint := botRightHalfFg
+ paint := botRightHalfFg
] ifFalse:[
- paint := botRightFg
+ paint := botRightFg
].
self paint:paint.
0 to:(count - 1) do:[:i |
- run := b - i.
- run > y ifTrue:[
- self displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom"
- ].
- run := r - i.
- self displayDeviceLineFromX:run y:yi-1 toX:run y:b. "right"
- xi := xi + 1.
- yi := yi + 1
+ run := b - i.
+ run > y ifTrue:[
+ self displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom"
+ ].
+ run := r - i.
+ self displayDeviceLineFromX:run y:yi-1 toX:run y:b. "right"
+ xi := xi + 1.
+ yi := yi + 1
].
- ((edgeStyle == #soft or:[edgeStyle == #softWin95])
+ ((edgeStyle == #soft or:[edgeStyle == #softWin95])
and:[lvl > 1]) ifTrue:[
- self paint:(device blackColor) "shadowColor".
- self displayDeviceLineFromX:x y:b toX:r y:b.
- self displayDeviceLineFromX:r y:y toX:r y:b
+ self paint:(device blackColor) "shadowColor".
+ self displayDeviceLineFromX:x y:b toX:r y:b.
+ self displayDeviceLineFromX:r y:y toX:r y:b
].
self edgeDrawn:#all
@@ -2253,8 +2247,8 @@
|d|
d := 2 * r.
- self
- fillArcX:(origin x - r)
+ self
+ fillArcX:(origin x - r)
y:(origin y - r)
width:d
height:d
@@ -2267,7 +2261,7 @@
fillArcIn:aRectangle from:startAngle angle:angle
"draw a filled arc in a box"
- self
+ self
fillArcX:(aRectangle left)
y:(aRectangle top)
width:(aRectangle width)
@@ -2288,12 +2282,12 @@
top := origin y.
right := corner x.
bot := corner y.
- self
- fillArcX:left
+ self
+ fillArcX:left
y:top
- width:(right - left + 1)
+ width:(right - left + 1)
height:(bot - top + 1)
- from:startAngle
+ from:startAngle
angle:angle
"Created: 13.4.1996 / 20:56:56 / cg"
@@ -2314,8 +2308,8 @@
fillArcX:x y:y width:w height:h from:startAngle to:endAngle
"draw a filled arc in a box, given startAngle and endAngle."
- self
- fillArcX:x
+ self
+ fillArcX:x
y:y
width:w
height:h
@@ -2339,7 +2333,7 @@
y:(aRectangle top)
width:(aRectangle width)
height:(aRectangle height)
- from:0
+ from:0
angle:360
"Created: 13.4.1996 / 20:57:41 / cg"
@@ -2352,11 +2346,11 @@
|d|
d := 2 * r.
- self
+ self
fillArcX:(x - r)
- y:(y - r)
+ y:(y - r)
width:d
- height:d
+ height:d
from:0
angle:360
@@ -2380,7 +2374,7 @@
!
fillRectangleOrigin:origin corner:corner
- "draw a filled rectangle.
+ "draw a filled rectangle.
Notice: the cornerPoint itself is NOT included"
|top left|
@@ -2393,7 +2387,7 @@
!
fillRectangleOrigin:origin extent:extent
- "draw a filled rectangle.
+ "draw a filled rectangle.
Notice: the cornerPoint itself is NOT included"
self fillRectangleX:(origin x) y:(origin y) width:(extent x) height:(extent y)
@@ -2412,38 +2406,38 @@
hHalf := hC / 2.
device isWindowsPlatform ifTrue:[
- "/ bug workaround
- "top left arc"
- self fillArcX:left y:top width:wC height:hC from:90 angle:90.
- "top right arc"
- self fillArcX:(right - wC - 1) y:top width:wC height:hC from:0 angle:90.
- "bottom right arc"
- self fillArcX:(right - wC - 1) y:(bottom - hC - 1) width:wC height:hC from:270 angle:90.
- "bottom left arc"
- self fillArcX:left y:(bottom - hC) width:wC height:hC-1 from:180 angle:90.
-
- "center rectangle"
- self fillRectangleX:(left + wHalf) y:top width:(width - wHalf - wHalf+1) height:height-1.
- "left partial rectangle"
- self fillRectangleX:left y:top+hHalf width:wHalf height:(height-hHalf-hHalf).
- "right partial rectangle"
- self fillRectangleX:right-wHalf y:top+hHalf width:wHalf-1 height:(height-hHalf-hHalf).
+ "/ bug workaround
+ "top left arc"
+ self fillArcX:left y:top width:wC height:hC from:90 angle:90.
+ "top right arc"
+ self fillArcX:(right - wC - 1) y:top width:wC height:hC from:0 angle:90.
+ "bottom right arc"
+ self fillArcX:(right - wC - 1) y:(bottom - hC - 1) width:wC height:hC from:270 angle:90.
+ "bottom left arc"
+ self fillArcX:left y:(bottom - hC) width:wC height:hC-1 from:180 angle:90.
+
+ "center rectangle"
+ self fillRectangleX:(left + wHalf) y:top width:(width - wHalf - wHalf+1) height:height-1.
+ "left partial rectangle"
+ self fillRectangleX:left y:top+hHalf width:wHalf height:(height-hHalf-hHalf).
+ "right partial rectangle"
+ self fillRectangleX:right-wHalf y:top+hHalf width:wHalf-1 height:(height-hHalf-hHalf).
] ifFalse:[
- "top left arc"
- self fillArcX:left y:top width:wC height:hC from:90 angle:90.
- "top right arc"
- self fillArcX:(right - wC) y:top width:wC height:hC from:0 angle:90.
- "bottom right arc"
- self fillArcX:(right - wC - 1) y:(bottom - hC) width:wC height:hC from:270 angle:90.
- "bottom left arc"
- self fillArcX:left y:(bottom - hC) width:wC height:hC from:180 angle:90.
-
- "center rectangle"
- self fillRectangleX:(left + wHalf) y:top width:(width - wHalf - wHalf+1) height:height.
- "left partial rectangle"
- self fillRectangleX:left y:top+hHalf width:wHalf height:(height-hHalf-hHalf).
- "right partial rectangle"
- self fillRectangleX:right-wHalf y:top+hHalf width:wHalf height:(height-hHalf-hHalf).
+ "top left arc"
+ self fillArcX:left y:top width:wC height:hC from:90 angle:90.
+ "top right arc"
+ self fillArcX:(right - wC) y:top width:wC height:hC from:0 angle:90.
+ "bottom right arc"
+ self fillArcX:(right - wC - 1) y:(bottom - hC) width:wC height:hC from:270 angle:90.
+ "bottom left arc"
+ self fillArcX:left y:(bottom - hC) width:wC height:hC from:180 angle:90.
+
+ "center rectangle"
+ self fillRectangleX:(left + wHalf) y:top width:(width - wHalf - wHalf+1) height:height.
+ "left partial rectangle"
+ self fillRectangleX:left y:top+hHalf width:wHalf height:(height-hHalf-hHalf).
+ "right partial rectangle"
+ self fillRectangleX:right-wHalf y:top+hHalf width:wHalf height:(height-hHalf-hHalf).
].
@@ -2481,10 +2475,10 @@
oldClip := clipRect.
self clippingRectangle:aRectangle.
- aBlock
- ensure:[
- self clippingRectangle:oldClip
- ]
+ aBlock
+ ensure:[
+ self clippingRectangle:oldClip
+ ]
!
flush
@@ -2507,7 +2501,7 @@
"blocked: ascii storeString not possible (recursive - view - subviews - container)"
self shouldNotImplement.
- "if proceeded from exception..."
+ "if proceeded from exception..."
self printOn:aStream.
! !