home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / winsrc.zip / DIALOG2.C < prev    next >
C/C++ Source or Header  |  1990-11-06  |  40KB  |  1,175 lines

  1. /*
  2.  
  3.     various dialog-box code - more in DIALOG.C
  4.  
  5. */
  6.  
  7. #include "windows.h"
  8. #include "winfract.h"
  9. #include "fractint.h"
  10. #include <math.h>
  11. #include <stdio.h>
  12.  
  13. extern HWND hwnd;                               /* handle to main window */
  14. extern char szHelpFileName[];                   /* Help file name*/
  15.  
  16. extern BOOL zoomflag;                /* TRUE is a zoom-box selected */
  17.  
  18. extern char *win_choices[];
  19. extern int win_numchoices, win_choicemade;
  20. int CurrentFractal;
  21.  
  22. extern HANDLE hDibInfo;        /* handle to the Device-independent bitmap */
  23. extern LPBITMAPINFO pDibInfo;        /* pointer to the DIB info */
  24.  
  25. extern int time_to_restart;                               /* time to restart?  */
  26. extern int time_to_reinit;                /* time to reinit? */
  27. extern int time_to_cycle;                               /* time to cycle? */
  28.  
  29. extern int xdots, ydots, colors, maxiter;
  30. extern int ytop, ybottom, xleft, xright;
  31. extern double xxmin, xxmax, yymin, yymax;
  32. extern int fractype;
  33. extern int calc_status;
  34. extern double param[4];
  35.  
  36. extern int inside, outside, biomorph, decomp, debugflag;
  37. extern int usr_stdcalcmode, usr_floatflag;
  38. extern    int    invert;     /* non-zero if inversion active */
  39. extern    double    inversion[3];    /* radius, xcenter, ycenter */
  40.  
  41. int tempfractype;
  42. int tempcolors;
  43. char tempstdcalcmode, tempfloatflag;
  44.  
  45. int numparams,numtrig;
  46. static char *trg[] = {"First Function","Second Function",
  47.               "Third Function","Fourth Function"};
  48. static int paramt[] = {ID_FRACPARTX1, ID_FRACPARTX2,
  49.                        ID_FRACPARTX3, ID_FRACPARTX4 };
  50. static int paramv[] = {ID_FRACPARAM1, ID_FRACPARAM2,
  51.                        ID_FRACPARAM3, ID_FRACPARAM4, };
  52.  
  53. extern int win_release;
  54. extern char win_comment[];
  55.  
  56. extern char DialogTitle[];
  57.  
  58. /****************************************************************************
  59.  
  60.     FUNCTION: About(HWND, unsigned, WORD, LONG)
  61.  
  62.     PURPOSE:  Processes messages for "About" dialog box
  63.  
  64.     MESSAGES:
  65.  
  66.         WM_INITDIALOG - initialize dialog box
  67.         WM_COMMAND    - Input received
  68.  
  69. ****************************************************************************/
  70.  
  71. BOOL FAR PASCAL About(hDlg, message, wParam, lParam)
  72. HWND hDlg;
  73. unsigned message;
  74. WORD wParam;
  75. LONG lParam;
  76. {
  77.  
  78. float temp;
  79. char tempname[40];
  80.  
  81.     switch (message) {
  82.  
  83.          case WM_KEYDOWN:
  84.              switch (wParam) {
  85.                  case VK_F1:
  86.                  /* F1, shifted F1 bring up the Help Index */
  87.                      WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  88.                      break;
  89.                  }
  90.  
  91.         case WM_INITDIALOG:
  92.             temp = win_release / 100.0;
  93.             sprintf(tempname,"Fractint for Windows - Vers %5.2f", temp);
  94.             SetDlgItemText(hDlg, ID_VERSION,tempname);
  95.             SetDlgItemText(hDlg, ID_COMMENT,win_comment);
  96.             return (TRUE);
  97.  
  98.         case WM_COMMAND:
  99.         if (wParam == IDOK
  100.                 || wParam == IDCANCEL) {
  101.                 EndDialog(hDlg, TRUE);
  102.                 return (TRUE);
  103.             }
  104.             break;
  105.     }
  106.     return (FALSE);
  107. }
  108.  
  109. /****************************************************************************
  110.  
  111.     FUNCTION: Status(HWND, unsigned, WORD, LONG)
  112.  
  113.     PURPOSE:  Processes messages for "Status" dialog box
  114.  
  115.     MESSAGES:
  116.  
  117.         WM_INITDIALOG - initialize dialog box
  118.         WM_COMMAND    - Input received
  119.  
  120. ****************************************************************************/
  121.  
  122. BOOL FAR PASCAL Status(hDlg, message, wParam, lParam)
  123. HWND hDlg;
  124. unsigned message;
  125. WORD wParam;
  126. LONG lParam;
  127. {
  128. char tempstring[100];
  129. int i, j;
  130.  
  131.     switch (message) {
  132.  
  133.         case WM_KEYDOWN:
  134.             switch (wParam) {
  135.                 case VK_F1:
  136.                 /* F1, shifted F1 bring up the Help Index */
  137.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  138.                     break;
  139.                 }
  140.  
  141.         case WM_INITDIALOG:
  142.             sprintf(tempstring,"fractal type: ");
  143.             strcat(tempstring, fractalspecific[fractype].name);
  144.             if (calc_status == 1)
  145.                 strcat(tempstring,"    (still being calculated)");
  146.             else
  147.                 strcat(tempstring,"    (interrupted/completed)");
  148.             /* ##### */
  149.             SetDlgItemText(hDlg, IDS_LINE1,tempstring);
  150.             if(fractalspecific[fractype].param[0][0] == 0)
  151.                 tempstring[0] = 0;
  152.             else
  153.                 sprintf(tempstring,"%-30.30s   %14.10f",
  154.                     fractalspecific[fractype].param[0], param[0]);
  155.             SetDlgItemText(hDlg, IDS_LINE2,tempstring);
  156.             if(fractalspecific[fractype].param[1][0] == 0)
  157.                 tempstring[0] = 0;
  158.             else
  159.                 sprintf(tempstring,"%-30.30s   %14.10f",
  160.                     fractalspecific[fractype].param[1], param[1]);
  161.             SetDlgItemText(hDlg, IDS_LINE3,tempstring);
  162.             if(fractalspecific[fractype].param[2][0] == 0)
  163.                 tempstring[0] = 0;
  164.             else
  165.                 sprintf(tempstring,"%-30.30s   %14.10f",
  166.                     fractalspecific[fractype].param[2], param[2]);
  167.             SetDlgItemText(hDlg, IDS_LINE4,tempstring);
  168.             if(fractalspecific[fractype].param[3][0] == 0)
  169.                 tempstring[0] = 0;
  170.             else
  171.                 sprintf(tempstring,"%-30.30s   %14.10f",
  172.                     fractalspecific[fractype].param[3], param[3]);
  173.             SetDlgItemText(hDlg, IDS_LINE5,tempstring);
  174.             sprintf(tempstring,"Xmin:        %25.16f", xxmin);
  175.             SetDlgItemText(hDlg, IDS_LINE6,tempstring);
  176.             sprintf(tempstring,"Xmax:        %25.16f", xxmax);
  177.             SetDlgItemText(hDlg, IDS_LINE7,tempstring);
  178.             sprintf(tempstring,"Ymin:        %25.16f", yymin);
  179.             SetDlgItemText(hDlg, IDS_LINE8,tempstring);
  180.             sprintf(tempstring,"Ymax:        %25.16f", yymax);
  181.             SetDlgItemText(hDlg, IDS_LINE9,tempstring);
  182.             return (TRUE);
  183.  
  184.         case WM_COMMAND:
  185.         if (wParam == IDOK
  186.                 || wParam == IDCANCEL) {
  187.                 EndDialog(hDlg, TRUE);
  188.                 return (TRUE);
  189.             }
  190.             break;
  191.     }
  192.     return (FALSE);
  193. }
  194.  
  195. /****************************************************************************
  196.  
  197.     FUNCTION: SelectFractal(HWND, unsigned, WORD, LONG)
  198.  
  199.     PURPOSE: Initializes window data and registers window class
  200.  
  201. ****************************************************************************/
  202.  
  203. BOOL FAR PASCAL SelectFractal(hDlg, message, wParam, lParam)
  204. HWND hDlg;
  205. unsigned message;
  206. WORD wParam;
  207. LONG lParam;
  208. {
  209.  
  210.     int i;
  211.     int index;
  212.  
  213.     switch (message) {
  214.  
  215.         case WM_KEYDOWN:
  216.             switch (wParam) {
  217.                 case VK_F1:
  218.                 /* F1, shifted F1 bring up the Help Index */
  219.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  220.                     break;
  221.                 }
  222.  
  223.         case WM_INITDIALOG:
  224.             SetDlgItemText(hDlg, ID_LISTTITLE, DialogTitle);
  225.             for (i = 0; i < win_numchoices; i++) 
  226.                 SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_ADDSTRING,
  227.                     NULL, (LONG) (LPSTR) win_choices[i]);
  228.             SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_SETCURSEL,
  229.                 win_choicemade, 0L);
  230.             return (TRUE);
  231.             break;
  232.         
  233.         case WM_COMMAND:
  234.             switch (wParam) {
  235.                 case IDOK:
  236. okay:           
  237.                     index=SendDlgItemMessage(hDlg, IDM_FRACTAL,
  238.                         LB_GETCURSEL, 0, 0L);
  239.                     if (index == LB_ERR) {
  240.                         MessageBox(hDlg, "No Choice selected",
  241.                             "Select From a List", MB_OK | MB_ICONEXCLAMATION);
  242.                         break;
  243.                         }
  244.                     win_choicemade = index;
  245.                     EndDialog(hDlg, 1);
  246.                     break;
  247.                   
  248.                 case IDCANCEL:
  249.                     win_choicemade = -1;
  250.                     EndDialog(hDlg, 0);
  251.                     break;
  252.                     
  253.                 case IDM_FRACTAL:
  254.                     switch (HIWORD(lParam)) {
  255.                         case LBN_SELCHANGE:
  256.                             index = SendDlgItemMessage(hDlg, IDM_FRACTAL,
  257.                                 LB_GETCURSEL, 0, 0L);
  258.                             if (index == LB_ERR)
  259.                                 break;
  260.                             break;
  261.                          
  262.                        case LBN_DBLCLK:
  263.                             goto okay;
  264.                             break;
  265.                     }
  266.                 break;
  267.                 }
  268.         
  269.         }
  270.     return (FALSE);
  271. }
  272.  
  273. /****************************************************************************
  274.  
  275.     FUNCTION: SelectFracParams(HWND, unsigned, WORD, LONG)
  276.  
  277.     PURPOSE: Initializes window data and registers window class
  278.  
  279. ****************************************************************************/
  280.  
  281. BOOL FAR PASCAL SelectFracParams(hDlg, message, wParam, lParam)
  282. HWND hDlg;
  283. unsigned message;
  284. WORD wParam;
  285. LONG lParam;
  286. {
  287.  
  288.     int i;
  289.     int index;
  290.     char temp[30];
  291.  
  292.     switch (message) {
  293.  
  294.         case WM_KEYDOWN:
  295.             switch (wParam) {
  296.                 case VK_F1:
  297.                 /* F1, shifted F1 bring up the Help Index */
  298.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  299.                     break;
  300.                 }
  301.  
  302.         case WM_INITDIALOG:
  303.                 tempfractype = CurrentFractal;
  304.                 for (numparams = 0; numparams < 4; numparams++)
  305.                     if (fractalspecific[tempfractype].param[numparams][0] == 0)
  306.                         break;
  307.                 numtrig = (fractalspecific[tempfractype].flags >> 6) & 7;
  308.                 for (i = 0; i < 4; i++) {
  309.                     sprintf(temp,"%f",fractalspecific[tempfractype].paramvalue[i]);
  310.                     SetDlgItemText(hDlg, paramv[i], temp);
  311.                     SetDlgItemText(hDlg, paramt[i],"(n/a)");
  312.                     if (i < numparams)
  313.                        SetDlgItemText(hDlg, paramt[i],
  314.                            fractalspecific[tempfractype].param[i]);
  315.                     }
  316.                for(i=0; i<numtrig; i++) {
  317.                     SetDlgItemText(hDlg, paramt[i+numparams], trg[i]);
  318.                     SetDlgItemText(hDlg, paramv[i+numparams],
  319.                         trigfn[trigndx[i]].name);
  320.                     }
  321.             sprintf(temp,"%f",fractalspecific[tempfractype].xmin);
  322.         SetDlgItemText(hDlg, ID_FRACXMIN,   temp);
  323.             sprintf(temp,"%f",fractalspecific[tempfractype].xmax);
  324.         SetDlgItemText(hDlg, ID_FRACXMAX,   temp);
  325.             sprintf(temp,"%f",fractalspecific[tempfractype].ymin);
  326.         SetDlgItemText(hDlg, ID_FRACYMIN,   temp);
  327.             sprintf(temp,"%f",fractalspecific[tempfractype].ymax);
  328.         SetDlgItemText(hDlg, ID_FRACYMAX,   temp);
  329.         SetDlgItemText(hDlg, ID_FRACNAME,   fractalspecific[tempfractype].name);
  330.             return (TRUE);
  331.             break;
  332.         
  333.         case WM_COMMAND:
  334.             switch (wParam) {
  335.                 case IDOK:
  336.                     for (i = 0; i < 4; i++) {
  337.                         GetDlgItemText(hDlg, paramv[i], temp, 10);
  338.                         param[i] = atof(temp);
  339.                         }
  340.                     for (i = 0; i < numtrig; i++) {
  341.                         GetDlgItemText(hDlg, paramv[i+numparams], temp, 10);
  342.                         temp[4] = 0;
  343.                         if (temp[3] == 32) temp[3] = 0;
  344.                         set_trig_array(i, temp);
  345.                         }
  346.             GetDlgItemText(hDlg, ID_FRACXMIN  , temp, 10);
  347.             xxmin = atof(temp);
  348.             GetDlgItemText(hDlg, ID_FRACXMAX  , temp, 10);
  349.             xxmax = atof(temp);
  350.             GetDlgItemText(hDlg, ID_FRACYMIN  , temp, 10);
  351.             yymin = atof(temp);
  352.             GetDlgItemText(hDlg, ID_FRACYMAX  , temp, 10);
  353.             yymax = atof(temp);
  354.                     invert = 0;
  355.                     inversion[0] = inversion[1] = inversion[2] = 0;
  356.                     fractype = CurrentFractal;
  357.                     EndDialog(hDlg, 1);
  358.                     break;
  359.                   
  360.                 case IDCANCEL:
  361.                     EndDialog(hDlg, 0);
  362.                     break;
  363.  
  364.                 }
  365.         
  366.         }
  367.     return (FALSE);
  368. }
  369.  
  370. /****************************************************************************
  371.  
  372.     FUNCTION: SelectImage(HWND, unsigned, WORD, LONG)
  373.  
  374.     PURPOSE: Initializes window data and registers window class
  375.  
  376. ****************************************************************************/
  377.  
  378. BOOL FAR PASCAL SelectImage(hDlg, message, wParam, lParam)
  379. HWND hDlg;
  380. unsigned message;
  381. WORD wParam;
  382. LONG lParam;
  383. {
  384.  
  385.     int i;
  386.     int index;
  387.     char temp[15];
  388.  
  389.     switch (message) {
  390.  
  391.         case WM_KEYDOWN:
  392.             switch (wParam) {
  393.                 case VK_F1:
  394.                 /* F1, shifted F1 bring up the Help Index */
  395.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  396.                     break;
  397.                 }
  398.  
  399.         case WM_INITDIALOG:
  400.             tempcolors = colors;
  401.             if (tempcolors == 2)
  402.                 CheckDlgButton(hDlg, ID_ICOLORS1, 1);
  403.             else if (tempcolors == 16)
  404.                 CheckDlgButton(hDlg, ID_ICOLORS2, 1);
  405.             else
  406.                 CheckDlgButton(hDlg, ID_ICOLORS3, 1);
  407.             sprintf(temp,"%d",xdots);
  408.         SetDlgItemText(hDlg, ID_ISIZEX, temp);
  409.             sprintf(temp,"%d",ydots);
  410.         SetDlgItemText(hDlg, ID_ISIZEY, temp);
  411.         i = ID_ISIZE7;
  412.         if (xdots ==  200 && ydots == 150) i = ID_ISIZE1;
  413.         if (xdots ==  320 && ydots == 200) i = ID_ISIZE2;
  414.         if (xdots ==  640 && ydots == 350) i = ID_ISIZE3;
  415.         if (xdots ==  640 && ydots == 480) i = ID_ISIZE4;
  416.         if (xdots ==  800 && ydots == 600) i = ID_ISIZE5;
  417.         if (xdots == 1024 && ydots == 768) i = ID_ISIZE6;
  418.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, i);
  419.             return (TRUE);
  420.             break;
  421.         
  422.         case WM_COMMAND:
  423.             switch (wParam) {
  424.                 case IDOK:
  425.                     /* retrieve and validate the results */
  426.             GetDlgItemText(hDlg, ID_ISIZEX, temp, 10);
  427.             xdots = atoi(temp);
  428.             if (xdots < 50) xdots = 50;
  429.             if (xdots > 2048) xdots = 2048;
  430.             GetDlgItemText(hDlg, ID_ISIZEY, temp, 10);
  431.             ydots = atoi(temp);
  432.             if (ydots < 50) ydots = 50;
  433.             if (ydots > 2048) ydots = 2048;
  434.                     colors = tempcolors;
  435.                     /* allocate and lock a pixel array for the bitmap */
  436.                     /* problem, here - can't just RETURN!!! */
  437.                     tryagain:
  438.                     if (!clear_screen(0)) {
  439.                         MessageBox(hDlg, "Not Enough Memory for that sized Image",
  440.                             NULL, MB_OK | MB_ICONHAND);
  441.                         xdots = ydots = 100;
  442.                         goto tryagain;
  443.                         };
  444.                     ytop    = 0;        /* reset the zoom-box */
  445.                     ybottom = ydots-1;
  446.                     xleft   = 0;
  447.                     xright  = xdots-1;
  448.                     set_win_offset();
  449.                     zoomflag = TRUE;
  450.                     time_to_restart = 1;
  451.                     EndDialog(hDlg, 1);
  452.                     break;
  453.                   
  454.                 case IDCANCEL:
  455.                     EndDialog(hDlg, 0);
  456.                     break;
  457.  
  458.                 case ID_ISIZE1:
  459.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE1);
  460.             SetDlgItemInt(hDlg, ID_ISIZEX, 200, TRUE);
  461.             SetDlgItemInt(hDlg, ID_ISIZEY, 150, TRUE);
  462.                     break;
  463.  
  464.                 case ID_ISIZE2:
  465.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE2);
  466.             SetDlgItemInt(hDlg, ID_ISIZEX, 320, TRUE);
  467.             SetDlgItemInt(hDlg, ID_ISIZEY, 200, TRUE);
  468.                     break;
  469.  
  470.                 case ID_ISIZE3:
  471.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE3);
  472.             SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE);
  473.             SetDlgItemInt(hDlg, ID_ISIZEY, 350, TRUE);
  474.                     break;
  475.  
  476.                 case ID_ISIZE4:
  477.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE4);
  478.             SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE);
  479.             SetDlgItemInt(hDlg, ID_ISIZEY, 480, TRUE);
  480.                     break;
  481.  
  482.                 case ID_ISIZE5:
  483.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE5);
  484.             SetDlgItemInt(hDlg, ID_ISIZEX, 800, TRUE);
  485.             SetDlgItemInt(hDlg, ID_ISIZEY, 600, TRUE);
  486.                     break;
  487.  
  488.                 case ID_ISIZE6:
  489.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE6);
  490.             SetDlgItemInt(hDlg, ID_ISIZEX, 1024, TRUE);
  491.             SetDlgItemInt(hDlg, ID_ISIZEY, 768, TRUE);
  492.                     break;
  493.  
  494.                 case ID_ISIZE7:
  495.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE7);
  496.                     break;
  497.  
  498.                 case ID_ICOLORS1:
  499.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS1);
  500.                     tempcolors = 2;
  501.                     break;
  502.  
  503.                 case ID_ICOLORS2:
  504.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS2);
  505.                     tempcolors = 16;
  506.                     break;
  507.  
  508.                 case ID_ICOLORS3:
  509.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS3);
  510.                     tempcolors = 256;
  511.                     break;
  512.  
  513.                 }
  514.         
  515.         }
  516.     return (FALSE);
  517. }
  518.  
  519. /****************************************************************************
  520.  
  521.     FUNCTION: SelectDoodads(HWND, unsigned, WORD, LONG)
  522.  
  523.     PURPOSE: Initializes window data and registers window class
  524.  
  525. ****************************************************************************/
  526.  
  527. BOOL FAR PASCAL SelectDoodads(hDlg, message, wParam, lParam)
  528. HWND hDlg;
  529. unsigned message;
  530. WORD wParam;
  531. LONG lParam;
  532. {
  533.  
  534.     int i;
  535.     int index;
  536.     char temp[80];
  537.     double win_invert;
  538.  
  539.     switch (message) {
  540.  
  541.         case WM_KEYDOWN:
  542.             switch (wParam) {
  543.                 case VK_F1:
  544.                 /* F1, shifted F1 bring up the Help Index */
  545.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  546.                     break;
  547.                 }
  548.  
  549.         case WM_INITDIALOG:
  550.             tempfloatflag = usr_floatflag;
  551.             tempstdcalcmode = usr_stdcalcmode;
  552.             if (tempstdcalcmode == '1')
  553.                 CheckDlgButton(hDlg, ID_PASS1, 1);
  554.             if (tempstdcalcmode == '2')
  555.                 CheckDlgButton(hDlg, ID_PASS2, 1);
  556.             if (tempstdcalcmode == 'g')
  557.                 CheckDlgButton(hDlg, ID_PASSS, 1);
  558.             if (tempstdcalcmode == 'b')
  559.                 CheckDlgButton(hDlg, ID_PASSB, 1);
  560.             if (tempfloatflag)
  561.                 CheckDlgButton(hDlg, ID_MATHF, 1);
  562.             else
  563.                 CheckDlgButton(hDlg, ID_MATHI, 1);
  564.             sprintf(temp,"%d",maxiter);
  565.         SetDlgItemText(hDlg, ID_MAXIT, temp);
  566.             sprintf(temp,"%d",biomorph);
  567.         SetDlgItemText(hDlg, ID_BIOMORPH, temp);
  568.             sprintf(temp,"%d",decomp);
  569.         SetDlgItemText(hDlg, ID_DECOMP, temp);
  570.             sprintf(temp,"%d",inside);
  571.         SetDlgItemText(hDlg, ID_INSIDE, temp);
  572.             sprintf(temp,"%d",outside);
  573.         SetDlgItemText(hDlg, ID_OUTSIDE, temp);
  574.         win_invert = -1;
  575.         if (invert != 0) {
  576.             win_invert = 0;
  577.             if (inversion[0] != AUTOINVERT)
  578.                 win_invert = inversion[0];
  579.             }
  580.             sprintf(temp,"%f",win_invert);
  581.         SetDlgItemText(hDlg, ID_INVERT, temp);
  582.             return (TRUE);
  583.             break;
  584.         
  585.         case WM_COMMAND:
  586.             switch (wParam) {
  587.                 case IDOK:
  588.                     /* retrieve and validate the results */
  589.                     usr_stdcalcmode = tempstdcalcmode;
  590.                     usr_floatflag = tempfloatflag;
  591.                     GetDlgItemText(hDlg, ID_MAXIT, temp, 10);
  592.                     maxiter = atoi(temp);
  593.                     if (maxiter < 10) maxiter = 10;
  594.                     if (maxiter > 32000) maxiter = 32000;
  595.                     GetDlgItemText(hDlg, ID_BIOMORPH, temp, 10);
  596.                     biomorph = atoi(temp);
  597.                     if (biomorph < 0) biomorph = -1;
  598.                     if (biomorph >= colors) biomorph = colors-1;
  599.                     GetDlgItemText(hDlg, ID_DECOMP, temp, 10);
  600.                     decomp = atoi(temp);
  601.                     if (decomp < 0) decomp = 0;
  602.                     if (decomp > 256) decomp = 256;
  603.                     GetDlgItemText(hDlg, ID_INSIDE, temp, 10);
  604.                     inside = atoi(temp);
  605.                     if (inside < 0) inside = 0;
  606.                     if (inside >= colors) inside = colors-1;
  607.                     GetDlgItemText(hDlg, ID_OUTSIDE, temp, 10);
  608.                     outside = atoi(temp);
  609.                     if (outside < 0) outside = -1;
  610.                     if (outside >= colors) outside = colors-1;
  611.                     GetDlgItemText(hDlg, ID_INVERT, temp, 10);
  612.                     win_invert = atof(temp);
  613.                     invert = 0;
  614.                     if (win_invert >= 0) {
  615.                         invert = 1;
  616.                         inversion[0] = AUTOINVERT;
  617.                         if (win_invert > 0)
  618.                             inversion[0] = win_invert;
  619.                         }
  620.                     time_to_restart = 1;
  621.                     EndDialog(hDlg, 1);
  622.                     break;
  623.                   
  624.                 case IDCANCEL:
  625.                     EndDialog(hDlg, 0);
  626.                     break;
  627.  
  628.                 case ID_PASS1:
  629.                     tempstdcalcmode = '1';
  630.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASS1);
  631.                     break;
  632.  
  633.                 case ID_PASS2:
  634.                     tempstdcalcmode = '2';
  635.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASS2);
  636.                     break;
  637.  
  638.                 case ID_PASSS:
  639.                     tempstdcalcmode = 'g';
  640.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASSS);
  641.                     break;
  642.  
  643.                 case ID_PASSB:
  644.                     tempstdcalcmode = 'b';
  645.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASSB, ID_PASSB);
  646.                     break;
  647.  
  648.                 case ID_MATHI:
  649.                     tempfloatflag = 0;
  650.                     CheckRadioButton(hDlg, ID_MATHI, ID_MATHF, ID_MATHI);
  651.                     break;
  652.  
  653.                 case ID_MATHF:
  654.                     tempfloatflag = 1;
  655.                     CheckRadioButton(hDlg, ID_MATHI, ID_MATHF, ID_MATHF);
  656.                     break;
  657.  
  658.                 }
  659.         
  660.         }
  661.     return (FALSE);
  662. }
  663.  
  664. /****************************************************************************
  665.  
  666.     FUNCTION: SelectCycle(HWND, unsigned, WORD, LONG)
  667.  
  668.     PURPOSE: Initializes window data and registers window class
  669.  
  670. ****************************************************************************/
  671.  
  672.  
  673. int win_cycledir = -1, win_cyclerand = 0, win_cyclefreq = 0;
  674. int win_tempcycle, win_tempcycledir, win_tempcyclerand, win_tempcyclefreq;
  675.  
  676. BOOL FAR PASCAL SelectCycle(hDlg, message, wParam, lParam)
  677. HWND hDlg;
  678. unsigned message;
  679. WORD wParam;
  680. LONG lParam;
  681. {
  682.  
  683.     int i;
  684.     int index;
  685.     char temp[80];
  686.  
  687.     switch (message) {
  688.  
  689.         case WM_KEYDOWN:
  690.             switch (wParam) {
  691.                 case VK_F1:
  692.                 /* F1, shifted F1 bring up the Help Index */
  693.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  694.                     break;
  695.                 }
  696.  
  697.         case WM_INITDIALOG:
  698.             win_tempcycle = time_to_cycle;
  699.             win_tempcycledir = win_cycledir;
  700.             win_tempcyclerand = win_cyclerand;
  701.             win_tempcyclefreq = win_cyclefreq;
  702.             if (win_tempcycle == 0)
  703.                 CheckDlgButton(hDlg, ID_CYCLEOFF, 1);
  704.             else
  705.                 CheckDlgButton(hDlg, ID_CYCLEON, 1);
  706.             if (win_tempcycledir == -1)
  707.                 CheckDlgButton(hDlg, ID_CYCLEOUT, 1);
  708.             else
  709.                 CheckDlgButton(hDlg, ID_CYCLEIN, 1);
  710.             if (win_tempcyclerand == 0)
  711.                 CheckDlgButton(hDlg, ID_CYCLESTAT, 1);
  712.             else
  713.                 CheckDlgButton(hDlg, ID_CYCLECHG, 1);
  714.             if (win_tempcyclefreq == 0)
  715.                 CheckDlgButton(hDlg, ID_CYCLELOW, 1);
  716.             else if (win_tempcyclefreq == 1)
  717.                 CheckDlgButton(hDlg, ID_CYCLEMED, 1);
  718.             else
  719.                 CheckDlgButton(hDlg, ID_CYCLEHIGH, 1);
  720.             return (TRUE);
  721.             break;
  722.         
  723.         case WM_COMMAND:
  724.             switch (wParam) {
  725.                 case IDOK:
  726.                     /* retrieve and validate the results */
  727.                     time_to_cycle = win_tempcycle;
  728.                     win_cycledir = win_tempcycledir;
  729.                     win_cyclerand = win_tempcyclerand;
  730.                     win_cyclefreq = win_tempcyclefreq;
  731.                     EndDialog(hDlg, 1);
  732.                     break;
  733.                   
  734.                 case IDCANCEL:
  735.                     EndDialog(hDlg, 0);
  736.                     break;
  737.  
  738.                 case ID_CYCLEOFF:
  739.                     win_tempcycle = 0;
  740.                     CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEOFF);
  741.                     break;
  742.  
  743.                 case ID_CYCLEON:
  744.                     win_tempcycle = 1;
  745.                     CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEON);
  746.                     break;
  747.  
  748.                 case ID_CYCLEOUT:
  749.                     win_tempcycledir = -1;
  750.                     CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEOUT);
  751.                     break;
  752.  
  753.                 case ID_CYCLEIN:
  754.                     win_tempcycledir = 1;
  755.                     CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEIN);
  756.                     break;
  757.  
  758.                 case ID_CYCLESTAT:
  759.                     win_tempcyclerand = 0;
  760.                     CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLESTAT);
  761.                     break;
  762.  
  763.                 case ID_CYCLECHG:
  764.                     win_tempcyclerand = 1;
  765.                     CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLECHG);
  766.                     break;
  767.  
  768.                 case ID_CYCLELOW:
  769.                     win_tempcyclefreq = 0;
  770.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLELOW);
  771.                     break;
  772.  
  773.                 case ID_CYCLEMED:
  774.                     win_tempcyclefreq = 1;
  775.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEMED);
  776.                     break;
  777.  
  778.                 case ID_CYCLEHIGH:
  779.                     win_tempcyclefreq = 2;
  780.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEHIGH);
  781.                     break;
  782.  
  783.                 }
  784.         
  785.         }
  786.     return (FALSE);
  787. }
  788.  
  789. FARPROC lpSelectFullScreen;
  790.  
  791. struct fullscreenvalues
  792. {
  793.    int type;   /* 'd' for decimal, 's' for string, '*' for comment */
  794.    union
  795.    {
  796.       double dval;
  797.       char   sval[16];
  798.    } uval;
  799. };
  800.  
  801. extern HANDLE hInst;
  802.  
  803. int win_fullscreen_count;
  804. char * far win_fullscreen_prompts[20];
  805. char *win_fullscreen_heading;
  806. static struct fullscreenvalues win_fullscreen_values[20];
  807.  
  808. int fullscreen_prompt(    /* full-screen prompting routine */
  809.     char *hdg,        /* heading, lines separated by \n */
  810.     int numprompts,     /* there are this many prompts (max) */
  811.     char * far *prompts,    /* array of prompting pointers */
  812.     struct fullscreenvalues values[], /* array of values */
  813.     int options,        /* future use bits in case we need them */
  814.     int fkeymask        /* bit n on if Fn to cause return */
  815.     )
  816. {
  817. int i;
  818. int Return;
  819.  
  820. win_fullscreen_count = numprompts;
  821. win_fullscreen_heading = hdg;
  822. win_fullscreen_count = numprompts;
  823. for (i = 0; i < win_fullscreen_count; i++) {
  824.    win_fullscreen_prompts[i] = prompts[i]; 
  825.    win_fullscreen_values[i]  = values[i];
  826.    }
  827.  
  828. lpSelectFullScreen = MakeProcInstance(SelectFullScreen, hInst);
  829. Return = DialogBox(hInst, "SelectFullScreen", hwnd, lpSelectFullScreen);
  830. FreeProcInstance(lpSelectFullScreen);
  831.  
  832. if (Return) {
  833.     for (i = 0; i < win_fullscreen_count; i++) {
  834.         values[i] = win_fullscreen_values[i];
  835.     }
  836.     return(0);
  837.     }
  838.  
  839. return(-1);
  840. }
  841.  
  842. BOOL FAR PASCAL SelectFullScreen(hDlg, message, wParam, lParam)
  843. HWND hDlg;
  844. unsigned message;
  845. WORD wParam;
  846. LONG lParam;
  847. {
  848.  
  849.     int i;
  850.     char temp[80];
  851.  
  852.     switch (message) {
  853.  
  854.         case WM_KEYDOWN:
  855.             switch (wParam) {
  856.                 case VK_F1:
  857.                 /* F1, shifted F1 bring up the Help Index */
  858.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  859.                     break;
  860.                 }
  861.  
  862.         case WM_INITDIALOG:
  863.             SetDlgItemText(hDlg, ID_PROMPT00,win_fullscreen_heading);
  864.             for (i = 0; i < win_fullscreen_count; i++) {
  865.                 SetDlgItemText(hDlg, ID_PROMPT01+i,win_fullscreen_prompts[i]);
  866.                 if (win_fullscreen_values[i].type == 'd')
  867.                     sprintf(temp,"%10.5f",win_fullscreen_values[i].uval.dval);
  868.                 else
  869.                     strcpy(temp,win_fullscreen_values[i].uval.sval);
  870.                 SetDlgItemText(hDlg, ID_ANSWER01+i,temp);
  871.                 }
  872.             return (TRUE);
  873.             break;
  874.         
  875.         case WM_COMMAND:
  876.             switch (wParam) {
  877.                 case IDOK:
  878.                     for (i = 0; i < win_fullscreen_count; i++) {
  879.                         GetDlgItemText(hDlg, ID_ANSWER01+i , temp, 10);
  880.                         if (win_fullscreen_values[i].type == 'd')
  881.                             win_fullscreen_values[i].uval.dval = atof(temp);
  882.                         else
  883.                             strcpy(win_fullscreen_values[i].uval.sval,temp);
  884.                     }
  885.                     EndDialog(hDlg, 1);
  886.                     break;
  887.                   
  888.                 case IDCANCEL:
  889.                     EndDialog(hDlg, 0);
  890.                     break;
  891.  
  892.                 }
  893.         
  894.         }
  895.     return (FALSE);
  896. }
  897.  
  898.  
  899. extern int init3d[];
  900. extern int win_3dspherical;
  901. extern char preview, showbox;
  902. extern int previewfactor, glassestype, whichimage;
  903. extern int xtrans, ytrans, transparent[2], RANDOMIZE;
  904.  
  905. static int win_answers[20];
  906.  
  907. BOOL FAR PASCAL Select3D(hDlg, message, wParam, lParam)
  908. HWND hDlg;
  909. unsigned message;
  910. WORD wParam;
  911. LONG lParam;
  912. {
  913.  
  914.     int i, tempfill;
  915.     char temp[80];
  916.  
  917.     switch (message) {
  918.  
  919.         case WM_KEYDOWN:
  920.             switch (wParam) {
  921.                 case VK_F1:
  922.                 /* F1, shifted F1 bring up the Help Index */
  923.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  924.                     break;
  925.                 }
  926.  
  927.         case WM_INITDIALOG:
  928.             win_answers[0] = preview;
  929.             win_answers[1] = showbox;
  930.             win_answers[2] = SPHERE;
  931.             win_answers[3] = previewfactor;
  932.             win_answers[4] = glassestype;
  933.             win_answers[5] = FILLTYPE+1;
  934.             for (i = ID_PREVIEW; i <= ID_SPHERICAL; i++)
  935.                 CheckDlgButton(hDlg, i, win_answers[i-ID_PREVIEW]);
  936.             sprintf(temp,"%d",win_answers[3]);
  937.         SetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp);
  938.             CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  939.                 ID_STEREO1+win_answers[4]);
  940.             CheckRadioButton(hDlg, ID_FILL1, ID_FILL8,
  941.                 ID_FILL1+win_answers[5]);
  942.             return (TRUE);
  943.             break;
  944.         
  945.         case WM_COMMAND:
  946.             switch (wParam) {
  947.                 case IDOK:
  948.                     if(win_answers[2] != SPHERE) {
  949.                         SPHERE = win_answers[2];
  950.                         set_3d_defaults();
  951.                         }
  952.                     preview = win_answers[0];
  953.                     showbox = win_answers[1];
  954.                     SPHERE  = win_answers[2];
  955.                     GetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp, 10);
  956.                     previewfactor = atoi(temp);
  957.                     glassestype = win_answers[4];
  958.                     FILLTYPE = win_answers[5]-1;
  959.                     win_3dspherical = SPHERE;
  960.                     if(previewfactor < 8)
  961.                        previewfactor = 8;
  962.                     if(previewfactor > 128)
  963.                        previewfactor = 128;
  964.                     if(glassestype < 0)
  965.                        glassestype = 0;
  966.                     if(glassestype > 3)
  967.                        glassestype = 3;
  968.                     whichimage = 0;
  969.                     if(glassestype)
  970.                        whichimage = 1;
  971.                     EndDialog(hDlg, 1);
  972.                     break;
  973.                     
  974.                 case ID_PREVIEW:
  975.                 case ID_SHOWBOX:
  976.                 case ID_SPHERICAL:
  977.                     i = wParam - ID_PREVIEW;
  978.                     win_answers[i] = 1 - win_answers[i];
  979.                     CheckDlgButton(hDlg, ID_PREVIEW + i, win_answers[i]);
  980.                     break;
  981.  
  982.                 case ID_FILL1:
  983.                 case ID_FILL2:
  984.                 case ID_FILL3:
  985.                 case ID_FILL4:
  986.                 case ID_FILL5:
  987.                 case ID_FILL6:
  988.                 case ID_FILL7:
  989.                 case ID_FILL8:
  990.                     i = wParam - ID_FILL1;
  991.                     win_answers[5] = i;
  992.                     CheckRadioButton(hDlg, ID_FILL1, ID_FILL8,
  993.                         ID_FILL1+win_answers[5]);
  994.                     break;
  995.  
  996.                 case ID_STEREO1:
  997.                 case ID_STEREO2:
  998.                 case ID_STEREO3:
  999.                 case ID_STEREO4:
  1000.                     i = wParam - ID_STEREO1;
  1001.                     win_answers[4] = i;
  1002.                     CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  1003.                         ID_STEREO1+win_answers[4]);
  1004.                     break;
  1005.  
  1006.                 case IDCANCEL:
  1007.                     EndDialog(hDlg, 0);
  1008.                     break;
  1009.  
  1010.                 }
  1011.         
  1012.         }
  1013.     return (FALSE);
  1014. }
  1015.  
  1016. BOOL FAR PASCAL Select3DPlanar(hDlg, message, wParam, lParam)
  1017. HWND hDlg;
  1018. unsigned message;
  1019. WORD wParam;
  1020. LONG lParam;
  1021. {
  1022.  
  1023.     int i;
  1024.     char temp[80];
  1025.  
  1026.     switch (message) {
  1027.  
  1028.         case WM_KEYDOWN:
  1029.             switch (wParam) {
  1030.                 case VK_F1:
  1031.                 /* F1, shifted F1 bring up the Help Index */
  1032.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  1033.                     break;
  1034.                 }
  1035.  
  1036.         case WM_INITDIALOG:
  1037.             win_answers[0] = XROT;
  1038.             win_answers[1] = YROT;
  1039.             win_answers[2] = ZROT;
  1040.             win_answers[3] = XSCALE;
  1041.             win_answers[4] = YSCALE;
  1042.             win_answers[5] = ROUGH;
  1043.             win_answers[6] = WATERLINE;
  1044.             win_answers[7] = ZVIEWER;
  1045.             win_answers[8] = XSHIFT;
  1046.             win_answers[9] = YSHIFT;
  1047.             win_answers[10] = xtrans;
  1048.             win_answers[11] = ytrans;
  1049.             win_answers[12] = transparent[0];
  1050.             win_answers[13] = transparent[1];
  1051.             win_answers[14] = RANDOMIZE;
  1052.             for (i = 0; i < 15; i++) {
  1053.                 sprintf(temp,"%d", win_answers[i]);
  1054.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1055.                 }
  1056.             return (TRUE);
  1057.             break;
  1058.         
  1059.         case WM_COMMAND:
  1060.             switch (wParam) {
  1061.                 case IDOK:
  1062.                     for (i = 0; i < 15; i++) {
  1063.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 10);
  1064.                         win_answers[i] = atof(temp);
  1065.                         }
  1066.                     XROT =           win_answers[0];
  1067.                     YROT =           win_answers[1];
  1068.                     ZROT =           win_answers[2];
  1069.                     XSCALE =         win_answers[3];
  1070.                     YSCALE =         win_answers[4];
  1071.                     ROUGH =          win_answers[5];
  1072.                     WATERLINE =      win_answers[6];
  1073.                     ZVIEWER =        win_answers[7];
  1074.                     XSHIFT =         win_answers[8];
  1075.                     YSHIFT =         win_answers[9];
  1076.                     xtrans =         win_answers[10];
  1077.                     ytrans =         win_answers[11];
  1078.                     transparent[0] = win_answers[12];
  1079.                     transparent[1] = win_answers[13];
  1080.                     RANDOMIZE =      win_answers[14];
  1081.                     if (RANDOMIZE >= 7) RANDOMIZE = 7;
  1082.                     if (RANDOMIZE <= 0) RANDOMIZE = 0;
  1083.                     EndDialog(hDlg, 1);
  1084.                     break;
  1085.                   
  1086.                 case IDCANCEL:
  1087.                     EndDialog(hDlg, 0);
  1088.                     break;
  1089.  
  1090.                 }
  1091.         
  1092.         }
  1093.     return (FALSE);
  1094. }
  1095.  
  1096. BOOL FAR PASCAL Select3DSpherical(hDlg, message, wParam, lParam)
  1097. HWND hDlg;
  1098. unsigned message;
  1099. WORD wParam;
  1100. LONG lParam;
  1101. {
  1102.  
  1103.     int i;
  1104.     char temp[80];
  1105.  
  1106.     switch (message) {
  1107.  
  1108.         case WM_KEYDOWN:
  1109.             switch (wParam) {
  1110.                 case VK_F1:
  1111.                 /* F1, shifted F1 bring up the Help Index */
  1112.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  1113.                     break;
  1114.                 }
  1115.  
  1116.         case WM_INITDIALOG:
  1117.             win_answers[0] = XROT;
  1118.             win_answers[1] = YROT;
  1119.             win_answers[2] = ZROT;
  1120.             win_answers[3] = XSCALE;
  1121.             win_answers[4] = YSCALE;
  1122.             win_answers[5] = ROUGH;
  1123.             win_answers[6] = WATERLINE;
  1124.             win_answers[7] = ZVIEWER;
  1125.             win_answers[8] = XSHIFT;
  1126.             win_answers[9] = YSHIFT;
  1127.             win_answers[10] = xtrans;
  1128.             win_answers[11] = ytrans;
  1129.             win_answers[12] = transparent[0];
  1130.             win_answers[13] = transparent[1];
  1131.             win_answers[14] = RANDOMIZE;
  1132.             for (i = 0; i < 15; i++) {
  1133.                 sprintf(temp,"%d", win_answers[i]);
  1134.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1135.                 }
  1136.             return (TRUE);
  1137.             break;
  1138.         
  1139.         case WM_COMMAND:
  1140.             switch (wParam) {
  1141.                 case IDOK:
  1142.                     for (i = 0; i < 15; i++) {
  1143.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 10);
  1144.                         win_answers[i] = atof(temp);
  1145.                         }
  1146.                     XROT =           win_answers[0];
  1147.                     YROT =           win_answers[1];
  1148.                     ZROT =           win_answers[2];
  1149.                     XSCALE =         win_answers[3];
  1150.                     YSCALE =         win_answers[4];
  1151.                     ROUGH =          win_answers[5];
  1152.                     WATERLINE =      win_answers[6];
  1153.                     ZVIEWER =        win_answers[7];
  1154.                     XSHIFT =         win_answers[8];
  1155.                     YSHIFT =         win_answers[9];
  1156.                     xtrans =         win_answers[10];
  1157.                     ytrans =         win_answers[11];
  1158.                     transparent[0] = win_answers[12];
  1159.                     transparent[1] = win_answers[13];
  1160.                     RANDOMIZE =      win_answers[14];
  1161.                     if (RANDOMIZE >= 7) RANDOMIZE = 7;
  1162.                     if (RANDOMIZE <= 0) RANDOMIZE = 0;
  1163.                     EndDialog(hDlg, 1);
  1164.                     break;
  1165.                   
  1166.                 case IDCANCEL:
  1167.                     EndDialog(hDlg, 0);
  1168.                     break;
  1169.  
  1170.                 }
  1171.         
  1172.         }
  1173.     return (FALSE);
  1174. }
  1175.