;+ ; GRAFF_FNAME ; Get a graffer filename ; ; Usage: ; file = graff_fname(topid, ifile, dir) ; ; Return: ; file string The filename (graffer.grf if null) ; ; Arguments: ; topid long input Widget ID of group leader ; ifile string input Initial value of file name in widget ; dir string in/out Directory where the file is to be ; found ; ; History: ; Original: 18/8/95; SJT ; Add timer event to push to front if obscured: 23/8/95; SJT ; Add file & dir arguments: Sep 95; SJT ;- function Gr_fn_event, event widget_control, event.id, get_uvalue = but widget_control, event.handler, get_uvalue = fwid txt = '' case but of 'ACTION': begin if (event.value eq 1) then begin widget_control, fwid(0), get_value = file widget_control, fwid(1), get_value = dir endif else begin file = '' dir = '' endelse iexit = event.value end 'POP': begin widget_control, event.top, /show widget_control, event.id, timer = 2. file = '' dir = '' iexit = 0 end endcase rv = {id:event.id, top:event.top, handler:event.handler, $ Exited:iexit, value:[file, dir]} return, rv end function Graff_fname, topid, ifile, dir if (n_elements(dir) eq 0) then dir = '' widget_control, topid, sensitive = 0 tlb = widget_base(title = 'Graffer file', group_leader = topid) base = widget_base(/column, tlb) jb = widget_base(base, /column, uvalue = 'POP') fwid = graff_enter(jb, value = ifile, xsize = 30, label = $ 'File:', /no_event) dwid = graff_enter(jb, value = dir, xsize = 30, label = $ 'Directory:', /no_event) junk = cw_bgroup(base, ['Done', 'Cancel'], /row, uvalue = 'ACTION', $ button_uvalue = [1, -1]) ; 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, tlb, /real widget_control, base, event_func = 'gr_fn_event', $ set_uvalue = [fwid, dwid] widget_control, jb, timer = 2. repeat begin ev = widget_event(tlb) endrep until (ev.exited ne 0) widget_control, ev.top, /destroy if (ev.exited eq -1) then file = '' $ else begin file = ev.value(0) dir = ev.value(1) if (file eq '') then file = 'graffer.grf' case !Version.os of 'vms': separator = ']' 'windows': separator = '\' 'MacOS': separator = "\" Else: separator = '/' ; Unixen endcase if (rstrpos(dir, separator) ne strlen(dir)-1) then $ dir = dir+separator endelse widget_control, topid, /sensitive return, file end