-- Hello.mesa
--  last edit 27-Feb-82  9:55:59  Sturgis

DIRECTORY
  Containers USING[Create],
  Menus USING [CreateMenu, InsertMenuEntry, Menu, MenuProc],
  Rope USING [Ref],
  ViewerMenus USING [Close, Destroy, Grow],
  ViewerOps USING [CreateChild, CreateViewer, MoveViewer, PaintViewer,
  	SetOpenHeight],
  ViewerClasses,
  ViewerSpecs,
  ViewerTools USING [MakeNewTextBox];

Hello: PROGRAM

IMPORTS Containers, Menus, ViewerMenus, ViewerOps, ViewerTools =

BEGIN OPEN ViewerClasses, ViewerSpecs;

helloContainer: ViewerClasses.Viewer;
helloMenu: Menus.Menu ← Menus.CreateMenu[];
textBoxs: ARRAY [0..100) OF Viewer;
nextShift: Shift ← right;
Shift: TYPE = {left, right};
	
BuildHelloContainer: PROC =
        BEGIN
	helloContainer ← Containers.Create[name: "Hello"];
	helloContainer.menu ← helloMenu;
	ViewerOps.SetOpenHeight[helloContainer, 50];
	END;
	
BuildHelloMenu: PROC =
        BEGIN
	Menus.InsertMenuEntry[helloMenu, "Destroy", DestroyHello];
	Menus.InsertMenuEntry[helloMenu, "Grow", ViewerMenus.Grow];
	Menus.InsertMenuEntry[helloMenu, "Close", ViewerMenus.Close];
	Menus.InsertMenuEntry[helloMenu, "shift", ShiftHello];
	END;

DestroyHello: Menus.MenuProc =
        BEGIN
	ViewerMenus.Destroy[parent];
	END;
	
ShiftHello: Menus.MenuProc =
        BEGIN
	movement: INTEGER ← IF nextShift = right THEN 50 ELSE -50;
	nextShift ← IF nextShift = right THEN left ELSE right;
	FOR i: CARDINAL IN [0..100) DO
	   ViewerOps.MoveViewer[textBoxs[i], textBoxs[i].wx+movement, textBoxs[i].wy, textBoxs[i].ww, textBoxs[i].wh, FALSE];
	   ENDLOOP;
	ViewerOps.PaintViewer[helloContainer];
	END;
	
BuildTextSubViewer: PROCEDURE[x, y: INTEGER] RETURNS[Viewer] =
    BEGIN
    RETURN[ViewerTools.MakeNewTextBox[helloContainer, x, y, 45, 50, "hi there", FALSE, FALSE]];
    END;

BuildTextSubViewers: PROCEDURE =
   BEGIN
   i: CARDINAL ← 0;
   FOR J: CARDINAL IN [0..10) DO
      FOR K: CARDINAL IN [0..10) DO
         textBoxs[i] ← BuildTextSubViewer[K*50, J*60];
	 i ← i + 1;
	 ENDLOOP;
      ENDLOOP;
   END;
	
-- main code

BuildHelloMenu[];
BuildHelloContainer[];
BuildTextSubViewers[]; -- editable, no border

END..

-- 14-Jan-82 16:21:12: Sturgis, started Hello.mesa
-- 14-Jan-82 17:47:13: The container comes up with the editable text box containing "Hi There".
       The box is the wrong height, in that it clips "there", and the wrong width in that in does not hold "Hi There" on one line.
       I can not yet move the text.
-- 15-Jan-82 16:31:08: add shift menu item
-- 15-Jan-82 17:08:05: make it 100 text boxes, to see how bad the repaint is
-- 12-Feb-82 17:06:33: update to a recent version of viewers
-- remark: 27-Feb-82  9:56:17: remove the warning messages from compilation