/**********************************************************************************/
/*                                                                                */
/*  DLG_PARAMS - dialog callbacks for blocks image parameters                     */
/*                                                                                */
/**********************************************************************************/

#define STRICT
#include <windows.h>
#include <commctrl.h>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include "const.h"
#include "classes.h"
#include "funcdefs.h"
#include "blocks.rh"
#include "extern.h"

extern "C"

INT_PTR CALLBACK DialogBlocksParams ( HWND hdwnd , UINT message ,
                                      WPARAM wParam , LPARAM /* lParam */ )
{
   int id ;
   char msg[256] ;

   switch ( message ) {
      
      case WM_INITDIALOG:
         SetDlgItemInt ( hdwnd , IDC_IMAGE_ROWS , blocks_params.nrows , TRUE ) ;
         SetDlgItemInt ( hdwnd , IDC_IMAGE_COLS , blocks_params.ncols , TRUE ) ;
         sprintf_s ( msg , "%.2lf", blocks_params.height ) ;
         SetDlgItemText ( hdwnd , IDC_HEIGHT , msg ) ;
         sprintf_s ( msg , "%.2lf", blocks_params.width ) ;
         SetDlgItemText ( hdwnd , IDC_WIDTH , msg ) ;
         sprintf_s ( msg , "%.2lf", blocks_params.depth ) ;
         SetDlgItemText ( hdwnd , IDC_DEPTH , msg ) ;
         sprintf_s ( msg , "%.2lf", blocks_params.angle ) ;
         SetDlgItemText ( hdwnd , IDC_ANGLE , msg ) ;
         sprintf_s ( msg , "%.2lf", blocks_params.front_tone ) ;
         SetDlgItemText ( hdwnd , IDC_FRONT_TONE , msg ) ;
         sprintf_s ( msg , "%.2lf", blocks_params.side_tone ) ;
         SetDlgItemText ( hdwnd , IDC_SIDE_TONE , msg ) ;
         sprintf_s ( msg , "%.2lf", blocks_params.top_tone ) ;
         SetDlgItemText ( hdwnd , IDC_TOP_TONE , msg ) ;
         return TRUE ;
         
      case WM_COMMAND:
         id = LOWORD ( wParam ) ;
         switch ( id ) {
            case IDOK:
               blocks_params.nrows = GetDlgItemInt ( hdwnd , IDC_IMAGE_ROWS , NULL , FALSE ) ;
               blocks_params.ncols = GetDlgItemInt ( hdwnd , IDC_IMAGE_COLS , NULL , FALSE ) ;
               GetDlgItemText ( hdwnd , IDC_HEIGHT , msg , 256 ) ;
               blocks_params.height = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_WIDTH , msg , 256 ) ;
               blocks_params.width = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_DEPTH , msg , 256 ) ;
               blocks_params.depth = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_ANGLE , msg , 256 ) ;
               blocks_params.angle = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_FRONT_TONE , msg , 256 ) ;
               blocks_params.front_tone = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_SIDE_TONE , msg , 256 ) ;
               blocks_params.side_tone = atof ( msg ) ;
               GetDlgItemText ( hdwnd , IDC_TOP_TONE , msg , 256 ) ;
               blocks_params.top_tone = atof ( msg ) ;
               EndDialog ( hdwnd , TRUE ) ;
               return TRUE ;  // Tell Windows we processed this message
            case IDCANCEL:
               EndDialog ( hdwnd , FALSE ) ;
               return TRUE ;  // Tell Windows we processed this message
            }
      }
      
   return FALSE ;  // Tell Windows we did not process this message
}
