DIRECTORY CD, CDBasics, CDColors, CDIO, CDOps, CDViewer, Commander, Convert, Imager, ImagerBackdoor, ImagerBox, ImagerSample, Process, Rope, SF, TerminalIO, Vector2, ViewerClasses, X11, X11Access, X11BitmapWidgets, X11Tk, X11Widgets; CDDisplayInX: CEDAR MONITOR IMPORTS CD, CDColors, CDIO, CDOps, CDViewer, Commander, Convert, Imager, ImagerBackdoor, ImagerBox, ImagerSample, Process, Rope, TerminalIO, Vector2, X11, X11Access, X11BitmapWidgets, X11Tk, X11Widgets = BEGIN Widget: TYPE = X11Widgets.Widget; initialSize: REAL _ 1.0; connection: X11.Connection _ NIL; globalSpec: XSpec _ NIL; synchronized: BOOL _ FALSE; screen: INT _ 0; server: Rope.ROPE _ "dana"; XSpec: TYPE = REF XSpecRec; XSpecRec: TYPE = RECORD [ connection: X11.Connection _ NIL, name: Rope.ROPE _ NIL, design: CD.Design _ NIL, layers: ARRAY CD.Layer OF BOOLEAN _ ALL[TRUE], bitmap: Widget _ NIL, magnification: Widget _ NIL, moveVector: Imager.VEC _ [0.0, 0.0] ]; LayerSpec: TYPE = REF LayerRec; LayerRec: TYPE = RECORD [ layerKey: ATOM _ NIL, statusKey: ATOM _ NIL ]; DestroyHit: X11Widgets.ButtonHitProcType = { X11Widgets.DestroyTopLevel[NARROW[key]]; }; SetLayer: X11Widgets.ButtonHitProcType = { i: XSpec _ NARROW[clientData]; compoundKey: LayerSpec _ NARROW[key]; layerKey: ATOM _ compoundKey.layerKey; statusKey: ATOM _ compoundKey.statusKey; layer: CD.Layer _ CD.FetchLayer[i.design.technology, layerKey]; i.layers[layer] _ statusKey = $on; }; ResetHit: X11Widgets.ButtonHitProcType = { i: XSpec _ NARROW[clientData]; X11Widgets.SetText[i.magnification, Convert.RopeFromReal[initialSize], immediately]; i.moveVector _ [0.0, 0.0]; DoDraw[i]; }; MoveHit: X11Widgets.ButtonHitProcType = { i: XSpec _ NARROW[clientData]; dX: REAL _ i.bitmap.s.size.width/2.0; dY: REAL _ i.bitmap.s.size.height/2.0; dXY: Imager.VEC _ SELECT key FROM $left => [-dX, 0.0], $right => [dX, 0.0], $up => [0.0, dY], $down => [0.0, -dY], ENDCASE => [0.0, 0.0]; i.moveVector _ Vector2.Add[i.moveVector, dXY]; DoDraw[i]; }; GrowShrinkHit: X11Widgets.ButtonHitProcType = { i: XSpec _ NARROW[clientData]; oldScale: REAL _ Convert.RealFromRope[X11Widgets.GetText[i.magnification]]; newScale: REAL _ SELECT key FROM $grow => MIN[oldScale*2.0, 100.0], $shrink => MAX[oldScale/2.0, 0.01], ENDCASE => oldScale; X11Widgets.SetText[i.magnification, Convert.RopeFromReal[newScale], immediately]; DoDraw[i]; }; MyDrawChild: CD.DrawProc = { CD.DrawOb[ob: ob, trans: trans, pr: pr, readOnlyInstProps: readOnlyInstProps]; }; MyDrawRect: CD.DrawRectProc = { IF globalSpec.layers[l] THEN { Imager.SetColor[pr.deviceContext, pr.contextColors[l]]; Imager.MaskBox[pr.deviceContext, [xmin: r.x1, ymin: r.y1, xmax: r.x2, ymax: r.y2]]}; }; DrawHit: X11Widgets.ButtonHitProcType = { i: XSpec _ NARROW[clientData]; DoDraw[i]; }; DoDraw: PROC [i: XSpec] ~ { ct: Imager.Context _ X11BitmapWidgets.CreateContext[i.bitmap]; boundsRect: Imager.Rectangle _ ImagerBackdoor.GetBounds[ct]; boundsBox: Imager.Box _ ImagerBox.BoxFromRectangle[boundsRect]; scale: REAL _ Convert.RealFromRope[X11Widgets.GetText[i.magnification]]; instance: CD.Instance _ CDOps.SelectedInstance[design: i.design].first; myDrawRef: CD.DrawRef _ CD.CreateDrawRef[[ interestClip: CDBasics.universe, drawChild: MyDrawChild, drawRect: MyDrawRect, deviceContext: ct, design: i.design, contextColors: CDColors.globalColors[bw][normal].cols ]]; Imager.SetColor[ct, Imager.white]; Imager.MaskBox[ct, boundsBox]; Imager.TranslateT[ct, i.moveVector]; Imager.ScaleT[ct, scale]; globalSpec _ i; IF instance # NIL THEN CD.DrawOb[myDrawRef, instance.ob, instance.trans, instance.properties]; myDrawRef _ NIL; globalSpec _ NIL; }; BitmapChanged: X11BitmapWidgets.BitmapEventProc = { i: XSpec _ NARROW[X11Tk.GetWidgetProp[widget, $CDDrawInX]]; IF i#NIL THEN { IF reason#terminate THEN { sm: ImagerSample.SampleMap _ ImagerSample.NewSampleMap[box: [[0, 0], [widget.s.size.height, widget.s.size.width]]]; X11BitmapWidgets.SetBitmap[widget, sm, SF.maxBox, FALSE]; DoDraw[i]; }; }; }; CreateLayerWidget: PROC [text: Rope.ROPE, layerKey: ATOM, i: XSpec] RETURNS [widget: Widget] ~ { header: Widget _ X11Widgets.CreateLabel[ widgetSpec: [borderWidth: 1], textSpec: [text: text] ]; toggle: Widget _ X11Widgets.CreateToggle[ widgetSpec: [borderWidth: 1], choices: LIST [ ["on", NEW[LayerRec _ [layerKey: layerKey, statusKey: $on]]], ["off", NEW[LayerRec _ [layerKey: layerKey, statusKey: $off]]]], hitProc: SetLayer, clientData: i ]; widget _ X11Widgets.CreateYStack[[], LIST[header, toggle]]; }; CreateTopWidget: PROC [connection: X11.Connection, design: CD.Design, name: Rope.ROPE] = { i: XSpec _ NEW[XSpecRec _ [connection: connection, name: name, design: design]]; top: Widget _ X11Widgets.CreateTopLevel[ parentWindow: X11.GetScreens[connection][screen].root, connection: i.connection, windowHeader: Rope.Cat["ChipNDale: ", name] ]; bitmap: Widget _ X11BitmapWidgets.CreateBitmapWidget[ widgetSpec: [size: [1000, 1000], borderWidth: 1], notify: BitmapChanged ]; levels: Widget _ X11Widgets.CreateXStack[[], LIST[CreateLayerWidget["ndif", $ndif, i], CreateLayerWidget["pdif", $pdif, i], CreateLayerWidget["pwell", $pwell, i], CreateLayerWidget["nwell", $nwell, i], CreateLayerWidget["pwCont", $pwellCont, i], CreateLayerWidget["nwCont", $nwellCont, i], CreateLayerWidget["wndif", $wndif, i], CreateLayerWidget["wpdif", $wpdif, i], CreateLayerWidget["wpwellCont", $wpwellCont, i], CreateLayerWidget["wnwellCont", $wnwellCont, i], CreateLayerWidget["pol", $pol, i], CreateLayerWidget["met", $met, i], CreateLayerWidget["met2", $met2, i], CreateLayerWidget["ovg", $ovg, i], CreateLayerWidget["cut", $cut, i], CreateLayerWidget["cut2", $cut2, i], CreateLayerWidget["imp", $imp, i], CreateLayerWidget["bur", $bur, i], CreateLayerWidget["bond", $bond, i]]]; redraw: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "redraw"], hitProc: DrawHit, clientData: i ]; destroy: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "destroy"], hitProc: DestroyHit, key: top ]; action: Widget _ X11Widgets.CreateXStack[[], LIST[redraw, destroy]]; reset: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "reset"], hitProc: ResetHit, clientData: i ]; left: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "left"], hitProc: MoveHit, clientData: i, key: $left ]; right: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "right"], hitProc: MoveHit, clientData: i, key: $right ]; up: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "up"], hitProc: MoveHit, clientData: i, key: $up ]; down: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "down"], hitProc: MoveHit, clientData: i, key: $down ]; grow: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "grow"], hitProc: GrowShrinkHit, clientData: i, key: $grow ]; shrink: Widget _ X11Widgets.CreateButton[ widgetSpec: [borderWidth: 1], textSpec: [text: "shrink"], hitProc: GrowShrinkHit, clientData: i, key: $shrink ]; magnification: Widget _ X11Widgets.CreateField[ widgetSpec: [borderWidth: 1], textSpec: [text: Convert.RopeFromReal[initialSize]]]; controls: Widget _ X11Widgets.CreateXStack[[], LIST[reset, left, right, up, down, grow, shrink, magnification]]; contents: Widget _ X11Widgets.CreateYStack[[], LIST[action, controls, levels, bitmap]]; i.bitmap _ bitmap; i.magnification _ magnification; X11Tk.PutWidgetProp[bitmap, $CDDrawInX, i]; X11Widgets.SetTopChild[top, contents]; X11Widgets.RealizeTopLevel[top]; }; Start: Commander.CommandProc ~ { designName: Rope.ROPE _ TerminalIO.RequestRope[prompt: "Enter design name: "]; design: CD.Design _ CDViewer.FindDesign[name: designName]; IF design = NIL THEN { design _ CDIO.ReadDesign[from: designName, wDir: CDIO.GetWorkingDirectory[]]; CDOps.SetMutability[design: design, mutability: editable]; [] _ CDViewer.CreateViewer[design: design, openPanel: FALSE]}; IF connection=NIL THEN { s: Rope.ROPE _ IF Rope.IsEmpty[server] THEN X11Access.GetServerName[] ELSE server; connection _ X11.CreateConnection[server: s, debugHelp: $demo, synchronized: synchronized]; }; IF screen<0 OR screen>=X11.ScreenCount[connection] THEN screen _ 0; CreateTopWidget[connection, design, designName]; }; Stop: Commander.CommandProc ~ { IF connection#NIL THEN { TRUSTED {Process.Detach[FORK X11.CloseConnection[connection]]}; connection _ NIL; }; }; Commander.Register["CDDemo", Start, "Create widget demo tool"]; Commander.Register["CDStop", Stop, "Stop widget demo tools"]; END. δ CDDisplayInX.mesa Copyright Σ 1989 by Xerox Corporation. All rights reserved. Created by Bryan Preas, May 23, 1989 4:37:54 pm PDT -- global frame varibles --these three lines are for debugging reasons, and should not be in a sample tool server: Rope.ROPE _ "clarissa"; PROC [pr: CD.DrawRef, ob: CD.Object, trans: CD.Transformation_[], readOnlyInstProps: CD.PropList_NIL]; PROC [pr: CD.DrawRef, r: CD.Rect, l: CD.Layer]; -- must have a better to pass context to DrawProc !! Κ Ξ™codešœ™Kšœ<™˜>Jšœ<˜Kšœœ5˜@—Kšœ ˜ Kšœ˜—Kšœ%œ˜;K˜K˜—š žœœœœœ˜ZKšœ œB˜Pšœ(˜(Kšœœ%˜6KšœE˜EKšœ˜—šœ5˜5Kšœ1˜1Kšœ˜Kšœ˜—šœ,˜,šœ%˜)Kšœ$˜$Kšœ&˜&Kšœ&˜&Kšœ+˜+Kšœ+˜+Kšœ&˜&Kšœ&˜&Kšœ0˜0Kšœ0˜0Kšœ"˜"Kšœ"˜"Kšœ$˜$Kšœ"˜"Kšœ"˜"Kšœ%˜%Kšœ"˜"Kšœ"˜"Kšœ&˜&——šœ)˜)Kšœ˜Kšœ˜Kšœ˜Kšœ˜—šœ*˜*Kšœ˜Kšœ˜Kšœ˜Kšœ˜—Kšœ-œ˜Dšœ(˜(Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜—šœ'˜'Kšœ˜Kšœ˜Kšœ+˜+Kšœ˜—šœ(˜(Kšœ˜Kšœ˜Kšœ,˜,Kšœ˜—šœ%˜%Kšœ˜Kšœ˜Kšœ)˜)Kšœ˜—šœ'˜'Kšœ˜Kšœ˜Kšœ+˜+Kšœ˜—šœ'˜'Kšœ˜Kšœ˜Kšœ1˜1Kšœ˜—šœ)˜)Kšœ˜Kšœ˜Kšœ3˜3Kšœ˜—šœ/˜/Kšœ˜Kšœ5˜5—Kšœ/œ=˜pKšœ/œ$˜WKšœ˜Kšœ ˜ Kšœ+˜+Kšœ&˜&Kšœ ˜ Kšœ˜K˜—šžœ˜ Kšœœ9˜NKšœœ0˜:šœ œœ˜Kšœ œ$œ˜MKšœ:˜:Kšœ6œ˜>—K˜šœ œœ˜Kš œœœœœ ˜SKšœ œK˜[Kšœ˜—Kšœ œ œœ ˜CKšœ0˜0K˜K˜—šžœ˜šœ œœ˜Kšœœœ˜?Kšœ œ˜Kšœ˜—K˜K˜—Kšœ?˜?Kšœ=˜=Kšœ˜K˜J˜—…—!š-L