; $Id: fdave_enterinfo.pro,v 1.3 2005/02/09 13:38:36 dimeo Exp $
;###############################################################################
;
; NAME:
;  FDAVE_ENTERINFO
;
; PURPOSE:
;  Modal widget dialog for entering information about the ascii file.
;
; CATEGORY:
;  DAVE, ASCII data reader.
;
; AUTHOR:
;   Robert M. Dimeo, Ph.D.
;   NIST Center for Neutron Research
;   100 Bureau Drive
;   Gaithersburg, MD 20899
;   Phone: (301) 975-8135
;   E-mail: robert.dimeo@nist.gov
;   http://www.ncnr.nist.gov/staff/dimeo
;
; LICENSE:
;  The software in this file is written by an employee of
;  National Institute of Standards and Technology
;  as part of the DAVE software project.
;
;  The DAVE software package is not subject to copyright protection
;  and is in the public domain. It should be considered as an
;  experimental neutron scattering data reduction, visualization, and
;  analysis system. As such, the authors assume no responsibility
;  whatsoever for its use, and make no guarantees, expressed or
;  implied, about its quality, reliability, or any other
;  characteristic. The use of certain trade names or commercial
;  products does not imply any endorsement of a particular product,
;  nor does it imply that the named product is necessarily the best
;  product for the stated purpose. We would appreciate acknowledgment
;  if the DAVE software is used of if the code in this file is
;  included in another product.
;
;###############################################################################
; fDave_EnterInfo.pro
;
; Modal widget function that allows the user to
; enter information to accompany an ASCII file.
;
; Written by R.M.Dimeo (11/13/01)
;;;;;;;;
pro fdaveEICleanup,tlb
widget_control,tlb,get_uvalue = pState,/no_copy
ptr_free,pState
return
end
;;;;;;;;
pro fdaveEIDismiss,event
widget_control,event.top,get_uvalue = pState,/no_copy
if event.id eq (*pState).cancel then begin
  widget_control,event.top,/destroy
  return
endif
if event.id eq (*pState).accept then begin
  widget_control,(*pState).xtitleField,get_value = xtitle
  widget_control,(*pState).ytitleField,get_value = ytitle
  widget_control,(*pState).instrumentField,get_value = instrument
  instrument = instrument[0]
  xtitle = xtitle[0]
  ytitle = ytitle[0]
  (*(*(*pState).inPtr).dataStrPtr).commonStr.instrument = instrument
  (*(*(*pState).inPtr).dataStrPtr).commonStr.xlabel = xtitle
  (*(*(*pState).inPtr).dataStrPtr).commonStr.histlabel = ytitle
  widget_control,event.top,set_uvalue = pState,/no_copy
  widget_control,event.top,/destroy
endif
return
end
;;;;;;;;
pro fdave_enterinfo_event,event
return
end
;;;;;;;;
function fdave_enterinfo,inPtr,group_leader = group_leader
tlb = widget_base(/modal,group_leader = group_leader,/col,$
        title = 'ASCII File Information',tlb_frame_attr = 1,$
        /base_align_center)
initXlabel = (*(*inPtr).dataStrPtr).commonStr.xlabel
initYlabel = (*(*inPtr).dataStrPtr).commonStr.histlabel
initInstrument = (*(*inPtr).dataStrPtr).commonStr.instrument
instrumentField = cw_field(tlb,title = 'Instrument' ,value = initInstrument,/string,xsize = 25)
xtitleField = cw_field(tlb,title = 'x label',value = initXlabel,/string,xsize = 25)
ytitleField = cw_field(tlb,title = 'y label',value = initYlabel,/string,xsize = 25)

rowBase = widget_base(tlb,/row,/base_align_center)
accept = widget_button(rowBase,value = 'ACCEPT',event_pro = 'fdaveEIDismiss')
cancel = widget_button(rowBase,value = 'CANCEL',event_pro = 'fdaveEIDismiss')

widget_control,tlb,/realize
state = {inPtr:inPtr,$
            xtitleField:xtitleField,$
            ytitleField:ytitleField,$
            instrumentField:instrumentField,$
            accept:accept,$
            cancel:cancel}

pState = ptr_new(state)
widget_control,tlb,set_uvalue = pState
xmanager,'fdave_enterinfo',tlb
return,0
end