File: GGWindowImpl.mesa
Author: Eric Bier on June 5, 1985 11:34:50 pm PDT
Copyright c 1985, 1986 by Xerox Corporation. All rights reserved.
Last edited by Bier on April 9, 1987 11:51:18 pm PDT
Contents: Code to create a Gargoyle window. Calls GGContainer to make the container and adds menus at the top. The graphics part of the Gargoyle window is an inner viewer of a BiScroller of class $ActionArea. The paint proc for a $ActionArea is defined herein.
Pier, April 24, 1987 1:22:53 am PDT
DIRECTORY
AtomButtons, AtomButtonsTypes, BiScrollers, BufferedRefresh, Buttons, Commander, CommandTool, Cursors, Feedback, FileNames, FunctionCache, Geom2D, GGAlign, GGBasicTypes, GGBoundBox, GGCaret, GGContainer, GGEvent, GGFont, GGGravity, GGInterfaceTypes, GGMeasure, GGMenus, GGModelTypes, GGMouseEvent, GGMultiGravity, GGOutline, GGRefresh, GGScene, GGSegmentTypes, GGSessionLog, GGState, GGUserInput, GGViewerOps, GGWindow, GraphicsButton, Icons, Imager, ImagerTransformation, IO, Rope, SlackProcess, Terminal, TiogaButtons, TIPUser, Vectors2d, ViewerClasses, ViewerOps;
GGWindowImpl:
CEDAR
PROGRAM
IMPORTS AtomButtons, BiScrollers, BufferedRefresh, Buttons, Commander, CommandTool, Cursors, Feedback, FileNames, FunctionCache, Geom2D, GGAlign, GGBoundBox, GGCaret, GGContainer, GGEvent, GGFont, GGGravity, GGMeasure, GGMenus, GGMouseEvent, GGMultiGravity, GGOutline, GGRefresh, GGScene, GGSessionLog, GGState, GGUserInput, GGViewerOps, GraphicsButton, Icons, Imager, ImagerTransformation, Rope, SlackProcess, Terminal, TIPUser, Vectors2d, ViewerOps
EXPORTS GGWindow = BEGIN
Caret: TYPE = REF CaretObj;
CaretObj: TYPE = GGInterfaceTypes.CaretObj;
CameraDataObj: TYPE = GGModelTypes.CameraDataObj;
Filters: TYPE = REF FiltersObj;
FiltersObj: TYPE = GGInterfaceTypes.FiltersObj;
Slice: TYPE = GGModelTypes.Slice;
ImagerProc: TYPE = GGInterfaceTypes.ImagerProc;
Outline: TYPE = GGModelTypes.Outline;
Point: TYPE = GGBasicTypes.Point;
Scene: TYPE = REF SceneObj;
SceneObj: TYPE = GGModelTypes.SceneObj;
Segment: TYPE = GGSegmentTypes.Segment;
Sequence: TYPE = GGModelTypes.Sequence;
Traj: TYPE = GGModelTypes.Traj;
Viewer: TYPE = ViewerClasses.Viewer;
ForegroundParts: TYPE = GGWindow.ForegroundParts;
GGData: TYPE = REF GargoyleDataObj;
GargoyleDataObj: TYPE = GGInterfaceTypes.GargoyleDataObj;
buttonAlign: INTEGER ← 2; -- align popUp and standard buttons in first button line
entryHeight: CARDINAL = 15; -- height of a line of items
entryVSpace: CARDINAL = 2; -- vertical leading between lines
entryHSpace: CARDINAL = 2; -- horizontal space between items on a line
column1: CARDINAL = 200; -- horizontal space between margin and column 1;
column2: CARDINAL = 250; -- horizontal space between margin and column 2.
column3: CARDINAL = 500; -- horizontal space between margin and column 3;
nameSize: CARDINAL = 140;
smallNumberSize: CARDINAL = 45;
numberSize: CARDINAL = 80;
bigNumberSize: CARDINAL = 160;
pointSize: CARDINAL = 160;
GGActionAreaPaint:
PROC [self: Viewer, context: Imager.Context, whatChanged:
REF
ANY, clear:
BOOL]
RETURNS [quit:
BOOL ←
FALSE] = {
ViewerClasses.PaintProc. whatChanged is a GGData. self is an ActionArea.
PaintEntireViewer:
PROC =
CHECKED {
BufferedRefresh.FitSandwichToScreen[ggData.refresh.sandwich, self.cw, self.ch];
RestoreScreenAndInvariants[paintAction: $PaintEntireScene, ggData: ggData, remake: none, backgndOK: TRUE, edited: FALSE, okToClearFeedback: FALSE];
};
clientToViewer: Imager.Transformation ← BiScrollers.GetStyle[].GetTransforms[BiScrollers.QuaBiScroller[self]].clientToViewer;
ggData: GGData;
IF whatChanged =
NIL
THEN {
--we are being called by Window Manager
We are called for one of two reasons: scrolling in an already open window, or reopening a window. If we are reopening we can take advantage of the fact that the sandwich may still be valid from when we closed the window. We detect this by comparing the new BiScrollers clientToViewer transform with the one we saved last time we came through here. If they are the same, we assume we can use the old sandwich.
ggData ← NARROW[BiScrollers.ClientDataOfViewer[self]];
BufferedRefresh.FitSandwichToScreen[ggData.refresh.sandwich, self.cw, self.ch];
IF ggData.refresh.clientToViewer#
NIL
AND ImagerTransformation.Equal[clientToViewer, ggData.refresh.clientToViewer]
THEN { -- Window Motion
RestoreScreenAndInvariants[paintAction: $ViewersPaintAllPlanes, ggData: ggData, remake: none, backgndOK: TRUE, edited: FALSE, okToClearFeedback: FALSE];
}
ELSE { -- Scrolling
RestoreScreenAndInvariants[paintAction: $ViewersPaintEntireScene, ggData: ggData, remake: none, backgndOK: TRUE, edited: FALSE, okToClearFeedback: FALSE];
};
}
ELSE {
ggData ← NARROW[whatChanged];
IF ggData.refresh.paintAction=$PaintEntireViewer THEN PaintEntireViewer[] ELSE
GGRefresh.ActionAreaPaint[context, ggData.refresh.paintAction, ggData];
};
ggData.refresh.clientToViewer ← clientToViewer; -- for next time around
};
RestoreScreenAndInvariants:
PUBLIC
PROC [paintAction:
ATOM, ggData: GGData, remake: ForegroundParts ← triggerBag, backgndOK:
BOOL ←
FALSE, edited:
BOOL ←
TRUE, okToClearFeedback:
BOOL] = {
IF okToClearFeedback THEN Feedback.ClearHerald[ggData.feedback];
Fix the foreground Chain.
IF ggData.aborted[bags]
THEN {
GGAlign.SetStaticBags[ggData];
BufferedRefresh.SetLayerOK[ggData.refresh.sandwich, $Foreground, FALSE];
BufferedRefresh.SetLayerOK[ggData.refresh.sandwich, $Background, FALSE];
ggData.aborted[bags] ← FALSE;
}
ELSE {
SELECT remake
FROM
none => NULL;
triggerBag => {
GGAlign.SetStaticBags[ggData];
BufferedRefresh.SetLayerOK[ggData.refresh.sandwich, $Foreground, FALSE];
};
objectBag => {
GGAlign.FlushAlignBag[ggData.hitTest.alignBag];
GGAlign.FillStaticAlignBag[ggData.hitTest.triggerBag, ggData.hitTest.sceneBag, ggData.hitTest, NOT GGState.ShowAlignments[ggData], GGState.Midpoints[ggData], ggData.hitTest.alignBag];
BufferedRefresh.SetLayerOK[ggData.refresh.sandwich, $Foreground, FALSE];
};
bitMap => {
BufferedRefresh.SetLayerOK[ggData.refresh.sandwich, $Foreground, FALSE];
};
sceneBag => {
GGAlign.FlushTriggerBag[ggData.hitTest.sceneBag];
GGAlign.FillStaticSceneBag[ggData.scene, ggData.hitTest.sceneBag];
GGAlign.AddAllMidpoints[ggData.hitTest.sceneBag, GGState.Midpoints[ggData], ggData.hitTest.alignBag];
};
ENDCASE => ERROR;
Fix the background invariant.
IF NOT backgndOK THEN BufferedRefresh.SetLayerOK[ggData.refresh.sandwich, $Background, FALSE]; -- don't set it TRUE if it is FALSE. It knows better than you do
};
Show the viewer as edited, if appropriate.
IF edited
THEN {
IF
NOT ggData.outer.newVersion
THEN {
ggData.outer.icon ← IF ggData.outer.file=NIL THEN dirtyNoNameIcon ELSE dirtyIcon;
ggData.outer.newVersion ← TRUE;
ViewerOps.PaintViewer[ggData.outer, caption];
};
};
ggData.refresh.paintAction ← paintAction;
ViewerOps.PaintViewer[
viewer: ggData.actionArea,
hint: client,
whatChanged: ggData,
clearClient: FALSE]
};
MakeGGViewer:
PROC [fileName: Rope.
ROPE ←
NIL] = {
ggData: GGData ← CreateWindow[GGScene.CreateScene[], TRUE, FALSE, FileNames.CurrentWorkingDirectory[] ]; -- create brand new GG window
IF fileName#NIL AND ~Rope.Equal[fileName, ""] THEN GGEvent.Get[event: LIST[$Get, fileName], clientData: ggData]; -- tell GGEvent.Get to try for this file
ViewerOps.PaintViewer[ggData.outer, caption]; -- just to get the icon to appear
};
CreateWindow:
PUBLIC
PROC [scene: Scene, iconic:
BOOL, paint:
BOOL, workingDirectory: Rope.
ROPE]
RETURNS [ggData: GGData] = {
tV: Viewer;
ggData ← NEW[GargoyleDataObj];
ggData.currentWDir ← workingDirectory;
ggData.originalWDir ← originalWDir; --global
ggData.hitTest ← NEW[FiltersObj];
ggData.hitTest.triggerBag ← GGAlign.CreateTriggerBag[];
ggData.hitTest.sceneBag ← GGAlign.CreateTriggerBag[];
ggData.hitTest.alignBag ← GGAlign.CreateAlignBag[];
ggData.refresh.lineCache ← FunctionCache.Create[maxEntries: 200];
ggData.scene ← scene;
ggData.caret ← NEW[CaretObj];
ggData.anchor ← NEW[CaretObj];
ggData.camera ← NEW[CameraDataObj];
GGMouseEvent.InitializeFSM[ggData];
ggData.drag.savedCaret ← NEW[CaretObj];
ggData.drag.selectState ← none;
ggData.drag.extendMode ← none;
ggData.refresh.startBoundBox ← GGBoundBox.NullBoundBox[];
ggData.refresh.sandwich ← GGRefresh.CreateSandwich[];
ggData.defaults ← NEW[GGInterfaceTypes.DefaultDataObj ← [strokeColor: Imager.black, fillColor: GGOutline.fillColor, font: GGFont.DefaultDefaultFontData[] ] ];
Construct the outer container.
ggData.outer ← GGContainer.Create[
info: [
name: "Gargoyle",
menu: NIL,
data: ggData,
iconic: TRUE,
column: left,
scrollable: FALSE,
icon: noNameIcon
],
paint: FALSE];
BuildActionArea[ggData];
ggData.height ← 0;
tV ← BiScrollers.CreateScale[ [parent: ggData.outer, wx: 0, wy: buttonAlign, border: FALSE], ggData.biScroller];
tV ← BiScrollers.CreateRotate[ [parent: ggData.outer, wx: tV.wx+tV.ww+entryHSpace, wy: buttonAlign, border: FALSE], ggData.biScroller];
tV ← BiScrollers.CreateFit[ [parent: ggData.outer, wx: tV.wx+tV.ww+entryHSpace, wy: buttonAlign, border: FALSE], ggData.biScroller];
tV ← BiScrollers.CreateReset[ [parent: ggData.outer, wx: tV.wx+tV.ww+entryHSpace, wy: buttonAlign, border: FALSE], ggData.biScroller];
tV ← BiScrollers.CreateEdge[ [parent: ggData.outer, wx: tV.wx+tV.ww+entryHSpace, wy: buttonAlign, border: FALSE], ggData.biScroller];
tV ← BiScrollers.CreatePrev[ [parent: ggData.outer, wx: tV.wx+tV.ww+entryHSpace, wy: buttonAlign, border: FALSE], ggData.biScroller];
tV ← Buttons.Create[info: [parent: ggData.outer, name: "CenterSel", wx: tV.wx+tV.ww+entryHSpace, wy: 0, border: FALSE], proc: CenterSel, clientData: ggData, paint: FALSE];
tV ← Buttons.Create[info: [parent: ggData.outer, name: "FitSel", wx: tV.wx+tV.ww+entryHSpace, wy: 0, border: FALSE], proc: FitSel, clientData: ggData, paint: FALSE];
ggData.height ← entryHeight;
slack process must be created before call to GGMenus.BuildControlPanel
ggData.slackHandle ← SlackProcess.Create[queueSize: 50, logSize: 50, optimizeProc: OptimizeQueue, loggingProc: GGSessionLog.EnterAction, abortProc: GGAbortProc, abortData: ggData, abortViewer: ggData.actionArea];
GGMenus.BuildControlPanel[ggData, NIL];
tV ← BiScrollers.QuaViewer[ggData.biScroller];
ViewerOps.MoveViewer[tV, 0, ggData.height, ggData.outer.cw, ggData.outer.ch-ggData.height, FALSE];
ggData.outer.newVersion ← FALSE;
ggData.gravityPool ← GGGravity.NewGravityPool[];
ggData.multiGravityPool ← GGMultiGravity.NewMultiGravityPool[];
SetCursorLooks[ggData.hitTest.gravityType, ggData]; -- assumes gravity is turned ON
[] ← SlackProcess.EnableAborts[handle: ggData.slackHandle];
};
OptimizeQueue: SlackProcess.OptimizeProc = {
PROC [qeGen: QueueEntryGenerator, actionsOnQueue: NAT] RETURNS [skipActions: NAT];
Notice that skipActions will be at most summary.count -1; The most recent action on the queue will be done if nothing else is appropriate. Always do the last During.
atom, nextAtom: ATOM;
action: LIST OF REF ANY;
IF actionsOnQueue < 2 THEN RETURN [0];
skipActions ← 0;
FOR i:
NAT
IN [0..actionsOnQueue-2]
DO
[----, ----, action] ← SlackProcess.GetQueueEntry[qeGen, i];
atom ← NARROW[action.first];
[----, ----, action] ← SlackProcess.GetQueueEntry[qeGen, i+1];
nextAtom ← NARROW[action.first];
IF atom = $During
AND nextAtom = $During
THEN {
skipActions ← skipActions + 1;
}
ELSE RETURN;
ENDLOOP;
};
GGAbortProc:
PROC [data:
REF
ANY] = {
-- called by SlackProcess when user signals for abort
ggData: GGData ← NARROW[data];
Feedback.Append[ggData.feedback, "Queued operations Aborted", oneLiner];
ggData.refresh.suppressRefresh ← FALSE; -- in case you killed FastPlayback
ggData.aborted ← ALL[TRUE]; -- copies of aborted for all purposes
};
CenterSel: Buttons.ButtonProc = {
ggData: GGData ← NARROW[clientData];
caretPos: Point ← GGCaret.GetPoint[ggData.caret];
bBox: GGBoundBox.BoundBox ← GGBoundBox.BoundBoxOfSelected[scene: ggData.scene, selectClass: normal];
IF bBox.null THEN BiScrollers.Align[bs: ggData.biScroller, client: [variant: coord[x: caretPos.x, y: caretPos.y]], viewer: [variant: fraction[fx: 0.5, fy: 0.5]], paint: TRUE]
ELSE BiScrollers.Align[bs: ggData.biScroller, client: [variant: coord[x: (bBox.loX+bBox.hiX)/2.0, y: (bBox.loY+bBox.hiY)/2.0]], viewer: [variant: fraction[fx: 0.5, fy: 0.5]], paint: TRUE];
};
FitSel: Buttons.ButtonProc = {
ggData: GGData ← NARROW[clientData];
tbBox, vBox, tvBox: Geom2D.Rect;
cToV: ImagerTransformation.Transformation;
bBox: GGBoundBox.BoundBox ← GGBoundBox.BoundBoxOfSelected[scene: ggData.scene, selectClass: normal];
IF
NOT bBox.null
THEN {
cToV ← BiScrollers.GetStyle[].GetTransforms[ggData.biScroller].clientToViewer;
tbBox ← ImagerTransformation.TransformRectangle[cToV, GGBoundBox.RectangleFromBoundBox[bBox] ];
vBox ← BiScrollers.ViewportBox[ggData.biScroller];
tvBox ← ImagerTransformation.TransformRectangle[cToV, vBox];
BiScrollers.BoxScale[bs: ggData.biScroller, from: tbBox, to: tvBox];
Change scale and offsets so that client data previously in `from' covers as much as possible of `to' (from and to in viewer coords).
};
};
PlaceOrigin: PROC [viewer: Viewer] = {
viewer is the ActionArea. The created bitmap contexts have their transformations concatted with the analogous BiScrollers transformation so that operations on the new bitmaps will match the viewer when they are finally displayed.
clientToViewer: Imager.Transformation;
ggData: GGData ← NARROW[BiScrollers.ClientDataOfViewer[viewer]];
[clientToViewer, ----] ← BiScrollers.GetStyle[].GetTransforms[BiScrollers.QuaBiScroller[viewer]];
BufferedRefresh.FitSandwichToScreen[ggData.refresh.sandwich, viewer.cw, viewer.ch];
};
ViewerToWorld:
PUBLIC
PROC [viewerPoint: Point, ggData: GGData]
RETURNS [worldPoint: Point] = {
vec: Imager.VEC;
viewerToClient: Imager.Transformation ← BiScrollers.GetStyle[].GetTransforms[BiScrollers.QuaBiScroller[ggData.actionArea]].viewerToClient;
vec ← ImagerTransformation.Transform[viewerToClient, [x: viewerPoint.x, y: viewerPoint.y] ];
worldPoint ← [ vec.x, vec.y];
};
WorldToViewer:
PUBLIC
PROC [worldPoint: Point, ggData: GGData]
RETURNS [viewerPoint: Point] = {
vec: Imager.VEC;
clientToViewer: Imager.Transformation ← BiScrollers.GetStyle[].GetTransforms[BiScrollers.QuaBiScroller[ggData.actionArea]].clientToViewer;
vec ← ImagerTransformation.Transform[clientToViewer, [x: worldPoint.x, y: worldPoint.y] ];
viewerPoint ← [ vec.x, vec.y];
};
NewGGViewers: Commander.CommandProc = {
[cmd: Handle] RETURNS [result: REF ← NIL, msg: Rope.ROPE ← NIL];
nameList, args: LIST OF Rope.ROPE ← NIL;
argLength: NAT ← 0;
switchChar: CHAR = '-;
[list: args, length: argLength] ← CommandTool.ParseToList[cmd: cmd, starExpand: TRUE, switchChar: switchChar ! CommandTool.Failed => CONTINUE; ];
IF args = NIL OR argLength < 1 THEN { MakeGGViewer[fileName: NIL]; RETURN;};
FOR rl:
LIST
OF Rope.
ROPE ← args, rl.rest
UNTIL rl =
NIL
DO
--open a GGViewer on each file
[] ← MakeGGViewer[fileName: FileNames.ResolveRelativePath[rl.first]];
ENDLOOP;
};
BuildActionArea:
PRIVATE
PROC [ggData: GGData] = {
Create an ActionArea which fills the bottom of the Gargoyle Container
bs: BiScrollers.BiScroller ← BiScrollers.GetStyle[].CreateBiScroller[
class: actionAreaClass,
info: [
parent: ggData.outer,
wx: 0, wy: ggData.height,
ww: ggData.outer.ww,
wh: ggData.outer.wh, -- only initial values for ww and wh. They are constrained below
data: ggData,
border: FALSE,
scrollable: FALSE],
paint: FALSE
];
ggData.actionArea ← bs.QuaViewer[inner: TRUE];
ggData.biScroller ← bs;
GGContainer.ChildXBound[ggData.outer, bs.QuaViewer[inner: FALSE]];
GGContainer.ChildYBound[ggData.outer, bs.QuaViewer[inner: FALSE]];
ggData.height ← ggData.height + ggData.actionArea.wh;
};
GGExtremaProc:
PROC [clientData:
REF
ANY, direction: Geom2D.Vec]
RETURNS [min, max: Geom2D.Vec]
--BiScrollers.ExtremaProc-- = {
This proc is required by BiScrollers to return the extremes of the displayed data
area: Geom2D.Rect;
ggData: GGData ← NARROW[clientData];
bigBox: GGBoundBox.BoundBox ← GGBoundBox.BoundBoxOfBoxes[GGScene.BoundBoxesInScene[ggData.scene].list];
area ← IF bigBox#NIL THEN [x: bigBox.loX, y: bigBox.loY, w: bigBox.hiX-bigBox.loX, h: bigBox.hiY-bigBox.loY] ELSE [0.0, 0.0, 1.0, 1.0];
[min, max] ← Geom2D.ExtremaOfRect[r: area, n: direction];
};
NewCaretPos:
PUBLIC
PROC [ggData: GGData] = {
caret0, caret1, caret2Pos: Point;
distance, angle, slope, lineDist: REAL;
caret0 ← ggData.measure.caret0;
caret1 ← ggData.measure.caret1;
caret2Pos ← Vectors2d.Scale[GGCaret.GetPoint[ggData.caret], 1.0/ggData.hitTest.scaleUnit];
distance ← GGMeasure.DistanceBetweenPoints[caret1, caret2Pos]; -- distance in scaleUnits
angle ← GGMeasure.SmallestAngleOfPoints[caret0, caret1, caret2Pos];
slope ← GGMeasure.SlopeOfPoints[caret1, caret2Pos];
lineDist ← GGMeasure.DistanceFromPointToLine[caret2Pos, caret0, caret1]; -- line distance in scaleUnits
ggData.measure.caret2Value ← caret2Pos;
GGViewerOps.SetPoint[ggData.measure.caret2, caret2Pos];
ggData.measure.slopeViewValue ← slope;
GGViewerOps.SetReal[ggData.measure.slopeView, slope];
ggData.measure.angleViewValue ← angle;
GGViewerOps.SetReal[ggData.measure.angleView, angle];
ggData.measure.radiusViewValue ← distance;
GGViewerOps.SetReal[ggData.measure.radiusView, distance];
ggData.measure.lineDistViewValue ← lineDist;
GGViewerOps.SetReal[ggData.measure.lineDistView, lineDist];
};
SaveCaretPos:
PUBLIC
PROC [ggData: GGData] = {
caret2Pos: Point ← Vectors2d.Scale[GGCaret.GetPoint[ggData.caret], 1.0/ggData.hitTest.scaleUnit];
ggData.measure.caret2Value ← caret2Pos;
GGViewerOps.SetPoint[ggData.measure.caret2, caret2Pos];
ggData.measure.caret0 ← ggData.measure.caret1;
ggData.measure.caret1 ← caret2Pos;
};
SetCursorLooks:
PUBLIC
PROC [type: GGInterfaceTypes.GravityType, ggData: GGData] = {
The following is a hack and is NOT the right way to do business. Unfortunately, the cursor data lives in a viewer CLASS rec instead of a viewer INSTANCE rec so their is no easy way to keep an instance-specific cursor.
newCursor: Cursors.CursorType;
mouseViewer: ViewerClasses.Viewer;
client: BOOL;
terminal: Terminal.Virtual ← Terminal.Current[];
mousePos: Terminal.Position ← Terminal.GetMousePosition[terminal]; -- mouse origin in upper left
tipScreenCoords: TIPUser.TIPScreenCoords ← NEW[TIPUser.TIPScreenCoordsRec ← [mouseX: mousePos.x, mouseY: mousePos.y, color: ggData.actionArea.column=color] ];
tipScreenCoords.mouseY ← IF ggData.actionArea.column=color THEN terminal.colorHeight-mousePos.y ELSE terminal.bwHeight-mousePos.y; -- move mouse origin to lower left
[mouseViewer, client] ← ViewerOps.MouseInViewer[tipScreenCoords];
ggData.actionArea.class.cursor ← newCursor ←
SELECT type
FROM
innerCircle => pointsPreferredCursor,
strictDistance => strictDistanceCursor,
off => offCursor,
ENDCASE => ERROR;
change the cursor immediately if the mouse is in the action area
IF mouseViewer=ggData.actionArea AND client THEN Cursors.SetCursor[newCursor];
};
BuildCursors:
PROC [] = {
pointsPreferredArray: Cursors.CursorArray = [600B+1100B, 600B+1100B+2040B, 2040B+4020B, 4020B+10010B, 10010B+20004B, 20004B+40002B, 40002B+100001B, 40002B+100001B, 40002B+100001B, 40002B+100001B, 20004B+40002B, 10010B+20004B, 4020B+10010B, 2040B+4020B, 600B+1100B+2040B, 600B+1100B]; -- diamond
strictDistanceArray: Cursors.CursorArray = [100001B+40002B, 40002B+20004B, 20004B+10010B, 10010B+4020B, 4020B+2040B, 2040B, 0, 0, 0, 0, 2040B, 4020B+2040B, 10010B+4020B, 20004B+10010B, 40002B+20004B, 100001B+40002B]; -- folded diamond
offArray: Cursors.CursorArray = [177777B, 177777B, 140003B, 140003B, 140003B, 140003B, 140003B, 140003B, 140003B, 140003B, 140003B, 140003B, 140003B, 140003B, 177777B, 177777B]; -- square
pointsPreferredCursor ← Cursors.NewCursor[bits: pointsPreferredArray, hotX: -8, hotY: -6];
strictDistanceCursor ← Cursors.NewCursor[bits: strictDistanceArray, hotX: -8, hotY: -5];
offCursor ← Cursors.NewCursor[bits: offArray, hotX: -8, hotY: -6];
};
Gargoyle Viewer State
SetHeuristics:
PUBLIC
PROC [ggData: GGData, on:
BOOL] = {
stateInfo: AtomButtons.TwoState ← ggData.hitTest.heuristicsButton;
state: AtomButtons.StateType ← AtomButtons.GetButtonState[stateInfo];
IF state = on AND on OR state = off AND NOT on THEN RETURN;
AtomButtons.SwitchState[stateInfo];
RestoreScreenAndInvariants[paintAction: $PaintEntireViewer, ggData: ggData, remake: triggerBag, backgndOK: FALSE, edited: FALSE, okToClearFeedback: TRUE];
};
GetHeuristics:
PUBLIC
PROC [ggData: GGData]
RETURNS [on:
BOOL] = {
stateInfo: AtomButtons.TwoState ← ggData.hitTest.heuristicsButton;
state: AtomButtons.StateType ← AtomButtons.GetButtonState[stateInfo];
on ← state = on;
};
SetGravityExtent:
PUBLIC
PROC [ggData: GGData, inches:
REAL] = {
screenDots: REAL;
graphicsState: AtomButtonsTypes.GraphicsState ← ggData.hitTest.gravityExtentButton;
ged: GGInterfaceTypes.GravityExtentData;
screenDots ← inches*72.0;
Feedback.PutF[ggData.feedback, oneLiner, "Gravity extent is now %g inches.", [real[inches]] ];
ged ← NEW[GGInterfaceTypes.GravityExtentDataObj ← [extent: screenDots]];
GraphicsButton.SetButtonValueAndPaint[graphicsState, ggData, ged];
ggData.hitTest.tolerance ← screenDots;
ggData.hitTest.criticalR ← screenDots;
ggData.hitTest.innerR ← screenDots/2.0;
};
GetGravityExtent:
PUBLIC
PROC [ggData: GGData]
RETURNS [inches:
REAL] = {
screenDots: REAL;
graphicsState: AtomButtonsTypes.GraphicsState ← ggData.hitTest.gravityExtentButton;
ged: GGInterfaceTypes.GravityExtentData;
ged ← NARROW[GraphicsButton.GetValue[graphicsState].buttonData];
screenDots ← ged.extent;
inches ← screenDots/72.0;
};
Init:
PROC = {
actionAreaClass ← BiScrollers.GetStyle[].NewBiScrollerClass[[
flavor: $ActionArea,
extrema: GGExtremaProc,
notify: GGUserInput.InputNotify,
paint: GGActionAreaPaint,
tipTable: TIPUser.InstantiateNewTIPTable["Gargoyle.TIP"],
mayStretch: FALSE, -- NOT OK to scale X and Y differently
offsetsMustBeIntegers: TRUE,
preferIntegerCoefficients: FALSE,
vanilla: GGBasicTransformProc, --proc which provides the vanilla transform for BiScrollers
preserve: [X: 0.5, Y: 0.5] --this specifies point that stays fixed when viewer size changes
]];
noNameIcon ← Icons.NewIconFromFile["Gargoyle.icons", 1]; -- done here so file will come from working directory into which Gargoyle was brought over, e.g. ///Commands/
dirtyNoNameIcon ← Icons.NewIconFromFile["Gargoyle.icons", 0]; -- done here so file will come from working directory into which Gargoyle was brought over, e.g. ///Commands/
dirtyIcon ← Icons.NewIconFromFile["Gargoyle.icons", 2]; -- done here so file will come from working directory into which Gargoyle was brought over, e.g. ///Commands/
originalWDir ← FileNames.CurrentWorkingDirectory[];
BuildCursors[];
Commander.Register[
key: "Gargoyle",
proc: NewGGViewers,
doc: "Create a Gargoyle Graphics Window",
clientData: NIL
];
};
actionAreaClass: BiScrollers.BiScrollerClass ← NIL; -- filled in by Init
noNameIcon: Icons.IconFlavor ← unInit; -- filled in by Init
dirtyNoNameIcon: Icons.IconFlavor ← unInit; -- filled in by Init
dirtyIcon: Icons.IconFlavor ← unInit; -- filled in by Init
originalWDir: Rope.ROPE ← NIL; -- filled in by Init
offCursor: Cursors.CursorType; -- filled in by BuildCursors
pointsPreferredCursor: Cursors.CursorType; -- filled in by BuildCursors
strictDistanceCursor: Cursors.CursorType; -- filled in by BuildCursors
Init[];
END.