home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c100 / 1.ddi / OOPWLD.ZIP / SHAPES / BGI.CPP next >
Encoding:
C/C++ Source or Header  |  1990-06-08  |  1.1 KB  |  35 lines

  1. // BGI.CPP : methods for Borland Graphics Interface "wrapper"
  2. #include "bgi.hpp"
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <conio.h>
  6.  
  7. bgi_graphics::bgi_graphics(char * path, graphics_drivers gdriv) {
  8.   // initialize graphics and local variables:
  9.   gdriver = gdriv;
  10.   initgraph(&gdriver, &gmode, path);
  11.   // read result of initialization:
  12.   errorcode = graphresult();
  13.   while (errorcode != grOk) {  /* an error occurred */
  14.     // try again with local directory:
  15.     initgraph(&gdriver, &gmode, ".");
  16.     errorcode = graphresult();
  17.     if(errorcode == grOk) break;
  18.     printf("Graphics error: %s\n", grapherrormsg(errorcode));
  19.     printf("Press any key to halt:");
  20.     getch();
  21.     exit(1); /* terminate with an error code */
  22.   }
  23.   X_max = getmaxx();
  24.   Y_max = getmaxy();
  25.   maxcolor = (COLORS)getmaxcolor();
  26. }
  27.  
  28. void bgi_graphics::bottomprompt(char * prompt) {
  29.   const clipping = 1;  // clipping on
  30.   setviewport(0, Y_max - textheight(prompt), X_max, Y_max, clipping);
  31.   clearviewport();
  32.   outtextxy(0,0, prompt);
  33.   setviewport(0,0, X_max, Y_max, clipping);
  34. }
  35.