; $Id: hfbs_rebwidget.pro,v 1.2 2002/01/14 20:59:25 amunter Exp $
; hfbs_RebWidget.pro
;
; Function widget that returns the lower limit, upper limit,
; and bin size for rebinned data.
;
; USAGE: rebVals = hfbs_RebWidget(xlo = xlo,xhi = xhi,$
;                             binsize = binsize,group_leader = event.top)
;
; Written by R.M.Dimeo (11/07/01)
;;;;;;;;;;;;;;
pro hfbs_RebWidgetQuit,event
widget_control,event.top,/destroy
return
end
;;;;;;;;;;;;;;
pro hfbs_RebWidget_event,event
widget_control,event.top,get_uvalue = pState,/no_copy
case event.id of
(*pState).cancel:  begin
                             widget_control,event.top,set_uvalue = pState,/no_copy
                             widget_control,event.top,/destroy
                           end
(*pState).accept: begin
                               widget_control,(*pState).wxlo,get_value = xlo
                               (*pState).xvlo = float(xlo[0])
                               widget_control,(*pState).wxhi,get_value = xhi
                               (*pState).xvhi = float(xhi[0])
                               widget_control,(*pState).wdx,get_value = binsize
                               (*pState).dxv = float(binsize[0])
                               widget_control,event.top,set_uvalue = pState,/no_copy
                               widget_control,event.top,/destroy
						   end
else:                    widget_control,event.top,set_uvalue = pState,/no_copy
endcase
return
end
;;;;;;;;;;;;;;
function hfbs_RebWidget,xlo = xlo,$
                                       xhi = xhi,$
                                       binsize = binsize,$
                                       group_leader = group_leader
; widget definition module
if n_elements(group_leader) ne 0 then begin
  tlb = widget_base(group_leader = group_leader,/row,title = 'Rebin Values',$
                             tlb_frame_attr = 1,/base_align_left,/modal)
endif else begin
  tlb = widget_base(/row,title = 'Rebin Values',$
                             tlb_frame_attr = 1,/base_align_left)
endelse
base1 = widget_base(tlb,/col,/base_align_left)
base2 = widget_base(tlb,/col,/base_align_left)
void = widget_text(base1,value = 'Lower limit')
wxlo = widget_text(base2,value = string(xlo),/editable)
void = widget_text(base1,value = 'Upper limit')
wxhi = widget_text(base2,value = string(xhi),/editable)
void = widget_text(base1,value = 'Bin size')
wdx = widget_text(base2,value = string(binsize),/editable)
accept = widget_button(base1,value = 'Accept')
cancel = widget_button(base2,value = 'Cancel')
centertlb,tlb
widget_control,tlb,/realize
state = {wxlo:wxlo,wxhi:wxhi,wdx:wdx,$
            xvlo:xlo,xvhi:xhi,dxv:binsize,$
            accept:accept,cancel:cancel}
pState = ptr_new(state)
widget_control,tlb,set_uvalue = pState
xmanager,'hfbs_RebWidget',tlb
state = *pState
ptr_free,pState
rebVals = [state.xvlo,state.xvhi,state.dxv]
return,rebVals
end