GGInXImpl.mesa
Copyright © 1993 by Xerox Corporation. All rights reserved.
Bier, August 23, 1993 10:36 am PDT
Contents: Like GGWindowImpl or MMMEditorGGImpl, but connects Gargoyle to an X Window instead of a Viewer or an MMM editor.
DIRECTORY
GGState, Commander, FileNames, GGBoundBox, GGInterfaceTypes, GGModelTypes, GGRefresh, GGRefreshTypes, GGScene, GGUserInput, GGWindow, GGWindowExtras, Imager, ImagerColor, ImagerTransformation, IO, Rope, SimpleFeedback, TIPTypes, TIPUser, Xl, XTk, XTkBitmapWidgets, XTkTIP, XTkWidgets;
GGInXImpl: CEDAR PROGRAM
IMPORTS GGState, Commander, FileNames, GGBoundBox, GGRefresh, GGScene, GGUserInput, GGWindow, GGWindowExtras, Imager, ImagerColor, SimpleFeedback, TIPUser, XTkBitmapWidgets, XTkTIP, XTkWidgets
EXPORTS GGInterfaceTypes
= BEGIN
RefreshDataObj: PUBLIC TYPE = GGRefreshTypes.RefreshDataObj; -- exports to GGInterfaceTypes
BoundBox: TYPE = GGBoundBox.BoundBox;
Context: TYPE = Imager.Context;
Event: TYPE = Xl.Event;
EventRep: TYPE = Xl.EventRep;
GGData: TYPE = GGInterfaceTypes.GGData;
ROPE: TYPE = Rope.ROPE;
Scene: TYPE = GGModelTypes.Scene;
TIPTable: TYPE = TIPTypes.TIPTable;
Transformation: TYPE = ImagerTransformation.Transformation;
Widget: TYPE = XTk.Widget;
Slope0: XTk.WidgetNotifyProc = {
i: Instance ~ NARROW[registerData];
SimpleFeedback.Append[$Gargoyle, oneLiner, $Feedback, "Slope0 pressed"];
};
Slope90: XTk.WidgetNotifyProc = {
i: Instance ~ NARROW[registerData];
SimpleFeedback.Append[$Gargoyle, oneLiner, $Feedback, "Slope90 pressed"];
};
Paint: XTk.WidgetNotifyProc = {
i: Instance ~ NARROW[registerData];
clientFrame, frameClient: Transformation;
DoPaint: PROC = {
bounds: BoundBox ¬ GGBoundBox.CreateBoundBox[0,0,200,100];
SimpleFeedback.Append[$Gargoyle, oneLiner, $Feedback, "Paint pressed"];
Imager.ConcatT[i.context, clientFrame]; -- mimic what BiScrollers does
GGRefresh.RepaintArea[i.context, i.ggData, $PaintEntireScene, bounds, FALSE, FALSE];
Imager.SetColor[i.context, ImagerColor.ColorFromRGB[[1,0,0]]];
Imager.MaskRectangle[i.context, [0,0,100,50]];
};
[clientFrame, frameClient] ¬ GGState.GetBiScrollersTransforms[i.ggData];
Imager.DoSaveAll[i.context, DoPaint];
};
XInputNotify: Xl.EventProcType = {
PROC [event: Event, clientData: REF, tq: TQ];
i: Instance ¬ NARROW[clientData];
WITH event SELECT FROM
input: REF READONLY tipEvent EventRep => {
IF input.results = NIL THEN SimpleFeedback.Append[$Gargoyle, oneLiner, $Feedback, "NIL TIP results"]
ELSE WITH input.results.first SELECT FROM
a: ATOM => {
SimpleFeedback.PutF[$Gargoyle, oneLiner, $Feedback, "TIP results: %g", [atom[a]] ];
GGUserInput.BiScrollerInputNotify[i.ggData, input.results];
};
ENDCASE => SimpleFeedback.Append[$Gargoyle, oneLiner, $Feedback, "TIP results: not an atom"];
};
ENDCASE => SimpleFeedback.Append[$Gargoyle, oneLiner, $Feedback, "Not a TIP result"];
};
WindowEventNotify: XTkBitmapWidgets.BitmapEventProc = {
};
Instance: TYPE = REF InstanceObj;
InstanceObj: TYPE = RECORD [
ggData: GGData,
context: Context
];
XGargoyleCommand: Commander.CommandProc ~ {
scene: Scene ¬ GGScene.CreateScene[];
workingDirectory: ROPE ¬ FileNames.CurrentWorkingDirectory[];
ggData: GGData ¬ GGWindow.CreateGGData[scene, workingDirectory];
widgetStream: IO.STREAM ¬ XTkWidgets.CreateStream[];
i: Instance ~ NEW[InstanceObj ¬ [ggData: ggData]];
slope0: Widget ¬ XTkWidgets.CreateButton[text: "Slope 0", hitProc: Slope0, registerData: i];
slope90: Widget ¬ XTkWidgets.CreateButton[text: "Slope 90", hitProc: Slope90, registerData: i];
paint: Widget ¬ XTkWidgets.CreateButton[text: "Paint", hitProc: Paint, registerData: i];
menus: Widget ¬ XTkWidgets.CreateXStack[stack: LIST[slope0, XTkWidgets.VRule[], slope90, XTkWidgets.VRule[], paint]];
out: Widget ¬ XTkWidgets.CreateStreamWidget[widgetSpec: [geometry: [size: [350, 200]]], widgetStream: widgetStream];
action: Widget ¬ XTkBitmapWidgets.CreateBitmapWidget[widgetSpec: [geometry: [size: [350, 200]]], notify: WindowEventNotify, data: NIL];
container: Widget ¬ XTkWidgets.CreateYStack[stack: LIST[menus, XTkWidgets.HRule[], action]];
shell: Widget ¬ XTkWidgets.CreateShell[child: container, windowHeader: "XGargoyle"];
BEGIN
table: TIPTable ¬ TIPUser.InstantiateNewTIPTable["/Cedar/Gargoyle/Gargoyle.tip"];
XTkTIP.Bind[widget: action, tipTable: table, eventProc: XInputNotify, eventData: i, yup: TRUE, pseudoHeight: 200];
END;
XTkBitmapWidgets.CreateAndSetBitmap[widget: action, size: [s: 200, f: 350], bpp: 0, origin: [0,0]];
i.context ¬ XTkBitmapWidgets.CreateContext[action];
XTkWidgets.RealizeShell[shell];
GGRefresh.RegisterPaintProc[ggData, XPaint, i];
GGWindowExtras.SetBeingBorn[ggData, FALSE];
BEGIN
filename: ROPE = "/net/brazil/brazil-12/gargoyle10/figs/Worm.gargoyle";
GGUserInput.BiScrollerInputNotify[i.ggData, LIST[$Get, filename]];
END;
};
XPaint: GGRefresh.PaintProc = {
PROC [ggData: GGData, request: REF ¬ NIL, bounds: BoundBox, clientData: REF ¬ NIL];
i: Instance ~ NARROW[clientData];
clientFrame, frameClient: Transformation;
DoPaint: PROC = {
whatHasChanged: ATOM;
SimpleFeedback.Append[$Gargoyle, oneLiner, $Feedback, "Painting..."];
whatHasChanged ¬ IF ggData.refresh.paintAction=NIL THEN $PaintAllPlanes ELSE ggData.refresh.paintAction;
Imager.ConcatT[i.context, clientFrame]; -- mimic what BiScrollers does
GGRefresh.RepaintArea[i.context, i.ggData, whatHasChanged, bounds, FALSE, FALSE];
ggData.refresh.paintAction ¬ $PaintAllPlanes;
};
[clientFrame, frameClient] ¬ GGState.GetBiScrollersTransforms[ggData];
Imager.DoSaveAll[i.context, DoPaint];
};
Commander.Register["XGargoyle", XGargoyleCommand, "Creates a Gargoyle X window"];
END.