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: BOOL ¬ FALSE] = { 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 ANY ¬ NIL, 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: ViewerClasses.NotifyProc = { 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"], -- case matters in PCedar!! cursor: bullseye ]]; ViewerOps.RegisterViewerClass[$GraphicsButton, graphicsButtonClass]; }; Init[]; END. ώGraphicsButtonImpl.mesa Contents: Procedures dealing selecting and deselecting objects, including both selection actions and selection feedback. Copyright Σ 1985, 1987, 1989, 1992 by Xerox Corporation. All rights reserved. Last edited by Bier on February 23, 1987 1:36:33 pm PST Pier, December 6, 1985 11:07:55 am PST Doug Wyatt, October 6, 1989 3:57:27 pm PDT Michael Plass, March 25, 1992 11:03 am PST [self: Viewer, input: LIST OF REF ANY, device: REF ¬ NIL, user: REF ¬ NIL, display: REF ¬ NIL]; Κ•NewlineDelimiter –(cedarcode) style˜code™K™yKšœ ΟeœC™NK™7K™&K™*K™*K™—šΟk ˜ Kšœh˜hK˜—šΟnœžœž˜!Kšžœ˜Kšžœ˜—Kšž˜˜Kšœžœ!˜3Kšœžœžœ˜+Kšœžœ&˜