PopUpSelection2.Mesa
Copyright © 1983, 1985, 1986 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, August 3, 1983 9:47 am
Last edited by: Christian Jacobi, August 26, 1986 10:21:13 am PDT
Mike Spreitzer November 14, 1986 5:28:55 pm PST
DIRECTORY Imager, Rope;
PopUpSelection2: CEDAR DEFINITIONS =
A pop-up menu abstraction.
BEGIN
ROPE: TYPE = Rope.ROPE;
All coordinates and sizes are in pixels.
Create: PROC [choices: ChoiceS, doc: ROPE, header: Image ← NIL, left, top: Label ← nullLabel, columns: NAT ← 1, timeOut: NAT ← 0] RETURNS [Menu];
ChoiceS: TYPE = REF ChoiceSequence;
ChoiceSequence: TYPE = RECORD [elts: SEQUENCE length: NAT OF Choice];
Choice: TYPE = RECORD [
image: Image,
doc: ROPE];
nullChoice: Choice = [NIL, NIL];
Image: TYPE = REF ImagePrivate;
ImagePrivate: TYPE = RECORD [
size: Imager.VEC,
Draw: Drawer,
data: REF ANYNIL
];
Drawer: TYPE = PROC [image: Image, context: Imager.Context, bounds: Imager.Rectangle, highlight: BOOL];
bounds describes the area to paint, in the context's current coordinate system; the caller tried to make it same as image.size; it might well be bigger; it should only be smaller if there's real trouble making it big enough. Do not assume the area has been cleared. highlighted indicates the user is pointing at this image and wants it highlighted. Not called under DoSave, so please restore context's transformation upon exit; other context state variables may be changed (and of course you can't assume they have any particular value upon entry).
nullLabel: Label = NIL;
Label: TYPE = REF LabelPrivate;
LabelPrivate: TYPE = RECORD [
minSpacing--parallel to edge being labelled--, minWidth--perpendicular--: NAT,
Draw: PROC [context: Imager.Context, org: Imager.VEC, n, spacing, width: NAT, data: REF ANY],
data: REF ANY
];
Menu: TYPE = REF MenuPrivate;
MenuPrivate: TYPE;
Pop: PROC [menu: Menu, default: NAT ← 0, position: REFNIL, InNotifier: Consumer ← NIL, notifyData: REF ANYNIL] RETURNS [INT];
Shows a pop-up menu and returns the number of the selected entry.
returns: 1 for first choice, 2 for second...
 0 if selected outside menu or on header-line
 -1 if timed out
default:  Hint for initial selection by implicit mouse movement. 0 if no default.
position:  Hint to override mouse position. See documentation for possible types.
Pop must not be called from inside a viewers-repaint or a TIP-notify procedure. You can get the answer in the notifier process, however, by supplying InNotifier & notifyData.
Consumer: TYPE = PROC [INT, REF ANY];
Must not be in a local frame, because it will be called from a different process (maybe even after Pop returns, depending on scheduling).
END.