TextNodeClassImpl.mesa; Written by S. McGregor, March 1983
Edited by McGregor, August 30, 1983 4:03 pm
Edited by Paxton, June 1, 1983 2:52 pm
DIRECTORY
Graphics,
Rope USING [Fetch],
RopeEdit USING [Size],
TiogaItemClass,
TiogaNode,
TiogaNodeOps,
VFonts;
TextNodeClassImpl:
CEDAR
PROGRAM
IMPORTS Graphics, Rope, RopeEdit, TiogaNodeOps, VFonts =
BEGIN
TextLengthProc: TiogaItemClass.ItemLengthProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
RETURN[RopeEdit.Size[text.rope]];
END;
TextNotifyProc: TiogaItemClass.ItemNotifyProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
ERROR;
END;
TextDestroyProc: TiogaItemClass.ItemDestroyProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
text.rope ← NIL;
text.runs ← NIL;
END;
TextCopyProc: TiogaItemClass.ItemCopyProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
ERROR;
END;
TextFastFormatProc: TiogaItemClass.ItemFastFormatProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
c: CHAR;
i: INT ← start;
size: INT ← RopeEdit.Size[text.rope];
rightExtent ← 0;
topExtent ← MIN[VFonts.FontAscent[], topBound];
bottomExtent ← MIN[VFonts.FontHeight[]-VFonts.FontAscent[], bottomBound];
Graphics.SetCP[context, 0, 0];
WHILE rightExtent<rightBound
AND i<size
DO
rightExtent ← rightExtent+VFonts.CharWidth[c ← Rope.Fetch[text.rope, i]];
Graphics.DrawChar[context, c];
i ← i+1;
ENDLOOP;
Graphics.DrawBox[context, [0, 0, rightExtent, 1]]; -- draw in baseline
Graphics.DrawBox[context, [0, -bottomExtent, 1, topExtent]]; -- draw in baseline
end ← i-1;
END;
TextLineBreakFormatProc: TiogaItemClass.ItemLineBreakFormatProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
ERROR;
END;
TextDisplayProc: TiogaItemClass.ItemDisplayProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
ERROR;
END;
TextSetSelectionProc: TiogaItemClass.ItemSetSelectionProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
ERROR;
END;
TextSetProc: TiogaItemClass.ItemSetProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
ERROR;
END;
TextGetProc: TiogaItemClass.ItemGetProc =
BEGIN
text: TiogaNode.RefTextNode = TiogaNodeOps.NarrowToTextNode[self];
ERROR;
END;
[] ← TiogaNodeOps.RegisterItemClass[TiogaItemClass.ItemClassRec[
length: TextLengthProc,
notify: TextNotifyProc,
format: TextFastFormatProc,
lineBreakFormat: TextLineBreakFormatProc,
display: TextDisplayProc,
setSelection: TextSetSelectionProc,
get: TextGetProc,
set: TextSetProc,
copy: TextCopyProc,
destroy: TextDestroyProc,
tipTable: NIL,
flavor: $Text,
privateOps: NIL
], FALSE];
END.