GEditPaintImpl.mesa; Edited by McGregor on December 9, 1982 9:58 am
DIRECTORY
Graphics, -- using lots
GEditClasses,
GEditPaint,
GEditSelect USING [MarkSelection, selection],
GEditViewer,
TextNode USING [FirstChild, NarrowToOtherNode, Next],
ViewerClasses USING [PaintProc, Viewer],
ViewerOps USING [XYWH2Box];
GEditPaintImpl: PROGRAM
IMPORTS GEditSelect, Graphics, TextNode, ViewerOps
EXPORTS GEditPaint =
BEGIN OPEN Graphics, GEditViewer, GEditClasses;
GEditPainter: PUBLIC ViewerClasses.PaintProc = BEGIN
ClipOutChildren: PROC = BEGIN
FOR v: ViewerClasses.Viewer ← self.child, v.sibling UNTIL v=NIL DO
Graphics.ClipBox[context, ViewerOps.XYWH2Box[v.wx, v.wy, v.ww, v.wh], TRUE];
ENDLOOP;
END;
PaintObject: PROC [object: Object] = INLINE BEGIN
class: Class ~ NARROW[object.class];
IF class#NIL AND class.paintProc#NIL THEN class.paintProc[object, context];
END;
gvd: GEditViewerData ~ NARROW[self.data];
Translate[context, gvd.hScroll, gvd.hScroll];
ClipOutChildren[];
IF whatChanged=NIL THEN BEGIN
IF GEditSelect.selection.viewer=self AND ~clear THEN GEditSelect.MarkSelection[context];
FOR ref: Object ← TextNode.NarrowToOtherNode[TextNode.FirstChild[gvd.root]],
TextNode.NarrowToOtherNode[TextNode.Next[ref]] UNTIL ref=NIL DO
PaintObject[ref];
ENDLOOP;
IF GEditSelect.selection.viewer=self THEN GEditSelect.MarkSelection[context];
END
ELSE IF whatChanged=$XORSelection THEN BEGIN-- adjusting selected object
[] ← Graphics.SetPaintMode[context, invert];
FOR ref: SelectedObject ← GEditSelect.selection.objects, ref.nextObject UNTIL ref=NIL DO
PaintObject[ref.object];
ENDLOOP;
END
ELSE IF whatChanged=$Selection THEN GEditSelect.MarkSelection[context]
ELSE BEGIN
IF GEditSelect.selection.viewer=self AND ~clear THEN GEditSelect.MarkSelection[context];
PaintObject[NARROW[whatChanged]];
IF GEditSelect.selection.viewer=self THEN GEditSelect.MarkSelection[context];
END;
END;
END.