AdobeToolImplA
Copyright Ó 1990, 1991, 1992, 1993 by Xerox Corporation. All rights reserved.
Philip James, March 10, 1992 11:59 am PST
Christian Jacobi, April 7, 1992 5:48 pm PDT
Swen Johnson, August 24, 1993 5:30 pm PDT
DIRECTORY
AdobeCommon USING [AdobeTimeRope, ButtonSeqObject, DependentsSequenceRec, EnumeratedTypes, EnumeratedTypesRec, GetFullLoginName, Handle, NoCredentials, PostMessage, SelectionsSequence],
AdobeOps USING [ArFIO, ARSystemHandle, DateFIO, EnumFIO, FixFIO, NumFIO, StrFIO, ToolType],
AdobeTool USING [BumpNumOfDeps, CountRopes, CurrentButtonProcData, CurrentButtonProcDataRec, EmptyFieldViewer],
BasicTime USING [Now],
Rope USING [Cat, Concat, Equal, Length, ROPE, Substr];
AdobeToolImplA: CEDAR MONITOR
IMPORTS AdobeCommon, AdobeTool, BasicTime, Rope
EXPORTS AdobeTool = {
SetUpSubmitTool: PUBLIC PROC [handle: AdobeCommon.Handle] = {
x, y, w, h: CARD;
procData: AdobeTool.CurrentButtonProcData;
thisViewer: REF ANY ¬ handle.fieldViewer.outer;
thisSH: AdobeOps.ARSystemHandle ¬ handle.systemHandle;
thisField: AdobeCommon.EnumeratedTypes ¬ NIL;
lineIndex: INTEGER ¬ 0;
fieldHeight: CARDINAL ¬ --VFonts.FontHeight[] + 2-- 17;
IF handle.fieldViewer.buttons # NIL THEN AdobeTool.EmptyFieldViewer[handle];
handle.currentAR ¬ 0;
handle.fieldViewer.buttons ¬ NEW[AdobeCommon.ButtonSeqObject[thisSH.fieldList.length]];
FOR field: CARDINAL IN [0..thisSH.fieldList.length) DO
handle.fieldViewer.buttons[field] ¬ NEW[AdobeCommon.EnumeratedTypesRec];
thisField ¬ handle.fieldViewer.buttons[field];
thisField.mainViewer ¬ handle;
FOR tt: AdobeOps.ToolType IN AdobeOps.ToolType DO
thisField.defaults[tt] ¬ thisSH.fieldList[field].defaultInfo[tt].default;
ENDLOOP;
procData ¬ NEW[AdobeTool.CurrentButtonProcDataRec];
procData.h ¬ handle;
procData.e ¬ handle.fieldViewer.buttons[field];
WITH thisSH.fieldList[field] SELECT FROM
it: AdobeOps.EnumFIO => {
numSubMenus, saveKey, currentEnum: CARD ¬ 0;
thisField.type ¬ enumerated;
thisField.dependentsSequence ¬ NEW[AdobeCommon.DependentsSequenceRec[5]];
IF it.field # LAST[CARD16] THEN {
currentSubMenu: CARD ¬ 0;
thisField.dependentOn ¬ handle.fieldViewer.buttons[it.field];
numSubMenus ¬ AdobeTool.CountRopes[thisField.dependentOn.allSelections[0].ropes];
AdobeTool.BumpNumOfDeps[handle.fieldViewer.buttons[field], handle.fieldViewer.buttons[it.field]];
thisField.currentMenu ¬ numSubMenus - 1;
thisField.allSelections ¬ NEW[AdobeCommon.SelectionsSequence[numSubMenus]];
WITH thisSH.fieldList[it.field] SELECT FROM
dep: AdobeOps.EnumFIO => {
--tmp-- itkd, depit, foo: CARD;
did: BOOL ¬ FALSE;
-- tmp -- max: CARD ¬ dep.possibilities[0].enumRecs.length;
FOR index: CARD IN [0..dep.possibilities[0].enumRecs.length) DO
did ¬ FALSE;
FOR itIndex: CARD IN [0..it.possibilities.length) DO
-- tmp -- itkd ¬ it.possibilities[itIndex].keyedDependency;
-- tmp -- depit ¬ dep.possibilities[0].enumRecs[index].item;
IF it.possibilities[itIndex].keyedDependency =
dep.possibilities[0].enumRecs[index].item THEN {
thisField.allSelections[currentSubMenu].num ¬ index;
-- tmp -- foo ¬ it.possibilities[itIndex].enumRecs.length;
FOR i: CARD IN [0..it.possibilities[itIndex].enumRecs.length) DO
thisField.allSelections[currentSubMenu].ropes ¬
CONS[it.possibilities[itIndex].enumRecs[it.possibilities[itIndex].enumRecs.length - i - 1].tag, thisField.allSelections[currentSubMenu].ropes];
ENDLOOP;
currentSubMenu ¬ currentSubMenu + 1;
did ¬ TRUE;
EXIT
};
ENDLOOP;
IF ~did THEN {
thisField.allSelections[currentSubMenu] ¬ [index, LIST["Nil"]];
currentSubMenu ¬ currentSubMenu + 1;
};
ENDLOOP;
};
ENDCASE => ERROR;
}
ELSE {
thisField.dependentOn ¬ NIL;
thisField.currentMenu ¬ 0;
thisField.allSelections ¬ NEW[AdobeCommon.SelectionsSequence[1]];
thisField.allSelections[0].num ¬ it.possibilities[0].enumRecs[0].item;
FOR index: CARD IN [0..it.possibilities[0].enumRecs.length) DO
thisField.allSelections[0].ropes ¬
CONS[
it.possibilities[0].enumRecs[it.possibilities[0].enumRecs.length - index - 1].tag, thisField.allSelections[0].ropes];
ENDLOOP;
thisField.currentSelection ¬ it.possibilities[0].enumRecs.length - 1;
};
thisField.button ¬ handle.makeButton[
parent: thisViewer,
x: 0,
y: lineIndex * fieldHeight,
name: Rope.Concat[it.name, ": "],
data: procData,
scrollable: FALSE,
proc: $CurrentButtonProc,
cData: procData];
[x, y, w, h] ¬ handle.getBoxGeometry[thisField.button];
thisField.controllerOf ¬ handle.newFieldBox[
parent: thisViewer,
x: w+5,
y: lineIndex * fieldHeight,
w: 400,
h: h,
border: FALSE,
scrollable: FALSE
];
handle.setContents[thisField.controllerOf, "{}"];
IF it.defaultInfo[submit].default # NIL THEN {
handle.inhibitEdits[thisField.controllerOf];
handle.setContents[thisField.controllerOf, Rope.Cat["{", it.defaultInfo[submit].default, "}"]];
thisField.boolVal ¬ TRUE;
};
};
it: AdobeOps.ArFIO => {
handle.fieldViewer.buttons[field].type ¬ arId;
handle.fieldViewer.buttons[field].button ¬ handle.makeButton[
parent: thisViewer,
x: 0,
y: lineIndex * fieldHeight,
name: Rope.Concat[it.name, ": "],
data: procData,
scrollable: FALSE,
proc: $SubmitFieldButtonProc,
cData: procData];
[x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button];
handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[
parent: thisViewer,
x: w+5,
y: lineIndex * fieldHeight,
w: 400,
h: h,
border: FALSE,
scrollable: FALSE
];
handle.inhibitEdits[thisField.controllerOf];
thisField.boolVal ¬ TRUE;
};
it: AdobeOps.DateFIO => {
handle.fieldViewer.buttons[field].type ¬ dateTime;
handle.fieldViewer.buttons[field].button ¬ handle.makeButton[
parent: thisViewer,
x: 0,
y: lineIndex * fieldHeight,
name: Rope.Concat[it.name, ": "],
data: procData,
scrollable: FALSE,
proc: $SubmitFieldButtonProc,
cData: procData];
[x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button];
handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[
parent: thisViewer,
x: w+5,
y: lineIndex * fieldHeight,
w: 400,
h: h,
border: FALSE,
scrollable: FALSE
];
IF it.defaultInfo[submit].default # NIL THEN {
handle.inhibitEdits[thisField.controllerOf];
IF Rope.Equal[it.defaultInfo[submit].default, "CurrentTOD", FALSE] THEN
handle.setContents[thisField.controllerOf, AdobeCommon.AdobeTimeRope[BasicTime.Now[]]]
ELSE
handle.setContents[thisField.controllerOf, it.defaultInfo[submit].default];
thisField.boolVal ¬ TRUE;
};
};
it: AdobeOps.NumFIO => {
handle.fieldViewer.buttons[field].type ¬ numeric;
handle.fieldViewer.buttons[field].button ¬ handle.makeButton[
parent: thisViewer,
x: 0,
y: lineIndex * fieldHeight,
name: Rope.Concat[it.name, ": "],
data: procData,
scrollable: FALSE,
proc: $SubmitFieldButtonProc,
cData: procData];
[x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button];
handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[
parent: thisViewer,
x: w+5,
y: lineIndex * fieldHeight,
w: 400,
h: h,
border: FALSE,
scrollable: FALSE
];
IF it.defaultInfo[submit].default # NIL THEN {
handle.inhibitEdits[thisField.controllerOf];
handle.setContents[thisField.controllerOf, it.defaultInfo[submit].default];
thisField.boolVal ¬ TRUE;
};
};
it: AdobeOps.FixFIO => {
handle.fieldViewer.buttons[field].type ¬ fixedLengthString;
handle.fieldViewer.buttons[field].button ¬ handle.makeButton[
parent: thisViewer,
x: 0,
y: lineIndex * fieldHeight,
name: Rope.Concat[it.name, ": "],
data: procData,
scrollable: FALSE,
proc: $SubmitFieldButtonProc,
cData: procData];
[x, y, w, h] ¬ handle.getBoxGeometry[handle.fieldViewer.buttons[field].button];
handle.fieldViewer.buttons[field].controllerOf ¬ handle.newFieldBox[
parent: thisViewer,
x: w+5,
y: lineIndex * fieldHeight,
w: handle.getBoxGeometry[handle.outer].w - w - 5,
h: h,
border: FALSE,
scrollable: TRUE
];
thisField.maxLength ¬ it.maxLength;
handle.xBoundBox[handle.fieldViewer.outer, handle.fieldViewer.buttons[field].controllerOf];
IF it.defaultInfo[submit].default # NIL THEN {
logName: Rope.ROPE ¬ NIL;
handle.inhibitEdits[thisField.controllerOf];
IF Rope.Equal[it.defaultInfo[submit].default, "LoginName", FALSE] THEN {
ENABLE AdobeCommon.NoCredentials => {
AdobeCommon.PostMessage[handle, TRUE, "You must xnslogin."];
logName ¬ "Login!";
CONTINUE
};
c: CARD;
logName ¬ AdobeCommon.GetFullLoginName[];
c ¬ logName.Length[];
IF c > it.maxLength THEN
logName ¬ Rope.Substr[logName, 0, it.maxLength];
handle.setContents[thisField.controllerOf, logName];
}
ELSE
handle.setContents[thisField.controllerOf, it.defaultInfo[submit].default];
thisField.boolVal ¬ TRUE;
};
};
it: AdobeOps.StrFIO => {
thisField.type ¬ string;
thisField.button ¬ handle.makeButton[
parent: thisViewer,
x: 0,
y: lineIndex * fieldHeight,
name: Rope.Concat[it.name, ": "],
data: procData,
scrollable: FALSE,
proc: $SubmitFieldButtonProc,
cData: procData];
[x, y, w, h] ¬ handle.getBoxGeometry[thisField.button];
thisField.adjButton ¬ handle.makeButton[
parent: thisViewer,
x: x + w - --VFonts.StringWidth["<Adj>"]-- 35 -5,
y: (lineIndex+1) * fieldHeight,
name: "<Adj>",
data: procData.e,
scrollable: TRUE,
proc: $AdjustStringHeight,
cData: procData];
thisField.controllerOf ¬ handle.newFieldBox[
parent: thisViewer,
x: w+5,
y: lineIndex * fieldHeight,
w: handle.getBoxGeometry[handle.outer].w - w - 5,
h: (h * handle.unboundFieldHeight) - 2,
border: FALSE,
scrollable: TRUE
];
handle.xBoundBox[handle.fieldViewer.outer, thisField.controllerOf];
thisField.currentHeight ¬ handle.unboundFieldHeight;
thisField.stream ← ViewerIO.CreateViewerStreams[
name: Rope.Concat[it.name, ".stream"],
viewer: thisField.controllerOf,
editedStream: FALSE
].out;
lineIndex ¬ lineIndex + thisField.currentHeight - 1;
IF it.defaultInfo[submit].default # NIL THEN {
handle.inhibitEdits[thisField.controllerOf];
handle.setContents[thisField.controllerOf, it.defaultInfo[submit].default];
thisField.boolVal ¬ TRUE;
};
};
ENDCASE;
lineIndex ¬ lineIndex + 1;
ENDLOOP;
};
}.
Swen Johnson, August 24, 1993
Bug fix: SetUpSubmitTool was passing incorrect value to handle.makeButton for data param, causing a NARROW fault later on.
changes to: SetUpSubmitTool: in call to handle.makeButton with proc = $AdjustStringHeight, use procData.e as actual parameter for data.