TestControlsImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Bloomenthal, June 12, 1986 12:41:03 pm PDT
DIRECTORY Commander, Controls, IO, Rope;
TestControlsImpl: CEDAR PROGRAM
IMPORTS Commander, Controls, IO, Rope
~ BEGIN
ProgramData:  TYPE ~ REF ProgramDataRec;
ProgramDataRec: TYPE ~ RECORD [
button1Bool: BOOLTRUE,
button2Nat: NAT ← 0
];
TestControls: Commander.CommandProc ~ {
[] ← Controls.OuterViewer[
name: "Test Controls",
column: right,
controls: LIST[
Controls.NewControl[name: "no detents", type: circ, max: 360.0, init: 90.0],
Controls.NewControl[name: "1 detent", type: circ, max: 360.0, init: 60.0, detents: LIST[[, 180.0]]],
Controls.NewControl[name: "2 detents", type: circ, max: 360.0, init: 45.0, report: FALSE, detents: LIST[[, 45.0], [, 290.0]]],
Controls.NewControl[name: "lin", type: vert, max: 1.0, init: 0.3, detents: LIST[[, 0.6]]],
Controls.NewControl[name: "log", type: vert, taper: log, max: 1.0, init: 0.3],
Controls.NewControl[name: "exp", type: vert, taper: exp, max: 1.0],
Controls.NewControl[name: "horizontal", type: horiz, max: 1.0, init: 0.5, w: 200, x: 15, y: 120]
],
entries: LIST[
["Toggle", Button1],
["State 0", Button2],
["Message", Button3],
["Help", Button4]
],
typeScript: TRUE,
data: NEW[ProgramDataRec]
];
};
Button1: Controls.ClickProc ~ {
outerData: Controls.OuterData ← NARROW[clientData];
programData: ProgramData ← NARROW[outerData.data];
programData.button1Bool ← NOT programData.button1Bool;
Controls.EntryStyle[outerData, "Toggle", IF programData.button1Bool THEN $BlackOnWhite ELSE $WhiteOnBlack];
};
Button2: Controls.ClickProc ~ {
outerData: Controls.OuterData ← NARROW[clientData];
programData: ProgramData ← NARROW[outerData.data];
SELECT programData.button2Nat FROM
0 => Controls.EntryReLabel[outerData, "State 0", "State 1"];
1 => Controls.EntryReLabel[outerData, "State 1", "State 2"];
2 => Controls.EntryReLabel[outerData, "State 2", "State 3"];
3 => Controls.EntryReLabel[outerData, "State 3", "State 0"];
ENDCASE;
programData.button2Nat ← (programData.button2Nat+1) MOD 4;
};
Button3: Controls.ClickProc ~ {
reply: Rope.ROPE;
outerData: Controls.OuterData ← NARROW[clientData];
Controls.TypeScriptWrite[outerData, "\nType something (end with CR) "];
reply ← Controls.TypeScriptRead[outerData];
Controls.TypeScriptWrite[outerData, Rope.Concat["\nThe reply was ", reply]];
};
Button4: Controls.ClickProc ~ {
outerData: Controls.OuterData ← NARROW[clientData];
IO.PutF[outerData.cmdOut, "This is a help message\n"];
};
Commander.Register["///Commands/TestControls", TestControls, "\nTest ControlsImpl.mesa."];
END.