-- Compiler ControllerMenus/n
-- m. stone March 14, 1984 8:26:04 pm PST
-- Tiberi November 4, 1979 5:41 PM
-- implementing module for griffin file controller menus
-- Last Edited by: Stone, November 14, 1983 3:06 pm
-- Last Edited by: Pier, February 13, 1984 4:25:40 pm PST
DIRECTORY
Ascii USING [Digit],
ControllerDefs: FROM "ControllerDefs"
USING [CurrentStyleRecord, CurrentFontDescriptor, AppendFont],
MenuDefs: FROM "MenuDefs",
RefreshDefs: FROM "RefreshDefs",
GriffinFontDefs: FROM "GriffinFontDefs",
StyleDefs: FROM "StyleDefs",
ControllerMenuDefs: FROM "ControllerMenuDefs",
PointDefs: FROM "PointDefs",
GriffinDefs USING [TypeIntoMenuItem, ShowUserMessage, AppendNumber],
Convert USING [IntFromRope],
GriffinMemoryDefs USING [CZone],
GriffinMenusInterface,
GriffinColor USING [StringToColor],
Rope;
--------------------------------------------------------------------
--------------------------------------------------------------------
ControllerMenus: PROGRAM
IMPORTS Ascii, MenuDefs, ControllerDefs,
RefreshDefs, GriffinFontDefs, PointDefs, Rope, GriffinDefs, Convert, GriffinMemoryDefs, GriffinColor
EXPORTS ControllerMenuDefs, GriffinMenusInterface =
BEGIN
ROPE: TYPE = Rope.ROPE;
colorMenu: PUBLIC MenuDefs.MenuHandle←NIL;
lineColorMenu: PUBLIC MenuDefs.MenuHandle←NIL;
textMenu: PUBLIC MenuDefs.MenuHandle←NIL;
charMenu: PUBLIC MenuDefs.MenuHandle←NIL;
fontMenu: PUBLIC MenuDefs.MenuHandle←NIL;
centerMenu: PUBLIC MenuDefs.MenuHandle←NIL;
thickMenu: PUBLIC MenuDefs.MenuHandle←NIL;
colorControlMenu: PUBLIC MenuDefs.MenuHandle←NIL;
maxFontNameLength: CARDINAL = 128;
InitCaptionMenu: PUBLIC PROCEDURE =
BEGIN
default: MenuDefs.MenuItemHandle;
addFontName: PROC[fd: GriffinFontDefs.FontDescriptorHandle] = {AddFontName[fd]};
textMenu ← MenuDefs.CreateMenu[vertical, [350,150], NIL];
default ← MenuDefs.AddMenuItem[textMenu,"0 d",TextDir];
[]←MenuDefs.AddMenuItem[textMenu,"90 d",TextDir];
[]←MenuDefs.AddMenuItem[textMenu,"180 d",TextDir];
[]←MenuDefs.AddMenuItem[textMenu,"270 d",TextDir];
MenuDefs.BugItem[default];
charMenu ← MenuDefs.CreateMenu[vertical, [350,250], NIL];
default ← MenuDefs.AddMenuItem[charMenu,"0 char d",CharDir];
[]←MenuDefs.AddMenuItem[charMenu,"90 char d",CharDir];
[]←MenuDefs.AddMenuItem[charMenu,"180 char d",CharDir];
[]←MenuDefs.AddMenuItem[charMenu,"270 char d",CharDir];
MenuDefs.BugItem[default];
fontMenu ← MenuDefs.CreateMenu[vertical, [240,250], NIL];
[] ← MenuDefs.AddMenuItem[fontMenu, "Add Font", AddFontItem];
fontName ← MenuDefs.AddMenuItem[fontMenu, "",TypeIntoFontName];
GriffinFontDefs.ForAllFonts[do: addFontName];
centerMenu ← MenuDefs.CreateMenu[vertical, [250,150], NIL];
default ← MenuDefs.AddMenuItem [centerMenu, "left", SetCenter];
[]←MenuDefs.AddMenuItem [centerMenu, "centered", SetCenter];
[]←MenuDefs.AddMenuItem [centerMenu, "right", SetCenter];
MenuDefs.BugItem[default];
END;
fontName: MenuDefs.MenuItemHandle;
TypeIntoFontName: PUBLIC MenuDefs.MenuProc =
BEGIN
MenuDefs.SelectOnly[item];
GriffinDefs.TypeIntoMenuItem[item];
END;
AddFontItem: PUBLIC MenuDefs.MenuProc =
BEGIN
name: ROPE ← MenuDefs.MenuString[fontName];
IF Rope.Length[name]=0 THEN GriffinDefs.ShowUserMessage["Enter font name first"]
ELSE {
fd: GriffinFontDefs.FontDescriptorHandle ← ParseFontName[name];
fd.rotation ← ControllerDefs.CurrentFontDescriptor[].rotation;
MenuDefs.SetMenuString[fontName, ""];
AddFontName[fd,TRUE];
};
RefreshDefs.RestoreScreen[];
END;
InitColorMenu: PUBLIC PROCEDURE =
BEGIN
default: MenuDefs.MenuItemHandle;
colorMenu ← MenuDefs.CreateMenu[vertical, [180,200], "Areas"];
[]←MenuDefs.AddMenuItem[colorMenu,"black",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk brown",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"brown",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"tan",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"maroon",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk red",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"red",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"orange",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk yellow",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"yellow",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"lt yellow",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk green",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"green",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"lt green",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk blue",ColorType];
[] ← MenuDefs.AddMenuItem[colorMenu,"blue",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"lt blue",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk aqua",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"aqua",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"cyan",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk purple",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"purple",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"violet",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"magenta",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"pink",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"dk grey",ColorType];
default←MenuDefs.AddMenuItem[colorMenu,"grey",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"lt grey",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"pale grey",ColorType];
[]←MenuDefs.AddMenuItem[colorMenu,"white",ColorType];
MenuDefs.BugItem[default];
lineColorMenu ← MenuDefs.CreateMenu[vertical, [100,200], "Lines"];
default←MenuDefs.AddMenuItem[lineColorMenu,"black",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk brown",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"brown",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"tan",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"maroon",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk red",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"red",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"orange",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk yellow",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"yellow",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"lt yellow",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk green",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"green",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"lt green",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk blue",ColorType];
[] ← MenuDefs.AddMenuItem[lineColorMenu,"blue",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"lt blue",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk aqua",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"aqua",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"cyan",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk purple",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"purple",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"violet",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"magenta",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"pink",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"dk grey",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"grey",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"lt grey",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"pale grey",ColorType];
[]←MenuDefs.AddMenuItem[lineColorMenu,"white",ColorType];
MenuDefs.BugItem[default];
END;
InitShapeMenu: PUBLIC PROCEDURE =
BEGIN
default: MenuDefs.MenuItemHandle;
colorControlMenu ← MenuDefs.CreateMenu[vertical, [100,180], NIL];
[]←MenuDefs.AddMenuItem[colorControlMenu, "Outlined", ColorControl];
[]←MenuDefs.AddMenuItem[colorControlMenu, "Filled", ColorControl];
default←MenuDefs.AddMenuItem[colorControlMenu, "Both", ColorControl];
MenuDefs.BugItem[default];
thickMenu ← MenuDefs.CreateMenu[vertical, [50,200], NIL];
[]←MenuDefs.AddMenuItem [thickMenu, "1 pt", SetThickness];
default ←MenuDefs.AddMenuItem [thickMenu, "2 pt", SetThickness];
[]←MenuDefs.AddMenuItem [thickMenu, "3 pt", SetThickness];
[]←MenuDefs.AddMenuItem [thickMenu, "4 pt", SetThickness];
MenuDefs.BugItem[default];
END;
DisplayCaptionMenu: PUBLIC PROCEDURE =
BEGIN
MenuDefs.ShowMenu[textMenu];
MenuDefs.ShowMenu[charMenu];
MenuDefs.ShowMenu[fontMenu];
MenuDefs.ShowMenu[centerMenu];
RefreshDefs.RestoreScreen[];
END;
UnDisplayCaptionMenu: PUBLIC PROCEDURE =
BEGIN
MenuDefs.HideMenu[textMenu];
MenuDefs.HideMenu[charMenu];
MenuDefs.HideMenu[fontMenu];
MenuDefs.HideMenu[centerMenu];
RefreshDefs.RestoreScreen[];
END;
DisplayColorMenu: PUBLIC PROCEDURE =
BEGIN
MenuDefs.ShowMenu[lineColorMenu];
MenuDefs.ShowMenu[colorMenu];
RefreshDefs.RestoreScreen[];
END;
UnDisplayColorMenu: PUBLIC PROCEDURE =
BEGIN
MenuDefs.HideMenu[colorMenu];
MenuDefs.HideMenu[lineColorMenu];
RefreshDefs.RestoreScreen[];
END;
DisplayShapeMenu: PUBLIC PROCEDURE =
BEGIN
MenuDefs.ShowMenu[colorControlMenu];
MenuDefs.ShowMenu[thickMenu];
RefreshDefs.RestoreScreen[];
END;
UnDisplayShapeMenu: PUBLIC PROCEDURE =
BEGIN OPEN MenuDefs;
MenuDefs.HideMenu[colorControlMenu];
MenuDefs.HideMenu[thickMenu];
RefreshDefs.RestoreScreen[];
END;
ColorControl: PUBLIC MenuDefs.MenuProc =
BEGIN OPEN StyleDefs,MenuDefs;
string: ROPE ← MenuDefs.MenuString[item];
style: StyleDefs.StyleHandle ← ControllerDefs.CurrentStyleRecord [];
SelectOnly[item];
SELECT TRUE FROM
Rope.Equal[string, "Outlined"] =>
BEGIN
style.outlined ← TRUE;
style.filled ← FALSE;
END;
Rope.Equal[string, "Filled"] =>
BEGIN
style.filled ← TRUE;
style.outlined ← FALSE;
END;
Rope.Equal[string, "Both"] =>
BEGIN
style.outlined ← TRUE;
style.filled ← TRUE;
END;
ENDCASE => ERROR;
END;
ColorType: PUBLIC MenuDefs.MenuProc =
BEGIN OPEN StyleDefs;
string: ROPE ← MenuDefs.MenuString[item];
color: Color ← GriffinColor.StringToColor[string];
IF MenuDefs.WhichMenu[item]=colorMenu
THEN ControllerDefs.CurrentStyleRecord [].fillcolor ← color
ELSE ControllerDefs.CurrentStyleRecord [].color ← color;
MenuDefs.SelectOnly[item];
END;
TextDir: PUBLIC MenuDefs.MenuProc =
BEGIN OPEN StyleDefs;
string: ROPE ← MenuDefs.MenuString[item];
ControllerDefs.CurrentStyleRecord [].orientation
← SELECT TRUE FROM
Rope.Equal[string,"0 d"] => Orientation [or0],
Rope.Equal[string,"90 d"] => Orientation [or90],
Rope.Equal[string,"180 d"] => Orientation [or180],
Rope.Equal[string,"270 d"] => Orientation [or270],
ENDCASE => ERROR;
MenuDefs.SelectOnly[item];
END;
CharDir: PUBLIC MenuDefs.MenuProc =
BEGIN OPEN StyleDefs, GriffinFontDefs;
string: ROPE ← MenuDefs.MenuString[item];
ControllerDefs.CurrentFontDescriptor [].rotation
← SELECT TRUE FROM
Rope.Equal[string,"0 char d"] => Rot0Degrees,
Rope.Equal[string,"90 char d"] => Rot90Degrees,
Rope.Equal[string,"180 char d"] => Rot180Degrees,
Rope.Equal[string,"270 char d"] => Rot270Degrees,
ENDCASE => ERROR;
MenuDefs.SelectOnly[item];
END;
AddFontName: PUBLIC PROCEDURE[font: GriffinFontDefs.FontDescriptorHandle, doRefresh: BOOLEAN ← FALSE] =
BEGIN
alreadyThere: BOOLEAN ← FALSE;
string: ROPE;
IsEqual: MenuDefs.MenuProc=
BEGIN
IF Rope.Equal[string, MenuDefs.MenuString[item],FALSE] THEN alreadyThere ← TRUE;
END;
string ← font.name;
string ← GriffinDefs.AppendNumber[string, font.points];
SELECT font.face FROM
3 => string ← Rope.Cat[string, "BI"];
2 => string ← Rope.Cat[string, "B"];
1 => string ← Rope.Cat[string, "I"];
ENDCASE;
IF fontMenu=NIL THEN RETURN; --happens only for menu font
MenuDefs.ForAllMenuItems[fontMenu, IsEqual];
IF alreadyThere THEN RETURN;
[] ← ControllerDefs.AppendFont[font];
MenuDefs.BugItem[MenuDefs.AddMenuItem[fontMenu, string, SetFont]];
--IF doRefresh THEN {MenuDefs.ShowMenu[fontMenu]; RefreshDefs.RestoreScreen};
END;
SetFont: PUBLIC MenuDefs.MenuProc =
BEGIN OPEN MenuDefs, ControllerDefs, GriffinFontDefs;
cfd: FontDescriptorHandle ← ControllerDefs.CurrentFontDescriptor[];
fd: FontDescriptorHandle ← ParseFontName[MenuString[item]];
cfd.name ← fd.name;
cfd.points ← fd.points;
cfd.face ← fd.face;
MenuDefs.SelectOnly[item];
END;
ParseFontName: PROC[name: ROPE] RETURNS [GriffinFontDefs.FontDescriptorHandle] =
BEGIN OPEN ControllerDefs, GriffinFontDefs;
i,j: CARDINAL;
face: ROPE;
cfd: FontDescriptorHandle ← GriffinMemoryDefs.CZone.NEW[GriffinFontDefs.FontDescriptor];
char: CHAR;
i ← 0;
UNTIL i=Rope.Length[name] DO
char ← Rope.Fetch[name,i];
IF Ascii.Digit[char] THEN EXIT ELSE i ← i+1;
ENDLOOP;
cfd.name ← Rope.Substr[name,0,i];
--get points and face. i is first digit in points
j ← i;
UNTIL j=Rope.Length[name] DO
char ← Rope.Fetch[name,j];
IF char='I OR char='i OR char='B OR char='b THEN EXIT ELSE j ← j+1;
ENDLOOP;
--j points to face or end of string
cfd.points ← Convert.IntFromRope[Rope.Substr[name,i,j-i]];
IF j#Rope.Length[name] THEN {
face ← Rope.Substr[name,j]; --rest of string
SELECT TRUE FROM
Rope.Equal[face,"i",FALSE] => cfd.face ← Italic;
Rope.Equal[face,"b",FALSE] => cfd.face ← Bold;
Rope.Equal[face,"bi",FALSE] => cfd.face ← BoldItalic;
ENDCASE => ERROR;
};
RETURN[cfd];
END;
SetCenter: PUBLIC MenuDefs.MenuProc =
BEGIN
string: ROPE ← MenuDefs.MenuString[item];
ControllerDefs.CurrentStyleRecord [].anchor
← SELECT TRUE FROM
Rope.Equal[string,"left"] => left,
Rope.Equal[string,"centered"] => center,
Rope.Equal[string,"right"] => right,
ENDCASE => ERROR;
MenuDefs.SelectOnly[item];
END;
SetThickness: PUBLIC MenuDefs.MenuProc =
BEGIN OPEN PointDefs;
string: ROPE ← MenuDefs.MenuString[item];
ControllerDefs.CurrentStyleRecord [].width
← SELECT TRUE FROM
Rope.Equal[string,"1 pt"] => ScrValToObjVal[1],
Rope.Equal[string,"2 pt"] => ScrValToObjVal[2],
Rope.Equal[string,"3 pt"] => ScrValToObjVal[3],
Rope.Equal[string,"4 pt"] => ScrValToObjVal[4],
ENDCASE => ERROR;
MenuDefs.SelectOnly[item];
END;
END.