DIRECTORY Atom USING [PropList], Cursors USING [CursorType], Icons USING [IconFlavor], Imager USING [Context], Rope USING [ROPE], TIPUser USING [TIPTable]; ViewerClasses: CEDAR DEFINITIONS = BEGIN Viewer: TYPE = REF ViewerRec; ViewerRec: TYPE = MACHINE DEPENDENT RECORD [ -- 36 words class: ViewerClass _ NIL, -- static info for all Viewers of this class ** wx, wy: INTEGER _ 0, -- position of viewer frame wrt parent's client space ww, wh: INTEGER _ 0, -- size of the viewer on the screen cx, cy: INTEGER _ 0, -- viewer client position wrt parent ** cw, ch: INTEGER _ 0, -- size of usable space wrt client ** lock: Lock _ [NIL, 0], -- locking information used by ViewerLocks * ** tipTable: TIPUser.TIPTable _ NIL, -- mouse and keyboard events, initialized from class name: Rope.ROPE _ NIL, -- Viewer name, displayed in caption (optional) file: Rope.ROPE _ NIL, -- backing file name (optional) menus: REF _ NIL, -- narrows to MenusPrivate.ViewerMenus * ** icon: Icons.IconFlavor _ unInit, -- picture to display when small, initialized from class column: Column _ left, -- screen space algorithm used when viewer is open scrollable: BOOL _ TRUE, -- optional scroll bar allocation hscrollable: BOOL _ FALSE, -- optional horizontal scroll bar allocation iconic: BOOL _ TRUE, -- small or large representation on screen border: BOOL _ TRUE, -- WMgr paints a one dot black border around viewer 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 clientContext: BOOL _ FALSE, -- hint that client has installed a context for this viewer * ** link: Viewer _ NIL, -- ring of linked viewers ** position: INTEGER _ 0, -- for window positioning primitives use * ** openHeight: INTEGER _ 0, -- "ideal" height hint for open viewer 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 ]; wxmin: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.wx] }; wymin: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.wy] }; wxmax: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.wx+self.ww] }; wymax: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.wy+self.wh] }; cxmin: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.cx] }; cymin: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.cy] }; cxmax: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.cx+self.cw] }; cymax: PROC[self: Viewer] RETURNS[INTEGER] = INLINE { RETURN[self.cy+self.ch] }; ViewerClass: TYPE = REF ViewerClassRec; ViewerClassRec: TYPE = RECORD [ flavor: ViewerFlavor _ NIL, -- name of viewer's class parent: ViewerClass _ NIL, -- super-class, if any 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) document scrolling hscroll: HScrollProc _ NIL, -- horizontal scrolling caption: CaptionProc _ NIL, -- experimental proc for user caption display menus: LIST OF ATOM _ NIL, -- registered menus to automatically add to the viewer tipTable: TIPUser.TIPTable _ NIL, -- table to parse mouse & keyboard events clipChildren: BOOL _ FALSE, -- clip out children during repaint simpleCreate: BOOL _ FALSE, -- simple creation of new instances (see below) bltContents: BltRule _ none, -- use blt to copy screen contents (see comment below) paintRectangles: BOOL _ FALSE, -- keep hints for the paintProc; see comment below icon: Icons.IconFlavor _ document, -- picture to display when small cursor: Cursors.CursorType _ textPointer -- standard cursor when mouse is in viewer ]; BltRule: TYPE = { none, top, center, bottom } ; PaintRectangleFlavor: TYPE = { invalid, blt } ; PaintRectangle: TYPE = REF PaintRectangleRec; PaintRectangleRec: TYPE = RECORD [ flavor: PaintRectangleFlavor _ invalid, x, y, w, h: INTEGER _ 0 ]; xmin: PROC[self: PaintRectangle] RETURNS[INTEGER] = INLINE { RETURN[self.x] }; ymin: PROC[self: PaintRectangle] RETURNS[INTEGER] = INLINE { RETURN[self.y] }; xmax: PROC[self: PaintRectangle] RETURNS[INTEGER] = INLINE { RETURN[self.x+self.w] }; ymax: PROC[self: PaintRectangle] RETURNS[INTEGER] = INLINE { RETURN[self.y+self.h] }; 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 = {static, left, right, color} ; PaintProc: TYPE = PROC [self: Viewer, context: Imager.Context, whatChanged: REF ANY, clear: BOOL] ; NotifyProc: TYPE = PROC [self: Viewer, input: LIST OF REF ANY] ; 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] RETURNS[ok: BOOL]; 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] ; END. "ViewerClasses.mesa; Written by S. McGregor Last Edited by: McGregor, July 21, 1983 10:41 am Last Edited by: Maxwell, January 3, 1983 2:14 pm Last Edited by: Pausch, August 17, 1983 10:06 am Last Edited by: Wyatt, October 27, 1983 11:10 am Instance data for a viewer; Due to some compiler defaulting problems, please act as if the * entries were PRIVATE and ** entries READONLY Class data for a viewer: The bltContents rule in the class requests that the window package attempt to save some of the current screen contents of a viewer by moving the bits to the new viewer location (e.g. when the viewer is moved). Rectangles thus saved will show up as a PaintRectangle with flavor=blt, as a convenience to clients that keep caches of screen contents. It does not make sense to enable this feature without also setting the paintRectangles bit. Clients that scale an image to fit the viewer bounding box should not use this feature. The paintRectangles bit in the class determines whether or not the window manager will pass a PaintRectangle (as the whatChanged parameter) to the viewer when the paintProc is called. These rectangles may be used by the client to optimize painting. If NIL, then the client must assume the entire viewer is invalid. If a PaintRectangle is seen by a paintProc, then it can safely assume that it need paint only those areas with flavor=invalid. The simpleCreate bit in the class implies that a new instances of this class can be constructed just with ViewerOps.CreateViewer[$ClassFlavor, info: [name: instanceName]]. If flavor=invalid, the area inside the rectangle needs to be repainted. If flavor=blt, the area inside the rectangle has already been painted by a blt. ViewerFlavors predefined by the Viewer package include: $Label, $MessageWindow, $Button, $Container, $Rule. Tioga implements $Text and $Typescript. Static documents, such as the message window, may not be open/closed Called by the window manager when the client should repaint the data on the screen. The context is clipped to the client screen area. whatChanged is just passed from the call to ViewerOps.PaintViewer, but will be NIL when the window manager requires a full repaint after moving a viewer on the screen (unless self.class.paintRectangles is set; see above). clear is a hint that the client background is white, so that the client can paint on the black bits if it so chooses. Input events from the class TIPTable. Mouse events get passed whenever the mouse is over the viewer, keyboard events get passed if the viewer owns the input focus (see the InputFocus interface). N.B. Called at Process.priorityForeground! Called when the input focus ownership is changing so that the client can modify things like selection feedback on the screen or private data structures and state. Called when the viewer has been destroyed for some reason. Copy implementor private data structures. The op atom for SetProc and GetProc is for private client agreements to get things like selection contents or content representations other than ropes. Called by the window manager shortly after a viewer is created so that the client can create and initialize private data structures. Also called on the "Reset" menu command. Requests client to save data structures on the disk. force should only be true when called from the emergency backup code on error recovery and requests that the client consider overriding monitors or locks that might otherwise prevent saving the data. If the save failed, the client should return ok=FALSE (example: trying to save a No Name viewer). Client scrolling and scrolling feedback. If op is 'query' the client should return the percentage of the scrollable document at the top and bottom of the screen, or default if unknown. If op is 'up' or 'down' then amount is number of pixels to glitch. If op is 'thumb' then amount is percentage into document to scroll. The shift and control information reflects the state of the shift and control keys during the up, down, and thumb ops and may be interpreted by the client as desired. Client horizontal scrolling and scrolling feedback. If op is 'query' the client should return the percentage of the scrollable document at the left and right of the screen, or default if unknown. If op is 'left' or 'right' then amount is number of pixels to glitch. If op is 'thumb' then amount is percentage into document to scroll. The shift and control information reflects the state of the shift and control keys during the left, right, and thumb ops and may be interpreted by the client as desired. Experimental: allows client to draw caption legend. ʪ– "cedar" style˜JšÏc*™*Jšœ!™0J™0J™0J™0J™šÏk ˜ Jšœžœ ˜Jšœžœ˜Jšœžœ˜Jšœžœ ˜Jšœžœžœ˜Jšœžœ ˜J˜—Jšœžœž ˜ Jšœž˜J˜Jšœžœžœ ˜J˜JšŠ™ŠJ˜š œ žœžœž œžœ ˜8Jšœžœ/˜KJšœžœ 5˜MJšœžœ #˜;Jšœžœ '˜?Jšœžœ %˜=Jšœžœ /˜IJšœžœ4˜VJšœ žœžœ/˜HJšœ žœžœ˜9Jšœžœžœ.˜AJšœ!8˜YJšœ2˜LJšœ žœžœ!˜Jšœžœ˜,Jš¢™¢J˜—šŸ œžœžœ˜)Jš:™:J˜—šŸœžœžœ˜+Jš)™)J˜—Jš—™—J˜JšŸœžœžœžœžœ žœžœžœžœ˜[J˜JšŸœžœžœžœžœžœžœžœ˜MJ˜šŸœžœžœ˜&Jš®™®J˜—šŸœžœžœžœžœžœžœ˜LJš®ž,™ßJ˜—šŸ œžœžœ&žœ˜EJš œžœžœžœžœžœžœ˜OJšœ žœ˜*Jšê™êJ˜—šŸ œžœžœ'žœ˜GJš œžœžœžœžœžœžœ˜OJšœ žœ˜.Jšû™ûJ˜—šŸ œžœžœ*˜BJš3™3J™—Jšžœ˜—…—ð5¼