<> <> <> 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]; << 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.>> <<>> 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]; <> <<0 is the lowest row.>> <> 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]; <> <