Viewing contents of file '../idllib/contrib/tappin/graffer/graff_s_prompt.pro'
;+
; GRAFF_S_PROMPT
;	Do you really want to destroy what you just did?
;
; Usage:
;	ido = graff_s_prompt(pdefs)
;
; Return:
;	ido	int	Do I go on?
;
; Argument
;	pdefs	struct	input	The graffer structure, needed if save
;	requested.
;
; History:
;	Original: 18/8/95; SJT
;	Add input focus to SAVE button: 22/8/95; SJT
;	Add options for binary or ascii save: 15/1/97; SJT
;-

function Graff_s_prompt, pdefs

widget_control, pdefs.ids.graffer, sensitive = 0

base = widget_base(/column, title = 'Graffer save?', $
                   group_leader = pdefs.ids.graffer, resource = $
                   'Graffer', tlb_frame_attr = 31)

msg = ['Plot has been modified', $
       'since last saved']

junk = widget_text(base, value = msg, xsize = max(strlen(msg)), ysize $
                   = n_elements(msg))

opts = ['CANCEL', 'SAVE BINARY', 'SAVE ASCII', 'CONTINUE']
vals = [0, -1, -2, 1]

junk = cw_bgroup(base, opts, /row, button_uvalue = vals, ids = bids)


;	RYO widget management to allow us to get the values back from
;	the event handler without using a common block, even after the
;	hierarchy has been destroyed.

widget_control, base, /real
widget_control, bids(1), /input

ev = widget_event(base)

widget_control, base, /destroy

if (ev.value eq -1) then begin
    gr_bin_save, pdefs
    ev.value = 1
endif else if (ev.value eq -2) then begin
    gr_asc_save, pdefs
    ev.value = 1
endif

widget_control, pdefs.ids.graffer, sensitive = 1

return, ev.value

end