DEFINITION WinView; (* Stephan Junker 31.10.93 *) (* WinView implements viewers which are displayed using standard AES windows. Most window functions are served automatically, but they can of course be overridden if a service doesn't meet your specification. *) CONST UpdateAll* = 0; (* aspect: update everything *) TYPE Viewer* = POINTER TO ViewDesc; ViewDesc* = RECORD(MVC.ViewDesc) handle- : INTEGER; elements- : SET; x-,y-,w-,h- : INTEGER; (* position and size of work space *) fx-,fy-,fw-,fh- : INTEGER; (* maximum size *) opened- : BOOLEAN; (* true if opened *) xOff-,yOff- : LONGINT; (* offset in pixels *) lSize-,cSize-:INTEGER; (* pixels per line/column *) dw-,dh- : LONGINT; (* width and height of data in pixels *) title-,info-: ARRAY 160 OF CHAR; PROCEDURE(v : Viewer) Init*; (* Intializes a new viewer. It is stored in a list, so don't dispose its memory! The fields are initialized as follows: handle = -1, x = fx = 0, y = fy = 40, w = fw = 640, h = fh = 360, opened = FALSE, xPos = 0, yPos = 0, lSize = 16, cSize = 8, elements = all elements, title = "Untitled", info = "" *) PROCEDURE(v : Viewer) Open*; (* opens a window at x,y with size w,h as defined in the viewer. Those values refer to the size of the work area! If opening fails, an error message is shown and v.Opened will be FALSE *) PROCEDURE(v : Viewer) Close*; (* closes the window defined by v. Closing implies deleting from the sight of the AES, so the window handle will be available again. However, the contents of v is untouched and the viewer may be opened again without any changing *) PROCEDURE(v : Viewer) Remove*; (* removes v from the viewer list and disposes its memory. It will be closed if open *) PROCEDURE(v : Viewer) Redraw*(x,y,w,h : INTEGER); (* this procedure redraws the rectangle x,y,w,h (absolute) in viewer v. Please override *) PROCEDURE(v: Viewer) UpdateRect*(x,y,w,h : INTEGER); (* calls v.Redraw in order to redraw the rectangle x,y,w,h. Window update is switched on and the mouse is invisible. *) PROCEDURE(v : Viewer) Update*(aspect : LONGINT); (* calls v.UpdateRect with the whole window as rectangle. aspect is ignored *) PROCEDURE(v : Viewer) HandleMsgEvent*(VAR msgBuf : Evnt.msgbuf); (* is called if a message is received which concerns the viewer v. The messages WMREDRAW, WMTOPPED, WMCLOSED, WMFULLED, WMARROWED, WMHSLID, WMVSLID, WMSIZED and WMMOVED are serviced. Override for other messages *) PROCEDURE(v : Viewer) HandleKeyEvent*(shiftbits : SET; scancode : INTEGER; char : CHAR); (* is called if a key is pressed and v is the top window. It reacts on some standard keys to scroll the window, override for others *) PROCEDURE(v : Viewer) HandleButtonEvent*(mbut : SET; mx, my, clicks : INTEGER); (* is called if WinView.HandleEvent detects a button event in the work area of viewer v *) PROCEDURE(v : Viewer) Topped*; (* called if the user wants to top viewer v *) PROCEDURE(v : Viewer) HSlid*(pos : INTEGER); (* called if the user slided the horizontal slider to position Pos *) PROCEDURE(v : Viewer) VSlid*(pos : INTEGER); (* called if the user slided the vertical slider to position Pos *) PROCEDURE(v : Viewer) Sized*(newW, newH : INTEGER); (* called if the user changed the size of viewer v to newW, newH *) PROCEDURE(v : Viewer) Moved*(newX, newY : INTEGER); (* called if the user moved viewer v to position newX, newY *) PROCEDURE(v : Viewer) Fulled*; (* sets the size of the window to full size or, if it has already full size, to the size it had before *) PROCEDURE(v : Viewer) PageUp*; (* displays the data of the previous page *) PROCEDURE(v : Viewer) PageDown*; (* displays the data of the next page *) PROCEDURE(v : Viewer) PageLeft*; (* displays the data of the page to the left *) PROCEDURE(v : Viewer) PageRight*; (* displays the data of the page to the right *) PROCEDURE(v : Viewer) LineUp*; (* displays the data of the previous line *) PROCEDURE(v : Viewer) LineDown*; (* displays the data of the next line *) PROCEDURE(v : Viewer) ColLeft*; (* displays the data one column to the left *) PROCEDURE(v : Viewer) ColRight*; (* displays the data one column to the right *) PROCEDURE(v : Viewer) Snap*; (* corrects the size and coordinates to certain rastered values. Override if desired *) PROCEDURE(v : Viewer) VSlider*; (* sets the vertical slider according to the values in v.dh and v.yOff. Override if this is not what you desire *) PROCEDURE(v : Viewer) HSlider*; (* sets the horizontal slider according to the values in v.dw and v.xOff. Override if this is not what you desire *) PROCEDURE(v : Viewer) SetPos*(x,y : INTEGER); (* sets the position of viewer v. The viewer is redrawn at the new position *) PROCEDURE(v : Viewer) SetSize*(w,h : INTEGER); (* sets the size of viewer v. The viewer is redrawn with the new size *) PROCEDURE(v : Viewer) SetElements*(elements : SET); (* sets the window elements of viewer v. The viewer is redrawn with the new elements *) PROCEDURE(v : Viewer) SetFullSize*(fx,fy,fw,fh : INTEGER); (* sets the maximum size of a viewer. This size is used if the window is to be fulled. This setting has no direct affect on the viewer. *) PROCEDURE(v : Viewer) SetOffset*(xOff,yOff : LONGINT); (* sets the offset in x and y direction. The offset defines the number of pixels invisible at the left and upper margin and tells the redraw procedure where to start with the redraw. These values are changed by the procedures which react on WM_ARROW and WM_xSLID messages. The contents of the viewer is redrawn immediately *) PROCEDURE(v : Viewer) SetLCSize*(lSize,cSize : INTEGER); (* sets the size of a line and a column in pixels. These values are used by the procedures reacting on WM_ARROW in order to shift the contents. This setting has no direct affect on the viewer. *) PROCEDURE(v : Viewer) SetDataWH*(dw,dh : INTEGER); (* sets the size of the whole data to display in pixels. These values are used by the procedures which set the horizontal and vertical sliders. Both are redrawn after this setting *) PROCEDURE(v : Viewer) SetTitle*(title : ARRAY OF CHAR); (* sets the title of the window *) PROCEDURE(v : Viewer) ScrollUp*(x,y,w,h,scroll : INTEGER); (* scrolls the rectangle x,y+scroll,w,h-scroll up by scroll pixels. This means that x,y,w,h defines the rectangle in which is to be scrolled. If the window is top, the scroll is performed directly, else it uses the rectangle list *) BEGIN DoScroll(VR.ScrollUp, v.handle,x,y,w,h,scroll); END ScrollUp; PROCEDURE(v : Viewer) ScrollDown*(x,y,w,h,scroll : INTEGER); (* same as ScrollUp but scrolls down *) BEGIN DoScroll(VR.ScrollDown, v.handle,x,y,w,h,scroll); END ScrollDown; PROCEDURE(v : Viewer) ScrollLeft*(x,y,w,h,scroll : INTEGER); (* same as ScrollUp but scrolls left *) BEGIN DoScroll(VR.ScrollLeft, v.handle,x,y,w,h,scroll); END ScrollLeft; PROCEDURE(v : Viewer) ScrollRight*(x,y,w,h,scroll : INTEGER); (* same as ScrollUp but scrolls down *) BEGIN DoScroll(VR.ScrollRight, v.handle,x,y,w,h,scroll); END ScrollRight; END; PROCEDURE HandleEvent*(VAR events : GemApp.Events) : BOOLEAN; (* reacts on the events concerning a window. Call in a procedure which overrides GemApp.HandleEvent. Returns true if the event is reacted on *) END WinView.