TestNodesClassImpl.mesa; Written by S. McGregor, August 1983
Edited by McGregor, August 30, 1983 4:15 pm
DIRECTORY
Graphics,
Rope,
TiogaItemClass,
TiogaNode,
TiogaNodeOps,
VFonts;
TestNodesClassImpl: CEDAR PROGRAM
IMPORTS Graphics, Rope, TiogaNodeOps, VFonts =
BEGIN
********** TestBox Class Implementation **********
BoxLengthProc: TiogaItemClass.ItemLengthProc = BEGIN
RETURN[1];
END;
BoxNotifyProc: TiogaItemClass.ItemNotifyProc = BEGIN
ERROR;
END;
BoxDestroyProc: TiogaItemClass.ItemDestroyProc = BEGIN
END;
BoxCopyProc: TiogaItemClass.ItemCopyProc = BEGIN
ERROR;
END;
BoxFastFormatProc: TiogaItemClass.ItemFastFormatProc = BEGIN
PROC [self: Item, start: Offset, xBound, yBound: INT ← unbounded, reason: FormatReason ← display, context: Graphics.Context ← NIL, xBase, yBase: INTEGER ← 0] RETURNS [nextOffset: Offset, width, height: INTEGER]
desiredWidth: INTEGER = 350;
desiredHeight: INTEGER = 8;
rightExtent ← MIN[desiredWidth, rightBound];
topExtent ← MIN[desiredHeight/2+desiredHeight/4, topBound];
bottomExtent ← MIN[desiredHeight-topExtent, bottomBound];
Graphics.SetStipple[context, 122645B];
Graphics.DrawBox[context, [0, -bottomExtent, rightExtent, topExtent]];
Graphics.SetColor[context, Graphics.black];
Graphics.DrawBox[context, [0, 0, rightExtent, 1]]; -- draw in baseline
Graphics.DrawBox[context, [0, -bottomExtent, 1, topExtent]]; -- draw in baseline
end ← 1;
END;
BoxLineBreakFormatProc: TiogaItemClass.ItemLineBreakFormatProc = BEGIN
ERROR;
END;
BoxDisplayProc: TiogaItemClass.ItemDisplayProc = BEGIN
ERROR;
END;
BoxSetSelectionProc: TiogaItemClass.ItemSetSelectionProc = BEGIN
ERROR;
END;
BoxSetProc: TiogaItemClass.ItemSetProc = BEGIN
ERROR;
END;
BoxGetProc: TiogaItemClass.ItemGetProc = BEGIN
ERROR;
END;
********** TestList Class Implementation **********
ListLengthProc: TiogaItemClass.ItemLengthProc = BEGIN
RETURN[1];
END;
ListNotifyProc: TiogaItemClass.ItemNotifyProc = BEGIN
ERROR;
END;
ListDestroyProc: TiogaItemClass.ItemDestroyProc = BEGIN
ERROR;
END;
ListCopyProc: TiogaItemClass.ItemCopyProc = BEGIN
ERROR;
END;
ListFastFormatProc: TiogaItemClass.ItemFastFormatProc = BEGIN
rope: Rope.ROPE = "<List>";
rightExtent ← MIN[VFonts.StringWidth[rope], rightBound];
topExtent ← MIN[VFonts.FontAscent[], topBound];
bottomExtent ← MIN[VFonts.FontHeight[]-VFonts.FontAscent[], bottomBound];
Graphics.SetCP[context, 0, 0];
Graphics.DrawRope[context, rope];
Graphics.DrawBox[context, [0, 0, rightExtent, 1]]; -- draw in baseline
Graphics.DrawBox[context, [0, 0, -bottomExtent, topExtent]]; -- draw in baseline
end ← Rope.Size[rope];
END;
ListLineBreakFormatProc: TiogaItemClass.ItemLineBreakFormatProc = BEGIN
ERROR;
END;
ListDisplayProc: TiogaItemClass.ItemDisplayProc = BEGIN
ERROR;
END;
ListSetSelectionProc: TiogaItemClass.ItemSetSelectionProc = BEGIN
ERROR;
END;
ListSetProc: TiogaItemClass.ItemSetProc = BEGIN
ERROR;
END;
ListGetProc: TiogaItemClass.ItemGetProc = BEGIN
ERROR;
END;
********** Class Registration **********
[] ← TiogaNodeOps.RegisterItemClass[TiogaItemClass.ItemClassRec[
length: BoxLengthProc,
notify: BoxNotifyProc,
format: BoxFastFormatProc,
lineBreakFormat: BoxLineBreakFormatProc,
display: BoxDisplayProc,
setSelection: BoxSetSelectionProc,
get: BoxGetProc,
set: BoxSetProc,
copy: BoxCopyProc,
destroy: BoxDestroyProc,
tipTable: NIL,
flavor: $TestBox,
privateOps: NIL
], FALSE];
[] ← TiogaNodeOps.RegisterItemClass[TiogaItemClass.ItemClassRec[
length: ListLengthProc,
notify: ListNotifyProc,
format: ListFastFormatProc,
lineBreakFormat: ListLineBreakFormatProc,
display: ListDisplayProc,
setSelection: ListSetSelectionProc,
get: ListGetProc,
set: ListSetProc,
copy: ListCopyProc,
destroy: ListDestroyProc,
tipTable: NIL,
flavor: $TestList,
privateOps: NIL
], FALSE];
END.