DIRECTORY CD, CDApplications, CDBasics, CDCells, CDCommandOps, CDDirectory, CDMarkObjects, CDOps, CDOrient, CDSequencer, Process, Rope, TerminalIO; CDMacroImpl: CEDAR PROGRAM IMPORTS CD, CDApplications, CDBasics, CDCells, CDCommandOps, CDMarkObjects, CDOps, CDOrient, CDSequencer, Process, Rope, TerminalIO SHARES CD, CDDirectory = BEGIN pForMacro: REF CD.ObjectProcs = CD.RegisterObjectType[$Macro]; pForCells: REF READONLY CD.ObjectProcs = CDCells.CreateEmptyCell[].p; CellToMacro: PROC[ob: CD.ObPtr] = BEGIN TerminalIO.WriteRope["**CellToMacro called "]; IF ob=NIL OR ob.specificRef=NIL THEN TerminalIO.WriteRope["bad object\n"] ELSE IF NOT ISTYPE[ob.specificRef, CD.CellPtr] THEN TerminalIO.WriteRope["object not cell\n"] ELSE { ob.p _ pForMacro; TerminalIO.WriteRope[" done\n"] } END; MacroAdjust: PROC [ob: CD.ObPtr, newBound: CD.DesignRect] = BEGIN TerminalIO.WriteRope["**MacroAdjust called "]; IF ob=NIL OR ob.specificRef=NIL THEN TerminalIO.WriteRope["bad object\n"] ELSE IF NOT ISTYPE[ob.specificRef, CD.CellPtr] THEN TerminalIO.WriteRope["object not cell\n"] ELSE { adjustItself: CDDirectory.AdjustItselfProc = NARROW[pForCells.directoryProcs, REF CDDirectory.DirectoryProcs]^.adjustItself; adjustItself[ob, newBound]; TerminalIO.WriteRope[" done\n"] } END; Describe: PROC[me: CD.ObPtr] RETURNS [Rope.ROPE] = BEGIN cptr: CD.CellPtr = NARROW[me.specificRef]; RETURN [Rope.Concat["special cell ", cptr.name]] END; AdjustItself: CDDirectory.AdjustItselfProc -- PROC [objToReposition: CD.ObPtr, newBound: CD.DesignRect] -- = BEGIN END; RepositionElements: CDDirectory.RepositionElementsProc -- PROC [me: CD.ObPtr, objToReposition: CD.ObPtr, oldSize: CD.DesignPosition, newBound: CD.DesignRect, design: CD.Design] -- = BEGIN END; ComputeBounds: CDDirectory.ComputeBoundsProc -- PROC [ob: CD.ObPtr] RETURNS [CD.DesignRect] -- = BEGIN RETURN [[x1: 0, y1: 0, x2: ob.size.x, y2: ob.size.y]]; END; InternalRead: CD.InternalReadProc --PROC [] RETURNS [ObPtr]-- = BEGIN ob: CD.ObPtr _ pForCells.internalRead[]; ob.p _ pForMacro; RETURN [ob] END; MakeSubClass: PROC[me: REF CD.ObjectProcs, from: REF READONLY CD.ObjectProcs] = BEGIN dummy: REF CD.ObjectProcs _ NEW[CD.ObjectProcs_from^]; dummy.further _ me.further; dummy.technology _ me.technology; dummy.objectType _ me.objectType; IF dummy.inDirectory THEN { dummy.directoryProcs _ NEW[CDDirectory.DirectoryProcs_ NARROW[from.directoryProcs, REF CDDirectory.DirectoryProcs]^ ]; }; me^ _ dummy^; END; DrawSelection: PROC [aptr: CD.ApplicationPtr, pos: CD.DesignPosition, orient: CD.Orientation, pr: CD.DrawRef] = BEGIN pr.drawRect[CDOrient.RectAt[pos, aptr.ob.size, orient], CD.highLightShade, pr] END; Init: PROC [] = INLINE BEGIN dp: REF CDDirectory.DirectoryProcs; MakeSubClass[me: pForMacro, from: pForCells]; dp _ NARROW[pForMacro.directoryProcs]; dp.adjustItself _ AdjustItself; dp.repositionElements _ RepositionElements; dp.computeBounds _ ComputeBounds; pForMacro.describe _ Describe; pForMacro.internalRead _ InternalRead; pForMacro.showMeSelected _ DrawSelection; CDSequencer.ImplementCommand[$TModifyMacroS, ModifyMacroS]; CDSequencer.ImplementCommand[$ModifyMacroS, SetMacroRectComm]; END; ModifyMacroS: PROC [comm: CDSequencer.Command] = BEGIN ap: CD.ApplicationPtr; multiple: BOOL; TerminalIO.WriteRope["Macro modifications\n"]; [ap, multiple] _ CDOps.SelectedApplication[comm.design]; IF multiple THEN TerminalIO.WriteRope[" multiple selection; not done\n"] ELSE IF ap=NIL THEN TerminalIO.WriteRope[" no selection; not done\n"] ELSE { rect: CD.DesignRect _ CDApplications.ARectO[ap]; TerminalIO.WriteRope[ap.ob.p.describe[ap.ob]]; IF ISTYPE[ap.ob.specificRef, CD.CellPtr] THEN { cptr: CD.CellPtr ~ NARROW[ap.ob.specificRef]; IF ap.ob.p=pForCells THEN { TerminalIO.WriteRope[" is ordinary cell\n"]; IF TerminalIO.UserSaysYes[label: "transform to macro", text: "transform cell to macro "] THEN { CellToMacro[ap.ob] } ELSE TerminalIO.WriteRope[" no\n"]; }; IF ap.ob.p#pForMacro THEN { TerminalIO.WriteRope[" not a macro; not done\n"]; RETURN }; pForMacro.showMeSelected _ pForCells.showMeSelected; DO m: INT; n: CARDINAL; rect _ CDBasics.Surround[rect, CDApplications.ARectO[ap]]; CDOps.Redraw[comm.design, rect]; CDOps.DoTheDelayedRedraws[comm.design]; Process.Pause[Process.MsecToTicks[100]]; -- to allow drawing n _ TerminalIO.RequestSelection[label: "macro commands", choice: LIST["exit macro commands", "x-position", "y-position", "x-size", "y-size", "pause for redraw"] ]; SELECT n FROM 1 => EXIT; 2 => { m _ TerminalIO.RequestInt["change x position > "]; MacroAdjust[ob: ap.ob, newBound: [x1: m, y1: 0, x2: ap.ob.size.x, y2: ap.ob.size.y]]; TerminalIO.WriteLn[]; }; 3 => { m _ TerminalIO.RequestInt["change y position > "]; MacroAdjust[ob: ap.ob, newBound: [x1: 0, y1: m, x2: ap.ob.size.x, y2: ap.ob.size.y]]; TerminalIO.WriteLn[]; }; 4 => { m _ TerminalIO.RequestInt["change x size > "]; MacroAdjust[ob: ap.ob, newBound: [x1: 0, y1: 0, x2: ap.ob.size.x+m, y2: ap.ob.size.y]]; TerminalIO.WriteLn[]; }; 5 => { m _ TerminalIO.RequestInt["change y size > "]; MacroAdjust[ob: ap.ob, newBound: [x1: 0, y1: 0, x2: ap.ob.size.x, y2: ap.ob.size.y+m]]; TerminalIO.WriteLn[]; }; 6 => Process.Pause[Process.MsecToTicks[200]]; ENDCASE => TerminalIO.WriteRope[" no selection\n"]; ENDLOOP; pForMacro.showMeSelected _ DrawSelection; TerminalIO.WriteRope[" end macro commands\n"]; } ELSE TerminalIO.WriteRope[" not a cell; not done\n"]; } END; SetMacroRect: PROC [mOb: CD.ObPtr] = BEGIN rect: CD.DesignRect _ mOb.p.insideRect[mOb]; bl, ur: BOOL_FALSE; Enumerate: PROC [markApp: CD.ApplicationPtr] RETURNS [quit: BOOL_FALSE] = BEGIN pos: CD.DesignPosition; name: Rope.ROPE = CDMarkObjects.GetMarkName[markApp]; IF Rope.Equal[name, "0"] THEN { IF bl THEN TerminalIO.WriteRope["multiple 0 marks\n"]; bl _ TRUE; pos _ CDMarkObjects.GetMarkPosition[markApp]; rect.x1 _ pos.x; rect.y1 _ pos.y } ELSE IF Rope.Equal[name, "1"] THEN { IF ur THEN TerminalIO.WriteRope["multiple 1 marks\n"]; ur _ TRUE; pos _ CDMarkObjects.GetMarkPosition[markApp]; rect.x2 _ pos.x; rect.y2 _ pos.y } END; [] _ CDMarkObjects.EnumerateMarks[cellOb: mOb, proc: Enumerate]; IF rect.x1>rect.x2 OR rect.y1>rect.y2 THEN { TerminalIO.WriteRope["bad rectangle\n"]; rect_CDBasics.empty; }; IF rect.x1>rect.x2 OR rect.y1>rect.y2 THEN { TerminalIO.WriteRope["marks are badly placed\n"]; rect _ CDBasics.empty; }; IF CDBasics.NonEmpty[rect] THEN MacroAdjust[mOb, rect] ELSE TerminalIO.WriteRope["not done\n"]; END; SetMacroRectComm: PROC [comm: CDSequencer.Command] = BEGIN aptr: CD.ApplicationPtr = CDCommandOps.TheApplication[comm, "Recompute interestrect"]; IF aptr#NIL THEN { IF ISTYPE[aptr.ob.specificRef, CD.CellPtr] THEN { IF aptr.ob.p=pForCells THEN { TerminalIO.WriteRope[" is ordinary cell\n"]; IF TerminalIO.UserSaysYes[label: "transform to macro", text: "transform cell to macro "] THEN CellToMacro[aptr.ob] ELSE { TerminalIO.WriteRope[" no\n"]; RETURN }; }; SetMacroRect[aptr.ob]; CDCommandOps.RedrawApplication[comm.design, aptr]; } ELSE TerminalIO.WriteRope[" not done; Selected object is not macro or cell\n"]; } END; Init[]; END. ΘCDMacroImpl.mesa (part of Chipndale) Copyright c 1984 by Xerox Corporation. All rights reserved. by Christian Jacobi April 23, 1984 5:18:54 pm PST last edited Christian Jacobi March 23, 1984 8:45:25 am PST --don't do that accidently --don't do that --here you cheat; therefore this tye is made !!!!!!! --me, from must have been registered! --does NOT subClass the furtherprocs --handle the following fields specially --handle directory --do overwrite all the other fields --xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx --commands --now do it --uses the marks "BottomLeft" and "UpperRight" to overide --coordinates, initialized with innerrect --xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Κ ˜šœ&™&Jšœ Οmœ1™Jšœ žœžœžœ+˜EJ˜šΟn œžœžœ ˜!Jšž˜Jšœ.˜.Jš žœžœžœžœžœ%˜IJš žœžœžœžœžœ žœ*˜]šžœ˜Jšœ˜Jšœ ˜ J˜—Jšžœ˜—J˜š  œžœžœžœ˜;Jšž˜Jšœ.˜.Jš žœžœžœžœžœ%˜IJš žœžœžœžœžœ žœ*˜]šžœ˜šœ-˜-Jšžœžœ+˜O—Jšœ˜Jšœ ˜ J˜—Jšžœ˜—J˜š  œžœžœžœžœ˜3Jšž˜Jšœžœ žœ˜*Jšžœ*˜0Jšžœ˜J˜—šŸ œ˜+JšΟc?œ˜AJšž˜Jšœ™Jšžœ˜—J˜šŸœ$˜6Jš‘|œ˜~Jšž˜Jšœ™Jšžœ˜—J˜šŸ œ ˜-Jš‘1œ˜3Jšž˜Jšœ4™4Jšžœ0˜6Jšžœ˜—J˜šŸ œžœ‘œ˜?Jšž˜Jšœ(˜(Jšœ˜Jšžœ˜ Jšžœ˜—Icode˜š  œžœžœžœžœžœžœ˜OJšœ%™%J™$Jšž˜Jš œžœžœžœžœ˜6šœ'™'Jšœ˜Jšœ!˜!Jšœ!˜!—šœ™šžœžœ˜šœžœ˜6Jšžœžœ˜˜>Jšžœ˜—J˜Jšœ2™2Jšœ ™ J˜š  œžœ˜0Jšž˜Jšœžœ˜Jšœ žœ˜J˜/Jšœ8˜8Jšžœ žœ;˜KJšžœžœžœžœ5˜Hšžœ˜Jšœžœ(˜0Jšœ.˜.šžœžœžœ žœ˜/Jšœžœ žœ˜-šžœžœ˜Jšœ,˜,šžœWžœ˜_Jšœ˜J˜—Jšžœ˜#J˜—šžœžœ˜Jšœ1˜1Jšž˜J˜—Jšœ ™ Jšœ4˜4šž˜Jšœžœ˜Jšœžœ˜ Jšœ:˜:Jšœ ˜ Jšœ'˜'Jšœ)‘˜<šœ8˜8Jšœžœ[˜gJ˜—šžœž˜ Jšœžœ˜ ˜Jšœ2˜2JšœU˜UJšœ˜J˜—˜Jšœ2˜2JšœU˜UJšœ˜J˜—˜Jšœ.˜.JšœW˜WJšœ˜J˜—˜Jšœ.˜.JšœW˜WJšœ˜J˜—Jšœ-˜-Jšžœ,˜3—Jšžœ˜—Jšœ)˜)Jšœ.˜.J˜—Jšžœ2˜6Jšœ˜—Jšžœ˜Jšœ˜—š  œžœžœ ˜$Jšœ9™9Jšœ)™)Jšž˜Jšœžœ$˜,Jšœžœžœ˜š   œžœ žœžœžœžœ˜IJšž˜Jšœžœ˜Jšœ žœ&˜5šžœžœ˜Jšžœžœ,˜6Jšœžœ˜ Jšœ-˜-Jšœ˜Jšœ˜Jšœ˜—šžœžœžœ˜$Jšžœžœ,˜6Jšœžœ˜ Jšœ-˜-Jšœ˜Jšœ˜J˜—Jšžœ˜—Jšœ@˜@šžœžœžœ˜,Jšœ(˜(Jšœ˜J˜—šžœžœžœ˜,Jšœ1˜1Jšœ˜J˜—Jšžœžœ˜7Jšžœ$˜(Jšžœ˜—J˜š œžœ˜4Jšžœ˜JšœžœN˜Všžœžœžœ˜šžœžœžœ ž˜1šžœžœ˜Jšœ,˜,JšžœWžœ˜ršžœ˜Jšœ˜Jšž˜J˜—J˜—Jšœ˜Jšœ2˜2J˜—JšžœL˜PJ˜—Jšžœ˜—J™Jšœ2™2J˜J˜Jšžœ˜J˜—…—ΐ'”