home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / bcpp / file10 / file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  12.0 KB  |  441 lines

  1. /**********************************************************************\
  2. *                                                                      *
  3. *  file.c -- routines for performing the functions on the FILE menu    *
  4. *                                                                      *
  5. \**********************************************************************/
  6.  
  7. #include "defs.h"
  8.  
  9. /**********************************************************************\
  10. *                                                                      *
  11. *  about_demo -- information about this demo program                   *
  12. *                                                                      *
  13. \**********************************************************************/
  14.  
  15. int about_demo()
  16. {
  17.    static char *string[] = {
  18.    "About This Demo",
  19.    "This demonstration program was written by",
  20.    "Diana Gruber, using Fastgraph from Ted Gruber",
  21.    "Software.  You may distribute this program",
  22.    "freely, but please do not distribute any",
  23.    "modified versions.  This program is distributed",
  24.    "with source code.  You may use this source",
  25.    "code in your Fastgraph applications.",
  26.    "",
  27.    "      Copyright (c) 1991,1992 Diana Gruber."
  28.    };
  29.  
  30.    /* clear the screen and display the info window */
  31.  
  32.    fg_mousevis(OFF);
  33.    fg_restore(0,xlimit,menu_bottom,ylimit);
  34.    info_window(120,520,60,string,10);
  35.  
  36.    /* wait for a keystroke or mouse button */
  37.  
  38.    fg_mousevis(ON);
  39.    wait_for_keystroke();
  40.  
  41.    /* restore the screen and return to the menu */
  42.  
  43.    fg_mousevis(OFF);
  44.    fg_restore(0,xlimit,menu_bottom,ylimit);
  45.  
  46.    fg_mousevis(ON);
  47.    redraw = TRUE;
  48.  
  49.    return(OK);
  50. }
  51.  
  52. /**********************************************************************\
  53. *                                                                      *
  54. *  about_docs -- information about this Fastgraph Documentation        *
  55. *                                                                      *
  56. \**********************************************************************/
  57.  
  58. int about_docs()
  59. {
  60.    static char *string[] = {
  61.    "Fastgraph Documentation",
  62.    "The Fastgraph manuals are exceptionally good.  The",
  63.    "270-page Fastgraph User's Guide provides information",
  64.    "about graphics concepts, suggestions about how to",
  65.    "use Fastgraph, and over 130 example programs.  The",
  66.    "Fastgraph Reference Manual provides an alphabetical",
  67.    "summary of each Fastgraph routine.  Fastgraph's",
  68.    "manuals enable even a novice programmer to use the",
  69.    "product effectively right from the start."
  70.    };
  71.  
  72.    /* clear the screen and display the info window */
  73.  
  74.    fg_mousevis(OFF);
  75.    fg_restore(0,xlimit,menu_bottom,ylimit);
  76.    info_window(100,540,60,string,9);
  77.  
  78.    /* wait for a keystroke or mouse button */
  79.  
  80.    fg_mousevis(ON);
  81.    wait_for_keystroke();
  82.  
  83.    /* clear the screen and return to the menu */
  84.  
  85.    fg_mousevis(OFF);
  86.    fg_restore(0,xlimit,menu_bottom,ylimit);
  87.  
  88.    fg_mousevis(ON);
  89.    redraw = TRUE;
  90.  
  91.    return(OK);
  92. }
  93.  
  94. /**********************************************************************\
  95. *                                                                      *
  96. *  about_fg -- display about Fastgraph information                     *
  97. *                                                                      *
  98. \**********************************************************************/
  99.  
  100. int about_fg()
  101. {
  102.    static char *string[] = {
  103.    "About Fastgraph",
  104.    "Fastgraph, the Programmer's Graphics Library by",
  105.    "Ted Gruber Software, is a collection of over 170",
  106.    "highly optimized routines callable from C, C++,",
  107.    "Turbo Pascal, QuickBASIC, and FORTRAN.",
  108.    "Fastgraph gives a programmer complete control",
  109.    "over the DOS-based text and graphics video",
  110.    "environment."
  111.    };
  112.  
  113.    /* clear the screen and display the info window */
  114.  
  115.    fg_mousevis(OFF);
  116.    fg_restore(0,xlimit,menu_bottom,ylimit);
  117.    info_window(120,520,60,string,8);
  118.  
  119.    /* wait for a keystroke or mouse button */
  120.  
  121.    fg_mousevis(ON);
  122.    wait_for_keystroke();
  123.  
  124.    /* clear the screen and return to the menu */
  125.  
  126.    fg_mousevis(OFF);
  127.    fg_restore(0,xlimit,menu_bottom,ylimit);
  128.  
  129.    fg_mousevis(ON);
  130.    redraw = TRUE;
  131.  
  132.    return(OK);
  133. }
  134.  
  135. /**********************************************************************\
  136. *                                                                      *
  137. *  about_order -- information about ordering by phone                  *
  138. *                                                                      *
  139. \**********************************************************************/
  140.  
  141. int about_order()
  142. {
  143.    static char *string[] = {
  144.    "Order by Phone/FAX",
  145.    "Fastgraph version 2.10 is available for $169 as",
  146.    "of June 1992.  To order Fastgraph, call our",
  147.    "orders/info line at (702) 735-1980, or FAX your",
  148.    "order to (702) 735-4603.",
  149.    "",
  150.    "You can also use these numbers for more",
  151.    "information or to request the Fastgraph/Light",
  152.    "evaluation kit.",
  153.    "",
  154.    "We accept Visa, MasterCard, and COD orders.",
  155.    "Purchase orders are welcome from most",
  156.    "companies, schools, and government agencies."
  157.    };
  158.  
  159.    /* clear the screen and display the info window */
  160.  
  161.    fg_mousevis(OFF);
  162.    fg_restore(0,xlimit,menu_bottom,ylimit);
  163.    info_window(120,520,60,string,13);
  164.  
  165.    /* wait for a keystroke or mouse button */
  166.  
  167.    fg_mousevis(ON);
  168.    wait_for_keystroke();
  169.  
  170.    /* clear the screen and return to the menu */
  171.  
  172.    fg_mousevis(OFF);
  173.    fg_restore(0,xlimit,menu_bottom,ylimit);
  174.  
  175.    fg_mousevis(ON);
  176.    redraw = TRUE;
  177.  
  178.    return(OK);
  179. }
  180.  
  181. /**********************************************************************\
  182. *                                                                      *
  183. *  about_site -- information about site licenses                       *
  184. *                                                                      *
  185. \**********************************************************************/
  186.  
  187. int about_site()
  188. {
  189.    static char *string[] = {
  190.    "Site Licenses",
  191.    "Site Licenses for Fastgraph are available.",
  192.    "Please call, FAX, or write for details."
  193.    };
  194.  
  195.    /* clear the screen and display the info window */
  196.  
  197.    fg_mousevis(OFF);
  198.    fg_restore(0,xlimit,menu_bottom,ylimit);
  199.    info_window(152,488,60,string,3);
  200.  
  201.    /* wait for a keystroke or mouse button */
  202.  
  203.    fg_mousevis(ON);
  204.    wait_for_keystroke();
  205.  
  206.    /* clear the screen and return to the menu */
  207.  
  208.    fg_mousevis(OFF);
  209.    fg_restore(0,xlimit,menu_bottom,ylimit);
  210.  
  211.    fg_mousevis(ON);
  212.    redraw = TRUE;
  213.  
  214.    return(OK);
  215. }
  216.  
  217. /**********************************************************************\
  218. *                                                                      *
  219. *  about_tech -- information about technical support                   *
  220. *                                                                      *
  221. \**********************************************************************/
  222.  
  223. int about_tech()
  224. {
  225.    static char *string[] = {
  226.    "Technical Support",
  227.    "Call Dust Devil BBS (702) 796-7134 for updates,",
  228.    "examples, source code, and echo mail support.",
  229.    "Check your local boards for the U'NI-net / US",
  230.    "Fastgraph support conference.  For voice support",
  231.    "call Ted Gruber Software at (702) 735-1980.",
  232.    };
  233.  
  234.    /* clear the screen and display the info window */
  235.  
  236.    fg_mousevis(OFF);
  237.    fg_restore(0,xlimit,menu_bottom,ylimit);
  238.    info_window(120,520,60,string,6);
  239.  
  240.    /* wait for a keystroke or mouse button */
  241.  
  242.    fg_mousevis(ON);
  243.    wait_for_keystroke();
  244.  
  245.    fg_mousevis(OFF);
  246.    fg_restore(0,xlimit,menu_bottom,ylimit);
  247.  
  248.    fg_mousevis(ON);
  249.    redraw = TRUE;
  250.  
  251.    return(OK);
  252. }
  253.  
  254. /**********************************************************************\
  255. *                                                                      *
  256. *  exit_program -- exit to DOS if desired                              *
  257. *                                                                      *
  258. \**********************************************************************/
  259.  
  260. exit_program()
  261. {
  262.    int xmin, xmax, ymin, ymax;
  263.  
  264.    fg_mousevis(OFF);
  265.    fg_restore(0,xlimit,menu_bottom,ylimit);
  266.  
  267.    /* define the window extremes */
  268.  
  269.    xmin = 210;
  270.    xmax = 430;
  271.    ymin = scale(150);
  272.    ymax = scale(200);
  273.    if (mouse) ymax += 2 * ptsize;
  274.  
  275.    fg_mousevis(OFF);
  276.  
  277.    /* display the pop-up window */
  278.  
  279.    draw_window(xmin,xmax,ymin,ymax,"Exit");
  280.    fg_setcolor(0);
  281.    center_pstring("Exit to DOS?",xmin,xmax,ymin+row_offset(3));
  282.  
  283.    /* get the response and exit if desired */
  284.  
  285.    if (get_answer(xmin,xmax,ymin+row_offset(4))) terminate();
  286.  
  287.    /* otherwise, just clear the screen and return */
  288.  
  289.    fg_restore(0,xlimit,menu_bottom,ylimit);
  290.    redraw = TRUE;
  291.  
  292.    return(OK);
  293. }
  294.  
  295. /**********************************************************************\
  296. *                                                                      *
  297. *  print_form -- print the order form                                  *
  298. *                                                                      *
  299. \**********************************************************************/
  300.  
  301. int print_form()
  302. {
  303.    FILE *stream;
  304.    unsigned char key,aux;
  305.    char fstring[80];
  306.  
  307.    static char *string[] = {
  308.    "Print order form",
  309.    "Press ESC to stop printing"
  310.    };
  311.  
  312.    static char *string1[] = {
  313.    "Printer Error",
  314.    "Is the printer online?"
  315.    };
  316.  
  317.    static char *string2[] = {
  318.    "File Error",
  319.    "Missing file: ORDER.FRM"
  320.    };
  321.  
  322.    /* check that the printer is online */
  323.  
  324.    if (!printer_ready())
  325.    {
  326.       fg_mousevis(OFF);
  327.       fg_restore(0,xlimit,menu_bottom,ylimit);
  328.       info_window(120,520,60,string1,2);
  329.  
  330.       fg_mousevis(ON);
  331.       wait_for_keystroke();
  332.  
  333.       fg_mousevis(OFF);
  334.       fg_restore(0,xlimit,menu_bottom,ylimit);
  335.  
  336.       redraw = TRUE;
  337.       return(OK);
  338.    }
  339.  
  340.    /* check that the file can be opened */
  341.  
  342.    stream = fopen("order.frm","rt");
  343.    if (stream == NULL)
  344.    {
  345.       fg_mousevis(OFF);
  346.       fg_restore(0,xlimit,menu_bottom,ylimit);
  347.       info_window(120,520,60,string2,2);
  348.  
  349.       fg_mousevis(ON);
  350.       wait_for_keystroke();
  351.  
  352.       fg_mousevis(OFF);
  353.       fg_restore(0,xlimit,menu_bottom,ylimit);
  354.  
  355.       redraw = TRUE;
  356.       return(ERR);
  357.    }
  358.  
  359.    /* clear the screen and display the info window */
  360.  
  361.    fg_mousevis(OFF);
  362.    fg_restore(0,xlimit,menu_bottom,ylimit);
  363.    info_window(120,520,60,string,2);
  364.  
  365.    fg_mousevis(ON);
  366.  
  367.    /* print the file, one line at a time */
  368.  
  369.    while (TRUE)
  370.    {
  371.       if (fgets(fstring,80,stream) == NULL)
  372.          break;
  373.       fg_intkey(&key,&aux);
  374.       if (key == ESC)
  375.          break;
  376.       if (fprintf(stdprn,"%s\r",fstring) == 0)
  377.          break;
  378.    }
  379.  
  380.    /* print form feed */
  381.  
  382.    fprintf(stdprn,"\f");
  383.  
  384.    /* close the file and flush the printer buffer */
  385.  
  386.    fclose(stream);
  387.    fflush(stdprn);
  388.  
  389.    /* clear the screen and return to the menu */
  390.  
  391.    fg_mousevis(OFF);
  392.    fg_restore(0,xlimit,menu_bottom,ylimit);
  393.  
  394.    fg_mousevis(ON);
  395.    redraw = TRUE;
  396.  
  397.    return(OK);
  398. }
  399.  
  400. /**********************************************************************\
  401. *                                                                      *
  402. *  shell -- create a DOS command shell                                 *
  403. *                                                                      *
  404. \**********************************************************************/
  405.  
  406. shell()
  407. {
  408.    register int page;
  409.  
  410.    /* return to the original video mode */
  411.  
  412.    for (page = 1; page < PAGES; page++)
  413.       fg_freepage(page);
  414.    fg_mousepos(&xmouse,&ymouse,&buttons);
  415.    fg_setmode(old_mode);
  416.    fg_reset();
  417.  
  418.    /* spawn the DOS command shell */
  419.  
  420.    printf("\nEnter the command EXIT to return to the Fastgraph demo.");
  421.    spawnlp(P_WAIT,"command.com",NULL);
  422.  
  423.    /* upon return from DOS, restore the video context */
  424.  
  425.    fg_setmode(mode);
  426.    for (page = 1; page < PAGES; page++)
  427.       fg_allocate(page);
  428.    fg_sethpage(1);
  429.    visual = 0;
  430.    hidden = 1;
  431.  
  432.    /* redraw the screen */
  433.  
  434.    redraw = TRUE;
  435.    draw_screen();
  436.    fg_restore(0,xlimit,0,ylimit);
  437.    init_mouse();
  438.  
  439.    return(OK);
  440. }
  441.