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: BOOL_FALSE] = 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: BOOL_TRUE] RETURNS [indOb: CD.Object] = 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. ZCDIndirectObjectsImpl.mesa Copyright c 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 --design: where pointOb already is and indOb will be included Κ«˜code™Kšœ Οmœ1™