DeskTops.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by: John Maxwell on: September 30, 1983 9:29 am
Doug Wyatt, March 1, 1985 3:25:46 pm PST
=
BEGIN
OPEN ViewerClasses;
A desktop is a configuration of viewers as they are laid out on a screen. A particular viewer may be in more than one desktop, and it may have a different size and position in each. The desktops just contain pointers to viewers, they do not contain the viewers themselves. If a viewer gets destroyed then the pointer becomes a dangling reference. If this happens, the desktop will do its best to create a new viewer just like the old one.
There is always one desktop which represents the configuration of viewers visible on the screen. This desktop (called the current desktop) is indicated on its icon by having its name inverted. When you go to a new desktop, the state of the screen is automatically saved in the current desktop and then the viewers in the new desktop are moved onto the screen.
Opening a desktop viewer will reveal a list of buttons, one for each viewer in the configuration. Red-clicking a button selects it, allowing it to be added to other desktops or deleted from this one. Yellow-clicking a buttons will cause its viewer to be moved to the screen. Yellow-clicking it again will open the viewer. Yellow-clicking a button while holding down the shift key will cause the viewer to grow to full size. Blue-clicking a button removes the viewer from the desktop.
Viewers can be added to a desktop by selecting them and then clicking 'AddSel' or 'CopySel' in the desktop. 'AddSel' will add the viewer to the desktop and remove it from the screen. 'CopySel' will copy the viewer to the desktop. Viewers in other desktops can be selected by Red-clicking the corresponding button. They can then be added or copied just like viewers on the screen.
Viewers not on the screen but in some desktop are saved off of the screen in 'hyperspace'. Viewers in 'hyperspace' have their offDeskTop bit set to TRUE. If a client program attempts to open, close, reposition, or blink a top-level viewer that is in hyperspace it will automatically be moved onto the screen. Painting a viewer does not move a viewer onto the screen. All viewers are made iconic before being moved into hyperspace, so client programs only has to worry about viewers in hyperspace if they want to repaint existing icons. A client program can explicitly move a viewer onto the screen with ViewerOps.ChangeColumn[viewer, {left, right}];
If a user or client destroys a viewer, the viewer is destroyed. If a desktop which contains that viewer is subsequently opened, the desktop will attempt to recreate the viewer by calling ViewerOps.CreateViewer[$ViewerFlavor, [name: name, file: backingFile, props: props]]. This may not always work. Programs which purvey special viewers should create their own viewer flavor and use the ViewerClasses.InitProc to make sure that new instances are initialized properly.
DeskTop: TYPE = Viewer;
Entry: TYPE = REF EntryRec;
EntryRec:
TYPE =
RECORD[
viewer: ViewerClasses.Viewer ← NIL, -- a hint
props: Atom.PropList ← NIL, -- saves properties
name: Rope.ROPE ← NIL, -- name stored in the header
backingFile: Rope.ROPE ← NIL, -- name of the backingfile
flavor: ViewerClasses.ViewerFlavor ← NIL,
column: ViewerClasses.Column ← left,
iconic: BOOLEAN ← FALSE,
position: INTEGER ← 0, -- icon position
height: INTEGER ← 0, -- suggested height when open
wy, wh: INTEGER ← 0
];
Create:
PROC [name: Rope.
ROPE]
RETURNS [desktop: DeskTop];
Searches for an existing desktop named 'name'. If Create finds one, the existing desktop is returned, otherwise a new desktop is created. If the existing desktop is currently off the screen Create will move it onto the screen. If this is the first desktop, then a second one will be created to represent the screen.
FlyTo:
PROC [desktop: DeskTop];
FlyTo causes the current configuration of viewers to be saved in the current desktop and to be replaced by the configuration in `desktop'. `Desktop' then becomes current. It is possible to fly to an iconic desktop by holding the control key down and clicking at it with the middle mouse button, or by selecting the icon and typing control 'O.
EnumerateEntries:
PROC[desktop: DeskTop, proc: EnumProc];
EnumProc: TYPE = PROC [entry: Entry] RETURNS [continue: BOOL ← TRUE];
Enumerates the viewers in a desktop. Desktops can be enumerated using ViewerOps.EnumerateViewers.
MoveViewer:
PROC[viewer: Viewer, old, new: DeskTop, remove:
BOOL ←
TRUE];
Moves the viewer to the new desktop. Removes it from old unless copy is true. If an entry already exists, then that information is just updated. A NIL Desktop designates the screen.
AddEntry:
PROC[desktop: DeskTop, entry: Entry, height, limit:
INTEGER ← -1];
Private procedure for clients who want to create desktops without creating viewers (entry.viewer = NIL). 'height' and 'limit' are used internally; don't worry about them.
ReadFile:
PROC[filename: Rope.
ROPE];
Creates a series of desktops from a file on the disk.
WriteFile:
PROC[desktop: DeskTop, filename: Rope.
ROPE ←
NIL];
Creates a file on the disk that can be read in at a later date.
ClearIcons:
PROC;
Destroys all of the unedited Tioga documents in the icon area and lists their names in a special tool called the MRUCache. Clicking a name in the MRUCache will cause the document to be recreated.