GGCaretImpl.mesa
Copyright Ó 1985, 1992 by Xerox Corporation. All rights reserved.
Pier, February 3, 1988 9:58:53 am PST
Bier, November 1, 1988 4:01:05 pm PST
Contents: Facilities for moving the caret and storing information about the neighborhood it inhabits (such as what trajectory it is sitting on).
DIRECTORY
GGBasicTypes, GGBoundBox, GGCaret, GGInterfaceTypes, GGModelTypes, GGSegmentTypes, GGSliceOps;
GGCaretImpl: CEDAR PROGRAM
IMPORTS GGBoundBox, GGSliceOps
EXPORTS GGCaret = BEGIN
Caret: TYPE = REF CaretObj;
CaretObj: TYPE = GGInterfaceTypes.CaretObj;
GGData: TYPE = GGInterfaceTypes.GGData;
Joint: TYPE = GGModelTypes.Joint;
Point: TYPE = GGBasicTypes.Point;
Segment: TYPE = GGSegmentTypes.Segment;
Sequence: TYPE = GGModelTypes.Sequence;
Slice: TYPE = GGModelTypes.Slice;
SliceDescriptor: TYPE = GGModelTypes.SliceDescriptor;
Traj: TYPE = GGModelTypes.Traj;
TrajData: TYPE = GGModelTypes.TrajData;
TrajPartType: TYPE = GGModelTypes.TrajPartType;
Vector: TYPE = GGBasicTypes.Vector;
NotYetImplemented: PUBLIC SIGNAL = CODE;
Create: PUBLIC PROC RETURNS [caret: Caret] = {
caret ¬ NEW[CaretObj];
};
Copy: PUBLIC PROC [to, from: Caret] = {
Used for dropping the anchor.
to­ ¬ from­;
};
Kill: PUBLIC PROC [caret: Caret] = {
This caret no longer exists. It should disappear from the screen.
caret.exists ¬ FALSE;
};
Exists: PUBLIC PROC [caret: Caret] RETURNS [BOOL] = {
RETURN[caret.exists];
};
BoundBoxOfCaret: PUBLIC PROC [caret: Caret, ggData: GGData] RETURNS [box: GGBoundBox.BoundBox ¬ NIL] = {
fudge: REAL ¬ 4.0; -- needed to make control points erase properly
leftOffset, rightOffset, topOffset, bottomOffset: REAL ¬ 0.0;
IF caret=NIL OR ggData=NIL THEN ERROR;
SELECT TRUE FROM
caret=ggData.caret => {
leftOffset ¬ GGCaret.caretWidth/2.0;
rightOffset ¬ leftOffset;
topOffset ¬ 0.0;
bottomOffset ¬ GGCaret.caretHeight;
};
caret=ggData.anchor => {
leftOffset ¬ GGCaret.anchorWidth/2.0;
rightOffset ¬ leftOffset;
topOffset ¬ GGCaret.anchorHeight/2.0;
bottomOffset ¬ topOffset;
};
ENDCASE => RETURN[NIL];
leftOffset ¬ leftOffset+fudge;
rightOffset ¬ rightOffset+fudge;
bottomOffset ¬ bottomOffset+fudge;
topOffset ¬ topOffset+fudge;
RETURN[GGBoundBox.CreateBoundBox[ caret.point.x-leftOffset, caret.point.y-bottomOffset, caret.point.x+rightOffset, caret.point.y+topOffset ]];
};
The Chair.
SitOn: PUBLIC PROC [caret: Caret, chair: SliceDescriptor ¬ NIL] = {
caret.chair ¬ chair;
};
GetChair: PUBLIC PROC [caret: Caret] RETURNS [chair: SliceDescriptor] = {
chair ¬ caret.chair;
};
SittingOnEnd: PUBLIC PROC [caret: Caret] RETURNS [BOOL] = {
IF caret.chair = NIL THEN RETURN[FALSE];
RETURN[GGSliceOps.IsDescriptorOfEnd[caret.chair]];
};
The Attractor.
NoAttractor: PUBLIC PROC [caret: Caret] = {
caret.attractor ¬ NIL;
};
SetAttractor: PUBLIC PROC [caret: Caret, point: Point, normal: Vector, attractor: REF ANY] = {
caret.exists ¬ TRUE;
caret.point ¬ point;
caret.normal ¬ normal;
caret.attractor ¬ attractor;
};
GetAttractor: PUBLIC PROC [caret: Caret] RETURNS [attractor: REF ANY] = {
attractor ¬ caret.attractor;
};
GetPoint: PUBLIC PROC [caret: Caret] RETURNS [point: Point] = {
point ¬ caret.point;
};
GetNormal: PUBLIC PROC [caret: Caret] RETURNS [normal: Vector] = {
normal ¬ caret.normal;
};
END.