-- TSGraphic.mesa
-- Michael Plass, June 9, 1982 10:34 am

-- Definitions for embedding graphical objects in typeset documents.

DIRECTORY
	TSGlue, TSTypes;

TSGraphic: DEFINITIONS =
BEGIN

Dimn: TYPE = TSTypes.Dimn;
nilDimn: Dimn = TSTypes.nilDimn;

Paint: PaintProc = INLINE {self.paintProc[self, context, originX, originY, extent]};

Layout: LayoutProc = INLINE {[flexX, flexY] ← self.layoutProc[self, maxX, maxY, suggestedX, suggestedY]};


Object: TYPE = REF ObjectRec;
ObjectRec: TYPE = RECORD [
	paintProc: PaintProc, -- procedure to call to draw the object
	layoutProc: LayoutProc, -- procedure that determines the extent of the object  
	data: REF ANY -- data the procedures need
	];

PaintProc: TYPE = PROCEDURE [
	self: Object,
	context: REF ANY, -- a TSOutput.Handle
	originX, originY: Dimn, -- this is where to paint it
	extent: TSTypes.Dimensions
	];

LayoutProc: TYPE = PROCEDURE [
	self: Object,
	maxX, maxY: Dimn ← nilDimn,
	suggestedX, suggestedY: Dimn ← nilDimn
	] RETURNS [flexX, flexY: TSGlue.Glue];

END.