mentor/derived/BresenhamTranscriptView.m3


 Copyright (C) 1995, Digital Equipment Corporation.       
 All rights reserved.                                     
 See the file COPYRIGHT for a full description.           
                                                          
 Last modified on Thu Feb  9 08:56:02 PST 1995 by kalsow  
      modified on Mon Jun  6 03:18:55 PDT 1994 by mhb   
      modified on Tue Feb 16 16:31:40 PST 1993 by johnh 

********************************************************************

      *  NOTE: This file is generated automatically from the event
      *        definition file Bresenham.evt.
      ********************************************************************


<* PRAGMA LL *>

MODULE BresenhamTranscriptView;

<*NOWARN*> IMPORT TextPort, Rd, ZeusClass, Filter, TextEditVBT;
<*NOWARN*> IMPORT Fmt, ZFmt, Wr, ZeusPanel, FormsVBT;
<*NOWARN*> IMPORT BresenhamViewClass, VBT, View;

<* FATAL FormsVBT.Error, FormsVBT.Unimplemented *>

REVEAL
  T = Public BRANDED OBJECT
    fv: FormsVBT.T := NIL;
    te: TextEditVBT.T := NIL;
  OVERRIDES
    init       := TViewInit;
    install    := TViewInstall;
    delete     := TViewDelete;
    snapshot   := TViewSnapshot;
    restore    := TViewRestore;
    config     := TViewConfig;
    reactivity := TViewReactivity;
    startrun   := TViewStartrun;
    endrun     := TViewEndrun;
    oeSetup := Setup;
    oeNewLine := NewLine;
    oeErrorInit := ErrorInit;
    oeShowPixel := ShowPixel;
    oeFindError := FindError;
    oeChangeError := ChangeError;
    oeCompareError := CompareError;
    oeShowNextPixel := ShowNextPixel;
    oeMove := Move;
  END;

PROCEDURE TViewInit (view: T): T =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "init");
    RETURN BresenhamViewClass.T.init (view, NIL);
  END TViewInit;

PROCEDURE Clear (<* UNUSED *> fv  : FormsVBT.T;
                 <* UNUSED *> name: TEXT;
                              cl  : REFANY;
                 <* UNUSED *> time: VBT.TimeStamp) =
  BEGIN
    TextPort.SetText(NARROW(cl, T).te.tp, "")
  END Clear;

PROCEDURE TViewInstall (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    view.fv := ZeusPanel.NewForm("BresenhamTranscriptView.fv");
    view.te := FormsVBT.GetVBT(view.fv, "transcript");
    TViewZTrace (view, "install");
    FormsVBT.AttachProc(view.fv, "clear", Clear, view);
    EVAL Filter.Replace (view, view.fv);
    BresenhamViewClass.T.install (view);
  END TViewInstall;

PROCEDURE TViewDelete (view: T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "delete");
    BresenhamViewClass.T.delete (view);
   END TViewDelete;

PROCEDURE TViewSnapshot (view: T; wr: Wr.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "snapshot");
    BresenhamViewClass.T.snapshot (view, wr);
   END TViewSnapshot;

PROCEDURE TViewRestore (view: T; rd: Rd.T) RAISES {ZeusClass.Error} =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "restore");
    BresenhamViewClass.T.restore (view, rd);
   END TViewRestore;

PROCEDURE TViewConfig (
    view: T;
    state: ZeusClass.StateChange;
    o: ZeusClass.T) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace (view, "config");
    BresenhamViewClass.T.config (view, state, o);
   END TViewConfig;

PROCEDURE TViewReactivity (view: T; <*UNUSED*> on: BOOLEAN) =
  <* LL = VBT.mu *>
  BEGIN
    TViewZTrace(view, "reactivity");
    BresenhamViewClass.T.reactivity (view, TRUE);
  END TViewReactivity;

PROCEDURE TViewStartrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "startrun");
    BresenhamViewClass.T.startrun (view);
   END TViewStartrun;

