<<>> <> <> <> <> <> <> <> <> <> <> <<>> DIRECTORY Atom USING [PropList], Imager USING [Context], Rope USING [ROPE], TIPTypes USING [TIPTable]; ViewerClasses: CEDAR DEFINITIONS = BEGIN Viewer: TYPE = REF ViewerRec; ViewerRec: TYPE = PACKED RECORD [ class: ViewerClass ¬ NIL, -- static info for all Viewers of this class ** wx, wy: INTEGER ¬ 0, -- position of viewer window wrt parent's client space ww, wh: INTEGER ¬ 0, -- size of viewer window area cx, cy: INTEGER ¬ 0, -- position of client space wrt window ** cw, ch: INTEGER ¬ 0, -- size of viewer client space ** lock: Lock ¬ [NIL, 0], -- locking information used by ViewerLocks * ** tipTable: TIPTable ¬ NIL, -- mouse and keyboard events, initialised from class name: Rope.ROPE ¬ NIL, -- Viewer name, displayed in caption (optional) file: Rope.ROPE ¬ NIL, -- backing file name (optional) label: Rope.ROPE ¬ NIL, -- icon label (optional) menu: Menu ¬ NIL, -- copied from class; set with ViewerOps.SetMenu icon: IconFlavor ¬ unInit, -- picture to display when small, initialised from class column: Column ¬ left, -- screen space algorithm used when viewer is open caption: BOOL ¬ FALSE, -- viewer has a caption bar at the top scrollable: BOOL ¬ TRUE, -- viewer has a vertical scroll bar hscrollable: BOOL ¬ FALSE, -- viewer has a horizontal scroll bar iconic: BOOL ¬ TRUE, -- small or large representation on screen border: BOOL ¬ TRUE, -- viewer has a surrounding black border newVersion: BOOL ¬ FALSE, -- hint that the user has made new edits ** newFile: BOOL ¬ FALSE, -- hint that a backing file does not yet exist ** visible: BOOL ¬ TRUE, -- WMgr maintained hint for repaint use * ** offDeskTop: BOOL ¬ FALSE, -- is viewer off of the current desktop? ** destroyed: BOOL ¬ FALSE, -- hint that viewer has been flushed from window tree ** init: BOOL ¬ FALSE, -- init proc call has been completed after creation * ** saveInProgress: BOOL ¬ FALSE, -- the saveProc has been called but not yet returned ** inhibitDestroy: BOOL ¬ FALSE, -- if TRUE then window menu will not permit destroy guardDestroy: BOOL ¬ FALSE, -- if TRUE then window menu will always guard destroy paintingWedged: BOOL ¬ FALSE, -- used to mark a viewer whose paint proc has died * ** transparentTIP: BOOL ¬ FALSE, -- passes user input events without tip table interpretation spare0, spare1, spare2, spare3, spare4, spare5: BOOL ¬ FALSE, -- spares position: [0..256) ¬ 0, -- icon position * ** openHeight: INTEGER ¬ 0, -- "ideal" height hint for open viewer link: Viewer ¬ NIL, -- ring of linked viewers ** parent: Viewer ¬ NIL, -- NIL if top level viewer ** sibling: Viewer ¬ NIL, -- sibling chain ** child: Viewer ¬ NIL, -- head of children chain ** props: Atom.PropList ¬ NIL, -- clients can associate properties with viewers ** data: REF ANY ¬ NIL, -- data slot for Viewer Class implementor cursor: CursorType ¬ none -- (see comment below) ]; <> <> ViewerClass: TYPE = REF ViewerClassRec; ViewerClassRec: TYPE = PACKED RECORD [ flavor: ViewerFlavor ¬ NIL, -- name of viewer's class notify: NotifyProc ¬ NIL, -- TIP input events parsed from tipTable paint: PaintProc ¬ NIL, -- called whenever the Viewer should repaint its contents modify: ModifyProc ¬ NIL, -- reports InputFocus changes destroy: DestroyProc ¬ NIL, -- called before Viewer structures freed on destroy copy: CopyProc ¬ NIL, -- copy data to new Viewer set: SetProc ¬ NIL, -- set the viewer contents get: GetProc ¬ NIL, -- get the viewer contents init: InitProc ¬ NIL, -- called on creation or reset to init client data save: SaveProc ¬ NIL, -- requests client to write contents to disk scroll: ScrollProc ¬ NIL, -- vertical scrolling hscroll: HScrollProc ¬ NIL, -- horizontal scrolling caption: CaptionProc ¬ NIL, -- display caption adjust: AdjustProc ¬ NIL, -- called when viewer size is changed menu: Menu ¬ NIL, -- template menu used for top-level viewers tipTable: TIPTable ¬ NIL, -- table to parse mouse & keyboard events topDownCoordSys: BOOL ¬ FALSE, -- TRUE => children positioned wrt top of client space bltH: HBltRule ¬ none, -- use blt to copy screen contents (see comment below) bltV: VBltRule ¬ none, -- use blt to copy screen contents (see comment below) icon: IconFlavor ¬ document, -- picture to display when small cursor: CursorType ¬ textPointer, -- standard cursor when mouse is in viewer props: Atom.PropList ¬ NIL ]; Menu: TYPE ~ REF MenuRec; MenuRec: TYPE = RECORD [ lines: ARRAY MenuLine OF MenuEntry ¬ ALL[NIL], x, y: INTEGER ¬ 0, linesUsed: [0..maxMenuLines] ¬ 1, lineInverted: MenuLine ¬ 0, inverted: MenuEntry ¬ NIL ]; maxMenuLines: NAT ~ 5; MenuLine: TYPE = [0..maxMenuLines); MenuEntry: TYPE = REF MenuEntryRec; MenuEntryRec: TYPE = PRIVATE MONITORED RECORD [ link: MenuEntry ¬ NIL, name: Rope.ROPE, proc: ClickProc, width: INTEGER ¬ 0, xPos: INTEGER ¬ 0, clientData: REF ANY ¬ NIL, documentation: REF ANY ¬ NIL, fork: BOOL ¬ TRUE, greyed: BOOL ¬ FALSE, guarded: BOOL ¬ FALSE, guardState: GuardState ¬ armed ]; GuardState: TYPE = { guarded, arming, armed }; TIPTable: TYPE ~ TIPTypes.TIPTable; CursorType: TYPE ~ MACHINE DEPENDENT { activate(0), blank(1), bullseye(2), confirm(3), crossHairsCircle(4), ftp(5), typeKey(6), hourGlass(7), move(8), menu(9), mouseRed(10), mouseYellow(11), mouseBlue(12), grow(13), pointDown(14), pointLeft(15), pointRight(16), pointUp(17), questionMark(18), retry(19), scrollDown(20), scrollLeft(21), scrollLeftRight(22), scrollRight(23), scrollUp(24), scrollUpDown(25), textPointer(26), none(27), last(255)}; IconFlavor: TYPE ~ MACHINE DEPENDENT { -- pre-defined icons document(0), dirtyDocument(1), fileCabinet(2), tool(3), typescript(4), private(CARDINAL.LAST-1), -- will cause call of viewer paintProc to paint icon unInit(CARDINAL.LAST) -- flag for unitialised icon type }; PaintHint: TYPE = { all, client, menu, caption }; <<>> HBltRule: TYPE = { none, left, center, right }; VBltRule: TYPE = { none, top, center, bottom }; <> <<>> PaintRectangle: TYPE = REF PaintRectangleRec; PaintRectangleRec: TYPE = RECORD[ x, y, w, h: INTEGER ¬ 0 ]; ViewerFlavor: TYPE = ATOM; <> Lock: TYPE = RECORD [ -- process-reentrant viewer lock process: UNSAFE PROCESS ¬ NIL, -- current write process count: CARDINAL ¬ 0 -- number of locks currently granted for this viewer ]; Column: TYPE = MACHINE DEPENDENT {static(0), left(1), right(2), color(3), (CARDINAL.LAST)}; <> <> PaintProc: TYPE = PROC [self: Viewer, context: Imager.Context, whatChanged: REF, clear: BOOL] RETURNS [quit: BOOL ¬ FALSE]; <> NotifyProc: TYPE = PROC [self: Viewer, input: LIST OF REF ANY, device: REF ¬ NIL, user: REF ¬ NIL, display: REF ¬ NIL]; <> ModifyProc: TYPE = PROC [self: Viewer, change: ModifyAction]; ModifyAction: TYPE = {set, push, pop, kill}; <> DestroyProc: TYPE = PROC [self: Viewer]; <> CopyProc: TYPE = PROC [self, new: Viewer]; <> SetProc: TYPE = PROC [self: Viewer, data: REF ANY, finalise: BOOL ¬ TRUE, op: ATOM ¬ NIL]; GetProc: TYPE = PROC [self: Viewer, op: ATOM ¬ NIL] RETURNS [data: REF ANY]; <> InitProc: TYPE = PROC [self: Viewer]; <> SaveProc: TYPE = PROC [self: Viewer, force: BOOL ¬ FALSE]; <> SaveAborted: ERROR[error: Rope.ROPE]; ScrollProc: TYPE = PROC [self: Viewer, op: ScrollOp, amount: INTEGER, shift, control: BOOL ¬ FALSE] RETURNS [top, bottom: INTEGER ¬ LAST[INTEGER]]; ScrollOp: TYPE = {query, up, down, thumb}; <> HScrollProc: TYPE = PROC [self: Viewer, op: HScrollOp, amount: INTEGER, shift, control: BOOL ¬ FALSE] RETURNS [left, right: INTEGER ¬ LAST[INTEGER]]; HScrollOp: TYPE = {query, left, right, thumb}; <> CaptionProc: TYPE = PROC [self: Viewer, context: Imager.Context]; <> AdjustProc: TYPE = PROC [self: Viewer] RETURNS [adjusted: BOOL ¬ FALSE]; <> MouseButton: TYPE = {red, yellow, blue}; <> ClickProc: TYPE = PROC [parent: Viewer, clientData: REF ANY ¬ NIL, mouseButton: MouseButton ¬ red, shift, control: BOOL ¬ FALSE]; <> END.