home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / PGL.ZIP / PGLCS.ZIP / TESTDEV.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-02  |  3.0 KB  |  100 lines

  1. /*
  2. *****************************************************************************
  3. *  testdev.c
  4. *****************************************************************************
  5. */
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include "pgl.h"
  9. char  name[64]="HPLJET";
  10.  
  11. main(int argc, char * argv[])
  12. {
  13.        int   port,psize,err=0;
  14.          int   i,res,nres,dpix,dpiy,nplanes,maxX,maxY,ncolors;
  15.          int   type, height, width, pox,poy;
  16.  
  17.        port  = pgPORTRAIT;
  18.        psize = pgHALFPAGE;
  19.  
  20.          /*
  21.          *   Load info on a specific printer device .
  22.          */
  23.        err=pgLoadDevInfo  ( name );
  24.          if( err )
  25.             {
  26.             printf( "Error Loading Device Driver -%s-\n",name);
  27.             exit(1);
  28.             }
  29.  
  30.          /*
  31.          *  Select Page formatting/size options.
  32.          *  This must be done prior to calling pgGetDevMaxX,pgGetDevMaxY
  33.          */
  34.          pgSetPageMargins  ( 100,100,100,100);
  35.          pgSetPageForm     ( port  );
  36.        pgSetPageSize     ( psize );
  37.  
  38.          /*
  39.          *    Get General Device Info
  40.          */
  41.          nres  = pgGetDevModes     ( );
  42.        type  = pgGetDevType      ( );  
  43.        height= pgGetDevHeight    ( );
  44.        width = pgGetDevWidth     ( );
  45.        pox   = pgGetDevOffsetX   ( );
  46.        poy   = pgGetDevOffsetY   ( );
  47.        printf("\n Device Parameters-----\n");
  48.        printf(  " No. Of Res Modes: %d\n",nres);
  49.        printf(  "         Dev Type: %d\n",type);
  50.        printf(  "       Dev Height: %d\n",height);
  51.        printf(  "        Dev Width: %d\n",width);
  52.        printf(  "     Dev Offset-X: %d\n",pox);
  53.        printf(  "     Dev Offset-Y: %d\n",poy);
  54.  
  55.         /*
  56.          *   Get Resolution Dependent Device Info
  57.          */
  58.          res     = nres-1;
  59.        dpix    = pgGetDevResX( res );
  60.        dpiy    = pgGetDevResY( res );
  61.        nplanes = pgGetDevPlanes( res );
  62.          ncolors = pgGetDevColors( res );
  63.          maxX    = pgGetDevMaxX( res );
  64.          maxY    = pgGetDevMaxY( res );
  65.  
  66.        printf("\n Resolution Dependent Device Parameters----\n");
  67.        printf(  "           RES: %d\n",res);
  68.        printf(  "         DPI-X: %d\n",dpix);
  69.        printf(  "         DPI-Y: %d\n",dpiy);
  70.        printf(  " No. Of Planes: %d\n",nplanes);
  71.        printf(  " No. Of Colors: %d\n",ncolors);
  72.        printf(  "          MaxX: %d\n",maxX);
  73.        printf(  "          MaxY: %d\n",maxY);
  74.  
  75.          /*
  76.          *      Open A Drawing File, set size to exact device/page specific
  77.          *   width and height dimensions.  Now your working in hardware
  78.        *   coordinates.
  79.          */
  80.          pgInitDrw( "testdev.plt", maxX+1, maxY+1, &err);
  81.  
  82.          if( ncolors == 2 )
  83.             pgSetColor(1);  /* Black Pen on white paper for B&W printer */
  84.         else
  85.             pgSetColor(0);  /* Black Pen on White paper on Color printer */
  86.  
  87.        pgRectangle( 0,  0, maxX, maxY, pgOUTLINE );
  88.        pgRectangle(20, 20, maxX-20, maxY-20, pgOUTLINE );
  89.  
  90.        pgSetTextStyle( pgTRIPLEX );
  91.        pgSetTextJustify( pgCENTER, pgCENTER );
  92.        pgSetTextScaling( 5,1,5,1 );
  93.        pgDrawTextXY(maxX/2,maxY/2,"Hello World");
  94.  
  95.          /*
  96.         * Close The Drawing File.
  97.           */
  98.        pgEndDrw();
  99. }
  100.