GGGraphicsButtonImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by Bier on July 14, 1986 1:00:04 pm PDT
Contents: Procedures dealing selecting and deselecting objects, including both selection actions and selection feedback.
Pier, December 6, 1985 11:07:55 am PST
DIRECTORY
GGBasicTypes, GGGraphicsButton, GGInterfaceTypes, GGShapes, GGUserInput, Imager, ImagerBackdoor, ImagerTransformation, Rope, TIPUser, ViewerClasses, ViewerOps;
GGGraphicsButtonImpl: CEDAR PROGRAM
IMPORTS GGShapes, GGUserInput, Imager, ImagerBackdoor, TIPUser, ViewerOps
EXPORTS GGGraphicsButton =
BEGIN
Viewer: TYPE = ViewerClasses.Viewer;
GargoyleData: TYPE = GGInterfaceTypes.GargoyleData;
GraphicsState: TYPE = REF GraphicsStateObj;
GraphicsStateObj: TYPE = GGGraphicsButton.GraphicsStateObj;
Line: TYPE = GGBasicTypes.Line;
Point: TYPE = GGBasicTypes.Point;
GraphicsButtonPaint: PROC [self: Viewer, context: Imager.Context, whatChanged: REF ANY, clear: BOOL] RETURNS [quit: BOOLFALSE] = {
graphicsState: GraphicsState;
IF whatChanged = NIL THEN { --we are being called by Window Manager
graphicsState ← NARROW[self.data];
Painter[graphicsState];
}
ELSE {
graphicsState ← NARROW[whatChanged];
DrawButton[context, graphicsState];
};
};
Painter: PUBLIC PROC [graphicsState: GraphicsState] = {
ViewerOps.PaintViewer[
viewer: graphicsState.button,
hint: client,
whatChanged: graphicsState,
clearClient: TRUE];
}; -- end of Painter
DrawButton: PROC [dc: Imager.Context, graphicsState: GraphicsState] = {
linePoint, caretPoint: Point;
line: Line;
rect: ImagerTransformation.Rectangle;
Imager.TranslateT[dc, [graphicsState.button.ww/2.0, graphicsState.button.wh/2.0]];
Imager.TranslateT[dc, [graphicsState.button.ww, graphicsState.button.wh/2.0]];
rect ← ImagerBackdoor.GetBounds[dc];
linePoint ← [0.0, 0.0];
caretPoint ← [-graphicsState.value, 0.0];
line ← GGLines.LineFromPointAndVector[linePoint, [0.0, 1.0]];
GGShapes.DrawLine[dc, line, rect];
GGShapes.DrawCaret[dc, caretPoint];
};
BuildGraphicsButton: PUBLIC PROC [viewer: ViewerClasses.Viewer, x,y,w,h: INTEGER, name: Rope.ROPE, initValue: REAL, clientData: REF ANY, atom: ATOM] RETURNS [nextX: INTEGER] = {
gargoyleData: GargoyleData ← NARROW[clientData];
stateInfo: GraphicsState;
stateInfo ← NEW[GraphicsStateObj];
stateInfo.button ← ViewerOps.CreateViewer[
flavor: $GraphicsButton,
info: [
parent: viewer,
wx: x, wy: y,
ww: w,
wh: h,
data: stateInfo,
scrollable: FALSE
]
];
stateInfo.value ← initValue;
stateInfo.clientData ← clientData;
stateInfo.atom ← atom;
gargoyleData.hitTest.gravityExtentButton ← stateInfo;
GGUserInput.MenuNotify[gargoyleData, LIST[stateInfo.atom, $InitialValue]];
nextX ← x + w;
}; -- end of BuildGraphicsButton
GetValue: PUBLIC PROC [graphicsState: GraphicsState] RETURNS [value: REAL] = {
value ← graphicsState.value;
};
SetButtonValueAndPaint: PUBLIC PROC [graphicsState: GraphicsState, value: REAL] = {
graphicsState.value ← value;
Painter[graphicsState];
};
InputNotify: PROC [self: ViewerClasses.Viewer, input: LIST OF REF ANY] = {
atom: ATOM;
graphicsState: GraphicsState ← NARROW[self.data];
gargoyleData: GargoyleData ← NARROW[graphicsState.clientData];
atom ← NARROW[input.first];
SELECT atom FROM
$BugUp => GGUserInput.MenuNotify[gargoyleData, LIST[graphicsState.atom, $ValueUp]];
$BugInitialize => GGUserInput.MenuNotify[gargoyleData, LIST[graphicsState.atom, $InitialValue]];
$BugDown => GGUserInput.MenuNotify[gargoyleData, LIST[graphicsState.atom, $ValueDown]];
ENDCASE => ERROR;
};
Init: PROC = {
graphicsButtonClass: ViewerClasses.ViewerClass;
graphicsButtonClass ←
NEW[ViewerClasses.ViewerClassRec ← [
paint: GraphicsButtonPaint,
notify: InputNotify,
tipTable: TIPUser.InstantiateNewTIPTable["GraphicsButton.TIP"],
cursor: bullseye
]];
ViewerOps.RegisterViewerClass[$GraphicsButton, graphicsButtonClass];
};
Init[];
END.