home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / EDUCATIO / STAGES12.ZIP / PCWINS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-14  |  7.8 KB  |  393 lines

  1. #include "header.h"
  2. #include "file.h"
  3.  
  4. /************************************************************************/
  5. /**    PC screen functions                           **/
  6. /************************************************************************/
  7. #if PC
  8. /* NB:  this code will only work on IBM PCs and compatibles.
  9.    "gotoxy, "window", "wherex" and "wherey"
  10.    are not standard C, they are features of Turbo-C only. */
  11.  
  12. /********************************/
  13. /*     function: wholewin    */
  14. /********************************/
  15. /* returns whole screen to one window */
  16. wholewin ()
  17. {
  18.   /* whole screen is 80 cols, 25 lines */
  19.   window(1, 1, 80, 25);
  20.   return(0);
  21. } /* wholewin */
  22.  
  23. /********************************/
  24. /*     function: makedisplay    */
  25. /********************************/
  26. /* makes border around screen, sets up initial windows */
  27. makedisplay ()
  28. {
  29.   /* clear screen */
  30.   wholewin();
  31.   clrscr();
  32.   /* make borders */
  33.   botline();
  34.   leftside();
  35.   rightside();
  36.   topline("");
  37.  
  38.   /* set up windows */
  39.   outputwin();
  40.   sep1win();
  41.   inputwin();
  42.   sep2win();
  43.   msgwin();
  44.   col80win();    /* erases chars in 80th col */
  45.   funcline();
  46.   return(0);
  47. } /* makedisplay */
  48.  
  49. /********************************/
  50. /*     function: outputwin    */
  51. /********************************/
  52. /* makes output window */
  53. outputwin ()
  54. {
  55.   window(2, OUTPUTTOP, 79, OUTPUTBOT);
  56.   return(0);
  57. } /* outputwin */
  58.  
  59. /********************************/
  60. /*     function: sep1win    */
  61. /********************************/
  62. /* makes first separation window (line of =s)
  63.    also prints cycle length anunciator */
  64. sep1win ()
  65. {
  66.   int i;
  67.  
  68.   window(2, SEP1LN, 79, SEP1LN);
  69.   for ( i=1; i<79; i++ ) {
  70.     gotoxy(i, 1);
  71.     putchar(HBAR);
  72.   }
  73.   gotoxy(52, 1);
  74.   cprintf(" Current Cycle=%.2lf days ", CycleTime);
  75.   normvideo();
  76.   return(0);
  77. } /* sep1win */
  78.  
  79. /********************************/
  80. /*     function: msgwin        */
  81. /********************************/
  82. /* makes messages window */
  83. msgwin ()
  84. {
  85.   window(2, MSGTOP, 79, MSGBOT);
  86.   return(0);
  87. } /* msgwin */
  88.  
  89. /********************************/
  90. /*     function: sep2win    */
  91. /********************************/
  92. /* makes second separation window (line of =s) */
  93. sep2win ()
  94. {
  95.   int i;
  96.  
  97.   window(2, SEP2LN, 79, SEP2LN);
  98.   for ( i=1; i<79; i++ ) {
  99.     gotoxy(i, 1);
  100.     putchar(HBAR);
  101.   }
  102.   normvideo();
  103.   return(0);
  104. } /* sep2win */
  105.  
  106. /********************************/
  107. /*     function: inputwin    */
  108. /********************************/
  109. /* makes input window: bottom 5 lines */
  110. inputwin ()
  111. {
  112.   window(2, INPUTTOP, 79, INPUTBOT);
  113.   return(0);
  114. } /* inputwin */
  115.  
  116. /********************************/
  117. /*     function: topline    */
  118. /********************************/
  119. /* makes border top line, puts "str" on it
  120.    (a menu name) */
  121. topline (str)
  122.   char *str;    /* menu label */
  123. {
  124.   int i, len;
  125.  
  126.   window(2, 1, 79, 1);
  127.   highvideo();
  128.   for ( i=1; i<79; i++ ) {
  129.     gotoxy(i, 1);
  130.     putchar(HBAR);
  131.   }
  132.   highvideo();
  133.   if (strlen(str)) {
  134.     gotoxy(3, 1);
  135.     cprintf("%s", str);
  136.   }
  137.   len = strlen(" ANIMAL: ") + strlen(Animal) + 1;
  138.   gotoxy(76-len, 1);
  139.   cprintf(" ANIMAL: %s ", Animal);
  140.   normvideo();
  141.   return(0);
  142. } /* topline */
  143.  
  144. /********************************/
  145. /*     function: botline    */
  146. /********************************/
  147. /* makes border bottom line, with annunciators:
  148.    left: file status   right: version */
  149. botline ()
  150. {
  151.   int i;
  152.  
  153.   window(2, 24, 79, 24);
  154.   for ( i=1; i<79; i++ ) {
  155.     gotoxy(i, 1);
  156.     putchar(HBAR);
  157.   }
  158.   highvideo();
  159.   gotoxy(4, 1);
  160.   if (FILEq && FILECOPY) {
  161.     cprintf("FILE: On");
  162.     normvideo();
  163.     putchar(HBAR);
  164.   } else {
  165.     cprintf("FILE: Off");
  166.   }
  167.   gotoxy(72, 1);
  168.   cprintf("%s", VERSION);
  169. /* took out this annunciator: F8 is just print screen,
  170.    a user would never leave the printer on for a whole session!
  171.   gotoxy(67, 1);
  172.   if (HARDCOPY) {
  173.     cprintf("PRINT: On");
  174.     normvideo();
  175.     putchar(HBAR);
  176.   } else {
  177.     cprintf("PRINT: Off");
  178.   }
  179. */
  180.   normvideo();
  181.   return(0);
  182. } /* botline */
  183.  
  184. /********************************/
  185. /*     function: leftside    */
  186. /********************************/
  187. /* makes border left side */
  188. leftside ()
  189. {
  190.   int i;
  191.  
  192.   window(1, 1, 1, 24);
  193.   for ( i=2; i<24; i++ ) {
  194.     gotoxy(1, i);
  195.     putchar(VBAR);
  196.   }
  197.   gotoxy(1, 1);
  198.   putchar(LTOP);
  199.   gotoxy(1, 16);
  200.   putchar(LTEE);
  201.   gotoxy(1, 20);
  202.   putchar(LTEE);
  203.   gotoxy(1, 24);
  204.   putchar(LBOT);
  205.   normvideo();
  206.   return(0);
  207. } /* leftside */
  208.  
  209. /********************************/
  210. /*     function: rightside    */
  211. /********************************/
  212. /* makes border right side */
  213. rightside ()
  214. {
  215.   int i;
  216.  
  217.   window(79, 1, 79, 24);
  218.   for ( i=2; i<24; i++ ) {
  219.     gotoxy(1, i);
  220.     putchar(VBAR);
  221.   }
  222.   gotoxy(1, 1);
  223.   putchar(RTOP);
  224.   gotoxy(1, 16);
  225.   putchar(RTEE);
  226.   gotoxy(1, 20);
  227.   putchar(RTEE);
  228.   gotoxy(1, 24);
  229.   putchar(RBOT);
  230.   normvideo();
  231.   return(0);
  232. } /* rightside */
  233.  
  234. /********************************/
  235. /*     function: col80win    */
  236. /********************************/
  237. /* the 80th col that isn't used */
  238. col80win ()
  239. {
  240.   int i;
  241.  
  242.   window(80, 1, 80, 24);
  243.   for ( i=0; i<24; i++ ){
  244.     gotoxy(1, i);
  245.     cprintf(" ");
  246.   }
  247.   return(0);
  248. } /* col80win */
  249.     
  250. /********************************/
  251. /*     function: funcline    */
  252. /********************************/
  253. /* displays active F-keys and ESC */
  254. funcline ()
  255. {
  256.   window(1, 25, 79, 25);
  257.  
  258.   highvideo();
  259.   gotoxy(1, 1);
  260.   cprintf("F1:");
  261.   normvideo();
  262.   cprintf("Gen");
  263.  
  264.   highvideo();
  265.   gotoxy(8, 1);
  266.   cprintf("F2:");
  267.   normvideo();
  268.   cprintf("Help");
  269.  
  270.   highvideo();
  271.   gotoxy(16, 1);
  272.   cprintf("F3:");
  273.   normvideo();
  274.   cprintf("Animl");
  275.  
  276.   highvideo();
  277.   gotoxy(25, 1);
  278.   cprintf("F4:");
  279.   normvideo();
  280.   cprintf("Cycl");
  281.  
  282.   highvideo();
  283.   gotoxy(33, 1);
  284.   cprintf("F5:");
  285.   normvideo();
  286.   cprintf("Cell");
  287.  
  288.   highvideo();
  289.   gotoxy(41, 1);
  290.   cprintf("F6:");
  291.   normvideo();
  292.   cprintf("Day");
  293.  
  294.   highvideo();
  295.   gotoxy(48, 1);
  296.   cprintf("F7:");
  297.   normvideo();
  298.   cprintf("File");
  299.  
  300.   highvideo();
  301.   gotoxy(56, 1);
  302.   cprintf("F8:");
  303.   normvideo();
  304.   cprintf("PSc");
  305.  
  306.   highvideo();
  307.   gotoxy(63, 1);
  308.   cprintf("F9:");
  309.   normvideo();
  310.   cprintf("Rfsh");
  311.  
  312.   highvideo();
  313.   gotoxy(71, 1);
  314.   cprintf("F10:");
  315.   normvideo();
  316.   cprintf("Exit");
  317.   return(0);
  318. } /* funcline */
  319.  
  320. /********************************/
  321. /*     function: makeactivewin    */
  322. /********************************/
  323. /* makes a given window active
  324.    1 = output window, 2 = input window, 3 = message window */
  325. makeactivewin (win)
  326.   int win;
  327. {
  328.   switch (win) {
  329.   case 1:
  330.     outputwin();
  331.     break;
  332.   case 2:
  333.     inputwin();
  334.     break;
  335.   case 3:
  336.     msgwin();
  337.     break;
  338.   default: /* shouldn't! */
  339.     msgwin();
  340.     clrscr();
  341.     rightside();
  342.     outputwin();
  343.     gotoxy(1, 5);
  344.     cprintf("%s<makeactivewin>: Internal error, win=%d", tab2, win);
  345.     gotoxy(1, 7);
  346.     cprintf("%s                 Sorry, aborting.", tab2);
  347.     printexit(18);
  348.   } /* switch */
  349.   return(0);
  350. } /* makeactivewin */
  351.  
  352. /********************************/
  353. /*     function: clrscr1    */
  354. /********************************/
  355. /* clears a window, then redraws the right border */
  356. clrscr1 (win)
  357.   int win;        /* code for window we came from */
  358. {
  359.   switch (win) {
  360.   case 1:
  361.     outputwin();
  362.     break;
  363.   case 2:
  364.     inputwin();
  365.     break;
  366.   case 3:
  367.     msgwin();
  368.     break;
  369.   default:    /* shouldn't! */
  370.     break;
  371.   } /* switch */
  372.   clrscr();
  373.   rightside();
  374.   makeactivewin(win);
  375.   gotoxy(1, 1);
  376.   return(0);
  377. } /* clrscr1 */
  378.  
  379. /********************************/
  380. /*     function: clreol1    */
  381. /********************************/
  382. /* clears a line to eol, then redraws the right border */
  383. clreol1 (win)
  384.   int win;        /* code for window we came from */
  385. {
  386.   clreol();
  387.   rightside();
  388.   makeactivewin(win);
  389.   return(0);
  390. } /* clreol1 */
  391.  
  392. #endif
  393.