CDMakeLabelCell.mesa (part of ChipNDale)
Copyright © 1985 by Xerox Corporation. All rights reserved.
by Christian Jacobi, October 2, 1985 3:46:55 pm PDT
last edited Christian Jacobi, March 19, 1986 3:25:58 pm PST
DIRECTORY
CD,
CDCells,
CDCommandOps,
CDCreateLabels,
CDDirectory,
CDMenus,
CDOps,
CDOrient,
CDProperties,
CDSequencer,
CDTexts,
Imager,
RefTab,
Rope,
TerminalIO;
CDMakeLabelCell: CEDAR PROGRAM
IMPORTS CD, CDCells, CDCommandOps, CDCreateLabels, CDDirectory, CDMenus, CDOps, CDOrient, CDProperties, RefTab, Rope, TerminalIO =
BEGIN
abortPlot: REF BOOLNEW[BOOLFALSE];
contextFilter: REF CD.ContextFilter ← NEW[CD.ContextFilter←ALL[TRUE]];
myProp: REFNEW[INT];
DrawContext: PROC [pr: CD.DrawRef, proc: CD.DrawContextLayerProc, ob: CD.Object, pos: CD.Position, orient: CD.Orientation, layer: CD.Layer] =
BEGIN
IF ob=NIL THEN RETURN;
WITH ob.specificRef SELECT FROM
tp: CDTexts.TextPtr => {
ref: RefTab.Ref ~ NARROW[pr.devicePrivate];
tCell: CD.Object ← NIL;
WITH ref.Fetch[ob].val SELECT FROM
cob: CD.Object => tCell ← cob;
ENDCASE => {
tiogaFont: Imager.Font ← NIL;
WITH CDProperties.GetProp[tp.cdFont.properties, $OriginalFont] SELECT FROM
f: Imager.Font => tiogaFont ← f;
ENDCASE => RETURN;
IF tiogaFont#NIL AND tiogaFont.name.Length[]>17 AND Rope.Equal["Xerox/TiogaFonts/", tiogaFont.name.Substr[len: 17], FALSE] THEN {
--realy is tiogafont
tCell ← CDCreateLabels.CreateTextCell[pr.design, tp.text, tiogaFont, tp.cdFont.scaleI, layer];
}
ELSE {
tCell ← CDCreateLabels.CreateTextCell[pr.design, tp.text, tp.cdFont.font, 1, layer];
};
[] ← ref.Store[ob, tCell]
};
IF tCell#NIL THEN {
origin: CD.Position ← CDOrient.MapPoint[
pointInCell: CD.ClientOrigin[ob],
cellSize: ob.size,
cellInstOrient: orient,
cellInstPos: pos
];
[] ← CDCells.IncludeOb[cell: cell, ob: tCell, position: origin, orientation: orient, mode: dontPropagate];
};
};
ENDCASE => NULL;
END;
cell: CD.Object;
ProtectedMakeLabelCell: PROC[comm: CDSequencer.Command] =
BEGIN
design: CD.Design ← comm.design;
dr: CD.DrawRef = CD.CreateDrawRef[[
drawContext: DrawContext,
contextFilter: contextFilter,
devicePrivate: RefTab.Create[],
design: design
]];
cell ← CDCells.CreateEmptyCell[];
CDOps.DrawDesign[design, dr];
[] ← CDCells.RepositionCell[cell, NIL];
[] ← CDDirectory.Include[design, cell, "dummy"];
[] ← CDCells.IncludeOb[design: design, ob: cell];
END;
MakeLabelCellComm: PROC [comm: CDSequencer.Command] =
BEGIN
TerminalIO.WriteRope["make a label cell\n"];
[] ← CDCommandOps.CallWithResource[ProtectedMakeLabelCell, comm, $MakeLabelCell, abortPlot];
END;
CDMenus.ImplementEntryCommand[$ProgramMenu, "make a label cell", MakeLabelCellComm];
END.