| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- (******************************************************************************)
- (* 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.
|