use ShapeStyle attributes
Mon Aug 22 17:00:59 WEST 2005 Malcolm.Wallace@cs.york.ac.uk
* use ShapeStyle attributes
Bring the ShapeStyle datatype into play. The palette of node shapes now
allows changes of fill-colour, stroke-colour, and stroke-width.
{
hunk ./Makefile 173
-src/ContextMenu.o : src/Shape.hi
+src/ContextMenu.o : src/Palette.hi
hunk ./Makefile 188
+src/Shape.o : src/Colors.hi
addfile ./simple.blobpalette
hunk ./simple.blobpalette 1
+ Palette
+ [ ("circle", Circle { shapeStyle = ShapeStyle { styleStrokeWidth = 1
+ , styleStrokeColour = RGB 0 0 0
+ , styleFill = RGB 200 128 200
+ }
+ , shapeRadius = 0.5 } )
+ , ("square", Polygon { shapeStyle = ShapeStyle { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 0 0 0
+ , styleFill = RGB 200 200 128
+ }
+ , shapePerimeter = [ DoublePoint (-0.5) (-0.5)
+ , DoublePoint 0.5 (-0.5)
+ , DoublePoint 0.5 0.5
+ , DoublePoint (-0.5) 0.5 ] } )
+ , ("triangle", Polygon { shapeStyle = ShapeStyle { styleStrokeWidth = 1
+ , styleStrokeColour = RGB 0 0 0
+ , styleFill = RGB 128 200 200
+ }
+ , shapePerimeter = [ DoublePoint (-0.5) (-0.5)
+ , DoublePoint 0.5 (-0.5)
+ , DoublePoint 0.0 0.5 ] } )
+ , ("lines", Composite { shapeSegments =
+ [ Lines { shapeStyle = ShapeStyle
+ { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 200 0 0
+ , styleFill = RGB 128 128 128
+ }
+ , shapePerimeter = [ DoublePoint 0.0 (-0.5)
+ , DoublePoint (-0.2) 0.5 ] }
+ , Lines { shapeStyle = ShapeStyle
+ { styleStrokeWidth = 2
+ , styleStrokeColour = RGB 200 0 0
+ , styleFill = RGB 128 128 128
+ }
+ , shapePerimeter = [ DoublePoint 0.2 (-0.5)
+ , DoublePoint 0.0 0.5 ] }
+ ] } )
+ ]
hunk ./src/Node.hs 28
- , nodeShape = Circle { shapeRadius=kNODE_RADIUS }
+ , nodeShape = Circle { shapeStyle = defaultShapeStyle
+ , shapeRadius = kNODE_RADIUS }
hunk ./src/Shape.hs 27
- deriving (Eq {-, Show, Read-})
-instance Show ShapeStyle where show _ = ""
-instance Read ShapeStyle where readsPrec _ s = [(ShapeStyle {}, s)]
+ deriving (Eq, Show, Read)
hunk ./src/Shape.hs 33
- (logicalToScreenX ppi (shapeRadius shape))
- options
+ (logicalToScreenX ppi (shapeRadius shape))
+ (options++style2options (shapeStyle shape))
hunk ./src/Shape.hs 38
- options
+ (options++style2options (shapeStyle shape))
hunk ./src/Shape.hs 41
- options
+ (options++style2options (shapeStyle shape))
hunk ./src/Shape.hs 53
-circle,square :: Shape
-circle = Circle { shapeRadius = kNODE_RADIUS }
-square = Polygon { shapePerimeter = [ DoublePoint (-0.5) (-0.5)
- , DoublePoint 0.5 (-0.5)
- , DoublePoint 0.5 0.5
- , DoublePoint (-0.5) 0.5 ] }
+circle :: Shape
+circle = Circle { shapeStyle = defaultShapeStyle
+ , shapeRadius = kNODE_RADIUS }
+
+style2options :: ShapeStyle -> [Prop (DC ())]
+style2options sty =
+ [ penWidth := styleStrokeWidth sty
+ , penColor := wxcolor (styleStrokeColour sty)
+ , brushKind := BrushSolid
+ , brushColor := wxcolor (styleFill sty)
+ ]
+
+defaultShapeStyle :: ShapeStyle
+defaultShapeStyle =
+ ShapeStyle { styleStrokeWidth = 1
+ , styleStrokeColour = licorice
+ , styleFill = nodeColor }
}