-- /ivy/binding/calendar/CalNutsImpl.mesa
-- to integrate calendar with nuts
-- Last edited by: Binding, August 27, 1984 10:40:43 am PDT
DIRECTORY
BasicTime USING [ Now],
Calendar USING [ ZoomLevel],
CalBrowser USING [ DisplayEvents],
CalSupport USING [ ExtractDate, DisplayMsg, CreateCalViewer],
CalStorage USING [ protData, Mode],
CalForm USING [ CreateCalForm],
CalNuts,
Nut USING [ Register, NutProc, SetNutInfo, ChangeName],
PrincOpsUtils USING [ IsBound],
Rope USING [ ROPE, Equal]
;
CalNutsImpl:
CEDAR
MONITOR
LOCKS CalStorage.protData
IMPORTS BasicTime, CalBrowser, CalSupport, PrincOpsUtils, CalStorage, CalForm, Nut, Rope
EXPORTS CalNuts
SHARES CalBrowser, CalSupport, CalStorage, CalForm
=
BEGIN
OPEN Calendar, CalStorage.protData;
RegisterWithNuts:
PUBLIC
PROC =
BEGIN
IF PrincOpsUtils.IsBound[ Nut.Register]
THEN
BEGIN
Nut.Register[ domain: "Calendar", segment: $Hickory, display: ShowCal];
Nut.SetNutInfo[ v: calViewer, segment: $Hickory, domain: "Calendar", entity: "Day"]
END
ELSE CalSupport.DisplayMsg[ "Nut not loaded"];
END; -- RegisterWithNuts
ShowCal: Nut.NutProc
-- [eName, domain: ROPE, segment: DB.Segment, lastSpawned: Viewer ← NIL] RETURNS[v: Viewer] -- =
BEGIN
IF segment = $Hickory
AND Rope.Equal[ "Calendar", domain]
THEN
BEGIN
SELECT
TRUE
FROM
Rope.Equal[ "Month", eName] => Show[ zoom: Month];
Rope.Equal[ "Day", eName] => Show[ zoom: Day];
Rope.Equal[ "Year", eName] => Show[ zoom: Year];
Rope.Equal[ "Editor", eName] => CalEdit[];
ENDCASE;
RETURN[ calViewer];
END;
END; -- ShowCal
Show:
ENTRY
PROCEDURE [ zoom: ZoomLevel] =
BEGIN
ENABLE UNWIND => NULL;
CalSupport.CreateCalViewer[];
curDate ← CalSupport.ExtractDate[ BasicTime.Now[]];
CalBrowser.DisplayEvents[ zoom, curDate];
END; -- Show
CalEdit:
ENTRY
PROCEDURE [] =
BEGIN
to enter editing mode via nuts
ENABLE UNWIND => NULL;
CalSupport.CreateCalViewer[];
curDate ← CalSupport.ExtractDate[ BasicTime.Now[]];
CalForm.CreateCalForm[ EnterEvent];
END; -- CalEdit
ResetNutInfo:
PUBLIC
PROCEDURE [ zoom: ZoomLevel ← unspecified, mode: CalStorage.Mode] =
BEGIN
resetting the nut info of the calViewer whenever we change modes or zoomLevel
IF PrincOpsUtils.IsBound[ Nut.Register]
THEN
IF mode = Browse
THEN
SELECT zoom
FROM
Day => Nut.ChangeName[ v: calViewer, newName: "Day"];
Year => Nut.ChangeName[ v: calViewer, newName: "Year"];
Month => Nut.ChangeName[ v: calViewer, newName: "Month"];
ENDCASE
ELSE
IF mode = EnterEvent
THEN
Nut.ChangeName[ v: calViewer, newName: "Editor"];
END; -- ResetNutInfo
END.