home *** CD-ROM | disk | FTP | other *** search
/ Computerworld 1996 March / Computerworld_1996-03_cd.bin / idg_cd3 / grafika / fraktaly / wins1821 / dialog.c < prev    next >
C/C++ Source or Header  |  1996-02-13  |  72KB  |  2,108 lines

  1. /*
  2.  
  3.     various dialog-box code
  4.  
  5. */
  6.  
  7. #include <windows.h>
  8. #include <commdlg.h>
  9. #include <print.h>
  10. #include <math.h>
  11. #include <stdio.h>
  12. #include "winfract.h"
  13. #include "dialog.h"
  14. #include "fractint.h"
  15. #include "fractype.h"
  16. #include "mathtool.h"
  17. #include "profile.h"
  18.  
  19. extern HWND hwnd;                               /* handle to main window */
  20. extern char szHelpFileName[];                   /* Help file name*/
  21.  
  22. extern BOOL zoomflag;                /* TRUE is a zoom-box selected */
  23.  
  24. extern char *win_choices[];
  25. extern int win_numchoices, win_choicemade;
  26. int CurrentFractal;
  27.  
  28. extern HANDLE hDibInfo;        /* handle to the Device-independent bitmap */
  29. extern LPBITMAPINFO pDibInfo;        /* pointer to the DIB info */
  30.  
  31. extern int time_to_restart;                               /* time to restart?  */
  32. extern int time_to_reinit;                /* time to reinit? */
  33. extern int time_to_cycle;                               /* time to cycle? */
  34.  
  35. extern int xdots, ydots, colors, maxiter;
  36. extern int ytop, ybottom, xleft, xright;
  37. extern double xxmin, xxmax, yymin, yymax;
  38. extern int fractype;
  39. extern int calc_status;
  40. extern double param[4];
  41. extern int bailout;
  42. extern struct moreparams far moreparams[];
  43.  
  44. extern int inside, outside, usr_biomorph, decomp, debugflag;
  45. extern int usr_stdcalcmode, usr_floatflag;
  46. extern    int    invert;     /* non-zero if inversion active */
  47. extern    double    inversion[3];    /* radius, xcenter, ycenter */
  48. extern int numtrigfn;
  49.  
  50. extern int LogFlag, fillcolor;
  51.  
  52. int win_temp1, win_temp2, win_temp3, win_temp4;
  53.  
  54. int numparams,numtrig, numextra;
  55. static char *trg[] = {"First Function","Second Function",
  56.               "Third Function","Fourth Function"};
  57. static int paramt[] = {ID_FRACPARTX1, ID_FRACPARTX2,
  58.                        ID_FRACPARTX3, ID_FRACPARTX4,
  59.                        ID_FRACPARTX5, ID_FRACPARTX6 };
  60. static int paramv[] = {ID_FRACPARAM1, ID_FRACPARAM2,
  61.                        ID_FRACPARAM3, ID_FRACPARAM4,
  62.                        ID_FRACPARAM5, ID_FRACPARAM6, };
  63.  
  64. extern int win_release;
  65. extern char far win_comment[];
  66.  
  67. extern char far DialogTitle[];
  68. extern unsigned char DefExt[10];
  69. extern unsigned char FullPathName[128];
  70. extern unsigned char readname[];
  71.  
  72. double far win_oldprompts[20];
  73.  
  74. extern int stopmsg(int ,CHAR far *);
  75.  
  76. /* far strings (near space is precious) */
  77. char far about_msg01[] = "(C) 1990, 1993 The Stone Soup Group";
  78. char far about_msg02[] = "";
  79. char far about_msg03[] = "";
  80. char far about_msg04[] = "";
  81. char far about_msg05[] = "Winfract is copyrighted freeware and may not be";
  82. char far about_msg06[] = "distributed for commercial or promotional purposes";
  83. char far about_msg07[] = "without written permission from the Stone Soup Group.";
  84. char far about_msg08[] = "Distribution of Winfract by BBS, network, and";
  85. char far about_msg09[] = "software shareware distributors, etc. is encouraged.";
  86. char far about_msg10[] = "";
  87.  
  88. BOOL FAR PASCAL About(hDlg, message, wParam, lParam)
  89. HWND hDlg;
  90. unsigned message;
  91. WORD wParam;
  92. LONG lParam;
  93. {
  94.  
  95. float temp;
  96. char tempname[40];
  97. extern char far winfract_title_text[];
  98. char about_msg00[80];
  99.  
  100.     switch (message) {
  101.  
  102.         case WM_INITDIALOG:
  103.             sprintf(about_msg00,"Winfract version %d.%02d, Fractals for Windows release",
  104.                 win_release/100, win_release%100);
  105.             SetDlgItemText(hDlg, ID_VERSION  ,about_msg00);
  106.             SetDlgItemText(hDlg, ID_COMMENT  ,about_msg01);
  107.             SetDlgItemText(hDlg, ID_COMMENT2 ,about_msg02);
  108.             SetDlgItemText(hDlg, ID_COMMENT3 ,about_msg03);
  109.             SetDlgItemText(hDlg, ID_COMMENT4 ,about_msg04);
  110.             SetDlgItemText(hDlg, ID_COMMENT5 ,about_msg05);
  111.             SetDlgItemText(hDlg, ID_COMMENT6 ,about_msg06);
  112.             SetDlgItemText(hDlg, ID_COMMENT7 ,about_msg07);
  113.             SetDlgItemText(hDlg, ID_COMMENT8 ,about_msg08);
  114.             SetDlgItemText(hDlg, ID_COMMENT9 ,about_msg09);
  115.             SetDlgItemText(hDlg, ID_COMMENT10,about_msg10);
  116.             return (TRUE);
  117.  
  118.         case WM_COMMAND:
  119.         if (wParam == IDOK
  120.                 || wParam == IDCANCEL) {
  121.                 EndDialog(hDlg, TRUE);
  122.                 return (TRUE);
  123.             }
  124.             break;
  125.     }
  126.     return (FALSE);
  127. }
  128.  
  129.  
  130. BOOL FAR PASCAL Status(hDlg, message, wParam, lParam)
  131. HWND hDlg;
  132. unsigned message;
  133. WORD wParam;
  134. LONG lParam;
  135. {
  136. char tempstring[100];
  137.     switch (message) {
  138.  
  139.         case WM_INITDIALOG:
  140.             sprintf(tempstring,"fractal type: ");
  141.             if (fractalspecific[fractype].name[0] != '*')
  142.                 strcat(tempstring, fractalspecific[fractype].name);
  143.             else
  144.                 strcat(tempstring, &fractalspecific[fractype].name[1]);
  145.             if (calc_status == 1)
  146.                 strcat(tempstring,"    (still being calculated)");
  147.             else if (calc_status == 2)
  148.                 strcat(tempstring,"    (interrupted, resumable)");
  149.             else if (calc_status == 3)
  150.                 strcat(tempstring,"    (interrupted, not resumable)");
  151.             else
  152.                 strcat(tempstring,"    (completed)");
  153.             /* ##### */
  154.             SetDlgItemText(hDlg, IDS_LINE1,tempstring);
  155.             if(fractalspecific[fractype].param[0][0] == 0)
  156.                 tempstring[0] = 0;
  157.             else
  158.                 sprintf(tempstring,"%-30.30s   %14.10f",
  159.                     fractalspecific[fractype].param[0], param[0]);
  160.             SetDlgItemText(hDlg, IDS_LINE2,tempstring);
  161.             if(fractalspecific[fractype].param[1][0] == 0)
  162.                 tempstring[0] = 0;
  163.             else
  164.                 sprintf(tempstring,"%-30.30s   %14.10f",
  165.                     fractalspecific[fractype].param[1], param[1]);
  166.             SetDlgItemText(hDlg, IDS_LINE3,tempstring);
  167.             if(fractalspecific[fractype].param[2][0] == 0)
  168.                 tempstring[0] = 0;
  169.             else
  170.                 sprintf(tempstring,"%-30.30s   %14.10f",
  171.                     fractalspecific[fractype].param[2], param[2]);
  172.             SetDlgItemText(hDlg, IDS_LINE4,tempstring);
  173.             if(fractalspecific[fractype].param[3][0] == 0)
  174.                 tempstring[0] = 0;
  175.             else
  176.                 sprintf(tempstring,"%-30.30s   %14.10f",
  177.                     fractalspecific[fractype].param[3], param[3]);
  178.             SetDlgItemText(hDlg, IDS_LINE5,tempstring);
  179.             sprintf(tempstring,"Xmin:        %25.16f", xxmin);
  180.             SetDlgItemText(hDlg, IDS_LINE6,tempstring);
  181.             sprintf(tempstring,"Xmax:        %25.16f", xxmax);
  182.             SetDlgItemText(hDlg, IDS_LINE7,tempstring);
  183.             sprintf(tempstring,"Ymin:        %25.16f", yymin);
  184.             SetDlgItemText(hDlg, IDS_LINE8,tempstring);
  185.             sprintf(tempstring,"Ymax:        %25.16f", yymax);
  186.             SetDlgItemText(hDlg, IDS_LINE9,tempstring);
  187.             return (TRUE);
  188.  
  189.         case WM_COMMAND:
  190.         if (wParam == IDOK
  191.                 || wParam == IDCANCEL) {
  192.                 EndDialog(hDlg, TRUE);
  193.                 return (TRUE);
  194.             }
  195.             break;
  196.     }
  197.     return (FALSE);
  198. }
  199.  
  200.  
  201. BOOL FAR PASCAL SelectFractal(hDlg, message, wParam, lParam)
  202. HWND hDlg;
  203. unsigned message;
  204. WORD wParam;
  205. LONG lParam;
  206. {
  207.  
  208.     int i;
  209.     int index;
  210.  
  211.     switch (message) {
  212.  
  213.         case WM_INITDIALOG:
  214.             SetDlgItemText(hDlg, ID_LISTTITLE,     DialogTitle);
  215.             for (i = 0; i < win_numchoices; i++) 
  216.                 SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_ADDSTRING,
  217.                     NULL, (LONG) (LPSTR) win_choices[i]);
  218.             SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_SETCURSEL,
  219.                 win_choicemade, 0L);
  220.             return (TRUE);
  221.  
  222.         case WM_COMMAND:
  223.             switch (wParam) {
  224.  
  225.                 case IDOK:
  226. okay:           
  227.                     index=SendDlgItemMessage(hDlg, IDM_FRACTAL,
  228.                         LB_GETCURSEL, 0, 0L);
  229.                     if (index == LB_ERR) {
  230.                         MessageBox(hDlg, "No Choice selected",
  231.                             "Select From a List", MB_OK | MB_ICONEXCLAMATION);
  232.                         break;
  233.                         }
  234.                     win_choicemade = index;
  235.                     EndDialog(hDlg, 1);
  236.                     break;
  237.                   
  238.                 case IDCANCEL:
  239.                     win_choicemade = -1;
  240.                     EndDialog(hDlg, 0);
  241.                     break;
  242.                     
  243.                 case IDM_FRACTAL:
  244.                     switch (HIWORD(lParam)) {
  245.                         case LBN_SELCHANGE:
  246.                             index = SendDlgItemMessage(hDlg, IDM_FRACTAL,
  247.                                 LB_GETCURSEL, 0, 0L);
  248.                             if (index == LB_ERR)
  249.                                 break;
  250.                             break;
  251.                          
  252.                        case LBN_DBLCLK:
  253.                             goto okay;
  254.  
  255.                     }
  256.             return (TRUE);
  257.                 }
  258.  
  259.         }
  260.     return (FALSE);
  261. }
  262.  
  263.  
  264. BOOL FAR PASCAL SelectFracParams(hDlg, message, wParam, lParam)
  265. HWND hDlg;
  266. unsigned message;
  267. WORD wParam;
  268. LONG lParam;
  269. {
  270.  
  271.     int i, j;
  272.     char temp[30];
  273.  
  274.     switch (message) {
  275.  
  276.         case WM_INITDIALOG:
  277.                 win_temp1 = CurrentFractal;
  278.             SetDlgItemText(hDlg, ID_FRACNAME,   fractalspecific[win_temp1].name);
  279.                 for (numparams = 0; numparams < 4; numparams++)
  280.                     if (fractalspecific[win_temp1].param[numparams][0] == 0)
  281.                         break;
  282.                 numtrig = (fractalspecific[win_temp1].flags >> 6) & 7;
  283.                 if (numparams+numtrig > 6) numparams = 6 - numtrig;
  284.                 for (i = 0; i < 6; i++) {
  285.                     temp[0] = 0;
  286.                     if (i < numparams)
  287.                         sprintf(temp,"%f",param[i]);
  288.                     SetDlgItemText(hDlg, paramv[i], temp);
  289.                     SetDlgItemText(hDlg, paramt[i],"(n/a)");
  290.                     if (i < numparams)
  291.                        SetDlgItemText(hDlg, paramt[i], fractalspecific[win_temp1].param[i]);
  292.                     }
  293.                for(i=0; i<numtrig; i++) {
  294.                     SetDlgItemText(hDlg, paramt[i+numparams], trg[i]);
  295.                     SetDlgItemText(hDlg, paramv[i+numparams],
  296.                         trigfn[trigndx[i]].name);
  297.                     }
  298.                 numextra = 0;
  299.                 if (fractalspecific[win_temp1].flags & MORE) {
  300.                     /* uh-oh - over four parameters! */
  301.                     int i, extra;
  302.                     if ((extra = find_extra_param(win_temp1)) > -1)
  303.                         for (i = 0; i < 6 - numparams - numtrig; i++)
  304.                             if (moreparams[extra].param[i][0] != 0) {
  305.                                 numextra++;
  306.                                 sprintf(temp,"%f",
  307.                                     moreparams[extra].paramvalue[i]);
  308.                                 SetDlgItemText(hDlg, paramt[i+numparams+numtrig],
  309.                                     moreparams[extra].param[i]);
  310.                                 SetDlgItemText(hDlg, paramv[i+numparams+numtrig],
  311.                                     temp);
  312.                                 }
  313.                     }
  314.                 sprintf(temp,"%d",bailout);
  315.             SetDlgItemText(hDlg, ID_BAILOUT,   temp);
  316.                 sprintf(temp,"%.12f",xxmin);
  317.             SetDlgItemText(hDlg, ID_FRACXMIN,   temp);
  318.                 sprintf(temp,"%.12f",xxmax);
  319.             SetDlgItemText(hDlg, ID_FRACXMAX,   temp);
  320.                 sprintf(temp,"%.12f",yymin);
  321.             SetDlgItemText(hDlg, ID_FRACYMIN,   temp);
  322.                 sprintf(temp,"%.12f",yymax);
  323.             SetDlgItemText(hDlg, ID_FRACYMAX,   temp);
  324.                 return (TRUE);
  325.  
  326.         case WM_COMMAND:
  327.             switch (wParam) {
  328.  
  329.                 case IDOK:
  330.                     {
  331.                     for (i = 0; i < numtrig; i++) {
  332.                         GetDlgItemText(hDlg, paramv[i+numparams], temp, 10);
  333.                         temp[6] = 0;
  334.                         for (j = 0; j <= 6; j++)
  335.                             if(temp[j] == ' ') temp[j] = 0;
  336.                         strlwr(temp);
  337.                         for(j=0;j<numtrigfn;j++)
  338.                             if(strcmp(temp,trigfn[j].name)==0)
  339.                                 break;
  340.                         if (j >= numtrigfn) {
  341.                             char oops[80];
  342.                             sprintf(oops, "Trig param %d, '%s' is not a valid trig function\n", i+1, temp);
  343.                             strcat(oops, "Try sin, cos, tan, cotan, sinh, etc.");
  344.                             stopmsg(0,oops);
  345.                             break;
  346.                             }
  347.                         }
  348.                         if (i != numtrig) break;
  349.                     }
  350.                     for (i = 0; i < numparams; i++) {
  351.                         GetDlgItemText(hDlg, paramv[i], temp, 20);
  352.                         param[i] = atof(temp);
  353.                         }
  354.                     for (i = 0; i < numtrig; i++) {
  355.                         GetDlgItemText(hDlg, paramv[i+numparams], temp, 10);
  356.                         temp[6] = 0;
  357.                         for (j = 0; j <= 6; j++)
  358.                             if (temp[j] == 32) temp[j] = 0;
  359.                         set_trig_array(i, temp);
  360.                         }
  361.                     for (i = 0; i < numextra; i++) {
  362.                         GetDlgItemText(hDlg, paramv[i+numparams+numtrig], temp, 20);
  363.                         param[i+4] = atof(temp);
  364.                         }
  365.             GetDlgItemText(hDlg, ID_BAILOUT   , temp, 10);
  366.             bailout = atof(temp);
  367.             GetDlgItemText(hDlg, ID_FRACXMIN  , temp, 20);
  368.             xxmin = atof(temp);
  369.             GetDlgItemText(hDlg, ID_FRACXMAX  , temp, 20);
  370.             xxmax = atof(temp);
  371.             GetDlgItemText(hDlg, ID_FRACYMIN  , temp, 20);
  372.             yymin = atof(temp);
  373.             GetDlgItemText(hDlg, ID_FRACYMAX  , temp, 20);
  374.             yymax = atof(temp);
  375.                     invert = 0;
  376.                     inversion[0] = inversion[1] = inversion[2] = 0;
  377.                     fractype = CurrentFractal;
  378.                     EndDialog(hDlg, 1);
  379.                     break;
  380.                     
  381.                   
  382.                 case IDCANCEL:
  383.                     EndDialog(hDlg, 0);
  384.                     break;
  385.  
  386.                 }
  387.         
  388.         }
  389.     return (FALSE);
  390. }
  391.  
  392.  
  393. BOOL FAR PASCAL SelectImage(hDlg, message, wParam, lParam)
  394. HWND hDlg;
  395. unsigned message;
  396. WORD wParam;
  397. LONG lParam;
  398. {
  399.  
  400.     int i;
  401.     char temp[15];
  402.  
  403.     switch (message) {
  404.  
  405.         case WM_INITDIALOG:
  406.             win_temp1 = colors;
  407.             if (win_temp1 == 2)
  408.                 CheckDlgButton(hDlg, ID_ICOLORS1, 1);
  409.             else if (win_temp1 == 16)
  410.                 CheckDlgButton(hDlg, ID_ICOLORS2, 1);
  411.             else
  412.                 CheckDlgButton(hDlg, ID_ICOLORS3, 1);
  413.             sprintf(temp,"%d",xdots);
  414.         SetDlgItemText(hDlg, ID_ISIZEX, temp);
  415.             sprintf(temp,"%d",ydots);
  416.         SetDlgItemText(hDlg, ID_ISIZEY, temp);
  417.         i = ID_ISIZE7;
  418.         if (xdots ==  200 && ydots == 150) i = ID_ISIZE1;
  419.         if (xdots ==  320 && ydots == 200) i = ID_ISIZE2;
  420.         if (xdots ==  640 && ydots == 350) i = ID_ISIZE3;
  421.         if (xdots ==  640 && ydots == 480) i = ID_ISIZE4;
  422.         if (xdots ==  800 && ydots == 600) i = ID_ISIZE5;
  423.         if (xdots == 1024 && ydots == 768) i = ID_ISIZE6;
  424.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, i);
  425.             return (TRUE);
  426.  
  427.         case WM_COMMAND:
  428.             switch (wParam) {
  429.  
  430.                 case IDOK:
  431.                     /* retrieve and validate the results */
  432.             GetDlgItemText(hDlg, ID_ISIZEX, temp, 10);
  433.             xdots = atoi(temp);
  434.             if (xdots < 50) xdots = 50;
  435.             if (xdots > 2048) xdots = 2048;
  436.             GetDlgItemText(hDlg, ID_ISIZEY, temp, 10);
  437.             ydots = atoi(temp);
  438.             if (ydots < 50) ydots = 50;
  439.             if (ydots > 2048) ydots = 2048;
  440.                     colors = win_temp1;
  441.                     win_savedac();
  442.                     /* allocate and lock a pixel array for the bitmap */
  443.                     /* problem, here - can't just RETURN!!! */
  444.                     tryagain:
  445.                     if (!clear_screen(0)) {
  446.                         MessageBox(hDlg, "Not Enough Memory for that sized Image",
  447.                             NULL, MB_OK | MB_ICONHAND);
  448.                         xdots = ydots = 100;
  449.                         goto tryagain;
  450.                         };
  451.                     ytop    = 0;        /* reset the zoom-box */
  452.                     ybottom = ydots-1;
  453.                     xleft   = 0;
  454.                     xright  = xdots-1;
  455.                     set_win_offset();
  456.                     zoomflag = TRUE;
  457.                     time_to_restart = 1;
  458.  
  459.                     ProgStr = Winfract;
  460.                     SaveIntParam(ImageWidthStr, xdots);
  461.                     SaveIntParam(ImageHeightStr, ydots);
  462.  
  463.                     EndDialog(hDlg, 1);
  464.                     break;
  465.                   
  466.                 case IDCANCEL:
  467.                     EndDialog(hDlg, 0);
  468.                     break;
  469.  
  470.                 case ID_ISIZE1:
  471.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE1);
  472.             SetDlgItemInt(hDlg, ID_ISIZEX, 200, TRUE);
  473.             SetDlgItemInt(hDlg, ID_ISIZEY, 150, TRUE);
  474.                     break;
  475.  
  476.                 case ID_ISIZE2:
  477.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE2);
  478.             SetDlgItemInt(hDlg, ID_ISIZEX, 320, TRUE);
  479.             SetDlgItemInt(hDlg, ID_ISIZEY, 200, TRUE);
  480.                     break;
  481.  
  482.                 case ID_ISIZE3:
  483.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE3);
  484.             SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE);
  485.             SetDlgItemInt(hDlg, ID_ISIZEY, 350, TRUE);
  486.                     break;
  487.  
  488.                 case ID_ISIZE4:
  489.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE4);
  490.             SetDlgItemInt(hDlg, ID_ISIZEX, 640, TRUE);
  491.             SetDlgItemInt(hDlg, ID_ISIZEY, 480, TRUE);
  492.                     break;
  493.  
  494.                 case ID_ISIZE5:
  495.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE5);
  496.             SetDlgItemInt(hDlg, ID_ISIZEX, 800, TRUE);
  497.             SetDlgItemInt(hDlg, ID_ISIZEY, 600, TRUE);
  498.                     break;
  499.  
  500.                 case ID_ISIZE6:
  501.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE6);
  502.             SetDlgItemInt(hDlg, ID_ISIZEX, 1024, TRUE);
  503.             SetDlgItemInt(hDlg, ID_ISIZEY, 768, TRUE);
  504.                     break;
  505.  
  506.                 case ID_ISIZE7:
  507.             CheckRadioButton(hDlg, ID_ISIZE1, ID_ISIZE7, ID_ISIZE7);
  508.                     break;
  509.  
  510.                 case ID_ICOLORS1:
  511.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS1);
  512.                     win_temp1 = 2;
  513.                     break;
  514.  
  515.                 case ID_ICOLORS2:
  516.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS2);
  517.                     win_temp1 = 16;
  518.                     break;
  519.  
  520.                 case ID_ICOLORS3:
  521.             CheckRadioButton(hDlg, ID_ICOLORS1, ID_ICOLORS3, ID_ICOLORS3);
  522.                     win_temp1 = 256;
  523.                     break;
  524.  
  525.                 }
  526.         
  527.         }
  528.     return (FALSE);
  529. }
  530.  
  531.  
  532. BOOL FAR PASCAL SelectDoodads(hDlg, message, wParam, lParam)
  533. HWND hDlg;
  534. unsigned message;
  535. WORD wParam;
  536. LONG lParam;
  537. {
  538.  
  539.     char temp[80];
  540.  
  541.     switch (message) {
  542.  
  543.         case WM_INITDIALOG:
  544.             win_temp1 = usr_floatflag;
  545.             win_temp2 = 0;
  546.             if (usr_stdcalcmode == '2') win_temp2 = 1;
  547.             if (usr_stdcalcmode == 'g') win_temp2 = 2;
  548.             if (usr_stdcalcmode == 'b') win_temp2 = 3;
  549.             if (usr_stdcalcmode == 't') win_temp2 = 4;
  550.             win_temp3 = 0;
  551.             if (inside == -1)    win_temp3 = 1;
  552.             if (inside == -59)   win_temp3 = 2;
  553.             if (inside == -60)   win_temp3 = 3;
  554.             if (inside == -61)   win_temp3 = 4;
  555.             if (inside == -100)  win_temp3 = 5;
  556.             if (inside == -101)  win_temp3 = 6;
  557.             win_temp4 = 0;
  558.             if (outside < 0 && outside > -6) win_temp4 = 0 - outside;
  559.             CheckDlgButton(hDlg, ID_PASS1+win_temp2,1);
  560.             CheckDlgButton(hDlg, ID_INSIDEC+win_temp3, 1);
  561.             CheckDlgButton(hDlg, ID_OUTSIDEN+win_temp4, 1);
  562.             if (win_temp1)
  563.                 CheckDlgButton(hDlg, ID_MATHF, 1);
  564.             else
  565.                 CheckDlgButton(hDlg, ID_MATHF, 0);
  566.             sprintf(temp,"%d",maxiter);
  567.         SetDlgItemText(hDlg, ID_MAXIT, temp);
  568.             sprintf(temp,"%d",usr_biomorph);
  569.         SetDlgItemText(hDlg, ID_BIOMORPH, temp);
  570.             sprintf(temp,"%d",LogFlag);
  571.         SetDlgItemText(hDlg, ID_LOGP, temp);
  572.             sprintf(temp,"%d",decomp);
  573.         SetDlgItemText(hDlg, ID_DECOMP, temp);
  574.             sprintf(temp,"%d",fillcolor);
  575.         SetDlgItemText(hDlg, ID_FILLC, temp);
  576.             sprintf(temp,"%d",max(inside,0));
  577.         SetDlgItemText(hDlg, ID_INSIDE, temp);
  578.             sprintf(temp,"%d",max(outside,0));
  579.         SetDlgItemText(hDlg, ID_OUTSIDE, temp);
  580.             return (TRUE);
  581.  
  582.         case WM_COMMAND:
  583.             switch (wParam) {
  584.  
  585.                 case IDOK:
  586.                     /* retrieve and validate the results */
  587.                     usr_stdcalcmode = '1';
  588.                     if (win_temp2 == 1) usr_stdcalcmode = '2';
  589.                     if (win_temp2 == 2) usr_stdcalcmode = 'g';
  590.                     if (win_temp2 == 3) usr_stdcalcmode = 'b';
  591.                     if (win_temp2 == 4) usr_stdcalcmode = 't';
  592.                     usr_floatflag = win_temp1;
  593.                     GetDlgItemText(hDlg, ID_MAXIT, temp, 10);
  594.                     maxiter = atoi(temp);
  595.                     if (maxiter < 10) maxiter = 10;
  596.                     if (maxiter > 32000) maxiter = 32000;
  597.                     GetDlgItemText(hDlg, ID_LOGP, temp, 10);
  598.                     LogFlag = atoi(temp);
  599.                     GetDlgItemText(hDlg, ID_BIOMORPH, temp, 10);
  600.                     usr_biomorph = atoi(temp);
  601.                     if (usr_biomorph < 0) usr_biomorph = -1;
  602.                     if (usr_biomorph >= colors) usr_biomorph = colors-1;
  603.                     GetDlgItemText(hDlg, ID_DECOMP, temp, 10);
  604.                     decomp = atoi(temp);
  605.                     if (decomp < 0) decomp = 0;
  606.                     if (decomp > 256) decomp = 256;
  607.                     GetDlgItemText(hDlg, ID_FILLC, temp, 10);
  608.                     fillcolor = atoi(temp);
  609.                     GetDlgItemText(hDlg, ID_INSIDE, temp, 10);
  610.                     inside = atoi(temp);
  611.                     if (inside < 0) inside = 0;
  612.                     if (inside >= colors) inside = colors-1;
  613.                     if (win_temp3 == 1) inside = -1;
  614.                     if (win_temp3 == 2) inside = -59;
  615.                     if (win_temp3 == 3) inside = -60;
  616.                     if (win_temp3 == 4) inside = -61;
  617.                     if (win_temp3 == 5) inside = -100;
  618.                     if (win_temp3 == 6) inside = -101;
  619.                     GetDlgItemText(hDlg, ID_OUTSIDE, temp, 10);
  620.                     outside = atoi(temp);
  621.                     if (outside < 0) outside = -1;
  622.                     if (outside >= colors) outside = colors-1;
  623.                     if (win_temp4 > 0) outside = 0 - win_temp4;
  624.                     time_to_restart = 1;
  625.                     EndDialog(hDlg, 1);
  626.                     break;
  627.                   
  628.                 case IDCANCEL:
  629.                     EndDialog(hDlg, 0);
  630.                     break;
  631.  
  632.                 case ID_PASS1:
  633.                 case ID_PASS2:
  634.                 case ID_PASSS:
  635.                 case ID_PASSB:
  636.                 case ID_PASST:
  637.                     win_temp2 = wParam - ID_PASS1;
  638.                     CheckRadioButton(hDlg, ID_PASS1, ID_PASST, wParam);
  639.                     break;
  640.  
  641.                 case ID_INSIDEC:
  642.                 case ID_INSIDEM:
  643.                 case ID_INSIDEZ:
  644.                 case ID_INSIDE60:
  645.                 case ID_INSIDE61:
  646.                 case ID_INSIDEE:
  647.                 case ID_INSIDES:
  648.                     win_temp3 = wParam - ID_INSIDEC;
  649.                     CheckRadioButton(hDlg, ID_INSIDEC, ID_INSIDES, wParam);
  650.                     break;
  651.  
  652.                 case ID_OUTSIDEN:
  653.                 case ID_OUTSIDEIT:
  654.                 case ID_OUTSIDER:
  655.                 case ID_OUTSIDEIM:
  656.                 case ID_OUTSIDEM:
  657.                 case ID_OUTSIDES:
  658.                     win_temp4 = wParam - ID_OUTSIDEN;
  659.                     CheckRadioButton(hDlg, ID_OUTSIDEN, ID_OUTSIDES, wParam);
  660.                     break;
  661.  
  662.                 case ID_MATHF:
  663.                     if (win_temp1 == 0)
  664.                         win_temp1 = 1;
  665.                     else
  666.                         win_temp1 = 0;
  667.                     CheckDlgButton(hDlg, ID_MATHF, win_temp1);
  668.                     break;
  669.  
  670.                 }
  671.         
  672.         }
  673.     return (FALSE);
  674. }
  675.  
  676.  
  677. BOOL FAR PASCAL SelectExtended(hDlg, message, wParam, lParam)
  678. HWND hDlg;
  679. unsigned message;
  680. WORD wParam;
  681. LONG lParam;
  682. {
  683.    char temp[80];
  684.    int i, j, k;
  685.    extern    int    finattract;    /* finite attractor switch */
  686.    extern    double    potparam[3];    /* three potential parameters*/
  687.    extern    int    pot16bit;
  688.    extern    int    usr_distest;    /* distance estimator option */
  689.    extern    int    distestwidth;
  690.    extern    int    rotate_lo,rotate_hi;
  691.  
  692.     switch (message) {
  693.  
  694.         case WM_INITDIALOG:
  695.             if (finattract)
  696.                 win_temp1 = 1;
  697.             else
  698.                 win_temp1 = 0;
  699.             CheckDlgButton(hDlg, ID_FINITE, win_temp1);
  700.             sprintf(temp,"%f",potparam[0]);
  701.         SetDlgItemText(hDlg, ID_POTENTMAX, temp);
  702.             sprintf(temp,"%f",potparam[1]);
  703.         SetDlgItemText(hDlg, ID_POTENTSLOPE, temp);
  704.             sprintf(temp,"%f",potparam[2]);
  705.         SetDlgItemText(hDlg, ID_POTENTBAIL, temp);
  706.             if (pot16bit)
  707.                 win_temp2 = 1;
  708.             else
  709.                 win_temp2 = 0;
  710.             CheckDlgButton(hDlg, ID_POTENT16, win_temp2);
  711.             sprintf(temp,"%i",usr_distest);
  712.         SetDlgItemText(hDlg, ID_DISTEST, temp);
  713.             sprintf(temp,"%i",distestwidth);
  714.         SetDlgItemText(hDlg, ID_DISTESTWID, temp);
  715.             for (i = 0; i < 3; i++) {
  716.                 sprintf(temp,"%.12f",inversion[i]);
  717.                 if (inversion[i] == AUTOINVERT)
  718.                 SetDlgItemText(hDlg, ID_INVERTRAD+i, "auto");
  719.                 else
  720.                 SetDlgItemText(hDlg, ID_INVERTRAD+i, temp);
  721.             }
  722.             sprintf(temp,"%i",rotate_lo);
  723.         SetDlgItemText(hDlg, ID_COLORMIN, temp);
  724.             sprintf(temp,"%i",rotate_hi);
  725.         SetDlgItemText(hDlg, ID_COLORMAX, temp);
  726.             win_oldprompts[0] = win_temp1;
  727.             win_oldprompts[1] = potparam[0];
  728.             win_oldprompts[2] = potparam[1];
  729.             win_oldprompts[3] = potparam[2];
  730.             win_oldprompts[4] = win_temp2;
  731.             win_oldprompts[5] = usr_distest;
  732.             win_oldprompts[6] = distestwidth;
  733.             win_oldprompts[7] = inversion[0];
  734.             win_oldprompts[8] = inversion[1];
  735.             win_oldprompts[9] = inversion[2];
  736.             return (TRUE);
  737.  
  738.         case WM_COMMAND:
  739.             switch (wParam) {
  740.  
  741.                 case IDOK:
  742.                     /* retrieve and validate the results */
  743.                     finattract = win_temp1;
  744.                     GetDlgItemText(hDlg, ID_POTENTMAX, temp, 10);
  745.                     potparam[0] = atof(temp);
  746.                     GetDlgItemText(hDlg, ID_POTENTSLOPE, temp, 10);
  747.                     potparam[1] = atof(temp);
  748.                     GetDlgItemText(hDlg, ID_POTENTBAIL, temp, 10);
  749.                     potparam[2] = atof(temp);
  750.                     pot16bit = win_temp2;
  751.                     GetDlgItemText(hDlg, ID_DISTEST, temp, 10);
  752.                     usr_distest = atoi(temp);
  753.                     GetDlgItemText(hDlg, ID_DISTESTWID, temp, 10);
  754.                     distestwidth = atoi(temp);
  755.                     for (i = 0; i < 3; i++) {
  756.                         GetDlgItemText(hDlg, ID_INVERTRAD+i, temp, 20);
  757.                         if (temp[0] == 'a' || temp[0] == 'A')
  758.                             inversion[i] = AUTOINVERT;
  759.                         else
  760.                             inversion[i] = atof(temp);
  761.                         }
  762.                     invert = (inversion[0] == 0.0) ? 0 : 3;
  763.                     GetDlgItemText(hDlg, ID_COLORMIN, temp, 10);
  764.                     rotate_lo = atoi(temp);
  765.                     GetDlgItemText(hDlg, ID_COLORMAX, temp, 10);
  766.                     rotate_hi = atoi(temp);
  767.                     if (rotate_lo < 0 || rotate_hi > 255 || rotate_lo > rotate_hi) {
  768.                         rotate_lo = 0;
  769.                         rotate_hi = 255;
  770.                         }
  771.                     time_to_restart = 0;
  772.                     if (
  773.                         win_oldprompts[0] != win_temp1   ||
  774.                         win_oldprompts[1] != potparam[0]  ||
  775.                         win_oldprompts[2] != potparam[1]  ||
  776.                         win_oldprompts[3] != potparam[2]  ||
  777.                         win_oldprompts[4] != win_temp2    ||
  778.                         win_oldprompts[5] != usr_distest  ||
  779.                         win_oldprompts[6] != distestwidth ||
  780.                         win_oldprompts[7] != inversion[0] ||
  781.                         win_oldprompts[8] != inversion[1] ||
  782.                         win_oldprompts[9] != inversion[2]
  783.                         ) time_to_restart = 1;
  784.                     EndDialog(hDlg, time_to_restart);
  785.                     break;
  786.                   
  787.                 case IDCANCEL:
  788.                     EndDialog(hDlg, 0);
  789.                     break;
  790.  
  791.                 case ID_FINITE:
  792.                     if (win_temp1 == 0)
  793.                         win_temp1 = 1;
  794.                     else
  795.                         win_temp1 = 0;
  796.                     CheckDlgButton(hDlg, ID_FINITE, win_temp1);
  797.                     break;
  798.  
  799.                 case ID_POTENT16:
  800.                     if (win_temp2 == 0)
  801.                         win_temp2 = 1;
  802.                     else
  803.                         win_temp2 = 0;
  804.                     CheckDlgButton(hDlg, ID_POTENT16, win_temp2);
  805.                     break;
  806.  
  807.                 }
  808.         
  809.         }
  810.     return (FALSE);
  811. }
  812.  
  813.  
  814. BOOL FAR PASCAL SelectSavePar(hDlg, message, wParam, lParam)
  815. HWND hDlg;
  816. unsigned message;
  817. WORD wParam;
  818. LONG lParam;
  819. {
  820.    char temp[80];
  821.    int i, j, k;
  822.    extern int  colorstate;     /* comments in cmdfiles */
  823.    extern char CommandFile[];
  824.    extern char CommandName[];
  825.    extern char far CommandComment1[];
  826.    extern char far CommandComment2[];
  827.    extern char colorfile[];
  828.    extern int  colorstate;
  829.    extern    int    usr_distest;    /* distance estimator option */
  830.    extern int  potflag;            /* continuous potential flag */
  831.    extern    double    potparam[3];    /* three potential parameters*/
  832.  
  833.     switch (message) {
  834.  
  835.         case WM_INITDIALOG:
  836.             win_temp1 = 1;
  837.             if (colorstate == 1)
  838.                 win_temp1 = 1;
  839.             if (colorstate == 2)
  840.                 win_temp1 = 2;
  841.             win_temp2 = colors - 1;
  842.             if (maxiter < win_temp2) win_temp2 = maxiter;
  843.             if (inside  > 0 && inside    > win_temp2) win_temp2 = inside;
  844.             if (outside > 0 && outside   > win_temp2) win_temp2 = outside;
  845.             if (usr_distest < 0 && 0-usr_distest > win_temp2) win_temp2 = 0-usr_distest;
  846.             if (decomp > win_temp2) win_temp2 = decomp - 1;
  847.             if (potflag && potparam[0] >= win_temp2) win_temp2 = potparam[0];
  848.             if (++win_temp2 > 256) win_temp2 = 256;
  849.         SetDlgItemText(hDlg, ID_PFILE, CommandFile);
  850.         SetDlgItemText(hDlg, ID_PENTRY, CommandName);
  851.         if (CommandName[0] == 0)
  852.             SetDlgItemText(hDlg, ID_PENTRY, "test");
  853.         SetDlgItemText(hDlg, ID_PCOM1, CommandComment1);
  854.         SetDlgItemText(hDlg, ID_PCOM2, CommandComment2);
  855.             CheckDlgButton(hDlg, ID_PCOL1+win_temp1, 1);
  856.             sprintf(temp,"%i",win_temp2);
  857.         SetDlgItemText(hDlg, ID_PCNUM, temp);
  858.         if (colorstate == 2)
  859.             SetDlgItemText(hDlg, ID_PCFILE, colorfile);
  860.             return (TRUE);
  861.  
  862.         case WM_COMMAND:
  863.             switch (wParam) {
  864.  
  865.                 case IDOK:
  866.                     /* retrieve and validate the results */
  867.                     GetDlgItemText(hDlg, ID_PFILE, CommandFile,     50);
  868.                     GetDlgItemText(hDlg, ID_PENTRY, CommandName,    50);
  869.                     GetDlgItemText(hDlg, ID_PCOM1, CommandComment1, 57);
  870.                     GetDlgItemText(hDlg, ID_PCOM2, CommandComment2, 57);
  871.                     GetDlgItemText(hDlg, ID_PCFILE, colorfile,      50);
  872.                     EndDialog(hDlg, 1);
  873.                     break;
  874.                   
  875.                 case IDCANCEL:
  876.                     EndDialog(hDlg, 0);
  877.                     break;
  878.  
  879.                 case ID_PCOL1:
  880.                 case ID_PCOL2:
  881.                 case ID_PCOL3:
  882.                     win_temp1 = wParam - ID_PCOL1;
  883.                     CheckRadioButton(hDlg, ID_PCOL1, ID_PCOL3, wParam);
  884.                 }
  885.         
  886.         }
  887.     return (FALSE);
  888. }
  889.  
  890.  
  891. int win_cycledir = -1, win_cyclerand = 0, win_cyclefreq = 0, win_cycledelay = 0;
  892. int win_tempcycle, win_tempcycledir, win_tempcyclerand, win_tempcyclefreq;
  893.  
  894. BOOL FAR PASCAL SelectCycle(hDlg, message, wParam, lParam)
  895. HWND hDlg;
  896. unsigned message;
  897. WORD wParam;
  898. LONG lParam;
  899. {
  900.     switch (message) {
  901.  
  902.         case WM_INITDIALOG:
  903.             win_tempcycle = time_to_cycle;
  904.             win_tempcycledir = win_cycledir;
  905.             win_tempcyclerand = win_cyclerand;
  906.             win_tempcyclefreq = win_cyclefreq;
  907.             if (win_tempcycle == 0)
  908.                 CheckDlgButton(hDlg, ID_CYCLEOFF, 1);
  909.             else
  910.                 CheckDlgButton(hDlg, ID_CYCLEON, 1);
  911.             if (win_tempcycledir == -1)
  912.                 CheckDlgButton(hDlg, ID_CYCLEOUT, 1);
  913.             else
  914.                 CheckDlgButton(hDlg, ID_CYCLEIN, 1);
  915.             if (win_tempcyclerand == 0)
  916.                 CheckDlgButton(hDlg, ID_CYCLESTAT, 1);
  917.             else
  918.                 CheckDlgButton(hDlg, ID_CYCLECHG, 1);
  919.             if (win_tempcyclefreq == 0)
  920.                 CheckDlgButton(hDlg, ID_CYCLELOW, 1);
  921.             else if (win_tempcyclefreq == 1)
  922.                 CheckDlgButton(hDlg, ID_CYCLEMED, 1);
  923.             else
  924.                 CheckDlgButton(hDlg, ID_CYCLEHIGH, 1);
  925.             return (TRUE);
  926.  
  927.         case WM_COMMAND:
  928.             switch (wParam) {
  929.  
  930.                 case IDOK:
  931.                     /* retrieve and validate the results */
  932.                     time_to_cycle = win_tempcycle;
  933.                     win_cycledir = win_tempcycledir;
  934.                     win_cyclerand = win_tempcyclerand;
  935.                     win_cyclefreq = win_tempcyclefreq;
  936.                     EndDialog(hDlg, 1);
  937.                     break;
  938.                   
  939.                 case IDCANCEL:
  940.                     EndDialog(hDlg, 0);
  941.                     break;
  942.  
  943.                 case ID_CYCLEOFF:
  944.                     win_tempcycle = 0;
  945.                     CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEOFF);
  946.                     break;
  947.  
  948.                 case ID_CYCLEON:
  949.                     win_tempcycle = 1;
  950.                     CheckRadioButton(hDlg, ID_CYCLEOFF, ID_CYCLEON, ID_CYCLEON);
  951.                     break;
  952.  
  953.                 case ID_CYCLEOUT:
  954.                     win_tempcycledir = -1;
  955.                     CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEOUT);
  956.                     break;
  957.  
  958.                 case ID_CYCLEIN:
  959.                     win_tempcycledir = 1;
  960.                     CheckRadioButton(hDlg, ID_CYCLEOUT, ID_CYCLEIN, ID_CYCLEIN);
  961.                     break;
  962.  
  963.                 case ID_CYCLESTAT:
  964.                     win_tempcyclerand = 0;
  965.                     CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLESTAT);
  966.                     break;
  967.  
  968.                 case ID_CYCLECHG:
  969.                     win_tempcyclerand = 1;
  970.                     CheckRadioButton(hDlg, ID_CYCLESTAT, ID_CYCLECHG, ID_CYCLECHG);
  971.                     break;
  972.  
  973.                 case ID_CYCLELOW:
  974.                     win_tempcyclefreq = 0;
  975.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLELOW);
  976.                     break;
  977.  
  978.                 case ID_CYCLEMED:
  979.                     win_tempcyclefreq = 1;
  980.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEMED);
  981.                     break;
  982.  
  983.                 case ID_CYCLEHIGH:
  984.                     win_tempcyclefreq = 2;
  985.                     CheckRadioButton(hDlg, ID_CYCLELOW, ID_CYCLEHIGH, ID_CYCLEHIGH);
  986.                     break;
  987.  
  988.                 }
  989.         
  990.         }
  991.     return (FALSE);
  992. }
  993.  
  994. FARPROC lpSelectFullScreen;
  995.  
  996. extern HANDLE hInst;
  997.  
  998. int win_fullscreen_count;
  999. char * far win_fullscreen_prompts[20];
  1000. char *win_fullscreen_heading;
  1001. static struct fullscreenvalues win_fullscreen_values[20];
  1002.  
  1003. int xxx_fullscreen_prompt(    /* full-screen prompting routine */
  1004.     char *hdg,        /* heading, lines separated by \n */
  1005.     int numprompts,     /* there are this many prompts (max) */
  1006.     char * far *prompts,    /* array of prompting pointers */
  1007.     struct fullscreenvalues values[], /* array of values */
  1008.     int options,        /* future use bits in case we need them */
  1009.     int fkeymask        /* bit n on if Fn to cause return */
  1010.     )
  1011. {
  1012. int i;
  1013. int Return;
  1014.  
  1015. win_fullscreen_count = numprompts;
  1016. win_fullscreen_heading = hdg;
  1017. win_fullscreen_count = numprompts;
  1018. for (i = 0; i < win_fullscreen_count; i++) {
  1019.    win_fullscreen_prompts[i] = prompts[i]; 
  1020.    win_fullscreen_values[i]  = values[i];
  1021.    }
  1022.  
  1023. lpSelectFullScreen = MakeProcInstance(SelectFullScreen, hInst);
  1024. Return = DialogBox(hInst, "SelectFullScreen", hwnd, lpSelectFullScreen);
  1025. FreeProcInstance(lpSelectFullScreen);
  1026.  
  1027. if (Return) {
  1028.     for (i = 0; i < win_fullscreen_count; i++) {
  1029.         values[i] = win_fullscreen_values[i];
  1030.     }
  1031.     return(0);
  1032.     }
  1033.  
  1034. return(-1);
  1035. }
  1036.  
  1037. BOOL FAR PASCAL SelectFullScreen(hDlg, message, wParam, lParam)
  1038. HWND hDlg;
  1039. unsigned message;
  1040. WORD wParam;
  1041. LONG lParam;
  1042. {
  1043.  
  1044.     int i;
  1045.     char temp[80];
  1046.  
  1047.     switch (message) {
  1048.  
  1049.         case WM_INITDIALOG:
  1050.             SetDlgItemText(hDlg, ID_PROMPT00,win_fullscreen_heading);
  1051.             for (i = 0; i < win_fullscreen_count; i++) {
  1052.                 SetDlgItemText(hDlg, ID_PROMPT01+i,win_fullscreen_prompts[i]);
  1053.                 if (win_fullscreen_values[i].type == 'd' ||
  1054.                     win_fullscreen_values[i].type == 'f')
  1055.                     sprintf(temp,"%10.5f",win_fullscreen_values[i].uval.dval);
  1056.                 else if(win_fullscreen_values[i].type == 'i')
  1057.                     sprintf(temp,"%d",win_fullscreen_values[i].uval.ival);
  1058.                 else if(win_fullscreen_values[i].type == 's')
  1059.                 {
  1060.                     strncpy(temp,win_fullscreen_values[i].uval.sval,16);
  1061.                     temp[15] = 0;
  1062.                 }
  1063.                 else if(win_fullscreen_values[i].type == 'l')
  1064.                     strcpy(temp,win_fullscreen_values[i].uval.ch.list[win_fullscreen_values[i].uval.ch.val]);
  1065.                 else
  1066.                     strcpy(temp,win_fullscreen_values[i].uval.sval);
  1067.                 SetDlgItemText(hDlg, ID_ANSWER01+i,temp);
  1068.                 }
  1069.             return (TRUE);
  1070.  
  1071.         case WM_COMMAND:
  1072.             switch (wParam) {
  1073.  
  1074.                 case IDOK:
  1075.                     for (i = 0; i < win_fullscreen_count; i++) {
  1076.                         GetDlgItemText(hDlg, ID_ANSWER01+i , temp, 20);
  1077.                         if (win_fullscreen_values[i].type == 'd' ||
  1078.                             win_fullscreen_values[i].type == 'f')
  1079.                             win_fullscreen_values[i].uval.dval = atof(temp);
  1080.                         else if(win_fullscreen_values[i].type == 'i')
  1081.                             win_fullscreen_values[i].uval.ival = atoi(temp);
  1082.                         else if(win_fullscreen_values[i].type == 's')
  1083.                             strncpy(win_fullscreen_values[i].uval.sval,temp,16);
  1084.                         else if(win_fullscreen_values[i].type == 'l')
  1085.                             strcpy(win_fullscreen_values[i].uval.ch.list[win_fullscreen_values[i].uval.ch.val],temp);
  1086.                         else
  1087.                             strcpy(win_fullscreen_values[i].uval.sval,temp);
  1088.                     }
  1089.                     EndDialog(hDlg, 1);
  1090.                     break;
  1091.                   
  1092.                 case IDCANCEL:
  1093.                     EndDialog(hDlg, 0);
  1094.                     break;
  1095.  
  1096.                 }
  1097.         
  1098.         }
  1099.     return (FALSE);
  1100. }
  1101.  
  1102.  
  1103. extern int init3d[];
  1104. extern int win_3dspherical;
  1105. extern char preview, showbox;
  1106. extern int previewfactor, glassestype, whichimage;
  1107. extern int xtrans, ytrans, transparent[2], RANDOMIZE;
  1108. extern int red_crop_left, red_crop_right;
  1109. extern int blue_crop_left, blue_crop_right;
  1110. extern int red_bright, blue_bright;
  1111. extern    int RAY;
  1112. extern    int BRIEF;
  1113. extern    int Ambient;
  1114. extern    char ray_name[];
  1115. extern int Targa_Overlay;
  1116. extern int Targa_Out;
  1117. extern    int    overlay3d;        /* 3D overlay flag: 0 = OFF */
  1118. extern int xadjust;
  1119. extern int eyeseparation;
  1120.  
  1121. static int far win_answers[20];
  1122.  
  1123. BOOL FAR PASCAL Select3D(hDlg, message, wParam, lParam)
  1124. HWND hDlg;
  1125. unsigned message;
  1126. WORD wParam;
  1127. LONG lParam;
  1128. {
  1129.  
  1130.     int i;
  1131.     char temp[80];
  1132.  
  1133.     switch (message) {
  1134.  
  1135.         case WM_INITDIALOG:
  1136.             win_answers[0] = preview;
  1137.             win_answers[1] = showbox;
  1138.             win_answers[2] = SPHERE;
  1139.             win_answers[3] = previewfactor;
  1140.             win_answers[4] = glassestype;
  1141.             win_answers[5] = FILLTYPE+1;
  1142.             win_answers[6] = RAY;
  1143.             win_answers[7] = BRIEF;
  1144.             win_answers[8] = Targa_Out;
  1145.             CheckDlgButton(hDlg, ID_PREVIEW, win_answers[0]);
  1146.             CheckDlgButton(hDlg, ID_SHOWBOX, win_answers[1]);
  1147.             CheckDlgButton(hDlg, ID_SPHERICAL, win_answers[2]);
  1148.             CheckDlgButton(hDlg, ID_RAYB, win_answers[7]);
  1149. /*
  1150.             CheckDlgButton(hDlg, ID_TARGA, win_answers[8]);
  1151. */
  1152.             sprintf(temp,"%d",win_answers[3]);
  1153.         SetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp);
  1154.             CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  1155.                 ID_STEREO1+win_answers[4]);
  1156.             CheckRadioButton(hDlg, ID_FILL1, ID_FILL8,
  1157.                 ID_FILL1+win_answers[5]);
  1158.             CheckRadioButton(hDlg, ID_RAY0, ID_RAY6,
  1159.                 ID_RAY0+win_answers[6]);
  1160.             check_writefile(ray_name,".ray");
  1161.         SetDlgItemText(hDlg, ID_RAYN, ray_name);
  1162.             return (TRUE);
  1163.  
  1164.         case WM_COMMAND:
  1165.             switch (wParam) {
  1166.  
  1167.                 case IDOK:
  1168.                     if(win_answers[2] != SPHERE) {
  1169.                         SPHERE = win_answers[2];
  1170.                         set_3d_defaults();
  1171.                         }
  1172.                     preview = win_answers[0];
  1173.                     showbox = win_answers[1];
  1174.                     SPHERE  = win_answers[2];
  1175.                     RAY     = win_answers[6];
  1176.                     BRIEF   = win_answers[7];
  1177.                     Targa_Out = win_answers[8];
  1178.                     GetDlgItemText(hDlg, ID_PREVIEWFACTOR, temp, 10);
  1179.                     GetDlgItemText(hDlg, ID_RAYN, temp, 30);
  1180.                     strcpy(ray_name, temp);
  1181.                     previewfactor = atoi(temp);
  1182.                     glassestype = win_answers[4];
  1183.                     FILLTYPE = win_answers[5]-1;
  1184.                     win_3dspherical = SPHERE;
  1185.                     if(previewfactor < 8)
  1186.                        previewfactor = 8;
  1187.                     if(previewfactor > 128)
  1188.                        previewfactor = 128;
  1189.                     if(glassestype < 0)
  1190.                        glassestype = 0;
  1191.                     if(glassestype > 3)
  1192.                        glassestype = 3;
  1193.                     whichimage = 0;
  1194.                     if(glassestype)
  1195.                        whichimage = 1;
  1196.                     if (Targa_Out && overlay3d)
  1197.                        Targa_Overlay = 1;
  1198.                     EndDialog(hDlg, 1);
  1199.                     break;
  1200.                     
  1201.                 case ID_PREVIEW:
  1202.                 case ID_SHOWBOX:
  1203.                 case ID_SPHERICAL:
  1204.                     i = wParam - ID_PREVIEW;
  1205.                     win_answers[i] = 1 - win_answers[i];
  1206.                     CheckDlgButton(hDlg, ID_PREVIEW + i, win_answers[i]);
  1207.                     break;
  1208.  
  1209.                 case ID_FILL1:
  1210.                 case ID_FILL2:
  1211.                 case ID_FILL3:
  1212.                 case ID_FILL4:
  1213.                 case ID_FILL5:
  1214.                 case ID_FILL6:
  1215.                 case ID_FILL7:
  1216.                 case ID_FILL8:
  1217.                     i = wParam - ID_FILL1;
  1218.                     win_answers[5] = i;
  1219.                     CheckRadioButton(hDlg, ID_FILL1, ID_FILL8,
  1220.                         ID_FILL1+win_answers[5]);
  1221.                     break;
  1222.  
  1223.                 case ID_STEREO1:
  1224.                 case ID_STEREO2:
  1225.                 case ID_STEREO3:
  1226.                 case ID_STEREO4:
  1227.                     i = wParam - ID_STEREO1;
  1228.                     win_answers[4] = i;
  1229.                     CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  1230.                         ID_STEREO1+win_answers[4]);
  1231.                     break;
  1232.  
  1233.                 case ID_RAY0:
  1234.                 case ID_RAY1:
  1235.                 case ID_RAY2:
  1236.                 case ID_RAY3:
  1237.                 case ID_RAY4:
  1238.                 case ID_RAY5:
  1239.                 case ID_RAY6:
  1240.                     i = wParam - ID_RAY0;
  1241.                     win_answers[6] = i;
  1242.                     CheckRadioButton(hDlg, ID_RAY0, ID_RAY6,
  1243.                         ID_RAY0+win_answers[6]);
  1244.                     break;
  1245.  
  1246.                 case ID_RAYB:
  1247.                     win_answers[7] = 1 - win_answers[7];
  1248.                     CheckDlgButton(hDlg, ID_RAYB, win_answers[7]);
  1249.                     break;
  1250.  
  1251.                 case ID_TARGA:
  1252.                     win_answers[8] = 1 - win_answers[8];
  1253.                     CheckDlgButton(hDlg, ID_TARGA, win_answers[8]);
  1254.                     break;
  1255.  
  1256.                 case IDCANCEL:
  1257.                     EndDialog(hDlg, 0);
  1258.                     break;
  1259.  
  1260.                 }
  1261.         
  1262.         }
  1263.     return (FALSE);
  1264. }
  1265.  
  1266. BOOL FAR PASCAL Select3DPlanar(hDlg, message, wParam, lParam)
  1267. HWND hDlg;
  1268. unsigned message;
  1269. WORD wParam;
  1270. LONG lParam;
  1271. {
  1272.  
  1273.     int i;
  1274.     char temp[80];
  1275.  
  1276.     switch (message) {
  1277.  
  1278.         case WM_INITDIALOG:
  1279.             win_answers[0] = XROT;
  1280.             win_answers[1] = YROT;
  1281.             win_answers[2] = ZROT;
  1282.             win_answers[3] = XSCALE;
  1283.             win_answers[4] = YSCALE;
  1284.             win_answers[5] = ROUGH;
  1285.             win_answers[6] = WATERLINE;
  1286.             win_answers[7] = ZVIEWER;
  1287.             win_answers[8] = XSHIFT;
  1288.             win_answers[9] = YSHIFT;
  1289.             win_answers[10] = xtrans;
  1290.             win_answers[11] = ytrans;
  1291.             win_answers[12] = transparent[0];
  1292.             win_answers[13] = transparent[1];
  1293.             win_answers[14] = RANDOMIZE;
  1294.             for (i = 0; i < 15; i++) {
  1295.                 sprintf(temp,"%d", win_answers[i]);
  1296.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1297.                 }
  1298.             return (TRUE);
  1299.  
  1300.         case WM_COMMAND:
  1301.             switch (wParam) {
  1302.  
  1303.                 case IDOK:
  1304.                     for (i = 0; i < 15; i++) {
  1305.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 20);
  1306.                         win_answers[i] = atof(temp);
  1307.                         }
  1308.                     XROT =           win_answers[0];
  1309.                     YROT =           win_answers[1];
  1310.                     ZROT =           win_answers[2];
  1311.                     XSCALE =         win_answers[3];
  1312.                     YSCALE =         win_answers[4];
  1313.                     ROUGH =          win_answers[5];
  1314.                     WATERLINE =      win_answers[6];
  1315.                     ZVIEWER =        win_answers[7];
  1316.                     XSHIFT =         win_answers[8];
  1317.                     YSHIFT =         win_answers[9];
  1318.                     xtrans =         win_answers[10];
  1319.                     ytrans =         win_answers[11];
  1320.                     transparent[0] = win_answers[12];
  1321.                     transparent[1] = win_answers[13];
  1322.                     RANDOMIZE =      win_answers[14];
  1323.                     if (RANDOMIZE >= 7) RANDOMIZE = 7;
  1324.                     if (RANDOMIZE <= 0) RANDOMIZE = 0;
  1325.                     EndDialog(hDlg, 1);
  1326.                     break;
  1327.                   
  1328.                 case IDCANCEL:
  1329.                     EndDialog(hDlg, 0);
  1330.                     break;
  1331.  
  1332.                 }
  1333.         
  1334.         }
  1335.     return (FALSE);
  1336. }
  1337.  
  1338.  
  1339. BOOL FAR PASCAL SelectIFS3D(hDlg, message, wParam, lParam)
  1340. HWND hDlg;
  1341. unsigned message;
  1342. WORD wParam;
  1343. LONG lParam;
  1344. {
  1345.  
  1346.     int i, numanswers;
  1347.     char temp[80];
  1348.  
  1349.     numanswers = 5;
  1350.  
  1351.     switch (message) {
  1352.  
  1353.         case WM_INITDIALOG:
  1354.             win_answers[0] = XROT;
  1355.             win_answers[1] = YROT;
  1356.             win_answers[2] = ZROT;
  1357.             win_answers[3] = ZVIEWER;
  1358.             win_answers[4] = XSHIFT;
  1359.             win_answers[5] = YSHIFT;
  1360.             win_answers[6] = glassestype;
  1361.             for (i = 0; i <= numanswers; i++) {
  1362.                 sprintf(temp,"%d", win_answers[i]);
  1363.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1364.                 }
  1365.             CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  1366.                 ID_STEREO1+win_answers[6]);
  1367.             return (TRUE);
  1368.  
  1369.         case WM_COMMAND:
  1370.             switch (wParam) {
  1371.  
  1372.                 case ID_STEREO1:
  1373.                 case ID_STEREO2:
  1374.                 case ID_STEREO3:
  1375.                 case ID_STEREO4:
  1376.                     i = wParam - ID_STEREO1;
  1377.                     win_answers[6] = i;
  1378.                     CheckRadioButton(hDlg, ID_STEREO1, ID_STEREO4,
  1379.                         ID_STEREO1+win_answers[6]);
  1380.                     break;
  1381.  
  1382.                 case IDOK:
  1383.                     for (i = 0; i <= numanswers; i++) {
  1384.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 20);
  1385.                         win_answers[i] = atof(temp);
  1386.                         }
  1387.                     XROT =           win_answers[0];
  1388.                     YROT =           win_answers[1];
  1389.                     ZROT =           win_answers[2];
  1390.                     ZVIEWER =        win_answers[3];
  1391.                     XSHIFT =         win_answers[4];
  1392.                     YSHIFT =         win_answers[5];
  1393.                     glassestype =    win_answers[6];
  1394.                     EndDialog(hDlg, 1);
  1395.                     break;
  1396.                   
  1397.                 case IDCANCEL:
  1398.                     EndDialog(hDlg, 0);
  1399.                     break;
  1400.  
  1401.                 }
  1402.         
  1403.         }
  1404.     return (FALSE);
  1405. }
  1406.  
  1407. char win_funnyglasses_map_name[41];
  1408.  
  1409. BOOL FAR PASCAL SelectFunnyGlasses(hDlg, message, wParam, lParam)
  1410. HWND hDlg;
  1411. unsigned message;
  1412. WORD wParam;
  1413. LONG lParam;
  1414. {
  1415.  
  1416.     int i, numanswers;
  1417.     char temp[80];
  1418.  
  1419.     numanswers = 7;
  1420.  
  1421.     switch (message) {
  1422.  
  1423.         case WM_INITDIALOG:
  1424.  
  1425.         /* defaults */
  1426.             if(ZVIEWER == 0)
  1427.                ZVIEWER = 150;
  1428.             if(eyeseparation == 0) {
  1429.                if(fractype==IFS3D || fractype==LLORENZ3D || fractype==FPLORENZ3D) {
  1430.                    eyeseparation =  2;
  1431.               xadjust       = -2;
  1432.                   }
  1433.                else {
  1434.               eyeseparation =  3;
  1435.               xadjust       =  0;
  1436.                   }
  1437.                }
  1438.  
  1439.             win_funnyglasses_map_name[0] = 0;
  1440.             if(glassestype == 1)
  1441.                 strcpy(win_funnyglasses_map_name,"glasses1.map");
  1442.             else if(glassestype == 2) {
  1443.                 if(FILLTYPE == -1)
  1444.                      strcpy(win_funnyglasses_map_name,"grid.map");
  1445.                 else
  1446.                 strcpy(win_funnyglasses_map_name,"glasses2.map");
  1447.                 }
  1448.  
  1449.             win_answers[0] = eyeseparation;
  1450.             win_answers[1] = xadjust;
  1451.             win_answers[2] = red_crop_left;
  1452.             win_answers[3] = red_crop_right;
  1453.             win_answers[4] = blue_crop_left;
  1454.             win_answers[5] = blue_crop_right;
  1455.             win_answers[6] = red_bright;
  1456.             win_answers[7] = blue_bright;
  1457.             for (i = 0; i < numanswers+1;i++) {
  1458.                 sprintf(temp,"%d", win_answers[i]);
  1459.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1460.                 }
  1461.             SetDlgItemText(hDlg, ID_ANS9,win_funnyglasses_map_name);
  1462.             return (TRUE);
  1463.  
  1464.         case WM_COMMAND:
  1465.             switch (wParam) {
  1466.  
  1467.                 case IDOK:
  1468.                     for (i = 0; i < numanswers+1; i++) {
  1469.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 20);
  1470.                         win_answers[i] = atof(temp);
  1471.                         }
  1472.                     GetDlgItemText(hDlg, ID_ANS9, temp, 40);
  1473.                     strcpy(win_funnyglasses_map_name, temp);
  1474.                     eyeseparation   =  win_answers[0];
  1475.                     xadjust         =  win_answers[1];
  1476.                     red_crop_left   =  win_answers[2];
  1477.                     red_crop_right  =  win_answers[3];
  1478.                     blue_crop_left  =  win_answers[4];
  1479.                     blue_crop_right =  win_answers[5];
  1480.                     red_bright      =  win_answers[6];
  1481.                     blue_bright     =  win_answers[7];
  1482.                     EndDialog(hDlg, 1);
  1483.                     break;
  1484.                   
  1485.                 case IDCANCEL:
  1486.                     EndDialog(hDlg, 0);
  1487.                     break;
  1488.  
  1489.                 }
  1490.         
  1491.         }
  1492.     return (FALSE);
  1493. }
  1494.  
  1495. BOOL FAR PASCAL SelectLightSource(hDlg, message, wParam, lParam)
  1496. HWND hDlg;
  1497. unsigned message;
  1498. WORD wParam;
  1499. LONG lParam;
  1500. {
  1501.  
  1502.     int i, numanswers;
  1503.     char temp[80];
  1504.  
  1505.     numanswers = 5;
  1506.  
  1507.     switch (message) {
  1508.  
  1509.         case WM_INITDIALOG:
  1510.             win_answers[0] = XLIGHT;
  1511.             win_answers[1] = YLIGHT;
  1512.             win_answers[2] = ZLIGHT;
  1513.             win_answers[3] = LIGHTAVG;
  1514.             win_answers[4] = Ambient;
  1515.             for (i = 0; i < numanswers+1;i++) {
  1516.                 sprintf(temp,"%d", win_answers[i]);
  1517.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1518.                 }
  1519.             return (TRUE);
  1520.  
  1521.         case WM_COMMAND:
  1522.             switch (wParam) {
  1523.  
  1524.                 case IDOK:
  1525.                     for (i = 0; i < numanswers+1; i++) {
  1526.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 20);
  1527.                         win_answers[i] = atof(temp);
  1528.                         }
  1529.                     XLIGHT   =  win_answers[0];
  1530.                     YLIGHT   =  win_answers[1];
  1531.                     ZLIGHT   =  win_answers[2];
  1532.                     LIGHTAVG =  win_answers[3];
  1533.                     Ambient  =  win_answers[4];
  1534.                     EndDialog(hDlg, 1);
  1535.                     break;
  1536.                   
  1537.                 case IDCANCEL:
  1538.                     EndDialog(hDlg, 0);
  1539.                     break;
  1540.  
  1541.                 }
  1542.         
  1543.         }
  1544.     return (FALSE);
  1545. }
  1546.  
  1547. BOOL FAR PASCAL Select3DSpherical(hDlg, message, wParam, lParam)
  1548. HWND hDlg;
  1549. unsigned message;
  1550. WORD wParam;
  1551. LONG lParam;
  1552. {
  1553.  
  1554.     int i;
  1555.     char temp[80];
  1556.  
  1557.     switch (message) {
  1558.  
  1559.         case WM_INITDIALOG:
  1560.             win_answers[0] = XROT;
  1561.             win_answers[1] = YROT;
  1562.             win_answers[2] = ZROT;
  1563.             win_answers[3] = XSCALE;
  1564.             win_answers[4] = YSCALE;
  1565.             win_answers[5] = ROUGH;
  1566.             win_answers[6] = WATERLINE;
  1567.             win_answers[7] = ZVIEWER;
  1568.             win_answers[8] = XSHIFT;
  1569.             win_answers[9] = YSHIFT;
  1570.             win_answers[10] = xtrans;
  1571.             win_answers[11] = ytrans;
  1572.             win_answers[12] = transparent[0];
  1573.             win_answers[13] = transparent[1];
  1574.             win_answers[14] = RANDOMIZE;
  1575.             for (i = 0; i < 15; i++) {
  1576.                 sprintf(temp,"%d", win_answers[i]);
  1577.                 SetDlgItemText(hDlg, ID_ANS1+i,temp);
  1578.                 }
  1579.             return (TRUE);
  1580.  
  1581.         case WM_COMMAND:
  1582.             switch (wParam) {
  1583.  
  1584.                 case IDOK:
  1585.                     for (i = 0; i < 15; i++) {
  1586.                         GetDlgItemText(hDlg, ID_ANS1+i, temp, 10);
  1587.                         win_answers[i] = atof(temp);
  1588.                         }
  1589.                     XROT =           win_answers[0];
  1590.                     YROT =           win_answers[1];
  1591.                     ZROT =           win_answers[2];
  1592.                     XSCALE =         win_answers[3];
  1593.                     YSCALE =         win_answers[4];
  1594.                     ROUGH =          win_answers[5];
  1595.                     WATERLINE =      win_answers[6];
  1596.                     ZVIEWER =        win_answers[7];
  1597.                     XSHIFT =         win_answers[8];
  1598.                     YSHIFT =         win_answers[9];
  1599.                     xtrans =         win_answers[10];
  1600.                     ytrans =         win_answers[11];
  1601.                     transparent[0] = win_answers[12];
  1602.                     transparent[1] = win_answers[13];
  1603.                     RANDOMIZE =      win_answers[14];
  1604.                     if (RANDOMIZE >= 7) RANDOMIZE = 7;
  1605.                     if (RANDOMIZE <= 0) RANDOMIZE = 0;
  1606.                     EndDialog(hDlg, 1);
  1607.                     break;
  1608.                   
  1609.                 case IDCANCEL:
  1610.                     EndDialog(hDlg, 0);
  1611.                     break;
  1612.  
  1613.                 }
  1614.         
  1615.         }
  1616.     return (FALSE);
  1617. }
  1618.  
  1619. BOOL FAR PASCAL SelectStarfield(hDlg, message, wParam, lParam)
  1620. HWND hDlg;
  1621. unsigned message;
  1622. WORD wParam;
  1623. LONG lParam;
  1624. {
  1625. extern double starfield_values[4];
  1626.  
  1627.    switch (message) {
  1628.  
  1629.         case WM_INITDIALOG:
  1630.             SetDlgItemInt(hDlg, ID_NUMSTARS,   (int)starfield_values[0], FALSE);
  1631.             SetDlgItemInt(hDlg, ID_CLUMPINESS, (int)starfield_values[1], FALSE);
  1632.             SetDlgItemInt(hDlg, ID_DIMRATIO,   (int)starfield_values[2], FALSE);
  1633.             return (TRUE);
  1634.  
  1635.         case WM_COMMAND:
  1636.             switch (wParam) {
  1637.  
  1638.                 case IDOK:
  1639.                     starfield_values[0] = GetDlgItemInt(hDlg, ID_NUMSTARS,   NULL, FALSE);
  1640.                     starfield_values[1] = GetDlgItemInt(hDlg, ID_CLUMPINESS, NULL, FALSE);
  1641.                     starfield_values[2] = GetDlgItemInt(hDlg, ID_DIMRATIO,   NULL, FALSE);
  1642.                     EndDialog(hDlg, 1);
  1643.                     break;
  1644.                   
  1645.                 case IDCANCEL:
  1646.                     EndDialog(hDlg, 0);
  1647.                     break;
  1648.  
  1649.                 }
  1650.         
  1651.         }
  1652.     return (FALSE);
  1653. }
  1654.  
  1655. extern int time_to_save;
  1656. extern int gif87a_flag;
  1657. int FileFormat = 0;
  1658. FARPROC lpStatusBox = NULL;
  1659. HWND hStatusBox;
  1660. BOOL OperCancelled;
  1661. char far StatusTitle[80];
  1662.  
  1663. extern LPBITMAPINFO pDibInfo;
  1664. extern char huge *pixels;
  1665. extern LPLOGPALETTE pLogPal;
  1666.  
  1667. BOOL FAR PASCAL StatusBoxProc(HWND hDlg, unsigned Msg, WORD wParam,
  1668.                 LONG lParam)
  1669. {
  1670.    char PerStr[10];
  1671.    RECT Rect, TextRect;
  1672.    HWND hBar, hCancel;
  1673.    HDC hBarDC;
  1674.    unsigned Percent;
  1675.  
  1676.    switch(Msg)
  1677.    {
  1678.       case WM_INITDIALOG:
  1679.          SetWindowText(hDlg, StatusTitle);
  1680.          hCancel = GetDlgItem(hDlg, ID_CANCEL);
  1681.          SetFocus(hCancel);
  1682.          return(FALSE);
  1683.  
  1684.       case WM_CHAR:
  1685.          if(wParam == VK_RETURN || wParam == VK_ESCAPE)
  1686.             OperCancelled = TRUE;
  1687.          break;
  1688.  
  1689.       case WM_COMMAND:
  1690.  
  1691.          if(wParam == ID_CANCEL)
  1692.             OperCancelled = TRUE;
  1693.          break;
  1694.  
  1695.       case WM_USER:
  1696.          /* Invalidate Bar Window */
  1697.          hBar = GetDlgItem(hDlg, ID_PERCENT);
  1698.          GetClientRect(hBar, &TextRect);
  1699.  
  1700.          /* Calculate Percentage */
  1701.          hBarDC = GetDC(hBar);
  1702.          Percent = (unsigned)((lParam * 100) / wParam);
  1703.          if(Percent <= 100)
  1704.          {
  1705.             wsprintf(PerStr, "%d", Percent);
  1706.             strcat(PerStr, "%");
  1707.  
  1708.             /* Display Bar */
  1709.             Rect = TextRect;
  1710.             Rect.right = (unsigned)((((long)Percent) * Rect.right) / 100);
  1711.             Rect.top += 2;
  1712.             Rect.bottom -= 2;
  1713.             Rectangle(hBarDC, Rect.left, Rect.top, Rect.right, Rect.bottom);
  1714.  
  1715.             /* Display Percentage */
  1716.             DrawText(hBarDC, PerStr, lstrlen(PerStr), &TextRect,
  1717.                      DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  1718.          }
  1719.  
  1720.          ReleaseDC(hBar, hBarDC);
  1721.          break;
  1722.  
  1723.       case WM_DESTROY:
  1724.          break;
  1725.  
  1726.       default:
  1727.          return(FALSE);
  1728.    }
  1729.    return(TRUE);
  1730. }
  1731.  
  1732. void OpenStatusBox(HWND hWnd, HANDLE hInst)
  1733. {
  1734.    if(lpStatusBox == NULL)
  1735.       lpStatusBox = MakeProcInstance(StatusBoxProc, hInst);
  1736.    hStatusBox = CreateDialog(hInst, "StatusBox", hWnd, lpStatusBox);
  1737. }
  1738.  
  1739. void CloseStatusBox(void)
  1740. {
  1741.    DestroyWindow(hStatusBox);
  1742. }
  1743.  
  1744. void UpdateStatusBox(unsigned long Partial, unsigned long Total)
  1745. {
  1746.    if(Total > 0xffff)
  1747.    {
  1748.       Total >>= 16;
  1749.       Partial >>= 16;
  1750.    }
  1751.    SendMessage(hStatusBox, WM_USER, (unsigned)Total, Partial);
  1752. }
  1753.  
  1754. void center_window(HWND hchild, int xadj, int yadj)
  1755. {
  1756.     RECT crect,prect;
  1757.     int i,cwidth,cheight;
  1758.     POINT center;
  1759.     GetWindowRect(hchild, &crect);
  1760.     GetClientRect(hwnd, &prect);   /* main Fractint window */
  1761.     cwidth  = crect.right - crect.left;
  1762.     cheight = crect.bottom - crect.top;
  1763.     center.x = (prect.right + prect.left) / 2;
  1764.     center.y = (prect.bottom + prect.top) / 2;
  1765.     ClientToScreen(hwnd, ¢er);
  1766.     if ((center.x += xadj - (cwidth  / 2)) < 0) center.x = 0;
  1767.     if ((center.y += yadj - (cheight / 2)) < 0) center.y = 0;
  1768.     if ((i = GetSystemMetrics(SM_CXSCREEN) - cwidth ) < center.x) center.x = i;
  1769.     if ((i = GetSystemMetrics(SM_CYSCREEN) - cheight) < center.y) center.y = i;
  1770.     MoveWindow(hchild, center.x, center.y, cwidth, cheight, FALSE);
  1771. }
  1772.  
  1773. void SaveBitmapFile(HWND hWnd, char *FullPathName)
  1774. {
  1775.    long TotalSize, Saved = 0, ImageSize, n;
  1776.    BITMAPFILEHEADER FileHeader;
  1777.    unsigned PalSize, BitCount;
  1778.    unsigned BlockSize = 10240;
  1779.    int hFile;
  1780.    char Temp[128];
  1781.    OFSTRUCT OfStruct;
  1782.    HANDLE hPal;
  1783.    RGBQUAD FAR *Pal;
  1784.  
  1785.    hFile = OpenFile(FullPathName, &OfStruct, OF_CREATE);
  1786.    if(hFile == NULL)
  1787.    {
  1788. FileError:
  1789.       wsprintf(Temp, "File I/O error while saving %s.", (LPSTR)FullPathName);
  1790.       MessageBox(hWnd, Temp, "File Error . . .", MB_OK | MB_ICONEXCLAMATION);
  1791.  
  1792. GeneralError:
  1793.       _lclose(hFile);
  1794.       OpenFile(FullPathName, &OfStruct, OF_DELETE);
  1795.       CloseStatusBox();
  1796.       return;
  1797.    }
  1798.  
  1799.    BitCount = pDibInfo->bmiHeader.biBitCount;
  1800.    if(BitCount != 24)
  1801.       PalSize = (1 << BitCount) * sizeof(RGBQUAD);
  1802.    else
  1803.       PalSize = 0;
  1804.  
  1805.    ImageSize = pDibInfo->bmiHeader.biSizeImage;
  1806.    FileHeader.bfType = 0x4d42; /* 'BM'; */
  1807.    FileHeader.bfSize = sizeof(FileHeader) +
  1808.                        pDibInfo->bmiHeader.biSize +
  1809.                        PalSize + ImageSize;
  1810.    TotalSize = FileHeader.bfSize;
  1811.    FileHeader.bfReserved1 = FileHeader.bfReserved2 = 0;
  1812.    FileHeader.bfOffBits = FileHeader.bfSize - ImageSize;
  1813.    Saved += _lwrite(hFile, (LPSTR)&FileHeader, sizeof(FileHeader));
  1814.    Saved += _lwrite(hFile, (LPSTR)pDibInfo, (int)pDibInfo->bmiHeader.biSize);
  1815.    if(PalSize)
  1816.    {
  1817.       hPal = GlobalAlloc(GMEM_FIXED, PalSize);
  1818.       Pal = (RGBQUAD FAR *)GlobalLock(hPal);
  1819.       if(Pal == NULL)
  1820.       {
  1821.          MessageBox(hWnd, "Insufficient Memory", "Memory Error . . .",
  1822.                           MB_ICONEXCLAMATION | MB_OK);
  1823.          goto GeneralError;
  1824.       }
  1825.       for(n = 0; n < (1 << BitCount); n++)
  1826.       {
  1827.          Pal[n].rgbRed   = pLogPal->palPalEntry[n].peRed;
  1828.          Pal[n].rgbGreen = pLogPal->palPalEntry[n].peGreen;
  1829.          Pal[n].rgbBlue  = pLogPal->palPalEntry[n].peBlue;
  1830.          Pal[n].rgbReserved = 0;
  1831.       }
  1832.       Saved += _lwrite(hFile, (LPSTR)Pal, PalSize);
  1833.       GlobalUnlock(hPal);
  1834.       GlobalFree(hPal);
  1835.    }
  1836.    UpdateStatusBox(Saved, TotalSize);
  1837.    keypressed();
  1838.  
  1839.    /* We should have saved enough bytes to reach the image offset.  If not,
  1840.       then there was an error. */
  1841.    if(Saved != FileHeader.bfOffBits)
  1842.       goto FileError;
  1843.  
  1844.    for(n = 0; n < (ImageSize - BlockSize); n += BlockSize)
  1845.    {
  1846.       if(_lwrite(hFile, (LPSTR)&pixels[n], BlockSize) != BlockSize)
  1847.          goto FileError;
  1848.       Saved += BlockSize;
  1849.       UpdateStatusBox(Saved, TotalSize);
  1850.       keypressed();
  1851.       if(OperCancelled)
  1852.       {
  1853.          MessageBox(hWnd, "File save cancelled.", "Save Cancelled", MB_OK);
  1854.          goto GeneralError;
  1855.       }
  1856.    }
  1857.    Saved += _lwrite(hFile, (LPSTR)&pixels[n], (int)(ImageSize - n));
  1858.    if(Saved != TotalSize)
  1859.       goto FileError;
  1860.  
  1861.    UpdateStatusBox(Saved, TotalSize);
  1862.    _lclose(hFile);
  1863.    CloseStatusBox();
  1864. }
  1865.  
  1866. /* common dialog boxes */
  1867.  
  1868. static char far *win_common_type[] = {
  1869.     "BMP Files (*.BMP)|*.bmp|",
  1870.     "GIF Files (*.GIF)|*.gif|",
  1871.     "Palette Files (*.MAP)|*.map|",
  1872.     "Parameter Files (*.PAR)|*.par|",
  1873.     "IFS Files (*.IFS)|*.ifs|",
  1874.     "Formula Files (*.FRM)|*.frm|",
  1875.     "L-system Files (*.L)|*.l|",
  1876.     "Any File (*.*)|*.*|",
  1877.     };
  1878.     
  1879. static char *win_common_type2[] = {
  1880.     ".bmp",
  1881.     ".gif",
  1882.     ".map",
  1883.     ".par",
  1884.     ".ifs",
  1885.     ".frm",
  1886.     ".l",
  1887.     ""
  1888.     };
  1889.  
  1890. Win_OpenFile(unsigned char FileName[])
  1891. {
  1892. OPENFILENAME ofn;
  1893. char szFilter[128], szDirName[128], szFile[128], szFileTitle[128];
  1894. char chReplace;
  1895. int i;
  1896.  
  1897. szFilter[0] = '\0';
  1898. szDirName[0] = '\0';
  1899. szFile[0] = '\0';
  1900. szFileTitle[0] = '\0';
  1901.  
  1902. /* lstrcpy(szFile,FileName); */
  1903. /* GetSystemDirectory(szDirName, sizeof(szDirName)); */
  1904.  
  1905. for (i = 0; i < 7; i++)
  1906.     if (strcmp(DefExt,win_common_type2[i]) == 0)
  1907.         break;
  1908. lstrcpy(szFilter, win_common_type[i]);
  1909. lstrcat(szFilter, win_common_type[7]);
  1910. chReplace = szFilter[strlen(szFilter) - 1];
  1911. for (i = 0; szFilter[i] != '\0'; i++) {
  1912.     if (szFilter[i] == chReplace)
  1913.         szFilter[i] = '\0';
  1914.         }
  1915.  
  1916. memset(&ofn, 0, sizeof(OPENFILENAME));
  1917. ofn.lStructSize = sizeof(OPENFILENAME);
  1918. ofn.hwndOwner = hwnd;
  1919. ofn.lpstrFilter = szFilter;
  1920. ofn.nFilterIndex = 1;
  1921. ofn.lpstrFile = szFile;
  1922. ofn.nMaxFile = sizeof(szFile);
  1923. ofn.lpstrFileTitle = szFileTitle;
  1924. ofn.nMaxFileTitle = sizeof(szFileTitle);
  1925. ofn.lpstrInitialDir = szDirName;
  1926. ofn.lpstrTitle = DialogTitle;
  1927. ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
  1928.  
  1929. i = GetOpenFileName(&ofn);
  1930. lstrcpy(FileName,szFile);
  1931.  
  1932. return i;
  1933.  
  1934. }
  1935.  
  1936. Win_SaveFile(unsigned char FileName[])
  1937. {
  1938. OPENFILENAME ofn;
  1939. char szFilter[128], szDirName[128], szFile[128], szFileTitle[128];
  1940. char chReplace;
  1941. int i;
  1942.  
  1943. szFilter[0] = '\0';
  1944. szDirName[0] = '\0';
  1945. szFile[0] = '\0';
  1946. szFileTitle[0] = '\0';
  1947.  
  1948. /* lstrcpy(szFile,FileName); */
  1949. /* GetSystemDirectory(szDirName, sizeof(szDirName)); */
  1950.  
  1951. for (i = 0; i < 7; i++)
  1952.     if (strcmp(DefExt,win_common_type2[i]) == 0)
  1953.         break;
  1954. lstrcpy(szFilter, win_common_type[i]);
  1955. if (i == 1)
  1956.     lstrcat(szFilter,win_common_type[0]);
  1957. lstrcat(szFilter,win_common_type[7]);
  1958.  
  1959. chReplace = szFilter[strlen(szFilter) - 1];
  1960. for (i = 0; szFilter[i] != '\0'; i++) {
  1961.     if (szFilter[i] == chReplace)
  1962.         szFilter[i] = '\0';
  1963.         }
  1964.  
  1965. memset(&ofn, 0, sizeof(OPENFILENAME));
  1966. ofn.lStructSize = sizeof(OPENFILENAME);
  1967. ofn.hwndOwner = hwnd;
  1968. ofn.lpstrFilter = szFilter;
  1969. ofn.nFilterIndex = 1;
  1970. ofn.lpstrFile = szFile;
  1971. ofn.nMaxFile = sizeof(szFile);
  1972. ofn.lpstrFileTitle = szFileTitle;
  1973. ofn.nMaxFileTitle = sizeof(szFileTitle);
  1974. ofn.lpstrInitialDir = szDirName;
  1975. ofn.lpstrTitle = DialogTitle;
  1976. ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
  1977. ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
  1978.  
  1979. i = GetSaveFileName(&ofn);
  1980. lstrcpy(FileName,szFile);
  1981. lstrcpy(FullPathName,szFile);
  1982. lstrcpy(readname,szFile);
  1983.  
  1984. FileFormat = ID_GIF89A;
  1985. if (strlen(FileName) > 4)
  1986.     if (stricmp(&FileName[strlen(FileName)-4],".BMP") == 0)
  1987.         FileFormat = ID_BMP;
  1988.  
  1989. return i;
  1990.  
  1991. }
  1992.  
  1993. static PRINTDLG pd;
  1994. static BOOL print_abort_flag;
  1995. static HWND print_abort_dialog;
  1996.  
  1997. int FAR PASCAL PrintAbortDlg(HWND hWnd, unsigned msg, WORD wParam, LONG lParam)
  1998. {
  1999.     if (msg == WM_COMMAND) { /* Cancel button (Enter, Esc, Return, Space) */
  2000.     print_abort_flag = TRUE;
  2001.     DestroyWindow(hWnd);
  2002.     return (TRUE);
  2003.     }
  2004.     if (msg == WM_INITDIALOG) {
  2005.     center_window(hWnd,0,0);
  2006.     SetFocus(hWnd);
  2007.     return (TRUE);
  2008.     }
  2009.     return (FALSE);
  2010. }
  2011.  
  2012. int FAR PASCAL PrintAbort(HDC hPr, int Code)
  2013. {
  2014.     MSG msg;
  2015.     while (PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE))
  2016.     if (!IsDialogMessage(print_abort_dialog, &msg)) {
  2017.         TranslateMessage(&msg);
  2018.         DispatchMessage(&msg);
  2019.         }
  2020.     return (! print_abort_flag); /* return FALSE iff aborted */
  2021. }
  2022.  
  2023. int PrintFile()
  2024. {
  2025. int printer_xdots, printer_ydots;
  2026. float aspect;
  2027. extern int win_xdots, win_ydots;
  2028. extern int pixelshift_per_byte;
  2029. extern int bytes_per_pixelline;
  2030.  
  2031.     // initialize the structure
  2032.     memset(&pd, 0, sizeof(pd));
  2033.     pd.lStructSize = sizeof(pd);
  2034.     pd.hwndOwner = (HWND)NULL;
  2035.     pd.Flags = PD_RETURNDC | PD_NOPAGENUMS | PD_NOSELECTION | PD_PRINTSETUP;
  2036.  
  2037.     if (PrintDlg(&pd) == TRUE) {
  2038.         int printer_bandable;
  2039.         long firstpixel;
  2040.         RECT printerRect;
  2041.         FARPROC lpPrintDlg;
  2042.         FARPROC p_print_abort;
  2043.         FARPROC p_pabort_dialog;
  2044.         int more;
  2045.  
  2046.         print_abort_flag = FALSE;
  2047.  
  2048.         printer_bandable = GetDeviceCaps(pd.hDC,RASTERCAPS) & RC_BANDING;
  2049.  
  2050.         if (GetDeviceCaps(pd.hDC,NUMCOLORS) <= 2)
  2051.         mono_dib_palette();    /* B&W stripes for B&W printers */
  2052.         else
  2053.         rgb_dib_palette();
  2054.  
  2055.     printer_xdots = GetDeviceCaps(pd.hDC,HORZRES);
  2056.     printer_ydots = GetDeviceCaps(pd.hDC,VERTRES);
  2057.     aspect = ((((1.0 * printer_ydots) / printer_xdots) * xdots) / ydots);
  2058.     if (aspect > 1.0) printer_ydots /= aspect;
  2059.     if (aspect < 1.0) printer_xdots /= aspect;
  2060.  
  2061.         firstpixel = win_ydots - ydots;
  2062.         firstpixel = firstpixel * bytes_per_pixelline;
  2063.  
  2064.         p_print_abort  = MakeProcInstance(PrintAbort,    hInst);
  2065.         p_pabort_dialog = MakeProcInstance(PrintAbortDlg, hInst);
  2066.         print_abort_dialog = CreateDialog(hInst, "Printabort", hwnd, p_pabort_dialog);
  2067.         ShowWindow(print_abort_dialog, SW_NORMAL);
  2068.         UpdateWindow(print_abort_dialog);
  2069.         EnableWindow(hwnd, FALSE);
  2070.         Escape (pd.hDC, SETABORTPROC, 0, (LPSTR)p_print_abort, NULL);
  2071.  
  2072.         Escape(pd.hDC, STARTDOC,  17, (LPSTR)"Winfract Printout", NULL);
  2073.  
  2074.         if (printer_bandable)
  2075.             Escape(pd.hDC, NEXTBAND, 0, (LPSTR) NULL, (LPSTR) &printerRect);
  2076.  
  2077.         more = 1;
  2078.         while (more) {
  2079.         if (printer_bandable)
  2080.             DPtoLP(pd.hDC, (LPPOINT) &printerRect, 2);
  2081.         StretchDIBits(pd.hDC,
  2082.             0, 0,
  2083.             printer_xdots, printer_ydots,
  2084.             0, 0,
  2085.             xdots, ydots,
  2086.             (LPSTR)&pixels[firstpixel], (LPBITMAPINFO)pDibInfo,
  2087.             DIB_RGB_COLORS, SRCCOPY);
  2088.            if (printer_bandable)
  2089.             Escape(pd.hDC, NEXTBAND, 0, (LPSTR) NULL, (LPSTR) &printerRect);
  2090.         more = ! (IsRectEmpty(&printerRect));
  2091.         if (print_abort_flag) more = FALSE;
  2092.         }
  2093.         Escape(pd.hDC, NEWFRAME, 0, NULL, NULL);
  2094.         Escape(pd.hDC, ENDDOC, 0, NULL, NULL );
  2095.  
  2096.         EnableWindow(hwnd, TRUE);
  2097.         DestroyWindow(print_abort_dialog);
  2098.         FreeProcInstance(p_print_abort);
  2099.         FreeProcInstance(p_pabort_dialog);
  2100.         DeleteDC(pd.hDC);
  2101.         if (pd.hDevMode)
  2102.             GlobalFree(pd.hDevMode);
  2103.         if (pd.hDevNames)
  2104.             GlobalFree(pd.hDevNames);
  2105.     }
  2106.     default_dib_palette();   /* replace the palette */
  2107. }
  2108.