-- TiogaDisplayTable.mesa; Written by S. McGregor, May 1983
-- Edited by McGregor, September 1, 1983 11:16 am
DIRECTORY
TiogaNode USING [Location, Path, Span],
TiogaItemClass USING [Break];
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 [ -- 19 words
startPos: TiogaNode.Location, -- first offset in displayed rectangle
endPos: TiogaNode.Location, -- last offset in displayed rectangle
valid: BOOLTRUE,   -- metrics valid for this rectangle
topLevelItem: BOOLTRUE, -- is this rectangle for a top level item instead of a child?
startOfComp: BOOLTRUE, -- is this rectangle the start of a composing stick load?
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..512) ← 0,    -- unused bits
yBaseline: INTEGER ← 0,  -- baseline displacement from top of parent
xBaseline: INTEGER ← 0,  -- baseline displacement from left of parent
topExtent: INTEGER ← 0,  -- bounding box extent above yBaseline
bottomExtent: INTEGER ← 0, -- bounding box extent below yBaseline
leftExtent: INTEGER ← 0,  -- bounding box extent left of xBaseline
rightExtent: INTEGER ← 0  -- bounding box extent right of xBaseline
];
It may be useful to be able to associate arbitrary data with a PageRectangle, since item nodes may wish to include their children positions. A property list in the PageRectangle would do the trick here, but is probably too expensive. RefTab?
Break: TYPE = TiogaItemClass.Break;
***** 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.Path];
Invalidate table entries contained within the children of the parent node
InvalidateBranch: PROC [dt: DisplayTable, node: TiogaNode.Path];
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.