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.MapPoint[
pointInCell: [x: p.x, y: p.y],
cellSize: cellSize, cellInstOrient: orient]];
END;
orig: CD.Position;
orig ← CDBasics.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, markObj.baseline + 0];
Graphics.MoveTo[path, x, y, TRUE];
[x, y] ← MapToReal[mid - 2, markObj.baseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid - 4, markObj.baseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid - 0, markObj.baseline + 8];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid + 4, markObj.baseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid + 2, markObj.baseline + 4];
Graphics.LineTo[path, x, y];
[x, y] ← MapToReal[mid + 2, markObj.baseline + 0];
Graphics.LineTo[path, x, y];
Graphics.DrawArea[self: context, path: path];
rect ← CDBasics.MoveRect[CDOrient.MapRect[
itemInCell: [x1: mid - 1, y1: markObj.baseline + 4, x2: mid + 1, y2: markObj.baseline + 7],
cellSize: aptr.ob.size, cellInstOrient: orient], pos];
pr.drawRect[rect, aptr.ob.level, pr];
rect ← CDBasics.MoveRect[CDOrient.MapRect[
itemInCell: [x1: mid - 2, y1: markObj.baseline, x2: mid + 2, y2: markObj.baseline + 6],
cellSize: aptr.ob.size, cellInstOrient: orient], pos];
pr.drawRect[rect, aptr.ob.level, pr];
rect ← CDBasics.MoveRect[CDOrient.MapRect[
itemInCell: [x1: mid - 3, y1: markObj.baseline + 4, x2: mid + 3, y2: markObj.baseline + 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, markObj.baseline, FALSE, aptr, pos, orient, context];
MoveTo[right, markObj.baseline, 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, markObj.baseline + 0, FALSE, aptr, pos, orient, context];
MoveTo[mid - 2, markObj.baseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid - 4, markObj.baseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid - 0, markObj.baseline + 8, TRUE, aptr, pos, orient, context];
MoveTo[mid + 4, markObj.baseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid + 2, markObj.baseline + 4, TRUE, aptr, pos, orient, context];
MoveTo[mid + 2, markObj.baseline + 0, TRUE, aptr, pos, orient, context];
IF
NARROW[aptr.ob.specificRef, StretchObj].type = pointed
THEN {
-- draw arrowheads
MoveTo[left + 2, markObj.baseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[left + 0, markObj.baseline + 0, TRUE, aptr, pos, orient, context];
MoveTo[left + 2, markObj.baseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 2, markObj.baseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[right - 0, markObj.baseline + 0, TRUE, aptr, pos, orient, context];
MoveTo[right - 2, markObj.baseline - 2, TRUE, aptr, pos, orient, context];
}
ELSE {
-- draw square ends
MoveTo[left + 1, markObj.baseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[left + 0, markObj.baseline + 2, TRUE, aptr, pos, orient, context];
MoveTo[left + 0, markObj.baseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[left + 1, markObj.baseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 1, markObj.baseline + 2, FALSE, aptr, pos, orient, context];
MoveTo[right - 0, markObj.baseline + 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 0, markObj.baseline - 2, TRUE, aptr, pos, orient, context];
MoveTo[right - 1, markObj.baseline - 2, TRUE, aptr, pos, orient, context];
};
END;