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