-- TiogaDisplayTable.mesa; Written by S. McGregor, May 1983
-- Edited by McGregor, July 11, 1983 11:10 am
DIRECTORY
TiogaNode USING [Location, Ref, RefBranchNode, Span];
TiogaDisplayTable: CEDAR DEFINITIONS = BEGIN
The data structures herein are used to describe the layout of the nodes in a displayed page. They are typically used for mouse resolving, incremental redisplay and scrolling. The screen layout is assumed to be non-overlapping rectangles, each representing an entire item or branch node, or a span within a text or list node. This data structure may be recursively applied by clients (such as box nodes) who wish to simulate page layout within the box node.
***** Basic DisplayTable data structures *****
DisplayTable: TYPE = REF DisplayTableRec;
DisplayTableRec: TYPE = RECORD [
lastIndexUsed: INTEGER ← 0,
lastY: INTEGER ← 0,
objects: REF PageRectangleSequenceRec
];
PageRectangleSequenceRec: TYPE = RECORD [
SEQUENCE maxRectangle: INTEGER OF PageRectangle -- sorted in y
];
PageRectangle: TYPE = MACHINE DEPENDENT RECORD [ -- 15 words
startPos: TiogaNode.Location, -- first offset in displayed rectangle
endPos: TiogaNode.Location, -- last offset in displayed rectangle
valid: BOOLTRUE,   -- metrics valid for this rectangle
end: Break ← eon,    -- reason for terminating rectangle
selectable: BOOLTRUE,  -- can this entry be selected
allInclusive: BOOLTRUE, -- no data in span [startPos..endPos] outside of PageRectangle
filler: [0..2048) ← 0,    -- unused bits
yOffset: INTEGER ← 0,   -- displacement from top of parent (viewer for top level)
xOffset: INTEGER ← 0,   -- displacement from left edge of parent (viewer for top level)
width: INTEGER ← 0,   -- width of PageRectangle
height: INTEGER ← 0,   -- height of PageRectangle
yBaseline: INTEGER ← 0,  -- baseline displacement from top of PageRectangle
xBaseline: INTEGER ← 0   -- baseline displacement from left of PageRectangle
];
Break: TYPE = { eon, cr, wrap, hyphen } ← eon;
***** Update entry in display table *****
StorePageRectangle: PROC [dt: DisplayTable, index: INTEGER, pr: PageRectangle] ;
Store a new value in the table, making room for more entries if needed, and update the lastIndexUsed and lastY fields.
***** Partial invalidation of display tables *****
InvalidateSpan: PROC [dt: DisplayTable, span: TiogaNode.Span];
Invalidate table entries contained within the span
InvalidateChildren: PROC [dt: DisplayTable, parent: TiogaNode.Ref];
Invalidate table entries contained within the children of the parent node
InvalidateBranch: PROC [dt: DisplayTable, node: TiogaNode.RefBranchNode];
Invalidate table entries contained within the branch
VerticalScroll: PROC [dt: DisplayTable, upLines: INTEGER];
Update the line table in case of a scrolling operation. If upLines is negative then table will be scrolled downward. Invalidated table entries will be set to startPos [NIL, 0], and yOffsets will be adjusted.
***** Coordinate to rectangle mapping *****
Resolve: PROC [dt: DisplayTable, x, y: INTEGER, useClosest: BOOLTRUE]
RETURNS [index: INTEGER ← notFound, mappedX, mappedY: INTEGER];
notFound: INTEGER = -1;
Map DisplayTable relative coordinates to the corresponding selectable display rectangle. If useClosest is TRUE, then the algorithm will choose the closest rectangle in the event that the coordinates are not contained within any rectangle. [needs refinement -SM]
***** Table size management *****
New: PROC [nEntries: INTEGER] RETURNS [dt: DisplayTable] ;
Return a new DisplayTable with room for at least nEntries.
Size: PROC [dt: DisplayTable] RETURNS [nEntries: INTEGER] = INLINE
{RETURN[dt.objects.maxRectangle+1]};
Return the current allocated size of the display table.
SetSize: PROC [dt: DisplayTable, nEntries: INTEGER];
Reallocate the table to a new size with space to hold up to nEntries. New entries are marked valid with startPos [NIL, 0].
LastIndex: PROC [dt: DisplayTable] RETURNS [lastIndex: INTEGER] = INLINE
{RETURN[dt.lastIndexUsed]};
Return the index of the last entry in the table (client maintained).
SetLastIndex: PROC [dt: DisplayTable, lastIndex: INTEGER] = INLINE
{dt.lastIndexUsed ← lastIndex};
Set the index of the last entry in the table (client maintained).
LastY: PROC [dt: DisplayTable] RETURNS [lastY: INTEGER] = INLINE
{RETURN[dt.lastY]};
Return the lastY value for the table (client maintained).
SetLastY: PROC [dt: DisplayTable, lastY: INTEGER] = INLINE
{dt.lastY ← lastY};
Set the lastY value for the table (client maintained).
END.