DIRECTORY CedarProcess, Imager, ImagerFont, IO, List, Menus, Rope, TIPUser, Vector2, ViewerClasses; Controls: CEDAR DEFINITIONS ~ BEGIN Context: TYPE ~ Imager.Context; ClickProc: TYPE ~ Menus.ClickProc; -- called if button is buttoned Viewer: TYPE ~ ViewerClasses.Viewer; -- buttons, controls, graphics, etc. Column: TYPE ~ ViewerClasses.Column; Font: TYPE ~ Imager.Font; Process: TYPE ~ CedarProcess.Process; ROPE: TYPE ~ IO.ROPE; STREAM: TYPE ~ IO.STREAM; Pos: TYPE ~ RECORD [x, y: INTEGER _ 0]; PosSequence: TYPE ~ REF PosSequenceRep; PosSequenceRep: TYPE ~ RECORD [ length: NAT _ 0, element: SEQUENCE maxLength: NAT OF Pos ]; PosSequences: TYPE ~ REF PosSequencesRep; PosSequencesRep: TYPE ~ RECORD [ length: NAT _ 0, element: SEQUENCE maxLength: NAT OF PosSequence ]; MouseButton: TYPE ~ {none, left, middle, right}; -- which mouse button was buttoned MouseState: TYPE ~ {none, down, held, up}; -- state of pressed button Mouse: TYPE ~ RECORD [ -- complete mouse information x, y: INTEGER _ 0, -- screen coordinates state: MouseState _ none, button: MouseButton _ none, controlKey, shiftKey: BOOL _ FALSE ]; IntegerSequence: TYPE ~ REF IntegerSequenceRep; IntegerSequenceRep: TYPE ~ RECORD [element: SEQUENCE length: NAT OF INTEGER]; RealSequence: TYPE ~ REF RealSequenceRep; RealSequenceRep: TYPE ~ RECORD [element: SEQUENCE length: NAT OF REAL]; Control: TYPE ~ REF ControlRep; ControlRep: TYPE ~ RECORD [ -- complete control information name: ROPE _ NIL, -- name of control type: ControlType _ vSlider, -- slider, dial, functioner, contourer proc: ControlProc _ NIL, -- proc to call if control adjusted process: Process _ NIL, -- fork new process if old not busy report: BOOL _ TRUE, -- if true, report control value truncate: BOOL _ FALSE, -- if true, truncate reported value row: INTEGER _ 0, -- row of control (0 is lowest) x, y, w, h: INTEGER _ 0, -- control sizes (usu. automatic set) textLocation: TextLocation _ above, -- where to place text font: Font _ NIL, -- font type (usu. defaulted) dummy: BOOL _ FALSE, -- if true, don't paint this control data: REF ANY _ NIL, -- client supplied data min, max, init: REAL _ 0.0, -- range and inital value of control detents: DetentList _ NIL, -- for sliders or dials taper: SliderTaper _ lin, -- for sliders value: REAL _ 0.0, -- (readonly) slider or dial value valuePrev: REAL _ 0.0, -- (readonly) previous slider value values: RealSequence _ NIL, -- function values sliderDialRef: REF ANY, -- (private) details in impl functionRef: REF ANY, -- (private) details in impl contourRef: REF ANY _ NIL, -- (private) details in impl sketchRef: REF ANY _ NIL, -- (private) details in impl mouse: Mouse, -- (readonly) mouse in control outerData: OuterData _ NIL, -- (readonly) parent viewer data viewer: Viewer _ NIL, -- (readonly) control viewer flavor: ATOM _ $Nil, -- (readonly) permit some wizardry title: Viewer _ NIL, -- (private) viewer to display name status: Viewer _ NIL, -- (private) viewer to display value parent: Viewer _ NIL, -- (private) outer viewer graphics: Viewer _ NIL -- (private) graphics viewer ]; ControlList: TYPE ~ LIST OF Control; ControlProc: TYPE ~ PROC [control: Control]; -- proc called if control adjusted ControlType: TYPE ~ { vSlider, -- vertical slider; bar is horizontal hSlider, -- horizontal slider; bar is vertical dial, -- circular dial function, -- rectangular viewer for function contour, -- rectangular viewer for contour sketch -- rectangular viewer for sketch }; ControlSizes: TYPE ~ RECORD [ wVSlider: INTEGER, -- width of vertical slider wHSlider: INTEGER, -- width of horizontal control hVSlider: INTEGER, -- height of vertical slider hHSlider: INTEGER, -- height of horizontal slider dDial: INTEGER, -- diameter of dial wSketch: INTEGER, -- width of sketcher hSketch: INTEGER -- height of sketcher ]; defSizes: ControlSizes ~ [25, 200, 60, 25, 60, 150, 150]; Detents: TYPE ~ RECORD [ -- detent positions within a control t: REAL, -- private value: REAL -- for client use ]; DetentList: TYPE ~ LIST OF Detents; TextLocation: TYPE ~ {above, below, left, right}; -- text placement relative to control SliderTaper: TYPE ~ {log, lin, exp}; -- logarithmic, linear, or exponential OuterData: TYPE ~ REF OuterDataRep; OuterDataRep: TYPE ~ RECORD [ -- complete outer data name: ROPE _ NIL, -- name of viewer column: Column _ left, -- column of viewer data: REF ANY _ NIL, -- client supplied data parent: Viewer _ NIL, -- (private) main outer viewer typeScript: Viewer _ NIL, -- (private) typeScript viewer graphics: Viewer _ NIL, -- (private) graphics viewer graphicsData: GraphicsData _ NIL, -- (private) graphics viewer data controls: ControlList _ NIL, -- controls for parent viewer controlSizes: ControlSizes _ defSizes, -- default sizes for controls lastControl: Control _ NIL, -- (readonly) last control moused buttons: LIST OF Button _ NIL, -- buttons for outer viewer destroyProc: DestroyProc _ NIL, -- call if outer viewer destroyed destroyed: BOOL _ FALSE, -- (readonly) if viewer destroyed directory: ROPE _ NIL, -- (readonly) commander directory cmdOut: STREAM _ NIL, -- (readonly) commander output controlsY: INTEGER _ 0, -- (private) base of controls controlsH: INTEGER _ 0, -- (private) height of controls graphicsY: INTEGER _ 0, -- (private) base of graphics graphicsH: INTEGER _ 0, -- (private) graphics viewer height tsY: INTEGER _ 0, -- (private) base of typescript tsH: INTEGER _ 0, -- (private) typescript height buttonsY: INTEGER _ 0, -- (private) base of buttons buttonsH: INTEGER _ 0, -- (private) height of buttons outerH: INTEGER _ 0, -- (private) height of outer viewer tSin: STREAM _ NIL, -- (private) input typescript stream tSout: STREAM _ NIL, -- (private) output typescript stream tSclear: BOOL _ TRUE -- (private) typescript display clear? ]; DestroyProc: TYPE ~ PROC [outerData: OuterData]; -- call when outer viewer destroyed OuterViewer: PROC [ name: ROPE _ NIL, column: Column _ left, buttons: ButtonList _ NIL, controls: ControlList _ NIL, controlSizes: ControlSizes _ defSizes, graphicsHeight: INTEGER _ 0, graphicsProc: GraphicsProc _ NIL, graphicsShow: GraphicsShow _ NIL, destroyProc: DestroyProc _ NIL, typeScriptHeight: INTEGER _ 0, data: REF ANY _ NIL, noOpen: BOOL _ FALSE] RETURNS [Viewer]; ChangeOuterViewer: PROC [outerData: OuterData, controls: ControlList]; GraphicsData: TYPE ~ REF GraphicsDataRep; GraphicsDataRep: TYPE ~ RECORD [ -- complete graphics viewer specs proc: GraphicsProc _ NIL, -- called if graphics mouse action show: GraphicsShow _ NIL, -- proc called to display graphics data: REF ANY _ NIL, -- client supplied data mouse: Mouse _ [0, 0, none, none], -- (readonly) graphics viewer mouse viewer: Viewer _ NIL, -- (private) graphics viewer parent: Viewer _ NIL -- (private) parent viewer ]; GraphicsProc: TYPE ~ PROC [ -- call if graphics viewer mouse action graphics: GraphicsData ]; GraphicsShow: TYPE ~ PROC [ -- graphics display proc context: Context, -- Imager context w, h: INTEGER, -- size of context data: REF ANY _ NIL, -- client supplied data whatChanged: REF ANY _ NIL, -- as in ViewerOps viewer: Viewer _ NIL -- as in ViewerOps ]; GraphicsViewer: PROC [ parent: Viewer, y, h: INTEGER _ 0, proc: GraphicsProc, show: GraphicsShow, data: REF ANY] RETURNS [Viewer]; NewControl: PROC [ name: ROPE _ NIL, type: ControlType _ vSlider, data: REF ANY _ NIL, min, max, init: REAL _ 0.0, proc: ControlProc _ NIL, report: BOOL _ TRUE, truncate: BOOL _ FALSE, row: INTEGER _ 0, x, y, w, h: INTEGER _ 0, textLocation: TextLocation _ above, dummy: BOOL _ FALSE, flavor: ATOM _ $Nil, detents: LIST OF Detents _ NIL, taper: SliderTaper _ lin, values: RealSequence _ NIL] RETURNS [Control]; Append: PROC [control: Control, controls: ControlList _ NIL] RETURNS [ControlList]; ControlViewerList: PROC [ parent, graphics: Viewer _ NIL, controls: Controls.ControlList, data: REF ANY]; ControlViewer: PROC [ parent: Viewer, graphics: Viewer _ NIL, control: Control, outerData: OuterData _ NIL]; NotifyControl: PUBLIC ViewerClasses.NotifyProc; SetMouse: PUBLIC PROC [atom: ATOM, tipCoords: TIPUser.TIPScreenCoords] RETURNS [Mouse]; LastControlMoused: PUBLIC PROC RETURNS [Control]; ControlPositions: PROC [controls: ControlList, sizes: ControlSizes, columnWidth: INTEGER] RETURNS [height: INTEGER]; ControlRow: PROC [control: Control, row: INTEGER]; GetSliderDialValue: PROC [control: Control] RETURNS [REAL]; GetFunctionValues: PROC [control: Control] RETURNS [RealSequence]; GetSketch: PROC [control: Control] RETURNS [PosSequences]; GetContour: PROC [control: Control] RETURNS [PosSequence]; Reset: PROC [c1, c2, c3, c4, c5, c6: Control _ NIL, repaint: BOOL _ TRUE]; SetSliderDialValue: PROC [control: Control, value: REAL, repaint: BOOL _ TRUE]; SetFunctionValues: PROC [control: Control, values: RealSequence, repaint: BOOL _ TRUE]; SetSketch: PROC [control: Control, sketch: PosSequences, repaint: BOOL _ TRUE]; SetContour: PROC [ control: Control, pairs: PosSequence, closed: BOOL _ FALSE, repaint: BOOL _ TRUE]; CloseContour: PUBLIC PROC [control: Control, repaint: BOOL _ TRUE]; Button: TYPE ~ RECORD [ -- specifications for a menu button name: ROPE _ NIL, -- name of button proc: ClickProc, -- proc to call upon button press row: INTEGER _ 0, -- vert. pos'n of button (0 is lowest) x, y, w, h: INTEGER _ 0, -- button dimensions (usu. auto. set) font: Font _ NIL, -- font type (usu. defaulted) fork: BOOL _ TRUE, -- if true, fork proc on button documentation: REF ANY _ NIL, -- as in Buttons.mesa paint: BOOL _ TRUE, -- as in Buttons.mesa guarded: BOOL _ FALSE, -- as in Buttons.mesa style: ATOM _ $BlackOnWhite, -- as in Buttons.mesa viewer: Viewer _ NIL -- (private) viewer for this button ]; ButtonList: TYPE ~ LIST OF Button; ButtonReLabel: PROC [outerData: OuterData, oldName, newName: ROPE]; ButtonToggle: PROC [outerData: OuterData, state: BOOL, trueName, falseName: ROPE]; ButtonStyle: PROC [outerData: OuterData, name: ROPE, style: ATOM]; ButtonPositions: PROC [buttons: ButtonList] RETURNS [buttonHeight: INTEGER]; ButtonViewerList: PROC [parent: Viewer, buttons: ButtonList, outerData: OuterData]; ButtonViewer: PROC [parent: Viewer, button: Button, outerData: OuterData] RETURNS [Viewer]; TypeScriptClear: PROC [outerData: OuterData]; TypeScriptWrite: PROC [outerData: OuterData, rope: ROPE]; TypeScriptRead: PROC [outerData: OuterData, prompt: ROPE _ NIL] RETURNS [ROPE]; TypeScriptReadFileName: PROC [outerData: OuterData] RETURNS [ROPE]; Vernier: PROC [vernier, control: Control, cwIncrease: BOOL _ TRUE, resolution: REAL _ 10.0]; IsContourClosed: PROC [control: Control] RETURNS [BOOL]; NPointsInContour: PROC [control: Control] RETURNS [INTEGER]; NLinesInSketch: PROC [control: Control] RETURNS [INTEGER]; NPointsInSketch: PROC [control: Control] RETURNS [INTEGER]; Quit: ClickProc; Restore: ClickProc; EndViewer: PROC [viewer: REF ANY]; END. ฎControls.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Bloomenthal, February 25, 1987 5:15:10 pm PST Imported Types Controls Types A Control A control is a viewers which may be a slider, dial, function, or contour. for all: for sliders, dials, and functions only: private implementation details: private/readonly for all: Outer Types and Procedures These relate to an outer, top-level viewer containing controls. Create a top level viewer whose data field is of type OuterData. The viewer may contain an arbitrary number of controls and buttons, a single typescript, and a single graphics viewer. The buttons are placed at the top of the viewer. Below the buttons is the optional, scrollable typescript (usually a height of 18 is good for one line); the software may print or prompt to the typescript, and the user may type a reply. Below the typescript is an optional sub-viewer for display of graphical material. The controls are placed below the graphics viewer. If noOpen then the viewer will not be opened (iconic or otherwise), permitting a program to manipulate the viewer (for example, installing an icon from a file) before displaying it. Resize outer viewer, if necessary to accomodate new controls; remove any previous controls no longer in the list. Graphics Types and Procedures This is the viewer that permits a graphics display. Create a graphics viewer of height h and parent. Control Creation Return a control but do not allocate its viewer; viewer allocation done by ControlViewer. name will appear above the control. proc, if non-nil, is called everytime the control is adjusted. If report is true, the current control value appears next to the control name. If truncate is true, the displayed value is rounded to an integer. The controls are normally ordered by OuterViewer, from right to left, beginning new rows as needed; if row is non-zero, however, the control will appear in the specified row and all subsequent controls will follow it; 0 is the lowest row. If y is non-zero, however, the control will appear at the specified y value, regardless of the value of row. If dummy is true, the control is used as a placeholder and is not painted. If there are any detents, the taper is constrained to linear. Add control to end of list and return pointer to beginning of list. Create set of viewers from list of controls. Usually used internally. Create a control given a parent viewer. Usually used internally. Specifying flavor is recommended for wizards only. Control Notification Wizards only! Get a mouse from tip output. Return the most recently touched control. This may be a control that no longer exists! Control Positioning If not already set, set default location and size for controls. Usually used internally. Place control on given row; to have an effect, this call must preceed call to OuterViewer; 0 is the lowest row. Control Reading Return the value of the control slider or dial. Return the values of the control function. Return a sketch from the control's sketch list. Return a contour from the control's contour chain. Control Setting Set to initalial value(s) and optionally repaint any non-nil controls. Set the value of the control slider or dial to value and repaint the control iff repaint is true. Set the values of the control function and repaint the control iff repaint is true. If control is type sketch, then replace its sketch with newSketch. If control is type contour, then replace its contour with newContour. Close the closed or unclosed contour. Button Definitions and Procedures These are menu buttons. When a button's proc is called, it is passed the outer viewer's data. Change the button name from oldName to newName (but alas, not the size). Change the button name to trueName or falseName, depending on state. Change the style of the named button; recognised display styles are: $BlackOnWhite - black letters on white background (default) $WhiteOnBlack - white letters on black background $BlackOnGrey - black letters on grey background If not already set, set default location and size for entries. Usually used internally. Create set of button viewers from list of entries. Usually used internally. Create a button viewer from button. Usually used internally. TypeScript Procedures This is a scrollable viewer permitting text to be read or written. Write a carriage-return to the tyescript viewer if the current line is not empty. Write rope into the typescript viewer. Wait for a reply terminated with a carriage-return. Wait for a reply and prepend directory name if necessary. Vernier Procedures vernier is used to make fine adjustments on control; vernier must be a dial, control must be a slider or dial. If cwIncrease, turning the vernier clockwise will increase the value of control. resolution is the number of vernier rotations required to move control through its full extent. Miscellaneous Querying Return true if contour associated with control is closed, false otherwise. Return false if no contour associated with control. Return number of pairs in contour associated with control. Return 0 if no contour associated with control. Return number of lines in sketch associated with control. Return 0 if no sketch associated with control. Return number of pairs in sketch associated with control. Return 0 if no sketch associated with control. Miscellaneous Procedures Default quit menu procedure. Restore all controls associated with outer to their initial settings. Destroy the given viewer. ส/˜šœ ™ Jšœ ฯmœ1™Jšœ žœžœก#˜CJšœž œ ก˜:Jšœ ž œ ก%˜EJšœ)ก˜?Jšœžœก˜9Jšœ žœžœก$˜AJšœ žœžœžœก˜5—™'Jšœžœ ก$˜GJšœžœก˜9Jšœ"ก˜0Jšœ žœ ก"˜?Jšœ žœ ก#˜BJšœžœก˜4—™Jšœžœžœก˜;Jšœžœžœก˜;Jšœžœžœžœก˜>Jšœžœžœžœก˜=—™Jšœก˜6Jšœžœก ˜BJšœžœก˜:Jšœ žœ ก"˜?Jšœžœก#˜AJšœžœก$˜CJšœžœก˜8Jšœžœก˜;—J˜—Jšœžœžœžœ ˜&J˜Jšœžœžœก"˜RJ˜šœžœ˜Jšœก%˜Jšœ ž œ ก˜™>JšœN™NJšœB™BJ™Jšœ[™[JšœY™YJšœ`™`JšœE™EJ™JšœJ™JJšœ=™=—Icode˜šขœžœ,žœžœ˜SJ™CJ™—šขœžœ˜Jšœžœ˜Jšœ˜Jšœžœžœ˜J™FJ™—šข œžœ˜Jšœ#žœ˜'Jšœ˜Jšœžœ˜J™AJ™2——š ™šะbn œžœ˜/J™ J™—šขœž œžœ&žœ ˜WJ™J™—šขœž œžœ ˜1J™W——š ™šฃœžฯbœ:žœ˜YJšžœ žœ˜J™YJ™—šฃ œžคœžœ˜2J™ZJ™——š ™šขœžœžœžœ˜;J™/J™—šขœžœžœ˜BJ™*J™—šข œžœžœ˜:J™/J™—šข œžœžœ˜:J™2——š ™š ขœžœ$žœ žœžœ˜JL™FL™—š ขœžœžœ žœžœ˜OJ™aJ™—šขœžœ3žœžœ˜WJ™SJ™—šข œžœ3žœžœ˜OJšœB™BJ™—šข œžœ˜Jš œ.žœžœ žœžœ˜RJ™EJ™—š ข œžœžœžœžœข˜CJ™%——š !™!Jšœ^™^J™šœ žœžœก#˜BJšœ žœžœ ก˜-Jšœก!˜T