PROCEDURE TViewEndrun (view: T) =
  <* LL = {} *>
  BEGIN
    TViewZTrace (view, "endrun");
    BresenhamViewClass.T.endrun (view);
  END TViewEndrun;
event handling methods:

PROCEDURE Setup (view: T;  width, height: INTEGER; show: BOOLEAN) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Setup ...")
       ELSE
          TViewTrace (view, "Setup "
          & Fmt.Int(width)
          & " "
          & Fmt.Int(height)
          & " "
          & Fmt.Bool(show)
          )
       END
    END
    END
  END Setup;

PROCEDURE NewLine (view: T;  x0, y0, x1, y1: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "NewLine ...")
       ELSE
          TViewTrace (view, "NewLine "
          & Fmt.Int(x0)
          & " "
          & Fmt.Int(y0)
          & " "
          & Fmt.Int(x1)
          & " "
          & Fmt.Int(y1)
          )
       END
    END
    END
  END NewLine;

PROCEDURE ErrorInit (view: T;  ) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "ErrorInit ...")
       ELSE
          TViewTrace (view, "ErrorInit "
          )
       END
    END
    END
  END ErrorInit;

PROCEDURE ShowPixel (view: T;  x, y, p1, p2: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "ShowPixel ...")
       ELSE
          TViewTrace (view, "ShowPixel "
          & Fmt.Int(x)
          & " "
          & Fmt.Int(y)
          & " "
          & Fmt.Int(p1)
          & " "
          & Fmt.Int(p2)
          )
       END
    END
    END
  END ShowPixel;

PROCEDURE FindError (view: T;  p: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "FindError ...")
       ELSE
          TViewTrace (view, "FindError "
          & Fmt.Int(p)
          )
       END
    END
    END
  END FindError;

PROCEDURE ChangeError (view: T;  p: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "ChangeError ...")
       ELSE
          TViewTrace (view, "ChangeError "
          & Fmt.Int(p)
          )
       END
    END
    END
  END ChangeError;

PROCEDURE CompareError (view: T;  p: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "CompareError ...")
       ELSE
          TViewTrace (view, "CompareError "
          & Fmt.Int(p)
          )
       END
    END
    END
  END CompareError;

PROCEDURE ShowNextPixel (view: T;  p: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "ShowNextPixel ...")
       ELSE
          TViewTrace (view, "ShowNextPixel "
          & Fmt.Int(p)
          )
       END
    END
    END
  END ShowNextPixel;

PROCEDURE Move (view: T;  p: INTEGER) =
  <* LL = {} *>
  BEGIN
    LOCK VBT.mu DO
    IF FormsVBT.GetBoolean(view.fv, "alg") THEN
       IF NOT FormsVBT.GetBoolean(view.fv, "args") THEN
          TViewTrace (view, "Move ...")
       ELSE
          TViewTrace (view, "Move "
          & Fmt.Int(p)
          )
       END
    END
    END
  END Move;

PROCEDURE TViewZTrace (view: T; t: TEXT) =
  BEGIN
    IF view.fv # NIL THEN
      IF FormsVBT.GetBoolean(view.fv, "zeus") THEN
        TextPort.PutText(view.te.tp, "**zeus:  " & t & "\n");
        TextPort.Normalize(view.te.tp, LAST(INTEGER))
      END
    END
  END TViewZTrace;

PROCEDURE TViewTrace (view: T; t: TEXT) =
  BEGIN
    TextPort.PutText(view.te.tp, "--event: " & t & "\n");
    TextPort.Normalize(view.te.tp, LAST(INTEGER))
  END TViewTrace;

PROCEDURE TViewNew (): View.T =
  BEGIN
    RETURN NEW(T).init()
  END TViewNew;

BEGIN
  ZeusPanel.RegisterView
      (TViewNew, "Bresenham Transcript View", "Bresenham");
END BresenhamTranscriptView.

interface View is in: