DIRECTORY Draw2d, Imager, QuadTree, Rope, Vector, ViewerClasses; Browser2D: CEDAR DEFINITIONS = BEGIN Item: TYPE = REF ItemRec; ItemRec: TYPE = RECORD [ class: ItemClass, data: REF ANY ]; ItemClass: TYPE = REF ItemClassRec; ItemClassRec: TYPE = RECORD [ paint: ItemPaintProc ¬ NIL, selectionNotify: ItemSelectionNotifyProc ¬ NIL, distanceTo: ItemDistanceToProc ¬ NIL, boundingBox: ItemBoundingBoxProc --must not be defaulted ]; ItemPaintProc: TYPE = PROC [self: Item, commonData: REF ANY, context: Imager.Context, zip: Draw2d.Zip, how: Instruction]; Instruction: TYPE = {normal, userSelected, clientSelected, deSelect}; ItemSelectionNotifyProc: TYPE = PROC [self: Item, commonData: REF ANY, how: Instruction]; ItemDistanceToProc: TYPE = PROC [self: Item, commonData: REF ANY, location: Vector.VEC] RETURNS [distance: REAL]; ItemBoundingBoxProc: TYPE = PROC [self: Item, commonData: REF ANY] RETURNS [box: BoundingBox]; BoundingBox: TYPE = QuadTree.BoundingBox; LeastCommonBoundingBox: PROC [a, b: BoundingBox] RETURNS [c: BoundingBox]; BrowserHandle: TYPE = REF BrowserHandleRec; BrowserHandleRec: TYPE; Create: PROC [size: BoundingBox, selectionDistance: REAL, icon: ViewerClasses.IconFlavor, caption: Rope.ROPE, commonData: REF ANY, Destroy: DestroyProc ¬ NIL] RETURNS [browser: BrowserHandle]; DestroyProc: TYPE = PROC [commonData: REF ANY]; AddItem: PROC [browser: BrowserHandle, item: Item, paint: BOOL ¬ FALSE]; RepaintBrowser: PROC [browser: BrowserHandle]; SelectItem: PROC [browser: BrowserHandle, item: Item]; BlinkSelections: PROC [browser: BrowserHandle, times: INT ¬ 3, delayMSecs: INT ¬ 1000]; ClearAllSelections: PROC [browser: BrowserHandle]; CenterSelections: PROC [browser: BrowserHandle, margin: Vector.VEC, tolerance: Vector.VEC, force: BOOLEAN ¬ FALSE] RETURNS [moved: BOOLEAN]; CenterEverything: PROC [browser: BrowserHandle]; SetMessageWindow: PROC [browser: BrowserHandle, contents: Rope.ROPE, times: INT ¬ 0, delayMSecs: INT ¬ 1000]; END. „ Browser2D.mesa Copyright Σ 1992 by Xerox Corporation. All rights reserved. Greene, June 1, 1990 8:23 pm PDT Client supplied procedure to draw the item. Defaulting this means that the item's bounding box will be drawn. When an item is selected in the browser, the items paint proc is called with how = userSelected, and then this procedure is called. Any work not related to painting should be included here to avoid locking problems. This procedure should report the distance from the "item" to the "location" to facilitate selecting the nearest item in the browser. Here the default is the Manhattan distance to the bounding box. RECORD[lowerLeft, upperRight: Vector.VEC]; Normally used after a long sequence of AddItems with paint = FALSE, if AddItem is called with paint = TRUE then this is not needed. First the item's paint proc is called with how = clientSelected, then the item's notify proc is called with how = clientSelected. The item's paint proc is called alternately with how = normal and how = clientSelected. Compute the bounding box of the selected items. If the box is closer than "tolerance" to the edges of the current viewport (or force = TRUE), then rescale the viewer so that the bounding box fits within the viewport with "margin" amount of space surrounding it. Used to insert Ropes into a small message window at the top of a browser. Times > 0 blinks the message window. Κ@•NewlineDelimiter –(cedarcode) style™J™lIcode˜KšΟk œ?˜HKšΟn œœ œ˜Kšœ˜Kšœœœ ˜šœ œœ˜K˜Kšœœ˜ K˜—K˜K˜Kšœ œœ˜#šœœœ˜Kšœœ˜Kšœ+œ˜/Kšœ!œ˜%Kšœ#Οc˜:K˜—K˜š œœœœœ>˜yJšœ+™+JšœA™A—Kšœ œ4˜EK˜š œœœœœ˜YJ™Ψ—K˜šœœœœœœœ œ˜qJšœ„™„Jšœ?™?—K˜Kš œœœœœœ˜^šœ œ˜)Jšœœ™*—K˜Kšžœœœ˜JK˜K˜Kšœœœ˜+Kšœœ˜K˜Kšžœœ(œ0œœœžœœœ˜ΐK˜Kš œ œœœœ˜/K˜Kšžœœ-œœ˜HK˜šžœœ˜.Kšœ=œ$œ™ƒ—K˜šž œœ&˜6Kšœ„™„—K˜šžœœ!œœ ˜WKšœW™W—K˜Kšžœœ˜2K˜šžœœ)œœ œœœ œ˜ŒKšœˆœz™†—K˜Kšžœœ˜0K˜K˜š žœœ)œ œœ ˜mKšœo™o—K˜Kšœ˜K˜K˜šœ˜K˜——…—Τ˜