CDX.mesa (part of ChipNDale)
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
by Ch. Jacobi, September 10, 1984 9:20:09 am PDT
last edited by Ch. Jacobi, May 29, 1985 11:03:42 am PDT
CDX:
CEDAR
DEFINITIONS
IMPORTS CDBasics =
BEGIN
--Public interface between ChipNDale and outside clients.
ClientPosition: TYPE = CD.Position;
ClientRect: TYPE = CD.Rect;
ClientOrigin:
PROC [ob:
CD.Object]
RETURNS [pos:
CD.Position] = INLINE {
--Returns the position of the client's object origin in objects internal cd coords
RETURN [ob.class.origin[ob]]
ClientIRect:
PROC [ob:
CD.Object]
RETURNS [ClientRect];
--Returns the interest rect in client's relative coords
ClientORect:
PROC [ob:
CD.Object]
RETURNS [ClientRect];
--Returns the real outside (cd coords) rect in client's relative coords
--Transfer between ChipNDale and client coordinates, both relative to the object
CDToClientPos:
PROC [ob:
CD.Object, pos:
CD.Position←[0, 0]]
RETURNS [cPos: ClientPosition] =
INLINE {
RETURN [CDBasics.SubPoints[pos, ClientOrigin[ob]]]};
ClientToCDPos:
PROC [ob:
CD.Object, cPos: ClientPosition←[0, 0]]
RETURNS [pos:
CD.Position] =
INLINE {RETURN [CDBasics.AddPoints[cPos, ClientOrigin[ob]]]};
CDToClientRect:
PROC [ob:
CD.Object, rect:
CD.Rect]
RETURNS [cRect: ClientRect] =
INLINE BEGIN
co: CD.Position = ClientOrigin[ob];
RETURN [ClientRect[x1: rect.x1-co.x, y1: rect.y1-co.y, x2: rect.x2-co.x, y2: rect.y2-co.y]]
END;
ClientToCDRect:
PROC [ob:
CD.Object, cRect: ClientRect]
RETURNS [rect:
CD.Rect] =
INLINE BEGIN
co: CD.Position = ClientOrigin[ob];
RETURN [CD.Rect[x1: cRect.x1+co.x, y1: cRect.y1+co.y, x2: cRect.x2+co.x, y2: cRect.y2+co.y]]
END;
--Transfer between client object relative coordinates and ChipNDale global coordinates
MapClientPos: PROC [cPos: ClientPosition←[0, 0], inst: CD.Instance] RETURNS [globPos: CD.Position];
DeMapClientPos: PROC [globPos: CD.Position, inst: CD.Instance] RETURNS [cPos: ClientPosition];
MapClientRect: PROC [cRect: ClientRect, inst: CD.Instance] RETURNS [globRect: CD.Rect];
DeMapClientRect:
PROC [globRect:
CD.Rect, inst:
CD.Instance]
RETURNS [cRect: ClientRect];
PositionFromPairO:
PROC [ob:
CD.Object,
cPos: ClientPosition←[0,0],
correspondingGlobPos: CD.Position←[0,0],
orientation: CD.Orientation𡤀
] RETURNS [appPos: CD.Position];
--Computes a position useable for an application, such that the
--client-origin relative point cPos is at the global position correspondingGlobPos
PositionFromPairI:
PROC [ob:
CD.Object,
cPos: ClientPosition←[0,0],
correspondingGlobPos: CD.Position←[0,0],
orientation: CD.Orientation𡤀
] RETURNS [iPos: CD.Position];
--Computes the position of the interest rect, such that the client-origin
--relative point cPos is at the global position correspondingGlobPos
END.