[Oberon] FPGA - OberonV4 Dialogs

Jörg Straube joerg.straube at iaeth.ch
Thu Dec 13 23:11:56 CET 2018


„m.draw := Draw“ should be after NEW(m) in the two main bodies and deleted from both New()s

Jörg

> Am 13.12.2018 um 22:13 schrieb Tomas Kral <thomas.kral at email.cz>:
> 
> Hi,
> 
> Now trying something of my own, not perfect, fun will start when I
> try to add some message loop (handler), as I do not understand this
> part much.
> 
> Clicking on `DLog.Load' (several times), and `DLog.Update' does things.
> 
> That mimics I can add objects at run time, possibly.
> 
> MODULE DLog; (* TK 13.12.2018 Dialogs - simple coding for RISC *)
>  IMPORT In, Out, Modules;
> 
>  TYPE
>    Object* = POINTER TO ObjDesc;
>    Methods* = POINTER TO MethodDesc;
>    Rect* = POINTER TO RectDesc;
> 
>    ObjDesc* = RECORD
>      do*: Methods;
>      r*: Rect; (*bounding rectangle*)
>      next: Object;
>      id*: INTEGER
>    END;
> 
>    RectDesc = RECORD x, y, w, h: INTEGER;
>    END;
> 
>    MethodDesc* = RECORD
>      draw*: PROCEDURE (o: Object);
>    END;
> 
>  VAR first: Object; cnt: INTEGER;
> 
>  PROCEDURE Load*;
>    VAR name: Modules.ModuleName; module: Modules.Module; New: PROCEDURE;
>  BEGIN In.Open; In.Name(name);
>    WHILE In.Done DO
>      Out.String(name); Out.String(" loading ");
>      Modules.Load(name, module);
>      New := Modules.ThisCommand(module, "New");
>      IF Modules.res = 0 THEN New() END ;
>      In.Name(name); Out.Ln
>    END;
>  END Load;
> 
>  PROCEDURE LinkObj*(o: Object);
>  BEGIN o.next := first; first := o;
>    INC(cnt); o.id := cnt
>  END LinkObj;
> 
>  PROCEDURE Update*;
>    VAR o: Object;
>  BEGIN o := first;
>    WHILE o # NIL DO o.do.draw(o); o := o.next END
>  END Update;
> 
> BEGIN first := NIL; cnt := 0
> END DLog.
> 
> DLog.Load DText DButton DButton DText DText ~ Objects from stream now, TODO from persistent file
> DLog.Update
> 
> 
> MODULE DText;
>  IMPORT DLog, Out;
> 
>  TYPE
>    Text = ARRAY 32 OF CHAR;
> 
>    Item = POINTER TO ItemDesc;
>    ItemDesc = RECORD(DLog.ObjDesc)
>      txt: Text; (*user runtime input*)
>    END;
> 
>  VAR it: Item; m: DLog.Methods;
> 
>  PROCEDURE Draw(o: DLog.Object);
>  BEGIN Out.String("Drawing text"); Out.Int(o.id, 2); Out.Ln
>  END Draw;
> 
>  PROCEDURE New*;
>  BEGIN NEW(it); DLog.LinkObj(it);
>    it.do := m; m.draw := Draw
>  END New;
> 
> BEGIN NEW(m)
> END DText.
> 
> 
> MODULE DButton;
>  IMPORT DLog, Out;
> 
>  CONST oval = 0; oblique = 1;
> 
>  TYPE
>    Item = POINTER TO ItemDesc;
>    ItemDesc = RECORD(DLog.ObjDesc)
>      shape: INTEGER;
>    END;
> 
>  VAR it: Item; m: DLog.Methods;
> 
>  PROCEDURE Draw(o: DLog.Object);
>  BEGIN Out.String("Drawing button"); Out.Int(o.id, 2); Out.Ln
>  END Draw;
> 
>  PROCEDURE New*;
>  BEGIN NEW(it); DLog.LinkObj(it);
>    it.do := m; m.draw := Draw
>  END New;
> 
> BEGIN NEW(m)
> END DButton.
> 
> -- 
> Tomas Kral <thomas.kral at email.cz>
> --
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
> https://lists.inf.ethz.ch/mailman/listinfo/oberon



More information about the Oberon mailing list