(******************************************************************************) (* SAMPLE20.MOD *) (* *) (* PopUps Example *) (* Taken from SAMPLE20.PAS - Metagraphics Software Corporation (c) 1987-1989 *) (* *) (* PSW 10/31/90 11:39pm *) (******************************************************************************) MODULE Sample20; (* * Graphix * Release 3.7 * (c) Copyright 1986-1992 PMI * Green Bay, Wisconsin * (414) 468-6040 * All rights reserved * *) IMPORT GrQry; IMPORT GrConst; IMPORT GrPorts; IMPORT GrFonts; IMPORT Meta; IMPORT IO; IMPORT Lib; FROM GrConst IMPORT rect; FROM GrPorts IMPORT adsPort; FROM GrFonts IMPORT adsFont; (* standard memory allocation procedures *) FROM Storage IMPORT ALLOCATE, DEALLOCATE, Available; VAR GrafixCard, CommPort: INTEGER; ch: CHAR; scrnR,tR: GrConst.rect; imagePtr: GrConst.adsImage; i,j: INTEGER; imBytes: CARDINAL; memBytes: WORD; menuTitle: ARRAY [0..128] OF CHAR; PROCEDURE OpenWindow(VAR R: rect; TITLE: ARRAY OF CHAR); VAR tR:rect; tsize: INTEGER; tdescent: INTEGER; scrnPort: adsPort; txftptr: adsFont; BEGIN imBytes := VAL(CARDINAL, Meta.ImageSize(R)); IF NOT(Available(imBytes)) THEN GrQry.GrQuit('Insufficient memory', 1); END; ALLOCATE(ADDRESS(imagePtr), imBytes ); Meta.ReadImage(R,imagePtr); (* Save the window area *) Meta.FillRect(R,1); (* Clear the window *) Meta.PenMode(GrConst.zXORz); (* Outline the window *) Meta.FrameRect(R); Meta.GetPort( scrnPort ); (* get address of current port *) (* assign address of the current port's font record *) txftptr := scrnPort^.txFont; (* get values of some font fields *) tdescent := txftptr^.descent; tsize := txftptr^.lnSpacing; (* Display title block *) Meta.SetRect(tR, R.Xmin,R.Ymin,R.Xmax,R.Ymin+tsize); Meta.FillRect(tR,0); Meta.MoveTo (tR.Xmin+5, tR.Ymax - tdescent ); Meta.DrawString(TITLE) END OpenWindow; PROCEDURE CloseWindow(VAR R:rect); BEGIN Meta.RasterOp (GrConst.zREPz); Meta.WriteImage (R, imagePtr); (* Restore the window area *) DEALLOCATE(imagePtr, imBytes); END CloseWindow; BEGIN (* init the system *) GrQry.GrInit(GrafixCard, CommPort); i := Meta.InitGrafix(-GrafixCard); IF (i # 0) THEN GrQry.GrInitErr(GrafixCard, CommPort, i) END; Meta.SetDisplay(GrConst.GrafPg0); Meta.ScreenRect(scrnR); Meta.FillRect(scrnR, 3); Meta.SetRect(tR, 75, 75, 250, 150); FOR j := 1 TO 3 DO Meta.MoveTo(10,20); Meta.DrawString('Press a key to show menu '); ch := IO.RdKey(); (* Wait for a keypress *) menuTitle := 'Menu Title'; OpenWindow (tR, menuTitle); Meta.MoveTo(10,20); Meta.DrawString('Press a key to remove menu'); ch := IO.RdKey(); (* Wait for a keypress *) CloseWindow(tR); Meta.OffsetRect(tR, 150,20) END; Meta.MoveTo(10,20); Meta.DrawString('Press Return to terminate '); ch := IO.RdKey(); (* Wait for a keypress *) GrQry.GrQuit('', 0); END Sample20.