home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / PGL.ZIP / PGLPS.ZIP / TESTDEV.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1992-01-20  |  2.9 KB  |  103 lines

  1. { TESTDEV.PAS }
  2. { PGL - Turbo Pascal Test Program }
  3.  
  4. program testdev;
  5. {$R-,S-}
  6. uses Crt, PGL;
  7.  
  8. label
  9. ExitPgm;
  10.  
  11. const
  12.   port = pgPORTRAIT;
  13.   psize= pgHALFPAGE;
  14.   name   : String[20] = 'HPLJET';
  15.   dfile  : String[20] = 'testdev.plt';
  16.  
  17. {type}
  18.  
  19. var
  20.   i, j, ierr, ncolors, res, maxX, maxY, nres : integer;
  21.   dwidth, dheight, dpix, dpiy, nplanes, dtype, pox, poy: integer;
  22.  
  23. { ****   TestDev main procedure   ****  }
  24. begin
  25.   ierr := pgLoadDevInfo ( name );
  26.   if  ierr <> 0 then
  27.     begin
  28.        Write('Err=',ierr ); 
  29.        goto ExitPgm;
  30.     end;
  31.  
  32. { Select Page formatting/size options. }
  33. { This must be done prior to calling pgGetDevMaxX,pgGetDevMaxY }
  34.  
  35.     pgSetPageMargins  ( 100,100,100,100);  
  36.     pgSetPageForm     ( port  ); 
  37.     pgSetPageSize     ( psize );  
  38.  
  39. {    Get General Device Info   }
  40.     
  41.     nres    := pgGetDevModes;
  42.     dtype   := pgGetDevType;       
  43.     dheight := pgGetDevHeight;   
  44.     dwidth  := pgGetDevWidth;    
  45.     pox     := pgGetDevOffsetX;  
  46.     poy     := pgGetDevOffsetY; 
  47.  
  48.     Writeln(  ' Device Parameters-----'); 
  49.     Writeln(  ' No. Of Res Modes: ',nres ); 
  50.     Writeln(  '         Dev Type: ',dtype );  
  51.     Writeln(  '       Dev Height: ',dheight);   
  52.     Writeln(  '        Dev Width: ',dwidth ); 
  53.     Writeln(  '     Dev Offset-X: ',pox ); 
  54.     Writeln(  '     Dev Offset-Y: ',poy );  
  55.  
  56.     Writeln ;
  57.  
  58. {  Get Resolution Dependent Device Info, on highest res supported }
  59.     
  60.     res      := nres -1 ;
  61.     dpix     := pgGetDevResX ( res ); 
  62.     dpiy     := pgGetDevResY ( res ); 
  63.     nplanes  := pgGetDevPlanes ( res );  
  64.     ncolors  := pgGetDevColors ( res );  
  65.     maxX     := pgGetDevMaxX ( res ); 
  66.     maxY     := pgGetDevMaxY ( res ); 
  67.  
  68.     Writeln( ' Resolution Dependent Device Parameters----'); 
  69.     Writeln( '           RES: ',res  ); 
  70.     Writeln( '         DPI-X: ',dpix );  
  71.     Writeln( '         DPI-Y: ',dpiy );  
  72.     Writeln( ' No. Of Planes: ',nplanes );  
  73.     Writeln( ' No. Of Colors: ',ncolors );  
  74.     Writeln( '          MaxX: ',maxX ); 
  75.     Writeln( '          MaxY: ',maxY );  
  76.  
  77.    { Open A Drawing File, set size to the exact physical device/page  }
  78.    { specific dwidth and dheight dimensions.  Now your working in hardware }
  79.    { coordinates. }
  80.     
  81.    pgInitDrw( dfile, maxX+1, maxY+1, ierr ); 
  82.    if ierr > 0 then
  83.         Writeln(' Error Opening a Drawing File =',ierr);
  84.  
  85.    if ncolors = 2 then
  86.        {  Black Pen on white paper for B&W a printer  }
  87.        pgSetColor(1)
  88.    else
  89.        {  Black Pen on White paper on Color a printer  }
  90.        pgSetColor(0); 
  91.    pgRectangle( 0,  0, maxX, maxY , pgOUTLINE );  
  92.    pgRectangle(20, 20, maxX -20, maxY -20, pgOUTLINE );  
  93.  
  94.    pgSetTextStyle( pgTRIPLEX ); 
  95.    pgSetTextJustify( pgCENTER, pgCENTER ); 
  96.    pgSetTextScaling( 5,1,5,1 ); 
  97.    pgDrawTextXY( maxX DIV 2, maxY DIV 2, 'Hello World' ); 
  98.  
  99.    { Close The Drawing File. }
  100.    pgEndDrw ;
  101. ExitPgm:
  102. end.
  103.