CDDefaultProcsImpl.mesa (part of ChipNDale)
Copyright © 1985 by Xerox Corporation. All rights reserved.
by Ch. Jacobi, May 22, 1985 3:35:49 pm PDT
last edited by Ch. Jacobi, August 28, 1985 5:56:53 pm PDT
DIRECTORY
Atom,
CD,
CDInstances,
CDBasics,
CDDefaultProcs,
CDDefaultProcsExtras,
CDDirectory,
CDOrient,
Imager,
Rope;
CDDefaultProcsImpl: CEDAR PROGRAM
IMPORTS Atom, CD, --CDInstances,-- CDBasics, CDDirectory, CDOrient, Imager, Rope
EXPORTS CDDefaultProcs, CDDefaultProcsExtras
SHARES CD =
BEGIN
OPEN CD;
--Object class implementors business
--ObjectClass
QuickDrawMe: PUBLIC PROC [inst: Instance, pos: Position, orient: Orientation, pr: REF DrawInformation] =
BEGIN
IF inst.ob.class.drawMe#DrawMe THEN
inst.ob.class.drawMe[inst, pos, orient, pr]
ELSE {
--pr.drawRect[CDOrient.RectAt[pos, inst.ob.size, orient], CD.highLightShade, pr]
ob1: CD.Object = CDDirectory.ExpandHard[inst.ob, pr.design, NIL];
IF ob1#NIL THEN {
pseudoInst: CD.Instance = NEW[CD.InstanceRep
← [ob: ob1, properties: inst.properties, location: pos, selected: FALSE]];
ob1.class.quickDrawMe[pseudoInst, pos, orient, pr];
pseudoInst.ob ← NIL;
pseudoInst.properties ← NIL;
}
ELSE pr.drawRect[CDOrient.RectAt[pos, inst.ob.size, orient], CD.highLightShade, pr]
}
END;
DrawMe: PUBLIC PROC [inst: Instance, pos: Position, orient: Orientation, pr: REF DrawInformation] =
BEGIN
IF inst.ob.class.quickDrawMe#QuickDrawMe THEN
inst.ob.class.quickDrawMe[inst, pos, orient, pr]
ELSE {
ob1: CD.Object = CDDirectory.ExpandHard[inst.ob, pr.design, NIL];
IF ob1#NIL THEN {
pseudoInst: CD.Instance = NEW[CD.InstanceRep
← [ob: ob1, properties: inst.properties, location: pos, selected: FALSE]];
ob1.class.drawMe[pseudoInst, pos, orient, pr];
pseudoInst.ob ← NIL;
pseudoInst.properties ← NIL;
}
ELSE pr.drawRect[CDOrient.RectAt[pos, inst.ob.size, orient], CD.highLightShade, pr]
}
END;
ShowMeSelected: PUBLIC PROC [inst: Instance, pos: Position, orient: Orientation, pr: REF DrawInformation] =
BEGIN
pr.drawOutLine[
CDOrient.MapRect[
itemInCell: CD.InterestRect[inst.ob],
cellSize: inst.ob.size,
cellInstOrient: orient,
cellInstPos: pos
],
pr
]
END;
ShowMeSelectedWithExpand: PUBLIC PROC [inst: Instance, pos: Position, orient: Orientation, pr: REF DrawInformation] =
BEGIN
ob1: CD.Object = CDDirectory.Expand[inst.ob, NIL, NIL];
IF ob1=NIL THEN pr.drawOutLine[
CDOrient.MapRect[
itemInCell: CD.InterestRect[inst.ob],
cellSize: inst.ob.size,
cellInstOrient: orient,
cellInstPos: pos
],
pr]
ELSE ob1.class.showMeSelected[
inst: NEW [CD.InstanceRep ← [ob: ob1,
location: inst.location,
orientation: inst.orientation,
selected: inst.selected
]],
pos: pos,
orient: orient,
pr: pr];
END;
HitInside: PUBLIC PROC [ob: Object, hitRect: Rect] RETURNS [BOOL] =
BEGIN
RETURN [CDBasics.Intersect[CD.InterestRect[ob], hitRect] ]
END;
InterestRect: PUBLIC PROC [ob: Object] RETURNS [Rect] =
BEGIN
RETURN [CDBasics.RectAt[[0, 0], ob.size]]
END;
InterestRectWithExpand: PUBLIC PROC [ob: Object] RETURNS [Rect] =
BEGIN
ob1: CD.Object = CDDirectory.Expand[ob, NIL, NIL];
IF ob1#NIL THEN RETURN [CD.InterestRect[ob1]]
ELSE RETURN [CDBasics.RectAt[[0, 0], ob.size]];
END;
OldInsideRect: PUBLIC PROC [ob: Object] RETURNS [Rect] =
BEGIN
RETURN [CD.InterestRect[ob]]
END;
InternalWrite: PUBLIC PROC [me: Object] =
BEGIN
ERROR
END;
InternalRead: PUBLIC PROC [] RETURNS [Object] =
BEGIN
ERROR
END;
Describe: PUBLIC PROC [me: Object] RETURNS [Rope.ROPE] =
BEGIN
Desc: PROC [class: REF READONLY CD.ObjectClass] RETURNS [Rope.ROPE] =
INLINE BEGIN
RETURN [
IF class.description=NIL THEN Atom.GetPName[class.objectType]
ELSE class.description
]
END;
IF me.class.inDirectory THEN {
n: Rope.ROPE = CDDirectory.Name[me];
IF ~Rope.IsEmpty[n] THEN RETURN [Rope.Cat[Desc[me.class], " ", n]]
};
RETURN [Desc[me.class]]
END;
DescribeInstance: PUBLIC PROC [ap: Instance] RETURNS [Rope.ROPE] =
BEGIN
RETURN [ap.ob.class.describe[ap.ob]]
END;
Origin: PUBLIC PROC [ob: Object] RETURNS [Position] =
BEGIN
RETURN [CDBasics.BaseOfRect[ob.class.interestRect[ob]]]
END;
--DrawProcs
DrawChild: PUBLIC PROC [inst: Instance, pos: Position, orient: Orientation, pr: REF DrawInformation] =
BEGIN
inst.ob.class.drawMe[inst, pos, orient, pr]
END;
DrawRect: PUBLIC PROC [r: Rect, l: Layer, pr: DrawRef] =
BEGIN
DrawRectInContext: PROC [context: Imager.Context, ob: CD.Object, layer: CD.Layer] =
BEGIN
Imager.MaskBox[context, [xmin: r.x1, xmax: r.x2, ymin: r.y1, ymax: r.y2]];
END;
pr.drawContext[pr, DrawRectInContext, NIL, [0, 0], 0, l]
END;
DrawOutLine: PUBLIC PROC [r: Rect, pr: DrawRef] =
BEGIN
END;
DrawComment: PUBLIC PROC [r: Rect, comment: Rope.ROPE, pr: DrawRef] =
BEGIN
END;
DrawContext: PUBLIC PROC [pr: DrawRef, proc: DrawContextLayerProc, ob: Object, pos: Position, orient: Orientation, layer: Layer] =
--calls proc which may use context; mode and color are set to layer's need
--call is suppressed if layer does not need drawing; this is default.
--on recursive calls, the context may or may not include previous transformations
BEGIN
IF pr.deviceContext#NIL AND pr.contextFilter#NIL AND pr.contextFilter[layer].doit THEN {
Action: PROC [] =
BEGIN
IF ob#NIL THEN {
Imager.TranslateT[pr.deviceContext, [pos.x, pos.y]];
CDOrient.OrientateContext[pr.deviceContext, ob.size, orient];
};
Imager.SetColor[pr.deviceContext, pr.contextFilter[layer].color];
proc[pr.deviceContext, ob, layer];
END;
Imager.DoSave[pr.deviceContext, Action];
}
END;
SetGround: PUBLIC PROC [pr: DrawRef, pushedOut: BOOL] =
BEGIN
END;
END.