AdobeCommonImplA:
CEDAR
MONITOR
IMPORTS AdobeCommon, IO, Rope
EXPORTS AdobeCommon, AdobeOps = {
Type declarations
FormIndex: TYPE = {tool, another, destroy, change, newSystem};
ToolState: TYPE = {active, inactive};
ToolStateProc: TYPE = PROCEDURE[inState: BOOLEAN] RETURNS [didIt: BOOLEAN];
ToolStateHandle: TYPE = REF ToolStateType;
ToolStateType:
TYPE =
MONITORED
RECORD[
lock: MONITORLOCK,
activeTools: CARDINAL ¬ 0,
toolList: ToolList ¬ NIL,
inactiveTools: CARDINAL ¬ 0];
ToolList: TYPE = REF WindowOfTool;
WindowOfTool:
TYPE =
RECORD [
w: AdobeCommon.Handle ¬ NIL,
next: ToolList ¬ NIL];
Global Variable declarations
stateInfo: ToolStateHandle ¬ NIL;
--Public herald names
editHeraldName: PUBLIC Rope.ROPE ¬ NIL;
editCkdOutHeraldName: PUBLIC Rope.ROPE ¬ NIL;
submitHeraldName: PUBLIC Rope.ROPE ¬ NIL;
reportHeraldName: PUBLIC Rope.ROPE ¬ NIL;
queryHeraldName: PUBLIC Rope.ROPE ¬ NIL;
sortHeraldName: PUBLIC Rope.ROPE ¬ NIL;
queryListHeraldName: PUBLIC Rope.ROPE ¬ NIL;
linked list of current system descriptions
sentinal: AdobeCommon.LockedSysDescPtr ¬ NIL;
Provide the sentinal to outside clients (never used by us)
GetDescList:
PUBLIC
PROCEDURE[]
RETURNS [descListHead: AdobeCommon.LockedSysDescPtr] = {
RETURN[sentinal]};
Find the instance data, given a window handle
GetData:
PUBLIC
PROCEDURE [w:
REF
ANY]
RETURNS [AdobeCommon.Handle] = {
RETURN [NIL]};
Find the instance data, given a subwindow handle
GetDataSW:
PUBLIC
PROCEDURE [sw:
REF
ANY]
RETURNS [AdobeCommon.Handle] = {
RETURN [NIL]};
PostMessage: PUBLIC PROCEDURE[handle: AdobeCommon.Handle, postCR: BOOL,
message: Rope.ROPE]
, v1, v2, v3: IO.Value ← [null[]]]
= {
IF handle.messageViewer.reportStream #
NIL
THEN {
handle.messageViewer.reportStream.PutF1["%g", IO.rope[message]];
IF postCR
THEN
handle.messageViewer.reportStream.PutRope["\n"];
};
};
SetTinyName: PUBLIC PROCEDURE [toolData: AdobeCommon.Handle] = {
SetEditLine:
PROCEDURE
RETURNS [Rope.
ROPE ¬
NIL] =
INLINE {
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[toolData.instanceData];
WITH instanceData
SELECT
FROM
editData:
REF AdobeCommonInternal.InstanceData.edit =>
IF editData.checkedOut THEN RETURN["**Edit**"]
ELSE RETURN["Edit"];
ENDCASE;
};
name: Rope.ROPE ¬ "Adobe";
name2: Rope.
ROPE ¬
SELECT toolData.tool
FROM
edit => IF toolData.instanceData = NIL THEN "Edit" ELSE SetEditLine[],
submit => "Submit",
report => "Report",
query => "Query",
sort => "Sort",
queryList => "QueryList",
ENDCASE => NIL;
toolData.setMainName[toolData.outer, Rope.Cat[name, " ", name2]]
toolData.outer.label ← Rope.Cat[name, " ", name2];
};
PostNumber:
PUBLIC
PROCEDURE [sw: AdobeCommon.Handle, postCR:
BOOLEAN,
number:
CARD] = {
IF sw.messageViewer.reportStream #
NIL
THEN {
sw.messageViewer.reportStream.PutF1["%g", IO.card[number]];
IF postCR
THEN
sw.messageViewer.reportStream.PutRope["\n"];
};
};
MakeHeraldNames:
PROCEDURE = {
editHeraldName ¬ "Adobe Edit ";
editCkdOutHeraldName ¬ "Adobe Edit **checked out** ";
submitHeraldName ¬ "Adobe Submit ";
reportHeraldName ¬ "Adobe Report ";
queryHeraldName ¬ "Adobe Query ";
sortHeraldName ¬ "Adobe Sort ";
queryListHeraldName ¬ "Adobe Query List ";
};
ChangeTools:
PROCEDURE [toolData: AdobeCommon.Handle]
RETURNS [did:
BOOL ¬
TRUE]= {
arSH: AdobeOps.ARSystemHandle;
formItem: FormSW.ItemHandle;
instanceData: AdobeCommonInternal.InstanceDataHandle ¬ NARROW[toolData.instanceData];
IF toolData.isBusy
THEN {
AdobeCommon.PostMessage[toolData, TRUE, "Can't change tools while busy!"];
formItem ← FormSW.FindItem[instanceData.formSW, index];
formItem.flags.invisible ← TRUE;
toolData.tool ← oldValue;
formItem.flags.invisible ← FALSE;
FormSW.DisplayItem[sw, index];
RETURN[FALSE]};
WITH instanceData
SELECT
FROM
inst:
REF AdobeCommonInternal.InstanceData.edit =>
IF inst.checkedOut
THEN {
AdobeCommon.PostMessage[toolData, TRUE,
"Can't change tools while AR checked out!"];
formItem ¬ FormSW.FindItem[instanceData.formSW, index];
formItem.flags.invisible ¬ TRUE;
toolData.tool ¬ oldValue;
formItem.flags.invisible ¬ FALSE;
FormSW.DisplayItem[sw, index];
RETURN[FALSE]};
inst:
REF AdobeCommonInternal.InstanceData.submit =>
IF inst.formDirty
THEN {
oldCursor: Cursor.Type ← Cursor.GetInfo[].type;
AdobeCommon.PostMessage[toolData, TRUE,
"Form has been edited! Click to confirm!"];
Cursor.Set[mouseRed];
IF UserInput.WaitForConfirmation[].okay THEN
Cursor.Set[oldCursor]
ELSE {
formItem ← FormSW.FindItem[instanceData.formSW, index];
formItem.flags.invisible ← TRUE;
toolData.tool ← oldValue;
formItem.flags.invisible ← FALSE;
FormSW.DisplayItem[sw, index];
Cursor.Set[oldCursor];
RETURN[FALSE]
}
}
ENDCASE;
MsgSW.Clear[toolData.msgSW];
AdobeCommon.DestroyOtherSWs[toolData];
IF toolData.context #
NIL
THEN {
--there is something to free
want to hang on to same ARSystemHandle
arSH ¬ toolData.context.arSH;
AdobeToolContext.FreeUserContext[@toolData.context, toolData.heap];
toolData.context ← AdobeToolContext.InitializeUserContext[arSH, toolData.tool, toolData.heap]
};
AdobeCommon.CreateOtherSWs[toolData];
EnableAdobeAborts[toolData.window];
};
RemoveSystemFromKnownSystems:
PUBLIC
PROCEDURE[name: Rope.
ROPE,
systems: AdobeCommon.SystemsHandle] = {
FOR i:
CARD
IN [0..systems.next)
DO
IF Rope.Equal[systems.system[i], name,
FALSE]
THEN {
FOR j:
CARD
IN [i+1..systems.next)
DO
systems.system[j-1] ¬ systems.system[j];
ENDLOOP;
systems.next ¬ systems.next - 1;
EXIT;
};
ENDLOOP;
};
nilPossibilities: PUBLIC AdobeOps.EnumeratedSequence;
Init:
PROCEDURE = {
nilPossibilities ¬ NEW[AdobeOps.EnumeratedSequenceType[1]];
nilPossibilities[0] ¬ ["Nil", AdobeOps.nilEnum];
};
Mainline code
Init[];
}.