IconManagerImpl.mesa; written by S. McGregor
Edited by McGregor on August 30, 1982 10:11 am
Last Edited by: Maxwell, January 28, 1983 3:09 pm
Last Edited by: Pausch, August 9, 1983 12:27 pm
Last Edited by: Wyatt, November 10, 1983 4:29 pm
DIRECTORY
Cursors USING [SetCursor],
IconManager,
InputFocus USING [GetInputFocus, SetInputFocus],
MessageWindow USING [Append, Blink, Confirm],
Process USING [Detach],
Rope USING [Cat],
TIPUser USING [InstantiateNewTIPTable, TIPScreenCoords, TIPTable],
ViewerOps USING [ChangeColumn, DestroyViewer, NotifyViewer, OpenIcon, PaintViewer, SaveViewer],
ViewerClasses,
ViewerTools USING [SelPosRec, SetSelection],
WindowManager USING [colorDisplayOn];
IconManagerImpl: CEDAR PROGRAM
IMPORTS Cursors, InputFocus, MessageWindow, Process, Rope, TIPUser, ViewerOps, ViewerTools,
WindowManager
EXPORTS IconManager
SHARES ViewerClasses
= BEGIN OPEN Cursors, ViewerClasses;
IconNotify: PUBLIC ViewerClasses.NotifyProc = {
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 ViewerOps.NotifyViewer[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    => {
code commented out by R. Pausch when changing over to new menu scheme
entry: Menus.MenuEntry = Menus.FindEntry[self.menu, "Save"];
MessageWindow.Append["Saving icon . . . ", TRUE];
IF entry = NIL THEN ViewerOps.SaveViewer[self] ELSE entry.proc[self];
ViewerOps.SaveViewer[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;
};
IconModify: PUBLIC ViewerClasses.ModifyProc = {
SELECT change FROM
set  => ViewerOps.PaintViewer[self, all];
kill => {selectedIcon ← NIL; ViewerOps.PaintViewer[self, all]};
ENDCASE;
};
selectedIcon: PUBLIC ViewerClasses.Viewer ← NIL;
DestroyIcon: PROC [icon: Viewer] = {
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];
};
ConfirmDestroyIcon: PROC [icon: Viewer] = {
IF MessageWindow.Confirm[Rope.Cat["Confirm delete (and loss of edits) for icon: ", icon.name]]
THEN ViewerOps.DestroyViewer[icon];
};
SelectIcon: PROC [viewer: Viewer] = {
IF InputFocus.GetInputFocus[].owner#viewer THEN {
InputFocus.SetInputFocus[NIL]; -- kill old so we don't smash selectedIcon
selectedIcon ← viewer;
InputFocus.SetInputFocus[viewer];
};
};
Open: PROC [viewer: Viewer, closeOthers: BOOL] = {ViewerOps.OpenIcon[viewer, closeOthers]};
iconTIP: PUBLIC TIPUser.TIPTable ← TIPUser.InstantiateNewTIPTable["Icons.tip"];
END.