IconManagerImpl.mesa;
Edited by McGregor on August 30, 1982 10:11 am
Last Edited by: Maxwell, January 28, 1983 3:09 pm
DIRECTORY
Cursors USING [SetCursor],
IconManager,
InputFocus USING [GetInputFocus, SetInputFocus],
Menus USING [FindEntry, MenuEntry],
MessageWindow USING [Append, Blink, Confirm],
Process USING [Detach],
Rope USING [Cat],
TIPUser USING [InstantiateNewTIPTable, TIPScreenCoords, TIPTable],
ViewerOps USING [DestroyViewer, OpenIcon, PaintViewer, ChangeColumn, SaveViewer],
ViewerClasses,
ViewerTools USING [SelPosRec, SetSelection],
WindowManager USING [colorDisplayOn];
IconManagerImpl: CEDAR PROGRAM
IMPORTS Cursors, InputFocus, Menus, MessageWindow, Process, Rope, TIPUser, ViewerOps, ViewerTools,
WindowManager
EXPORTS IconManager
SHARES Menus, ViewerClasses =
BEGIN OPEN Cursors, ViewerClasses;
IconNotify: PUBLIC ViewerClasses.NotifyProc = BEGIN
mx, my: INTEGER;
closeOthers, switchDisplays: BOOLFALSE;
FOR l: LIST OF REF ANY ← input, l.rest UNTIL l = NIL DO WITH l.first SELECT FROM
z: TIPUser.TIPScreenCoords => [mx, ----, my] ← z^;
z: ATOM => SELECT z FROM
$OpenDesktop, $ResetDesktop => {
IF self.class.flavor = $DeskTop THEN self.class.notify[self, input]; RETURN};
$SetInputFocus => SELECT self.class.flavor FROM
$Text => ViewerTools.SetSelection[self, NEW[ViewerTools.SelPosRec←[]]];
$Typescript, $Chat => ViewerTools.SetSelection[self];
ENDCASE;
$CloseOthers  => closeOthers ← TRUE;
$Color   => IF WindowManager.colorDisplayOn THEN
ViewerOps.ChangeColumn[self, color];
$Delete   => DestroyIcon[self];
$Save    => {
entry: Menus.MenuEntry = Menus.FindEntry[self.menu, "Save"];
MessageWindow.Append["Saving icon . . . ", TRUE];
IF entry = NIL THEN ViewerOps.SaveViewer[self] ELSE entry.proc[self];
MessageWindow.Append["done."]};
$Left    => ViewerOps.ChangeColumn[self, left];
$MouseMove => Cursors.SetCursor[textPointer];
$Open   => ViewerOps.OpenIcon[self, closeOthers];
$Right   => ViewerOps.ChangeColumn[self, right];
$Select   => SelectIcon[self];
$TogglePos  => ViewerOps.ChangeColumn[self, SELECT self.column FROM
left => right,
right => left,
color => left,
ENDCASE => ERROR];
ENDCASE  => NULL;
ENDCASE => NULL;
ENDLOOP;
END;
IconModify: PUBLIC ViewerClasses.ModifyProc = BEGIN
SELECT change FROM
set  => ViewerOps.PaintViewer[self, all];
kill => {selectedIcon ← NIL; ViewerOps.PaintViewer[self, all]};
ENDCASE;
END;
selectedIcon: PUBLIC ViewerClasses.Viewer ← NIL;
DestroyIcon: PROC [icon: Viewer] = BEGIN
IF icon.inhibitDestroy THEN {
MessageWindow.Append["That icon cannot be destroyed.", TRUE];
MessageWindow.Blink[];
RETURN};
IF icon.link = NIL AND (icon.newVersion OR icon.newFile) THEN
TRUSTED {Process.Detach[FORK ConfirmDestroyIcon[icon]]} -- fork for confirmation
ELSE ViewerOps.DestroyViewer[icon];
END;
ConfirmDestroyIcon: PROC [icon: Viewer] = BEGIN
IF MessageWindow.Confirm[Rope.Cat["Confirm delete (and loss of edits) for icon: ", icon.name]]
THEN ViewerOps.DestroyViewer[icon];
END;
SelectIcon: PROC [viewer: Viewer] = BEGIN
IF InputFocus.GetInputFocus[].owner#viewer THEN BEGIN
InputFocus.SetInputFocus[NIL]; -- kill old so we don't smash selectedIcon
selectedIcon ← viewer;
InputFocus.SetInputFocus[viewer];
END;
END;
Open: PROC [viewer: Viewer, closeOthers: BOOL] = {ViewerOps.OpenIcon[viewer, closeOthers]};
iconTIP: PUBLIC TIPUser.TIPTable ←
TIPUser.InstantiateNewTIPTable["/Indigo/CedarViewers/Viewers/Icons.tip"] ;
END.