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 GargoyleData: TYPE = GGInterfaceTypes.GargoyleData; GraphicsState: TYPE = REF GraphicsStateObj; GraphicsStateObj: TYPE = GGGraphicsButton.GraphicsStateObj; Line: TYPE = GGBasicTypes.Line; Point: TYPE = GGBasicTypes.Point; 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]; 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; rect: Imager.Rectangle; 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]; 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. ψGGGraphicsButtonImpl.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Last edited by Bier on February 10, 1987 2:05:03 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 line: Line; Imager.TranslateT[dc, [graphicsState.button.ww/2.0, graphicsState.button.wh/2.0]]; line _ GGLines.LineFromPointAndVector[linePoint, [0.0, 1.0]]; GGShapes.DrawLine[dc, line, rect]; Κ˜code™Kšœ Οmœ1™Kšœžœ˜Kšžœž˜Kšœ/žœ ˜SKšœ7žœ%˜`Kšœ1žœ"˜WKšžœžœ˜K˜K˜—šŸœžœ˜Kšœ/˜/Kšœ˜Kšœ˜šžœ!˜$Kšœ˜Kšœ˜Kšœ?˜?K˜Kšœ˜—Kšœ˜KšœD˜DKšœ˜K˜—Kšœ˜K™Kšžœ˜K˜K˜K˜—…— -