DIRECTORY List, TableBase, TableConstraints, TableLayout, TextNode, TSArtwork, TSFont, TSGlue, TSGraphic, TSObject, TSOps, TSOutput, TSTranslate, TSTranslatePrivate, TSTypes; TryItImpl: CEDAR PROGRAM IMPORTS List, TableBase, TableConstraints, TSFont, TSGlue, TSObject, TSOps, TSOutput, TSTranslate, TSTranslatePrivate, TSTypes = { OPEN TableBase, TableLayout; MakeExtentsValid: PROC [box: TableBase.RefTableBox] ~ { IF NOT box.nodeExtentsValid THEN { box.tsObject _ CreateTypesetObject[box.node]; box.nodeExtents _ box.tsObject.layoutProc[box.tsObject]; box.nodeExtentsValid _ TRUE; }; }; BaselineList: TYPE ~ REF BaselineListRec; BaselineListRec: TYPE ~ RECORD [ x, y: TSTypes.Dimn, extent: TSTypes.Dimensions]; BaselinesFromDownList: PROCEDURE [box: TableBase.RefTableBox] RETURNS [baselineList: LIST OF BaselineList] ~ TRUSTED { IF NOT box.nodeExtentsValid THEN MakeExtentsValid[box]; WITH b: BoxFromTypesetObject[box.tsObject] SELECT FROM list => { source: TSObject.ListReader _ b.items.CreateReader[]; x: TSTypes.Dimn _ TSTypes.zeroDimn; y: TSTypes.Dimn _ TSTypes.zeroDimn; alignX: TSTypes.Dimn _ TSTypes.zeroDimn; IF b.direction # down THEN ERROR ImplementationError["expected down list"]; UNTIL source.End[] DO SELECT source.CurrentTag[] FROM exception => { item: REF ANY _ source.CurrentItem[]; SELECT TRUE FROM ISTYPE[item, TSObject.Box] => { WITH b: NARROW[item, TSObject.Box] SELECT FROM list => { x _ x.AddDimn[b.extent[left]]; y _ y.AddDimn[b.extent[up]]; baselineList _ CONS[NEW[BaselineListRec _ [x, y, b.extent]], baselineList]; alignX _ PositionOfAlignChar[box.alignChar, box.alignFirst, b.items.CreateReader[], b.glueset]; }; ENDCASE => ERROR; }; ISTYPE[item, TSObject.Glue] => { glue: TSObject.Glue ~ NARROW[item]; delta: TSTypes.Dimn ~ TSGlue.FixGlue[glue^, b.glueset]; y _ y.AddDimn[delta]; }; ISTYPE[item, TSObject.Kern] => { kern: TSObject.Kern ~ NARROW[item]; y _ y.AddDimn[kern^]; }; ENDCASE => ERROR; }; ENDCASE => ERROR; source.Next[]; ENDLOOP; }; ENDCASE => ERROR ImplementationError["Expecting a down list box from a TypsetObject"]; IF baselineList # NIL THEN TRUSTED { baselineList _ LOOPHOLE[List.Reverse[LOOPHOLE[baselineList]]]; }; }; PositionOfAlignChar: PROC [alignChar: CHAR, alignFirst: BOOLEAN, boxList: TSObject.ListReader, glueSet: TSGlue.GlueSet] RETURNS [alignX: TSTypes.Dimn] ~ { direction: TSObject.Direction ~ right; opposite: TSObject.Direction ~ left; x: TSTypes.Dimn _ TSTypes.zeroDimn; lastCharX: TSTypes.Dimn _ TSTypes.zeroDimn; UNTIL boxList.End[] DO SELECT boxList.CurrentTag[] FROM char => { thisChar: CHAR ~ boxList.CurrentChar[]; extent: TSTypes.Dimensions _ boxList.currentFont.CharDimensions[thisChar]; IF alignChar = thisChar THEN { IF alignFirst THEN RETURN [lastCharX]; }; lastCharX _ x _ x.AddDimn[extent[direction].SubDimn[extent[opposite]]]; boxList.Next[]; }; space => { WHILE boxList.CurrentTag[] = space DO x _ x.AddDimn[TSGlue.FixGlue[boxList.currentFont.SpaceGlue[], glueSet]]; boxList.Next[]; ENDLOOP; }; exception => { item: REF ANY _ boxList.CurrentItem[]; SELECT TRUE FROM ISTYPE[item, TSObject.Glue] => { g: TSObject.Glue _ NARROW[item]; x _ x.AddDimn[TSGlue.FixGlue[g^, glueSet]]; boxList.Next[]; }; ISTYPE[item, TSObject.Kern] => { x _ x.AddDimn[NARROW[item, TSObject.Kern]^]; boxList.Next[]; }; ENDCASE => ERROR UnimplementedCase; }; ENDCASE => ERROR UnimplementedCase; ENDLOOP; RETURN [lastCharX]; }; CreateTypesetObject: TSArtwork.ObjectFromBranchProc = { object _ NEW[TSGraphic.ObjectRec]; object.paintProc _ TypesetObjectPaint; object.layoutProc _ TypesetObjectLayout; object.data _ NEW[TypesetObjectRec _ [node: node]]; }; TypesetObjectRec: TYPE = RECORD [ node: TextNode.Ref, vlist: TSObject.ItemList, box: TSObject.Box ]; TypesetObjectLayout: TSGraphic.LayoutProc = TRUSTED { data: REF TypesetObjectRec _ NARROW[self.data]; data.vlist _ TSTranslate.TreeToVlist[data.node].galley; TSTranslatePrivate.InitializeStateForNewNode[ data.vlist.listWriter, NARROW[data.vlist.listWriter.writerData] ]; data.box _ TSOps.GetSlimBoxFrom[data.vlist]; extent _ data.box.extent; }; TypesetObjectPaint: TSGraphic.PaintProc = { data: REF TypesetObjectRec _ NARROW[self.data]; TSOutput.BoxOut[NARROW[context], originX, originY, data.box^]; }; BoxFromTypesetObject: PROC [self: TSGraphic.Object] RETURNS [box: TSObject.Box] ~ { data: REF TypesetObjectRec _ NARROW[self.data]; box _ data.box; }; }. LTryItImpl.Mesa Created by Rick Beach, October 14, 1984 1:41:34 pm PDT ΚΟ˜™J™6—unitšΟk ˜ J˜J˜ J˜J˜ J˜ J˜ Jšœ˜Jšœ˜Jšœ ˜ Jšœ ˜ J˜Jšœ ˜ J˜ J˜Jšœ˜—šœ œ˜Jšœw˜~Jšœ˜Jšœ˜J˜—šΟnœœ!˜7šœœœ˜"Jšœ-˜-Jšœ8˜8Jšœœ˜J˜—J˜—Kšœœœ˜)šœœœ˜ J˜J˜—š žœ œœœœœ˜vJšœœœ˜7šœ'œ˜6šœ ˜ J˜5J˜#J˜#J˜(Jšœœœ+˜Kšœ˜šœ˜šœ˜Jšœœœ˜%šœœ˜šœ˜šœœœ˜.˜ J˜J˜Jšœœœ4˜KJ˜_J˜—Jšœœ˜—J˜—šœ˜ Jšœœ˜#J˜7Jšœ˜J˜—šœ˜ Jšœœ˜#Jšœ˜J˜—Jšœœ˜—Jšœ˜—Jšœœ˜—J˜Jšœ˜—Jšœ˜—JšœœF˜V—Jš œœœœœœ˜fJ˜—š žœœ œœ9œ˜šJ˜&J˜$J˜#J˜+šœ˜šœ˜ šœ ˜ Jšœ œ˜'JšœJ˜Jšœœ˜Jšœ œœ ˜&Jšœ˜—J˜GJšœ˜Jšœ˜—šœ ˜ šœ˜%JšœH˜HJšœ˜Jšœ˜—Jšœ˜—šœ˜Jšœœœ˜&šœœ˜šœ˜ Jšœœ˜ J˜+Jšœ˜J˜—šœ˜ Jšœœ˜,Jšœ˜J˜—Jšœœ˜#—Jšœ˜—Jšœœ˜#—Jš˜—Jšœ ˜J˜—šžœ$˜7Jšœ œ˜"J˜&J˜(Jšœœ"˜3J˜—šœœœ˜!J˜J˜J˜J˜—šžœœ˜5Jšœœœ ˜/J˜7˜-J˜Jšœ"˜(J˜—Jšœ,˜,Jšœ˜J˜—šžœ˜+Jšœœœ ˜/Jšœœ(˜>J˜—šžœœœ˜SJšœœœ ˜/J˜J˜—J˜J˜—…—)