DIALOGS.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX - Modelling, Animation and Rendering Package
00003 -- */
00004 
00005 
00006 /* file DIALOGS.C */
00007 
00008 // Code for the Dialog box functions for most of the dialogs
00009 
00010 #define MODULE_DIALOGS 1
00011 
00012 #include "design.h"
00013 #include "..\animate\spin_dll.h"
00014 
00015 static int CountHierarchyList(HWND hdlg,skel *Sp);
00016 static int UpdateHierarchyList(HWND hdlg,skel *Sp, skel *Ssp);
00017 static skel *GetSkelFromList(HWND hdlg, skel *Sp);
00018 
00019 
00020 static BOOL CALLBACK OneRealDlgProc(HWND hwnd, UINT msg,
00021                                     WPARAM wparam, LPARAM lparam){
00022  BOOL err;
00023  char tempstr[16];
00024  struct np {char *title,*name1,*name2;
00025             int i,il,ih; double r;} *dp;
00026  switch( msg ) {
00027    case WM_PAINT:
00028      PaintDialogBackground(hwnd,ghinst_main);
00029      break;
00030    case WM_INITDIALOG:{
00031        dp=(struct np *)lparam;
00032        SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)dp->title);
00033        SendDlgItemMessage(hwnd,DLG_1R_TEXTR,WM_SETTEXT,0,(LPARAM)dp->name2);
00034        sprintf(tempstr,"%.4lf",dp->r);
00035        SendDlgItemMessage(hwnd,DLG_1R_EDITR,WM_SETTEXT,0,(LPARAM)tempstr);
00036        SendDlgItemMessage(hwnd,DLG_1R_EDITR,EM_LIMITTEXT,(WPARAM)12,0);
00037        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00038        CentreDialogOnCursor(hwnd);
00039      }
00040      return (TRUE);
00041    case WM_COMMAND:
00042       switch(LOWORD(wparam)){
00043         case IDCANCEL:
00044         case DLG_1R_CANCEL:
00045           EndDialog(hwnd, FAIL);
00046           return(TRUE);
00047         case IDOK:
00048         case DLG_1R_OK:
00049           dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00050           if(GetDlgItemText(hwnd,DLG_1R_EDITR,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00051           dp->r=atof(tempstr);
00052           EndDialog(hwnd,OK);
00053           return(TRUE);
00054         default:
00055           break;
00056       }
00057       break;
00058     default: break;
00059  }
00060  return(FALSE);
00061 }
00062 
00063 int Read1Real(char *title, char *it1,
00064                     double *r, double rl, double rh, HWND parent){
00065  struct np {char *title,*name1,*name2;
00066             int i,il,ih; double r;} d;
00067  int rv;
00068  d.title=title;
00069  d.name2=it1;
00070  d.r = *r;
00071 // EnableToolPannels(ALL_PANNELS,FALSE);
00072  if(DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_1R),parent,
00073             (DLGPROC)OneRealDlgProc,(LPARAM)&d) == OK){
00074    if(*r < rl)rv=FAIL;
00075    else if(*r > rh)rv=FAIL;
00076    else {
00077      *r = d.r;
00078      rv=OK;
00079    }
00080  }
00081  else rv=FAIL;
00082 // EnableToolPannels(ALL_PANNELS,TRUE);
00083  return rv;
00084 }
00085 
00086 static BOOL CALLBACK ThreeRealsDlgProc(HWND hwnd, UINT msg,
00087                                     WPARAM wparam, LPARAM lparam){
00088  char tempstr[16];
00089  struct np {char *title,*name1,*name2,*name3; double cal1,cal2,cal3;} *dp;
00090  switch( msg ) {
00091    case WM_PAINT:
00092      PaintDialogBackground(hwnd,ghinst_main);
00093      break;
00094    case WM_INITDIALOG:{
00095        dp=(struct np *)lparam;
00096        SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)dp->title);
00097        SendDlgItemMessage(hwnd,DLG_3REALS_NAME1,WM_SETTEXT,0,(LPARAM)dp->name1);
00098        SendDlgItemMessage(hwnd,DLG_3REALS_NAME2,WM_SETTEXT,0,(LPARAM)dp->name2);
00099        SendDlgItemMessage(hwnd,DLG_3REALS_NAME3,WM_SETTEXT,0,(LPARAM)dp->name3);
00100        sprintf(tempstr,"%.4lf",dp->cal1);
00101        SendDlgItemMessage(hwnd,DLG_3REALS_CAL1,WM_SETTEXT,0,(LPARAM)tempstr);
00102        SendDlgItemMessage(hwnd,DLG_3REALS_CAL1,EM_LIMITTEXT,(WPARAM)12,0);
00103        sprintf(tempstr,"%.4lf",dp->cal2);
00104        SendDlgItemMessage(hwnd,DLG_3REALS_CAL2,WM_SETTEXT,0,(LPARAM)tempstr);
00105        SendDlgItemMessage(hwnd,DLG_3REALS_CAL2,EM_LIMITTEXT,(WPARAM)12,0);
00106        sprintf(tempstr,"%.4lf",dp->cal3);
00107        SendDlgItemMessage(hwnd,DLG_3REALS_CAL3,WM_SETTEXT,0,(LPARAM)tempstr);
00108        SendDlgItemMessage(hwnd,DLG_3REALS_CAL3,EM_LIMITTEXT,(WPARAM)12,0);
00109        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00110        CentreDialogOnCursor(hwnd);
00111      }
00112      return (TRUE);
00113    case WM_COMMAND:
00114       switch(LOWORD(wparam)){
00115         case IDCANCEL:
00116         case DLG_3REALS_CANCEL:
00117           EndDialog(hwnd, FAIL);
00118           return(TRUE);
00119         case IDOK:
00120         case DLG_3REALS_OK:
00121           dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00122           if(GetDlgItemText(hwnd,DLG_3REALS_CAL1,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00123           dp->cal1=atof(tempstr);
00124           if(GetDlgItemText(hwnd,DLG_3REALS_CAL2,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00125           dp->cal2=atof(tempstr);
00126           if(GetDlgItemText(hwnd,DLG_3REALS_CAL3,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00127           dp->cal3=atof(tempstr);
00128           EndDialog(hwnd,OK);
00129           return(TRUE);
00130         default:
00131           break;
00132       }
00133       break;
00134     default: break;
00135  }
00136  return(FALSE);
00137 }
00138 
00139 int Read3Reals(char *title, double *r1, double *r2, double *r3, int list){
00140  int rv;
00141  char *lists[3][3]={ {"Left/Right" ,"Back/Front", "Up/Down"},  // first arg is number of lists
00142                      {"Direction", "Elevation", "Bank"},
00143                      {"Weight", "Range", "Zone"}
00144                   };
00145  struct np {char *title,*name1,*name2,*name3; double cal1,cal2,cal3;} d,*dp;
00146  d.title=title;
00147  d.name1=lists[list][0];
00148  d.name2=lists[list][1];
00149  d.name3=lists[list][2];
00150  d.cal1 = *r1;
00151  d.cal2 = *r2;
00152  d.cal3 = *r3;
00153  EnableToolPannels(ALL_PANNELS,FALSE);
00154  if(DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_3REALS),ghwnd_main,
00155             (DLGPROC)ThreeRealsDlgProc,(LPARAM)&d) == OK){
00156    *r1 = d.cal1;
00157    *r2 = d.cal2;
00158    *r3 = d.cal3;
00159    rv=OK;
00160  }
00161  else rv=FAIL;
00162  EnableToolPannels(ALL_PANNELS,TRUE);
00163  return rv;
00164 }
00165 
00166 static BOOL CALLBACK ThreeIntsDlgProc(HWND hwnd, UINT msg,
00167                                     WPARAM wparam, LPARAM lparam){
00168  BOOL err;
00169  int i;
00170  struct np {char *title,*name1,*name2,*name3;
00171             int i1,i2,i3,i1h,i2h,i3h,i1l,i2l,i3l;} *dp;
00172  switch( msg ) {
00173    case WM_PAINT:
00174      PaintDialogBackground(hwnd,ghinst_main);
00175      break;
00176    case WM_INITDIALOG:{
00177        dp=(struct np *)lparam;
00178        SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)dp->title);
00179        SendDlgItemMessage(hwnd,DLG_3INTS_TEXT1,WM_SETTEXT,0,(LPARAM)dp->name1);
00180        SendDlgItemMessage(hwnd,DLG_3INTS_TEXT2,WM_SETTEXT,0,(LPARAM)dp->name2);
00181        SendDlgItemMessage(hwnd,DLG_3INTS_TEXT3,WM_SETTEXT,0,(LPARAM)dp->name3);
00182        SetDlgItemInt(hwnd,DLG_3INTS_EDIT1,dp->i1,FALSE);
00183        SendDlgItemMessage(hwnd,DLG_3INTS_EDIT1,EM_LIMITTEXT,(WPARAM)6,0);
00184        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN1,SPNM_SETRANGE,0,
00185                           MAKELPARAM(dp->i1l,dp->i1h));
00186        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN1,SPNM_SETCRNTVALUE,
00187                           (WPARAM)dp->i1,0);
00188        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN1,SPNM_SETEDITCTRL,0,
00189                           (LPARAM)GetDlgItem(hwnd,DLG_3INTS_EDIT1));
00190        SetDlgItemInt(hwnd,DLG_3INTS_EDIT2,dp->i2,FALSE);
00191        SendDlgItemMessage(hwnd,DLG_3INTS_EDIT2,EM_LIMITTEXT,(WPARAM)6,0);
00192        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN2,SPNM_SETRANGE,0,
00193                           MAKELPARAM(dp->i2l,dp->i2h));
00194        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN2,SPNM_SETCRNTVALUE,
00195                           (WPARAM)dp->i2,0);
00196        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN2,SPNM_SETEDITCTRL,0,
00197                           (LPARAM)GetDlgItem(hwnd,DLG_3INTS_EDIT2));
00198        SetDlgItemInt(hwnd,DLG_3INTS_EDIT3,dp->i3,FALSE);
00199        SendDlgItemMessage(hwnd,DLG_3INTS_EDIT3,EM_LIMITTEXT,(WPARAM)6,0);
00200        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN3,SPNM_SETRANGE,0,
00201                           MAKELPARAM(dp->i3l,dp->i3h));
00202        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN3,SPNM_SETCRNTVALUE,
00203                           (WPARAM)dp->i3,0);
00204        SendDlgItemMessage(hwnd,DLG_3INTS_SPIN3,SPNM_SETEDITCTRL,0,
00205                           (LPARAM)GetDlgItem(hwnd,DLG_3INTS_EDIT3));
00206        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00207        CentreDialogOnCursor(hwnd);
00208      }
00209      return (TRUE);
00210    case WM_COMMAND:
00211       switch(LOWORD(wparam)){
00212         case IDCANCEL:
00213         case DLG_3INTS_CANCEL:
00214           EndDialog(hwnd, FAIL);
00215           return(TRUE);
00216         case IDOK:
00217         case DLG_3INTS_OK:
00218           dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00219           i=GetDlgItemInt(hwnd,DLG_3INTS_EDIT1,&err,FALSE);
00220           if(!err)EndDialog(hwnd,FAIL);
00221           if(i > dp->i1h || i < dp->i1l)EndDialog(hwnd,FAIL);
00222           dp->i1=i;
00223           i=GetDlgItemInt(hwnd,DLG_3INTS_EDIT2,&err,FALSE);
00224           if(!err)EndDialog(hwnd,FAIL);
00225           if(i > dp->i2h || i < dp->i2l)EndDialog(hwnd,FAIL);
00226           dp->i2=i;
00227           i=GetDlgItemInt(hwnd,DLG_3INTS_EDIT3,&err,FALSE);
00228           if(!err)EndDialog(hwnd,FAIL);
00229           if(i > dp->i3h || i < dp->i3l)EndDialog(hwnd,FAIL);
00230           dp->i3=i;
00231           EndDialog(hwnd,OK);
00232           return(TRUE);
00233         default:
00234           break;
00235       }
00236       break;
00237     default: break;
00238  }
00239  return(FALSE);
00240 }
00241 
00242 int Read3Ints(char *title, char *it1, char *it2, char *it3,
00243                     int *i1, int *i2, int *i3, HWND parent){
00244  struct np {char *title,*name1,*name2,*name3;
00245             int i1,i2,i3,i1h,i2h,i3h,i1l,i2l,i3l;} d,*dp;
00246  int rv;
00247  d.title=title;
00248  d.name1=it1;
00249  d.name2=it2;
00250  d.name3=it3;
00251  d.i1 = *i1;  d.i1l=0; d.i1h=9000;
00252  d.i2 = *i2;  d.i2l=0; d.i2h=9000;
00253  d.i3 = *i3;  d.i3l=0; d.i3h=9000;
00254  if(DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_3INTS),parent,
00255             (DLGPROC)ThreeIntsDlgProc,(LPARAM)&d) == OK){
00256    *i1 = d.i1;
00257    *i2 = d.i2;
00258    *i3 = d.i3;
00259    rv=OK;
00260  }
00261  else rv=FAIL;
00262  return rv;
00263 }
00264 
00265 int Read2Ints(char *title, char *it1, char *it2,
00266                     int *i1, int *i2, HWND parent){
00267  return FAIL;
00268 }
00269 
00270 BOOL CALLBACK SpiralsDlgProc(HWND hwnd, UINT msg,
00271                              WPARAM wparam, LPARAM lparam){
00272  BOOL err,active;
00273  int i;
00274  struct np {int type,n,r;} *dp;
00275  switch( msg ) {
00276    case WM_PAINT:
00277      PaintDialogBackground(hwnd,ghinst_main);
00278      break;
00279    case WM_INITDIALOG:{
00280        dp=(struct np *)lparam;
00281        SetDlgItemInt(hwnd,DLG_SPIRAL_EDITN,dp->n,FALSE);
00282        SendDlgItemMessage(hwnd,DLG_SPIRAL_EDITN,EM_LIMITTEXT,(WPARAM)6,0);
00283        SendDlgItemMessage(hwnd,DLG_SPIRAL_SPINN,SPNM_SETRANGE,0,
00284                           MAKELPARAM(5,90));
00285        SendDlgItemMessage(hwnd,DLG_SPIRAL_SPINN,SPNM_SETCRNTVALUE,
00286                           (WPARAM)dp->n,0);
00287        SendDlgItemMessage(hwnd,DLG_SPIRAL_SPINN,SPNM_SETEDITCTRL,0,
00288                           (LPARAM)GetDlgItem(hwnd,DLG_SPIRAL_EDITN));
00289        SetDlgItemInt(hwnd,DLG_SPIRAL_EDITR,dp->r,FALSE);
00290        SendDlgItemMessage(hwnd,DLG_SPIRAL_EDITR,EM_LIMITTEXT,(WPARAM)6,0);
00291        SendDlgItemMessage(hwnd,DLG_SPIRAL_SPINR,SPNM_SETRANGE,0,
00292                           MAKELPARAM(10,9999));
00293        SendDlgItemMessage(hwnd,DLG_SPIRAL_SPINR,SPNM_SETCRNTVALUE,
00294                           (WPARAM)dp->r,0);
00295        SendDlgItemMessage(hwnd,DLG_SPIRAL_SPINR,SPNM_SETEDITCTRL,0,
00296                           (LPARAM)GetDlgItem(hwnd,DLG_SPIRAL_EDITR));
00297        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00298        if(dp->type == 0)active=TRUE; else active=FALSE;
00299        SendDlgItemMessage(hwnd,DLG_SPIRAL_ARC,BM_SETCHECK,active,0);
00300        SendDlgItemMessage(hwnd,DLG_SPIRAL_LOG,BM_SETCHECK,!active,0);
00301        CentreDialogOnCursor(hwnd);
00302      }
00303      return (TRUE);
00304    case WM_COMMAND:
00305       dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00306       switch(LOWORD(wparam)){
00307         case DLG_SPIRAL_ARC:
00308           dp->type=0;
00309           break;
00310         case DLG_SPIRAL_LOG:
00311           dp->type=1;
00312           break;
00313         case IDCANCEL:
00314         case DLG_SPIRAL_CANCEL:
00315           EndDialog(hwnd, FAIL);
00316           return(TRUE);
00317         case IDOK:
00318         case DLG_SPIRAL_OK:
00319           i=GetDlgItemInt(hwnd,DLG_SPIRAL_EDITN,&err,FALSE);
00320           if(!err)EndDialog(hwnd, -1);
00321           if(i > 90)i=90; if(i < 5)i=5;
00322           dp->n=i;
00323           i=GetDlgItemInt(hwnd,DLG_SPIRAL_EDITR,&err,FALSE);
00324           if(!err)EndDialog(hwnd, -1);
00325           if(i > 9999)i=9999; if(i < 10)i=10;
00326           dp->r=i;
00327           EndDialog(hwnd,OK);
00328           return(TRUE);
00329         default:
00330           break;
00331       }
00332       break;
00333     default: break;
00334  }
00335  return(FALSE);
00336 }
00337 
00338 static BOOL CALLBACK OneIntOneRealDlgProc(HWND hwnd, UINT msg,
00339                                     WPARAM wparam, LPARAM lparam){
00340  int i;
00341  BOOL err;
00342  char tempstr[16];
00343  struct np {char *title,*name1,*name2;
00344             int i,il,ih; double r;} *dp;
00345  switch( msg ) {
00346    case WM_PAINT:
00347      PaintDialogBackground(hwnd,ghinst_main);
00348      break;
00349    case WM_INITDIALOG:{
00350        dp=(struct np *)lparam;
00351        SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)dp->title);
00352        SendDlgItemMessage(hwnd,DLG_1I1R_TEXTI,WM_SETTEXT,0,(LPARAM)dp->name1);
00353        SendDlgItemMessage(hwnd,DLG_1I1R_TEXTR,WM_SETTEXT,0,(LPARAM)dp->name2);
00354        SetDlgItemInt(hwnd,DLG_1I1R_EDITI,dp->i,FALSE);
00355        SendDlgItemMessage(hwnd,DLG_1I1R_EDITI,EM_LIMITTEXT,(WPARAM)6,0);
00356        SendDlgItemMessage(hwnd,DLG_1I1R_SPINI,SPNM_SETRANGE,0,
00357                           MAKELPARAM(dp->il,dp->ih));
00358        SendDlgItemMessage(hwnd,DLG_1I1R_SPINI,SPNM_SETCRNTVALUE,
00359                           (WPARAM)dp->i,0);
00360        SendDlgItemMessage(hwnd,DLG_1I1R_SPINI,SPNM_SETEDITCTRL,0,
00361                           (LPARAM)GetDlgItem(hwnd,DLG_1I1R_EDITI));
00362        sprintf(tempstr,"%.4lf",dp->r);
00363        SendDlgItemMessage(hwnd,DLG_1I1R_EDITR,WM_SETTEXT,0,(LPARAM)tempstr);
00364        SendDlgItemMessage(hwnd,DLG_1I1R_EDITR,EM_LIMITTEXT,(WPARAM)12,0);
00365        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00366        CentreDialogOnCursor(hwnd);
00367      }
00368      return (TRUE);
00369    case WM_COMMAND:
00370       switch(LOWORD(wparam)){
00371         case IDCANCEL:
00372         case DLG_1I1R_CANCEL:
00373           EndDialog(hwnd, FAIL);
00374           return(TRUE);
00375         case IDOK:
00376         case DLG_1I1R_OK:
00377           dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00378           i=GetDlgItemInt(hwnd,DLG_1I1R_EDITI,&err,FALSE);
00379           if(!err)EndDialog(hwnd, -1);
00380           if(i > dp->ih)i=dp->ih; if(i < dp->il)i=dp->il;
00381           dp->i=i;
00382           if(GetDlgItemText(hwnd,DLG_1I1R_EDITR,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00383           dp->r=atof(tempstr);
00384           EndDialog(hwnd,OK);
00385           return(TRUE);
00386         default:
00387           break;
00388       }
00389       break;
00390     default: break;
00391  }
00392  return(FALSE);
00393 }
00394 
00395 int Read1Int1Real(char *title, char *it1, char *it2,
00396                     int *i, int il, int ih,
00397                     double *r, double rl, double rh, HWND parent){
00398  struct np {char *title,*name1,*name2;
00399             int i,il,ih; double r;} d;
00400  int rv;
00401  d.title=title;
00402  d.name1=it1;
00403  d.name2=it2;
00404  d.i = *i;  d.il=il; d.ih=ih;
00405  d.r = *r;
00406 // EnableToolPannels(ALL_PANNELS,FALSE);
00407  if(DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_1I1R),parent,
00408             (DLGPROC)OneIntOneRealDlgProc,(LPARAM)&d) == OK){
00409    *i = d.i;
00410    *r = d.r;
00411    rv=OK;
00412  }
00413  else rv=FAIL;
00414 // EnableToolPannels(ALL_PANNELS,TRUE);
00415  return rv;
00416 }
00417 
00418 static BOOL CALLBACK OneStringOneRealDlgProc(HWND hwnd, UINT msg, 
00419                                     WPARAM wparam, LPARAM lparam){
00420  int i;
00421  BOOL err;
00422  char tempstr[16];
00423  struct np {char *title,*name1,*name2;
00424             char *str; double r;} *dp;
00425  switch( msg ) {
00426    case WM_PAINT:
00427      PaintDialogBackground(hwnd,ghinst_main);
00428      break;
00429    case WM_INITDIALOG:{
00430        dp=(struct np *)lparam;
00431        SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)dp->title);
00432        SendDlgItemMessage(hwnd,DLG_1S1R_TEXTI,WM_SETTEXT,0,(LPARAM)dp->name1);
00433        SendDlgItemMessage(hwnd,DLG_1S1R_TEXTR,WM_SETTEXT,0,(LPARAM)dp->name2);
00434        SendDlgItemMessage(hwnd,DLG_1S1R_STRING,WM_SETTEXT,0,(LPARAM)dp->str);
00435        SendDlgItemMessage(hwnd,DLG_1S1R_STRING,EM_LIMITTEXT,(WPARAM)12,0);
00436        sprintf(tempstr,"%.4lf",dp->r);
00437        SendDlgItemMessage(hwnd,DLG_1S1R_EDITR,WM_SETTEXT,0,(LPARAM)tempstr);
00438        SendDlgItemMessage(hwnd,DLG_1S1R_EDITR,EM_LIMITTEXT,(WPARAM)12,0);
00439        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00440        CentreDialogOnCursor(hwnd);
00441      }
00442      return (TRUE);
00443    case WM_COMMAND:
00444       switch(LOWORD(wparam)){
00445         case IDCANCEL:
00446         case DLG_1S1R_CANCEL:
00447           EndDialog(hwnd, FAIL);
00448           return(TRUE);
00449         case IDOK:
00450         case DLG_1S1R_OK:
00451           dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00452           if(GetDlgItemText(hwnd,DLG_1S1R_EDITR,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00453           dp->r=atof(tempstr);
00454           if(GetDlgItemText(hwnd,DLG_1S1R_STRING,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00455           if(strlen(tempstr) > 0)strcpy(dp->str,tempstr);
00456           EndDialog(hwnd,OK);
00457           return(TRUE);
00458         default:
00459           break;
00460       }
00461       break;
00462     default: break;
00463  }
00464  return(FALSE);
00465 }
00466 
00467 int Read1String1Real(char *title, char *it1, char *it2,
00468                      char *strg,
00469                      double *r, double rl, double rh, HWND parent){
00470  struct np {char *title,*name1,*name2;
00471             char *str; double r;} d;
00472  int rv;
00473  d.title=title;
00474  d.name1=it1;
00475  d.name2=it2;
00476  d.str=strg;
00477  d.r = *r;
00478 // EnableToolPannels(ALL_PANNELS,FALSE);
00479  if(DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_1S1R),parent,
00480             (DLGPROC)OneStringOneRealDlgProc,(LPARAM)&d) == OK){
00481    *r = d.r;
00482    rv=OK;
00483  }
00484  else rv=FAIL;
00485 // EnableToolPannels(ALL_PANNELS,TRUE);
00486  return rv;
00487 }
00488 
00489 static BOOL CALLBACK OneStringThreeRealDlgProc(HWND hwnd, UINT msg, 
00490                                     WPARAM wparam, LPARAM lparam){
00491  int i;
00492  BOOL err;
00493  char tempstr[16];
00494  struct np {char *title,*name1,*name2,*name3,*name4;
00495             char *str; double r,r2,r3;} *dp;
00496  switch( msg ) {
00497    case WM_PAINT:
00498      PaintDialogBackground(hwnd,ghinst_main);
00499      break;
00500    case WM_INITDIALOG:{
00501        dp=(struct np *)lparam;
00502        SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)dp->title);
00503        SendDlgItemMessage(hwnd,DLG_1S3R_TEXTS,WM_SETTEXT,0,(LPARAM)dp->name1);
00504        SendDlgItemMessage(hwnd,DLG_1S3R_TEXTR,WM_SETTEXT,0,(LPARAM)dp->name2);
00505        SendDlgItemMessage(hwnd,DLG_1S3R_TEXTR2,WM_SETTEXT,0,(LPARAM)dp->name3);
00506        SendDlgItemMessage(hwnd,DLG_1S3R_TEXTR3,WM_SETTEXT,0,(LPARAM)dp->name4);
00507        SendDlgItemMessage(hwnd,DLG_1S3R_STRING,WM_SETTEXT,0,(LPARAM)dp->str);
00508        SendDlgItemMessage(hwnd,DLG_1S3R_STRING,EM_LIMITTEXT,(WPARAM)12,0);
00509        sprintf(tempstr,"%.4lf",dp->r);
00510        SendDlgItemMessage(hwnd,DLG_1S3R_EDITR,WM_SETTEXT,0,(LPARAM)tempstr);
00511        SendDlgItemMessage(hwnd,DLG_1S3R_EDITR,EM_LIMITTEXT,(WPARAM)12,0);
00512        sprintf(tempstr,"%.4lf",dp->r2);
00513        SendDlgItemMessage(hwnd,DLG_1S3R_EDITR2,WM_SETTEXT,0,(LPARAM)tempstr);
00514        SendDlgItemMessage(hwnd,DLG_1S3R_EDITR2,EM_LIMITTEXT,(WPARAM)12,0);
00515        sprintf(tempstr,"%.4lf",dp->r3);
00516        SendDlgItemMessage(hwnd,DLG_1S3R_EDITR3,WM_SETTEXT,0,(LPARAM)tempstr);
00517        SendDlgItemMessage(hwnd,DLG_1S3R_EDITR3,EM_LIMITTEXT,(WPARAM)12,0);
00518        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00519        CentreDialogOnCursor(hwnd);
00520      }
00521      return (TRUE);
00522    case WM_COMMAND:
00523       switch(LOWORD(wparam)){
00524         case IDCANCEL:
00525         case DLG_1S3R_CANCEL:
00526           EndDialog(hwnd, FAIL);
00527           return(TRUE);
00528         case IDOK:
00529         case DLG_1S3R_OK:
00530           dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00531           if(GetDlgItemText(hwnd,DLG_1S3R_EDITR,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00532           dp->r=atof(tempstr);
00533           if(GetDlgItemText(hwnd,DLG_1S3R_EDITR2,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00534           dp->r2=atof(tempstr);
00535           if(GetDlgItemText(hwnd,DLG_1S3R_EDITR3,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00536           dp->r3=atof(tempstr);
00537           if(GetDlgItemText(hwnd,DLG_1S3R_STRING,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00538           if(strlen(tempstr) > 0)strcpy(dp->str,tempstr);
00539           EndDialog(hwnd,OK);
00540           return(TRUE);
00541         default:
00542           break;
00543       }
00544       break;
00545     default: break;
00546  }
00547  return(FALSE);
00548 }
00549 
00550 int Read1String3Real(char *title, char *it1, char *it2, char *it3, char *it4,
00551                      char *strg,
00552                      double *r, double *r2, double *r3, HWND parent){
00553  struct np {char *title,*name1,*name2,*name3,*name4;
00554             char *str; double r,r2,r3;} d;
00555  int rv;
00556  d.title=title;
00557  d.name1=it1;
00558  d.name2=it2;
00559  d.name3=it3;
00560  d.name4=it4;
00561  d.str=strg;
00562  d.r = *r;
00563  d.r2 = *r2;
00564  d.r3 = *r3;
00565 // EnableToolPannels(ALL_PANNELS,FALSE);
00566  if(DialogBoxParam(ghinst_main,MAKEINTRESOURCE(DLG_1S3R),parent,
00567             (DLGPROC)OneStringThreeRealDlgProc,(LPARAM)&d) == OK){
00568    *r = d.r;
00569    *r2 = d.r2;
00570    *r3 = d.r3;
00571    rv=OK;
00572  }
00573  else rv=FAIL;
00574 // EnableToolPannels(ALL_PANNELS,TRUE);
00575  return rv;
00576 }
00578 
00579 
00580 
00581 BOOL CALLBACK FunctionPlotDlgProc(HWND hwnd, UINT msg,
00582                              WPARAM wparam, LPARAM lparam){
00583  BOOL err;
00584  int i;
00585  struct np {int t,x,y;} *dp;
00586  switch( msg ) {
00587    case WM_PAINT:
00588      PaintDialogBackground(hwnd,ghinst_main);
00589      break;
00590    case WM_INITDIALOG:{
00591         char *function_list[]={
00592           "Plain Grid",
00593            "Sine Wave",
00594            "Tangent Function",
00595            "Bi-variate Normal Dist.",
00596            "Plot of Sine(x) * Sine(y)",
00597            "Plot of Sine(x * y)",
00598            "Plot of Sine(x) * Sine(3*y)",
00599            "Plot of Sine(x) + Cosine(y)"
00600          };
00601        dp=(struct np *)lparam;
00602        for(i=0;i<8;i++)SendDlgItemMessage(hwnd,DLG_FPLOT_LIST,LB_ADDSTRING,0,
00603                                           (LPARAM)function_list[i]);
00604        SendDlgItemMessage(hwnd,DLG_FPLOT_LIST,LB_SETCURSEL,0,(LPARAM)dp->t);
00605        SetDlgItemInt(hwnd,DLG_FPLOT_EDITX,dp->x,FALSE);
00606        SendDlgItemMessage(hwnd,DLG_FPLOT_EDITX,EM_LIMITTEXT,(WPARAM)6,0);
00607        SendDlgItemMessage(hwnd,DLG_FPLOT_SPINX,SPNM_SETRANGE,0,
00608                           MAKELPARAM(2,90));
00609        SendDlgItemMessage(hwnd,DLG_FPLOT_SPINX,SPNM_SETCRNTVALUE,
00610                           (WPARAM)dp->x,0);
00611        SendDlgItemMessage(hwnd,DLG_FPLOT_SPINX,SPNM_SETEDITCTRL,0,
00612                           (LPARAM)GetDlgItem(hwnd,DLG_FPLOT_EDITX));
00613        SetDlgItemInt(hwnd,DLG_FPLOT_EDITY,dp->y,FALSE);
00614        SendDlgItemMessage(hwnd,DLG_FPLOT_EDITY,EM_LIMITTEXT,(WPARAM)6,0);
00615        SendDlgItemMessage(hwnd,DLG_FPLOT_SPINY,SPNM_SETRANGE,0,
00616                           MAKELPARAM(2,90));
00617        SendDlgItemMessage(hwnd,DLG_FPLOT_SPINY,SPNM_SETCRNTVALUE,
00618                           (WPARAM)dp->y,0);
00619        SendDlgItemMessage(hwnd,DLG_FPLOT_SPINY,SPNM_SETEDITCTRL,0,
00620                           (LPARAM)GetDlgItem(hwnd,DLG_FPLOT_EDITY));
00621        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00622        CentreDialogOnCursor(hwnd);
00623      }
00624      return (TRUE);
00625    case WM_COMMAND:
00626       dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00627       switch(LOWORD(wparam)){
00628         case DLG_FPLOT_LIST:
00629           switch(HIWORD(wparam)){
00630             case LBN_DBLCLK:
00631               SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(DLG_FPLOT_OK,0),0);
00632               break;
00633             default:
00634               break;
00635           }
00636           break;
00637         case IDCANCEL:
00638         case DLG_FPLOT_CANCEL:
00639           EndDialog(hwnd, FAIL);
00640           return(TRUE);
00641         case IDOK:
00642         case DLG_FPLOT_OK:
00643           i=GetDlgItemInt(hwnd,DLG_FPLOT_EDITX,&err,FALSE);
00644           if(!err)EndDialog(hwnd, -1);
00645           if(i > 190)i=190;
00646           if(i < 2)i=2;
00647           dp->x=i;
00648           i=GetDlgItemInt(hwnd,DLG_FPLOT_EDITY,&err,FALSE);
00649           if(!err)EndDialog(hwnd, -1);
00650           if(i > 190)i=190;
00651           if(i < 2)i=2;
00652           dp->y=i;
00653           dp->t=SendMessage(GetDlgItem(hwnd,DLG_FPLOT_LIST),LB_GETCURSEL,0,0);
00654           EndDialog(hwnd,OK);
00655           return(TRUE);
00656         default:
00657           break;
00658       }
00659       break;
00660     default: break;
00661  }
00662  return(FALSE);
00663 }
00664 
00665 BOOL CALLBACK ExtrudeAlongDlgProc(HWND hwnd, UINT msg,
00666                              WPARAM wparam, LPARAM lparam){
00667  char tempstr[16];
00668  BOOL err;
00669  int i;
00670  struct np {double expan,repeat_map;} *dp;
00671  switch( msg ) {
00672    case WM_PAINT:
00673      PaintDialogBackground(hwnd,ghinst_main);
00674      break;
00675    case WM_INITDIALOG:{
00676        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00677        dp=(struct np *)lparam;
00678        sprintf(tempstr,"%.4lf",dp->expan);
00679        SendDlgItemMessage(hwnd,DLG_EXTRUDEALONG_EXP,WM_SETTEXT,0,(LPARAM)tempstr);
00680        SendDlgItemMessage(hwnd,DLG_EXTRUDEALONG_EXP,EM_LIMITTEXT,(WPARAM)12,0);
00681        sprintf(tempstr,"%.4lf",dp->repeat_map);
00682        SendDlgItemMessage(hwnd,DLG_EXTRUDEALONG_MAP,WM_SETTEXT,0,(LPARAM)tempstr);
00683        SendDlgItemMessage(hwnd,DLG_EXTRUDEALONG_MAP,EM_LIMITTEXT,(WPARAM)12,0);
00684        CentreDialogOnCursor(hwnd);
00685      }
00686      return (TRUE);
00687    case WM_COMMAND:
00688       dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00689       switch(LOWORD(wparam)){
00690         case IDCANCEL:
00691         case DLG_EXTRUDEALONG_CANCEL:
00692           EndDialog(hwnd,FAIL);
00693           return(TRUE);
00694         case IDOK:
00695         case DLG_EXTRUDEALONG_OK:
00696           if(GetDlgItemText(hwnd,DLG_EXTRUDEALONG_EXP,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00697           if((dp->expan=atof(tempstr)) == 0)EndDialog(hwnd, FAIL);
00698           if(GetDlgItemText(hwnd,DLG_EXTRUDEALONG_MAP,tempstr,10) == 0)EndDialog(hwnd, FAIL);
00699           if((dp->repeat_map=atof(tempstr)) == 0)EndDialog(hwnd, FAIL);
00700           if(SendDlgItemMessage(hwnd,DLG_EXTRUDEALONG_EXPAND,BM_GETCHECK,0,0))
00701                 EndDialog(hwnd,2);
00702           else  EndDialog(hwnd,1);
00703           return(TRUE);
00704         default:
00705           break;
00706       }
00707       break;
00708     default: break;
00709  }
00710  return(FALSE);
00711 }
00712 
00713 BOOL CALLBACK FlipDlgProc(HWND hwnd, UINT msg,
00714                           WPARAM wparam, LPARAM lparam){
00715  BOOL active;
00716  int i;
00717  struct np {int plane,weld;} *dp;
00718  switch( msg ) {
00719    case WM_PAINT:
00720      PaintDialogBackground(hwnd,ghinst_main);
00721      break;
00722    case WM_INITDIALOG:{
00723        SetWindowLong(hwnd,GWL_USERDATA,lparam);
00724        dp=(struct np *)lparam;
00725        if(dp->plane)active=TRUE; else active=FALSE;
00726        SendDlgItemMessage(hwnd,DLG_FLIP_PLANEV,BM_SETCHECK,active,0);
00727        SendDlgItemMessage(hwnd,DLG_FLIP_PLANEH,BM_SETCHECK,!active,0);
00728        if(dp->weld)active=TRUE; else active=FALSE;
00729        SendDlgItemMessage(hwnd,DLG_FLIP_WELDON,BM_SETCHECK,active,0);
00730        SendDlgItemMessage(hwnd,DLG_FLIP_WELDOFF,BM_SETCHECK,!active,0);
00731        CentreDialogOnCursor(hwnd);
00732      }
00733      return (TRUE);
00734    case WM_COMMAND:
00735       dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
00736       switch(LOWORD(wparam)){
00737         case DLG_FLIP_PLANEH:  dp->plane=0; break;
00738         case DLG_FLIP_PLANEV:  dp->plane=1; break;
00739         case DLG_FLIP_WELDOFF: dp->weld=0; break;
00740         case DLG_FLIP_WELDON:  dp->weld=1; break;
00741         case IDCANCEL:
00742         case DLG_FLIP_CANCEL:
00743           EndDialog(hwnd,FAIL);
00744           return(TRUE);
00745         case IDOK:
00746         case DLG_FLIP_OK:
00747           EndDialog(hwnd,OK);
00748           return(TRUE);
00749         default:
00750           break;
00751       }
00752       break;
00753     default: break;
00754  }
00755  return(FALSE);
00756 }
00757 
00758 BOOL CALLBACK ExpandDlgProc(HWND hwnd, UINT msg,
00759                           WPARAM wparam, LPARAM lparam){
00760 #define RANGE 100
00761  char tempstr[16];
00762  HWND hctl;
00763  int iMin,iMax;
00764  RECT rc;
00765  POINT p;
00766  static int i,xpos=-1,ypos=-1,xpand_a=0;
00767  static double xpand_x=1.0,xpand_y=1.0,xpand_z=1.0;
00768  static BOOL active,xpand_X=TRUE,xpand_Y=TRUE,xpand_Z=TRUE,
00769              xpand_vf=TRUE,xpand_cu=TRUE;
00770  double a;
00771  switch( msg ) {
00772    case WM_PAINT:
00773      PaintDialogBackground(hwnd,ghinst_main);
00774      break;
00775    case WM_INITDIALOG:
00776      EnableWindow(ghwnd_main,TRUE);
00777      if(xpand_vf)active=TRUE; else active=FALSE;
00778      SendDlgItemMessage(hwnd,DLG_EXPAND_VERT,BM_SETCHECK,active,0);
00779      SendDlgItemMessage(hwnd,DLG_EXPAND_FACE,BM_SETCHECK,!active,0);
00780      if(xpand_cu)active=TRUE; else active=FALSE;
00781      SendDlgItemMessage(hwnd,DLG_EXPAND_CURSOR,BM_SETCHECK,active,0);
00782      SendDlgItemMessage(hwnd,DLG_EXPAND_CENTRE,BM_SETCHECK,!active,0);
00783      if(xpand_X)active=TRUE; else active=FALSE;
00784      SendDlgItemMessage(hwnd,DLG_EXPAND_LR,BM_SETCHECK,active,0);
00785      if(xpand_Y)active=TRUE; else active=FALSE;
00786      SendDlgItemMessage(hwnd,DLG_EXPAND_FB,BM_SETCHECK,active,0);
00787      if(xpand_Z)active=TRUE; else active=FALSE;
00788      SendDlgItemMessage(hwnd,DLG_EXPAND_UD,BM_SETCHECK,active,0);
00789      sprintf(tempstr,"%.2lf",xpand_x);
00790      SendDlgItemMessage(hwnd,DLG_EXPAND_EDITLR,WM_SETTEXT,0,(LPARAM)tempstr);
00791      SendDlgItemMessage(hwnd,DLG_EXPAND_EDITLR,EM_LIMITTEXT,(WPARAM)12,0);
00792      sprintf(tempstr,"%.2lf",xpand_y);
00793      SendDlgItemMessage(hwnd,DLG_EXPAND_EDITFB,WM_SETTEXT,0,(LPARAM)tempstr);
00794      SendDlgItemMessage(hwnd,DLG_EXPAND_EDITFB,EM_LIMITTEXT,(WPARAM)12,0);
00795      sprintf(tempstr,"%.2lf",xpand_z);
00796      SendDlgItemMessage(hwnd,DLG_EXPAND_EDITUD,WM_SETTEXT,0,(LPARAM)tempstr);
00797      SendDlgItemMessage(hwnd,DLG_EXPAND_EDITUD,EM_LIMITTEXT,(WPARAM)12,0);
00798 //     SetScrollRange(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),SB_CTL,-RANGE,RANGE,FALSE);
00799 //     SetScrollPos(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),SB_CTL,0,TRUE);
00800      SendMessage(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),
00801        TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(-RANGE,RANGE));
00802      for(i = -RANGE+20; i < RANGE; i += 20)
00803        SendMessage(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),
00804          TBM_SETTIC,(WPARAM)0,(LPARAM)i);
00805      SendMessage(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),
00806        TBM_SETPOS,TRUE,(LPARAM)0);
00807      if(xpos == -1 && ypos == -1){
00808        CentreDialogOnCursor(hwnd);
00809        GetWindowRect(hwnd,&rc);
00810        p.x=rc.right; p.y=rc.top;
00811        ScreenToClient(ghwnd_main,&p);
00812        xpos=p.x; ypos=p.y;
00813      }
00814      else SetWindowPos(hwnd,HWND_TOP,xpos,ypos,0,0,SWP_NOSIZE);
00815      return (TRUE);
00816    case WM_DESTROY:
00817      GetWindowRect(hwnd,&rc);
00818      xpos=rc.left; ypos=rc.top;
00819      break;
00820    case WM_HSCROLL:
00821      if((HWND)lparam == (hctl=GetDlgItem(hwnd,DLG_EXPAND_SLIDER))){
00822        iMin=SendMessage(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),
00823          TBM_GETRANGEMIN,0,0);
00824        iMax=SendMessage(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),
00825          TBM_GETRANGEMAX,0,0);
00826 //       GetScrollRange(hctl,SB_CTL,&iMin,&iMax);
00827        switch (LOWORD(wparam)) {
00828          case SB_PAGEDOWN: xpand_a = min(iMax,xpand_a+5); break;
00829          case SB_LINEDOWN: xpand_a = min(iMax,xpand_a+1); break;
00830          case SB_PAGEUP:   xpand_a = max(iMin,xpand_a-5); break;
00831          case SB_LINEUP:   xpand_a = max(iMin,xpand_a-1); break;
00832 //         case SB_THUMBTRACK:
00833 //         case SB_THUMBPOSITION:
00834          case TB_THUMBTRACK:
00835          case TB_THUMBPOSITION:
00836            xpand_a=(int)((short)HIWORD(wparam));  break;
00837          default: break;
00838        }
00839 //       SetScrollPos(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),SB_CTL,xpand_a,TRUE);
00840        SendMessage(GetDlgItem(hwnd,DLG_EXPAND_SLIDER),
00841          TBM_SETPOS,TRUE,(LPARAM)xpand_a);
00842        a=3.0*(double)xpand_a/(double)RANGE;
00843        if(xpand_a < 0){
00844          a=1.0/(1.0-a);
00845        }
00846        else if(xpand_a > 0){
00847          a=1.0+a;
00848        }
00849        else a=1.0;
00850        sprintf(tempstr,"%.2lf",a); xpand_y=xpand_z=xpand_x=a;
00851        SendDlgItemMessage(hwnd,DLG_EXPAND_EDITLR,WM_SETTEXT,0,(LPARAM)tempstr);
00852        SendDlgItemMessage(hwnd,DLG_EXPAND_EDITFB,WM_SETTEXT,0,(LPARAM)tempstr);
00853        SendDlgItemMessage(hwnd,DLG_EXPAND_EDITUD,WM_SETTEXT,0,(LPARAM)tempstr);
00854      }
00855      break;
00856    case WM_COMMAND:
00857      switch(LOWORD(wparam)){
00858        case DLG_EXPAND_LR: xpand_X = !xpand_X; break;
00859        case DLG_EXPAND_FB: xpand_Y = !xpand_Y; break;
00860        case DLG_EXPAND_UD: xpand_Z = !xpand_Z; break;
00861        case DLG_EXPAND_VERT: xpand_vf=TRUE;    break;
00862        case DLG_EXPAND_FACE: xpand_vf=FALSE;   break;
00863        case DLG_EXPAND_CURSOR: xpand_cu=TRUE;  break;
00864        case DLG_EXPAND_CENTRE: xpand_cu=FALSE; break;
00865        case DLG_EXPAND_14: strcpy(tempstr,"0.250"); goto DISPLAY;
00866        case DLG_EXPAND_13: strcpy(tempstr,"0.333"); goto DISPLAY;
00867        case DLG_EXPAND_12: strcpy(tempstr,"0.500"); goto DISPLAY;
00868        case DLG_EXPAND_2:  strcpy(tempstr,"2.000"); goto DISPLAY;
00869        case DLG_EXPAND_3:  strcpy(tempstr,"3.000"); goto DISPLAY;
00870        case DLG_EXPAND_4:  strcpy(tempstr,"4.000"); goto DISPLAY;
00871          DISPLAY:
00872          sscanf(tempstr,"%lf",&xpand_x); xpand_y=xpand_z=xpand_x;
00873          SendDlgItemMessage(hwnd,DLG_EXPAND_EDITLR,WM_SETTEXT,0,(LPARAM)tempstr);
00874          SendDlgItemMessage(hwnd,DLG_EXPAND_EDITFB,WM_SETTEXT,0,(LPARAM)tempstr);
00875          SendDlgItemMessage(hwnd,DLG_EXPAND_EDITUD,WM_SETTEXT,0,(LPARAM)tempstr);
00876          break;
00877        case DLG_EXPAND_EXPAND:
00878        case IDCANCEL:
00879        case DLG_EXPAND_DONE:
00880          if(GetDlgItemText(hwnd,DLG_EXPAND_EDITLR,tempstr,10) != 0 &&
00881             (a=atof(tempstr)) != 0)xpand_x=a;
00882          if(GetDlgItemText(hwnd,DLG_EXPAND_EDITFB,tempstr,10) != 0 &&
00883             (a=atof(tempstr)) != 0)xpand_y=a;
00884          if(GetDlgItemText(hwnd,DLG_EXPAND_EDITUD,tempstr,10) != 0 &&
00885             (a=atof(tempstr)) != 0)xpand_z=a;
00886          if(LOWORD(wparam) == DLG_EXPAND_EXPAND){
00887            long  cx,cy,cz;
00888            double sx,sy,sz,medianX,medianY,medianZ;
00889            int i;
00890            vertex *vp,*V0,*V1,*V2;
00891            face *fp;
00892            Save_Undo(1);
00893            if(xpand_X)sx=xpand_x; else sx=1.0;
00894            if(xpand_Y)sy=xpand_y; else sy=1.0;
00895            if(xpand_Z)sz=xpand_z; else sz=1.0;
00896            cx=NpointerX; cy=NpointerY; cz=NpointerZ;
00897            if(!xpand_cu){
00898              point p,temp;
00899              get_centre(1,p,temp,FALSE);
00900              cx=p[0]; cy=p[1]; cz=p[2];
00901            }
00902            if(xpand_vf){/* expand using verts */
00903              vp=MainVp; if(Nvert > 0)for(i=0;i<Nvert;i++){
00904                if(vp->status==SELECTED){
00905                  vp->xyz[0]=(long)((double)(vp->xyz[0]-cx)*sx)+cx;
00906                  vp->xyz[1]=(long)((double)(vp->xyz[1]-cy)*sy)+cy;
00907                  vp->xyz[2]=(long)((double)(vp->xyz[2]-cz)*sz)+cz;
00908                }
00909                vp++;
00910              }
00911            }
00912            else{ /* expand using faces */
00913              if((fp=MainFp) != NULL)for(i=0;i<Nface;i++){
00914                V0=(MainVp+fp->V[0]);
00915                V1=(MainVp+fp->V[1]);
00916                V2=(MainVp+fp->V[2]);
00917                if(V0->status == SELECTED ||
00918                   V1->status == SELECTED ||
00919                   V2->status == SELECTED){
00920                  medianX=(V0->xyz[0] + V1->xyz[0] + V2->xyz[0])/3.0;
00921                  medianY=(V0->xyz[1] + V1->xyz[1] + V2->xyz[1])/3.0;
00922                  medianZ=(V0->xyz[2] + V1->xyz[2] + V2->xyz[2])/3.0;
00923                  V0->xyz[0]=(long)(((double)V0->xyz[0]-medianX)*sx)+medianX;
00924                  V0->xyz[1]=(long)(((double)V0->xyz[1]-medianY)*sy)+medianY;
00925                  V0->xyz[2]=(long)(((double)V0->xyz[2]-medianZ)*sz)+medianZ;
00926                  V1->xyz[0]=(long)(((double)V1->xyz[0]-medianX)*sx)+medianX;
00927                  V1->xyz[1]=(long)(((double)V1->xyz[1]-medianY)*sy)+medianY;
00928                  V1->xyz[2]=(long)(((double)V1->xyz[2]-medianZ)*sz)+medianZ;
00929                  V2->xyz[0]=(long)(((double)V2->xyz[0]-medianX)*sx)+medianX;
00930                  V2->xyz[1]=(long)(((double)V2->xyz[1]-medianY)*sy)+medianY;
00931                  V2->xyz[2]=(long)(((double)V2->xyz[2]-medianZ)*sz)+medianZ;
00932                }
00933                fp++;
00934              }
00935            }
00936            ExpandNurbsAction(cx,cy,cz,sx,sy,sz);
00937            DrawModel();
00938            if(ghwndOpenGLview == NULL)Draw3dView(0,0);
00939            else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0); // update
00940            break;
00941          }
00942          DestroyWindow(ghwndDlgExpand);
00943          ghwndDlgExpand=NULL;
00944 //         EndDialog(hwnd,OK);
00945 //         return(TRUE);
00946        default:
00947          break;
00948      }
00949      break;
00950    default: break;
00951  }
00952  return(FALSE);
00953 #undef RANGE
00954 }
00955 
00956 static skel *GetSkelFromList(HWND hdlg, skel *Sp){
00957  int i,n=0;
00958  skel *sp;
00959  HWND hctl;
00960  hctl=GetDlgItem(hdlg,DLG_SKEL_DIR);
00961  if((i=SendMessage(hctl,LB_GETCURSEL,0,0)) == LB_ERR)return NULL;
00962  if((sp=FirstSp) != NULL)while(sp != NULL){
00963    if(sp->at == Sp){
00964      if(i == n)return sp;
00965      n++;
00966    }
00967    sp=sp->next;
00968  }
00969  return NULL;
00970 }
00971 
00972 static int UpdateHierarchyList(HWND hdlg,skel *Sp, skel *Ssp){
00973  BOOL active;
00974  int n=0,id=0;
00975  HWND hctl;
00976  skel *sp,*spp=NULL,*sp1=NULL;
00977  hctl=GetDlgItem(hdlg,DLG_SKEL_DIR);
00978  SendMessage(hctl,LB_RESETCONTENT,0,0);
00979  if((sp=FirstSp) != NULL)while(sp != NULL){
00980    if(sp->at == Sp){
00981      SendMessage(hctl,LB_ADDSTRING,0,(LPARAM)(sp->name));
00982      if(sp == Ssp){id=n; spp=sp;}
00983      sp1=sp;
00984      n++;
00985    }
00986    sp=sp->next;
00987  }
00988  if(n == 0)SendMessage(hctl,LB_ADDSTRING,0,(LPARAM)"<end>");
00989  else      SendMessage(hctl,LB_SETCURSEL,(WPARAM)id,0);
00990  if(Sp == NULL)active=FALSE; else active=TRUE;
00991  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_ADD),active);
00992  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_DELETE),active);
00993  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_PARENT),active);
00994  if(n == 0)active=FALSE; else active=TRUE;
00995  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_RENAME),active);
00996  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_CHILD),active);
00997  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_SELECT),active);
00998  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_DESELECT),active);
00999  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_HIDE),active);
01000  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_ATTACH),active);
01001  EnableWindow(GetDlgItem(hdlg,DLG_SKEL_DETACH),active);
01002  {
01003    char c1[64],c2[64];
01004    if(spp == NULL){
01005      if(Ssp == NULL){
01006        if(sp1 == NULL){
01007          if(Sp == NULL)sp=FirstSp;
01008          else sp=Sp;
01009        }
01010        else sp=sp1;
01011      }
01012      else sp=Ssp;
01013    }
01014    else sp=spp;
01015    if(sp == NULL)sp=FirstSp; /* last resort */
01016    strcpy(c1,"\\"); strcat(c1,sp->name);
01017    sp=sp->at;
01018    while(sp != NULL){
01019      strcpy(c2,"\\"); strcat(c2,sp->name); strcat(c2,c1);
01020      strcpy(c1,c2);
01021      if(strlen(c1) > 60)break;
01022      sp=sp->at;
01023    }
01024    strcat(c1,"\\");
01025    SendDlgItemMessage(hdlg,DLG_SKEL_FAMILY,WM_SETTEXT,0,(LPARAM)c1);
01026  }
01027  return n;
01028 }
01029 
01030 BOOL CALLBACK HierarchyDlgProc(HWND hwnd, UINT msg,
01031                           WPARAM wparam, LPARAM lparam){
01032  static int Nlist;
01033  char local_name[16];
01034  int i;
01035  skel *sp;
01036  vertex *vp;
01037  switch( msg ) {
01038    case WM_PAINT:
01039      PaintDialogBackground(hwnd,ghinst_main);
01040      break;
01041    case WM_INITDIALOG:
01042      current_skeleton=NULL;
01043      Nlist=UpdateHierarchyList(hwnd,current_skeleton,FirstSp);
01044      EnableWindow(ghwnd_main,TRUE);
01045      EnableWindow(GetDlgItem(hwnd,DLG_SKEL_FAMILY),FALSE);
01046      CentreDialogOnCursor(hwnd);
01047      return (TRUE);
01048    case WM_COMMAND:
01049      switch(HIWORD(wparam)){
01050        case LBN_DBLCLK:
01051          SendMessage(hwnd,WM_COMMAND,MAKEWPARAM(DLG_SKEL_CHILD,0),0);
01052          break;
01053        default:
01054          break;
01055      }
01056      switch(LOWORD(wparam)){
01057        case DLG_SKEL_ROOT:
01058          current_skeleton=NULL;
01059          Nlist=UpdateHierarchyList(hwnd,current_skeleton,FirstSp);
01060          break;
01061        case DLG_SKEL_PARENT:
01062          if(current_skeleton != NULL){
01063            Nlist=UpdateHierarchyList(hwnd,current_skeleton->at,current_skeleton);
01064            current_skeleton=current_skeleton->at;
01065          }
01066          break;
01067        case DLG_SKEL_CHILD:
01068          if(Nlist > 0){
01069            sp=GetSkelFromList(hwnd,current_skeleton);
01070            if(sp != NULL){
01071              Nlist=UpdateHierarchyList(hwnd,sp,NULL);
01072              current_skeleton=sp;
01073            }
01074          }
01075          break;
01076        case DLG_SKEL_DELETE:
01077          sp=GetSkelFromList(hwnd,current_skeleton);
01078          if(sp != NULL && sp->at != NULL){
01079            SkDelete(sp);
01080            Nlist=UpdateHierarchyList(hwnd,current_skeleton,NULL);
01081          }
01082          break;
01083        case DLG_SKEL_RENAME:
01084          sp=GetSkelFromList(hwnd,current_skeleton);
01085          strcpy(local_name,sp->name);
01086          RequestCharString(12,local_name,"New Name",hwnd);
01087          if(strlen(local_name) > 0){
01088            strcpy(sp->name,local_name);
01089            Nlist=UpdateHierarchyList(hwnd,current_skeleton,sp);
01090          }
01091          break;
01092        case DLG_SKEL_ADD:
01093          if(current_skeleton == NULL)break;
01094          CreateSkeleton(current_skeleton);
01095          MainSp->xyz[2] = -(long)MINUNIT*4L*Nskel;
01096          ZeroSkeletonBoundingBox(MainSp);
01097          strcpy(local_name,MainSp->name);
01098          RequestCharString(12,local_name,"New Name",hwnd);
01099          if(strlen(local_name) > 0)strcpy(MainSp->name,local_name);
01100          Nlist=UpdateHierarchyList(hwnd,current_skeleton,MainSp);
01101          break;
01102        case DLG_SKEL_ATTACH:
01103          if((sp=GetSkelFromList(hwnd,current_skeleton)) == NULL)break;
01104          GetSkeletonBoundBox(sp,1); /* assign as well */
01105          break;
01106        case DLG_SKEL_DETACH:
01107          if((sp=GetSkelFromList(hwnd,current_skeleton)) == NULL)break;
01108          if((vp=MainVp) != NULL)for(i=0;i<Nvert;i++,vp++){
01109            if(vp->sp == sp)vp->sp=NULL;
01110          }
01111          break;
01112        case DLG_SKEL_SELECT:
01113        case DLG_SKEL_DESELECT:
01114        case DLG_SKEL_HIDE:
01115          if((sp=GetSkelFromList(hwnd,current_skeleton)) == NULL)break;
01116          SelectByHierarchy(sp,(int)LOWORD(wparam));
01117          break;
01118        case IDCANCEL:
01119        case DLG_SKEL_DONE:
01120          current_skeleton=NULL;
01121          EndDialog(hwnd,OK);
01122          return(TRUE);
01123        default:
01124          break;
01125      }
01126      break;
01127    default: break;
01128  }
01129  return(FALSE);
01130 }
01131 
01132 BOOL CALLBACK SqueezeDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam){
01133  double *d,d1;
01134  char tempstr[16];
01135  switch( msg ) {
01136    case WM_PAINT:
01137      PaintDialogBackground(hdlg,ghinst_main);
01138      break;
01139    case WM_INITDIALOG:
01140      d=(double *)lparam;
01141      SetWindowLong(hdlg,GWL_USERDATA,lparam);
01142      EnableToolPannels(ALL_PANNELS,FALSE);
01143      sprintf(tempstr,"%.2lf",*d);
01144      SendDlgItemMessage(hdlg,DLG_SQUEEZE_WELDVALUE,WM_SETTEXT,0,(LPARAM)tempstr);
01145      SendDlgItemMessage(hdlg,DLG_SQUEEZE_WELDVALUE,EM_LIMITTEXT,(WPARAM)12,0);
01146      CentreDialogOnCursor(hdlg);
01147      return (TRUE);
01148    case WM_DESTROY:
01149      EnableToolPannels(ALL_PANNELS,TRUE);
01150      break;
01151    case WM_COMMAND:
01152       d=(double *)GetWindowLong(hdlg,GWL_USERDATA);
01153       switch(LOWORD(wparam)){
01154         case IDCANCEL:
01155           EndDialog(hdlg,0);
01156           return(TRUE);
01157         case DLG_SQUEEZE_CUR:
01158           EndDialog(hdlg,1);
01159           return(TRUE);
01160         case DLG_SQUEEZE_CENT:
01161           EndDialog(hdlg,2);
01162           return(TRUE);
01163         case DLG_SQUEEZE_WELD:
01164           if(GetDlgItemText(hdlg,DLG_SQUEEZE_WELDVALUE,tempstr,10) == 0){
01165             EndDialog(hdlg,0);
01166             return(TRUE);
01167           }
01168           if((d1=atof(tempstr)) == 0){
01169             EndDialog(hdlg,0);
01170             return(TRUE);
01171           }
01172           *d=d1;
01173           EndDialog(hdlg,3);
01174           return(TRUE);
01175         default:  break;
01176       }
01177       break;
01178     default: break;
01179  }
01180  return(FALSE);
01181 }
01182 
01183 BOOL CALLBACK ExplodeDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam){
01184  struct TEMP {int id,id1; double dxx,dyy,dzz;} *tc;
01185  char tempstr[16];
01186  switch( msg ) {
01187    case WM_PAINT:
01188      PaintDialogBackground(hdlg,ghinst_main);
01189      break;
01190    case WM_INITDIALOG:
01191      tc=(struct TEMP *)lparam;
01192      SetWindowLong(hdlg,GWL_USERDATA,lparam);
01193      EnableToolPannels(ALL_PANNELS,FALSE);
01194      if(tc->id == 5)SendDlgItemMessage(hdlg,DLG_EXPLODE_FACES,BM_SETCHECK,TRUE,0);
01195      if(tc->id1 == 1)SendDlgItemMessage(hdlg,DLG_EXPLODE_FO_RANDOM,BM_SETCHECK,TRUE,0);
01196      sprintf(tempstr,"%.2lf",tc->dxx);
01197      SendDlgItemMessage(hdlg,DLG_EXPLODE_FO_PROPX,WM_SETTEXT,0,(LPARAM)tempstr);
01198      SendDlgItemMessage(hdlg,DLG_EXPLODE_FO_PROPX,EM_LIMITTEXT,(WPARAM)12,0);
01199      sprintf(tempstr,"%.2lf",tc->dyy);
01200      SendDlgItemMessage(hdlg,DLG_EXPLODE_FO_PROPY,WM_SETTEXT,0,(LPARAM)tempstr);
01201      SendDlgItemMessage(hdlg,DLG_EXPLODE_FO_PROPY,EM_LIMITTEXT,(WPARAM)12,0);
01202      sprintf(tempstr,"%.2lf",tc->dzz);
01203      SendDlgItemMessage(hdlg,DLG_EXPLODE_FO_PROPZ,WM_SETTEXT,0,(LPARAM)tempstr);
01204      SendDlgItemMessage(hdlg,DLG_EXPLODE_FO_PROPZ,EM_LIMITTEXT,(WPARAM)12,0);
01205      CentreDialogOnCursor(hdlg);
01206      return (TRUE);
01207    case WM_DESTROY:
01208      EnableToolPannels(ALL_PANNELS,TRUE);
01209      break;
01210    case WM_COMMAND:
01211       tc=(struct TEMP *)GetWindowLong(hdlg,GWL_USERDATA);
01212       switch(LOWORD(wparam)){
01213         case DLG_EXPLODE_SPHERE:     tc->id=1;  break;
01214         case DLG_EXPLODE_H:          tc->id=2;  break;
01215         case DLG_EXPLODE_VFB:        tc->id=3;  break;
01216         case DLG_EXPLODE_VLR:        tc->id=4;  break;
01217         case DLG_EXPLODE_FACES:      tc->id=5;  break;
01218         case DLG_EXPLODE_GRID:       tc->id=6;  break;
01219         case DLG_EXPLODE_FO_UNIFORM: tc->id1=0; break;
01220         case DLG_EXPLODE_FO_RANDOM:  tc->id1=1; break;
01221         case DLG_EXPLODE_FO_PROP:    tc->id1=2; break;
01222         case IDCANCEL:
01223           tc->id=0;
01224           EndDialog(hdlg,FALSE);
01225           return(TRUE);
01226         case IDOK:
01227           if(GetDlgItemText(hdlg,DLG_EXPLODE_FO_PROPX,tempstr,10) == 0)
01228              tc->id=0;
01229           if((tc->dxx=atof(tempstr)) == 0)tc->id=0;
01230           if(GetDlgItemText(hdlg,DLG_EXPLODE_FO_PROPY,tempstr,10) == 0)
01231              tc->id=0;
01232           if((tc->dyy=atof(tempstr)) == 0)tc->id=0;
01233           if(GetDlgItemText(hdlg,DLG_EXPLODE_FO_PROPZ,tempstr,10) == 0)
01234              tc->id=0;
01235           if((tc->dzz=atof(tempstr)) == 0)tc->id=0;
01236           EndDialog(hdlg,TRUE);
01237           return(TRUE);
01238         default:  break;
01239       }
01240       break;
01241     default: break;
01242  }
01243  return(FALSE);
01244 }
01245 
01246 // Preferences code
01247 
01248 static BOOL CALLBACK GeneralPreferencesDlgProc(HWND hdlg,UINT msg,
01249                            WPARAM wparam,LPARAM lparam){
01250  BOOL state;
01251  char *w, yesyes[]="YES", nono[]="NO";
01252  static unsigned char uColour[3];
01253  switch( msg ) {
01254    case WM_PAINT:
01255      PaintDialogBackground(hdlg,ghinst_main);
01256      break;
01257    case WM_INITDIALOG:
01258      CentreDialogOnScreen(GetParent(hdlg));
01259      if(Preferences.buttons)state=TRUE; else state=FALSE;
01260      SendDlgItemMessage(hdlg,DLG_PREFERENCES_BUTTONS,BM_SETCHECK,state,0);
01261      if(Preferences.quick_trick)state=TRUE; else state=FALSE;
01262      SendDlgItemMessage(hdlg,DLG_PREFERENCES_QUICKTRICK,BM_SETCHECK,state,0);
01263      if(Preferences.undo)state=TRUE; else state=FALSE;
01264      SendDlgItemMessage(hdlg,DLG_PREFERENCES_UNDO,BM_SETCHECK,state,0);
01265      if(Preferences.tooltips)state=TRUE; else state=FALSE;
01266      SendDlgItemMessage(hdlg,DLG_PREFERENCES_TOOLTIPS,BM_SETCHECK,state,0);
01267      if(Preferences.bigv)state=TRUE; else state=FALSE;
01268      SendDlgItemMessage(hdlg,DLG_PREFERENCES_BIGV,BM_SETCHECK,state,0);
01269      if(Preferences.use_positions)state=TRUE; else state=FALSE;
01270      SendDlgItemMessage(hdlg,DLG_PREFERENCES_POSITIONS,BM_SETCHECK,state,0);
01271      if(Preferences.toolsmall)state=TRUE; else state=FALSE;
01272      SendDlgItemMessage(hdlg,DLG_PREFERENCES_TOOLSMALL,BM_SETCHECK,state,0);
01273      if(Preferences.toolleft)state=TRUE; else state=FALSE;
01274      SendDlgItemMessage(hdlg,DLG_PREFERENCES_TOOLLEFT,BM_SETCHECK,state,0);
01275      uColour[0]=Preferences.Vcolour[0];
01276      uColour[1]=Preferences.Vcolour[1];
01277      uColour[2]=Preferences.Vcolour[2];
01278      return (TRUE);
01279    case WM_DRAWITEM:{
01280        LPDRAWITEMSTRUCT lpdis;
01281        HBRUSH   hbr,hbrold;
01282        BYTE r,g,b;
01283        lpdis=(LPDRAWITEMSTRUCT)lparam;
01284        if(lpdis->CtlID == DLG_PREFERENCES_VCOLOUR){
01285          r=uColour[0]; g=uColour[1]; b=uColour[2];
01286          if(lpdis->itemState & ODS_SELECTED)
01287            InvertRect(lpdis->hDC,&(lpdis->rcItem));
01288          else{
01289            hbr=CreateSolidBrush(RGB(r,g,b));
01290            hbrold=SelectObject(lpdis->hDC,hbr);
01291            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
01292                          lpdis->rcItem.right,lpdis->rcItem.bottom);
01293            SelectObject(lpdis->hDC,hbrold);
01294            DeleteObject(hbr);
01295          }
01296        }
01297      }
01298      return TRUE;
01299    case WM_NOTIFY:
01300      switch(((LPNMHDR)lparam)->code){
01301        case PSN_APPLY:
01302          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_BUTTONS,BM_GETCHECK,0,0))
01303             Preferences.buttons=TRUE; else Preferences.buttons=FALSE;
01304          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_QUICKTRICK,BM_GETCHECK,0,0))
01305             Preferences.quick_trick=TRUE; else Preferences.quick_trick=FALSE;
01306          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_UNDO,BM_GETCHECK,0,0))
01307             Preferences.undo=TRUE; else Preferences.undo=FALSE;
01308          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_TOOLTIPS,BM_GETCHECK,0,0))
01309             Preferences.tooltips=TRUE; else Preferences.tooltips=FALSE;
01310          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_BIGV,BM_GETCHECK,0,0))
01311             Preferences.bigv=TRUE; else Preferences.bigv=FALSE;
01312          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_POSITIONS,BM_GETCHECK,0,0))
01313             Preferences.use_positions=TRUE; else Preferences.use_positions=FALSE;
01314          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_TOOLSMALL,BM_GETCHECK,0,0))
01315             Preferences.toolsmall=TRUE; else Preferences.toolsmall=FALSE;
01316          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_TOOLLEFT,BM_GETCHECK,0,0))
01317             Preferences.toolleft=TRUE; else Preferences.toolleft=FALSE;
01318          if(Preferences.buttons)w=yesyes; else w=nono;
01319          WritePrivateProfileString(IniSection,"BUTTONS",w,IniFilename);
01320          if(Preferences.quick_trick)w=yesyes; else w=nono;
01321          WritePrivateProfileString(IniSection,"QUICKTRICK",w,IniFilename);
01322          if(Preferences.undo){
01323            w=yesyes;
01324            UNDO_ON=1;
01325          }
01326          else{
01327            UNDO_ON=0;
01328            Empty_Undo();
01329            w=nono;
01330          }
01331          WritePrivateProfileString(IniSection,"UNDO",w,IniFilename);
01332          { char pref_str[32];
01333            Preferences.Vcolour[0]=uColour[0];
01334            Preferences.Vcolour[1]=uColour[1];
01335            Preferences.Vcolour[2]=uColour[2];
01336            sprintf(pref_str,"%ld %ld %ld",(long)uColour[0],
01337                    (long)uColour[1],(long)uColour[2]);
01338            WritePrivateProfileString(IniSection,"VIEWCOLOUR",
01339                                       pref_str,IniFilename);
01340          }
01341          if(Preferences.tooltips)w=yesyes; else w=nono;
01342          WritePrivateProfileString(IniSection,"TOOLTIPS",w,IniFilename);
01343          if(Preferences.bigv)w=yesyes; else w=nono;
01344          WritePrivateProfileString(IniSection,"BIGV",w,IniFilename);
01345          if(Preferences.use_positions)w=yesyes; else w=nono;
01346          WritePrivateProfileString(IniSection,"POSITIONS",w,IniFilename);
01347          if(Preferences.toolsmall)w=yesyes; else w=nono;
01348          WritePrivateProfileString(IniSection,"TOOLSMALL",w,IniFilename);
01349          if(Preferences.toolleft)w=yesyes; else w=nono;
01350          WritePrivateProfileString(IniSection,"TOOLLEFT",w,IniFilename);
01351          break;
01352        default:  break;
01353      }
01354      break;
01355    case WM_COMMAND:
01356       switch(LOWORD(wparam)){
01357         case DLG_PREFERENCES_VCOLOUR:
01358           SetSfxColour(uColour,IDX_MISC_BACK_COLOUR,hdlg);
01359           InvalidateRect(GetDlgItem(hdlg,DLG_PREFERENCES_VCOLOUR),NULL,FALSE);
01360           break;
01361         default: break;
01362       }
01363       break;
01364    default: break;
01365  }
01366  return(FALSE);
01367 }
01368 
01369 static BOOL CALLBACK StartupPreferencesDlgProc(HWND hdlg,UINT msg,
01370                            WPARAM wparam,LPARAM lparam){
01371  BOOL state;
01372  char *w, yesyes[]="YES", nono[]="NO";
01373  switch( msg ) {
01374    case WM_PAINT:
01375      PaintDialogBackground(hdlg,ghinst_main);
01376      break;
01377    case WM_INITDIALOG:
01378      if(Preferences.use_OpenGL)state=TRUE; else state=FALSE;
01379      SendDlgItemMessage(hdlg,DLG_PREFERENCES_OPENGL,BM_SETCHECK,state,0);
01380      if(Preferences.background)state=TRUE; else state=FALSE;
01381      SendDlgItemMessage(hdlg,DLG_PREFERENCES_BACKGROUND,BM_SETCHECK,state,0);
01382      return (TRUE);
01383    case WM_NOTIFY:
01384      switch(((LPNMHDR)lparam)->code){
01385        case PSN_APPLY:
01386          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_OPENGL,BM_GETCHECK,0,0))
01387             Preferences.use_OpenGL=TRUE; else Preferences.use_OpenGL=FALSE;
01388          if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_BACKGROUND,BM_GETCHECK,0,0))
01389             Preferences.background=TRUE; else Preferences.background=FALSE;
01390          if(Preferences.use_OpenGL)w=yesyes; else w=nono;
01391          WritePrivateProfileString(IniSection,"USEOPENGL",w,IniFilename);
01392          if(Preferences.background)w=yesyes; else w=nono;
01393          WritePrivateProfileString(IniSection,"BACKIMAGE",w,IniFilename);
01394          break;
01395        default:  break;
01396      }
01397      break;
01398    default: break;
01399  }
01400  return(FALSE);
01401 }
01402 
01403 void PreferencesPropertyDlgProc(HWND hwndOwner){
01404  char title[256];
01405  int i;
01406  PROPSHEETPAGE psp[2];
01407  PROPSHEETHEADER psh;
01408  for(i=0;i<2;i++){
01409    psp[i].dwSize = sizeof(PROPSHEETPAGE);
01410    psp[i].dwFlags = PSP_DEFAULT;
01411    psp[i].hInstance = ghinst_main;
01412    psp[i].pszIcon = NULL;
01413    psp[i].lParam = 0;
01414  }
01415  psp[0].pszTemplate = MAKEINTRESOURCE(DLG_PREFERENCES_GENERAL);
01416  psp[0].pfnDlgProc = (DLGPROC)GeneralPreferencesDlgProc;
01417  psp[1].pszTemplate = MAKEINTRESOURCE(DLG_PREFERENCES_START);
01418  psp[1].pfnDlgProc = (DLGPROC)StartupPreferencesDlgProc;
01419  psh.dwSize = sizeof(PROPSHEETHEADER);
01420  psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW;
01421  psh.hwndParent = hwndOwner;
01422  psh.hInstance = ghinst_main;
01423  psh.nStartPage = 0;
01424  psh.pszIcon = NULL;
01425  LoadString(ghinst_main,IDX_MISC_PREF_TITLE,title,255);
01426  psh.pszCaption = (LPSTR)title;
01427  psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
01428  psh.ppsp = (LPCPROPSHEETPAGE) &psp;
01429  PropertySheet(&psh);
01430  return;
01431 }
01432 
01433 //end Preferences
01434 
01435 #include "..\common\animate\about.h"
01436 
01437 BOOL CALLBACK AboutDlgProc(HWND hdlg,UINT msg,
01438                            WPARAM wparam,LPARAM lparam){
01439  char name[255];
01440  switch( msg ) {
01441    case WM_PAINT:
01442      PaintDialogBackground(hdlg,ghinst_main);
01443      break;
01444    case WM_INITDIALOG:
01445      CentreDialogOnScreen(hdlg);
01446 //     strcpy(name,gszHomeDir);
01447 //     strcat(name,"OPENFX.AVI");
01448      SendDlgItemMessage(hdlg,DLG_ABOUT_VERSION,WM_SETTEXT,
01449                        0,(LPARAM)ABOUT_VERSION);
01450 //     Animate_Open(GetDlgItem(hdlg, DLG_ABOUT_ANIMATE),name);
01451      return TRUE;
01452    case WM_COMMAND:
01453       switch(LOWORD(wparam)){
01454         case IDCANCEL:
01455         case IDOK:
01456           EndDialog(hdlg,TRUE);
01457           return(TRUE);
01458         default:  break;
01459       }
01460       break;
01461     default: break;
01462  }
01463  return(FALSE);
01464 }
01465 
01466 BOOL CALLBACK RotateDlgProc(HWND hwnd, UINT msg,
01467                             WPARAM wparam, LPARAM lparam){
01468  BOOL err,active;
01469  int i;
01470  struct np {int a; BOOL clock;} *dp;
01471  switch( msg ) {
01472    case WM_PAINT:
01473      PaintDialogBackground(hwnd,ghinst_main);
01474      break;
01475    case WM_INITDIALOG:{
01476        dp=(struct np *)lparam;
01477        SetDlgItemInt(hwnd,DLG_ROTATE_ANGLE,dp->a,FALSE);
01478        SendDlgItemMessage(hwnd,DLG_ROTATE_ANGLE,EM_LIMITTEXT,(WPARAM)6,0);
01479        SendDlgItemMessage(hwnd,DLG_ROTATE_ANGLESPIN,SPNM_SETRANGE,0,
01480                           MAKELPARAM(0,360));
01481        SendDlgItemMessage(hwnd,DLG_ROTATE_ANGLESPIN,SPNM_SETCRNTVALUE,
01482                           (WPARAM)dp->a,0);
01483        SendDlgItemMessage(hwnd,DLG_ROTATE_ANGLESPIN,SPNM_SETEDITCTRL,0,
01484                           (LPARAM)GetDlgItem(hwnd,DLG_ROTATE_ANGLE));
01485        SetWindowLong(hwnd,GWL_USERDATA,lparam);
01486        if(dp->clock == 0)active=TRUE; else active=FALSE;
01487        SendDlgItemMessage(hwnd,DLG_ROTATE_CLOCK,BM_SETCHECK,active,0);
01488        SendDlgItemMessage(hwnd,DLG_ROTATE_ANTICLOCK,BM_SETCHECK,!active,0);
01489        CentreDialogOnCursor(hwnd);
01490      }
01491      return (TRUE);
01492    case WM_COMMAND:
01493       switch(LOWORD(wparam)){
01494         case IDCANCEL:
01495           EndDialog(hwnd,FALSE);
01496           return(TRUE);
01497         case IDOK:
01498           dp=(struct np *)GetWindowLong(hwnd,GWL_USERDATA);
01499           i=GetDlgItemInt(hwnd,DLG_ROTATE_ANGLE,&err,FALSE);
01500           if(!err)EndDialog(hwnd,FAIL);
01501           dp->a=i;
01502           if(SendDlgItemMessage(hwnd,DLG_ROTATE_CLOCK,BM_GETCHECK,0,0))
01503                dp->clock=TRUE;
01504           else dp->clock=FALSE;
01505           EndDialog(hwnd,TRUE);
01506           return(TRUE);
01507         default:
01508           break;
01509       }
01510       break;
01511     default: break;
01512  }
01513  return(FALSE);
01514 }
01515 
01516 BOOL CALLBACK MoveDlgProc(HWND hwnd, UINT msg,
01517                           WPARAM wparam, LPARAM lparam){
01518  long i,x,y,z;
01519  char temp[64];
01520  vertex *vp;
01521  switch( msg ) {
01522    case WM_PAINT:
01523      PaintDialogBackground(hwnd,ghinst_main);
01524      break;
01525    case WM_INITDIALOG:{
01526        strcpy(temp,"0.00");
01527        SetDlgItemText(hwnd,DLG_MOVE_X,temp);
01528        SetDlgItemText(hwnd,DLG_MOVE_Y,temp);
01529        SetDlgItemText(hwnd,DLG_MOVE_Z,temp);
01530        CentreDialogOnCursor(hwnd);
01531      }
01532      return (TRUE);
01533    case WM_COMMAND:
01534       switch(LOWORD(wparam)){
01535         case IDCANCEL:
01536           EndDialog(hwnd,FALSE);
01537           return(TRUE);
01538         case IDOK:
01539           if(GetDlgItemText(hwnd,DLG_MOVE_X,temp,32) == 0)
01540             EndDialog(hwnd,FALSE);
01541           x=(long)(atof(temp)*ruler);
01542           if(GetDlgItemText(hwnd,DLG_MOVE_Y,temp,32) == 0)
01543             EndDialog(hwnd,FALSE);
01544           y=(long)(atof(temp)*ruler);
01545           if(GetDlgItemText(hwnd,DLG_MOVE_Z,temp,32) == 0)
01546             EndDialog(hwnd,FALSE);
01547           z=(long)(atof(temp)*ruler);
01548           vp=MainVp; if(Nvert > 0)for(i=0;i<Nvert;i++){
01549             if(vp->status==SELECTED){
01550               vp->xyz[0] += x;
01551               vp->xyz[1] += y;
01552               vp->xyz[2] += z;
01553             }
01554             vp++;
01555           }
01556           EndDialog(hwnd,TRUE);
01557           return(TRUE);
01558         default:
01559           break;
01560       }
01561       break;
01562     default: break;
01563  }
01564  return(FALSE);
01565 }
01566 
01567 // Primitives Dialog code
01568 
01569 extern long PrimitiveType;
01570 
01571 #define D_BORDER 4
01572 #define N_PRIMS 10
01573 
01574 typedef struct tag_dlghdr1 {
01575   HWND hwndDlg[N_PRIMS];
01576   RECT rcTab;
01577 } DLGHDR1;
01578 
01579 static DLGHDR1 DlgHdrPrimitives,*lpDlgHdrPrimitives;
01580 static HWND    hwndTabPrimitives;
01581 
01582 static void UpdateCubePrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
01583  char tempstr[16];
01584  sprintf(tempstr,"%.2lf",dp->lr);
01585  SendDlgItemMessage(hwnd,DLG_PR_CUBE_LR,WM_SETTEXT,0,(LPARAM)tempstr);
01586  SendDlgItemMessage(hwnd,DLG_PR_CUBE_LR,EM_LIMITTEXT,(WPARAM)12,0);
01587  sprintf(tempstr,"%.2lf",dp->fb);
01588  SendDlgItemMessage(hwnd,DLG_PR_CUBE_FB,WM_SETTEXT,0,(LPARAM)tempstr);
01589  SendDlgItemMessage(hwnd,DLG_PR_CUBE_FB,EM_LIMITTEXT,(WPARAM)12,0);
01590  sprintf(tempstr,"%.2lf",dp->ud);
01591  SendDlgItemMessage(hwnd,DLG_PR_CUBE_UD,WM_SETTEXT,0,(LPARAM)tempstr);
01592  SendDlgItemMessage(hwnd,DLG_PR_CUBE_UD,EM_LIMITTEXT,(WPARAM)12,0);
01593  sprintf(tempstr,"%.2lf",dp->width);
01594  SendDlgItemMessage(hwnd,DLG_PR_CUBE_WIDTH,WM_SETTEXT,0,(LPARAM)tempstr);
01595  SendDlgItemMessage(hwnd,DLG_PR_CUBE_WIDTH,EM_LIMITTEXT,(WPARAM)12,0);
01596  sprintf(tempstr,"%.2lf",dp->length);
01597  SendDlgItemMessage(hwnd,DLG_PR_CUBE_LENGTH,WM_SETTEXT,0,(LPARAM)tempstr);
01598  SendDlgItemMessage(hwnd,DLG_PR_CUBE_LENGTH,EM_LIMITTEXT,(WPARAM)12,0);
01599  sprintf(tempstr,"%.2lf",dp->height);
01600  SendDlgItemMessage(hwnd,DLG_PR_CUBE_HEIGHT,WM_SETTEXT,0,(LPARAM)tempstr);
01601  SendDlgItemMessage(hwnd,DLG_PR_CUBE_HEIGHT,EM_LIMITTEXT,(WPARAM)12,0);
01602  return;
01603 }
01604 
01605 BOOL CALLBACK CubePrimitiveDlgProc(HWND hwnd, UINT msg,
01606                                    WPARAM wparam, LPARAM lparam){
01607  char tempstr[16];
01608  PRIMITIVE *dp=&PrimStruct;
01609  switch( msg ) {
01610    case WM_PAINT:
01611      PaintDialogBackground(hwnd,ghinst_main);
01612      break;
01613    case WM_INITDIALOG:
01614      UpdateCubePrimitiveDlgProc(hwnd,dp);
01615      return (TRUE);
01616    case WM_DRAWITEM:{
01617        LPDRAWITEMSTRUCT lpdis;
01618        HBRUSH   hbr,hbrold;
01619        BYTE r,g,b;
01620        lpdis=(LPDRAWITEMSTRUCT)lparam;
01621        if(lpdis->CtlID == DLG_PR_CUBE_COLOUR){
01622          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
01623          if(lpdis->itemState & ODS_SELECTED)
01624             InvertRect(lpdis->hDC,&(lpdis->rcItem));
01625          else{
01626            hbr=CreateSolidBrush(RGB(r,g,b));
01627            hbrold=SelectObject(lpdis->hDC,hbr);
01628            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
01629                          lpdis->rcItem.right,lpdis->rcItem.bottom);
01630            SelectObject(lpdis->hDC,hbrold);
01631            DeleteObject(hbr);
01632          }
01633        }
01634      }
01635      return TRUE;
01636    case WM_UPDATEPDIALOG:
01637      UpdateCubePrimitiveDlgProc(hwnd,dp);
01638      break;
01639    case WM_COMMAND:
01640       switch(LOWORD(wparam)){
01641         case DLG_PR_CUBE_COLOUR:
01642           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
01643           InvalidateRect(GetDlgItem(hwnd,DLG_PR_CUBE_COLOUR),NULL,FALSE);
01644           break;
01645         case IDOK:
01646           GetDlgItemText(hwnd,DLG_PR_CUBE_LR,tempstr,10);
01647           dp->lr=atof(tempstr);
01648           GetDlgItemText(hwnd,DLG_PR_CUBE_FB,tempstr,10);
01649           dp->fb=atof(tempstr);
01650           GetDlgItemText(hwnd,DLG_PR_CUBE_UD,tempstr,10);
01651           dp->ud=atof(tempstr);
01652           GetDlgItemText(hwnd,DLG_PR_CUBE_WIDTH,tempstr,10);
01653           dp->width=atof(tempstr);
01654           GetDlgItemText(hwnd,DLG_PR_CUBE_LENGTH,tempstr,10);
01655           dp->length=atof(tempstr);
01656           GetDlgItemText(hwnd,DLG_PR_CUBE_HEIGHT,tempstr,10);
01657           dp->height=atof(tempstr);
01658           break;
01659         default:
01660           break;
01661       }
01662       break;
01663     default: break;
01664  }
01665  return(FALSE);
01666 }
01667 
01668 static void UpdateSpherePrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
01669  BOOL active;
01670  char tempstr[16];
01671  sprintf(tempstr,"%.2lf",dp->lr);
01672  SendDlgItemMessage(hwnd,DLG_PR_SPH_LR,WM_SETTEXT,0,(LPARAM)tempstr);
01673  SendDlgItemMessage(hwnd,DLG_PR_SPH_LR,EM_LIMITTEXT,(WPARAM)12,0);
01674  sprintf(tempstr,"%.2lf",dp->fb);
01675  SendDlgItemMessage(hwnd,DLG_PR_SPH_FB,WM_SETTEXT,0,(LPARAM)tempstr);
01676  SendDlgItemMessage(hwnd,DLG_PR_SPH_FB,EM_LIMITTEXT,(WPARAM)12,0);
01677  sprintf(tempstr,"%.2lf",dp->ud);
01678  SendDlgItemMessage(hwnd,DLG_PR_SPH_UD,WM_SETTEXT,0,(LPARAM)tempstr);
01679  SendDlgItemMessage(hwnd,DLG_PR_SPH_UD,EM_LIMITTEXT,(WPARAM)12,0);
01680  sprintf(tempstr,"%.2lf",dp->radius);
01681  SendDlgItemMessage(hwnd,DLG_PR_SPH_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
01682  SendDlgItemMessage(hwnd,DLG_PR_SPH_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
01683  if(dp->smooth == 1)active=TRUE; else active=FALSE;
01684  SendDlgItemMessage(hwnd,DLG_PR_SPH_ON,BM_SETCHECK,active,0);
01685  SendDlgItemMessage(hwnd,DLG_PR_SPH_OFF,BM_SETCHECK,!active,0);
01686  if(dp->faces == 20)
01687           SendDlgItemMessage(hwnd,DLG_PR_SPH_20,BM_SETCHECK,1,0);
01688  if(dp->faces == 80)
01689           SendDlgItemMessage(hwnd,DLG_PR_SPH_80,BM_SETCHECK,1,0);
01690  if(dp->faces == 320)
01691           SendDlgItemMessage(hwnd,DLG_PR_SPH_320,BM_SETCHECK,1,0);
01692  if(dp->faces == 1280)
01693           SendDlgItemMessage(hwnd,DLG_PR_SPH_1280,BM_SETCHECK,1,0);
01694  return;
01695 }
01696 
01697 BOOL CALLBACK SpherePrimitiveDlgProc(HWND hwnd, UINT msg,
01698                                     WPARAM wparam, LPARAM lparam){
01699  BOOL active;
01700  char tempstr[16];
01701  PRIMITIVE *dp=&PrimStruct;
01702  switch( msg ) {
01703    case WM_PAINT:
01704      PaintDialogBackground(hwnd,ghinst_main);
01705      break;
01706    case WM_INITDIALOG:
01707      UpdateSpherePrimitiveDlgProc(hwnd,dp);
01708      return (TRUE);
01709    case WM_DRAWITEM:{
01710        LPDRAWITEMSTRUCT lpdis;
01711        HBRUSH   hbr,hbrold;
01712        BYTE r,g,b;
01713        lpdis=(LPDRAWITEMSTRUCT)lparam;
01714        if(lpdis->CtlID == DLG_PR_SPH_COLOUR){
01715          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
01716          if(lpdis->itemState & ODS_SELECTED)
01717             InvertRect(lpdis->hDC,&(lpdis->rcItem));
01718          else{
01719            hbr=CreateSolidBrush(RGB(r,g,b));
01720            hbrold=SelectObject(lpdis->hDC,hbr);
01721            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
01722                          lpdis->rcItem.right,lpdis->rcItem.bottom);
01723            SelectObject(lpdis->hDC,hbrold);
01724            DeleteObject(hbr);
01725          }
01726        }
01727      }
01728      return TRUE;
01729    case WM_UPDATEPDIALOG:
01730      UpdateSpherePrimitiveDlgProc(hwnd,dp);
01731      break;
01732    case WM_COMMAND:
01733       switch(LOWORD(wparam)){
01734         case DLG_PR_SPH_20:
01735           dp->faces=20;
01736           break;
01737         case DLG_PR_SPH_80:
01738           dp->faces=80;
01739           break;
01740         case DLG_PR_SPH_320:
01741           dp->faces=320;
01742           break;
01743         case DLG_PR_SPH_1280:
01744           dp->faces=1280;
01745           break;
01746         case DLG_PR_SPH_ON:
01747           dp->smooth=1;
01748           break;
01749         case DLG_PR_SPH_OFF:
01750           dp->smooth=0;
01751           break;
01752         case DLG_PR_SPH_COLOUR:
01753           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
01754           InvalidateRect(GetDlgItem(hwnd,DLG_PR_SPH_COLOUR),NULL,FALSE);
01755           break;
01756         case IDOK:
01757           GetDlgItemText(hwnd,DLG_PR_SPH_LR,tempstr,10);
01758           dp->lr=atof(tempstr);
01759           GetDlgItemText(hwnd,DLG_PR_SPH_FB,tempstr,10);
01760           dp->fb=atof(tempstr);
01761           GetDlgItemText(hwnd,DLG_PR_SPH_UD,tempstr,10);
01762           dp->ud=atof(tempstr);
01763           GetDlgItemText(hwnd,DLG_PR_SPH_RADIUS,tempstr,10);
01764           dp->radius=atof(tempstr);
01765           break;
01766         default:
01767           break;
01768       }
01769       break;
01770     default: break;
01771  }
01772  return(FALSE);
01773 }
01774 
01775 static void UpdateSphere1PrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
01776  BOOL active;
01777  char tempstr[16];
01778  sprintf(tempstr,"%.2lf",dp->lr);
01779  SendDlgItemMessage(hwnd,DLG_PR_SPH1_LR,WM_SETTEXT,0,(LPARAM)tempstr);
01780  SendDlgItemMessage(hwnd,DLG_PR_SPH1_LR,EM_LIMITTEXT,(WPARAM)12,0);
01781  sprintf(tempstr,"%.2lf",dp->fb);
01782  SendDlgItemMessage(hwnd,DLG_PR_SPH1_FB,WM_SETTEXT,0,(LPARAM)tempstr);
01783  SendDlgItemMessage(hwnd,DLG_PR_SPH1_FB,EM_LIMITTEXT,(WPARAM)12,0);
01784  sprintf(tempstr,"%.2lf",dp->ud);
01785  SendDlgItemMessage(hwnd,DLG_PR_SPH1_UD,WM_SETTEXT,0,(LPARAM)tempstr);
01786  SendDlgItemMessage(hwnd,DLG_PR_SPH1_UD,EM_LIMITTEXT,(WPARAM)12,0);
01787  sprintf(tempstr,"%.2lf",dp->radius);
01788  SendDlgItemMessage(hwnd,DLG_PR_SPH1_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
01789  SendDlgItemMessage(hwnd,DLG_PR_SPH1_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
01790  if(dp->smooth == 1)active=TRUE; else active=FALSE;
01791  SendDlgItemMessage(hwnd,DLG_PR_SPH1_ON,BM_SETCHECK,active,0);
01792  SendDlgItemMessage(hwnd,DLG_PR_SPH1_OFF,BM_SETCHECK,!active,0);
01793  SetDlgItemInt(hwnd,DLG_PR_SPH1_VERT,dp->nvert,FALSE);
01794  SendDlgItemMessage(hwnd,DLG_PR_SPH1_VERT,EM_LIMITTEXT,(WPARAM)6,0);
01795  SendDlgItemMessage(hwnd,DLG_PR_SPH1_VERTS,SPNM_SETRANGE,0,
01796                           MAKELPARAM(3,1000));
01797  SendDlgItemMessage(hwnd,DLG_PR_SPH1_VERTS,SPNM_SETCRNTVALUE,
01798                           (WPARAM)dp->nvert,0);
01799  SendDlgItemMessage(hwnd,DLG_PR_SPH1_VERTS,SPNM_SETEDITCTRL,0,
01800                           (LPARAM)GetDlgItem(hwnd,DLG_PR_SPH1_VERT));
01801  SetDlgItemInt(hwnd,DLG_PR_SPH1_HORZ,dp->nhorz,FALSE);
01802  SendDlgItemMessage(hwnd,DLG_PR_SPH1_HORZ,EM_LIMITTEXT,(WPARAM)6,0);
01803  SendDlgItemMessage(hwnd,DLG_PR_SPH1_HORZS,SPNM_SETRANGE,0,
01804                           MAKELPARAM(4,1000));
01805  SendDlgItemMessage(hwnd,DLG_PR_SPH1_HORZS,SPNM_SETCRNTVALUE,
01806                           (WPARAM)dp->nhorz,0);
01807  SendDlgItemMessage(hwnd,DLG_PR_SPH1_HORZS,SPNM_SETEDITCTRL,0,
01808                           (LPARAM)GetDlgItem(hwnd,DLG_PR_SPH1_HORZ));
01809  return;
01810 }
01811 
01812 BOOL CALLBACK Sphere1PrimitiveDlgProc(HWND hwnd, UINT msg,
01813                                     WPARAM wparam, LPARAM lparam){
01814  BOOL err,active;
01815  char tempstr[16];
01816  int i;
01817  PRIMITIVE *dp=&PrimStruct;
01818  switch( msg ) {
01819    case WM_PAINT:
01820      PaintDialogBackground(hwnd,ghinst_main);
01821      break;
01822    case WM_INITDIALOG:
01823      UpdateSphere1PrimitiveDlgProc(hwnd,dp);
01824      return (TRUE);
01825    case WM_DRAWITEM:{
01826        LPDRAWITEMSTRUCT lpdis;
01827        HBRUSH   hbr,hbrold;
01828        BYTE r,g,b;
01829        lpdis=(LPDRAWITEMSTRUCT)lparam;
01830        if(lpdis->CtlID == DLG_PR_SPH1_COLOUR){
01831          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
01832          if(lpdis->itemState & ODS_SELECTED)
01833             InvertRect(lpdis->hDC,&(lpdis->rcItem));
01834          else{
01835            hbr=CreateSolidBrush(RGB(r,g,b));
01836            hbrold=SelectObject(lpdis->hDC,hbr);
01837            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
01838                          lpdis->rcItem.right,lpdis->rcItem.bottom);
01839            SelectObject(lpdis->hDC,hbrold);
01840            DeleteObject(hbr);
01841          }
01842        }
01843      }
01844      return TRUE;
01845    case WM_UPDATEPDIALOG:
01846      UpdateSphere1PrimitiveDlgProc(hwnd,dp);
01847      break;
01848    case WM_COMMAND:
01849       switch(LOWORD(wparam)){
01850         case DLG_PR_SPH1_ON:
01851           dp->smooth=1;
01852           break;
01853         case DLG_PR_SPH1_OFF:
01854           dp->smooth=0;
01855           break;
01856         case DLG_PR_SPH1_COLOUR:
01857           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
01858           InvalidateRect(GetDlgItem(hwnd,DLG_PR_SPH1_COLOUR),NULL,FALSE);
01859           break;
01860         case IDOK:
01861           GetDlgItemText(hwnd,DLG_PR_SPH1_LR,tempstr,10);
01862           dp->lr=atof(tempstr);
01863           GetDlgItemText(hwnd,DLG_PR_SPH1_FB,tempstr,10);
01864           dp->fb=atof(tempstr);
01865           GetDlgItemText(hwnd,DLG_PR_SPH1_UD,tempstr,10);
01866           dp->ud=atof(tempstr);
01867           GetDlgItemText(hwnd,DLG_PR_SPH1_RADIUS,tempstr,10);
01868           dp->radius=atof(tempstr);
01869           i=GetDlgItemInt(hwnd,DLG_PR_SPH1_VERT,&err,FALSE);
01870           if(i > 9999)i=9999;
01871           if(i < 3)i=3;
01872           dp->nvert=i;
01873           i=GetDlgItemInt(hwnd,DLG_PR_SPH1_HORZ,&err,FALSE);
01874           if(i > 9999)i=9999;
01875           if(i < 4)i=4;
01876           dp->nhorz=i;
01877           break;
01878         default:
01879           break;
01880       }
01881       break;
01882     default: break;
01883  }
01884  return(FALSE);
01885 }
01886 
01887 static void UpdatePolygonPrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
01888  char tempstr[16];
01889  sprintf(tempstr,"%.2lf",dp->lr);
01890  SendDlgItemMessage(hwnd,DLG_PR_POLY_LR,WM_SETTEXT,0,(LPARAM)tempstr);
01891  SendDlgItemMessage(hwnd,DLG_PR_POLY_LR,EM_LIMITTEXT,(WPARAM)12,0);
01892  sprintf(tempstr,"%.2lf",dp->fb);
01893  SendDlgItemMessage(hwnd,DLG_PR_POLY_FB,WM_SETTEXT,0,(LPARAM)tempstr);
01894  SendDlgItemMessage(hwnd,DLG_PR_POLY_FB,EM_LIMITTEXT,(WPARAM)12,0);
01895  sprintf(tempstr,"%.2lf",dp->ud);
01896  SendDlgItemMessage(hwnd,DLG_PR_POLY_UD,WM_SETTEXT,0,(LPARAM)tempstr);
01897  SendDlgItemMessage(hwnd,DLG_PR_POLY_UD,EM_LIMITTEXT,(WPARAM)12,0);
01898  sprintf(tempstr,"%.2lf",dp->radius);
01899  SendDlgItemMessage(hwnd,DLG_PR_POLY_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
01900  SendDlgItemMessage(hwnd,DLG_PR_POLY_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
01901  SetDlgItemInt(hwnd,DLG_PR_POLY_SIDES,dp->nsides,FALSE);
01902  SendDlgItemMessage(hwnd,DLG_PR_POLY_SIDES,EM_LIMITTEXT,(WPARAM)6,0);
01903  SendDlgItemMessage(hwnd,DLG_PR_POLY_SIDESS,SPNM_SETRANGE,0,
01904                           MAKELPARAM(4,1000));
01905  SendDlgItemMessage(hwnd,DLG_PR_POLY_SIDESS,SPNM_SETCRNTVALUE,
01906                           (WPARAM)dp->nsides,0);
01907  SendDlgItemMessage(hwnd,DLG_PR_POLY_SIDESS,SPNM_SETEDITCTRL,0,
01908                           (LPARAM)GetDlgItem(hwnd,DLG_PR_POLY_SIDES));
01909  return;
01910 }
01911 
01912 BOOL CALLBACK PolygonPrimitiveDlgProc(HWND hwnd, UINT msg,
01913                                     WPARAM wparam, LPARAM lparam){
01914  BOOL err,active;
01915  char tempstr[16];
01916  int i;
01917  PRIMITIVE *dp=&PrimStruct;
01918  switch( msg ) {
01919    case WM_PAINT:
01920      PaintDialogBackground(hwnd,ghinst_main);
01921      break;
01922    case WM_INITDIALOG:
01923      UpdatePolygonPrimitiveDlgProc(hwnd,dp);
01924      return (TRUE);
01925    case WM_UPDATEPDIALOG:
01926      UpdatePolygonPrimitiveDlgProc(hwnd,dp);
01927      break;
01928    case WM_COMMAND:
01929       switch(LOWORD(wparam)){
01930         case IDOK:
01931           i=GetDlgItemInt(hwnd,DLG_PR_POLY_SIDES,&err,FALSE);
01932           if(i > 9999)i=9999;
01933           if(i < 4)i=4;
01934           dp->nsides=i;
01935           GetDlgItemText(hwnd,DLG_PR_POLY_LR,tempstr,10);
01936           dp->lr=atof(tempstr);
01937           GetDlgItemText(hwnd,DLG_PR_POLY_FB,tempstr,10);
01938           dp->fb=atof(tempstr);
01939           GetDlgItemText(hwnd,DLG_PR_POLY_UD,tempstr,10);
01940           dp->ud=atof(tempstr);
01941           GetDlgItemText(hwnd,DLG_PR_POLY_RADIUS,tempstr,10);
01942           dp->radius=atof(tempstr);
01943           break;
01944         default:
01945           break;
01946       }
01947       break;
01948     default: break;
01949  }
01950  return(FALSE);
01951 }
01952 
01953 static void UpdateDiskPrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
01954  char tempstr[16];
01955  sprintf(tempstr,"%.2lf",dp->lr);
01956  SendDlgItemMessage(hwnd,DLG_PR_DISK_LR,WM_SETTEXT,0,(LPARAM)tempstr);
01957  SendDlgItemMessage(hwnd,DLG_PR_DISK_LR,EM_LIMITTEXT,(WPARAM)12,0);
01958  sprintf(tempstr,"%.2lf",dp->fb);
01959  SendDlgItemMessage(hwnd,DLG_PR_DISK_FB,WM_SETTEXT,0,(LPARAM)tempstr);
01960  SendDlgItemMessage(hwnd,DLG_PR_DISK_FB,EM_LIMITTEXT,(WPARAM)12,0);
01961  sprintf(tempstr,"%.2lf",dp->ud);
01962  SendDlgItemMessage(hwnd,DLG_PR_DISK_UD,WM_SETTEXT,0,(LPARAM)tempstr);
01963  SendDlgItemMessage(hwnd,DLG_PR_DISK_UD,EM_LIMITTEXT,(WPARAM)12,0);
01964  sprintf(tempstr,"%.2lf",dp->radius);
01965  SendDlgItemMessage(hwnd,DLG_PR_DISK_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
01966  SendDlgItemMessage(hwnd,DLG_PR_DISK_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
01967  SetDlgItemInt(hwnd,DLG_PR_DISK_SIDES,dp->nsides,FALSE);
01968  SendDlgItemMessage(hwnd,DLG_PR_DISK_SIDES,EM_LIMITTEXT,(WPARAM)6,0);
01969  SendDlgItemMessage(hwnd,DLG_PR_DISK_SIDESS,SPNM_SETRANGE,0,
01970                           MAKELPARAM(4,1000));
01971  SendDlgItemMessage(hwnd,DLG_PR_DISK_SIDESS,SPNM_SETCRNTVALUE,
01972                           (WPARAM)dp->nsides,0);
01973  SendDlgItemMessage(hwnd,DLG_PR_DISK_SIDESS,SPNM_SETEDITCTRL,0,
01974                           (LPARAM)GetDlgItem(hwnd,DLG_PR_DISK_SIDES));
01975  return;
01976 }
01977 
01978 BOOL CALLBACK DiskPrimitiveDlgProc(HWND hwnd, UINT msg,
01979                                     WPARAM wparam, LPARAM lparam){
01980  BOOL err,active;
01981  char tempstr[16];
01982  int i;
01983  PRIMITIVE *dp=&PrimStruct;
01984  switch( msg ) {
01985    case WM_PAINT:
01986      PaintDialogBackground(hwnd,ghinst_main);
01987      break;
01988    case WM_INITDIALOG:
01989      UpdateDiskPrimitiveDlgProc(hwnd,dp);
01990      return (TRUE);
01991    case WM_DRAWITEM:{
01992        LPDRAWITEMSTRUCT lpdis;
01993        HBRUSH   hbr,hbrold;
01994        BYTE r,g,b;
01995        lpdis=(LPDRAWITEMSTRUCT)lparam;
01996        if(lpdis->CtlID == DLG_PR_DISK_COLOUR){
01997          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
01998          if(lpdis->itemState & ODS_SELECTED)
01999             InvertRect(lpdis->hDC,&(lpdis->rcItem));
02000          else{
02001            hbr=CreateSolidBrush(RGB(r,g,b));
02002            hbrold=SelectObject(lpdis->hDC,hbr);
02003            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
02004                          lpdis->rcItem.right,lpdis->rcItem.bottom);
02005            SelectObject(lpdis->hDC,hbrold);
02006            DeleteObject(hbr);
02007          }
02008        }
02009      }
02010      return TRUE;
02011    case WM_UPDATEPDIALOG:
02012      UpdateDiskPrimitiveDlgProc(hwnd,dp);
02013      break;
02014    case WM_COMMAND:
02015       switch(LOWORD(wparam)){
02016         case DLG_PR_DISK_COLOUR:
02017           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
02018           InvalidateRect(GetDlgItem(hwnd,DLG_PR_DISK_COLOUR),NULL,FALSE);
02019           break;
02020         case IDOK:
02021           GetDlgItemText(hwnd,DLG_PR_DISK_LR,tempstr,10);
02022           dp->lr=atof(tempstr);
02023           GetDlgItemText(hwnd,DLG_PR_DISK_FB,tempstr,10);
02024           dp->fb=atof(tempstr);
02025           GetDlgItemText(hwnd,DLG_PR_DISK_UD,tempstr,10);
02026           dp->ud=atof(tempstr);
02027           GetDlgItemText(hwnd,DLG_PR_DISK_RADIUS,tempstr,10);
02028           dp->radius=atof(tempstr);
02029           i=GetDlgItemInt(hwnd,DLG_PR_DISK_SIDES,&err,FALSE);
02030           if(i > 9999)i=9999; if(i < 4)i=4;
02031           dp->nsides=i;
02032           break;
02033         default:
02034           break;
02035       }
02036       break;
02037     default: break;
02038  }
02039  return(FALSE);
02040 }
02041 
02042 static void UpdateTubePrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
02043  char tempstr[16];
02044  sprintf(tempstr,"%.2lf",dp->lr);
02045  SendDlgItemMessage(hwnd,DLG_PR_TUBE_LR,WM_SETTEXT,0,(LPARAM)tempstr);
02046  SendDlgItemMessage(hwnd,DLG_PR_TUBE_LR,EM_LIMITTEXT,(WPARAM)12,0);
02047  sprintf(tempstr,"%.2lf",dp->fb);
02048  SendDlgItemMessage(hwnd,DLG_PR_TUBE_FB,WM_SETTEXT,0,(LPARAM)tempstr);
02049  SendDlgItemMessage(hwnd,DLG_PR_TUBE_FB,EM_LIMITTEXT,(WPARAM)12,0);
02050  sprintf(tempstr,"%.2lf",dp->ud);
02051  SendDlgItemMessage(hwnd,DLG_PR_TUBE_UD,WM_SETTEXT,0,(LPARAM)tempstr);
02052  SendDlgItemMessage(hwnd,DLG_PR_TUBE_UD,EM_LIMITTEXT,(WPARAM)12,0);
02053  sprintf(tempstr,"%.2lf",dp->radius);
02054  SendDlgItemMessage(hwnd,DLG_PR_TUBE_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
02055  SendDlgItemMessage(hwnd,DLG_PR_TUBE_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
02056  sprintf(tempstr,"%.2lf",dp->length);
02057  SendDlgItemMessage(hwnd,DLG_PR_TUBE_LENGTH,WM_SETTEXT,0,(LPARAM)tempstr);
02058  SendDlgItemMessage(hwnd,DLG_PR_TUBE_LENGTH,EM_LIMITTEXT,(WPARAM)12,0);
02059  SetDlgItemInt(hwnd,DLG_PR_TUBE_SIDES,dp->nsides,FALSE);
02060  SendDlgItemMessage(hwnd,DLG_PR_TUBE_SIDES,EM_LIMITTEXT,(WPARAM)6,0);
02061  SendDlgItemMessage(hwnd,DLG_PR_TUBE_SIDESS,SPNM_SETRANGE,0,
02062                           MAKELPARAM(4,1000));
02063  SendDlgItemMessage(hwnd,DLG_PR_TUBE_SIDESS,SPNM_SETCRNTVALUE,
02064                           (WPARAM)dp->nsides,0);
02065  SendDlgItemMessage(hwnd,DLG_PR_TUBE_SIDESS,SPNM_SETEDITCTRL,0,
02066                           (LPARAM)GetDlgItem(hwnd,DLG_PR_TUBE_SIDES));
02067  SetDlgItemInt(hwnd,DLG_PR_TUBE_NSTEPS,dp->nsteps,FALSE);
02068  SendDlgItemMessage(hwnd,DLG_PR_TUBE_NSTEPS,EM_LIMITTEXT,(WPARAM)6,0);
02069  SendDlgItemMessage(hwnd,DLG_PR_TUBE_NSTEPSS,SPNM_SETRANGE,0,
02070                           MAKELPARAM(1,1000));
02071  SendDlgItemMessage(hwnd,DLG_PR_TUBE_NSTEPSS,SPNM_SETCRNTVALUE,
02072                           (WPARAM)dp->nsteps,0);
02073  SendDlgItemMessage(hwnd,DLG_PR_TUBE_NSTEPSS,SPNM_SETEDITCTRL,0,
02074                           (LPARAM)GetDlgItem(hwnd,DLG_PR_TUBE_NSTEPS));
02075  return;
02076 }
02077 
02078 BOOL CALLBACK TubePrimitiveDlgProc(HWND hwnd, UINT msg,
02079                                     WPARAM wparam, LPARAM lparam){
02080  BOOL err,active;
02081  char tempstr[16];
02082  int i;
02083  PRIMITIVE *dp=&PrimStruct;
02084  switch( msg ) {
02085    case WM_PAINT:
02086      PaintDialogBackground(hwnd,ghinst_main);
02087      break;
02088    case WM_INITDIALOG:
02089      UpdateTubePrimitiveDlgProc(hwnd,dp);
02090      return (TRUE);
02091    case WM_UPDATEPDIALOG:
02092      UpdateTubePrimitiveDlgProc(hwnd,dp);
02093      break;
02094    case WM_DRAWITEM:{
02095        LPDRAWITEMSTRUCT lpdis;
02096        HBRUSH   hbr,hbrold;
02097        BYTE r,g,b;
02098        lpdis=(LPDRAWITEMSTRUCT)lparam;
02099        if(lpdis->CtlID == DLG_PR_TUBE_COLOUR){
02100          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
02101          if(lpdis->itemState & ODS_SELECTED)
02102             InvertRect(lpdis->hDC,&(lpdis->rcItem));
02103          else{
02104            hbr=CreateSolidBrush(RGB(r,g,b));
02105            hbrold=SelectObject(lpdis->hDC,hbr);
02106            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
02107                          lpdis->rcItem.right,lpdis->rcItem.bottom);
02108            SelectObject(lpdis->hDC,hbrold);
02109            DeleteObject(hbr);
02110          }
02111        }
02112      }
02113      return TRUE;
02114    case WM_COMMAND:
02115       switch(LOWORD(wparam)){
02116         case DLG_PR_TUBE_COLOUR:
02117           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
02118           InvalidateRect(GetDlgItem(hwnd,DLG_PR_TUBE_COLOUR),NULL,FALSE);
02119           break;
02120         case IDOK:
02121           GetDlgItemText(hwnd,DLG_PR_TUBE_LR,tempstr,10);
02122           dp->lr=atof(tempstr);
02123           GetDlgItemText(hwnd,DLG_PR_TUBE_FB,tempstr,10);
02124           dp->fb=atof(tempstr);
02125           GetDlgItemText(hwnd,DLG_PR_TUBE_UD,tempstr,10);
02126           dp->ud=atof(tempstr);
02127           GetDlgItemText(hwnd,DLG_PR_TUBE_RADIUS,tempstr,10);
02128           dp->radius=atof(tempstr);
02129           GetDlgItemText(hwnd,DLG_PR_TUBE_LENGTH,tempstr,10);
02130           dp->length=atof(tempstr);
02131           i=GetDlgItemInt(hwnd,DLG_PR_TUBE_SIDES,&err,FALSE);
02132           if(i > 9999)i=9999; if(i < 4)i=4;
02133           dp->nsides=i;
02134           i=GetDlgItemInt(hwnd,DLG_PR_TUBE_NSTEPS,&err,FALSE);
02135           if(i > 9999)i=9999; if(i < 1)i=1;
02136           dp->nsteps=i;
02137           break;
02138         default:
02139           break;
02140       }
02141       break;
02142     default: break;
02143  }
02144  return(FALSE);
02145 }
02146 
02147 static void UpdateCylinderPrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
02148  char tempstr[16];
02149  sprintf(tempstr,"%.2lf",dp->lr);
02150  SendDlgItemMessage(hwnd,DLG_PR_CYL_LR,WM_SETTEXT,0,(LPARAM)tempstr);
02151  SendDlgItemMessage(hwnd,DLG_PR_CYL_LR,EM_LIMITTEXT,(WPARAM)12,0);
02152  sprintf(tempstr,"%.2lf",dp->fb);
02153  SendDlgItemMessage(hwnd,DLG_PR_CYL_FB,WM_SETTEXT,0,(LPARAM)tempstr);
02154  SendDlgItemMessage(hwnd,DLG_PR_CYL_FB,EM_LIMITTEXT,(WPARAM)12,0);
02155  sprintf(tempstr,"%.2lf",dp->ud);
02156  SendDlgItemMessage(hwnd,DLG_PR_CYL_UD,WM_SETTEXT,0,(LPARAM)tempstr);
02157  SendDlgItemMessage(hwnd,DLG_PR_CYL_UD,EM_LIMITTEXT,(WPARAM)12,0);
02158  sprintf(tempstr,"%.2lf",dp->radius);
02159  SendDlgItemMessage(hwnd,DLG_PR_CYL_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
02160  SendDlgItemMessage(hwnd,DLG_PR_CYL_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
02161  sprintf(tempstr,"%.2lf",dp->length);
02162  SendDlgItemMessage(hwnd,DLG_PR_CYL_LENGTH,WM_SETTEXT,0,(LPARAM)tempstr);
02163  SendDlgItemMessage(hwnd,DLG_PR_CYL_LENGTH,EM_LIMITTEXT,(WPARAM)12,0);
02164  SetDlgItemInt(hwnd,DLG_PR_CYL_SIDES,dp->nsides,FALSE);
02165  SendDlgItemMessage(hwnd,DLG_PR_CYL_SIDES,EM_LIMITTEXT,(WPARAM)6,0);
02166  SendDlgItemMessage(hwnd,DLG_PR_CYL_SIDESS,SPNM_SETRANGE,0,
02167                           MAKELPARAM(4,1000));
02168  SendDlgItemMessage(hwnd,DLG_PR_CYL_SIDESS,SPNM_SETCRNTVALUE,
02169                           (WPARAM)dp->nsides,0);
02170  SendDlgItemMessage(hwnd,DLG_PR_CYL_SIDESS,SPNM_SETEDITCTRL,0,
02171                           (LPARAM)GetDlgItem(hwnd,DLG_PR_CYL_SIDES));
02172  SetDlgItemInt(hwnd,DLG_PR_CYL_NSTEPS,dp->nsteps,FALSE);
02173  SendDlgItemMessage(hwnd,DLG_PR_CYL_NSTEPS,EM_LIMITTEXT,(WPARAM)6,0);
02174  SendDlgItemMessage(hwnd,DLG_PR_CYL_NSTEPSS,SPNM_SETRANGE,0,
02175                           MAKELPARAM(1,1000));
02176  SendDlgItemMessage(hwnd,DLG_PR_CYL_NSTEPSS,SPNM_SETCRNTVALUE,
02177                           (WPARAM)dp->nsteps,0);
02178  SendDlgItemMessage(hwnd,DLG_PR_CYL_NSTEPSS,SPNM_SETEDITCTRL,0,
02179                           (LPARAM)GetDlgItem(hwnd,DLG_PR_CYL_NSTEPS));
02180  return;
02181 }
02182 
02183 BOOL CALLBACK CylinderPrimitiveDlgProc(HWND hwnd, UINT msg,
02184                                     WPARAM wparam, LPARAM lparam){
02185  BOOL err,active;
02186  char tempstr[16];
02187  int i;
02188  PRIMITIVE *dp=&PrimStruct;
02189  switch( msg ) {
02190    case WM_PAINT:
02191      PaintDialogBackground(hwnd,ghinst_main);
02192      break;
02193    case WM_INITDIALOG:
02194      UpdateCylinderPrimitiveDlgProc(hwnd,dp);
02195      return (TRUE);
02196    case WM_DRAWITEM:{
02197        LPDRAWITEMSTRUCT lpdis;
02198        HBRUSH   hbr,hbrold;
02199        BYTE r,g,b;
02200        lpdis=(LPDRAWITEMSTRUCT)lparam;
02201        if(lpdis->CtlID == DLG_PR_CYL_COLOUR){
02202          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
02203          if(lpdis->itemState & ODS_SELECTED)
02204             InvertRect(lpdis->hDC,&(lpdis->rcItem));
02205          else{
02206            hbr=CreateSolidBrush(RGB(r,g,b));
02207            hbrold=SelectObject(lpdis->hDC,hbr);
02208            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
02209                          lpdis->rcItem.right,lpdis->rcItem.bottom);
02210            SelectObject(lpdis->hDC,hbrold);
02211            DeleteObject(hbr);
02212          }
02213        }
02214      }
02215      return TRUE;
02216    case WM_UPDATEPDIALOG:
02217      UpdateCylinderPrimitiveDlgProc(hwnd,dp);
02218      break;
02219    case WM_COMMAND:
02220       switch(LOWORD(wparam)){
02221         case DLG_PR_CYL_COLOUR:
02222           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
02223           InvalidateRect(GetDlgItem(hwnd,DLG_PR_CYL_COLOUR),NULL,FALSE);
02224           break;
02225         case IDOK:
02226           GetDlgItemText(hwnd,DLG_PR_CYL_LR,tempstr,10);
02227           dp->lr=atof(tempstr);
02228           GetDlgItemText(hwnd,DLG_PR_CYL_FB,tempstr,10);
02229           dp->fb=atof(tempstr);
02230           GetDlgItemText(hwnd,DLG_PR_CYL_UD,tempstr,10);
02231           dp->ud=atof(tempstr);
02232           GetDlgItemText(hwnd,DLG_PR_CYL_RADIUS,tempstr,10);
02233           dp->radius=atof(tempstr);
02234           GetDlgItemText(hwnd,DLG_PR_CYL_LENGTH,tempstr,10);
02235           dp->length=atof(tempstr);
02236           i=GetDlgItemInt(hwnd,DLG_PR_CYL_SIDES,&err,FALSE);
02237           if(i > 9999)i=9999; if(i < 4)i=4;
02238           dp->nsides=i;
02239           i=GetDlgItemInt(hwnd,DLG_PR_CYL_NSTEPS,&err,FALSE);
02240           if(i > 9999)i=9999; if(i < 1)i=1;
02241           dp->nsteps=i;
02242           break;
02243         default:
02244           break;
02245       }
02246       break;
02247     default: break;
02248  }
02249  return(FALSE);
02250 }
02251 
02252 static void UpdateConePrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
02253  char tempstr[16];
02254  sprintf(tempstr,"%.2lf",dp->lr);
02255  SendDlgItemMessage(hwnd,DLG_PR_CONE_LR,WM_SETTEXT,0,(LPARAM)tempstr);
02256  SendDlgItemMessage(hwnd,DLG_PR_CONE_LR,EM_LIMITTEXT,(WPARAM)12,0);
02257  sprintf(tempstr,"%.2lf",dp->fb);
02258  SendDlgItemMessage(hwnd,DLG_PR_CONE_FB,WM_SETTEXT,0,(LPARAM)tempstr);
02259  SendDlgItemMessage(hwnd,DLG_PR_CONE_FB,EM_LIMITTEXT,(WPARAM)12,0);
02260  sprintf(tempstr,"%.2lf",dp->ud);
02261  SendDlgItemMessage(hwnd,DLG_PR_CONE_UD,WM_SETTEXT,0,(LPARAM)tempstr);
02262  SendDlgItemMessage(hwnd,DLG_PR_CONE_UD,EM_LIMITTEXT,(WPARAM)12,0);
02263  sprintf(tempstr,"%.2lf",dp->radius);
02264  SendDlgItemMessage(hwnd,DLG_PR_CONE_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
02265  SendDlgItemMessage(hwnd,DLG_PR_CONE_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
02266  sprintf(tempstr,"%.2lf",dp->length);
02267  SendDlgItemMessage(hwnd,DLG_PR_CONE_LENGTH,WM_SETTEXT,0,(LPARAM)tempstr);
02268  SendDlgItemMessage(hwnd,DLG_PR_CONE_LENGTH,EM_LIMITTEXT,(WPARAM)12,0);
02269  SetDlgItemInt(hwnd,DLG_PR_CONE_SIDES,dp->nsides,FALSE);
02270  SendDlgItemMessage(hwnd,DLG_PR_CONE_SIDES,EM_LIMITTEXT,(WPARAM)6,0);
02271  SendDlgItemMessage(hwnd,DLG_PR_CONE_SIDESS,SPNM_SETRANGE,0,
02272                     MAKELPARAM(4,1000));
02273  SendDlgItemMessage(hwnd,DLG_PR_CONE_SIDESS,SPNM_SETCRNTVALUE,
02274                     (WPARAM)dp->nsides,0);
02275  SendDlgItemMessage(hwnd,DLG_PR_CONE_SIDESS,SPNM_SETEDITCTRL,0,
02276                     (LPARAM)GetDlgItem(hwnd,DLG_PR_CONE_SIDES));
02277  return;
02278 }
02279 
02280 BOOL CALLBACK ConePrimitiveDlgProc(HWND hwnd, UINT msg,
02281                                     WPARAM wparam, LPARAM lparam){
02282  BOOL err,active;
02283  char tempstr[16];
02284  int i;
02285  PRIMITIVE *dp=&PrimStruct;
02286  switch( msg ) {
02287    case WM_PAINT:
02288      PaintDialogBackground(hwnd,ghinst_main);
02289      break;
02290    case WM_INITDIALOG:
02291      UpdateConePrimitiveDlgProc(hwnd,dp);
02292      return (TRUE);
02293    case WM_DRAWITEM:{
02294        LPDRAWITEMSTRUCT lpdis;
02295        HBRUSH   hbr,hbrold;
02296        BYTE r,g,b;
02297        lpdis=(LPDRAWITEMSTRUCT)lparam;
02298        if(lpdis->CtlID == DLG_PR_CONE_COLOUR){
02299          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
02300          if(lpdis->itemState & ODS_SELECTED)
02301             InvertRect(lpdis->hDC,&(lpdis->rcItem));
02302          else{
02303            hbr=CreateSolidBrush(RGB(r,g,b));
02304            hbrold=SelectObject(lpdis->hDC,hbr);
02305            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
02306                          lpdis->rcItem.right,lpdis->rcItem.bottom);
02307            SelectObject(lpdis->hDC,hbrold);
02308            DeleteObject(hbr);
02309          }
02310        }
02311      }
02312      return TRUE;
02313    case WM_UPDATEPDIALOG:
02314      UpdateConePrimitiveDlgProc(hwnd,dp);
02315      break;
02316    case WM_COMMAND:
02317       switch(LOWORD(wparam)){
02318         case DLG_PR_CONE_COLOUR:
02319           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
02320           InvalidateRect(GetDlgItem(hwnd,DLG_PR_CONE_COLOUR),NULL,FALSE);
02321           break;
02322         case IDOK:
02323           GetDlgItemText(hwnd,DLG_PR_CONE_LR,tempstr,10);
02324           dp->lr=atof(tempstr);
02325           GetDlgItemText(hwnd,DLG_PR_CONE_FB,tempstr,10);
02326           dp->fb=atof(tempstr);
02327           GetDlgItemText(hwnd,DLG_PR_CONE_UD,tempstr,10);
02328           dp->ud=atof(tempstr);
02329           GetDlgItemText(hwnd,DLG_PR_CONE_RADIUS,tempstr,10);
02330           dp->radius=atof(tempstr);
02331           GetDlgItemText(hwnd,DLG_PR_CONE_LENGTH,tempstr,10);
02332           dp->length=atof(tempstr);
02333           i=GetDlgItemInt(hwnd,DLG_PR_CONE_SIDES,&err,FALSE);
02334           if(i > 9999)i=9999; if(i < 4)i=4;
02335           dp->nsides=i;
02336           break;
02337         default:
02338           break;
02339       }
02340       break;
02341     default: break;
02342  }
02343  return(FALSE);
02344 }
02345 
02346 static void  UpdatePlanePrimitiveDlgProc(HWND hwnd,PRIMITIVE *dp){
02347  char tempstr[16];
02348  sprintf(tempstr,"%.2lf",dp->lr);
02349  SendDlgItemMessage(hwnd,DLG_PR_PLANE_LR,WM_SETTEXT,0,(LPARAM)tempstr);
02350  SendDlgItemMessage(hwnd,DLG_PR_PLANE_LR,EM_LIMITTEXT,(WPARAM)12,0);
02351  sprintf(tempstr,"%.2lf",dp->fb);
02352  SendDlgItemMessage(hwnd,DLG_PR_PLANE_FB,WM_SETTEXT,0,(LPARAM)tempstr);
02353  SendDlgItemMessage(hwnd,DLG_PR_PLANE_FB,EM_LIMITTEXT,(WPARAM)12,0);
02354  sprintf(tempstr,"%.2lf",dp->ud);
02355  SendDlgItemMessage(hwnd,DLG_PR_PLANE_UD,WM_SETTEXT,0,(LPARAM)tempstr);
02356  SendDlgItemMessage(hwnd,DLG_PR_PLANE_UD,EM_LIMITTEXT,(WPARAM)12,0);
02357  sprintf(tempstr,"%.2lf",dp->width);
02358  SendDlgItemMessage(hwnd,DLG_PR_PLANE_WIDTH,WM_SETTEXT,0,(LPARAM)tempstr);
02359  SendDlgItemMessage(hwnd,DLG_PR_PLANE_WIDTH,EM_LIMITTEXT,(WPARAM)12,0);
02360  sprintf(tempstr,"%.2lf",dp->length);
02361  SendDlgItemMessage(hwnd,DLG_PR_PLANE_LENGTH,WM_SETTEXT,0,(LPARAM)tempstr);
02362  SendDlgItemMessage(hwnd,DLG_PR_PLANE_LENGTH,EM_LIMITTEXT,(WPARAM)12,0);
02363  return;
02364 }
02365 
02366 BOOL CALLBACK PlanePrimitiveDlgProc(HWND hwnd, UINT msg,
02367                                     WPARAM wparam, LPARAM lparam){
02368  char tempstr[16];
02369  PRIMITIVE *dp=&PrimStruct;
02370  switch( msg ) {
02371    case WM_PAINT:
02372      PaintDialogBackground(hwnd,ghinst_main);
02373      break;
02374    case WM_INITDIALOG:
02375      UpdatePlanePrimitiveDlgProc(hwnd,dp);
02376      return (TRUE);
02377    case WM_DRAWITEM:{
02378        LPDRAWITEMSTRUCT lpdis;
02379        HBRUSH   hbr,hbrold;
02380        BYTE r,g,b;
02381        lpdis=(LPDRAWITEMSTRUCT)lparam;
02382        if(lpdis->CtlID == DLG_PR_PLANE_COLOUR){
02383          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
02384          if(lpdis->itemState & ODS_SELECTED)
02385             InvertRect(lpdis->hDC,&(lpdis->rcItem));
02386          else{
02387            hbr=CreateSolidBrush(RGB(r,g,b));
02388            hbrold=SelectObject(lpdis->hDC,hbr);
02389            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
02390                          lpdis->rcItem.right,lpdis->rcItem.bottom);
02391            SelectObject(lpdis->hDC,hbrold);
02392            DeleteObject(hbr);
02393          }
02394        }
02395      }
02396      return TRUE;
02397    case WM_UPDATEPDIALOG:
02398      UpdatePlanePrimitiveDlgProc(hwnd,dp);
02399      break;
02400    case WM_COMMAND:
02401       switch(LOWORD(wparam)){
02402         case DLG_PR_PLANE_COLOUR:
02403           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
02404           InvalidateRect(GetDlgItem(hwnd,DLG_PR_PLANE_COLOUR),NULL,FALSE);
02405           break;
02406         case IDOK:
02407           GetDlgItemText(hwnd,DLG_PR_PLANE_LR,tempstr,10);
02408           dp->lr=atof(tempstr);
02409           GetDlgItemText(hwnd,DLG_PR_PLANE_FB,tempstr,10);
02410           dp->fb=atof(tempstr);
02411           GetDlgItemText(hwnd,DLG_PR_PLANE_UD,tempstr,10);
02412           dp->ud=atof(tempstr);
02413           GetDlgItemText(hwnd,DLG_PR_PLANE_WIDTH,tempstr,10);
02414           dp->width=atof(tempstr);
02415           GetDlgItemText(hwnd,DLG_PR_PLANE_LENGTH,tempstr,10);
02416           dp->length=atof(tempstr);
02417           break;
02418         default:
02419           break;
02420       }
02421       break;
02422     default: break;
02423  }
02424  return(FALSE);
02425 }
02426 
02427 static void UpdateTorusPrimitiveDlgProc(HWND hwnd, PRIMITIVE *dp){
02428  BOOL active;
02429  char tempstr[16];
02430  sprintf(tempstr,"%.2lf",dp->lr);
02431  SendDlgItemMessage(hwnd,DLG_PR_TORUS_LR,WM_SETTEXT,0,(LPARAM)tempstr);
02432  SendDlgItemMessage(hwnd,DLG_PR_TORUS_LR,EM_LIMITTEXT,(WPARAM)12,0);
02433  sprintf(tempstr,"%.2lf",dp->fb);
02434  SendDlgItemMessage(hwnd,DLG_PR_TORUS_FB,WM_SETTEXT,0,(LPARAM)tempstr);
02435  SendDlgItemMessage(hwnd,DLG_PR_TORUS_FB,EM_LIMITTEXT,(WPARAM)12,0);
02436  sprintf(tempstr,"%.2lf",dp->ud);
02437  SendDlgItemMessage(hwnd,DLG_PR_TORUS_UD,WM_SETTEXT,0,(LPARAM)tempstr);
02438  SendDlgItemMessage(hwnd,DLG_PR_TORUS_UD,EM_LIMITTEXT,(WPARAM)12,0);
02439  sprintf(tempstr,"%.2lf",dp->radius);
02440  SendDlgItemMessage(hwnd,DLG_PR_TORUS_RADIUS,WM_SETTEXT,0,(LPARAM)tempstr);
02441  SendDlgItemMessage(hwnd,DLG_PR_TORUS_RADIUS,EM_LIMITTEXT,(WPARAM)12,0);
02442  sprintf(tempstr,"%.2lf",dp->torus_ratio);
02443  SendDlgItemMessage(hwnd,DLG_PR_TORUS_RATIO,WM_SETTEXT,0,(LPARAM)tempstr);
02444  SendDlgItemMessage(hwnd,DLG_PR_TORUS_RATIO,EM_LIMITTEXT,(WPARAM)12,0);
02445  if(dp->smooth == 1)active=TRUE; else active=FALSE;
02446  SendDlgItemMessage(hwnd,DLG_PR_TORUS_ON,BM_SETCHECK,active,0);
02447  SendDlgItemMessage(hwnd,DLG_PR_TORUS_OFF,BM_SETCHECK,!active,0);
02448  SetDlgItemInt(hwnd,DLG_PR_TORUS_VERT,dp->nvert,FALSE);
02449  SendDlgItemMessage(hwnd,DLG_PR_TORUS_VERT,EM_LIMITTEXT,(WPARAM)6,0);
02450  SendDlgItemMessage(hwnd,DLG_PR_TORUS_VERTS,SPNM_SETRANGE,0,
02451                           MAKELPARAM(3,1000));
02452  SendDlgItemMessage(hwnd,DLG_PR_TORUS_VERTS,SPNM_SETCRNTVALUE,
02453                           (WPARAM)dp->nvert,0);
02454  SendDlgItemMessage(hwnd,DLG_PR_TORUS_VERTS,SPNM_SETEDITCTRL,0,
02455                           (LPARAM)GetDlgItem(hwnd,DLG_PR_TORUS_VERT));
02456  SetDlgItemInt(hwnd,DLG_PR_TORUS_HORZ,dp->nhorz,FALSE);
02457  SendDlgItemMessage(hwnd,DLG_PR_TORUS_HORZ,EM_LIMITTEXT,(WPARAM)6,0);
02458  SendDlgItemMessage(hwnd,DLG_PR_TORUS_HORZS,SPNM_SETRANGE,0,
02459                           MAKELPARAM(4,1000));
02460  SendDlgItemMessage(hwnd,DLG_PR_TORUS_HORZS,SPNM_SETCRNTVALUE,
02461                           (WPARAM)dp->nhorz,0);
02462  SendDlgItemMessage(hwnd,DLG_PR_TORUS_HORZS,SPNM_SETEDITCTRL,0,
02463                           (LPARAM)GetDlgItem(hwnd,DLG_PR_TORUS_HORZ));
02464  return;
02465 }
02466 
02467 BOOL CALLBACK TorusPrimitiveDlgProc(HWND hwnd, UINT msg,
02468                                     WPARAM wparam, LPARAM lparam){
02469  BOOL err,active;
02470  char tempstr[16];
02471  int i;
02472  PRIMITIVE *dp=&PrimStruct;
02473  switch( msg ) {
02474    case WM_PAINT:
02475      PaintDialogBackground(hwnd,ghinst_main);
02476      break;
02477    case WM_INITDIALOG:
02478      UpdateTorusPrimitiveDlgProc(hwnd,dp);
02479      return (TRUE);
02480    case WM_DRAWITEM:{
02481        LPDRAWITEMSTRUCT lpdis;
02482        HBRUSH   hbr,hbrold;
02483        BYTE r,g,b;
02484        lpdis=(LPDRAWITEMSTRUCT)lparam;
02485        if(lpdis->CtlID == DLG_PR_TORUS_COLOUR){
02486          r=dp->fc[0]; g=dp->fc[1]; b=dp->fc[2];
02487          if(lpdis->itemState & ODS_SELECTED)
02488             InvertRect(lpdis->hDC,&(lpdis->rcItem));
02489          else{
02490            hbr=CreateSolidBrush(RGB(r,g,b));
02491            hbrold=SelectObject(lpdis->hDC,hbr);
02492            Rectangle(lpdis->hDC,lpdis->rcItem.left,lpdis->rcItem.top,
02493                          lpdis->rcItem.right,lpdis->rcItem.bottom);
02494            SelectObject(lpdis->hDC,hbrold);
02495            DeleteObject(hbr);
02496          }
02497        }
02498      }
02499      return TRUE;
02500    case WM_UPDATEPDIALOG:
02501      UpdateTorusPrimitiveDlgProc(hwnd,dp);
02502      break;
02503    case WM_COMMAND:
02504       switch(LOWORD(wparam)){
02505         case DLG_PR_TORUS_ON:
02506           dp->smooth=1;
02507           break;
02508         case DLG_PR_TORUS_OFF:
02509           dp->smooth=0;
02510           break;
02511         case DLG_PR_TORUS_COLOUR:
02512           SetSfxColour(dp->fc,IDX_MISC_CHOOSE_COLOUR,hwnd);
02513           InvalidateRect(GetDlgItem(hwnd,DLG_PR_TORUS_COLOUR),NULL,FALSE);
02514           break;
02515         case IDOK:
02516           GetDlgItemText(hwnd,DLG_PR_TORUS_LR,tempstr,10);
02517           dp->lr=atof(tempstr);
02518           GetDlgItemText(hwnd,DLG_PR_TORUS_FB,tempstr,10);
02519           dp->fb=atof(tempstr);
02520           GetDlgItemText(hwnd,DLG_PR_TORUS_UD,tempstr,10);
02521           dp->ud=atof(tempstr);
02522           GetDlgItemText(hwnd,DLG_PR_TORUS_RADIUS,tempstr,10);
02523           dp->radius=atof(tempstr);
02524           GetDlgItemText(hwnd,DLG_PR_TORUS_RATIO,tempstr,10);
02525           dp->torus_ratio=atof(tempstr);
02526           i=GetDlgItemInt(hwnd,DLG_PR_TORUS_VERT,&err,FALSE);
02527           if(i > 9999)i=9999;
02528           if(i < 3)i=3;
02529           dp->nvert=i;
02530           i=GetDlgItemInt(hwnd,DLG_PR_TORUS_HORZ,&err,FALSE);
02531           if(i > 9999)i=9999;
02532           if(i < 4)i=4;
02533           dp->nhorz=i;
02534           break;
02535         default:
02536           break;
02537       }
02538       break;
02539     default: break;
02540  }
02541  return(FALSE);
02542 }
02543 
02544 BOOL CALLBACK PrimitivesDlgProc(HWND hdlg,UINT msg,
02545                                 WPARAM wparam,LPARAM lparam){
02546  static int xpos= -1,ypos= -1;
02547  int i,xp,yp;
02548  RECT rc,rd;
02549  char str[32];
02550  switch( msg ){
02551    // put in PAINT statement here if required RSF TODO
02552    case WM_INITDIALOG:{
02553        TC_ITEM tie;
02554        int h;
02555        DWORD dwDlgBase=GetDialogBaseUnits();
02556        if(PrimStruct.auto_interactive)
02557          SendDlgItemMessage(hdlg,DLG_TAB_PRIMES_AUTO,BM_SETCHECK,TRUE,0);
02558        else
02559          SendDlgItemMessage(hdlg,DLG_TAB_PRIMES_AUTO,BM_SETCHECK,FALSE,0);
02560        if(xpos == -1 && ypos == -1){
02561          xp=GetPrivateProfileInt(IniSection,"PRPOSX",-1,IniFilename);
02562          yp=GetPrivateProfileInt(IniSection,"PRPOSY",-1,IniFilename);
02563          if(xp < 0 || yp < 0){
02564            RECT rc1;
02565            GetWindowRect(hdlg,&rc1);
02566            GetWindowRect(ghwndTools,&rc);
02567            if(bToolpannelLeft)xpos=rc.right+5;
02568            else               xpos=rc.left-(rc1.right-rc1.left)-5;
02569            ypos=rc.top;
02570          }
02571          else{
02572            xpos=xp; ypos=yp;
02573          }
02574        }
02575        SetWindowPos(hdlg,HWND_TOP,xpos,ypos,0,0,SWP_NOSIZE);
02576        lpDlgHdrPrimitives=&DlgHdrPrimitives;
02577        GetWindowRect(hdlg,&rc);
02578        GetWindowRect(GetDlgItem(hdlg,IDOK),&rd);
02579        h=rd.top-rc.top-GetSystemMetrics(SM_CYCAPTION);
02580        GetClientRect(hdlg,&rc);
02581        hwndTabPrimitives=CreateWindowEx(
02582                             0,
02583                             WC_TABCONTROL,"Hello ",
02584                             TCS_MULTILINE |//TCS_FOCUSNEVER |
02585                             WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
02586                             (D_BORDER*LOWORD(dwDlgBase))/4,
02587                             (D_BORDER*HIWORD(dwDlgBase))/8,
02588                             rc.right-(2*D_BORDER*LOWORD(dwDlgBase))/4,
02589                             h-(2*D_BORDER*HIWORD(dwDlgBase))/8,
02590                             hdlg,NULL,ghinst_main,NULL);
02591        {char text_string[255];
02592          LoadString(ghinst_main,IDX_MISC_LANGUAGE,
02593                     text_string,sizeof(text_string));
02594          if(strcmp(text_string,"ENGLISH") == 0)
02595            SendMessage(hwndTabPrimitives,WM_SETFONT, /* for text in tab */
02596                   (WPARAM)GetStockObject(ANSI_VAR_FONT),0);
02597        }
02598        memset(&tie,0,sizeof(TC_ITEM));
02599        tie.mask = TCIF_TEXT;// | TCIF_IMAGE;
02600 //       tie.iImage = -1;
02601        tie.pszText=str;
02602        LoadString(ghinst_main,IDX_PRIMS_RECTANGLE,str,32);
02603        TabCtrl_InsertItem(hwndTabPrimitives,0,&tie);
02604        LoadString(ghinst_main,IDX_PRIMS_CUBE,str,32);
02605        TabCtrl_InsertItem(hwndTabPrimitives,1,&tie);
02606        LoadString(ghinst_main,IDX_PRIMS_POLYGON,str,32);
02607        TabCtrl_InsertItem(hwndTabPrimitives,2,&tie);
02608        LoadString(ghinst_main,IDX_PRIMS_TUBE,str,32);
02609        TabCtrl_InsertItem(hwndTabPrimitives,3,&tie);
02610        LoadString(ghinst_main,IDX_PRIMS_DISK,str,32);
02611        TabCtrl_InsertItem(hwndTabPrimitives,4,&tie);
02612        LoadString(ghinst_main,IDX_PRIMS_CYLINDER,str,32);
02613        TabCtrl_InsertItem(hwndTabPrimitives,5,&tie);
02614        LoadString(ghinst_main,IDX_PRIMS_CONE,str,32);
02615        TabCtrl_InsertItem(hwndTabPrimitives,6,&tie);
02616        LoadString(ghinst_main,IDX_PRIMS_SPHERE,str,32);
02617        TabCtrl_InsertItem(hwndTabPrimitives,7,&tie);
02618        LoadString(ghinst_main,IDX_PRIMS_SPHERE1,str,32);
02619        TabCtrl_InsertItem(hwndTabPrimitives,8,&tie);
02620        LoadString(ghinst_main,IDX_PRIMS_TORUS,str,32);
02621        TabCtrl_InsertItem(hwndTabPrimitives,9,&tie);
02622        SetRectEmpty(&rc);
02623        TabCtrl_AdjustRect(hwndTabPrimitives,FALSE,&rc);
02624        rc.left += (D_BORDER*LOWORD(dwDlgBase))/4;
02625        rc.top += (D_BORDER*HIWORD(dwDlgBase))/8;
02626        CopyRect(&(lpDlgHdrPrimitives->rcTab),&rc);
02627        for(i=0;i<N_PRIMS;i++)lpDlgHdrPrimitives->hwndDlg[i]=NULL;
02628        lpDlgHdrPrimitives->hwndDlg[0]=CreateDialog(ghinst_main,
02629                                    MAKEINTRESOURCE(DLG_PR_PLANE),
02630                                    hdlg,(DLGPROC)PlanePrimitiveDlgProc);
02631        SetWindowPos(lpDlgHdrPrimitives->hwndDlg[0],NULL,
02632                     lpDlgHdrPrimitives->rcTab.left,
02633                     lpDlgHdrPrimitives->rcTab.top,0,0,
02634                     SWP_NOSIZE | SWP_NOZORDER);
02635        ShowWindow(lpDlgHdrPrimitives->hwndDlg[0],SW_SHOW);
02636      }
02637      return TRUE;
02638    case WM_NOTIFY:
02639      if( ((LPNMHDR)lparam)->code == TCN_SELCHANGING){
02640        int id=TabCtrl_GetCurSel(hwndTabPrimitives);
02641      }
02642      if( ((LPNMHDR)lparam)->code == TCN_SELCHANGE){
02643        int id=TabCtrl_GetCurSel(hwndTabPrimitives);
02644        for(i=0;i<N_PRIMS;i++){
02645          if(lpDlgHdrPrimitives->hwndDlg[i] != NULL){
02646            SendMessage(lpDlgHdrPrimitives->hwndDlg[i],
02647                        WM_COMMAND,(WPARAM)IDOK,0);
02648            DestroyWindow(lpDlgHdrPrimitives->hwndDlg[i]);
02649            lpDlgHdrPrimitives->hwndDlg[i]=NULL;
02650          }
02651        }
02652        PrimitiveType=id;
02653        if(id == 0)lpDlgHdrPrimitives->hwndDlg[0]=CreateDialog(ghinst_main,
02654                                      MAKEINTRESOURCE(DLG_PR_PLANE),
02655                                      hdlg,(DLGPROC)PlanePrimitiveDlgProc);
02656        if(id == 1)lpDlgHdrPrimitives->hwndDlg[1]=CreateDialog(ghinst_main,
02657                                      MAKEINTRESOURCE(DLG_PR_CUBE),
02658                                      hdlg,(DLGPROC)CubePrimitiveDlgProc);
02659        if(id == 2)lpDlgHdrPrimitives->hwndDlg[2]=CreateDialog(ghinst_main,
02660                                      MAKEINTRESOURCE(DLG_PR_POLY),
02661                                      hdlg,(DLGPROC)PolygonPrimitiveDlgProc);
02662        if(id == 3)lpDlgHdrPrimitives->hwndDlg[3]=CreateDialog(ghinst_main,
02663                                      MAKEINTRESOURCE(DLG_PR_TUBE),
02664                                      hdlg,(DLGPROC)TubePrimitiveDlgProc);
02665        if(id == 4)lpDlgHdrPrimitives->hwndDlg[4]=CreateDialog(ghinst_main,
02666                                      MAKEINTRESOURCE(DLG_PR_DISK),
02667                                      hdlg,(DLGPROC)DiskPrimitiveDlgProc);
02668        if(id == 5)lpDlgHdrPrimitives->hwndDlg[5]=CreateDialog(ghinst_main,
02669                                      MAKEINTRESOURCE(DLG_PR_CYL),
02670                                      hdlg,(DLGPROC)CylinderPrimitiveDlgProc);
02671        if(id == 6)lpDlgHdrPrimitives->hwndDlg[6]=CreateDialog(ghinst_main,
02672                                      MAKEINTRESOURCE(DLG_PR_CONE),
02673                                      hdlg,(DLGPROC)ConePrimitiveDlgProc);
02674        if(id == 7)lpDlgHdrPrimitives->hwndDlg[7]=CreateDialog(ghinst_main,
02675                                      MAKEINTRESOURCE(DLG_PR_SPH),
02676                                      hdlg,(DLGPROC)SpherePrimitiveDlgProc);
02677        if(id == 8)lpDlgHdrPrimitives->hwndDlg[8]=CreateDialog(ghinst_main,
02678                                      MAKEINTRESOURCE(DLG_PR_SPH1),
02679                                      hdlg,(DLGPROC)Sphere1PrimitiveDlgProc);
02680        if(id == 9)lpDlgHdrPrimitives->hwndDlg[9]=CreateDialog(ghinst_main,
02681                                      MAKEINTRESOURCE(DLG_PR_TORUS),
02682                                      hdlg,(DLGPROC)TorusPrimitiveDlgProc);
02683        if(lpDlgHdrPrimitives->hwndDlg[id] != NULL){
02684          SetWindowPos(lpDlgHdrPrimitives->hwndDlg[id],NULL,
02685                       lpDlgHdrPrimitives->rcTab.left,
02686                       lpDlgHdrPrimitives->rcTab.top,0,0,
02687                       SWP_NOSIZE | SWP_NOZORDER);
02688          ShowWindow(lpDlgHdrPrimitives->hwndDlg[id],SW_SHOW);
02689        }
02690      }
02691      break;
02692    case WM_SYSCOMMAND:
02693      switch(LOWORD(wparam & 0xfff0)){
02694        default:
02695          break;
02696        case SC_CLOSE:
02697          PostMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
02698          break;
02699      }
02700      break;
02701    case WM_COMMAND:
02702      switch( LOWORD(wparam) ){
02703        case DLG_TAB_PRIMES_AUTO:
02704          if(SendDlgItemMessage(hdlg,DLG_TAB_PRIMES_AUTO,BM_GETCHECK,0,0))
02705            PrimStruct.auto_interactive=TRUE;
02706          else
02707            PrimStruct.auto_interactive=FALSE;
02708          break;
02709        case IDOK:
02710          for(i=0;i<N_PRIMS;i++){
02711            if(lpDlgHdrPrimitives->hwndDlg[i] != NULL)
02712             SendMessage(lpDlgHdrPrimitives->hwndDlg[i],WM_COMMAND,
02713                         (WPARAM)IDOK,0);
02714          }
02715          BuildPrimitive(PrimitiveType,ActiveView);
02716          break;
02717        case IDCANCEL:
02718          PostMessage(ghwnd_main,WM_COMMAND,IDM_STOP,0);
02719        default:
02720          break;
02721      }
02722      break;
02723    case WM_NCHITTEST:
02724      if(current_message >= 0){
02725        current_message = -1;
02726        SendPrgmMessage(IDS_ZERO,1);
02727      }
02728      break;
02729    case WM_UPDATEPDIALOG:
02730      /* send message to active dialog to update it */
02731      for(i=0;i<N_PRIMS;i++){
02732        if(lpDlgHdrPrimitives->hwndDlg[i] != NULL)
02733          SendMessage(lpDlgHdrPrimitives->hwndDlg[i],WM_UPDATEPDIALOG,0,0);
02734      }
02735      break;
02736    case WM_INTERROGATE:
02737      /* send message to interrogate the dialog it */
02738      for(i=0;i<N_PRIMS;i++){
02739        if(lpDlgHdrPrimitives->hwndDlg[i] != NULL)
02740          SendMessage(lpDlgHdrPrimitives->hwndDlg[i],WM_COMMAND,(WPARAM)IDOK,0);
02741      }
02742      break;
02743    case WM_DESTROY:
02744      for(i=0;i<N_PRIMS;i++){
02745        if(lpDlgHdrPrimitives->hwndDlg[i] != NULL)
02746          DestroyWindow(lpDlgHdrPrimitives->hwndDlg[i]);
02747        lpDlgHdrPrimitives->hwndDlg[i]=NULL;
02748      }
02749      GetWindowRect(hdlg,&rc);
02750      xpos=rc.left; ypos=rc.top;
02751      sprintf(str,"%ld",xpos);
02752      WritePrivateProfileString(IniSection,"PRPOSX",str,IniFilename);
02753      sprintf(str,"%ld",ypos);
02754      WritePrivateProfileString(IniSection,"PRPOSY",str,IniFilename);
02755      break;
02756    default: break;
02757  }
02758  return( FALSE );
02759 }
02760 
02761 BOOL IsPrimitivesDialogMessage(MSG *msg){
02762  int i;
02763  DLGHDR1 *lpDlgHdr;
02764  lpDlgHdr=&DlgHdrPrimitives;
02765  for(i=0;i<N_PRIMS;i++){
02766    if(lpDlgHdr->hwndDlg[i] != NULL){
02767      if(IsDialogMessage(lpDlgHdr->hwndDlg[i],msg))return TRUE;
02768    }
02769  }
02770  return IsDialogMessage(ghwndDlgPrimitives,msg);
02771 }

Generated on Sun Apr 27 14:20:08 2014 for OpenFX by  doxygen 1.5.6