/******************************************************************************/
/*                                                                            */
/*  DLG_CMAP - Dialog callback for color map entry                            */
/*                                                                            */
/******************************************************************************/

#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 <malloc.h>
#include <new.h>
#include <float.h>

#include "const.h"
#include "classes.h"
#include "extern.h"
#include "funcdefs.h"
#include "julia.rh"

extern "C"

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

         sprintf_s ( msg , "%.1lf" , CmapStart ) ;
         SetDlgItemText ( hdwnd , IDC_COLORMAP_START , msg ) ;
         SetDlgItemInt ( hdwnd , IDC_COLORMAP_NCOLORS , CmapNcolors , FALSE ) ;
         sprintf_s ( msg , "%.1lf" , CmapFloor ) ;
         SetDlgItemText ( hdwnd , IDC_COLORMAP_FLOOR , msg ) ;
         SetDlgItemInt ( hdwnd , IDC_COLORMAP_NLINEAR , CmapNlinear , FALSE ) ;
         SetDlgItemInt ( hdwnd , IDC_COLORMAP_NLOG , CmapNlog , FALSE ) ;
         
      case WM_COMMAND:
         id = LOWORD ( wParam ) ;
         switch ( id ) {

            case IDOK:

               GetDlgItemText ( hdwnd , IDC_COLORMAP_START , msg , 255 ) ;
               CmapStart = atof ( msg ) ;
               CmapNcolors = GetDlgItemInt ( hdwnd , IDC_COLORMAP_NCOLORS , NULL , FALSE ) ;
               GetDlgItemText ( hdwnd , IDC_COLORMAP_FLOOR , msg , 255 ) ;
               CmapFloor = atof ( msg ) ;
               CmapNlinear = GetDlgItemInt ( hdwnd , IDC_COLORMAP_NLINEAR , NULL , FALSE ) ;
               CmapNlog = GetDlgItemInt ( hdwnd , IDC_COLORMAP_NLOG , NULL , FALSE ) ;

            case IDCANCEL:
               EndDialog ( hdwnd , FALSE ) ;
               return TRUE ;  // Tell Windows we processed this message
            }
      }
      
   return FALSE ;  // Tell Windows we did not process this message
}
