; $Id: dave_choose_menu_system.pro,v 1.4 2005/02/03 18:04:12 azuah Exp $
; DAVE_CHOOSE_MENU_SYSTEM.PRO
;
; Dialog that gives users option to run "classic DAVE" or the
; new "tree-view DAVE".
;
;###############################################################################
;
; 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.
;
;###############################################################################
;
; Written by R.M.Dimeo (02/28/04)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
pro dcm_event,event
widget_control,event.top,get_uvalue = pstate
uname = widget_info(event.id,/uname)
case uname of
'CHOICE':   $
   begin
      if event.value eq 0 then (*pstate).choice.classic = 1B $
         else (*pstate).choice.classic = 0B
   end
'SHOW':     $
   begin
      setting = widget_info(event.id,/button_set)
      (*pstate).choice.show_choice = ~setting
   end
'DISMISS':  $
   begin
      id = widget_info(event.top,find_by_uname = 'CHOICE')
      widget_control,id,get_value = value
      if value eq 0 then sel = 1B else sel = 0B
      (*pstate).choice.classic = sel

      id = widget_info(event.top,find_by_uname = 'SHOW')
      setting = widget_info(id,/button_set)
      (*pstate).choice.show_choice = not setting
      widget_control,event.top,/destroy
   end
else:
endcase
end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
function dave_choose_menu_system,   classic = classic,      $
                                    show_choice = show_choice
title = 'Menu System Selection'
tlb = widget_base(/col,title = title,/tlb_frame_attr,/base_align_center)
strout = ['You now have a choice between two ways in which', $
   'the DAVE menu system is displayed.  If you have used DAVE', $
    'before then you are familiar with the "classic DAVE" mode.', $
    'The second choice is called "Tree View DAVE" which you', $
    'may find easier to navigate.', $
    '', $
    'Make your selection below.  You can opt not to display this', $
    'dialog again by selecting "Do not ask me again".']
this_len = 60
void = widget_text(tlb,value = strout,ysize = n_elements(strout), $
   xsize = this_len)

names = ['Classic DAVE','Tree View DAVE']
group_id = cw_bgroup(tlb,names,/row,label_top = 'Selection',/exclusive, $
   uname = 'CHOICE')

base = widget_base(tlb,/nonexclusive)
show_id = widget_button(base,value = "Do not ask me this again", $
   uname = 'SHOW')
void = widget_button(tlb,value = 'CONTINUE',uname = 'DISMISS')
centertlb,tlb

widget_control,tlb,/realize
if classic then values = 0 else values = 1
widget_control,group_id,set_value = values
widget_control,show_id,set_button = ~show_choice

state = {choice:{classic:classic,show_choice:show_choice}}
pstate = ptr_new(state)
widget_control,tlb,set_uvalue = pstate
reg_name = 'dcm'
xmanager,reg_name,tlb,event_handler = 'dcm_event'
choice = (*pstate).choice
ptr_free,pstate
return,choice
end
