home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c034 / 4.ddi / SOURCE / CHRTOPT.C$ / CHRTOPT.bin
Encoding:
Text File  |  1990-01-19  |  24.7 KB  |  912 lines

  1. #include <stdio.h>
  2. #include <conio.h>
  3. #include <string.h>
  4. #include <graph.h>
  5. #include <pgchart.h>
  6. #include "chrtdemo.h"
  7.  
  8. /* Structures for system configuration and chart environment. */
  9. extern struct videoconfig vc;
  10. extern chartenv ce;
  11.  
  12. /* Variable used to track control and screen position.  */
  13. extern struct SCREENINFO si;
  14.  
  15. /* Colors of menus and prompts. */
  16. extern struct tagColor co;
  17.  
  18. /* Arrays of strings used by the Menu function. The first string is the
  19.  * menu title. The next non-null strings are the menu selections. A null
  20.  * string indicates the end of the list.
  21.  */
  22. char *pszAxes[] =
  23.     { "Axis", "X Axis", "Y Axis", "" };
  24.  
  25. char *pszAxis[] =
  26.     { "? Options", "Grid", "Axis Title", "Color",
  27.       "Range Type", "Scale", "Tic Marks", "" };
  28.  
  29. char *pszAuto[] =
  30.     { "Auto", "Auto", "Manual", "" };
  31.  
  32. char *pszBorder[] =
  33.     { "Type", "Color", "Style", "" };
  34.  
  35. char *pszChartWindow[] =
  36.     { "Chart", "Size", "Color (Background)", "Border", "" };
  37.  
  38. char *pszDataWindow[] =
  39.     { "Data", "Color (Background)", "Border", "" };
  40.  
  41. char * pszFontOpt[] =
  42.     { "Font Options", "Change Typeface", "Set Character Size", "" };
  43.  
  44. char *pszJustify[] =
  45.     { "Justify", "Left", "Center", "Right", "" };
  46.  
  47. char *pszLegendWindow[] =
  48.     { "Options", "Place", "Text Color", "Size", "Color (Background)",
  49.       "Border", "" };
  50.  
  51. char *pszPlace[] =
  52.     { "Place", "Right", "Bottom", "Overlay", "" };
  53.  
  54. char *pszScale[] =
  55.     { "Scale", "Low (Min)", "High (Max)", "Scale Factor", "Title", "" };
  56.  
  57. char *pszSize[] =
  58.     { "Size", "Top", "Left", "Bottom", "Right", "" };
  59.  
  60. char *pszTic[] =
  61.     { "Tic Type", "Interval", "Format", "Decimals", "" };
  62.  
  63. char *pszTitleOpt[] =
  64.     { "", "Text", "Color", "Justify", "" };
  65.  
  66. char *pszTitles[] =
  67.     { "Title", "Main Title", "Sub Title", "" };
  68.  
  69. char *pszTypeface[] =
  70.     { "Type Faces", "Courier", "Helv", "Tms Rmn", "Modern", "Script",
  71.            "Roman", "None", "" };
  72.  
  73. char *pszWindows[] =
  74.     { "Window", "Chart Window", "Data Window", "" };
  75.  
  76. /*  Axes - Selects X or Y axis.
  77.  *
  78.  *  Params: none
  79.  */
  80. void Axes()
  81. {
  82.     int iChoice;
  83.     static axistype *patAxis[2] = { &ce.xaxis, &ce.yaxis };
  84.  
  85.     /* Get menu choice and call appropriate axis Menu. */
  86.     PushTitle( pszAxes[0] );
  87.     Help( "Choose 'X' or 'Y' Axis", co.InputColor );
  88.     while( (iChoice = Menu( pszAxes )) != ESCAPE )
  89.     {
  90.         /* Modify axis title, depending on choice. */
  91.         pszAxis[0][0] = (--iChoice == 0) ? 'X' : 'Y';
  92.  
  93.         /* Obtain axis information for appropriate axis. */
  94.         Axis( patAxis[iChoice] );
  95.     }
  96.     PopTitle();
  97. }
  98.  
  99. /*  Axis - Selects axis options.
  100.  *
  101.  *  Params: pat - Pointer to axistype variable
  102.  */
  103. void Axis( axistype *pat )
  104. {
  105.     int iChoice;
  106.  
  107.     PushTitle( pszAxis[0] );
  108.     while( (iChoice = Menu( pszAxis )) != ESCAPE )
  109.     {
  110.  
  111.         /* Get Axis option.  */
  112.         switch( iChoice )
  113.         {
  114.             case 1:
  115.                 /* Grid or not? */
  116.                 iChoice = BlankMenu( "Grid", "Grid", "No Grid" );
  117.                 switch( iChoice )
  118.                 {
  119.  
  120.                     case 1:
  121.                         /* If yes, set grid flag and get the grid style. */
  122.                         pat->grid = TRUE;
  123.                         Help( "Enter a number in the range 0-10.",
  124.                 co.InputColor );
  125.                         pat->gridstyle =
  126.                             InputInt( "Grid Style? ", pat->gridstyle, 0, 10 );
  127.                         break;
  128.  
  129.                     case 2:
  130.                         /* If no, clear grid flag.  */
  131.                         pat->grid = FALSE;
  132.                 }
  133.                 PopTitle();
  134.                 break;
  135.  
  136.             case 2:
  137.                 /* Select axis title options. */
  138.                 pszTitleOpt[0] = "Axis Title";
  139.                 TitleOpt( &pat->axistitle );
  140.                 break;
  141.  
  142.             case 3:
  143.                 /* Select color. */
  144.                 Help( "Enter a number in the range 0-15.", co.InputColor );
  145.                 pat->axiscolor =
  146.                     InputInt( "Axis Color? ", pat->axiscolor, 0, 15 );
  147.                 break;
  148.  
  149.             case 4:
  150.                 /* Get the axis range.  */
  151.                 AxisRange( pat );
  152.                 break;
  153.  
  154.             case 5:
  155.                 /* Get the axis scale.  */
  156.                 AxisScale( pat );
  157.                 break;
  158.  
  159.             case 6:
  160.                 /* Get axis tic mark options.  */
  161.                 AxisTics( pat );
  162.                 break;
  163.  
  164.         }
  165.     }
  166.     PopTitle();
  167. }
  168.  
  169. /*  AxisRange - Selects range for an axis.
  170.  *
  171.  *  Params: pat - pointer to axistype variable
  172.  */
  173. void AxisRange( axistype *pat )
  174. {
  175.     int iChoice;
  176.  
  177.     iChoice = BlankMenu( "Range Type", "Normal", "Log" );
  178.     switch( iChoice )
  179.     {
  180.         case 1:
  181.             /* Set range type to linear.  */
  182.             pat->rangetype = _PG_LINEARAXIS;
  183.             break;
  184.  
  185.         case 2:
  186.             /* Set range type to log, then query for log base.  */
  187.             pat->rangetype = _PG_LOGAXIS;
  188.             Help( "Enter a value greater than or equal 2.", co.InputColor );
  189.             pat->logbase = (float)InputInt( "Log base? ",
  190.                                             (int)pat->logbase, 2, 0 );
  191.             break;
  192.     }
  193.     PopTitle();
  194. }
  195.  
  196. /*  AxisScale - Selects scale options for an axis.
  197.  *
  198.  *  Params: pat - pointer to axistype variable
  199.  */
  200. void AxisScale( axistype *pat )
  201. {
  202.     int iChoice;
  203.  
  204.     PushTitle( pszAuto[0] );
  205.     iChoice = Menu( pszAuto );
  206.     switch( iChoice )
  207.     {
  208.  
  209.         case 1:
  210.             /* Set AutoScale flag.  */
  211.             pat->autoscale = TRUE;
  212.             break;
  213.  
  214.         case 2:
  215.  
  216.             /* Clear AutoScale flag and get scale options.  */
  217.             pat->autoscale = FALSE;
  218.             PushTitle( pszScale[0] );
  219.             while( (iChoice = Menu( pszScale )) != ESCAPE )
  220.             {
  221.  
  222.                 switch( iChoice )
  223.                 {
  224.  
  225.                     case 1:  
  226.                         /* Query for scale minimum.  */
  227.                         Help( "Enter the range minimum value.", co.InputColor );
  228.                         pat->scalemin =
  229.                             (float)InputInt( "Minimum? ",
  230.                                              (int)pat->scalemin, 1, 0 );
  231.                         break;
  232.  
  233.                     case 2:  
  234.                         /* Query for scale maximum.  */
  235.                         Help( "Enter the range maximum value.", co.InputColor );
  236.                         pat->scalemin =
  237.                             (float)InputInt( "Minimum? ",
  238.                                              (int)pat->scalemin, 1, 0 );
  239.                         break;
  240.  
  241.                     case 3:
  242.                         /* Query for scale factor.  */
  243.                         Help( "Enter scale factor (must be 1 or greater).",
  244.                                  co.InputColor );
  245.                         pat->scalefactor =
  246.                             (float)InputInt( "Scale Factor? ",
  247.                                              (int)pat->scalefactor, 1, 0 );
  248.                         break;
  249.  
  250.                     case 4:  
  251.                         /* Modify scale title, then use menu to get
  252.                          * title options.
  253.                          */
  254.                         pszTitleOpt[0] = "Scale Title";
  255.                         TitleOpt( &pat->scaletitle );
  256.  
  257.                 }
  258.             }
  259.             PopTitle();
  260.     }
  261.     PopTitle();
  262. }
  263.  
  264. /*  AxisTics - Selects tic options for an axis.
  265.  *
  266.  *  Params: pat - pointer to axistype variable
  267.  */
  268. void AxisTics( axistype *pat )
  269. {
  270.     int iChoice;
  271.  
  272.     PushTitle( pszTic[0] );
  273.     while( (iChoice = Menu( pszTic )) != ESCAPE )
  274.     {
  275.         switch( iChoice )
  276.         {
  277.  
  278.             case 1:
  279.                 /* Query for tic interval.  */
  280.                 Help( "Enter distance in data units.", co.InputColor );
  281.                 pat->ticinterval =
  282.                     InputFloat( "Distance between tic marks? ",
  283.                                pat->ticinterval );
  284.                 pat->autoscale = FALSE;
  285.                 break;
  286.  
  287.             case 2:
  288.                 /* Query for tic format.  */
  289.                 iChoice = BlankMenu( "Tic Format", "Normal", "Log" );
  290.                 if( iChoice != ESCAPE )
  291.                     pat->ticformat = iChoice;
  292.                 break;
  293.  
  294.             case 3:
  295.                 /* Query for number of decimal places per tic.  */
  296.                 pat->ticdecimals =
  297.                     InputInt( "Enter decimal places (0 to 9). ",
  298.                                pat->ticdecimals, 0, 9 );
  299.                 pat->autoscale = FALSE;
  300.                 break;
  301.         }
  302.  
  303.     }
  304.     PopTitle();
  305. }
  306.  
  307. /*  Border - Specifies border information for a window.
  308.  *
  309.  *  Params: pwt - Pointer to windowtype variable
  310.  */
  311. void Border( windowtype *pwt )
  312. {
  313.     int iChoice;
  314.  
  315.     /* Ask whether a border is wanted.  */
  316.     iChoice = BlankMenu( "Border", "Border", "No Border" );
  317.     switch( iChoice )
  318.     {
  319.  
  320.         case 1:
  321.  
  322.             /* If border, set Border flag and query for border options.  */
  323.             pwt->border= TRUE;
  324.             PushTitle( pszBorder[0] );
  325.             while( (iChoice = Menu( pszBorder )) != ESCAPE )
  326.             {
  327.                 switch( iChoice )
  328.                 {
  329.                     case 1:
  330.                         /* Query for border color.  */
  331.                         Help( "Enter a color in the range 0-15.",
  332.                             co.InputColor );
  333.                         pwt->bordercolor =
  334.                             InputInt( "Border color? ",
  335.                                        pwt->bordercolor, 0, 15 );
  336.                         break;
  337.  
  338.                     case 2:
  339.                         /* Query for border style.  */
  340.                         Help( "Enter a style in the range 0-10.", co.InputColor );
  341.                         pwt->borderstyle =
  342.                             InputInt( "Border style? ",
  343.                                        pwt->borderstyle, 0, 10 );
  344.                 }
  345.             }
  346.             PopTitle();
  347.             break;
  348.  
  349.         case 2:
  350.             /* If no border, clear Border flag.  */
  351.             pwt->border= FALSE;
  352.     }
  353.     PopTitle();
  354. }
  355.  
  356. /*  ChangeTypeface - Allow the user to specify a new type face.
  357.  *
  358.  *  Params: iFaceIndex - index of last typeface
  359.  *
  360.  *  Return: index of new typeface
  361.  */
  362.  
  363. int ChangeTypeface( int iFaceIndex )
  364. {
  365.     int iChoice;
  366.  
  367.     /* Get menu choice and call appropriate axis Menu. */
  368.     PushTitle( pszFontOpt[0] );
  369.     Help( "Choose one of the type faces listed.", co.InputColor );
  370.  
  371.     if( (iChoice = Menu( pszTypeface ) - 1) != ESCAPE )
  372.     {
  373.         /* If the user wants the system font, unregister the other fonts. */
  374.         if( iChoice == NOFONT )
  375.             _unregisterfonts();
  376.  
  377.         /* If the user wants any font but the system font, make sure the
  378.          *   fonts are registered.
  379.          */
  380.         else
  381.         {
  382.             /* If last face was NOFONT, register fonts. */
  383.             if( iFaceIndex == NOFONT )
  384.             {
  385.                 /* Assumes font files are in current directory.
  386.                  * Could be enhanced to handle any directory.
  387.                  */
  388.                 if( _registerfonts( "*.FON" ) < 0 )
  389.                     ErrorMsg( "Font files must be in current directory" );
  390.                 else
  391.                     iFaceIndex = iChoice;
  392.             }
  393.             else
  394.                 iFaceIndex = iChoice;
  395.         }
  396.     }
  397.  
  398.     PopTitle();
  399.     return iFaceIndex;
  400. }
  401.  
  402. /*  ChooseFont - Chooses a font from the font library.
  403.  *
  404.  *  Params: WhichFont - A member of the set [COURIER, HELV, TMS_RMN,
  405.  *                        MODERN, SCRIPT, ROMAN, NOFONT]
  406.  *          Height    - The desired height of the text (in pixels)
  407.  */
  408.  
  409. void ChooseFont( int WhichFont, int Height )
  410. {
  411.     static char *FontIds[] =
  412.     {
  413.         "courier", "helv", "tms rmn", "modern", "script", "roman"
  414.     };
  415.     char SetCommand[30];
  416.  
  417.     /* Construct the command to send to _setfont. */
  418.     sprintf( SetCommand, "t'%s'h%dw0b", FontIds[WhichFont], Height );
  419.  
  420.     if( _setfont( SetCommand ) < 0 )
  421.     {
  422.         _outtext( "Could not set. Try different font or size" );
  423.         getch();
  424.     }
  425. }
  426.  
  427. /*  ChartWindow - Gets chart window information.
  428.  *
  429.  *  Params: None
  430.  */
  431. void ChartWindow()
  432. {
  433.     int iChoice;
  434.  
  435.     PushTitle( pszChartWindow[0] );
  436.     while( (iChoice = Menu( pszChartWindow )) != ESCAPE )
  437.     {
  438.  
  439.         /* Get window options.  */
  440.         switch( iChoice )
  441.         {
  442.  
  443.             case 1:
  444.                 /* Get window size.  */
  445.                 WindowSize( &ce.chartwindow );
  446.                 break;
  447.  
  448.             case 2:
  449.                 /* Query for background color.  */
  450.                 Help( "Enter a number in the range 0-15", co.InputColor );
  451.                 ce.chartwindow.background =
  452.                     InputInt( "Background Color? ", ce.chartwindow.background,
  453.                               0, 15 );
  454.                 break;
  455.  
  456.             case 3:
  457.  
  458.                 /* Get border options.  */
  459.                 Border( &ce.chartwindow );
  460.  
  461.         }
  462.     }
  463.     PopTitle();
  464. }
  465.  
  466. /*  DataWindow - Geta data window information.
  467.  *
  468.  *  Params: None
  469.  */
  470. void DataWindow()
  471. {
  472.     int iChoice;
  473.  
  474.     PushTitle( pszDataWindow[0] );
  475.     while( (iChoice = Menu( pszDataWindow )) != ESCAPE )
  476.     {
  477.  
  478.         /* Get data window menu options.  */
  479.         switch( iChoice )
  480.         {
  481.  
  482.             case 1: 
  483.                 /* Query for background color.  */
  484.                 Help( "Enter a number in the range 0-15", co.InputColor );
  485.                 ce.datawindow.background =
  486.                     InputInt( "Background Color? ",
  487.                                ce.datawindow.background,
  488.                                0, 15 );
  489.                 break;
  490.  
  491.             case 2:
  492.                 /* Get border options.  */
  493.                 Border( &ce.datawindow );
  494.                 break;
  495.  
  496.         }
  497.     }
  498.     PopTitle();
  499. }
  500.  
  501. /*  FontOptions - Allows the user to modify the font used for display.
  502.  *
  503.  *  Params: None
  504.  */
  505.  
  506. void FontOptions()
  507. {
  508.     int iChoice;
  509.     static int iFaceIndex = NOFONT;
  510.     static int iTypeSize = 8;
  511.  
  512.     /* Get menu choice and call appropriate axis Menu. */
  513.     PushTitle( pszFontOpt[0] );
  514.  
  515.     while( (iChoice = Menu( pszFontOpt )) != ESCAPE )
  516.     {
  517.         switch( iChoice )
  518.         {
  519.             /* Change Typeface. */
  520.             case 1:
  521.                 iFaceIndex = ChangeTypeface( iFaceIndex );
  522.                 ChooseFont( iFaceIndex, iTypeSize );
  523.                 break;
  524.  
  525.             /* Change Type Size. */
  526.             case 2:
  527.  
  528.                 if( iFaceIndex == NOFONT )
  529.                 {
  530.                     ErrorMsg( "Select a font first" );
  531.                     break;
  532.                 }
  533.  
  534.                 iTypeSize = InputInt( "Enter a type size. ", iTypeSize,
  535.                                        8, 128 );
  536.  
  537.                 ChooseFont( iFaceIndex, iTypeSize );
  538.                 break;
  539.  
  540.             default:
  541.                 break;
  542.         }
  543.     }
  544.     PopTitle();
  545. }
  546.  
  547. /*  Justify - Gets title justification option.
  548.  *
  549.  *  Params: Pointer to titletype variable
  550.  */
  551. void Justify( titletype *ptt )
  552. {
  553.     int iChoice;
  554.  
  555.     PushTitle( pszJustify[0] );
  556.     iChoice = Menu( pszJustify );
  557.     switch( iChoice )
  558.     {
  559.  
  560.         /* Set justification.  */
  561.         case 1:
  562.         case 2:
  563.         case 3:
  564.             ptt->justify = iChoice;
  565.     }
  566.     PopTitle();
  567. }
  568.  
  569. /*  Legend - Asks whether a legend is desired, and if so, gets
  570.  *  legend options.
  571.  *
  572.  *  Params: None
  573.  */
  574. void Legend()
  575. {
  576.     int iChoice;
  577.  
  578.     /* Is legend desired?  */
  579.     iChoice = BlankMenu( "Legend", "Legend", "No Legend" );
  580.     switch( iChoice )
  581.     {
  582.         case 1:
  583.             /* If legend, set legend flag and get options.  */
  584.             ce.legend.legend = TRUE;
  585.             PushTitle( pszLegendWindow[0] );
  586.             do
  587.             {
  588.                 iChoice = Menu( pszLegendWindow );
  589.                 switch( iChoice )
  590.                 {
  591.  
  592.                     case 1:
  593.                         /* Get legend place.  */
  594.                         LegendPlace();
  595.                         break;
  596.  
  597.                     case 2:
  598.                         /* Query for legend color.  */
  599.                         Help( "Enter a number in the range 0-15.", co.InputColor );
  600.                         ce.legend.textcolor =
  601.                             InputInt( "Text color? ",
  602.                                        ce.legend.textcolor,
  603.                                        0, 15 );
  604.                         break;
  605.  
  606.                     case 3:
  607.                         /* Get auto or manual sizing.  */
  608.                         PushTitle( "Auto Legend" );
  609.                         iChoice = Menu( pszAuto );
  610.  
  611.                         /* Set or clear the autosize flag. If manual
  612.                          * sizing was selected, get legend size.
  613.                          */
  614.                         switch( iChoice )
  615.                         {
  616.                             case 1:
  617.                                 ce.legend.autosize = TRUE;
  618.                                 break;
  619.  
  620.                             case 2:
  621.                                 ce.legend.autosize = FALSE;
  622.                                 WindowSize( &ce.legend.legendwindow );
  623.                         }
  624.                         PopTitle();
  625.                         break;
  626.  
  627.                     case 4:
  628.                         /* Query for background color.  */
  629.                         Help( "Type a number in the range 0-15.", co.InputColor );
  630.                         ce.legend.legendwindow.background =
  631.                             InputInt( "Background color? ",
  632.                                        ce.legend.legendwindow.background,
  633.                                        0, 15 );
  634.                         break;
  635.  
  636.                     case 5:
  637.                         /* Get border options for legend window.  */
  638.                         Border( &ce.legend.legendwindow );
  639.                 }
  640.  
  641.             } while( iChoice != ESCAPE );
  642.             PopTitle();
  643.             break;
  644.  
  645.         case 2:
  646.             /* If no legend wanted, clear flag.  */
  647.             ce.legend.legend = FALSE;
  648.  
  649.     }
  650.     PopTitle();
  651. }
  652.  
  653. /*  LegendPlace - Gets legend placement option.
  654.  *
  655.  *  Params: None
  656.  */
  657. void LegendPlace()
  658. {
  659.     int iChoice;
  660.  
  661.     /* Get legend placement.  */
  662.     PushTitle( pszPlace[0] );
  663.     iChoice = Menu( pszPlace );
  664.     switch( iChoice )
  665.     {
  666.  
  667.         case 1:
  668.             ce.legend.place = _PG_RIGHT;
  669.             break;
  670.  
  671.         case 2:
  672.             ce.legend.place = _PG_BOTTOM;
  673.             break;
  674.  
  675.         case 3:
  676.             ce.legend.place = _PG_OVERLAY;
  677.     }
  678.     PopTitle();
  679. }
  680.  
  681. /*  ScreenMode - Gets a new screen mode.
  682.  *
  683.  *  Params: None
  684.  */
  685. void ScreenMode()
  686. {
  687.     int iMode, i;
  688.     char szTmp[80], szHlp[80];
  689.     static int iLegal[5][11] =
  690.     {
  691.         { 3, 4, 5, 6 },
  692.         { 4, 4, 5, 6, 64 },
  693.         { 4, 4, 5, 6, 19 },
  694.         { 7, 4, 5, 6, 13, 14, 15, 16 },
  695.         { 10, 4, 5, 6, 13, 14, 15, 16, 17, 18, 19 }
  696.     };
  697.     int iAdaptor;
  698.  
  699.     PushTitle( "Screen Mode" );
  700.  
  701.     /* Show appropriate help line for adaptor.  */
  702.     switch( vc.adapter )
  703.     {
  704.         case _HGC:
  705.             PopTitle();
  706.             return;
  707.         case _CGA:
  708.             iAdaptor = 0;
  709.             break;
  710.         case _OCGA:
  711.             iAdaptor = 1;
  712.             break;
  713.         case _MCGA:
  714.             iAdaptor = 2;
  715.             break;
  716.         case _EGA:
  717.         case _OEGA:
  718.             if( vc.adapter == _MONO )
  719.             {
  720.                 PopTitle();
  721.                 return;
  722.             }
  723.             else
  724.                 iAdaptor = 3;
  725.             break;
  726.         case _VGA:
  727.         case _OVGA:
  728.             iAdaptor = 4;
  729.             break;
  730.     }
  731.  
  732.     /* Form the help line (which gives the choices legal for
  733.      * the adaptor sensed in the user's machine).
  734.      */
  735.     for( iMode = 0, szHlp[0] = '\0'; iMode <= iLegal[iAdaptor][0]; ++iMode )
  736.     {
  737.         if( iMode == 0 )
  738.             strcpy( szTmp, "Enter " );
  739.         else if( iMode < iLegal[iAdaptor][0] )
  740.             sprintf( szTmp, "%d, ", iLegal[iAdaptor][iMode] );
  741.         else
  742.             sprintf( szTmp, "or %d", iLegal[iAdaptor][iMode] );
  743.         strcat( szHlp, szTmp );
  744.     }
  745.  
  746.     WrtForm( 18 );
  747.     Help( szHlp, co.InputColor );
  748.  
  749.     /* Query for screen mode. */
  750.     for( ;; )
  751.     {
  752.         iMode = InputInt( "Screen Mode? ", si.mode, 1, 64 );
  753.         for( i = 1; i <= iLegal[iAdaptor][0]; ++i ) /* Test legal values    */
  754.             if( iMode == iLegal[iAdaptor][i] )      /* If a match is found  */
  755.                 break;                              /* Terminate for loop   */
  756.         if( iMode == iLegal[iAdaptor][i] )          /* If it's a match,     */
  757.             break;                                  /* terminate do loop,   */
  758.         else                                        /* otherwise BEEP, and  */
  759.             putchar( BEEP );                        /* solicit correct data */
  760.     }
  761.  
  762.     PopTitle();
  763.     if( SetGraphMode( iMode ) )
  764.         _setvideomode( _DEFAULTMODE );
  765.     else
  766.         ShowError( _PG_BADSCREENMODE );
  767.  
  768.     /* Force rescaling of the chart by resetting the window
  769.      * rectangles for the chart and data windows to zero size.
  770.      */
  771.     ce.chartwindow.x1 = ce.chartwindow.x2 = ce.chartwindow.y1 =
  772.         ce.chartwindow.y2 = 0;
  773.     ce.datawindow = ce.chartwindow;
  774. }
  775.  
  776. /*  TitleOpt - Gets title options.
  777.  *
  778.  *  Params: ptt - Pointer to titletype variable
  779.  */
  780. void TitleOpt( titletype *ptt )
  781. {
  782.     int iChoice;
  783.  
  784.     PushTitle( pszTitleOpt[0] );
  785.     do
  786.     {
  787.         iChoice = Menu( pszTitleOpt );
  788.         switch( iChoice )
  789.         {
  790.  
  791.             case 1: 
  792.                 /* Query for title text.  */
  793.                 Help( "70 characters maximum length.", co.InputColor );
  794.                 InputStr( "Enter Text: ", ptt->title );
  795.                 break;
  796.  
  797.             case 2: 
  798.                 /* Query for title color color.  */
  799.                 Help( "Enter a number in the range 0-15.", co.InputColor );
  800.                 ptt->titlecolor =
  801.                     InputInt( "Title Color? ", ptt->titlecolor, 0, 15 );
  802.                 break;
  803.  
  804.             case 3:
  805.                 /* Get justify option.  */
  806.                 Justify( ptt );
  807.         }
  808.         ClrHelp();
  809.  
  810.     } while( iChoice != ESCAPE );
  811.     PopTitle();
  812. }
  813.  
  814. /*  Titles - Manages Main and Sub title menus.
  815.  *
  816.  *  Params: None
  817.  */
  818. void Titles()
  819. {
  820.     int iChoice;
  821.  
  822.     PushTitle( pszTitles[0] );
  823.     do
  824.     {
  825.         iChoice = Menu( pszTitles );
  826.         switch( iChoice )
  827.         {
  828.  
  829.             case 1:
  830.                 /* Fix menu title and get options for main title.  */
  831.                 pszTitleOpt[0] = "MainTitle";
  832.                 TitleOpt( &ce.maintitle );
  833.                 break;
  834.  
  835.             case 2:
  836.                 /* Fix menu title and get options for subtitle.  */
  837.                 pszTitleOpt[0] = "Sub Title";
  838.                 TitleOpt( &ce.subtitle );
  839.         }
  840.     } while( iChoice != ESCAPE );
  841.     PopTitle();
  842. }
  843.  
  844. /*  Windows - Selects chart or data window, and gets options for either.
  845.  *
  846.  *  Params: None
  847.  */
  848. void Windows()
  849. {
  850.     int iChoice;
  851.  
  852.     PushTitle( pszWindows[0] );
  853.     do
  854.     {
  855.  
  856.         /* Select window and get options for it.  */
  857.         iChoice = Menu( pszWindows );
  858.         switch( iChoice )
  859.         {
  860.  
  861.             case 1:
  862.                 ChartWindow();
  863.                 break;
  864.  
  865.             case 2:
  866.                 DataWindow();
  867.  
  868.         }
  869.     } while( iChoice != ESCAPE );
  870.     PopTitle();
  871. }
  872.  
  873. /*  WindowSize - Gets coordinates for window location and size.
  874.  *
  875.  *  Params: pwt - pointer to windowtype variable
  876.  */
  877. void WindowSize( windowtype *pwt )
  878. {
  879.     int iChoice;
  880.  
  881.     /* Get window size settings.  */
  882.     PushTitle( pszSize[0] );
  883.     do
  884.     {
  885.         /* Query for top, bottom, left, or right of window.  */
  886.         iChoice = Menu( pszSize );
  887.         switch( iChoice )
  888.         {
  889.  
  890.             case 1:
  891.                 Help( "Enter window top in pixels.", co.InputColor );
  892.                 pwt->y1 = InputInt( "Top? ", pwt->y1, 0, si.yMax );
  893.                 break;
  894.  
  895.             case 2:
  896.                 Help( "Enter window Left in pixels.", co.InputColor );
  897.                 pwt->x1 = InputInt( "Left? ", pwt->x1, 0, si.xMax );
  898.                 break;
  899.  
  900.             case 3:
  901.                 Help( "Enter window bottom in pixels.", co.InputColor );
  902.                 pwt->y2 = InputInt( "Bottom? ", pwt->y2, 0, si.yMax );
  903.                 break;
  904.  
  905.             case 4:
  906.                 Help( "Enter window right in pixels.", co.InputColor );
  907.                 pwt->x2 = InputInt( "Right? ", pwt->x2, 0, si.xMax );
  908.         }
  909.     } while( iChoice != ESCAPE );
  910.     PopTitle();
  911. }
  912.