home *** CD-ROM | disk | FTP | other *** search
- /*
- *****************************************************************************
- * testdev.c
- *****************************************************************************
- */
- #include <stdlib.h>
- #include <stdio.h>
- #include "pgl.h"
- char name[64]="HPLJET";
-
- main(int argc, char * argv[])
- {
- int port,psize,err=0;
- int i,res,nres,dpix,dpiy,nplanes,maxX,maxY,ncolors;
- int type, height, width, pox,poy;
-
- port = pgPORTRAIT;
- psize = pgHALFPAGE;
-
- /*
- * Load info on a specific printer device .
- */
- err=pgLoadDevInfo ( name );
- if( err )
- {
- printf( "Error Loading Device Driver -%s-\n",name);
- exit(1);
- }
-
- /*
- * Select Page formatting/size options.
- * This must be done prior to calling pgGetDevMaxX,pgGetDevMaxY
- */
- pgSetPageMargins ( 100,100,100,100);
- pgSetPageForm ( port );
- pgSetPageSize ( psize );
-
- /*
- * Get General Device Info
- */
- nres = pgGetDevModes ( );
- type = pgGetDevType ( );
- height= pgGetDevHeight ( );
- width = pgGetDevWidth ( );
- pox = pgGetDevOffsetX ( );
- poy = pgGetDevOffsetY ( );
- printf("\n Device Parameters-----\n");
- printf( " No. Of Res Modes: %d\n",nres);
- printf( " Dev Type: %d\n",type);
- printf( " Dev Height: %d\n",height);
- printf( " Dev Width: %d\n",width);
- printf( " Dev Offset-X: %d\n",pox);
- printf( " Dev Offset-Y: %d\n",poy);
-
- /*
- * Get Resolution Dependent Device Info
- */
- res = nres-1;
- dpix = pgGetDevResX( res );
- dpiy = pgGetDevResY( res );
- nplanes = pgGetDevPlanes( res );
- ncolors = pgGetDevColors( res );
- maxX = pgGetDevMaxX( res );
- maxY = pgGetDevMaxY( res );
-
- printf("\n Resolution Dependent Device Parameters----\n");
- printf( " RES: %d\n",res);
- printf( " DPI-X: %d\n",dpix);
- printf( " DPI-Y: %d\n",dpiy);
- printf( " No. Of Planes: %d\n",nplanes);
- printf( " No. Of Colors: %d\n",ncolors);
- printf( " MaxX: %d\n",maxX);
- printf( " MaxY: %d\n",maxY);
-
- /*
- * Open A Drawing File, set size to exact device/page specific
- * width and height dimensions. Now your working in hardware
- * coordinates.
- */
- pgInitDrw( "testdev.plt", maxX+1, maxY+1, &err);
-
- if( ncolors == 2 )
- pgSetColor(1); /* Black Pen on white paper for B&W printer */
- else
- pgSetColor(0); /* Black Pen on White paper on Color printer */
-
- pgRectangle( 0, 0, maxX, maxY, pgOUTLINE );
- pgRectangle(20, 20, maxX-20, maxY-20, pgOUTLINE );
-
- pgSetTextStyle( pgTRIPLEX );
- pgSetTextJustify( pgCENTER, pgCENTER );
- pgSetTextScaling( 5,1,5,1 );
- pgDrawTextXY(maxX/2,maxY/2,"Hello World");
-
- /*
- * Close The Drawing File.
- */
- pgEndDrw();
- }