DIRECTORY Atom, CD, CDCallSpecific, CDInline, CDIO, CDLRUCache, CDOrient, CDProperties, CDRects, CDTechnology, Rope, SafeStorage, TokenIO; CDRectsImpl: CEDAR MONITOR IMPORTS Atom, CD, CDCallSpecific, CDInline, CDIO, CDLRUCache, CDOrient, CDProperties, CDTechnology, Rope, SafeStorage, TokenIO EXPORTS CDRects SHARES CD = BEGIN permanent: ZONE = SafeStorage.GetPermanentZone[]; lambda: CD.DesignNumber = CD.lambda; dummyRectPtr: CD.RectPtr = permanent.NEW[CD.RectRecord _ [filler: NIL]]; bCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 50, newProc: New]; sCache: CDLRUCache.LRUCache = CDLRUCache.Create[size: 30, newProc: New]; New: PROC [] RETURNS [CD.ObPtr] = { ob: CD.ObPtr _ NEW[CD.ObjectDefinition]; ob.specificRef _ dummyRectPtr; RETURN [ob] }; CreateRectProc: TYPE = PROC [size: CD.DesignPosition, l: CD.Level] RETURNS [CD.ObPtr] _ CreateBareRect; createRectArray: REF ARRAY CD.Level OF CreateRectProc = permanent.NEW[ARRAY CD.Level OF CreateRectProc]; -- initialized by default CreateRect: PUBLIC PROC [size: CD.DesignPosition, l: CD.Level] RETURNS [CD.ObPtr] = BEGIN RETURN [createRectArray[l][size, l]] END; HangExtensionsOn: PROC[on: REF CD.ObjectProcs] = BEGIN CDCallSpecific.Register[$Lengthen, on, Lengthen]; CDCallSpecific.Register[$Default, on, Defaulten]; END; UseAsCreateRect: PUBLIC PROC [ l: CD.Level, createRect: PROC [size: CD.DesignPosition, l: CD.Level] RETURNS [CD.ObPtr], hangExtensionsOn: REF CD.ObjectProcs ] = BEGIN IF createRect=NIL THEN createRect _ CreateBareRect; createRectArray[l] _ createRect; IF hangExtensionsOn#NIL THEN HangExtensionsOn[hangExtensionsOn]; CDProperties.PutPropOnLevel[onto: l, prop: $CDxRectCreation, val: $CDxUser]; END; CreateBareRect: PUBLIC PROC [size: CD.DesignPosition, l: CD.Level] RETURNS [CD.ObPtr] = BEGIN rp: CD.ObPtr ~ bCache.UnusedOrNew[]; rp.p _ pForRects; rp.size _ CDInline.MaxPoint[size, [1, 1]]; rp.level _ l; RETURN [bCache.ReplaceByAequivalent[rp]] END; CreateSaveRect: PUBLIC PROC [size: CD.DesignPosition, l: CD.Level] RETURNS [CD.ObPtr] = BEGIN rp: CD.ObPtr ~ sCache.UnusedOrNew[]; rp.p _ pForSaveRects; rp.size _ CDInline.MaxPoint[size, [lambda, lambda]]; rp.level _ l; RETURN [sCache.ReplaceByAequivalent[rp]] END; pForRects: REF CD.ObjectProcs; pForSaveRects: REF CD.ObjectProcs; Init: PROC [] = BEGIN pForRects _ CD.RegisterObjectType[$Rect]; pForRects.drawMe _ pForRects.quickDrawMe _ DrawMeForRects; pForRects.internalRead _ ReadRect; pForRects.internalWrite _ WriteRect; pForRects.describe _ Describe; pForRects.wireTyped _ TRUE; HangExtensionsOn[pForRects]; pForSaveRects _ CD.RegisterObjectType[$SaveRect]; pForSaveRects.drawMe _ pForSaveRects.quickDrawMe _ DrawMeForSaveRects; pForSaveRects.internalRead _ ReadRect; pForSaveRects.internalWrite _ WriteRect; pForSaveRects.describe _ Describe; pForSaveRects.wireTyped _ TRUE; HangExtensionsOn[pForSaveRects]; END; Describe: PROC[me: CD.ObPtr] RETURNS [Rope.ROPE] = BEGIN RETURN [Rope.Concat["rect ", Atom.GetPName[CD.LevelKey[me.level]]]] END; DrawMeForRects: PROC [aptr: CD.ApplicationPtr, pos: CD.DesignPosition, orient: CD.Orientation, pr: CD.DrawRef] = BEGIN pr.drawRect[CDOrient.RectAt[pos, aptr.ob.size, orient], aptr.ob.level, pr] END; DrawMeForSaveRects: PROC [aptr: CD.ApplicationPtr, pos: CD.DesignPosition, orient: CD.Orientation, pr: CD.DrawRef] = BEGIN pr.saveRect[CDOrient.RectAt[pos, aptr.ob.size, orient], aptr.ob.level, pr] END; Lengthen: CDCallSpecific.CallProc = BEGIN sz: CD.DesignPosition _ CDInline.SizeOfRect[aptr.ob.p.insideRect[aptr.ob]]; amount: CD.DesignPosition; IF x=NIL THEN amount _ [0, lambda] ELSE IF ISTYPE [x, REF CD.DesignPosition] THEN amount _ NARROW[x, REF CD.DesignPosition]^ ELSE {done_FALSE; RETURN}; sz _ CDInline.AddPoints[sz, amount]; IF sz.x<=0 OR sz.y<=0 THEN {done _ FALSE; RETURN}; aptr.ob _ CreateRect[sz, aptr.ob.level]; repaintMe _ TRUE; END; Defaulten: CDCallSpecific.CallProc = BEGIN sz: CD.DesignPosition _ CDInline.SizeOfRect[aptr.ob.p.insideRect[aptr.ob]]; w: CD.DesignNumber _ CDTechnology.LevelWidth[design, aptr.ob.level]; IF w<=0 THEN {done _ FALSE; RETURN}; sz.x _ w; aptr.ob _ CreateRect[sz, aptr.ob.level]; repaintMe _TRUE; END; SetLength: CDCallSpecific.CallProc = BEGIN newLength: CD.DesignNumber _ NARROW[x, REF CD.DesignNumber]^; sz: CD.DesignPosition _ aptr.ob.size; IF sz.ysz.x THEN sz.x _ newWidth ELSE sz.y _ newWidth; aptr.ob _ CreateRect[sz, aptr.ob.level]; repaintMe _ TRUE; END; WriteRect: CD.InternalWriteProc -- PROC [me: ObPtr] -- = BEGIN sz: CD.DesignPosition = CDInline.SizeOfRect[me.p.insideRect[me]]; TokenIO.WriteInt[sz.x]; TokenIO.WriteInt[sz.y]; CDIO.WriteLevel[me.level]; END; ReadRect: CD.InternalReadProc --PROC [] RETURNS [ObPtr]-- = BEGIN x: INT = TokenIO.ReadInt[]; y: INT = TokenIO.ReadInt[]; l: CD.Level = CDIO.ReadLevel[]; ob: CD.ObPtr = CreateRect[CD.DesignPosition[x, y], l]; RETURN [ob] END; Init[]; END. ŒCDRectsImpl.mesa (part of Chipndale) Copyright c 1983 by Xerox Corporation. All rights reserved. Christian Jacobi June 24, 1983 4:58 pm last edited Christian Jacobi July 20, 1984 9:54:43 am PDT --???setWidth: REF CDCallSpecific.CallProc_permanent.NEW[CDCallSpecific.CallProc_SetWidth]; --???setLength: REF CDCallSpecific.CallProc_permanent.NEW[CDCallSpecific.CallProc_SetLength]; Κc˜šœ&™&Jšœ Οmœ1™