CDIndirectObjectsImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reversed.
Concept by Bertrand Serlet, November 8, 1985 11:34:29 am PST
Created by Christian Jacobi, February 12, 1986 6:50:17 pm PST
Last edited by Christian Jacobi, February 12, 1986 8:46:08 pm PST
DIRECTORY
CD,
CDDirectory,
CDIO,
CDIndirectObjects,
CDProperties,
Rope;
CDIndirectObjectsImpl: CEDAR PROGRAM
IMPORTS CD, CDDirectory, CDIO, CDProperties, Rope
EXPORTS CDIndirectObjects
SHARES CDDirectory =
BEGIN
indirectClass: PUBLIC REF CD.ObjectClass;
dp: REF CDDirectory.DirectoryProcs;
ReduceIndirect: PUBLIC PROC [design: CD.Design, indOb: CD.Object] RETURNS [changed: BOOLFALSE] =
BEGIN
IF indOb.class=indirectClass THEN {
inst: CD.Instance = NARROW[indOb.specificRef];
WHILE inst.ob.class=indirectClass DO
inst2: CD.Instance = NARROW[inst.ob.specificRef];
CDProperties.AppendProps[winner: indOb.properties, looser: inst.ob.properties, putOnto: indOb];
inst.ob ← inst2.ob;
changed ← TRUE;
ENDLOOP;
IF changed THEN CDDirectory.PropagateChange[indOb, design];
}
END;
CreateIndirect: PUBLIC PROC [design: CD.Design, pointOb: CD.Object, reduce: BOOLTRUE] RETURNS [indOb: CD.Object] =
--design: where pointOb already is and indOb will be included
BEGIN
inst: CD.Instance = NEW[CD.InstanceRep←[ob: pointOb]];
IF pointOb=NIL THEN ERROR;
indOb ← NEW[CD.ObjectRep ← [class: indirectClass, size: pointOb.size, specificRef: inst]];
IF reduce THEN [] ← ReduceIndirect[NIL, indOb];
dp.setName[indOb, Rope.Cat["Ind-", CDDirectory.Name[pointOb]]];
IF design#NIL THEN [] ← CDDirectory.Include[design, indOb];
END;
ChangeIndirect: PUBLIC PROC [design: CD.Design, indOb: CD.Object, pointNew: CD.Object] =
BEGIN
inst: CD.Instance = NARROW[indOb.specificRef];
replace: CDDirectory.ReplaceList = LIST[NEW[CDDirectory.ReplaceRec ← [
old: inst.ob,
oldSize: indOb.size,
new: pointNew,
newSize: pointNew.size,
off: [0, 0]
]]];
[] ← CDDirectory.DoReplaceDirectChild[me: indOb, design: design, replace: replace];
END;
Expand: PROC[me: CD.Object, from: CD.Design, to: CD.Design←NIL] RETURNS [ob: CD.Object] =
BEGIN
inst: CD.Instance = NARROW[me.specificRef];
ob ← IF from=to THEN inst.ob ELSE CDDirectory.Another[inst.ob, from, to];
END;
Another: PROC[me: CD.Object, from: CD.Design, to: CD.Design←NIL] RETURNS [CD.Object] =
BEGIN
inst: CD.Instance = NARROW[me.specificRef];
ob1: CD.Object ← IF from=to THEN inst.ob ELSE CDDirectory.Another[inst.ob, from, to];
RETURN [CreateIndirect[design: to, pointOb: ob1, reduce: FALSE]];
END;
EnumChilds: PROC [me: CD.Object, p: CDDirectory.EnumerateObjectsProc, x: REF] =
BEGIN
p[NARROW[me.specificRef, CD.Instance].ob, x];
END;
DrawSelection: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation,
pr: CD.DrawRef] =
BEGIN
ind: CD.Instance = NARROW[inst.ob.specificRef];
ind.ob.class.showMeSelected[ind, pos, orient, pr]
END;
Describe: PROC[me: CD.Object] RETURNS [Rope.ROPE] =
BEGIN
inst: CD.Instance = NARROW[me.specificRef];
RETURN [Rope.Cat["indirect ", inst.ob.class.describe[inst.ob]]];
END;
InterestRect: PROC [ob: CD.Object] RETURNS [CD.Rect] =
BEGIN
RETURN [CD.InterestRect[NARROW[ob.specificRef, CD.Instance].ob]]
END;
Read: CD.InternalReadProc --PROC [] RETURNS [Object]-- =
BEGIN
ind: CD.Object = CDIO.ReadObject[];
RETURN [CreateIndirect[design: CDIO.DesignInReadOperation[], pointOb: ind]];
END;
Write: CD.InternalWriteProc -- PROC [me: Object] -- =
BEGIN
inst: CD.Instance = NARROW[me.specificRef];
CDIO.WriteObject[inst.ob];
END;
ReplaceDirectChild: CDDirectory.ReplaceDChildsProc =
BEGIN
inst: CD.Instance = NARROW[me.specificRef];
rep: REF CDDirectory.ReplaceRec ← NIL;
FOR replaceList: CDDirectory.ReplaceList ← replace, replaceList.rest WHILE replaceList#NIL DO
IF replaceList.first.old=inst.ob THEN {rep ← replaceList.first; EXIT}
ENDLOOP;
IF rep#NIL THEN {
oldSize: CD.Position ← me.size;
inst.ob ← rep.new;
me.size ← rep.new.size;
changed ← TRUE;
IF design#NIL THEN {
CDDirectory.RepositionObject[
design: design,
ob: me,
oldSize: oldSize,
baseOff: rep.off
];
};
}
END;
QuickDrawMe: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: CD.DrawRef] =
BEGIN
ind: CD.Instance = NARROW[inst.ob.specificRef];
ind.ob.class.quickDrawMe[ind, pos, orient, pr];
END;
DrawMe: PROC [inst: CD.Instance, pos: CD.Position, orient: CD.Orientation, pr: CD.DrawRef] =
BEGIN
ind: CD.Instance = NARROW[inst.ob.specificRef];
pr.drawChild[ind, pos, orient, pr];
END;
Origin: PROC [ob: CD.Object] RETURNS [CD.Position] =
BEGIN
inst: CD.Instance = NARROW[ob.specificRef];
RETURN [ inst.ob.class.origin[inst.ob] ];
END;
Init: PROC [] =
BEGIN
indirectClass ← CD.RegisterObjectClass[$indirect];
dp ← CDDirectory.InstallDirectoryProcs[indirectClass];
dp.expand ← Expand;
dp.another ← Another;
dp.enumerateChildObjects ← EnumChilds;
dp.replaceDirectChilds ← ReplaceDirectChild;
indirectClass.origin ← Origin;
indirectClass.drawMe ← DrawMe;
indirectClass.quickDrawMe ← QuickDrawMe;
indirectClass.showMeSelected ← DrawSelection;
indirectClass.internalRead ← Read;
indirectClass.internalWrite ← Write;
indirectClass.interestRect ← InterestRect;
indirectClass.describe ← Describe;
END;
Init[];
END.