GraphicsButtonImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Last edited by Bier on February 23, 1987 1:36:33 pm PST
Contents: Procedures dealing selecting and deselecting objects, including both selection actions and selection feedback.
Pier, December 6, 1985 11:07:55 am PST
DIRECTORY
AtomButtonsTypes, GraphicsButton, Imager, ImagerTransformation, Rope, TIPUser, ViewerClasses, ViewerOps;
GraphicsButtonImpl: CEDAR PROGRAM
IMPORTS TIPUser, ViewerOps
EXPORTS GraphicsButton =
BEGIN
GBChoiceList: TYPE = AtomButtonsTypes.GBChoiceList;
GraphicsState: TYPE = REF GraphicsStateObj;
GraphicsStateObj: TYPE = AtomButtonsTypes.GraphicsStateObj;
HandleButtonProc: TYPE = AtomButtonsTypes.HandleButtonProc;
RepaintProc: TYPE = AtomButtonsTypes.RepaintProc;
UpdateGraphicsButtonProc: TYPE = AtomButtonsTypes.UpdateGraphicsButtonProc;
Viewer: TYPE = ViewerClasses.Viewer;
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];
graphicsState.repaintProc[context, graphicsState.clientData, graphicsState.buttonData, graphicsState.button];
};
};
Painter: PUBLIC PROC [graphicsState: GraphicsState] = {
ViewerOps.PaintViewer[
viewer: graphicsState.button,
hint: client,
whatChanged: graphicsState,
clearClient: TRUE];
}; -- end of Painter
BuildGraphicsButton: PUBLIC PROC [container: Viewer, x,y,w,h: INTEGER, clientData: REF ANY, choices: GBChoiceList, handleProc: HandleButtonProc, repaintProc: RepaintProc, buttonData: REF ANYNIL, updateProc: UpdateGraphicsButtonProc ← NIL] RETURNS [nextX: INTEGER] = {
stateInfo: GraphicsState;
stateInfo ← NEW[GraphicsStateObj];
stateInfo.button ← ViewerOps.CreateViewer[
flavor: $GraphicsButton,
info: [
parent: container,
wx: x, wy: y,
ww: w,
wh: h,
data: stateInfo,
scrollable: FALSE
]
];
stateInfo.clientData ← clientData;
stateInfo.buttonData ← buttonData;
stateInfo.repaintProc ← repaintProc;
stateInfo.handleProc ← handleProc;
stateInfo.choices ← choices;
IF updateProc # NIL THEN updateProc[clientData, stateInfo];
nextX ← x + w;
}; -- end of BuildGraphicsButton
GetValue: PUBLIC PROC [graphicsState: GraphicsState] RETURNS [clientData: REF ANY, buttonData: REF ANY] = {
clientData ← graphicsState.clientData;
buttonData ← graphicsState.buttonData;
};
SetButtonValueAndPaint: PUBLIC PROC [graphicsState: GraphicsState, clientData: REF ANY, buttonData: REF ANY ← NIL] = {
graphicsState.clientData ← clientData;
graphicsState.buttonData ← buttonData;
Painter[graphicsState];
};
InputNotify: PROC [self: ViewerClasses.Viewer, input: LIST OF REF ANY] = {
graphicsState: GraphicsState ← NARROW[self.data];
handleProc: HandleButtonProc ← graphicsState.handleProc;
ctrl, shift, mouse: ATOM;
list: GBChoiceList;
action: LIST OF REF ANY;
ctrl ← NARROW[input.first];
shift ← NARROW[input.rest.first];
mouse ← NARROW[input.rest.rest.first];
list ← graphicsState.choices;
IF ctrl = $Ctrl THEN
FOR i: NAT IN [1..6] DO
IF list = NIL THEN RETURN;
list ← list.rest;
ENDLOOP;
IF shift = $Shift THEN
FOR i: NAT IN [1..3] DO
IF list = NIL THEN RETURN;
list ← list.rest;
ENDLOOP;
SELECT mouse FROM
$Left => {};
$Middle => {IF list = NIL THEN RETURN; list ← list.rest;};
$Right => {IF list = NIL THEN RETURN; list ← list.rest; IF list = NIL THEN RETURN; list ← list.rest;};
ENDCASE => ERROR;
IF list = NIL THEN RETURN;
action ← list.first.event;
handleProc[graphicsState.clientData, action];
};
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.