CreateCaminoItem:
PUBLIC
PROC [name:
ROPE, object: AlgebraClasses.Object ←
NIL]
RETURNS [CaminoItem] =
BEGIN
expr:
EXPR ←
IF object =
NIL
THEN
NIL
ELSE
NARROW[
AC.ApplyNoLkpNoRecastRef[
AC.LookupMethodInStructure[$toExpr, object.class], LIST[object] ], EXPR];
domain: Object ← IF object = NIL THEN NIL ELSE object.class;
my: CaminoItem ← NEW[CaminoItemRec];
myMenu: Menus.Menu ← Menus.CreateMenu[lines: 3];
my.object ← object;
my.outer ← Containers.Create[
info: [
name: name, -- name displayed in the caption
iconic: TRUE,
column: left,-- initially in the left column
menu: myMenu, -- displaying our menu command
scrollable: FALSE -- inhibit user from scrolling contents
]
];
MakeScratchDomain[my, name, domain]; -- build each (sub)viewer in turn
MakeExpr[my, expr];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["SetName", SetName, my], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["Undo", Undo, my.exprViewer.data], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["Scale", Scale, my.exprViewer.data], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["Home", Home, my.exprViewer.data], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["NewItem", NewItem, my], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["ToTioga", ConvertToTioga, my], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["SetPtSize", SetPtSize, my], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["ToExprRope", ConvertToExprRope, my.exprViewer.data], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["ToASRope", ConvertToASRope, my.exprViewer.data], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["FromExprRope", ConvertFromExprRope, my.exprViewer.data], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry[name: "Debug", proc: EnterDebugger, clientData: my.exprViewer.data, guarded: TRUE], 0];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["SelectPrimary", SelectEntirePrimary, my.exprViewer.data], 1];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["ReplaceWithObject", EnterObject, my.exprViewer.data], 1];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["ReplaceWithOperator", ReplaceWithOperator, my.exprViewer.data], 1];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["WrapWithOperator", WrapWithOperator, my.exprViewer.data], 1];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["SelectCopy", SelectEntireCopy, my.exprViewer.data], 1];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["FromTioga", ConvertFromTioga, my], 1];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["EvalPrimaryInPlace", EvalPrimaryInPlace, my], 2];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["OpPrimaryInPlace", OperatePrimaryInPlace, my], 2];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["OpWDInPlace", OperateWorkingDomainInPlace, my], 2];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["OpPrimary", OperatePrimaryNew, my], 2];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["OpWD", OperateWorkingDomainNew, my], 2];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["EvalTiogaInPlace", EvalTiogaInPlace, my], 2];
Menus.AppendMenuEntry[myMenu, Menus.CreateEntry["Algebra", DoAlgebra, my], 2];
ViewerOps.SetMenu[my.outer, myMenu]; -- hint our desired height
ViewerOps.SetOpenHeight[my.outer, my.height]; -- hint our desired height (SampleTool)
ViewerOps.PaintViewer[my.outer, all];-- reflect above change
ViewerOps.PaintViewer[my.exprViewer, client];-- get expression viewer sized
RepaintViewer[my.exprViewer];
RETURN[my];
END;
MakeScratchDomain:
PROC [caminoItem: CaminoItem, name:
ROPE, domain: Object] =
BEGIN
scratchPadButton, objectDomainButton, workingDomainButton: Buttons.Button;
initialName: Rope.ROPE;
initialDomain: Rope.ROPE;
initialName ← IF name = NIL THEN " " ELSE name;
initialDomain ←
IF domain =
NIL
THEN " "
ELSE
NARROW[
AC.ApplyNoLkpNoRecastRef[
AC.LookupMethodInStructure[$shortPrintName, domain], LIST[domain] ], ROPE];
caminoItem.height ← caminoItem.height + entryVSpace; -- space down from the top of the viewer
caminoItem.name ← initialName;
objectDomainButton ← Buttons.Create[
info: [
name: "Result Domain:",
wy: caminoItem.height,
default the width so that it will be computed for us --
ww:, -- default the width so that it will be computed for us
wh: entryHeight, -- specify rather than defaulting so line is uniform
parent: caminoItem.outer,
border: TRUE],
clientData: caminoItem, -- this will be passed to our button proc
proc: Null];
caminoItem.objectDomainViewer ← Labels.Create[
info: [
name: initialDomain, -- initial contents
wx: objectDomainButton.wx + objectDomainButton.ww + entryHSpace,
wy: caminoItem.height,
ww: 30*VFonts.CharWidth['0], -- 30 digits worth of width
wh: entryHeight,
parent: caminoItem.outer,
border: TRUE
]
];
workingDomainButton ← Buttons.Create[
info: [
name: "Working Domain:",
wy: caminoItem.height,
wx: caminoItem.objectDomainViewer.wx + caminoItem.objectDomainViewer.ww + entryHSpace,
default the width so that it will be computed for us --
ww:, -- default the width so that it will be computed for us
wh: entryHeight, -- specify rather than defaulting so line is uniform
parent: caminoItem.outer,
border: TRUE],
clientData: caminoItem, -- this will be passed to our button proc
proc: SetWorkingDomain];
caminoItem.workingDomainViewer ← Labels.Create[
info: [
name: initialDomain, -- initial contents
wx: workingDomainButton.wx + workingDomainButton.ww + entryHSpace,
wy: caminoItem.height,
ww: 30*VFonts.CharWidth['0], -- 30 digits worth of width
wh: entryHeight,
parent: caminoItem.outer,
border: TRUE
]
];
caminoItem.workingDomain ← domain;
caminoItem.height ← caminoItem.height + entryHeight + entryVSpace; -- interline spacing
scratchPadButton ← Buttons.Create[
info: [
name: "ScratchPad:",
wy: caminoItem.height,
default the width so that it will be computed for us --
wh: entryHeight, -- specify rather than defaulting so line is uniform
parent: caminoItem.outer,
border: TRUE ],
proc: PromptScratch,
clientData: caminoItem]; -- this will be passed to our button proc
caminoItem.scratchPadViewer ← ViewerTools.MakeNewTextViewer[
info: [
parent: caminoItem.outer,
wx: scratchPadButton.wx + scratchPadButton.ww + entryHSpace,
wy: caminoItem.height+2,
ww: 80*VFonts.CharWidth['0], -- 80 digits worth of width
wh: entryHeight,
data: "", -- initial contents
scrollable: FALSE,
border: TRUE] ];
scratchPadButton ← Buttons.Create[
info: [
name: "Scratch:",
wx: caminoItem.nameViewer.wx + caminoItem.nameViewer.ww + entryHSpace,
wy: caminoItem.height,
wh: entryHeight, -- specify rather than defaulting so line is uniform
parent: caminoItem.outer,
border: TRUE],
proc: PromptScratch,
clientData: caminoItem]; -- this will be passed to our button proc
caminoItem.scratchPadViewer ← ViewerTools.MakeNewTextViewer[
info: [
parent: caminoItem.outer,
wx: scratchPadButton.wx + scratchPadButton.ww + entryHSpace,
wy: caminoItem.height,
ww: 30*VFonts.CharWidth['0], -- 30 digits worth of width
wh: entryHeight,
data: " ", -- initial contents
scrollable: FALSE,
border: TRUE] ];
caminoItem.height ← caminoItem.height + entryHeight + entryVSpace; -- interline spacing
END;