IconEditorDefs.mesa
Last Edit by Mike Spreitzer, November 13, 1982 2:59 pm
Last Edited by: Teitelman, April 11, 1983 3:05 pm
Last Edited by: Beach, February 16, 1984 5:46:46 pm PST
Last Edited by: Pier, February 17, 1985 3:37:43 pm PST
DIRECTORY
Containers USING [Container],
Graphics USING [Box],
IO USING [STREAM],
Menus USING [Menu, MenuProc],
Rope USING [ROPE],
ViewerClasses USING [Viewer];
IconEditorDefs: CEDAR DEFINITIONS = BEGIN
*** general constants and types used for icons ***
iconW: INTEGER = 64;  -- width and height of an icon (in bits)
iconH: INTEGER = 64;

intWBound: CARDINAL = iconW-1;
intHBound: CARDINAL = iconH-1;
intW: TYPE = [0..intWBound];
intH: TYPE = [0..intHBound];
maxStorage: INTEGER = 32;    -- how many icons kept "in core" at any given time
bitArray: TYPE = ARRAY intH OF MACHINE DEPENDENT RECORD [b: PACKED ARRAY intW OF BOOLEAN];
rectangleRec: TYPE = RECORD [ x, y, w, h: INTEGER ← 0];
lineRec: TYPE = RECORD [ x1, y1, x2, y2: INTEGER ← 0];
MarkType: TYPE = {rect, line};
markPoint: TYPE = RECORD [x, y: INTEGER ← 0];
iconUpdate: TYPE = {screen, board, icon, bit, newIcon, mark, rect, line};
iconInfoRef: TYPE = REF iconInfoRec;
iconInfoRec: TYPE = RECORD [
handle: IconHandle,
update: iconUpdate,
currentIcon: iconFlavor,
clearBit: BOOLEANFALSE,
x, y: REAL ← 0];
*** constants used for laying out display ***
normalThickness: REAL = 1.0;
bitsPerWord: CARDINAL = 16;
*** constants used for laying out display ***
distX: CARDINAL = 4;       -- fixed distance between Icons on the menu
distY: CARDINAL = 4;
maxIconsOnDisplay: CARDINAL = 20;  -- Maximum # of Icons allowed in the displayed Icon menu
minimumUnit: CARDINAL = 3;
*** type declarations for Icon File Format ***
iconFlavor: TYPE = MACHINE DEPENDENT { -- pre-defined icons
 document(0),
 dirtyDocument(1),
 fileCabinet(2),
 tool(3),
 typescript(4),
 private(177776B), -- will cause call of viewer paintProc to paint icon
 unInit(177777B)  -- private flag for unitialized icon type
 };
iconRef: TYPE = REF iconFileFormat;
iconFileFormat: TYPE = MACHINE DEPENDENT RECORD [
 bits: bitArray,           -- 64 x 64 bit pattern
 label: BOOLFALSE,         -- label icon with viewer name?
invertLabel: BOOLFALSE,       -- invert text when labeling?
 filler: [0..16384) ← 0,
 lx, ly, lw, lh: INTEGER ← 0,       -- rectangle for label (from bottom left)
 empty: ARRAY [0..251) OF UNSPECIFIEDALL[0] -- for future use
 ];
