Color:
PROC [context: Graphics.Context] =
BEGIN
MapToReal:
PROC[x, y:
INT]
RETURNS [
REAL,
REAL] =
INLINE
BEGIN
MapPoint:
PROC [p: CD.Position, cellSize: CD.Position, orient: CD.Orientation]
RETURNS [CD.Position] =
INLINE
BEGIN
RETURN[CDOrient.MapPosition[
itemInCell: [x1: p.x, y1: p.y, x2: p.x, y2: p.y],
cellSize: cellSize, cellInstOrient: orient]];
END;
orig: CD.Position;
orig ← CDInline.AddPoints[MapPoint[[x, y], aptr.ob.size, orient], pos];
RETURN[orig.x, orig.y];
END;
mid: INT ← aptr.ob.size.x / 2;
x, y: REAL;
path: Graphics.Path ← Graphics.NewPath[size: 8];
IF context = NIL THEN RETURN;
[] ← Graphics.SetFat[context, FALSE];
-- fill in the arrow, a hack since we can't do color except in rectangles
[x, y] ← MapToReal[mid - 2, objBaseline + 0];
Graphics.MoveTo[path, x, y, TRUE];
[x, y] ← MapToReal[mid - 2, objBaseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid - 4, objBaseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid - 0, objBaseline + 8];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid + 4, objBaseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid + 2, objBaseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid + 2, objBaseline + 0];
Graphics.LineTo[path, x, y];
Graphics.DrawArea[self: context, path: path];
rect ← CDInline.MoveRect[CDOrient.MapRect[
itemInCell: [x1: mid - 1, y1: objBaseline + 4, x2: mid + 1, y2: objBaseline + 7],
cellSize: aptr.ob.size, cellInstOrient: orient], pos];
pr.drawRect[rect, aptr.ob.level, pr];
rect ← CDInline.MoveRect[CDOrient.MapRect[
itemInCell: [x1: mid - 2, y1: objBaseline, x2: mid + 2, y2: objBaseline + 6],
cellSize: aptr.ob.size, cellInstOrient: orient], pos];
pr.drawRect[rect, aptr.ob.level, pr];
rect ← CDInline.MoveRect[CDOrient.MapRect[
itemInCell: [x1: mid - 3, y1: objBaseline + 4, x2: mid + 3, y2: objBaseline + 5],
cellSize: aptr.ob.size, cellInstOrient: orient], pos];
pr.drawRect[rect, aptr.ob.level, pr];
END;
Outline:
PROC [context: Graphics.Context] =
BEGIN
right: INT ← aptr.ob.size.x;
left: INT ← 0;
mid: INT ← aptr.ob.size.x / 2;
IF context = NIL THEN RETURN;
[] ← Graphics.SetFat[context, FALSE];
-- draw the stretch line
MoveTo[left, objBaseline, FALSE, aptr, pos, orient, context];
MoveTo[right, objBaseline, TRUE, aptr, pos, orient, context];
{ -- use our `Fetch' procedure so we know that it works the same as drawing
line: LineData ← Fetch[aptr];
pos1, pos2: CD.Position;
pos1 ← pos2 ← line.point;
IF line.direction = up OR line.direction = down THEN
pos2.x ← pos1.x + line.length
ELSE
pos2.y ← pos1.y + line.length;
Graphics.SetCP[context, pos1.x, pos1.y];
Graphics.DrawTo[context, pos2.x, pos2.y];
};
-- draw direction arrow
MoveTo[mid - 2, objBaseline + 0, FALSE, aptr, pos, orient, context];
MoveTo[mid - 2, objBaseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid - 4, objBaseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid - 0, objBaseline + 8, TRUE, aptr, pos, orient, context];
MoveTo[mid + 4, objBaseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid + 2, objBaseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid + 2, objBaseline + 0, TRUE, aptr, pos, orient, context];
IF
NARROW[aptr.ob.specificRef, StretchObj].type = pointed
THEN {
-- draw arrowheads
MoveTo[left + 2, objBaseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[left + 0, objBaseline + 0, TRUE, aptr, pos, orient, context];
MoveTo[left + 2, objBaseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 2, objBaseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[right - 0, objBaseline + 0, TRUE, aptr, pos, orient, context];
MoveTo[right - 2, objBaseline - 2, TRUE, aptr, pos, orient, context];
}
ELSE {
-- draw square ends
MoveTo[left + 1, objBaseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[left + 0, objBaseline + 2, TRUE, aptr, pos, orient, context];
MoveTo[left + 0, objBaseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[left + 1, objBaseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 1, objBaseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[right - 0, objBaseline + 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 0, objBaseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 1, objBaseline - 2, TRUE, aptr, pos, orient, context];
};
END;