PRO RH_W_DPIMAGE_Event, Event

  COMMON rh_wdpim, np, larg , period, mode_inter, rot_p, i_affich_lobe
  COMMON rh_dpim_base, bnp, brs, bper, bmode_inter, brot_p, baffich_lobe 

  WIDGET_CONTROL,Event.Id,GET_UVALUE = Ev

  CASE Ev OF

  'help_im': BEGIN
	     rh_dp_aide, message, sujet = 'specifying the image'
             mes = DIALOG_MESSAGE(message, /INFORMATION, $
                   TITLE = 'Read Me: Specifying the image')
	  END
  'std'   : BEGIN
            DEF_STR_DP, str_dp
            np          = str_dp.np
            larg        = str_dp.larg
            period      = str_dp.n_period
            mode_inter  = str_dp.mode_interpol - 1
            rot_p       = str_dp.rot_p
            tab = ['128','256','64']
            ind = where (np eq fix(tab))
            WIDGET_CONTROL, bnp, SET_DROPLIST_SELECT = ind(0)
            tab = ['4','6','8','10']
            ind = where (larg eq fix(tab))
            WIDGET_CONTROL, brs, SET_DROPLIST_SELECT = ind(0)
            tab = ['1.','1.5']
            ind = where (period eq float(tab))
            WIDGET_CONTROL, bper, SET_DROPLIST_SELECT = ind(0)
            WIDGET_CONTROL, bmode_inter, SET_DROPLIST_SELECT = mode_inter
            WIDGET_CONTROL, brot_p, SET_DROPLIST_SELECT = rot_p
	  END
  'np':BEGIN
;               print,'np'
               CASE event.index OF
               0: np=128
               1: np=256
	       2: np=64
               ENDCASE
          END

  'radius':  BEGIN
               CASE event.index OF
               0: larg=4.
               1: larg=6.
               2: larg=8.
               3: larg=10.
               ENDCASE
          END
  'period':BEGIN
               CASE event.index OF
               0: period = 1.
               1: period = 1.5
               ENDCASE
               print,'period',period
           END
  'mode_inter': BEGIN
               CASE event.index OF
               0: mode_inter = 0
               1: mode_inter = 1
               2: mode_inter = 2
               ENDCASE
           END
  'rot_P' : rot_p = event.index
  'i_affich_lobe' : begin
i_affich_lobe = event.index
print,i_affich_lobe
end
  'ok':  BEGIN
;         print,'ok',np, larg, period, iuv, i_clean, tab_sel_ext, mode_inter
         WIDGET_CONTROL,EVENT.TOP,/DESTROY   
         END
  ENDCASE
END


PRO RH_W_DPIMAGE

  COMMON rh_wdpim, np, larg , period, mode_inter, rot_p, i_affich_lobe

  COMMON rh_dpim_base, bnp, brs, bper, bmode_inter, brot_p, baffich_lobe 

  if (xregistered('RH_W_DPIMAGE')) then begin     ; Don't make a second copy.
     print,' " Specifying the image " already in use'
     return
  end

;  IF N_ELEMENTS(Group) EQ 0 THEN GROUP=0

  imBASE = WIDGET_BASE(COLUMN=1,$ 
             TITLE='Specifying the image', SPACE= 20, $
	    /BASE_ALIGN_CENTER)

  BASE = WIDGET_BASE(imbase, /COLUMN, SPACE= 15,/BASE_ALIGN_CENTER,/FRAME)
 
  b = WIDGET_BUTTON( BASE, UVALUE='help_im', VALUE='Read Me', $
      xs=4., ys=0.8, units = 2)

  ggbase = widget_base(base, /col, /frame)

;-------------- gbase ----------------------------
  gbase = widget_base(ggbase, /row)   

  tab = ['4','6','8','10']
  ind = where (larg eq fix(tab))
  lrs = WIDGET_Label(gbase,Value=' Field (sol rad):') 
  brs = WIDGET_DROPLIST( gBASE, UVALUE='radius',value=tab) 
  WIDGET_CONTROL, brs, SET_DROPLIST_SELECT = ind(0)
 
  lrot_p = WIDGET_Label(gbase,Value=' P angle rotation : ')
  tab = [' No','Yes']
  brot_P = WIDGET_DROPLIST( gBASE, UVALUE='rot_P',value= tab)
  WIDGET_CONTROL, brot_p, SET_DROPLIST_SELECT = rot_p

;-------------- gbase1 ----------------------------
  gbase1 = widget_base(ggbase, /row)
  tab = ['1.','1.5']
  ind = where (period eq float(tab))
  lper1 = WIDGET_Label(gbase1,Value=' ( From interferometric image over') 
  bper = WIDGET_DROPLIST( gBASE1, UVALUE='period',value=tab)
  WIDGET_CONTROL, bper, SET_DROPLIST_SELECT = ind(0)
  lper2 = WIDGET_Label(gbase1,Value=' periods )')
;-------------- gbase15 ----------------------------
  gbase15 = widget_base(ggbase, /row) 
  lnp = WIDGET_Label(gbase15,Value=' Final image : pixels')
  tab = ['128','256','64']
  ind = where (np eq fix(tab))
  bnp = WIDGET_DROPLIST( gBASE15, UVALUE='np',value= tab)
  WIDGET_CONTROL, bnp, SET_DROPLIST_SELECT = ind(0)
;-------------- gbase25 ----------------------------
  gbase25 = widget_base(ggbase, /row)
  tab = [' Fast','Spline', ' FFT']
  lmode_inter = WIDGET_Label(gbase25,Value=' Final interpolation :')  
  bmode_inter = WIDGET_DROPLIST( gBASE25, UVALUE='mode_inter',	$
		value=tab)
  WIDGET_CONTROL, bmode_inter, SET_DROPLIST_SELECT = mode_inter
;---------------------------------------------------
  gbase26 = widget_base(ggbase, /row)
  laffich_lobe = WIDGET_Label(gbase26,Value=' Display Beam : ')
  tab = [' No','Yes']
  baffich_lobe = WIDGET_DROPLIST( gbase26, UVALUE='i_affich_lobe',value= tab)
  WIDGET_CONTROL, baffich_lobe, SET_DROPLIST_SELECT = i_affich_lobe


  b = WIDGET_BUTTON( BASE, UVALUE='std',                        $
                     VALUE='Back to Local Standard Parameters', $
                     xs=10., ys=1, units=2)

  b = WIDGET_BUTTON( BASE, UVALUE='ok', VALUE='ok', $
      xs=2., ys=1, units = 2)

  WIDGET_CONTROL, imBASE, /REALIZE
  
   XMANAGER, 'RH_W_DPIMAGE', imBASE,/NO_BLOCK

END