*** type declarations for Icon Editor ***
IconHandle: TYPE = REF IconHandleRec;
IconHandleRec: TYPE = RECORD [
container: Containers.Container,
viewer: ViewerClasses.Viewer,
iconFileWindow: ViewerClasses.Viewer,
iconNumberWindow: ViewerClasses.Viewer,
iconFetchFileWindow: ViewerClasses.Viewer,
iconNameWindow: ViewerClasses.Viewer, -- w.t..
varying parameters
iconFileName: Rope.ROPE,
iconFile: IO.STREAM,
numberOfIcons: CARDINAL ← 0,  -- How many icons in the current file
numberReadIn: CARDINAL ← 0,  -- How many icons originally read in (needed for reset)
numIconsPerRow, numIconsPerCol: CARDINAL,
possibleX, possibleY: CARDINAL,   -- space remaining for board after Icon menu allocated
icX, icY: CARDINAL,      -- computed origin for the Icon menu
boardSize: REAL,
unit: INTEGER,
startDisplay: CARDINAL ← 0,   -- where to start displaying icons on screen
icons
icons: ARRAY [0..maxStorage) OF iconRef,
currentIC: iconFlavor ← FIRST[IconEditorDefs.iconFlavor],
nextFlavor: iconFlavor, -- Keeps track of next possible flavor for new icons

currentIconRep: iconRef,  -- the icon currently displayed on drawing board
savedBitMap: bitArray,  -- used for "un-doing" operations
area and line marking variables
firstMark: BOOLEANTRUE,     -- Used for marking diagonal points of rectangles
drewLine, drewRectangle: BOOLEANFALSE, -- Used for erasing previously drawn rectangles or lines
currentRectangle, labelRect: rectangleRec, -- Normalized coordinates of rectangle (from bottom left)
currentLine: lineRec,
mark1, mark2: markPoint,     -- Diagonal (mark) points of rectangles
functionNotApplied: BOOLEAN-- Indicates whether previous rectangle should be erased
];
*** Signals ***
CouldntLoadIcons: SIGNAL;
CouldntSaveIcons: SIGNAL;
ViewerNoGood: SIGNAL;
PointsMarked: PROCEDURE [handle: IconHandle, representation: MarkType] RETURNS [BOOLEAN];
SaveBitMap: PROCEDURE [handle: IconHandle];
LayoutBoard: PROCEDURE [handle: IconHandle, bounds: Graphics.Box];
GetNewFlavor: PROCEDURE [handle: IconHandle] RETURNS [newFlavor: iconFlavor];
LoadIcons: PROCEDURE[handle: IconHandle, filename: Rope.ROPE]
RETURNS [nRead: INTEGER, iconFile: IO.STREAM];
SaveIcons: PROCEDURE[handle: IconHandle, filename: Rope.ROPE, numberOfIcons: CARDINAL]
RETURNS [iconFile: IO.STREAM];
NormalizeRectangle: PROC [corner1, corner2: markPoint] RETURNS [rect: rectangleRec];
TransferEndPoints: PROC [endpoint1, endpoint2: markPoint] RETURNS [line: lineRec];
ComputeEndPoints: PROC [handle: IconHandle, oldLine: lineRec] RETURNS [newLine: lineRec];
ClearIcon: PROCEDURE[handle: IconHandle, flavor: iconFlavor];
MirrorIcon: PROCEDURE[handle: IconHandle, flavor: iconFlavor, rect: rectangleRec];
DrawLine: PROCEDURE[handle: IconHandle, line: lineRec, flavor: iconFlavor];
FreshMarks: PROCEDURE [handle: IconHandle];
WhiteLabel: PROC [handle: IconHandle, flavor: iconFlavor];
BlackLabel: PROC [handle: IconHandle, flavor: iconFlavor];
SetLabel: PROC [handle: IconHandle, flavor: iconFlavor, rect: rectangleRec];
UnSetLabel: PROC [handle: IconHandle, flavor: iconFlavor];
SetWhite: PROC [handle: IconHandle, flavor: iconFlavor, rect: rectangleRec];
SetDeskTopGray: PROC [handle: IconHandle, flavor: iconFlavor, rect: rectangleRec];
SetDarkGray: PROC [handle: IconHandle, flavor: iconFlavor, rect: rectangleRec];
SetBlack: PROC [handle: IconHandle, flavor: iconFlavor, rect: rectangleRec];
Invert: PROC [handle: IconHandle, flavor: iconFlavor, rect: rectangleRec];
MoveRight: PROC [handle: IconHandle, flavor: iconFlavor, slowShift: BOOLEAN];
MoveLeft: PROC [handle: IconHandle, flavor: iconFlavor, slowShift: BOOLEAN];
MoveUp: PROC [handle: IconHandle, flavor: iconFlavor, slowShift: BOOLEAN];
MoveDown: PROC [handle: IconHandle, flavor: iconFlavor, slowShift: BOOLEAN];
FillIcon: PROC [handle: IconHandle];
CreateMenu: PROCEDURE [handle: IconHandle] RETURNS [iconMenu: Menus.Menu];
BlackLabelProc, WhiteLabelProc, LineProc, InvertProc, BlackProc, DarkGrayProc, DeskTopGrayProc, WhiteProc, UnLabelIconProc, LabelIconProc, RightProc, LeftProc, DownProc, UpProc, UndoProc, FillIconProc, ShowLabelProc, CreateIconProc, DeleteIconProc, RotateDisplayProc, LoadIconProc, SaveProc, ResetProc: Menus.MenuProc;
END.